This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .fadein, | |
| .fadeout { | |
| -webkit-transition:all linear 0.5s; | |
| -moz-transition:all linear 0.5s; | |
| -o-transition:all linear 0.5s; | |
| transition:all linear 0.5s; | |
| } | |
| .fadein.ng-hide-remove, | |
| .fadeout.ng-hide-add.ng-hide-add-active { | |
| opacity: 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Usage: | |
| <input type="text" id="address" name="address" placeholder="Start Typing An Address" ng-model="address" details="placeDetails" googleplace /> | |
| Fiddle: http://jsfiddle.net/wholypantalones/5qtt1f8g/ | |
| */ | |
| //controller | |
| $scope.$watch('placeDetails', function() { | |
| angular.forEach($scope.placeDetails.address_components,function(val,key) { | |
| if(val.types[0] == "locality") { | |
| $scope.city = val.short_name; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* usage: | |
| $scope.thing = $scope.myObject.thing2[$scope.findIndex($scope.myObject.thing2,'attr',$scope.variable)]; | |
| > $scope.thing = $scope.myObject.thing2[i]; | |
| */ | |
| $scope.findIndex = function(arr,attr,val) { | |
| for (var i = 0; i < arr.length; i += 1) { | |
| if (arr[i][attr] === val) { | |
| return i; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* usage: | |
| dataService.getData("[GET|POST]","[url]",{data:object},{params:object},{timeout:object}).then(function(dataResponse) { | |
| $scope.item = dataResponse.data; | |
| }); | |
| */ | |
| /* Service inject 'httpService' as dependency | |
| angular.module('httpService', []).service('dataService', function ($http, $rootScope) { | |
| */ | |
| app.service('dataService', function($http,$rootScope) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //http://plnkr.co/edit/W1sp75P0PyOdZ834xvQu?p=preview | |
| Email: /^[_a-zA-Z0-9]+(\.[_a-zA-Z0-9]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-z]{2,4})$/ | |
| Postal Code: /^(\d{5}(-\d{4})?|[A-Z]\d[A-Z] *\d[A-Z]\d)$/ | |
| Credit Card: (/^5[1-5]/.test(value)) ? "Mastercard" : (/^4/.test(value)) ? "Visa" : (/^3[47]/.test(value)) ? 'American Express' : (/^6011|65|64[4-9]|622(1(2[6-9]|[3-9]\d)|[2-8]\d{2}|9([01]\d|2[0-5]))/.test(value)) ? 'Discover' : undefined; | |
| Allow Numbers Only: /[^\d]+/g | |
| Replace Whitespace: /[\W_]+/g |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //<input capitalize> | |
| app.directive('capitalize', function() { | |
| return { | |
| require: 'ngModel', | |
| link: function(scope, element, attrs, modelCtrl) { | |
| var capitalize = function(inputValue) { | |
| if(inputValue == undefined) inputValue = ''; | |
| var capitalized = inputValue.toUpperCase(); // change to .charAt(0).toUpperCase() for actual capitalize | |
| if(capitalized !== inputValue) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* usage: | |
| <div> {{somedata | killcaps}}</div> | |
| <select ng-model="countryCd" ng-options="c.countryCode as c.countryName | killcaps for c in countries"></select> | |
| */ | |
| app.filter('killcaps', function() { | |
| return function (killcaps) { | |
| var newValue = killcaps.replace(/_/g," ").replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}); | |
| return newValue; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Given a query string "?to=email&why=because&first=John&Last=smith" | |
| // getUrlVar("to") will return "email" | |
| // getUrlVar("last") will return "smith" | |
| // Slightly more concise and improved version based on http://www.jquery4u.com/snippets/url-parameters-jquery/ | |
| function getUrlVar(key){ | |
| var result = new RegExp(key + "=([^&]*)", "i").exec(window.location.search); | |
| return result && unescape(result[1]) || ""; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //this will default to the first option of nothing is selected or the selected option is removed | |
| $("body").on("change", "#chosen-select", function() { | |
| if($(this).val() === null) { | |
| $(this).find("option:first").prop("selected", true).trigger("chosen:updated"); | |
| // or $(this).find("option[value=thing]").prop("selected", true).trigger("chosen:updated"); | |
| } else { | |
| $(this).find("option:first").prop("selected", false).trigger("chosen:updated"); | |
| // or $(this).find("option[value=thing]").prop("selected", false).trigger("chosen:updated"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // usage {{countSeats(table.seats)}} | |
| // fiddle http://jsfiddle.net/wholypantalones/vCMEM/1/ | |
| $scope.countSeats = function(seatsObj) { | |
| if(typeof(seatsObj) !== "undefined") { | |
| return Object.keys(seatsObj).length; | |
| } // prevents "Error while interpolating" | |
| }; // in dom | |
| angular.forEach($scope.tables, function(val,key) { |