This file contains 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
myApp.directive('capitalizeFirst', function($parse) { | |
return { | |
require: 'ngModel', | |
link: function(scope, element, attrs, modelCtrl) { | |
var capitalize = function(inputValue) { | |
if (inputValue === undefined) { inputValue = ''; } | |
var capitalized = inputValue.charAt(0).toUpperCase() + | |
inputValue.substring(1); | |
if(capitalized !== inputValue) { | |
modelCtrl.$setViewValue(capitalized); |
This file contains 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
angular.module('Scope.safeApply', []) | |
.run(['$rootScope', function ($rootScope) { | |
$rootScope.$safeApply = function () { | |
var fn, phase = this.$root.$$phase; | |
if (arguments.length == 1) { | |
fn = arguments[0]; | |
} else { |
This file contains 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
Array.prototype.binarySearch = function(find, comparator) { | |
var low = 0, high = this.length - 1, | |
i, comparison; | |
while (low <= high) { | |
i = Math.floor((low + high) / 2); | |
comparison = comparator(this[i], find); | |
if (comparison < 0) { low = i + 1; continue; }; | |
if (comparison > 0) { high = i - 1; continue; }; | |
return i; | |
} |
NewerOlder