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
/*** | |
* The following functionality is a custom-based poly-fill placeholder for AngularJS | |
* @example <input id="weight" name="weight" type="number" defaulttext="enter your weight" | |
* min="50" max="500" required /> | |
* For browsers lower than IE 10 the in-built placeholder functionality is used, otherwise | |
* the poly-fill is used | |
*/ | |
app.directive('defaulttext', function($timeout){ | |
if (!$.browser.msie || $.browser.version >= 10) { | |
return { |
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
/** | |
* General-purpose Event binding. Bind any event not natively supported by | |
* Angular Pass an object with keynames for events to ng-event Allows $event | |
* object and $params object to be passed | |
* | |
* @example <input ng-event="{ focus : 'counter++', blur : 'someCallback()' }"> | |
* @example <input ng-event="{ myCustomEvent : 'myEventHandler($event, | |
* $params)'}"> | |
* | |
* @param ng-event |
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
/** | |
* General-purpose validator for ngModel. angular.js comes with several built-in | |
* validation mechanism for input fields (ngRequired, ngPattern etc.) but using | |
* an arbitrary validation function requires creation of a custom formatters and / | |
* or parsers. The ng-validate directive makes it easy to use any function(s) | |
* defined in scope as a validator function(s). A validator function will | |
* trigger validation on both model and input changes. | |
* | |
* @example <input ng-validate=" 'myValidatorFunction($value)' "> | |
* @example <input ng-validate="{ foo : '$value > anotherModel', bar : |
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
app.directive('ng-numeric', function($log) { | |
return { | |
require: 'ngModel', | |
link: function (scope, element, attr, ngModelCtrl) { | |
function fromUser(text) { | |
var transformedInput = text.replace(/[^0-9]/g, ''); | |
$log.info(transformedInput); | |
if(transformedInput !== text) { | |
ngModelCtrl.$setViewValue(transformedInput); | |
ngModelCtrl.$render(); |
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
'use strict'; | |
// Ordinal Number Filter | |
// --------------------- | |
// This filter takes a number and returns its ordinal value | |
// i.e. 1 -> 1st, 2 -> 2nd, etc. | |
// h/t http://ecommerce.shopify.com/c/ecommerce-design/t/ordinal-number-in-javascript-1st-2nd-3rd-4th-29259 | |
angular.module('ordinal', []).filter('ordinal', function() { |
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
var getUrlVars = function () { | |
var vars = [], hash, $href, hashes, i; | |
$href = window.location.href; | |
hashes = $href.slice($href.indexOf('?') + 1).split('&'); | |
for (i = 0; i < hashes.length; i += 1) { | |
hash = hashes[i].split('='); | |
vars.push(hash[0]); | |
vars[hash[0]] = hash[1]; | |
} | |
return vars; |
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
var randomColor = function () { | |
return '#' + ('00000' + (Math.random() * 16777216 << 0).toString(16)).substr(-6); | |
}; |
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
var uuid = function () { | |
var mask = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'; | |
return (function (mask) { | |
return mask.replace(/[xy]/g, function (c) { | |
var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8); | |
return v.toString(16); | |
}); | |
}(mask)); | |
} |
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
/** | |
* The following function does a top-down recursive decent on a json tree to | |
* find an element with-in structure | |
* | |
* @param value -value to retrieve | |
* @param jObj -json object to traverse | |
* @param deep - deep traversal | |
* @return JsonElement if found or null if element not found | |
*/ | |
public JsonElement get(String value, JsonObject jObj, boolean deep) { |
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
/** | |
(c) Ferron Hanse 2012 | |
https://github.com/ferronrsmith/anuglarjs-jasmine-matchers | |
Released under the MIT license | |
**/ | |
/*jslint nomen : true*/ | |
/*jslint bitwise : true*/ | |
/*global describe, beforeEach, inject, module, angular, document, it, expect, $, jasmine, toJson */ |
OlderNewer