Browse files

Bumped to v0.2.1 since lots of people are complaining about bugs in t…

…he date directive that are actually fixed.
  • Loading branch information...
1 parent e417a52 commit 051fd984c9fa541fe61105e7f1d45fd83a212b0a @petebacondarwin petebacondarwin committed Sep 19, 2012
Showing with 1,120 additions and 1,076 deletions.
  1. +69 −65 build/angular-ui-ieshiv.js
  2. +2 −2 build/angular-ui-ieshiv.min.js
  3. +2 −3 build/angular-ui.css
  4. +1,044 −1,003 build/angular-ui.js
  5. +2 −2 build/angular-ui.min.js
  6. +1 −1 package.json
View
134 build/angular-ui-ieshiv.js
@@ -1,84 +1,88 @@
/**
* AngularUI - The companion suite for AngularJS
- * @version v0.2.0 - 2012-08-06
+ * @version v0.2.1 - 2012-09-19
* @link http://angular-ui.github.com
* @license MIT License, http://www.opensource.org/licenses/MIT
*/
// READ: http://docs-next.angularjs.org/guide/ie
-(function(exports){
-
+(function (exports) {
+
var debug = window.ieShivDebug || false;
-
- var getIE = function() {
- // Returns the version of Internet Explorer or a -1
- // (indicating the use of another browser).
- var rv = -1; // Return value assumes failure.
- if (navigator.appName == 'Microsoft Internet Explorer') {
- var ua = navigator.userAgent;
- var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
- if (re.exec(ua) != null) {
- rv = parseFloat( RegExp.$1 );
- }
- }
- return rv;
+
+ var getIE = function () {
+ // Returns the version of Internet Explorer or a -1
+ // (indicating the use of another browser).
+ var rv = -1; // Return value assumes failure.
+ if (navigator.appName === 'Microsoft Internet Explorer') {
+ var ua = navigator.userAgent;
+ var re = new RegExp("MSIE ([0-9]{1,}[\\.0-9]{0,})");
+ if (re.exec(ua) !== null) {
+ rv = parseFloat(RegExp.$1);
+ }
+ }
+ return rv;
};
- var toCustomElements = function(str,delim) {
- var result = [];
- var dashed = str.replace(/([A-Z])/g, function($1) { return " "+$1.toLowerCase();} );
- var tokens = dashed.split(' ');
- var ns = tokens[0];
- var dirname = tokens.slice(1).join('-');
-
- // this is finite list and it seemed senseless to create a custom method
- result.push(ns + ":" + dirname);
- result.push(ns + "-" + dirname);
- result.push("x-" + ns + "-" + dirname);
- result.push("data-" + ns + "-" + dirname);
- return result;
+ var toCustomElements = function (str, delim) {
+ var result = [];
+ var dashed = str.replace(/([A-Z])/g, function ($1) {
+ return " " + $1.toLowerCase();
+ });
+ var tokens = dashed.split(' ');
+ var ns = tokens[0];
+ var dirname = tokens.slice(1).join('-');
+
+ // this is finite list and it seemed senseless to create a custom method
+ result.push(ns + ":" + dirname);
+ result.push(ns + "-" + dirname);
+ result.push("x-" + ns + "-" + dirname);
+ result.push("data-" + ns + "-" + dirname);
+ return result;
};
- var shiv = function() {
- // TODO: unfortunately, angular is not exposing these in 'ng' module
- var tags = [ 'ngInclude', 'ngPluralize', 'ngView' ]; // angular specific,
-
- // TODO: unfortunately, angular does not expose module names, it is a simple change to angular's loader.js
- // however, not sure if something happens when referencing them, so maybe an OK thing.
-
- var moduleNames = window.myAngularModules || []; // allow user to inject their own directives
- moduleNames.push('ui.directives');
-
- if(debug) console.log('moduleNames', moduleNames);
- for(var k = 0, mlen = moduleNames.length; k < mlen; k++) {
- var modules = angular.module(moduleNames[k]); // will throw runtime exception
- angular.forEach(modules._invokeQueue, function(item) {
- // only allow directives
- if(item[1] === "directive") {
- var dirname = item[2][0];
- tags.push(dirname);
- } else {
- if(debug) console.log("skipping",item[1], item[2][0]);
- }
- });
- }
-
- if(debug) console.log("tags found", tags);
- for(var i = 0, tlen = tags.length; i < tlen; i++) {
- if(debug) console.log("tag",tags[i]);
- var customElements = toCustomElements(tags[i],':');
- for(var j = 0, clen = customElements.length; j < clen; j++) {
- var customElement = customElements[j];
- if(debug) console.log("shivving",customElement);
- document.createElement(customElement);
- }
+ var shiv = function () {
+ // TODO: unfortunately, angular is not exposing these in 'ng' module
+ var tags = [ 'ngInclude', 'ngPluralize', 'ngView', 'ngSwitch' ]; // angular specific,
+
+ // TODO: unfortunately, angular does not expose module names, it is a simple change to angular's loader.js
+ // however, not sure if something happens when referencing them, so maybe an OK thing.
+
+ var moduleNames = window.myAngularModules || []; // allow user to inject their own directives
+ moduleNames.push('ui.directives');
+
+ if (debug) console.log('moduleNames', moduleNames);
+ function pushDirectives(item) {
+ // only allow directives
+ if (item[1] === "directive") {
+ var dirname = item[2][0];
+ tags.push(dirname);
+ } else {
+ if (debug) console.log("skipping", item[1], item[2][0]);
+ }
+ }
+
+ for (var k = 0, mlen = moduleNames.length; k < mlen; k++) {
+ var modules = angular.module(moduleNames[k]); // will throw runtime exception
+ angular.forEach(modules._invokeQueue, pushDirectives);
+ }
+
+ if (debug) console.log("tags found", tags);
+ for (var i = 0, tlen = tags.length; i < tlen; i++) {
+ if (debug) console.log("tag", tags[i]);
+ var customElements = toCustomElements(tags[i], ':');
+ for (var j = 0, clen = customElements.length; j < clen; j++) {
+ var customElement = customElements[j];
+ if (debug) console.log("shivving", customElement);
+ document.createElement(customElement);
+ }
}
};
-
+
var ieVersion = getIE();
-
+
if ((ieVersion > -1 && ieVersion < 9) || debug) {
shiv();
}
-
+
})(window);
View
4 build/angular-ui-ieshiv.min.js
@@ -1,7 +1,7 @@
/**
* AngularUI - The companion suite for AngularJS
- * @version v0.2.0 - 2012-08-06
+ * @version v0.2.1 - 2012-09-19
* @link http://angular-ui.github.com
* @license MIT License, http://www.opensource.org/licenses/MIT
*/
-(function(a){var b=window.ieShivDebug||!1,c=function(){var a=-1;if(navigator.appName=="Microsoft Internet Explorer"){var b=navigator.userAgent,c=new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})");c.exec(b)!=null&&(a=parseFloat(RegExp.$1))}return a},d=function(a,b){var c=[],d=a.replace(/([A-Z])/g,function(a){return" "+a.toLowerCase()}),e=d.split(" "),f=e[0],g=e.slice(1).join("-");return c.push(f+":"+g),c.push(f+"-"+g),c.push("x-"+f+"-"+g),c.push("data-"+f+"-"+g),c},e=function(){var a=["ngInclude","ngPluralize","ngView"],c=window.myAngularModules||[];c.push("ui.directives"),b&&console.log("moduleNames",c);for(var e=0,f=c.length;e<f;e++){var g=angular.module(c[e]);angular.forEach(g._invokeQueue,function(c){if(c[1]==="directive"){var d=c[2][0];a.push(d)}else b&&console.log("skipping",c[1],c[2][0])})}b&&console.log("tags found",a);for(var h=0,i=a.length;h<i;h++){b&&console.log("tag",a[h]);var j=d(a[h],":");for(var k=0,l=j.length;k<l;k++){var m=j[k];b&&console.log("shivving",m),document.createElement(m)}}},f=c();(f>-1&&f<9||b)&&e()})(window);
+(function(e){var t=window.ieShivDebug||!1,n=function(){var e=-1;if(navigator.appName==="Microsoft Internet Explorer"){var t=navigator.userAgent,n=new RegExp("MSIE ([0-9]{1,}[\\.0-9]{0,})");n.exec(t)!==null&&(e=parseFloat(RegExp.$1))}return e},r=function(e,t){var n=[],r=e.replace(/([A-Z])/g,function(e){return" "+e.toLowerCase()}),i=r.split(" "),s=i[0],o=i.slice(1).join("-");return n.push(s+":"+o),n.push(s+"-"+o),n.push("x-"+s+"-"+o),n.push("data-"+s+"-"+o),n},i=function(){function i(n){if(n[1]==="directive"){var r=n[2][0];e.push(r)}else t&&console.log("skipping",n[1],n[2][0])}var e=["ngInclude","ngPluralize","ngView","ngSwitch"],n=window.myAngularModules||[];n.push("ui.directives"),t&&console.log("moduleNames",n);for(var s=0,o=n.length;s<o;s++){var u=angular.module(n[s]);angular.forEach(u._invokeQueue,i)}t&&console.log("tags found",e);for(var a=0,f=e.length;a<f;a++){t&&console.log("tag",e[a]);var l=r(e[a],":");for(var c=0,h=l.length;c<h;c++){var p=l[c];t&&console.log("shivving",p),document.createElement(p)}}},s=n();(s>-1&&s<9||t)&&i()})(window);
View
5 build/angular-ui.css
@@ -1,5 +1,3 @@
-
-
/**
* import components to builds angular-ui.css
*/
@@ -43,4 +41,5 @@
.ui-match {
background: yellow;
-}
+}
+
View
2,047 build/angular-ui.js
@@ -1,584 +1,590 @@
-/**
- * AngularUI - The companion suite for AngularJS
- * @version v0.2.0 - 2012-08-06
- * @link http://angular-ui.github.com
- * @license MIT License, http://www.opensource.org/licenses/MIT
- */
-
-
-angular.module('ui.config', []).value('ui.config', {});
-angular.module('ui.filters', ['ui.config']);
-angular.module('ui.directives', ['ui.config']);
-angular.module('ui', ['ui.filters', 'ui.directives', 'ui.config']);
-
-
-/**
- * Animates the injection of new DOM elements by simply creating the DOM with a class and then immediately removing it
- * Animations must be done using CSS3 transitions, but provide excellent flexibility
- *
- * @todo Add proper support for animating out
- * @param [options] {mixed} Can be an object with multiple options, or a string with the animation class
- * class {string} the CSS class(es) to use. For example, 'ui-hide' might be an excellent alternative class.
- * @example <li ng-repeat="item in items" ui-animate=" 'ui-hide' ">{{item}}</li>
- */
-angular.module('ui.directives').directive('uiAnimate', ['ui.config', '$timeout', function(uiConfig, $timeout) {
- var options = {};
- if (angular.isString(uiConfig.animate)) {
- options['class'] = uiConfig.animate;
- } else if (uiConfig.animate) {
- options = uiConfig.animate;
- }
- return {
- restrict: 'A', // supports using directive as element, attribute and class
- link: function($scope, element, attrs) {
- var opts = {};
- if (attrs.uiAnimate) {
- opts = $scope.$eval(attrs.uiAnimate);
- if (angular.isString(opts)) {
- opts = {'class': opts};
- }
- }
- opts = angular.extend({'class': 'ui-animate'}, options, opts);
-
- element.addClass(opts['class']);
- $timeout(function(){
- element.removeClass(opts['class']);
- }, false);
- }
- };
-}]);
-
-
-/*global angular, CodeMirror, Error*/
-/**
- * Binds a CodeMirror widget to a <textarea> element.
- */
-angular.module('ui.directives').directive('uiCodemirror', ['ui.config', '$parse', function (uiConfig, $parse) {
- 'use strict';
-
- uiConfig.codemirror = uiConfig.codemirror || {};
- return {
- require: 'ngModel',
- link: function (scope, elm, attrs, ngModel) {
- // Only works on textareas
- if ( !elm.is('textarea') ) {
- throw new Error('ui-codemirror can only be applied to a textarea element');
- }
-
- var codemirror;
- // This is the method that we use to get the value of the ui-codemirror attribute expression.
- var uiCodemirrorGet = $parse(attrs.uiCodemirror);
- // This method will be called whenever the code mirror widget content changes
- var onChangeHandler = function (ed) {
- // We only update the model if the value has changed - this helps get around a little problem where $render triggers a change despite already being inside a $apply loop.
- var newValue = ed.getValue();
- if ( newValue !== ngModel.$viewValue ) {
- ngModel.$setViewValue(newValue);
- scope.$apply();
- }
- };
- // Create and wire up a new code mirror widget (unwiring a previous one if necessary)
- var updateCodeMirror = function(options) {
- // Merge together the options from the uiConfig and the attribute itself with the onChange event above.
- options = angular.extend({}, options, uiConfig.codemirror);
-
- // We actually want to run both handlers if the user has provided their own onChange handler.
- var userOnChange = options.onChange;
- if ( userOnChange ) {
- options.onChange = function(ed) {
- onChangeHandler(ed);
- userOnChange(ed);
- };
- } else {
- options.onChange = onChangeHandler;
- }
-
- // If there is a codemirror widget for this element already then we need to unwire if first
- if ( codemirror ) {
- codemirror.toTextArea();
- }
- // Create the new codemirror widget
- codemirror = CodeMirror.fromTextArea(elm[0], options);
- };
-
- // Initialize the code mirror widget
- updateCodeMirror(uiCodemirrorGet());
-
- // Now watch to see if the codemirror attribute gets updated
- scope.$watch(uiCodemirrorGet, updateCodeMirror, true);
-
- // CodeMirror expects a string, so make sure it gets one.
- // This does not change the model.
- ngModel.$formatters.push(function(value) {
- if(angular.isUndefined(value) || value === null) {
- return '';
- }
- else if (angular.isObject(value) || angular.isArray(value)) {
- throw new Error('ui-codemirror cannot use an object or an array as a model');
- }
- return value;
- });
-
- // Override the ngModelController $render method, which is what gets called when the model is updated.
- // This takes care of the synchronizing the codeMirror element with the underlying model, in the case that it is changed by something else.
- ngModel.$render = function() {
- codemirror.setValue(ngModel.$viewValue);
- };
- }
- };
-}]);
-
-/*
- Gives the ability to style currency based on its sign.
-*/
- angular.module('ui.directives').directive('uiCurrency', ['ui.config','currencyFilter' , function(uiConfig, currencyFilter) {
- var options = {
- pos: 'ui-currency-pos',
- neg: 'ui-currency-neg',
- zero: 'ui-currency-zero'
- };
- if (uiConfig.currency) {
- angular.extend(options, uiConfig.currency);
- }
- return {
- restrict: 'EAC',
- require: 'ngModel',
- link: function(scope, element, attrs, controller) {
- var opts, // instance-specific options
- renderview,
- value;
-
- opts = angular.extend({}, options, scope.$eval(attrs.uiCurrency));
-
- renderview = function(viewvalue) {
- var num;
- num = viewvalue * 1;
- if (num > 0) {
- element.addClass(opts.pos);
- } else {
- element.removeClass(opts.pos);
- }
- if (num < 0) {
- element.addClass(opts.neg);
- } else {
- element.removeClass(opts.neg);
- }
- if (num === 0) {
- element.addClass(opts.zero);
- } else {
- element.removeClass(opts.zero);
- }
- if (viewvalue === '') {
- element.text('');
- } else {
- element.text(currencyFilter(num, opts.symbol));
- }
- return true;
- };
-
- controller.$render = function() {
- value = controller.$viewValue;
- element.val(value);
- renderview(value);
- };
-
- }
- };
- }]);
-
-/*
- jQuery UI Datepicker plugin wrapper
-
- @param [ui-date] {object} Options to pass to $.fn.datepicker() merged onto ui.config
-*/
-
-angular.module('ui.directives').directive('uiDate', [
- 'ui.config', function(uiConfig) {
- var options;
- options = {};
- if (uiConfig.date != null) {
- angular.extend(options, uiConfig.date);
- }
- return {
- require: '?ngModel',
- link: function(scope, element, attrs, controller) {
- var opts, updateModel, usersOnSelectHandler;
- opts = angular.extend({}, options, scope.$eval(attrs.uiDate));
- /* If we have a controller (i.e. ngModelController) then wire it up
- */
-
- if (controller != null) {
- updateModel = function(value, picker) {
- return scope.$apply(function() {
- return controller.$setViewValue(element.datepicker("getDate"));
- });
- };
- if (opts.onSelect != null) {
- /* Caller has specified onSelect to call this as well as updating the model
- */
-
- usersOnSelectHandler = opts.onSelect;
- opts.onSelect = function(value, picker) {
- updateModel(value);
- return usersOnSelectHandler(value, picker);
- };
- } else {
- /* No onSelect already specified so just update the model
- */
-
- opts.onSelect = updateModel;
- }
- /* Update the date picker when the model changes
- */
-
- controller.$render = function() {
- var date;
- date = controller.$viewValue;
- if (!(date instanceof Date)) {
- date = new Date(date);
- }
- return element.datepicker("setDate", date);
- };
- }
- /* Create the datepicker widget
- */
-
- return element.datepicker(opts);
- }
- };
- }
-]);
-
-
-/**
- * General-purpose Event binding. Bind any event not natively supported by Angular
- * Pass an object with keynames for events to ui-event
- * Allows $event object and $params object to be passed
- *
- * @example <input ui-event="{ focus : 'counter++', blur : 'someCallback()' }">
- * @example <input ui-event="{ myCustomEvent : 'myEventHandler($event, $params)'}">
- *
- * @param ui-event {string|object literal} The event to bind to as a string or a hash of events with their callbacks
- */
-angular.module('ui.directives').directive('uiEvent', ['$parse',
-function($parse) {
- return function(scope, elm, attrs) {
- var events = scope.$eval(attrs.uiEvent);
- angular.forEach(events, function(uiEvent, eventName){
- var fn = $parse(uiEvent);
- elm.bind(eventName, function(evt) {
- var params = Array.prototype.slice.call(arguments);
- //Take out first paramater (event object);
- params = params.splice(1);
- scope.$apply(function() {
- fn(scope, {$event: evt, $params: params})
- });
- });
- });
- };
-}]);
-
-/*
- * Defines the ui-if tag. This removes/adds an element from the dom depending on a condition
- * Originally created by @tigbro, for the @jquery-mobile-angular-adapter
- * https://github.com/tigbro/jquery-mobile-angular-adapter
- */
-angular.module('ui.directives').directive('uiIf', [function() {
- return {
- transclude: 'element',
- priority: 1000,
- terminal: true,
- restrict: 'A',
- compile: function(element, attr, linker) {
- return function(scope, iterStartElement, attr) {
- iterStartElement[0].doNotMove = true;
- var expression = attr.uiIf;
- var lastElement;
- var lastScope;
- scope.$watch(expression, function(newValue) {
- if (lastElement) {
- lastElement.remove();
- lastElement = null;
- }
- lastScope && lastScope.$destroy();
- if (newValue) {
- lastScope = scope.$new();
- linker(lastScope, function(clone) {
- lastElement = clone;
- iterStartElement.after(clone);
- });
- }
- // Note: need to be parent() as jquery cannot trigger events on comments
- // (angular creates a comment node when using transclusion, as ng-repeat does).
- iterStartElement.parent().trigger("$childrenChanged");
- });
- };
- }
- };
-}]);
-
-/**
- * General-purpose jQuery wrapper. Simply pass the plugin name as the expression.
- *
- * It is possible to specify a default set of parameters for each jQuery plugin.
- * Under the jq key, namespace each plugin by that which will be passed to ui-jq.
- * Unfortunately, at this time you can only pre-define the first parameter.
- * @example { jq : { datepicker : { showOn:'click' } } }
- *
- * @param ui-jq {string} The $elm.[pluginName]() to call.
- * @param [ui-options] {mixed} Expression to be evaluated and passed as options to the function
- * Multiple parameters can be separated by commas
- * Set {ngChange:false} to disable passthrough support for change events ( since angular watches 'input' events, not 'change' events )
- *
- * @example <input ui-jq="datepicker" ui-options="{showOn:'click'},secondParameter,thirdParameter">
- */
-angular.module('ui.directives').directive('uiJq', ['ui.config', function(uiConfig) {
- return {
- restrict: 'A',
- compile: function(tElm, tAttrs) {
- if (!angular.isFunction(tElm[tAttrs.uiJq])) {
- throw new Error('ui-jq: The "'+tAttrs.uiJq+'" function does not exist');
- return;
- }
- var options = uiConfig['jq'] && uiConfig['jq'][tAttrs.uiJq];
- return function (scope, elm, attrs) {
- var linkOptions = [], ngChange = 'change';
-
- if (attrs.uiOptions) {
- linkOptions = scope.$eval('['+attrs.uiOptions+']');
- if (angular.isObject(options) && angular.isObject(linkOptions[0])) {
- linkOptions[0] = angular.extend(options, linkOptions[0]);
- }
- } else if (options) {
- linkOptions = [options];
- }
- if (attrs.ngModel && elm.is('select,input,textarea')) {
- if (linkOptions && angular.isObject(linkOptions[0]) && linkOptions[0].ngChange !== undefined) {
- ngChange = linkOptions[0].ngChange;
- }
- ngChange && elm.on(ngChange, function(){
- elm.trigger('input');
- });
- }
- elm[attrs.uiJq].apply(elm, linkOptions);
- };
- }
- };
-}]);
-
-
-/**
- * Bind one or more handlers to particular keys or their combination
- * @param hash {mixed} keyBindings Can be an object or string where keybinding expression of keys or keys combinations and AngularJS Exspressions are set. Object syntax: "{ keys1: expression1 [, keys2: expression2 [ , ... ]]}". String syntax: ""expression1 on keys1 [ and expression2 on keys2 [ and ... ]]"". Expression is an AngularJS Expression, and key(s) are dash-separated combinations of keys and modifiers (one or many, if any. Order does not matter). Supported modifiers are 'ctrl', 'shift', 'alt' and key can be used either via its keyCode (13 for Return) or name. Named keys are 'backspace', 'tab', 'enter', 'esc', 'space', 'pageup', 'pagedown', 'end', 'home', 'left', 'up', 'right', 'down', 'insert', 'delete'.
- * @example <input ui-keypress="{enter:'x = 1', 'ctrl-shift-space':'foo()', 'shift-13':'bar()'}" /> <input ui-keypress="foo = 2 on ctrl-13 and bar('hello') on shift-esc" />
- **/
-angular.module('ui.directives').directive('uiKeypress', ['$parse', function($parse){
- return {
- link: function(scope, elm, attrs) {
- var keysByCode = {
- 8: 'backspace',
- 9: 'tab',
- 13: 'enter',
- 27: 'esc',
- 32: 'space',
- 33: 'pageup',
- 34: 'pagedown',
- 35: 'end',
- 36: 'home',
- 37: 'left',
- 38: 'up',
- 39: 'right',
- 40: 'down',
- 45: 'insert',
- 46: 'delete'
- };
-
- var params, paramsParsed, expression, keys, combinations = [];
- try {
- params = scope.$eval(attrs.uiKeypress);
- paramsParsed = true;
- } catch (error) {
- params = attrs.uiKeypress.split(/\s+and\s+/i);
- paramsParsed = false;
- }
-
- // Prepare combinations for simple checking
- angular.forEach(params, function(v, k) {
- var combination = {};
- if(paramsParsed) {
- // An object passed
- combination.expression = $parse(v);
- combination.keys = k;
- } else {
- // A string passed
- v = v.split(/\s+on\s+/i);
- combination.expression = $parse(v[0]);
- combination.keys = v[1];
- }
-
- keys = {};
- angular.forEach(combination.keys.split('-'), function(value) {
- keys[value] = true;
- });
- combination.keys = keys;
- combinations.push(combination);
- });
-
- // Check only mathcing of pressed keys one of the conditions
- elm.bind('keydown', function(event) {
- // No need to do that inside the cycle
- var altPressed = event.metaKey || event.altKey;
- var ctrlPressed = event.ctrlKey;
- var shiftPressed = event.shiftKey;
-
- // Iterate over prepared combinations
- angular.forEach(combinations, function(combination) {
-
- var mainKeyPressed = (combination.keys[keysByCode[event.keyCode]] || combination.keys[event.keyCode.toString()]) || false;
-
- var altRequired = combination.keys.alt || false;
- var ctrlRequired = combination.keys.ctrl || false;
- var shiftRequired = combination.keys.shift || false;
-
- if( mainKeyPressed &&
- ( altRequired == altPressed ) &&
- ( ctrlRequired == ctrlPressed ) &&
- ( shiftRequired == shiftPressed )
- ) {
- // Run the function
- scope.$apply(function(){
- combination.expression(scope, { '$event' : event });
- });
- }
- });
- });
- }
- };
-}]);
-
-(function() {
- var app = angular.module('ui.directives');
-
- //Setup map events from a google map object to trigger on a given element too,
- //then we just use ui-event to catch events from an element
- function bindMapEvents(scope, eventsStr, googleObject, element) {
- angular.forEach(eventsStr.split(' '), function(eventName) {
- var $event = { type: 'map-'+eventName };
- google.maps.event.addListener(googleObject, eventName, function(evt) {
- element.trigger(angular.extend({}, $event, evt));
- //We create an $apply if it isn't happening. we need better support for this
- //We don't want to use timeout because tons of these events fire at once,
- //and we only need one $apply
- if (!scope.$$phase) scope.$apply();
- });
- });
- }
-
- app.directive('uiMap',
- ['ui.config', '$parse', function(uiConfig, $parse) {
-
- var mapEvents = 'bounds_changed center_changed click dblclick drag dragend '+
- 'dragstart heading_changed idle maptypeid_changed mousemove mouseout '+
- 'mouseover projection_changed resize rightclick tilesloaded tilt_changed '+
- 'zoom_changed';
- var options = uiConfig.map || {};
-
- return {
- restrict: 'A',
- //doesn't work as E for unknown reason
- link: function(scope, elm, attrs) {
- var opts = angular.extend({}, options, scope.$eval(attrs.uiOptions));
- var map = new google.maps.Map(elm[0], opts);
- var model = $parse(attrs.uiMap);
-
- //Set scope variable for the map
- model.assign(scope, map);
-
- bindMapEvents(scope, mapEvents, map, elm);
- }
- };
- }]);
-
- app.directive('uiMapInfoWindow',
- ['ui.config', '$parse', '$compile', function(uiConfig, $parse, $compile) {
-
- var infoWindowEvents = 'closeclick content_change domready '+
- 'position_changed zindex_changed';
- var options = uiConfig.mapInfoWindow || {};
-
- return {
- link: function(scope, elm, attrs) {
- var opts = angular.extend({}, options, scope.$eval(attrs.uiOptions));
- opts.content = elm[0];
- var model = $parse(attrs.uiMapInfoWindow);
- var infoWindow = model(scope);
-
- if (!infoWindow) {
- infoWindow = new google.maps.InfoWindow(opts);
- model.assign(scope, infoWindow);
- }
-
- bindMapEvents(scope, infoWindowEvents, infoWindow, elm);
-
- /* The info window's contents dont' need to be on the dom anymore,
- google maps has them stored. So we just replace the infowindow element
- with an empty div. (we don't just straight remove it from the dom because
- straight removing things from the dom can mess up angular) */
- elm.replaceWith('<div></div>');
-
- //Decorate infoWindow.open to $compile contents before opening
- var _open = infoWindow.open;
- infoWindow.open = function open(a1,a2,a3,a4,a5,a6) {
- $compile(elm.contents())(scope);
- _open.call(infoWindow, a1,a2,a3,a4,a5,a6);
- };
- }
- };
- }]);
-
- /*
- * Map overlay directives all work the same. Take map marker for example
- * <ui-map-marker="myMarker"> will $watch 'myMarker' and each time it changes,
- * it will hook up myMarker's events to the directive dom element. Then
- * ui-event will be able to catch all of myMarker's events. Super simple.
- */
- function mapOverlayDirective(directiveName, events) {
- app.directive(directiveName, [function() {
- return {
- restrict: 'A',
- link: function(scope, elm, attrs) {
- scope.$watch(attrs[directiveName], function(newObject) {
- bindMapEvents(scope, events, newObject, elm);
- });
- }
- };
- }]);
- };
-
- mapOverlayDirective('uiMapMarker',
- 'animation_changed click clickable_changed cursor_changed '+
- 'dblclick drag dragend draggable_changed dragstart flat_changed icon_changed '+
- 'mousedown mouseout mouseover mouseup position_changed rightclick '+
- 'shadow_changed shape_changed title_changed visible_changed zindex_changed');
-
- mapOverlayDirective('uiMapPolyline',
- 'click dblclick mousedown mousemove mouseout mouseover mouseup rightclick');
-
- mapOverlayDirective('uiMapPolygon',
- 'click dblclick mousedown mousemove mouseout mouseover mouseup rightclick');
-
- mapOverlayDirective('uiMapRectangle',
- 'bounds_changed click dblclick mousedown mousemove mouseout mouseover '+
- 'mouseup rightclick');
-
- mapOverlayDirective('uiMapCircle',
- 'center_changed click dblclick mousedown mousemove '+
- 'mouseout mouseover mouseup radius_changed rightclick');
-
- mapOverlayDirective('uiMapGroundOverlay',
- 'click dblclick');
-
-})();
+/**
+ * AngularUI - The companion suite for AngularJS
+ * @version v0.2.1 - 2012-09-19
+ * @link http://angular-ui.github.com
+ * @license MIT License, http://www.opensource.org/licenses/MIT
+ */
+
+
+angular.module('ui.config', []).value('ui.config', {});
+angular.module('ui.filters', ['ui.config']);
+angular.module('ui.directives', ['ui.config']);
+angular.module('ui', ['ui.filters', 'ui.directives', 'ui.config']);
+
+/**
+ * Animates the injection of new DOM elements by simply creating the DOM with a class and then immediately removing it
+ * Animations must be done using CSS3 transitions, but provide excellent flexibility
+ *
+ * @todo Add proper support for animating out
+ * @param [options] {mixed} Can be an object with multiple options, or a string with the animation class
+ * class {string} the CSS class(es) to use. For example, 'ui-hide' might be an excellent alternative class.
+ * @example <li ng-repeat="item in items" ui-animate=" 'ui-hide' ">{{item}}</li>
+ */
+angular.module('ui.directives').directive('uiAnimate', ['ui.config', '$timeout', function (uiConfig, $timeout) {
+ var options = {};
+ if (angular.isString(uiConfig.animate)) {
+ options['class'] = uiConfig.animate;
+ } else if (uiConfig.animate) {
+ options = uiConfig.animate;
+ }
+ return {
+ restrict: 'A', // supports using directive as element, attribute and class
+ link: function ($scope, element, attrs) {
+ var opts = {};
+ if (attrs.uiAnimate) {
+ opts = $scope.$eval(attrs.uiAnimate);
+ if (angular.isString(opts)) {
+ opts = {'class': opts};
+ }
+ }
+ opts = angular.extend({'class': 'ui-animate'}, options, opts);
+
+ element.addClass(opts['class']);
+ $timeout(function () {
+ element.removeClass(opts['class']);
+ }, 20, false);
+ }
+ };
+}]);
+
+
+/*global angular, CodeMirror, Error*/
+/**
+ * Binds a CodeMirror widget to a <textarea> element.
+ */
+angular.module('ui.directives').directive('uiCodemirror', ['ui.config', '$parse', function (uiConfig, $parse) {
+ 'use strict';
+
+ uiConfig.codemirror = uiConfig.codemirror || {};
+ return {
+ require: 'ngModel',
+ link: function (scope, elm, attrs, ngModel) {
+ // Only works on textareas
+ if (!elm.is('textarea')) {
+ throw new Error('ui-codemirror can only be applied to a textarea element');
+ }
+
+ var codemirror;
+ // This is the method that we use to get the value of the ui-codemirror attribute expression.
+ var uiCodemirrorGet = $parse(attrs.uiCodemirror);
+ // This method will be called whenever the code mirror widget content changes
+ var onChangeHandler = function (ed) {
+ // We only update the model if the value has changed - this helps get around a little problem where $render triggers a change despite already being inside a $apply loop.
+ var newValue = ed.getValue();
+ if (newValue !== ngModel.$viewValue) {
+ ngModel.$setViewValue(newValue);
+ scope.$apply();
+ }
+ };
+ // Create and wire up a new code mirror widget (unwiring a previous one if necessary)
+ var updateCodeMirror = function (options) {
+ // Merge together the options from the uiConfig and the attribute itself with the onChange event above.
+ options = angular.extend({}, options, uiConfig.codemirror);
+
+ // We actually want to run both handlers if the user has provided their own onChange handler.
+ var userOnChange = options.onChange;
+ if (userOnChange) {
+ options.onChange = function (ed) {
+ onChangeHandler(ed);
+ userOnChange(ed);
+ };
+ } else {
+ options.onChange = onChangeHandler;
+ }
+
+ // If there is a codemirror widget for this element already then we need to unwire if first
+ if (codemirror) {
+ codemirror.toTextArea();
+ }
+ // Create the new codemirror widget
+ codemirror = CodeMirror.fromTextArea(elm[0], options);
+ };
+
+ // Initialize the code mirror widget
+ updateCodeMirror(uiCodemirrorGet());
+
+ // Now watch to see if the codemirror attribute gets updated
+ scope.$watch(uiCodemirrorGet, updateCodeMirror, true);
+
+ // CodeMirror expects a string, so make sure it gets one.
+ // This does not change the model.
+ ngModel.$formatters.push(function (value) {
+ if (angular.isUndefined(value) || value === null) {
+ return '';
+ }
+ else if (angular.isObject(value) || angular.isArray(value)) {
+ throw new Error('ui-codemirror cannot use an object or an array as a model');
+ }
+ return value;
+ });
+
+ // Override the ngModelController $render method, which is what gets called when the model is updated.
+ // This takes care of the synchronizing the codeMirror element with the underlying model, in the case that it is changed by something else.
+ ngModel.$render = function () {
+ codemirror.setValue(ngModel.$viewValue);
+ };
+ }
+ };
+}]);
+/*
+ Gives the ability to style currency based on its sign.
+ */
+angular.module('ui.directives').directive('uiCurrency', ['ui.config', 'currencyFilter' , function (uiConfig, currencyFilter) {
+ var options = {
+ pos: 'ui-currency-pos',
+ neg: 'ui-currency-neg',
+ zero: 'ui-currency-zero'
+ };
+ if (uiConfig.currency) {
+ angular.extend(options, uiConfig.currency);
+ }
+ return {
+ restrict: 'EAC',
+ require: 'ngModel',
+ link: function (scope, element, attrs, controller) {
+ var opts, // instance-specific options
+ renderview,
+ value;
+
+ opts = angular.extend({}, options, scope.$eval(attrs.uiCurrency));
+
+ renderview = function (viewvalue) {
+ var num;
+ num = viewvalue * 1;
+ if (num > 0) {
+ element.addClass(opts.pos);
+ } else {
+ element.removeClass(opts.pos);
+ }
+ if (num < 0) {
+ element.addClass(opts.neg);
+ } else {
+ element.removeClass(opts.neg);
+ }
+ if (num === 0) {
+ element.addClass(opts.zero);
+ } else {
+ element.removeClass(opts.zero);
+ }
+ if (viewvalue === '') {
+ element.text('');
+ } else {
+ element.text(currencyFilter(num, opts.symbol));
+ }
+ return true;
+ };
+
+ controller.$render = function () {
+ value = controller.$viewValue;
+ element.val(value);
+ renderview(value);
+ };
+
+ }
+ };
+}]);
+
+/*global angular */
+/*
+ jQuery UI Datepicker plugin wrapper
+
+ @param [ui-date] {object} Options to pass to $.fn.datepicker() merged onto ui.config
+ */
+
+angular.module('ui.directives').directive('uiDate', ['ui.config', function (uiConfig) {
+ 'use strict';
+ var options;
+ options = {};
+ if (angular.isObject(uiConfig.date)) {
+ angular.extend(options, uiConfig.date);
+ }
+ return {
+ require:'?ngModel',
+ link:function (scope, element, attrs, controller) {
+ var getOptions = function () {
+ return angular.extend({}, uiConfig.date, scope.$eval(attrs.uiDate));
+ };
+ var initDateWidget = function () {
+ var opts = getOptions();
+
+ // If we have a controller (i.e. ngModelController) then wire it up
+ if (controller) {
+ var updateModel = function () {
+ scope.$apply(function () {
+ controller.$setViewValue(element.datepicker("getDate"));
+ });
+ };
+ if (opts.onSelect) {
+ // Caller has specified onSelect, so call this as well as updating the model
+ var userHandler = opts.onSelect;
+ opts.onSelect = function (value, picker) {
+ updateModel();
+ return userHandler(value, picker);
+ };
+ } else {
+ // No onSelect already specified so just update the model
+ opts.onSelect = updateModel;
+ }
+ // In case the user changes the text directly in the input box
+ element.bind('change', updateModel);
+
+ // Update the date picker when the model changes
+ controller.$render = function () {
+ var date = controller.$viewValue;
+ element.datepicker("setDate", date);
+ // Update the model if we received a string
+ if (angular.isString(date)) {
+ controller.$setViewValue(element.datepicker("getDate"));
+ }
+ };
+ }
+ // If we don't destroy the old one it doesn't update properly when the config changes
+ element.datepicker('destroy');
+ // Create the new datepicker widget
+ element.datepicker(opts);
+ // Force a render to override whatever is in the input text box
+ controller.$render();
+ };
+ // Watch for changes to the directives options
+ scope.$watch(getOptions, initDateWidget, true);
+ }
+ };
+}
+]);
+
+/**
+ * General-purpose Event binding. Bind any event not natively supported by Angular
+ * Pass an object with keynames for events to ui-event
+ * Allows $event object and $params object to be passed
+ *
+ * @example <input ui-event="{ focus : 'counter++', blur : 'someCallback()' }">
+ * @example <input ui-event="{ myCustomEvent : 'myEventHandler($event, $params)'}">
+ *
+ * @param ui-event {string|object literal} The event to bind to as a string or a hash of events with their callbacks
+ */
+angular.module('ui.directives').directive('uiEvent', ['$parse',
+ function ($parse) {
+ return function (scope, elm, attrs) {
+ var events = scope.$eval(attrs.uiEvent);
+ angular.forEach(events, function (uiEvent, eventName) {
+ var fn = $parse(uiEvent);
+ elm.bind(eventName, function (evt) {
+ var params = Array.prototype.slice.call(arguments);
+ //Take out first paramater (event object);
+ params = params.splice(1);
+ scope.$apply(function () {
+ fn(scope, {$event: evt, $params: params});
+ });
+ });
+ });
+ };
+ }]);
+
+/*
+ * Defines the ui-if tag. This removes/adds an element from the dom depending on a condition
+ * Originally created by @tigbro, for the @jquery-mobile-angular-adapter
+ * https://github.com/tigbro/jquery-mobile-angular-adapter
+ */
+angular.module('ui.directives').directive('uiIf', [function () {
+ return {
+ transclude: 'element',
+ priority: 1000,
+ terminal: true,
+ restrict: 'A',
+ compile: function (element, attr, linker) {
+ return function (scope, iterStartElement, attr) {
+ iterStartElement[0].doNotMove = true;
+ var expression = attr.uiIf;
+ var lastElement;
+ var lastScope;
+ scope.$watch(expression, function (newValue) {
+ if (lastElement) {
+ lastElement.remove();
+ lastElement = null;
+ }
+ if (lastScope) {
+ lastScope.$destroy();
+ lastScope = null;
+ }
+ if (newValue) {
+ lastScope = scope.$new();
+ linker(lastScope, function (clone) {
+ lastElement = clone;
+ iterStartElement.after(clone);
+ });
+ }
+ // Note: need to be parent() as jquery cannot trigger events on comments
+ // (angular creates a comment node when using transclusion, as ng-repeat does).
+ iterStartElement.parent().trigger("$childrenChanged");
+ });
+ };
+ }
+ };
+}]);
+/**
+ * General-purpose jQuery wrapper. Simply pass the plugin name as the expression.
+ *
+ * It is possible to specify a default set of parameters for each jQuery plugin.
+ * Under the jq key, namespace each plugin by that which will be passed to ui-jq.
+ * Unfortunately, at this time you can only pre-define the first parameter.
+ * @example { jq : { datepicker : { showOn:'click' } } }
+ *
+ * @param ui-jq {string} The $elm.[pluginName]() to call.
+ * @param [ui-options] {mixed} Expression to be evaluated and passed as options to the function
+ * Multiple parameters can be separated by commas
+ * Set {ngChange:false} to disable passthrough support for change events ( since angular watches 'input' events, not 'change' events )
+ *
+ * @example <input ui-jq="datepicker" ui-options="{showOn:'click'},secondParameter,thirdParameter">
+ */
+angular.module('ui.directives').directive('uiJq', ['ui.config', function (uiConfig) {
+ return {
+ restrict: 'A',
+ compile: function (tElm, tAttrs) {
+ if (!angular.isFunction(tElm[tAttrs.uiJq])) {
+ throw new Error('ui-jq: The "' + tAttrs.uiJq + '" function does not exist');
+ }
+ var options = uiConfig.jq && uiConfig.jq[tAttrs.uiJq];
+ return function (scope, elm, attrs) {
+ var linkOptions = [], ngChange = 'change';
+
+ if (attrs.uiOptions) {
+ linkOptions = scope.$eval('[' + attrs.uiOptions + ']');
+ if (angular.isObject(options) && angular.isObject(linkOptions[0])) {
+ linkOptions[0] = angular.extend(options, linkOptions[0]);
+ }
+ } else if (options) {
+ linkOptions = [options];
+ }
+ if (attrs.ngModel && elm.is('select,input,textarea')) {
+ if (linkOptions && angular.isObject(linkOptions[0]) && linkOptions[0].ngChange !== undefined) {
+ ngChange = linkOptions[0].ngChange;
+ }
+ if (ngChange) {
+ elm.on(ngChange, function () {
+ elm.trigger('input');
+ });
+ }
+ }
+ elm[attrs.uiJq].apply(elm, linkOptions);
+ };
+ }
+ };
+}]);
+
+/**
+ * Bind one or more handlers to particular keys or their combination
+ * @param hash {mixed} keyBindings Can be an object or string where keybinding expression of keys or keys combinations and AngularJS Exspressions are set. Object syntax: "{ keys1: expression1 [, keys2: expression2 [ , ... ]]}". String syntax: ""expression1 on keys1 [ and expression2 on keys2 [ and ... ]]"". Expression is an AngularJS Expression, and key(s) are dash-separated combinations of keys and modifiers (one or many, if any. Order does not matter). Supported modifiers are 'ctrl', 'shift', 'alt' and key can be used either via its keyCode (13 for Return) or name. Named keys are 'backspace', 'tab', 'enter', 'esc', 'space', 'pageup', 'pagedown', 'end', 'home', 'left', 'up', 'right', 'down', 'insert', 'delete'.
+ * @example <input ui-keypress="{enter:'x = 1', 'ctrl-shift-space':'foo()', 'shift-13':'bar()'}" /> <input ui-keypress="foo = 2 on ctrl-13 and bar('hello') on shift-esc" />
+ **/
+angular.module('ui.directives').directive('uiKeypress', ['$parse', function ($parse) {
+ return {
+ link: function (scope, elm, attrs) {
+ var keysByCode = {
+ 8: 'backspace',
+ 9: 'tab',
+ 13: 'enter',
+ 27: 'esc',
+ 32: 'space',
+ 33: 'pageup',
+ 34: 'pagedown',
+ 35: 'end',
+ 36: 'home',
+ 37: 'left',
+ 38: 'up',
+ 39: 'right',
+ 40: 'down',
+ 45: 'insert',
+ 46: 'delete'
+ };
+
+ var params, paramsParsed, expression, keys, combinations = [];
+ try {
+ params = scope.$eval(attrs.uiKeypress);
+ paramsParsed = true;
+ } catch (error) {
+ params = attrs.uiKeypress.split(/\s+and\s+/i);
+ paramsParsed = false;
+ }
+
+ // Prepare combinations for simple checking
+ angular.forEach(params, function (v, k) {
+ var combination = {};
+ if (paramsParsed) {
+ // An object passed
+ combination.expression = $parse(v);
+ combination.keys = k;
+ } else {
+ // A string passed
+ v = v.split(/\s+on\s+/i);
+ combination.expression = $parse(v[0]);
+ combination.keys = v[1];
+ }
+
+ keys = {};
+ angular.forEach(combination.keys.split('-'), function (value) {
+ keys[value] = true;
+ });
+ combination.keys = keys;
+ combinations.push(combination);
+ });
+
+ // Check only mathcing of pressed keys one of the conditions
+ elm.bind('keydown', function (event) {
+ // No need to do that inside the cycle
+ var altPressed = event.metaKey || event.altKey;
+ var ctrlPressed = event.ctrlKey;
+ var shiftPressed = event.shiftKey;
+
+ // Iterate over prepared combinations
+ angular.forEach(combinations, function (combination) {
+
+ var mainKeyPressed = (combination.keys[keysByCode[event.keyCode]] || combination.keys[event.keyCode.toString()]) || false;
+
+ var altRequired = combination.keys.alt || false;
+ var ctrlRequired = combination.keys.ctrl || false;
+ var shiftRequired = combination.keys.shift || false;
+
+ if (mainKeyPressed &&
+ ( altRequired == altPressed ) &&
+ ( ctrlRequired == ctrlPressed ) &&
+ ( shiftRequired == shiftPressed )
+ ) {
+ // Run the function
+ scope.$apply(function () {
+ combination.expression(scope, { '$event': event });
+ });
+ }
+ });
+ });
+ }
+ };
+}]);
+
+(function () {
+ var app = angular.module('ui.directives');
+
+ //Setup map events from a google map object to trigger on a given element too,
+ //then we just use ui-event to catch events from an element
+ function bindMapEvents(scope, eventsStr, googleObject, element) {
+ angular.forEach(eventsStr.split(' '), function (eventName) {
+ //Prefix all googlemap events with 'map-', so eg 'click'
+ //for the googlemap doesn't interfere with a normal 'click' event
+ var $event = { type: 'map-' + eventName };
+ google.maps.event.addListener(googleObject, eventName, function (evt) {
+ element.trigger(angular.extend({}, $event, evt));
+ //We create an $apply if it isn't happening. we need better support for this
+ //We don't want to use timeout because tons of these events fire at once,
+ //and we only need one $apply
+ if (!scope.$$phase) scope.$apply();
+ });
+ });
+ }
+
+ app.directive('uiMap',
+ ['ui.config', '$parse', function (uiConfig, $parse) {
+
+ var mapEvents = 'bounds_changed center_changed click dblclick drag dragend ' +
+ 'dragstart heading_changed idle maptypeid_changed mousemove mouseout ' +
+ 'mouseover projection_changed resize rightclick tilesloaded tilt_changed ' +
+ 'zoom_changed';
+ var options = uiConfig.map || {};
+
+ return {
+ restrict: 'A',
+ //doesn't work as E for unknown reason
+ link: function (scope, elm, attrs) {
+ var opts = angular.extend({}, options, scope.$eval(attrs.uiOptions));
+ var map = new google.maps.Map(elm[0], opts);
+ var model = $parse(attrs.uiMap);
+
+ //Set scope variable for the map
+ model.assign(scope, map);
+
+ bindMapEvents(scope, mapEvents, map, elm);
+ }
+ };
+ }]);
+
+ app.directive('uiMapInfoWindow',
+ ['ui.config', '$parse', '$compile', function (uiConfig, $parse, $compile) {
+
+ var infoWindowEvents = 'closeclick content_change domready ' +
+ 'position_changed zindex_changed';
+ var options = uiConfig.mapInfoWindow || {};
+
+ return {
+ link: function (scope, elm, attrs) {
+ var opts = angular.extend({}, options, scope.$eval(attrs.uiOptions));
+ opts.content = elm[0];
+ var model = $parse(attrs.uiMapInfoWindow);
+ var infoWindow = model(scope);
+
+ if (!infoWindow) {
+ infoWindow = new google.maps.InfoWindow(opts);
+ model.assign(scope, infoWindow);
+ }
+
+ bindMapEvents(scope, infoWindowEvents, infoWindow, elm);
+
+ /* The info window's contents dont' need to be on the dom anymore,
+ google maps has them stored. So we just replace the infowindow element
+ with an empty div. (we don't just straight remove it from the dom because
+ straight removing things from the dom can mess up angular) */
+ elm.replaceWith('<div></div>');
+
+ //Decorate infoWindow.open to $compile contents before opening
+ var _open = infoWindow.open;
+ infoWindow.open = function open(a1, a2, a3, a4, a5, a6) {
+ $compile(elm.contents())(scope);
+ _open.call(infoWindow, a1, a2, a3, a4, a5, a6);
+ };
+ }
+ };
+ }]);
+
+ /*
+ * Map overlay directives all work the same. Take map marker for example
+ * <ui-map-marker="myMarker"> will $watch 'myMarker' and each time it changes,
+ * it will hook up myMarker's events to the directive dom element. Then
+ * ui-event will be able to catch all of myMarker's events. Super simple.
+ */
+ function mapOverlayDirective(directiveName, events) {
+ app.directive(directiveName, [function () {
+ return {
+ restrict: 'A',
+ link: function (scope, elm, attrs) {
+ scope.$watch(attrs[directiveName], function (newObject) {
+ bindMapEvents(scope, events, newObject, elm);
+ });
+ }
+ };
+ }]);
+ }
+
+ mapOverlayDirective('uiMapMarker',
+ 'animation_changed click clickable_changed cursor_changed ' +
+ 'dblclick drag dragend draggable_changed dragstart flat_changed icon_changed ' +
+ 'mousedown mouseout mouseover mouseup position_changed rightclick ' +
+ 'shadow_changed shape_changed title_changed visible_changed zindex_changed');
+
+ mapOverlayDirective('uiMapPolyline',
+ 'click dblclick mousedown mousemove mouseout mouseover mouseup rightclick');
+
+ mapOverlayDirective('uiMapPolygon',
+ 'click dblclick mousedown mousemove mouseout mouseover mouseup rightclick');
+
+ mapOverlayDirective('uiMapRectangle',
+ 'bounds_changed click dblclick mousedown mousemove mouseout mouseover ' +
+ 'mouseup rightclick');
+
+ mapOverlayDirective('uiMapCircle',
+ 'center_changed click dblclick mousedown mousemove ' +
+ 'mouseout mouseover mouseup radius_changed rightclick');
+
+ mapOverlayDirective('uiMapGroundOverlay',
+ 'click dblclick');
+
+})();
/*
Attaches jquery-ui input mask onto input element
*/
@@ -620,257 +626,259 @@ angular.module('ui.directives').directive('uiMask', [
};
}
]);
-
-angular.module('ui.directives')
-.directive('uiModal', ['$timeout', function($timeout) {
- return {
- restrict: 'EAC',
- require: 'ngModel',
- link: function(scope, elm, attrs, model) {
- //helper so you don't have to type class="modal hide"
- elm.addClass('modal hide');
- scope.$watch(attrs.ngModel, function(value) {
- elm.modal(value && 'show' || 'hide');
- });
- elm.on('show.ui', function() {
- $timeout(function() {
- model.$setViewValue(true);
- });
- });
- elm.on('hide.ui', function() {
- $timeout(function() {
- model.$setViewValue(false);
- });
- });
- }
- };
-}]);
-
-/**
- * Add a clear button to form inputs to reset their value
- */
-angular.module('ui.directives').directive('uiReset', ['$parse', function($parse) {
- return {
- require:'ngModel',
- link: function(scope, elm, attrs, ctrl) {
- elm.wrap('<span class="ui-resetwrap" />').after('<a class="ui-reset" />').next().click(function(e){
- e.preventDefault();
- scope.$apply(function(){
- // This lets you SET the value of the 'parsed' model
- ctrl.$setViewValue(null);
- });
- });
- }
- };
-}]);
-
-/*global angular, $*/
-/**
- * Adds a 'ui-scrollfix' class to the element when the page scrolls past it's position.
- * @param [offset] {int} optional Y-offset to override the detected offset.
- * Takes 300 (absolute) or -300 or +300 (relative to detected)
- */
-angular.module('ui.directives').directive('uiScrollfix', ['$window', function ($window) {
- 'use strict';
- return {
- link: function (scope, elm, attrs) {
- var top = elm.offset().top;
- if (!attrs.uiScrollfix) {
- attrs.uiScrollfix = top;
- } else {
- // chartAt is generally faster than indexOf: http://jsperf.com/indexof-vs-chartat
- if (attrs.uiScrollfix.charAt(0) === '-') {
- attrs.uiScrollfix = top - attrs.uiScrollfix.substr(1);
- } else if (attrs.uiScrollfix.charAt(0) === '+') {
- attrs.uiScrollfix = top + parseFloat(attrs.uiScrollfix.substr(1));
- }
- }
- angular.element($window).on('scroll.ui-scrollfix', function () {
- // if pageYOffset is defined use it, otherwise use other crap for IE
- var offset;
- if (angular.isDefined($window.pageYOffset)) {
- offset = $window.pageYOffset;
- } else {
- var iebody = (document.compatMode && document.compatMode !== "BackCompat") ? document.documentElement : document.body;
- offset = iebody.scrollTop;
- }
- if (!elm.hasClass('ui-scrollfix') && offset > attrs.uiScrollfix) {
- elm.addClass('ui-scrollfix');
- } else if (elm.hasClass('ui-scrollfix') && offset < attrs.uiScrollfix) {
- elm.removeClass('ui-scrollfix');
- }
- });
- }
- };
-}]);
-
-
-/**
- * Enhanced Select2 Dropmenus
- *
- * @AJAX Mode - When in this mode, your value will be an object (or array of objects) of the data used by Select2
- * This change is so that you do not have to do an additional query yourself on top of Select2's own query
- * @params [options] {object} The configuration options passed to $.fn.select2(). Refer to the documentation
- */
-angular.module('ui.directives').directive('uiSelect2', ['ui.config', '$http', function(uiConfig, $http){
- var options = {};
- if (uiConfig.select2) {
- angular.extend(options, uiConfig.select2);
- }
- return {
- require: '?ngModel',
- compile: function(tElm, tAttrs) {
- var watch,
- repeatOption,
- isSelect = tElm.is('select'),
- isMultiple = (tAttrs.multiple !== undefined);
-
- // Enable watching of the options dataset if in use
- if (tElm.is('select')) {
- repeatOption = tElm.find('option[ng-repeat]');
- if (repeatOption.length) {
- watch = repeatOption.attr('ng-repeat').split(' ').pop();
- }
- }
-
- return function(scope, elm, attrs, controller) {
- // instance-specific options
- var opts = angular.extend({}, options, scope.$eval(attrs.uiSelect2));
-
- if (isSelect) {
- // Use <select multiple> instead
- delete opts.multiple;
- delete opts.initSelection;
- } else if (isMultiple) {
- opts.multiple = true;
- }
-
- if (controller) {
- // Watch the model for programmatic changes
- controller.$render = function() {
- if (isSelect) {
- elm.select2('val', controller.$modelValue);
- } else {
- if (isMultiple && !controller.$modelValue) {
- elm.select2('data', []);
- } else {
- elm.select2('data', controller.$modelValue);
- }
- }
- };
-
-
- // Watch the options dataset for changes
- if (watch) {
- scope.$watch(watch, function(newVal, oldVal, scope){
- if (!newVal) return;
- // Delayed so that the options have time to be rendered
- setTimeout(function(){
- elm.select2('val', controller.$viewValue);
- // Refresh angular to remove the superfluous option
- elm.trigger('change');
- });
- });
- }
-
- if (!isSelect) {
- // Set the view and model value and update the angular template manually for the ajax/multiple select2.
- elm.bind("change", function(){
- scope.$apply(function(){
- controller.$setViewValue(elm.select2('data'));
- });
- });
-
- if (opts.initSelection) {
- var initSelection = opts.initSelection;
- opts.initSelection = function(element, callback) {
- initSelection(element, function(value){
- controller.$setViewValue(value);
- callback(value);
- });
- }
- }
- }
- }
-
- attrs.$observe('disabled', function(value){
- elm.select2(value && 'disable' || 'enable');
- });
-
- // Set initial value since Angular doesn't
- elm.val(scope.$eval(attrs.ngModel));
-
- // Initialize the plugin late so that the injected DOM does not disrupt the template compiler
- setTimeout(function(){
- elm.select2(opts);
- });
- }
- }
- };
-}]);
-
-
-/**
- * uiShow Directive
- *
- * Adds a 'ui-show' class to the element instead of display:block
- * Created to allow tighter control of CSS without bulkier directives
- *
- * @param expression {boolean} evaluated expression to determine if the class should be added
- */
-angular.module('ui.directives').directive('uiShow', [function() {
- return function(scope, elm, attrs) {
- scope.$watch(attrs.uiShow, function(newVal, oldVal){
- if (newVal) {
- elm.addClass('ui-show');
- } else {
- elm.removeClass('ui-show');
- }
- });
- };
-}])
-
-/**
- * uiHide Directive
- *
- * Adds a 'ui-hide' class to the element instead of display:block
- * Created to allow tighter control of CSS without bulkier directives
- *
- * @param expression {boolean} evaluated expression to determine if the class should be added
- */
-.directive('uiHide', [function() {
- return function(scope, elm, attrs) {
- scope.$watch(attrs.uiHide, function(newVal, oldVal){
- if (newVal) {
- elm.addClass('ui-hide');
- } else {
- elm.removeClass('ui-hide');
- }
- });
- };
-}])
-
-/**
- * uiToggle Directive
- *
- * Adds a class 'ui-show' if true, and a 'ui-hide' if false to the element instead of display:block/display:none
- * Created to allow tighter control of CSS without bulkier directives. This also allows you to override the
- * default visibility of the element using either class.
- *
- * @param expression {boolean} evaluated expression to determine if the class should be added
- */
-.directive('uiToggle', [function() {
- return function(scope, elm, attrs) {
- scope.$watch(attrs.uiToggle, function(newVal, oldVal){
- if (newVal) {
- elm.removeClass('ui-hide').addClass('ui-show');
- } else {
- elm.removeClass('ui-show').addClass('ui-hide');
- }
- });
- };
-}]);
-
+
+angular.module('ui.directives')
+.directive('uiModal', ['$timeout', function($timeout) {
+ return {
+ restrict: 'EAC',
+ require: 'ngModel',
+ link: function(scope, elm, attrs, model) {
+ //helper so you don't have to type class="modal hide"
+ elm.addClass('modal hide');
+ scope.$watch(attrs.ngModel, function(value) {
+ elm.modal(value && 'show' || 'hide');
+ });
+ //If bootstrap animations are enabled, listen to 'shown' and 'hidden' events
+ elm.on(jQuery.support.transition && 'shown' || 'show', function() {
+ $timeout(function() {
+ model.$setViewValue(true);
+ });
+ });
+ elm.on(jQuery.support.transition && 'hidden' || 'hide', function() {
+ $timeout(function() {
+ model.$setViewValue(false);
+ });
+ });
+ }
+ };
+}]);
+/**
+ * Add a clear button to form inputs to reset their value
+ */
+angular.module('ui.directives').directive('uiReset', ['$parse', function ($parse) {
+ return {
+ require: 'ngModel',
+ link: function (scope, elm, attrs, ctrl) {
+ var aElement = angular.element('<a class="ui-reset" />');
+ elm.wrap('<span class="ui-resetwrap" />').after(aElement);
+
+ aElement.bind('click', function (e) {
+ e.preventDefault();
+ scope.$apply(function () {
+ // This lets you SET the value of the 'parsed' model
+ ctrl.$setViewValue(null);
+ ctrl.$render();
+ });
+ });
+ }
+ };
+}]);
+
+/*global angular, $, document*/
+/**
+ * Adds a 'ui-scrollfix' class to the element when the page scrolls past it's position.
+ * @param [offset] {int} optional Y-offset to override the detected offset.
+ * Takes 300 (absolute) or -300 or +300 (relative to detected)
+ */
+angular.module('ui.directives').directive('uiScrollfix', ['$window', function ($window) {
+ 'use strict';
+ return {
+ link: function (scope, elm, attrs) {
+ var top = elm.offset().top;
+ if (!attrs.uiScrollfix) {
+ attrs.uiScrollfix = top;
+ } else {
+ // chartAt is generally faster than indexOf: http://jsperf.com/indexof-vs-chartat
+ if (attrs.uiScrollfix.charAt(0) === '-') {
+ attrs.uiScrollfix = top - attrs.uiScrollfix.substr(1);
+ } else if (attrs.uiScrollfix.charAt(0) === '+') {
+ attrs.uiScrollfix = top + parseFloat(attrs.uiScrollfix.substr(1));
+ }
+ }
+ angular.element($window).on('scroll.ui-scrollfix', function () {
+ // if pageYOffset is defined use it, otherwise use other crap for IE
+ var offset;
+ if (angular.isDefined($window.pageYOffset)) {
+ offset = $window.pageYOffset;
+ } else {
+ var iebody = (document.compatMode && document.compatMode !== "BackCompat") ? document.documentElement : document.body;
+ offset = iebody.scrollTop;
+ }
+ if (!elm.hasClass('ui-scrollfix') && offset > attrs.uiScrollfix) {
+ elm.addClass('ui-scrollfix');
+ } else if (elm.hasClass('ui-scrollfix') && offset < attrs.uiScrollfix) {
+ elm.removeClass('ui-scrollfix');
+ }
+ });
+ }
+ };
+}]);
+
+/**
+ * Enhanced Select2 Dropmenus
+ *
+ * @AJAX Mode - When in this mode, your value will be an object (or array of objects) of the data used by Select2
+ * This change is so that you do not have to do an additional query yourself on top of Select2's own query
+ * @params [options] {object} The configuration options passed to $.fn.select2(). Refer to the documentation
+ */
+angular.module('ui.directives').directive('uiSelect2', ['ui.config', '$http', function (uiConfig, $http) {
+ var options = {};
+ if (uiConfig.select2) {
+ angular.extend(options, uiConfig.select2);
+ }
+ return {
+ require: '?ngModel',
+ compile: function (tElm, tAttrs) {
+ var watch,
+ repeatOption,
+ isSelect = tElm.is('select'),
+ isMultiple = (tAttrs.multiple !== undefined);
+
+ // Enable watching of the options dataset if in use
+ if (tElm.is('select')) {
+ repeatOption = tElm.find('option[ng-repeat]');
+ if (repeatOption.length) {
+ watch = repeatOption.attr('ng-repeat').split(' ').pop();
+ }
+ }
+
+ return function (scope, elm, attrs, controller) {
+ // instance-specific options
+ var opts = angular.extend({}, options, scope.$eval(attrs.uiSelect2));
+
+ if (isSelect) {
+ // Use <select multiple> instead
+ delete opts.multiple;
+ delete opts.initSelection;
+ } else if (isMultiple) {
+ opts.multiple = true;
+ }
+
+ if (controller) {
+ // Watch the model for programmatic changes
+ controller.$render = function () {
+ if (isSelect) {
+ elm.select2('val', controller.$modelValue);
+ } else {
+ if (isMultiple && !controller.$modelValue) {
+ elm.select2('data', []);
+ } else {
+ elm.select2('data', controller.$modelValue);
+ }
+ }
+ };
+
+
+ // Watch the options dataset for changes
+ if (watch) {
+ scope.$watch(watch, function (newVal, oldVal, scope) {
+ if (!newVal) return;
+ // Delayed so that the options have time to be rendered
+ setTimeout(function () {
+ elm.select2('val', controller.$viewValue);
+ // Refresh angular to remove the superfluous option
+ elm.trigger('change');
+ });
+ });
+ }
+
+ if (!isSelect) {
+ // Set the view and model value and update the angular template manually for the ajax/multiple select2.
+ elm.bind("change", function () {
+ scope.$apply(function () {
+ controller.$setViewValue(elm.select2('data'));
+ });
+ });
+
+ if (opts.initSelection) {
+ var initSelection = opts.initSelection;
+ opts.initSelection = function (element, callback) {
+ initSelection(element, function (value) {
+ controller.$setViewValue(value);
+ callback(value);
+ });
+ };
+ }
+ }
+ }
+
+ attrs.$observe('disabled', function (value) {
+ elm.select2(value && 'disable' || 'enable');
+ });
+
+ // Set initial value since Angular doesn't
+ elm.val(scope.$eval(attrs.ngModel));
+
+ // Initialize the plugin late so that the injected DOM does not disrupt the template compiler
+ setTimeout(function () {
+ elm.select2(opts);
+ });
+ };
+ }
+ };
+}]);
+
+/**
+ * uiShow Directive
+ *
+ * Adds a 'ui-show' class to the element instead of display:block
+ * Created to allow tighter control of CSS without bulkier directives
+ *
+ * @param expression {boolean} evaluated expression to determine if the class should be added
+ */
+angular.module('ui.directives').directive('uiShow', [function () {
+ return function (scope, elm, attrs) {
+ scope.$watch(attrs.uiShow, function (newVal, oldVal) {
+ if (newVal) {
+ elm.addClass('ui-show');
+ } else {
+ elm.removeClass('ui-show');
+ }
+ });
+ };
+}])
+
+/**
+ * uiHide Directive
+ *
+ * Adds a 'ui-hide' class to the element instead of display:block
+ * Created to allow tighter control of CSS without bulkier directives
+ *
+ * @param expression {boolean} evaluated expression to determine if the class should be added
+ */
+ .directive('uiHide', [function () {
+ return function (scope, elm, attrs) {
+ scope.$watch(attrs.uiHide, function (newVal, oldVal) {
+ if (newVal) {
+ elm.addClass('ui-hide');
+ } else {
+ elm.removeClass('ui-hide');
+ }
+ });
+ };
+}])
+
+/**
+ * uiToggle Directive
+ *
+ * Adds a class 'ui-show' if true, and a 'ui-hide' if false to the element instead of display:block/display:none
+ * Created to allow tighter control of CSS without bulkier directives. This also allows you to override the
+ * default visibility of the element using either class.
+ *
+ * @param expression {boolean} evaluated expression to determine if the class should be added
+ */
+ .directive('uiToggle', [function () {
+ return function (scope, elm, attrs) {
+ scope.$watch(attrs.uiToggle, function (newVal, oldVal) {
+ if (newVal) {
+ elm.removeClass('ui-hide').addClass('ui-show');
+ } else {
+ elm.removeClass('ui-show').addClass('ui-hide');
+ }
+ });
+ };
+}]);
+
/*
jQuery UI Sortable plugin wrapper
@@ -922,59 +930,58 @@ angular.module('ui.directives').directive('uiSortable', [
};
}
]);
-
-
-/**
- * Binds a TinyMCE widget to <textarea> elements.
- */
-angular.module('ui.directives').directive('uiTinymce', ['ui.config', function(uiConfig){
- uiConfig.tinymce = uiConfig.tinymce || {};
- return {
- require: 'ngModel',
- link: function(scope, elm, attrs, ngModel) {
- var expression,
- options = {
- // Update model on button click
- onchange_callback: function(inst) {
- if (inst.isDirty()) {
- inst.save();
- ngModel.$setViewValue(elm.val());
- scope.$apply();
- }
- },
- // Update model on keypress
- handle_event_callback: function(e) {
- if (this.isDirty()) {
- this.save();
- ngModel.$setViewValue(elm.val());
- scope.$apply();
- }
- return true; // Continue handling
- },
- // Update model when calling setContent (such as from the source editor popup)
- setup : function(ed) {
- ed.onSetContent.add(function(ed, o) {
- if (ed.isDirty()) {
- ed.save();
- ngModel.$setViewValue(elm.val());
- scope.$apply();
- }
- });
- }
- };
- if (attrs.uiTinymce) {
- expression = scope.$eval(attrs.uiTinymce);
- } else {
- expression = {};
- }
- angular.extend(options, uiConfig.tinymce, expression);
- setTimeout(function(){
- elm.tinymce(options);
- });
- }
- };
-}]);
-
+
+/**
+ * Binds a TinyMCE widget to <textarea> elements.
+ */
+angular.module('ui.directives').directive('uiTinymce', ['ui.config', function (uiConfig) {
+ uiConfig.tinymce = uiConfig.tinymce || {};
+ return {
+ require: 'ngModel',
+ link: function (scope, elm, attrs, ngModel) {
+ var expression,
+ options = {
+ // Update model on button click
+ onchange_callback: function (inst) {
+ if (inst.isDirty()) {
+ inst.save();
+ ngModel.$setViewValue(elm.val());
+ scope.$apply();
+ }
+ },
+ // Update model on keypress
+ handle_event_callback: function (e) {
+ if (this.isDirty()) {
+ this.save();
+ ngModel.$setViewValue(elm.val());
+ scope.$apply();
+ }
+ return true; // Continue handling
+ },
+ // Update model when calling setContent (such as from the source editor popup)
+ setup: function (ed) {
+ ed.onSetContent.add(function (ed, o) {
+ if (ed.isDirty()) {
+ ed.save();
+ ngModel.$setViewValue(elm.val());
+ scope.$apply();
+ }
+ });
+ }
+ };
+ if (attrs.uiTinymce) {
+ expression = scope.$eval(attrs.uiTinymce);
+ } else {
+ expression = {};
+ }
+ angular.extend(options, uiConfig.tinymce, expression);
+ setTimeout(function () {
+ elm.tinymce(options);
+ });
+ }
+ };
+}]);
+
/**
* General-purpose validator for ngModel.
* angular.js comes with several built-in validation mechanism for input fields (ngRequired, ngPattern etc.) but using
@@ -992,9 +999,9 @@ angular.module('ui.directives').directive('uiTinymce', ['ui.config', function(ui
angular.module('ui.directives').directive('uiValidate', function () {
return {
- restrict:'A',
- require:'ngModel',
- link:function (scope, elm, attrs, ctrl) {
+ restrict: 'A',
+ require: 'ngModel',
+ link: function (scope, elm, attrs, ctrl) {
var validateFn, validateExpr = attrs.uiValidate;
@@ -1007,7 +1014,7 @@ angular.module('ui.directives').directive('uiValidate', function () {
validateExpr = { validator: validateExpr };
}
- angular.forEach(validateExpr, function(validatorFn, key){
+ angular.forEach(validateExpr, function (validatorFn, key) {
validateFn = function (valueToValidate) {
if (validatorFn(valueToValidate)) {
ctrl.$setValidity(key, true);
@@ -1022,117 +1029,151 @@ angular.module('ui.directives').directive('uiValidate', function () {
});
}
};
-});
-
-/**
- * Wraps the
- * @param text {string} haystack to search through
- * @param search {string} needle to search for
- * @param [caseSensitive] {boolean} optional boolean to use case-sensitive searching
- */
-angular.module('ui.filters').filter('highlight', function() {
- return function(text, search, caseSensitive) {
- if (search || angular.isNumber(search)) {
- text = text.toString();
- search = search.toString();
- if (caseSensitive) {
- return text.split(search).join('<span class="ui-match">'+search+'</span>');
- } else {
- return text.replace(new RegExp(search, 'gi'), '<span class="ui-match">$&</span>');
- }
- } else {
- return text;
- }
- };
-});
-
-
-/**
- * Converts variable-esque naming conventions to something presentational, capitalized words separated by space.
- * @param {String} value The value to be parsed and prettified.
- * @param {String} [inflector] The inflector to use. Default: humanize.
- * @return {String}
- * @example {{ 'Here Is my_phoneNumber' | inflector:'humanize' }} => Here Is My Phone Number
- * {{ 'Here Is my_phoneNumber' | inflector:'underscore' }} => here_is_my_phone_number
- * {{ 'Here Is my_phoneNumber' | inflector:'variable' }} => hereIsMyPhoneNumber
- */
-angular.module('ui.filters').filter('inflector', function () {
- function ucwords(text) {
- return text.replace(/^([a-z])|\s+([a-z])/g, function ($1) {
- return $1.toUpperCase();
- });
- }
- function breakup(text, separator) {
- return text.replace(/[A-Z]/g, function(match){
- return separator + match;
- });
- }
- var inflectors = {
- humanize: function(value) {
- return ucwords(breakup(value, ' ').split('_').join(' '));
- },
- underscore: function(value) {
- return value.substr(0,1).toLowerCase() + breakup(value.substr(1), '_').toLowerCase().split(' ').join('_');
- },
- variable: function(value) {
- value = value.substr(0,1).toLowerCase() + ucwords(value.split('_').join(' ')).substr(1).split(' ').join('');
- return value;
- }
- };
-
- return function (text, inflector, separator) {
- if (inflector !== false && angular.isString(text)) {
- inflector = inflector || 'humanize';
- return inflectors[inflector](text);
- } else {
- return text;
- }
- };
-});
-
-
-/**
- * Filters out all duplicate items from an array by checking the specified key
- * @param [key] {string} the name of the attribute of each object to compare for uniqueness
- if the key is empty, the entire object will be compared
- if the key === false then no filtering will be performed
- * @return {array}
- */
-angular.module('ui.filters').filter('unique', function() {
-
- return function(items, filterOn) {
-
- if (filterOn===false){
- return items;
- }
-
- if ((filterOn || angular.isUndefined(filterOn))&& angular.isArray(items)) {
- var hashCheck = {}, newItems = [];
-
- var extractValueToCompare = function(item) {
- if (angular.isObject(item) && angular.isString(filterOn)) {
- return item[filterOn];
- } else {
- return item;
- }
- };
-
- angular.forEach(items, function (item) {
- var valueToCheck, isDuplicate = false;
-
- for (var i = 0; i < newItems.length; i++) {
- if (angular.equals(extractValueToCompare(newItems[i]), extractValueToCompare(item))) {
- isDuplicate = true;
- break;
- }
- }
- if (!isDuplicate){
- newItems.push(item);
- }
-
- });
- items = newItems;
- }
- return items;
- };
-});
+});
+
+/**
+ * A replacement utility for internationalization very similar to sprintf.
+ *
+ * @param replace {mixed} The tokens to replace depends on type
+ * string: all instances of $0 will be replaced
+ * array: each instance of $0, $1, $2 etc. will be placed with each array item in corresponding order
+ * object: all attributes will be iterated through, with :key being replaced with its corresponding value
+ * @return string
+ *
+ * @example: 'Hello :name, how are you :day'.format({ name:'John', day:'Today' })
+ * @example: 'Records $0 to $1 out of $2 total'.format(['10', '20', '3000'])
+ * @example: '$0 agrees to all mentions $0 makes in the event that $0 hits a tree while $0 is driving drunk'.format('Bob')
+ */
+angular.module('ui.filters').filter('format', function(){
+ return function(value, replace) {
+ if (!value) {
+ return value;
+ }
+ var target = value.toString(), token;
+ if (replace === undefined) {
+ return target;
+ }
+ if (!angular.isArray(replace) && !angular.isObject(replace)) {
+ return target.split('$0').join(replace);
+ }
+ token = angular.isArray(replace) && '$' || ':';
+
+ angular.forEach(replace, function(value, key){
+ target = target.split(token+key).join(value);
+ });
+ return target;
+ };
+});
+
+/**
+ * Wraps the
+ * @param text {string} haystack to search through
+ * @param search {string} needle to search for
+ * @param [caseSensitive] {boolean} optional boolean to use case-sensitive searching
+ */
+angular.module('ui.filters').filter('highlight', function () {
+ return function (text, search, caseSensitive) {
+ if (search || angular.isNumber(search)) {
+ text = text.toString();
+ search = search.toString();
+ if (caseSensitive) {
+ return text.split(search).join('<span class="ui-match">' + search + '</span>');
+ } else {
+ return text.replace(new RegExp(search, 'gi'), '<span class="ui-match">$&</span>');
+ }
+ } else {
+ return text;
+ }
+ };
+});
+
+/**
+ * Converts variable-esque naming conventions to something presentational, capitalized words separated by space.
+ * @param {String} value The value to be parsed and prettified.
+ * @param {String} [inflector] The inflector to use. Default: humanize.
+ * @return {String}
+ * @example {{ 'Here Is my_phoneNumber' | inflector:'humanize' }} => Here Is My Phone Number
+ * {{ 'Here Is my_phoneNumber' | inflector:'underscore' }} => here_is_my_phone_number
+ * {{ 'Here Is my_phoneNumber' | inflector:'variable' }} => hereIsMyPhoneNumber
+ */
+angular.module('ui.filters').filter('inflector', function () {
+ function ucwords(text) {
+ return text.replace(/^([a-z])|\s+([a-z])/g, function ($1) {
+ return $1.toUpperCase();
+ });
+ }
+
+ function breakup(text, separator) {
+ return text.replace(/[A-Z]/g, function (match) {
+ return separator + match;
+ });
+ }
+
+ var inflectors = {
+ humanize: function (value) {
+ return ucwords(breakup(value, ' ').split('_').join(' '));
+ },
+ underscore: function (value) {
+ return value.substr(0, 1).toLowerCase() + breakup(value.substr(1), '_').toLowerCase().split(' ').join('_');
+ },
+ variable: function (value) {
+ value = value.substr(0, 1).toLowerCase() + ucwords(value.split('_').join(' ')).substr(1).split(' ').join('');
+ return value;
+ }
+ };
+
+ return function (text, inflector, separator) {
+ if (inflector !== false && angular.isString(text)) {
+ inflector = inflector || 'humanize';
+ return inflectors[inflector](text);
+ } else {
+ return text;
+ }
+ };
+});
+
+/**
+ * Filters out all duplicate items from an array by checking the specified key
+ * @param [key] {string} the name of the attribute of each object to compare for uniqueness
+ if the key is empty, the entire object will be compared
+ if the key === false then no filtering will be performed
+ * @return {array}
+ */
+angular.module('ui.filters').filter('unique', function () {
+
+ return function (items, filterOn) {
+
+ if (filterOn === false) {
+ return items;
+ }
+
+ if ((filterOn || angular.isUndefined(filterOn)) && angular.isArray(items)) {
+ var hashCheck = {}, newItems = [];
+
+ var extractValueToCompare = function (item) {
+ if (angular.isObject(item) && angular.isString(filterOn)) {
+ return item[filterOn];
+ } else {
+ return item;
+ }
+ };
+
+ angular.forEach(items, function (item) {
+ var valueToCheck, isDuplicate = false;
+
+ for (var i = 0; i < newItems.length; i++) {
+ if (angular.equals(extractValueToCompare(newItems[i]), extractValueToCompare(item))) {
+ isDuplicate = true;
+ break;
+ }
+ }
+ if (!isDuplicate) {
+ newItems.push(item);
+ }
+
+ });
+ items = newItems;
+ }
+ return items;
+ };
+});
View
4 build/angular-ui.min.js
@@ -1,7 +1,7 @@
/**
* AngularUI - The companion suite for AngularJS
- * @version v0.2.0 - 2012-08-06
+ * @version v0.2.1 - 2012-09-19
* @link http://angular-ui.github.com
* @license MIT License, http://www.opensource.org/licenses/MIT
*/
-angular.module("ui.config",[]).value("ui.config",{}),angular.module("ui.filters",["ui.config"]),angular.module("ui.directives",["ui.config"]),angular.module("ui",["ui.filters","ui.directives","ui.config"]),angular.module("ui.directives").directive("uiAnimate",["ui.config","$timeout",function(a,b){var c={};return angular.isString(a.animate)?c["class"]=a.animate:a.animate&&(c=a.animate),{restrict:"A",link:function(a,d,e){var f={};e.uiAnimate&&(f=a.$eval(e.uiAnimate),angular.isString(f)&&(f={"class":f})),f=angular.extend({"class":"ui-animate"},c,f),d.addClass(f["class"]),b(function(){d.removeClass(f["class"])},!1)}}}]),angular.module("ui.directives").directive("uiCodemirror",["ui.config","$parse",function(a,b){return"use strict",a.codemirror=a.codemirror||{},{require:"ngModel",link:function(c,d,e,f){if(!d.is("textarea"))throw new Error("ui-codemirror can only be applied to a textarea element");var g,h=b(e.uiCodemirror),i=function(a){var b=a.getValue();b!==f.$viewValue&&(f.$setViewValue(b),c.$apply())},j=function(b){b=angular.extend({},b,a.codemirror);var c=b.onChange;c?b.onChange=function(a){i(a),c(a)}:b.onChange=i,g&&g.toTextArea(),g=CodeMirror.fromTextArea(d[0],b)};j(h()),c.$watch(h,j,!0),f.$formatters.push(function(a){if(angular.isUndefined(a)||a===null)return"";if(angular.isObject(a)||angular.isArray(a))throw new Error("ui-codemirror cannot use an object or an array as a model");return a}),f.$render=function(){g.setValue(f.$viewValue)}}}}]),angular.module("ui.directives").directive("uiCurrency",["ui.config","currencyFilter",function(a,b){var c={pos:"ui-currency-pos",neg:"ui-currency-neg",zero:"ui-currency-zero"};return a.currency&&angular.extend(c,a.currency),{restrict:"EAC",require:"ngModel",link:function(a,d,e,f){var g,h,i;g=angular.extend({},c,a.$eval(e.uiCurrency)),h=function(a){var c;return c=a*1,c>0?d.addClass(g.pos):d.removeClass(g.pos),c<0?d.addClass(g.neg):d.removeClass(g.neg),c===0?d.addClass(g.zero):d.removeClass(g.zero),a===""?d.text(""):d.text(b(c,g.symbol)),!0},f.$render=function(){i=f.$viewValue,d.val(i),h(i)}}}}]),angular.module("ui.directives").directive("uiDate",["ui.config",function(a){var b;return b={},a.date!=null&&angular.extend(b,a.date),{require:"?ngModel",link:function(a,c,d,e){var f,g,h;return f=angular.extend({},b,a.$eval(d.uiDate)),e!=null&&(g=function(b,d){return a.$apply(function(){return e.$setViewValue(c.datepicker("getDate"))})},f.onSelect!=null?(h=f.onSelect,f.onSelect=function(a,b){return g(a),h(a,b)}):f.onSelect=g,e.$render=function(){var a;return a=e.$viewValue,a instanceof Date||(a=new Date(a)),c.datepicker("setDate",a)}),c.datepicker(f)}}}]),angular.module("ui.directives").directive("uiEvent",["$parse",function(a){return function(b,c,d){var e=b.$eval(d.uiEvent);angular.forEach(e,function(d,e){var f=a(d);c.bind(e,function(a){var c=Array.prototype.slice.call(arguments);c=c.splice(1),b.$apply(function(){f(b,{$event:a,$params:c})})})})}}]),angular.module("ui.directives").directive("uiIf",[function(){return{transclude:"element",priority:1e3,terminal:!0,restrict:"A",compile:function(a,b,c){return function(a,b,d){b[0].doNotMove=!0;var e=d.uiIf,f,g;a.$watch(e,function(d){f&&(f.remove(),f=null),g&&g.$destroy(),d&&(g=a.$new(),c(g,function(a){f=a,b.after(a)})),b.parent().trigger("$childrenChanged")})}}}}]),angular.module("ui.directives").directive("uiJq",["ui.config",function(a){return{restrict:"A",compile:function(b,c){if(!angular.isFunction(b[c.uiJq]))throw new Error('ui-jq: The "'+c.uiJq+'" function does not exist');var d=a.jq&&a.jq[c.uiJq];return function(a,b,c){var e=[],f="change";c.uiOptions?(e=a.$eval("["+c.uiOptions+"]"),angular.isObject(d)&&angular.isObject(e[0])&&(e[0]=angular.extend(d,e[0]))):d&&(e=[d]),c.ngModel&&b.is("select,input,textarea")&&(e&&angular.isObject(e[0])&&e[0].ngChange!==undefined&&(f=e[0].ngChange),f&&b.on(f,function(){b.trigger("input")})),b[c.uiJq].apply(b,e)}}}}]),angular.module("ui.directives").directive("uiKeypress",["$parse",function(a){return{link:function(b,c,d){var e={8:"backspace",9:"tab",13:"enter",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"delete"},f,g,h,i,j=[];try{f=b.$eval(d.uiKeypress),g=!0}catch(k){f=d.uiKeypress.split(/\s+and\s+/i),g=!1}angular.forEach(f,function(b,c){var d={};g?(d.expression=a(b),d.keys=c):(b=b.split(/\s+on\s+/i),d.expression=a(b[0]),d.keys=b[1]),i={},angular.forEach(d.keys.split("-"),function(a){i[a]=!0}),d.keys=i,j.push(d)}),c.bind("keydown",function(a){var c=a.metaKey||a.altKey,d=a.ctrlKey,f=a.shiftKey;angular.forEach(j,function(g){var h=g.keys[e[a.keyCode]]||g.keys[a.keyCode.toString()]||!1,i=g.keys.alt||!1,j=g.keys.ctrl||!1,k=g.keys.shift||!1;h&&i==c&&j==d&&k==f&&b.$apply(function(){g.expression(b,{$event:a})})})})}}}]),function(){function b(a,b,c,d){angular.forEach(b.split(" "),function(b){var e={type:"map-"+b};google.maps.event.addListener(c,b,function(b){d.trigger(angular.extend({},e,b)),a.$$phase||a.$apply()})})}function c(c,d){a.directive(c,[function(){return{restrict:"A",link:function(a,e,f){a.$watch(f[c],function(c){b(a,d,c,e)})}}}])}var a=angular.module("ui.directives");a.directive("uiMap",["ui.config","$parse",function(a,c){var d="bounds_changed center_changed click dblclick drag dragend dragstart heading_changed idle maptypeid_changed mousemove mouseout mouseover projection_changed resize rightclick tilesloaded tilt_changed zoom_changed",e=a.map||{};return{restrict:"A",link:function(a,f,g){var h=angular.extend({},e,a.$eval(g.uiOptions)),i=new google.maps.Map(f[0],h),j=c(g.uiMap);j.assign(a,i),b(a,d,i,f)}}}]),a.directive("uiMapInfoWindow",["ui.config","$parse","$compile",function(a,c,d){var e="closeclick content_change domready position_changed zindex_changed",f=a.mapInfoWindow||{};return{link:function(a,g,h){var i=angular.extend({},f,a.$eval(h.uiOptions));i.content=g[0];var j=c(h.uiMapInfoWindow),k=j(a);k||(k=new google.maps.InfoWindow(i),j.assign(a,k)),b(a,e,k,g),g.replaceWith("<div></div>");var l=k.open;k.open=function(b,c,e,f,h,i){d(g.contents())(a),l.call(k,b,c,e,f,h,i)}}}}]),c("uiMapMarker","animation_changed click clickable_changed cursor_changed dblclick drag dragend draggable_changed dragstart flat_changed icon_changed mousedown mouseout mouseover mouseup position_changed rightclick shadow_changed shape_changed title_changed visible_changed zindex_changed"),c("uiMapPolyline","click dblclick mousedown mousemove mouseout mouseover mouseup rightclick"),c("uiMapPolygon","click dblclick mousedown mousemove mouseout mouseover mouseup rightclick"),c("uiMapRectangle","bounds_changed click dblclick mousedown mousemove mouseout mouseover mouseup rightclick"),c("uiMapCircle","center_changed click dblclick mousedown mousemove mouseout mouseover mouseup radius_changed rightclick"),c("uiMapGroundOverlay","click dblclick")}(),angular.module("ui.directives").directive("uiMask",[function(){return{require:"ngModel",scope:{uiMask:"="},link:function(a,b,c,d){return d.$render=function(){var c;return c=d.$viewValue||"",b.val(c),b.mask(a.uiMask)},d.$parsers.push(function(a){var c;return c=b.data("mask-isvalid"),d.$setValidity("mask",c),b.mask()}),b.bind("keyup",function(){return a.$apply(function(){return d.$setViewValue(b.mask())})})}}}]),angular.module("ui.directives").directive("uiModal",["$timeout",function(a){return{restrict:"EAC",require:"ngModel",link:function(b,c,d,e){c.addClass("modal hide"),b.$watch(d.ngModel,function(a){c.modal(a&&"show"||"hide")}),c.on("show.ui",function(){a(function(){e.$setViewValue(!0)})}),c.on("hide.ui",function(){a(function(){e.$setViewValue(!1)})})}}}]),angular.module("ui.directives").directive("uiReset",["$parse",function(a){return{require:"ngModel",link:function(a,b,c,d){b.wrap('<span class="ui-resetwrap" />').after('<a class="ui-reset" />').next().click(function(b){b.preventDefault(),a.$apply(function(){d.$setViewValue(null)})})}}}]),angular.module("ui.directives").directive("uiScrollfix",["$window",function(a){return"use strict",{link:function(b,c,d){var e=c.offset().top;d.uiScrollfix?d.uiScrollfix.charAt(0)==="-"?d.uiScrollfix=e-d.uiScrollfix.substr(1):d.uiScrollfix.charAt(0)==="+"&&(d.uiScrollfix=e+parseFloat(d.uiScrollfix.substr(1))):d.uiScrollfix=e,angular.element(a).on("scroll.ui-scrollfix",function(){var b;if(angular.isDefined(a.pageYOffset))b=a.pageYOffset;else{var e=document.compatMode&&document.compatMode!=="BackCompat"?document.documentElement:document.body;b=e.scrollTop}!c.hasClass("ui-scrollfix")&&b>d.uiScrollfix?c.addClass("ui-scrollfix"):c.hasClass("ui-scrollfix")&&b<d.uiScrollfix&&c.removeClass("ui-scrollfix")})}}}]),angular.module("ui.directives").directive("uiSelect2",["ui.config","$http",function(a,b){var c={};return a.select2&&angular.extend(c,a.select2),{require:"?ngModel",compile:function(a,b){var d,e,f=a.is("select"),g=b.multiple!==undefined;return a.is("select")&&(e=a.find("option[ng-repeat]"),e.length&&(d=e.attr("ng-repeat").split(" ").pop())),function(a,b,e,h){var i=angular.extend({},c,a.$eval(e.uiSelect2));f?(delete i.multiple,delete i.initSelection):g&&(i.multiple=!0);if(h){h.$render=function(){f?b.select2("val",h.$modelValue):g&&!h.$modelValue?b.select2("data",[]):b.select2("data",h.$modelValue)},d&&a.$watch(d,function(a,c,d){if(!a)return;setTimeout(function(){b.select2("val",h.$viewValue),b.trigger("change")})});if(!f){b.bind("change",function(){a.$apply(function(){h.$setViewValue(b.select2("data"))})});if(i.initSelection){var j=i.initSelection;i.initSelection=function(a,b){j(a,function(a){h.$setViewValue(a),b(a)})}}}}e.$observe("disabled",function(a){b.select2(a&&"disable"||"enable")}),b.val(a.$eval(e.ngModel)),setTimeout(function(){b.select2(i)})}}}}]),angular.module("ui.directives").directive("uiShow",[function(){return function(a,b,c){a.$watch(c.uiShow,function(a,c){a?b.addClass("ui-show"):b.removeClass("ui-show")})}}]).directive("uiHide",[function(){return function(a,b,c){a.$watch(c.uiHide,function(a,c){a?b.addClass("ui-hide"):b.removeClass("ui-hide")})}}]).directive("uiToggle",[function(){return function(a,b,c){a.$watch(c.uiToggle,function(a,c){a?b.removeClass("ui-hide").addClass("ui-show"):b.removeClass("ui-show").addClass("ui-hide")})}}]),angular.module("ui.directives").directive("uiSortable",["ui.config",function(a){var b;return b={},a.sortable!=null&&angular.extend(b,a.sortable),{require:"?ngModel",link:function(a,c,d,e){var f,g,h,i,j;return h=angular.extend({},b,a.$eval(d.uiOptions)),e!=null&&(f=function(a,b){return b.item.data("ui-sortable-start",b.item.index())},g=function(b,c){var d,f;return f=c.item.data("ui-sortable-start"),d=c.item.index(),e.$modelValue.splice(d,0,e.$modelValue.splice(f,1)[0]),a.$apply()},i=h.start,h.start=function(b,c){return f(b,c),typeof i=="function"&&i(b,c),a.$apply()},j=h.update,h.update=function(b,c){return g(b,c),typeof j=="function"&&j(b,c),a.$apply()}),c.sortable(h)}}}]),angular.module("ui.directives").directive("uiTinymce",["ui.config",function(a){return a.tinymce=a.tiny