diff --git a/.gitignore b/.gitignore index 05bb64311..8188cf1fc 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,6 @@ dist # Ignore tmp directory tmp .tmp + +# Ignore grails plugin build +grails/ag-plugin/web-app/angleGrinder diff --git a/grails/ag-plugin/web-app/angleGrinder/font/FontAwesome.otf b/grails/ag-plugin/web-app/angleGrinder/font/FontAwesome.otf deleted file mode 100644 index 64049bf2e..000000000 Binary files a/grails/ag-plugin/web-app/angleGrinder/font/FontAwesome.otf and /dev/null differ diff --git a/grails/ag-plugin/web-app/angleGrinder/font/fontawesome-webfont.eot b/grails/ag-plugin/web-app/angleGrinder/font/fontawesome-webfont.eot deleted file mode 100644 index 7d81019e4..000000000 Binary files a/grails/ag-plugin/web-app/angleGrinder/font/fontawesome-webfont.eot and /dev/null differ diff --git a/grails/ag-plugin/web-app/angleGrinder/font/fontawesome-webfont.svg b/grails/ag-plugin/web-app/angleGrinder/font/fontawesome-webfont.svg deleted file mode 100644 index ba0afe5ef..000000000 --- a/grails/ag-plugin/web-app/angleGrinder/font/fontawesome-webfont.svg +++ /dev/null @@ -1,284 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/grails/ag-plugin/web-app/angleGrinder/font/fontawesome-webfont.ttf b/grails/ag-plugin/web-app/angleGrinder/font/fontawesome-webfont.ttf deleted file mode 100644 index d46172476..000000000 Binary files a/grails/ag-plugin/web-app/angleGrinder/font/fontawesome-webfont.ttf and /dev/null differ diff --git a/grails/ag-plugin/web-app/angleGrinder/font/fontawesome-webfont.woff b/grails/ag-plugin/web-app/angleGrinder/font/fontawesome-webfont.woff deleted file mode 100644 index 3c89ae09b..000000000 Binary files a/grails/ag-plugin/web-app/angleGrinder/font/fontawesome-webfont.woff and /dev/null differ diff --git a/grails/ag-plugin/web-app/angleGrinder/img/ajax-loader.gif b/grails/ag-plugin/web-app/angleGrinder/img/ajax-loader.gif deleted file mode 100644 index 09d621ede..000000000 Binary files a/grails/ag-plugin/web-app/angleGrinder/img/ajax-loader.gif and /dev/null differ diff --git a/grails/ag-plugin/web-app/angleGrinder/img/fiber.jpg b/grails/ag-plugin/web-app/angleGrinder/img/fiber.jpg deleted file mode 100644 index 93cfd8150..000000000 Binary files a/grails/ag-plugin/web-app/angleGrinder/img/fiber.jpg and /dev/null differ diff --git a/grails/ag-plugin/web-app/angleGrinder/img/glyphicons-halflings-white.png b/grails/ag-plugin/web-app/angleGrinder/img/glyphicons-halflings-white.png deleted file mode 100644 index 3bf6484a2..000000000 Binary files a/grails/ag-plugin/web-app/angleGrinder/img/glyphicons-halflings-white.png and /dev/null differ diff --git a/grails/ag-plugin/web-app/angleGrinder/img/glyphicons-halflings.png b/grails/ag-plugin/web-app/angleGrinder/img/glyphicons-halflings.png deleted file mode 100644 index a99699932..000000000 Binary files a/grails/ag-plugin/web-app/angleGrinder/img/glyphicons-halflings.png and /dev/null differ diff --git a/grails/ag-plugin/web-app/angleGrinder/img/select2-spinner.gif b/grails/ag-plugin/web-app/angleGrinder/img/select2-spinner.gif deleted file mode 100644 index 5b33f7e54..000000000 Binary files a/grails/ag-plugin/web-app/angleGrinder/img/select2-spinner.gif and /dev/null differ diff --git a/grails/ag-plugin/web-app/angleGrinder/img/select2.png b/grails/ag-plugin/web-app/angleGrinder/img/select2.png deleted file mode 100644 index 1d804ffb9..000000000 Binary files a/grails/ag-plugin/web-app/angleGrinder/img/select2.png and /dev/null differ diff --git a/grails/ag-plugin/web-app/angleGrinder/img/select2x2.png b/grails/ag-plugin/web-app/angleGrinder/img/select2x2.png deleted file mode 100644 index 4bdd5c961..000000000 Binary files a/grails/ag-plugin/web-app/angleGrinder/img/select2x2.png and /dev/null differ diff --git a/grails/ag-plugin/web-app/angleGrinder/img/selectPointer.gif b/grails/ag-plugin/web-app/angleGrinder/img/selectPointer.gif deleted file mode 100644 index 67ab49af2..000000000 Binary files a/grails/ag-plugin/web-app/angleGrinder/img/selectPointer.gif and /dev/null differ diff --git a/grails/ag-plugin/web-app/angleGrinder/img/ui-bg_flat_0_aaaaaa_40x100.png b/grails/ag-plugin/web-app/angleGrinder/img/ui-bg_flat_0_aaaaaa_40x100.png deleted file mode 100644 index e425e6e46..000000000 Binary files a/grails/ag-plugin/web-app/angleGrinder/img/ui-bg_flat_0_aaaaaa_40x100.png and /dev/null differ diff --git a/grails/ag-plugin/web-app/angleGrinder/img/ui-bg_glass_55_fbf9ee_1x400.png b/grails/ag-plugin/web-app/angleGrinder/img/ui-bg_glass_55_fbf9ee_1x400.png deleted file mode 100644 index 3b2914a2d..000000000 Binary files a/grails/ag-plugin/web-app/angleGrinder/img/ui-bg_glass_55_fbf9ee_1x400.png and /dev/null differ diff --git a/grails/ag-plugin/web-app/angleGrinder/img/ui-bg_glass_65_ffffff_1x400.png b/grails/ag-plugin/web-app/angleGrinder/img/ui-bg_glass_65_ffffff_1x400.png deleted file mode 100644 index e81a6d065..000000000 Binary files a/grails/ag-plugin/web-app/angleGrinder/img/ui-bg_glass_65_ffffff_1x400.png and /dev/null differ diff --git a/grails/ag-plugin/web-app/angleGrinder/img/ui-bg_glass_75_dadada_1x400.png b/grails/ag-plugin/web-app/angleGrinder/img/ui-bg_glass_75_dadada_1x400.png deleted file mode 100644 index 5a46b47cb..000000000 Binary files a/grails/ag-plugin/web-app/angleGrinder/img/ui-bg_glass_75_dadada_1x400.png and /dev/null differ diff --git a/grails/ag-plugin/web-app/angleGrinder/img/ui-bg_glass_75_e6e6e6_1x400.png b/grails/ag-plugin/web-app/angleGrinder/img/ui-bg_glass_75_e6e6e6_1x400.png deleted file mode 100644 index 86c2baa65..000000000 Binary files a/grails/ag-plugin/web-app/angleGrinder/img/ui-bg_glass_75_e6e6e6_1x400.png and /dev/null differ diff --git a/grails/ag-plugin/web-app/angleGrinder/img/ui-bg_glass_75_ffffff_1x400.png b/grails/ag-plugin/web-app/angleGrinder/img/ui-bg_glass_75_ffffff_1x400.png deleted file mode 100644 index 52ff2d680..000000000 Binary files a/grails/ag-plugin/web-app/angleGrinder/img/ui-bg_glass_75_ffffff_1x400.png and /dev/null differ diff --git a/grails/ag-plugin/web-app/angleGrinder/img/ui-bg_highlight-soft_75_cccccc_1x100.png b/grails/ag-plugin/web-app/angleGrinder/img/ui-bg_highlight-soft_75_cccccc_1x100.png deleted file mode 100644 index 3cd467e18..000000000 Binary files a/grails/ag-plugin/web-app/angleGrinder/img/ui-bg_highlight-soft_75_cccccc_1x100.png and /dev/null differ diff --git a/grails/ag-plugin/web-app/angleGrinder/img/ui-bg_inset-soft_95_fef1ec_1x100.png b/grails/ag-plugin/web-app/angleGrinder/img/ui-bg_inset-soft_95_fef1ec_1x100.png deleted file mode 100644 index a50a17f9a..000000000 Binary files a/grails/ag-plugin/web-app/angleGrinder/img/ui-bg_inset-soft_95_fef1ec_1x100.png and /dev/null differ diff --git a/grails/ag-plugin/web-app/angleGrinder/img/ui-icons_222222_256x240.png b/grails/ag-plugin/web-app/angleGrinder/img/ui-icons_222222_256x240.png deleted file mode 100644 index 0085d125f..000000000 Binary files a/grails/ag-plugin/web-app/angleGrinder/img/ui-icons_222222_256x240.png and /dev/null differ diff --git a/grails/ag-plugin/web-app/angleGrinder/img/ui-icons_2e83ff_256x240.png b/grails/ag-plugin/web-app/angleGrinder/img/ui-icons_2e83ff_256x240.png deleted file mode 100644 index 3bb63f15c..000000000 Binary files a/grails/ag-plugin/web-app/angleGrinder/img/ui-icons_2e83ff_256x240.png and /dev/null differ diff --git a/grails/ag-plugin/web-app/angleGrinder/img/ui-icons_454545_256x240.png b/grails/ag-plugin/web-app/angleGrinder/img/ui-icons_454545_256x240.png deleted file mode 100644 index a813d3e3c..000000000 Binary files a/grails/ag-plugin/web-app/angleGrinder/img/ui-icons_454545_256x240.png and /dev/null differ diff --git a/grails/ag-plugin/web-app/angleGrinder/img/ui-icons_888888_256x240.png b/grails/ag-plugin/web-app/angleGrinder/img/ui-icons_888888_256x240.png deleted file mode 100644 index 0b5ccc85e..000000000 Binary files a/grails/ag-plugin/web-app/angleGrinder/img/ui-icons_888888_256x240.png and /dev/null differ diff --git a/grails/ag-plugin/web-app/angleGrinder/img/ui-icons_cd0a0a_256x240.png b/grails/ag-plugin/web-app/angleGrinder/img/ui-icons_cd0a0a_256x240.png deleted file mode 100644 index 8c3af0c41..000000000 Binary files a/grails/ag-plugin/web-app/angleGrinder/img/ui-icons_cd0a0a_256x240.png and /dev/null differ diff --git a/grails/ag-plugin/web-app/angleGrinder/img/ui-icons_f6cf3b_256x240.png b/grails/ag-plugin/web-app/angleGrinder/img/ui-icons_f6cf3b_256x240.png deleted file mode 100644 index 3c3574574..000000000 Binary files a/grails/ag-plugin/web-app/angleGrinder/img/ui-icons_f6cf3b_256x240.png and /dev/null differ diff --git a/grails/ag-plugin/web-app/angleGrinder/scripts/angleGrinder.alerts.min.js b/grails/ag-plugin/web-app/angleGrinder/scripts/angleGrinder.alerts.min.js deleted file mode 100644 index 4bd020a00..000000000 --- a/grails/ag-plugin/web-app/angleGrinder/scripts/angleGrinder.alerts.min.js +++ /dev/null @@ -1,71 +0,0 @@ -(function() { - var Alerts, alerts; - alerts = angular.module("angleGrinder.alerts", []); - alerts.value("alertTimeout", 3e3); - Alerts = function() { - Alerts.$inject = [ "$log", "$timeout", "alertTimeout" ]; - function Alerts($log, $timeout, alertTimeout) { - this.$log = $log; - this.$timeout = $timeout; - this.alertTimeout = alertTimeout; - this.lastId = 0; - this.messages = []; - } - Alerts.prototype.nextId = function() { - return this.lastId += 1; - }; - Alerts.prototype.push = function(type, text) { - var id; - id = this.nextId(); - this.$log.info("Alert [" + id + ", " + type + "]", text); - this.messages.push({ - "id": id, - "type": type, - "text": text - }); - this.delayedDispose(id); - return id; - }; - Alerts.prototype.info = function(text) { - return this.push("info", text); - }; - Alerts.prototype.error = function(text) { - return this.push("error", text); - }; - Alerts.prototype.dispose = function(id) { - var at; - at = _(this.messages.map(function(message) { - return message.id; - })).indexOf(id); - return this.messages.splice(at, 1); - }; - Alerts.prototype.delayedDispose = function(id) { - var disposeTheAlert; - if (this.alertTimeout != null && this.alertTimeout > 0) { - disposeTheAlert = function(_this) { - return function() { - _this.$log.info("Disposing alert", id, "after", _this.alertTimeout, "milliseconds"); - return _this.dispose(id); - }; - }(this); - return this.$timeout(disposeTheAlert, this.alertTimeout); - } - }; - return Alerts; - }(); - alerts.service("alerts", Alerts); - alerts.controller("alerts", [ "$scope", "alerts", function($scope, alerts) { - $scope.alertMessages = alerts.messages; - return $scope.disposeAlert = function(id) { - return alerts.dispose(id); - }; - } ]); - alerts.directive("agAlerts", function() { - return { - "restrict": "E", - "replace": true, - "template": '', - "controller": "alerts" - }; - }); -}).call(this); \ No newline at end of file diff --git a/grails/ag-plugin/web-app/angleGrinder/scripts/angleGrinder.common.min.js b/grails/ag-plugin/web-app/angleGrinder/scripts/angleGrinder.common.min.js deleted file mode 100644 index 98a86c6fb..000000000 --- a/grails/ag-plugin/web-app/angleGrinder/scripts/angleGrinder.common.min.js +++ /dev/null @@ -1,411 +0,0 @@ -(function() { - var common, __slice = [].slice; - common = angular.module("angleGrinder.common", [ "ui.bootstrap.modal" ]); - common.config([ "$localeProvider", "$provide", function($localeProvider, $provide) { - var defaultLocale; - defaultLocale = $localeProvider.$get(); - angular.extend(defaultLocale.NUMBER_FORMATS.PATTERNS[1], { - "negPre": "-", - "negSuf": "" - }); - return $provide.value("$locale", defaultLocale); - } ]); - common.factory("pendingRequests", [ "$http", function($http) { - var pendingRequests; - pendingRequests = function() { - return pendingRequests.any(); - }; - pendingRequests.any = function() { - return pendingRequests["for"]("GET", "POST", "PUT", "PATCH", "DELETE"); - }; - pendingRequests["for"] = function() { - var httpMethods, requests; - httpMethods = 1 <= arguments.length ? __slice.call(arguments, 0) : []; - requests = _.filter($http.pendingRequests, function(request) { - return _.contains(httpMethods, request.method); - }); - return requests.length > 0; - }; - return pendingRequests; - } ]); - common.value("isEmpty", function(str) { - return _.isString(str) && _.isEmpty(str); - }); - common.service("isFalsy", [ "isEmpty", function(isEmpty) { - return function(value) { - if (_.isNaN(value)) { - return true; - } - if (isEmpty(value)) { - return true; - } - if (_.isNull(value)) { - return true; - } - if (_.isUndefined(value)) { - return true; - } - if (value === false) { - return true; - } - return false; - }; - } ]); - common.value("camelize", function(str) { - return str.replace(/(\-|\.|_|\s)+(.)?/g, function(match, p1, p2) { - if (p2) { - return p2.toUpperCase(); - } else { - return ""; - } - }); - }); -}).call(this); - -(function() { - var app; - app = angular.module("angleGrinder.common"); - app.directive("agBackButton", [ "$window", function($window) { - return { - "restrict": "A", - "link": function(scope, element) { - return element.on("click", function(event) { - event.preventDefault(); - return $window.history.back(); - }); - } - }; - } ]); -}).call(this); - -(function() { - var app; - app = angular.module("angleGrinder.common"); - app.provider("agCurrencyFilter", function() { - var defaultFormat, defaultSymbol; - defaultSymbol = "$"; - defaultFormat = "<%= symbol %><%= amount %>"; - return { - "setDefaultSymbol": function(symbol) { - return defaultSymbol = symbol; - }, - "setDefaultFormat": function(format) { - return defaultFormat = format; - }, - "$get": [ "$filter", "isFalsy", function($filter, isFalsy) { - return function(amount, symbol) { - var formattedAmount; - if (symbol == null) { - symbol = defaultSymbol; - } - if (isFalsy(amount)) { - return ""; - } - formattedAmount = $filter("currency")(amount, ""); - return _.template(defaultFormat)({ - "amount": formattedAmount, - "symbol": symbol - }); - }; - } ] - }; - }); -}).call(this); - -(function() { - var app; - app = angular.module("angleGrinder.common"); - app.provider("agDateFilter", function() { - var defaultFormat; - defaultFormat = "mediumDate"; - return { - "setDefaultFormat": function(format) { - return defaultFormat = format; - }, - "$get": [ "$filter", "isFalsy", function($filter, isFalsy) { - return function(date, format) { - if (format == null) { - format = defaultFormat; - } - if (isFalsy(date)) { - return ""; - } - return $filter("date")(date, format); - }; - } ] - }; - }); -}).call(this); - -(function() { - var app; - app = angular.module("angleGrinder.common"); - app.provider("agDateTimeFilter", function() { - var defaultFormat; - defaultFormat = "dd MMM yyyy hh:mm a"; - return { - "setDefaultFormat": function(format) { - return defaultFormat = format; - }, - "$get": [ "$filter", function($filter) { - return function(date, format) { - if (format == null) { - format = defaultFormat; - } - return $filter("agDate")(date, format); - }; - } ] - }; - }); -}).call(this); - -(function() { - var app; - app = angular.module("angleGrinder.common"); - app.filter("checkMark", function() { - return function(input, options) { - if (options == null) { - options = {}; - } - if (input) { - if (options.hideTruth) { - return ""; - } - return "\u2713"; - } else { - if (options.hideFalse) { - return ""; - } - return "\u2718"; - } - }; - }); -}).call(this); - -(function() { - var app, __slice = [].slice; - app = angular.module("angleGrinder.common"); - app.service("deepPick", function() { - var getDeep, setDeep; - getDeep = function(obj, path) { - var key, keys, _i, _len; - keys = path.split("."); - for (_i = 0, _len = keys.length; _i < _len; _i++) { - key = keys[_i]; - obj = obj[key]; - if (obj === void 0) { - return; - } - } - return obj; - }; - setDeep = function(obj, path, value) { - var i, key, keys, n; - keys = path.split("."); - i = 0; - n = keys.length; - n--; - while (i < n) { - key = keys[i++]; - obj = obj[key] = _.isObject(obj[key]) ? obj[key] : {}; - } - return obj[keys[i]] = value; - }; - return function() { - var keys, obj, path, result, value, _i, _len; - obj = arguments[0], keys = 2 <= arguments.length ? __slice.call(arguments, 1) : []; - result = new Object(); - for (_i = 0, _len = keys.length; _i < _len; _i++) { - path = keys[_i]; - value = getDeep(obj, path); - if (value !== void 0) { - setDeep(result, path, value); - } - } - return result; - }; - }); -}).call(this); - -(function() { - var app; - app = angular.module("angleGrinder.common"); - app.filter("newLines", function() { - return function(text) { - if (!angular.isString(text)) { - return text; - } - return text.replace(/\n/g, "
"); - }; - }); -}).call(this); - -(function() { - var app; - app = angular.module("angleGrinder.common"); - app.value("urlBuilder", function(path, params) { - var queryString; - if (params == null) { - params = {}; - } - queryString = _.chain(params).map(function(value, key) { - return "" + key + "=" + value; - }).join("&").value(); - return _.filter([ path, queryString ], function(part) { - return part.length > 0; - }).join("?"); - }); - app.provider("pathWithContext", function() { - var contextPath, sanitizePath; - contextPath = "/"; - sanitizePath = function(path) { - if (path.length === 0) { - return "/"; - } - return "/" + path.replace(/\/*$/, "").replace(/^\/*/, ""); - }; - return { - "setContextPath": function(path) { - contextPath = sanitizePath(path); - }, - "$get": [ "urlBuilder", function(urlBuilder) { - return function(path, params) { - if (params == null) { - params = {}; - } - path = _.filter([ contextPath, sanitizePath(path) ], function(part) { - return part != null && part !== "/"; - }).join(""); - return urlBuilder(path, params); - }; - } ] - }; - }); - app.filter("withContext", [ "pathWithContext", function(pathWithContext) { - return function(path) { - return pathWithContext(path); - }; - } ]); -}).call(this); - -(function() { - var ConfirmationDialogCtrl, app, __hasProp = {}.hasOwnProperty, __extends = function(child, parent) { - for (var key in parent) { - if (__hasProp.call(parent, key)) child[key] = parent[key]; - } - function ctor() { - this.constructor = child; - } - ctor.prototype = parent.prototype; - child.prototype = new ctor(); - child.__super__ = parent.prototype; - return child; - }; - app = angular.module("angleGrinder.common"); - ConfirmationDialogCtrl = function(_super) { - __extends(ConfirmationDialogCtrl, _super); - function ConfirmationDialogCtrl() { - return ConfirmationDialogCtrl.__super__.constructor.apply(this, arguments); - } - ConfirmationDialogCtrl.register(app); - ConfirmationDialogCtrl.inject("$scope", "$modalInstance", "$log", "options"); - ConfirmationDialogCtrl.prototype.close = function(confirmed) { - this.$log.info("[ag] closing confirmation dialog", confirmed); - return this.$modalInstance.close(confirmed); - }; - return ConfirmationDialogCtrl; - }(BaseCtrl); - app.service("confirmationDialog", [ "$modal", "$log", function($modal, $log) { - return { - "open": function(options) { - if (options == null) { - options = {}; - } - if (angular.isString(options)) { - options = { - "message": options - }; - } - if (options.message == null) { - options.message = "Are you sure?"; - } - if (options.cancelLabel == null) { - options.cancelLabel = "Cancel"; - } - if (options.okLabel == null) { - options.okLabel = "Ok"; - } - $log.info("[ag] opening confirmation dialog", options); - return $modal.open({ - "keyboard": false, - "backdrop": "static", - "controller": "ConfirmationDialogCtrl as ctrl", - "template": '\n\n', - "resolve": { - "options": function() { - return options; - } - } - }); - } - }; - } ]); -}).call(this); - -(function() { - var NotificationDialog, NotificationDialogCtrl, app, __hasProp = {}.hasOwnProperty, __extends = function(child, parent) { - for (var key in parent) { - if (__hasProp.call(parent, key)) child[key] = parent[key]; - } - function ctor() { - this.constructor = child; - } - ctor.prototype = parent.prototype; - child.prototype = new ctor(); - child.__super__ = parent.prototype; - return child; - }; - app = angular.module("angleGrinder.common"); - NotificationDialogCtrl = function(_super) { - __extends(NotificationDialogCtrl, _super); - function NotificationDialogCtrl() { - return NotificationDialogCtrl.__super__.constructor.apply(this, arguments); - } - NotificationDialogCtrl.register(app); - NotificationDialogCtrl.inject("$scope", "$modalInstance", "$log", "message"); - NotificationDialogCtrl.prototype.initialize = function() { - return this.expose(this.$scope, "message", "close"); - }; - NotificationDialogCtrl.prototype.close = function() { - this.$log.info("Closing notification dialog"); - return this.$modalInstance.close(); - }; - return NotificationDialogCtrl; - }(BaseCtrl); - app.run([ "$templateCache", function($templateCache) { - return $templateCache.put("templates/dialogs/notification.html", '\n\n'); - } ]); - NotificationDialog = function() { - NotificationDialog.$inject = [ "$modal", "$log" ]; - function NotificationDialog($modal, $log) { - this.$modal = $modal; - this.$log = $log; - } - NotificationDialog.prototype.open = function(message) { - this.$log.info("Opening notification dialog, message:", message); - return this.$modal.open({ - "templateUrl": "templates/dialogs/notification.html", - "controller": "NotificationDialogCtrl", - "keyboard": false, - "backdrop": "static", - "resolve": { - "message": function() { - return message; - } - } - }); - }; - return NotificationDialog; - }(); - app.service("notificationDialog", NotificationDialog); -}).call(this); \ No newline at end of file diff --git a/grails/ag-plugin/web-app/angleGrinder/scripts/angleGrinder.file-upload.min.js b/grails/ag-plugin/web-app/angleGrinder/scripts/angleGrinder.file-upload.min.js deleted file mode 100644 index f079018e7..000000000 --- a/grails/ag-plugin/web-app/angleGrinder/scripts/angleGrinder.file-upload.min.js +++ /dev/null @@ -1,1971 +0,0 @@ -(function($) { - "use strict"; - var loadImage = function(file, callback, options) { - var img = document.createElement("img"), url, oUrl; - img.onerror = callback; - img.onload = function() { - if (oUrl && !(options && options.noRevoke)) { - loadImage.revokeObjectURL(oUrl); - } - if (callback) { - callback(loadImage.scale(img, options)); - } - }; - if (loadImage.isInstanceOf("Blob", file) || loadImage.isInstanceOf("File", file)) { - url = oUrl = loadImage.createObjectURL(file); - img._type = file.type; - } else if (typeof file === "string") { - url = file; - if (options && options.crossOrigin) { - img.crossOrigin = options.crossOrigin; - } - } else { - return false; - } - if (url) { - img.src = url; - return img; - } - return loadImage.readFile(file, function(e) { - var target = e.target; - if (target && target.result) { - img.src = target.result; - } else { - if (callback) { - callback(e); - } - } - }); - }, urlAPI = window.createObjectURL && window || window.URL && URL.revokeObjectURL && URL || window.webkitURL && webkitURL; - loadImage.isInstanceOf = function(type, obj) { - return Object.prototype.toString.call(obj) === "[object " + type + "]"; - }; - loadImage.transformCoordinates = function() { - return; - }; - loadImage.getTransformedOptions = function(options) { - return options; - }; - loadImage.renderImageToCanvas = function(canvas, img, sourceX, sourceY, sourceWidth, sourceHeight, destX, destY, destWidth, destHeight) { - canvas.getContext("2d").drawImage(img, sourceX, sourceY, sourceWidth, sourceHeight, destX, destY, destWidth, destHeight); - return canvas; - }; - loadImage.hasCanvasOption = function(options) { - return options.canvas || options.crop; - }; - loadImage.scale = function(img, options) { - options = options || {}; - var canvas = document.createElement("canvas"), useCanvas = img.getContext || loadImage.hasCanvasOption(options) && canvas.getContext, width = img.naturalWidth || img.width, height = img.naturalHeight || img.height, destWidth = width, destHeight = height, maxWidth, maxHeight, minWidth, minHeight, sourceWidth, sourceHeight, sourceX, sourceY, tmp, scaleUp = function() { - var scale = Math.max((minWidth || destWidth) / destWidth, (minHeight || destHeight) / destHeight); - if (scale > 1) { - destWidth = destWidth * scale; - destHeight = destHeight * scale; - } - }, scaleDown = function() { - var scale = Math.min((maxWidth || destWidth) / destWidth, (maxHeight || destHeight) / destHeight); - if (scale < 1) { - destWidth = destWidth * scale; - destHeight = destHeight * scale; - } - }; - if (useCanvas) { - options = loadImage.getTransformedOptions(options); - sourceX = options.left || 0; - sourceY = options.top || 0; - if (options.sourceWidth) { - sourceWidth = options.sourceWidth; - if (options.right !== undefined && options.left === undefined) { - sourceX = width - sourceWidth - options.right; - } - } else { - sourceWidth = width - sourceX - (options.right || 0); - } - if (options.sourceHeight) { - sourceHeight = options.sourceHeight; - if (options.bottom !== undefined && options.top === undefined) { - sourceY = height - sourceHeight - options.bottom; - } - } else { - sourceHeight = height - sourceY - (options.bottom || 0); - } - destWidth = sourceWidth; - destHeight = sourceHeight; - } - maxWidth = options.maxWidth; - maxHeight = options.maxHeight; - minWidth = options.minWidth; - minHeight = options.minHeight; - if (useCanvas && maxWidth && maxHeight && options.crop) { - destWidth = maxWidth; - destHeight = maxHeight; - tmp = sourceWidth / sourceHeight - maxWidth / maxHeight; - if (tmp < 0) { - sourceHeight = maxHeight * sourceWidth / maxWidth; - if (options.top === undefined && options.bottom === undefined) { - sourceY = (height - sourceHeight) / 2; - } - } else if (tmp > 0) { - sourceWidth = maxWidth * sourceHeight / maxHeight; - if (options.left === undefined && options.right === undefined) { - sourceX = (width - sourceWidth) / 2; - } - } - } else { - if (options.contain || options.cover) { - minWidth = maxWidth = maxWidth || minWidth; - minHeight = maxHeight = maxHeight || minHeight; - } - if (options.cover) { - scaleDown(); - scaleUp(); - } else { - scaleUp(); - scaleDown(); - } - } - if (useCanvas) { - canvas.width = destWidth; - canvas.height = destHeight; - loadImage.transformCoordinates(canvas, options); - return loadImage.renderImageToCanvas(canvas, img, sourceX, sourceY, sourceWidth, sourceHeight, 0, 0, destWidth, destHeight); - } - img.width = destWidth; - img.height = destHeight; - return img; - }; - loadImage.createObjectURL = function(file) { - return urlAPI ? urlAPI.createObjectURL(file) : false; - }; - loadImage.revokeObjectURL = function(url) { - return urlAPI ? urlAPI.revokeObjectURL(url) : false; - }; - loadImage.readFile = function(file, callback, method) { - if (window.FileReader) { - var fileReader = new FileReader(); - fileReader.onload = fileReader.onerror = callback; - method = method || "readAsDataURL"; - if (fileReader[method]) { - fileReader[method](file); - return fileReader; - } - } - return false; - }; - if (typeof define === "function" && define.amd) { - define(function() { - return loadImage; - }); - } else { - $.loadImage = loadImage; - } -})(this); - -(function(factory) { - "use strict"; - if (typeof define === "function" && define.amd) { - define([ "load-image" ], factory); - } else { - factory(window.loadImage); - } -})(function(loadImage) { - "use strict"; - var hasblobSlice = window.Blob && (Blob.prototype.slice || Blob.prototype.webkitSlice || Blob.prototype.mozSlice); - loadImage.blobSlice = hasblobSlice && function() { - var slice = this.slice || this.webkitSlice || this.mozSlice; - return slice.apply(this, arguments); - }; - loadImage.metaDataParsers = { - "jpeg": { - "65505": [] - } - }; - loadImage.parseMetaData = function(file, callback, options) { - options = options || {}; - var that = this, maxMetaDataSize = options.maxMetaDataSize || 262144, data = {}, noMetaData = !(window.DataView && file && file.size >= 12 && file.type === "image/jpeg" && loadImage.blobSlice); - if (noMetaData || !loadImage.readFile(loadImage.blobSlice.call(file, 0, maxMetaDataSize), function(e) { - if (e.target.error) { - console.log(e.target.error); - callback(data); - return; - } - var buffer = e.target.result, dataView = new DataView(buffer), offset = 2, maxOffset = dataView.byteLength - 4, headLength = offset, markerBytes, markerLength, parsers, i; - if (dataView.getUint16(0) === 65496) { - while (offset < maxOffset) { - markerBytes = dataView.getUint16(offset); - if (markerBytes >= 65504 && markerBytes <= 65519 || markerBytes === 65534) { - markerLength = dataView.getUint16(offset + 2) + 2; - if (offset + markerLength > dataView.byteLength) { - console.log("Invalid meta data: Invalid segment size."); - break; - } - parsers = loadImage.metaDataParsers.jpeg[markerBytes]; - if (parsers) { - for (i = 0; i < parsers.length; i += 1) { - parsers[i].call(that, dataView, offset, markerLength, data, options); - } - } - offset += markerLength; - headLength = offset; - } else { - break; - } - } - if (!options.disableImageHead && headLength > 6) { - if (buffer.slice) { - data.imageHead = buffer.slice(0, headLength); - } else { - data.imageHead = new Uint8Array(buffer).subarray(0, headLength); - } - } - } else { - console.log("Invalid JPEG file: Missing JPEG marker."); - } - callback(data); - }, "readAsArrayBuffer")) { - callback(data); - } - }; -}); - -(function(factory) { - "use strict"; - if (typeof define === "function" && define.amd) { - define([ "jquery" ], factory); - } else { - factory(window.jQuery); - } -})(function($) { - "use strict"; - var counter = 0; - $.ajaxTransport("iframe", function(options) { - if (options.async) { - var initialIframeSrc = options.initialIframeSrc || "javascript:false;", form, iframe, addParamChar; - return { - "send": function(_, completeCallback) { - form = $('
'); - form.attr("accept-charset", options.formAcceptCharset); - addParamChar = /\?/.test(options.url) ? "&" : "?"; - if (options.type === "DELETE") { - options.url = options.url + addParamChar + "_method=DELETE"; - options.type = "POST"; - } else if (options.type === "PUT") { - options.url = options.url + addParamChar + "_method=PUT"; - options.type = "POST"; - } else if (options.type === "PATCH") { - options.url = options.url + addParamChar + "_method=PATCH"; - options.type = "POST"; - } - counter += 1; - iframe = $('').bind("load", function() { - var fileInputClones, paramNames = $.isArray(options.paramName) ? options.paramName : [ options.paramName ]; - iframe.unbind("load").bind("load", function() { - var response; - try { - response = iframe.contents(); - if (!response.length || !response[0].firstChild) { - throw new Error(); - } - } catch (e) { - response = undefined; - } - completeCallback(200, "success", { - "iframe": response - }); - $('').appendTo(form); - window.setTimeout(function() { - form.remove(); - }, 0); - }); - form.prop("target", iframe.prop("name")).prop("action", options.url).prop("method", options.type); - if (options.formData) { - $.each(options.formData, function(index, field) { - $('').prop("name", field.name).val(field.value).appendTo(form); - }); - } - if (options.fileInput && options.fileInput.length && options.type === "POST") { - fileInputClones = options.fileInput.clone(); - options.fileInput.after(function(index) { - return fileInputClones[index]; - }); - if (options.paramName) { - options.fileInput.each(function(index) { - $(this).prop("name", paramNames[index] || options.paramName); - }); - } - form.append(options.fileInput).prop("enctype", "multipart/form-data").prop("encoding", "multipart/form-data"); - options.fileInput.removeAttr("form"); - } - form.submit(); - if (fileInputClones && fileInputClones.length) { - options.fileInput.each(function(index, input) { - var clone = $(fileInputClones[index]); - $(input).prop("name", clone.prop("name")).attr("form", clone.attr("form")); - clone.replaceWith(input); - }); - } - }); - form.append(iframe).appendTo(document.body); - }, - "abort": function() { - if (iframe) { - iframe.unbind("load").prop("src", initialIframeSrc); - } - if (form) { - form.remove(); - } - } - }; - } - }); - $.ajaxSetup({ - "converters": { - "iframe text": function(iframe) { - return iframe && $(iframe[0].body).text(); - }, - "iframe json": function(iframe) { - return iframe && $.parseJSON($(iframe[0].body).text()); - }, - "iframe html": function(iframe) { - return iframe && $(iframe[0].body).html(); - }, - "iframe xml": function(iframe) { - var xmlDoc = iframe && iframe[0]; - return xmlDoc && $.isXMLDoc(xmlDoc) ? xmlDoc : $.parseXML(xmlDoc.XMLDocument && xmlDoc.XMLDocument.xml || $(xmlDoc.body).html()); - }, - "iframe script": function(iframe) { - return iframe && $.globalEval($(iframe[0].body).text()); - } - } - }); -}); - -(function(factory) { - "use strict"; - if (typeof define === "function" && define.amd) { - define([ "jquery", "jquery.ui.widget" ], factory); - } else { - factory(window.jQuery); - } -})(function($) { - "use strict"; - $.support.fileInput = !(new RegExp("(Android (1\\.[0156]|2\\.[01]))" + "|(Windows Phone (OS 7|8\\.0))|(XBLWP)|(ZuneWP)|(WPDesktop)" + "|(w(eb)?OSBrowser)|(webOS)" + "|(Kindle/(1\\.0|2\\.[05]|3\\.0))").test(window.navigator.userAgent) || $('').prop("disabled")); - $.support.xhrFileUpload = !!(window.ProgressEvent && window.FileReader); - $.support.xhrFormDataFileUpload = !!window.FormData; - $.support.blobSlice = window.Blob && (Blob.prototype.slice || Blob.prototype.webkitSlice || Blob.prototype.mozSlice); - $.widget("blueimp.fileupload", { - "options": { - "dropZone": $(document), - "pasteZone": $(document), - "fileInput": undefined, - "replaceFileInput": true, - "paramName": undefined, - "singleFileUploads": true, - "limitMultiFileUploads": undefined, - "limitMultiFileUploadSize": undefined, - "limitMultiFileUploadSizeOverhead": 512, - "sequentialUploads": false, - "limitConcurrentUploads": undefined, - "forceIframeTransport": false, - "redirect": undefined, - "redirectParamName": undefined, - "postMessage": undefined, - "multipart": true, - "maxChunkSize": undefined, - "uploadedBytes": undefined, - "recalculateProgress": true, - "progressInterval": 100, - "bitrateInterval": 500, - "autoUpload": true, - "messages": { - "uploadedBytes": "Uploaded bytes exceed file size" - }, - "i18n": function(message, context) { - message = this.messages[message] || message.toString(); - if (context) { - $.each(context, function(key, value) { - message = message.replace("{" + key + "}", value); - }); - } - return message; - }, - "formData": function(form) { - return form.serializeArray(); - }, - "add": function(e, data) { - if (e.isDefaultPrevented()) { - return false; - } - if (data.autoUpload || data.autoUpload !== false && $(this).fileupload("option", "autoUpload")) { - data.process().done(function() { - data.submit(); - }); - } - }, - "processData": false, - "contentType": false, - "cache": false - }, - "_specialOptions": [ "fileInput", "dropZone", "pasteZone", "multipart", "forceIframeTransport" ], - "_blobSlice": $.support.blobSlice && function() { - var slice = this.slice || this.webkitSlice || this.mozSlice; - return slice.apply(this, arguments); - }, - "_BitrateTimer": function() { - this.timestamp = Date.now ? Date.now() : new Date().getTime(); - this.loaded = 0; - this.bitrate = 0; - this.getBitrate = function(now, loaded, interval) { - var timeDiff = now - this.timestamp; - if (!this.bitrate || !interval || timeDiff > interval) { - this.bitrate = (loaded - this.loaded) * (1e3 / timeDiff) * 8; - this.loaded = loaded; - this.timestamp = now; - } - return this.bitrate; - }; - }, - "_isXHRUpload": function(options) { - return !options.forceIframeTransport && (!options.multipart && $.support.xhrFileUpload || $.support.xhrFormDataFileUpload); - }, - "_getFormData": function(options) { - var formData; - if ($.type(options.formData) === "function") { - return options.formData(options.form); - } - if ($.isArray(options.formData)) { - return options.formData; - } - if ($.type(options.formData) === "object") { - formData = []; - $.each(options.formData, function(name, value) { - formData.push({ - "name": name, - "value": value - }); - }); - return formData; - } - return []; - }, - "_getTotal": function(files) { - var total = 0; - $.each(files, function(index, file) { - total += file.size || 1; - }); - return total; - }, - "_initProgressObject": function(obj) { - var progress = { - "loaded": 0, - "total": 0, - "bitrate": 0 - }; - if (obj._progress) { - $.extend(obj._progress, progress); - } else { - obj._progress = progress; - } - }, - "_initResponseObject": function(obj) { - var prop; - if (obj._response) { - for (prop in obj._response) { - if (obj._response.hasOwnProperty(prop)) { - delete obj._response[prop]; - } - } - } else { - obj._response = {}; - } - }, - "_onProgress": function(e, data) { - if (e.lengthComputable) { - var now = Date.now ? Date.now() : new Date().getTime(), loaded; - if (data._time && data.progressInterval && now - data._time < data.progressInterval && e.loaded !== e.total) { - return; - } - data._time = now; - loaded = Math.floor(e.loaded / e.total * (data.chunkSize || data._progress.total)) + (data.uploadedBytes || 0); - this._progress.loaded += loaded - data._progress.loaded; - this._progress.bitrate = this._bitrateTimer.getBitrate(now, this._progress.loaded, data.bitrateInterval); - data._progress.loaded = data.loaded = loaded; - data._progress.bitrate = data.bitrate = data._bitrateTimer.getBitrate(now, loaded, data.bitrateInterval); - this._trigger("progress", $.Event("progress", { - "delegatedEvent": e - }), data); - this._trigger("progressall", $.Event("progressall", { - "delegatedEvent": e - }), this._progress); - } - }, - "_initProgressListener": function(options) { - var that = this, xhr = options.xhr ? options.xhr() : $.ajaxSettings.xhr(); - if (xhr.upload) { - $(xhr.upload).bind("progress", function(e) { - var oe = e.originalEvent; - e.lengthComputable = oe.lengthComputable; - e.loaded = oe.loaded; - e.total = oe.total; - that._onProgress(e, options); - }); - options.xhr = function() { - return xhr; - }; - } - }, - "_isInstanceOf": function(type, obj) { - return Object.prototype.toString.call(obj) === "[object " + type + "]"; - }, - "_initXHRData": function(options) { - var that = this, formData, file = options.files[0], multipart = options.multipart || !$.support.xhrFileUpload, paramName = $.type(options.paramName) === "array" ? options.paramName[0] : options.paramName; - options.headers = $.extend({}, options.headers); - if (options.contentRange) { - options.headers["Content-Range"] = options.contentRange; - } - if (!multipart || options.blob || !this._isInstanceOf("File", file)) { - options.headers["Content-Disposition"] = 'attachment; filename="' + encodeURI(file.name) + '"'; - } - if (!multipart) { - options.contentType = file.type || "application/octet-stream"; - options.data = options.blob || file; - } else if ($.support.xhrFormDataFileUpload) { - if (options.postMessage) { - formData = this._getFormData(options); - if (options.blob) { - formData.push({ - "name": paramName, - "value": options.blob - }); - } else { - $.each(options.files, function(index, file) { - formData.push({ - "name": $.type(options.paramName) === "array" && options.paramName[index] || paramName, - "value": file - }); - }); - } - } else { - if (that._isInstanceOf("FormData", options.formData)) { - formData = options.formData; - } else { - formData = new FormData(); - $.each(this._getFormData(options), function(index, field) { - formData.append(field.name, field.value); - }); - } - if (options.blob) { - formData.append(paramName, options.blob, file.name); - } else { - $.each(options.files, function(index, file) { - if (that._isInstanceOf("File", file) || that._isInstanceOf("Blob", file)) { - formData.append($.type(options.paramName) === "array" && options.paramName[index] || paramName, file, file.uploadName || file.name); - } - }); - } - } - options.data = formData; - } - options.blob = null; - }, - "_initIframeSettings": function(options) { - var targetHost = $("").prop("href", options.url).prop("host"); - options.dataType = "iframe " + (options.dataType || ""); - options.formData = this._getFormData(options); - if (options.redirect && targetHost && targetHost !== location.host) { - options.formData.push({ - "name": options.redirectParamName || "redirect", - "value": options.redirect - }); - } - }, - "_initDataSettings": function(options) { - if (this._isXHRUpload(options)) { - if (!this._chunkedUpload(options, true)) { - if (!options.data) { - this._initXHRData(options); - } - this._initProgressListener(options); - } - if (options.postMessage) { - options.dataType = "postmessage " + (options.dataType || ""); - } - } else { - this._initIframeSettings(options); - } - }, - "_getParamName": function(options) { - var fileInput = $(options.fileInput), paramName = options.paramName; - if (!paramName) { - paramName = []; - fileInput.each(function() { - var input = $(this), name = input.prop("name") || "files[]", i = (input.prop("files") || [ 1 ]).length; - while (i) { - paramName.push(name); - i -= 1; - } - }); - if (!paramName.length) { - paramName = [ fileInput.prop("name") || "files[]" ]; - } - } else if (!$.isArray(paramName)) { - paramName = [ paramName ]; - } - return paramName; - }, - "_initFormSettings": function(options) { - if (!options.form || !options.form.length) { - options.form = $(options.fileInput.prop("form")); - if (!options.form.length) { - options.form = $(this.options.fileInput.prop("form")); - } - } - options.paramName = this._getParamName(options); - if (!options.url) { - options.url = options.form.prop("action") || location.href; - } - options.type = (options.type || $.type(options.form.prop("method")) === "string" && options.form.prop("method") || "").toUpperCase(); - if (options.type !== "POST" && options.type !== "PUT" && options.type !== "PATCH") { - options.type = "POST"; - } - if (!options.formAcceptCharset) { - options.formAcceptCharset = options.form.attr("accept-charset"); - } - }, - "_getAJAXSettings": function(data) { - var options = $.extend({}, this.options, data); - this._initFormSettings(options); - this._initDataSettings(options); - return options; - }, - "_getDeferredState": function(deferred) { - if (deferred.state) { - return deferred.state(); - } - if (deferred.isResolved()) { - return "resolved"; - } - if (deferred.isRejected()) { - return "rejected"; - } - return "pending"; - }, - "_enhancePromise": function(promise) { - promise.success = promise.done; - promise.error = promise.fail; - promise.complete = promise.always; - return promise; - }, - "_getXHRPromise": function(resolveOrReject, context, args) { - var dfd = $.Deferred(), promise = dfd.promise(); - context = context || this.options.context || promise; - if (resolveOrReject === true) { - dfd.resolveWith(context, args); - } else if (resolveOrReject === false) { - dfd.rejectWith(context, args); - } - promise.abort = dfd.promise; - return this._enhancePromise(promise); - }, - "_addConvenienceMethods": function(e, data) { - var that = this, getPromise = function(args) { - return $.Deferred().resolveWith(that, args).promise(); - }; - data.process = function(resolveFunc, rejectFunc) { - if (resolveFunc || rejectFunc) { - data._processQueue = this._processQueue = (this._processQueue || getPromise([ this ])).pipe(function() { - if (data.errorThrown) { - return $.Deferred().rejectWith(that, [ data ]).promise(); - } - return getPromise(arguments); - }).pipe(resolveFunc, rejectFunc); - } - return this._processQueue || getPromise([ this ]); - }; - data.submit = function() { - if (this.state() !== "pending") { - data.jqXHR = this.jqXHR = that._trigger("submit", $.Event("submit", { - "delegatedEvent": e - }), this) !== false && that._onSend(e, this); - } - return this.jqXHR || that._getXHRPromise(); - }; - data.abort = function() { - if (this.jqXHR) { - return this.jqXHR.abort(); - } - this.errorThrown = "abort"; - that._trigger("fail", null, this); - return that._getXHRPromise(false); - }; - data.state = function() { - if (this.jqXHR) { - return that._getDeferredState(this.jqXHR); - } - if (this._processQueue) { - return that._getDeferredState(this._processQueue); - } - }; - data.processing = function() { - return !this.jqXHR && this._processQueue && that._getDeferredState(this._processQueue) === "pending"; - }; - data.progress = function() { - return this._progress; - }; - data.response = function() { - return this._response; - }; - }, - "_getUploadedBytes": function(jqXHR) { - var range = jqXHR.getResponseHeader("Range"), parts = range && range.split("-"), upperBytesPos = parts && parts.length > 1 && parseInt(parts[1], 10); - return upperBytesPos && upperBytesPos + 1; - }, - "_chunkedUpload": function(options, testOnly) { - options.uploadedBytes = options.uploadedBytes || 0; - var that = this, file = options.files[0], fs = file.size, ub = options.uploadedBytes, mcs = options.maxChunkSize || fs, slice = this._blobSlice, dfd = $.Deferred(), promise = dfd.promise(), jqXHR, upload; - if (!(this._isXHRUpload(options) && slice && (ub || mcs < fs)) || options.data) { - return false; - } - if (testOnly) { - return true; - } - if (ub >= fs) { - file.error = options.i18n("uploadedBytes"); - return this._getXHRPromise(false, options.context, [ null, "error", file.error ]); - } - upload = function() { - var o = $.extend({}, options), currentLoaded = o._progress.loaded; - o.blob = slice.call(file, ub, ub + mcs, file.type); - o.chunkSize = o.blob.size; - o.contentRange = "bytes " + ub + "-" + (ub + o.chunkSize - 1) + "/" + fs; - that._initXHRData(o); - that._initProgressListener(o); - jqXHR = (that._trigger("chunksend", null, o) !== false && $.ajax(o) || that._getXHRPromise(false, o.context)).done(function(result, textStatus, jqXHR) { - ub = that._getUploadedBytes(jqXHR) || ub + o.chunkSize; - if (currentLoaded + o.chunkSize - o._progress.loaded) { - that._onProgress($.Event("progress", { - "lengthComputable": true, - "loaded": ub - o.uploadedBytes, - "total": ub - o.uploadedBytes - }), o); - } - options.uploadedBytes = o.uploadedBytes = ub; - o.result = result; - o.textStatus = textStatus; - o.jqXHR = jqXHR; - that._trigger("chunkdone", null, o); - that._trigger("chunkalways", null, o); - if (ub < fs) { - upload(); - } else { - dfd.resolveWith(o.context, [ result, textStatus, jqXHR ]); - } - }).fail(function(jqXHR, textStatus, errorThrown) { - o.jqXHR = jqXHR; - o.textStatus = textStatus; - o.errorThrown = errorThrown; - that._trigger("chunkfail", null, o); - that._trigger("chunkalways", null, o); - dfd.rejectWith(o.context, [ jqXHR, textStatus, errorThrown ]); - }); - }; - this._enhancePromise(promise); - promise.abort = function() { - return jqXHR.abort(); - }; - upload(); - return promise; - }, - "_beforeSend": function(e, data) { - if (this._active === 0) { - this._trigger("start"); - this._bitrateTimer = new this._BitrateTimer(); - this._progress.loaded = this._progress.total = 0; - this._progress.bitrate = 0; - } - this._initResponseObject(data); - this._initProgressObject(data); - data._progress.loaded = data.loaded = data.uploadedBytes || 0; - data._progress.total = data.total = this._getTotal(data.files) || 1; - data._progress.bitrate = data.bitrate = 0; - this._active += 1; - this._progress.loaded += data.loaded; - this._progress.total += data.total; - }, - "_onDone": function(result, textStatus, jqXHR, options) { - var total = options._progress.total, response = options._response; - if (options._progress.loaded < total) { - this._onProgress($.Event("progress", { - "lengthComputable": true, - "loaded": total, - "total": total - }), options); - } - response.result = options.result = result; - response.textStatus = options.textStatus = textStatus; - response.jqXHR = options.jqXHR = jqXHR; - this._trigger("done", null, options); - }, - "_onFail": function(jqXHR, textStatus, errorThrown, options) { - var response = options._response; - if (options.recalculateProgress) { - this._progress.loaded -= options._progress.loaded; - this._progress.total -= options._progress.total; - } - response.jqXHR = options.jqXHR = jqXHR; - response.textStatus = options.textStatus = textStatus; - response.errorThrown = options.errorThrown = errorThrown; - this._trigger("fail", null, options); - }, - "_onAlways": function(jqXHRorResult, textStatus, jqXHRorError, options) { - this._trigger("always", null, options); - }, - "_onSend": function(e, data) { - if (!data.submit) { - this._addConvenienceMethods(e, data); - } - var that = this, jqXHR, aborted, slot, pipe, options = that._getAJAXSettings(data), send = function() { - that._sending += 1; - options._bitrateTimer = new that._BitrateTimer(); - jqXHR = jqXHR || ((aborted || that._trigger("send", $.Event("send", { - "delegatedEvent": e - }), options) === false) && that._getXHRPromise(false, options.context, aborted) || that._chunkedUpload(options) || $.ajax(options)).done(function(result, textStatus, jqXHR) { - that._onDone(result, textStatus, jqXHR, options); - }).fail(function(jqXHR, textStatus, errorThrown) { - that._onFail(jqXHR, textStatus, errorThrown, options); - }).always(function(jqXHRorResult, textStatus, jqXHRorError) { - that._onAlways(jqXHRorResult, textStatus, jqXHRorError, options); - that._sending -= 1; - that._active -= 1; - if (options.limitConcurrentUploads && options.limitConcurrentUploads > that._sending) { - var nextSlot = that._slots.shift(); - while (nextSlot) { - if (that._getDeferredState(nextSlot) === "pending") { - nextSlot.resolve(); - break; - } - nextSlot = that._slots.shift(); - } - } - if (that._active === 0) { - that._trigger("stop"); - } - }); - return jqXHR; - }; - this._beforeSend(e, options); - if (this.options.sequentialUploads || this.options.limitConcurrentUploads && this.options.limitConcurrentUploads <= this._sending) { - if (this.options.limitConcurrentUploads > 1) { - slot = $.Deferred(); - this._slots.push(slot); - pipe = slot.pipe(send); - } else { - this._sequence = this._sequence.pipe(send, send); - pipe = this._sequence; - } - pipe.abort = function() { - aborted = [ undefined, "abort", "abort" ]; - if (!jqXHR) { - if (slot) { - slot.rejectWith(options.context, aborted); - } - return send(); - } - return jqXHR.abort(); - }; - return this._enhancePromise(pipe); - } - return send(); - }, - "_onAdd": function(e, data) { - var that = this, result = true, options = $.extend({}, this.options, data), files = data.files, filesLength = files.length, limit = options.limitMultiFileUploads, limitSize = options.limitMultiFileUploadSize, overhead = options.limitMultiFileUploadSizeOverhead, batchSize = 0, paramName = this._getParamName(options), paramNameSet, paramNameSlice, fileSet, i, j = 0; - if (limitSize && (!filesLength || files[0].size === undefined)) { - limitSize = undefined; - } - if (!(options.singleFileUploads || limit || limitSize) || !this._isXHRUpload(options)) { - fileSet = [ files ]; - paramNameSet = [ paramName ]; - } else if (!(options.singleFileUploads || limitSize) && limit) { - fileSet = []; - paramNameSet = []; - for (i = 0; i < filesLength; i += limit) { - fileSet.push(files.slice(i, i + limit)); - paramNameSlice = paramName.slice(i, i + limit); - if (!paramNameSlice.length) { - paramNameSlice = paramName; - } - paramNameSet.push(paramNameSlice); - } - } else if (!options.singleFileUploads && limitSize) { - fileSet = []; - paramNameSet = []; - for (i = 0; i < filesLength; i = i + 1) { - batchSize += files[i].size + overhead; - if (i + 1 === filesLength || batchSize + files[i + 1].size + overhead > limitSize || limit && i + 1 - j >= limit) { - fileSet.push(files.slice(j, i + 1)); - paramNameSlice = paramName.slice(j, i + 1); - if (!paramNameSlice.length) { - paramNameSlice = paramName; - } - paramNameSet.push(paramNameSlice); - j = i + 1; - batchSize = 0; - } - } - } else { - paramNameSet = paramName; - } - data.originalFiles = files; - $.each(fileSet || files, function(index, element) { - var newData = $.extend({}, data); - newData.files = fileSet ? element : [ element ]; - newData.paramName = paramNameSet[index]; - that._initResponseObject(newData); - that._initProgressObject(newData); - that._addConvenienceMethods(e, newData); - result = that._trigger("add", $.Event("add", { - "delegatedEvent": e - }), newData); - return result; - }); - return result; - }, - "_replaceFileInput": function(input) { - var inputClone = input.clone(true); - $("
").append(inputClone)[0].reset(); - input.after(inputClone).detach(); - $.cleanData(input.unbind("remove")); - this.options.fileInput = this.options.fileInput.map(function(i, el) { - if (el === input[0]) { - return inputClone[0]; - } - return el; - }); - if (input[0] === this.element[0]) { - this.element = inputClone; - } - }, - "_handleFileTreeEntry": function(entry, path) { - var that = this, dfd = $.Deferred(), errorHandler = function(e) { - if (e && !e.entry) { - e.entry = entry; - } - dfd.resolve([ e ]); - }, dirReader; - path = path || ""; - if (entry.isFile) { - if (entry._file) { - entry._file.relativePath = path; - dfd.resolve(entry._file); - } else { - entry.file(function(file) { - file.relativePath = path; - dfd.resolve(file); - }, errorHandler); - } - } else if (entry.isDirectory) { - dirReader = entry.createReader(); - dirReader.readEntries(function(entries) { - that._handleFileTreeEntries(entries, path + entry.name + "/").done(function(files) { - dfd.resolve(files); - }).fail(errorHandler); - }, errorHandler); - } else { - dfd.resolve([]); - } - return dfd.promise(); - }, - "_handleFileTreeEntries": function(entries, path) { - var that = this; - return $.when.apply($, $.map(entries, function(entry) { - return that._handleFileTreeEntry(entry, path); - })).pipe(function() { - return Array.prototype.concat.apply([], arguments); - }); - }, - "_getDroppedFiles": function(dataTransfer) { - dataTransfer = dataTransfer || {}; - var items = dataTransfer.items; - if (items && items.length && (items[0].webkitGetAsEntry || items[0].getAsEntry)) { - return this._handleFileTreeEntries($.map(items, function(item) { - var entry; - if (item.webkitGetAsEntry) { - entry = item.webkitGetAsEntry(); - if (entry) { - entry._file = item.getAsFile(); - } - return entry; - } - return item.getAsEntry(); - })); - } - return $.Deferred().resolve($.makeArray(dataTransfer.files)).promise(); - }, - "_getSingleFileInputFiles": function(fileInput) { - fileInput = $(fileInput); - var entries = fileInput.prop("webkitEntries") || fileInput.prop("entries"), files, value; - if (entries && entries.length) { - return this._handleFileTreeEntries(entries); - } - files = $.makeArray(fileInput.prop("files")); - if (!files.length) { - value = fileInput.prop("value"); - if (!value) { - return $.Deferred().resolve([]).promise(); - } - files = [ { - "name": value.replace(/^.*\\/, "") - } ]; - } else if (files[0].name === undefined && files[0].fileName) { - $.each(files, function(index, file) { - file.name = file.fileName; - file.size = file.fileSize; - }); - } - return $.Deferred().resolve(files).promise(); - }, - "_getFileInputFiles": function(fileInput) { - if (!(fileInput instanceof $) || fileInput.length === 1) { - return this._getSingleFileInputFiles(fileInput); - } - return $.when.apply($, $.map(fileInput, this._getSingleFileInputFiles)).pipe(function() { - return Array.prototype.concat.apply([], arguments); - }); - }, - "_onChange": function(e) { - var that = this, data = { - "fileInput": $(e.target), - "form": $(e.target.form) - }; - this._getFileInputFiles(data.fileInput).always(function(files) { - data.files = files; - if (that.options.replaceFileInput) { - that._replaceFileInput(data.fileInput); - } - if (that._trigger("change", $.Event("change", { - "delegatedEvent": e - }), data) !== false) { - that._onAdd(e, data); - } - }); - }, - "_onPaste": function(e) { - var items = e.originalEvent && e.originalEvent.clipboardData && e.originalEvent.clipboardData.items, data = { - "files": [] - }; - if (items && items.length) { - $.each(items, function(index, item) { - var file = item.getAsFile && item.getAsFile(); - if (file) { - data.files.push(file); - } - }); - if (this._trigger("paste", $.Event("paste", { - "delegatedEvent": e - }), data) !== false) { - this._onAdd(e, data); - } - } - }, - "_onDrop": function(e) { - e.dataTransfer = e.originalEvent && e.originalEvent.dataTransfer; - var that = this, dataTransfer = e.dataTransfer, data = {}; - if (dataTransfer && dataTransfer.files && dataTransfer.files.length) { - e.preventDefault(); - this._getDroppedFiles(dataTransfer).always(function(files) { - data.files = files; - if (that._trigger("drop", $.Event("drop", { - "delegatedEvent": e - }), data) !== false) { - that._onAdd(e, data); - } - }); - } - }, - "_onDragOver": function(e) { - e.dataTransfer = e.originalEvent && e.originalEvent.dataTransfer; - var dataTransfer = e.dataTransfer; - if (dataTransfer && $.inArray("Files", dataTransfer.types) !== -1 && this._trigger("dragover", $.Event("dragover", { - "delegatedEvent": e - })) !== false) { - e.preventDefault(); - dataTransfer.dropEffect = "copy"; - } - }, - "_initEventHandlers": function() { - if (this._isXHRUpload(this.options)) { - this._on(this.options.dropZone, { - "dragover": this._onDragOver, - "drop": this._onDrop - }); - this._on(this.options.pasteZone, { - "paste": this._onPaste - }); - } - if ($.support.fileInput) { - this._on(this.options.fileInput, { - "change": this._onChange - }); - } - }, - "_destroyEventHandlers": function() { - this._off(this.options.dropZone, "dragover drop"); - this._off(this.options.pasteZone, "paste"); - this._off(this.options.fileInput, "change"); - }, - "_setOption": function(key, value) { - var reinit = $.inArray(key, this._specialOptions) !== -1; - if (reinit) { - this._destroyEventHandlers(); - } - this._super(key, value); - if (reinit) { - this._initSpecialOptions(); - this._initEventHandlers(); - } - }, - "_initSpecialOptions": function() { - var options = this.options; - if (options.fileInput === undefined) { - options.fileInput = this.element.is('input[type="file"]') ? this.element : this.element.find('input[type="file"]'); - } else if (!(options.fileInput instanceof $)) { - options.fileInput = $(options.fileInput); - } - if (!(options.dropZone instanceof $)) { - options.dropZone = $(options.dropZone); - } - if (!(options.pasteZone instanceof $)) { - options.pasteZone = $(options.pasteZone); - } - }, - "_getRegExp": function(str) { - var parts = str.split("/"), modifiers = parts.pop(); - parts.shift(); - return new RegExp(parts.join("/"), modifiers); - }, - "_isRegExpOption": function(key, value) { - return key !== "url" && $.type(value) === "string" && /^\/.*\/[igm]{0,3}$/.test(value); - }, - "_initDataAttributes": function() { - var that = this, options = this.options; - $.each($(this.element[0].cloneNode(false)).data(), function(key, value) { - if (that._isRegExpOption(key, value)) { - value = that._getRegExp(value); - } - options[key] = value; - }); - }, - "_create": function() { - this._initDataAttributes(); - this._initSpecialOptions(); - this._slots = []; - this._sequence = this._getXHRPromise(true); - this._sending = this._active = 0; - this._initProgressObject(this); - this._initEventHandlers(); - }, - "active": function() { - return this._active; - }, - "progress": function() { - return this._progress; - }, - "add": function(data) { - var that = this; - if (!data || this.options.disabled) { - return; - } - if (data.fileInput && !data.files) { - this._getFileInputFiles(data.fileInput).always(function(files) { - data.files = files; - that._onAdd(null, data); - }); - } else { - data.files = $.makeArray(data.files); - this._onAdd(null, data); - } - }, - "send": function(data) { - if (data && !this.options.disabled) { - if (data.fileInput && !data.files) { - var that = this, dfd = $.Deferred(), promise = dfd.promise(), jqXHR, aborted; - promise.abort = function() { - aborted = true; - if (jqXHR) { - return jqXHR.abort(); - } - dfd.reject(null, "abort", "abort"); - return promise; - }; - this._getFileInputFiles(data.fileInput).always(function(files) { - if (aborted) { - return; - } - if (!files.length) { - dfd.reject(); - return; - } - data.files = files; - jqXHR = that._onSend(null, data).then(function(result, textStatus, jqXHR) { - dfd.resolve(result, textStatus, jqXHR); - }, function(jqXHR, textStatus, errorThrown) { - dfd.reject(jqXHR, textStatus, errorThrown); - }); - }); - return this._enhancePromise(promise); - } - data.files = $.makeArray(data.files); - if (data.files.length) { - return this._onSend(null, data); - } - } - return this._getXHRPromise(false, data && data.context); - } - }); -}); - -(function(factory) { - "use strict"; - if (typeof define === "function" && define.amd) { - define([ "jquery", "./jquery.fileupload" ], factory); - } else { - factory(window.jQuery); - } -})(function($) { - "use strict"; - var originalAdd = $.blueimp.fileupload.prototype.options.add; - $.widget("blueimp.fileupload", $.blueimp.fileupload, { - "options": { - "processQueue": [], - "add": function(e, data) { - var $this = $(this); - data.process(function() { - return $this.fileupload("process", data); - }); - originalAdd.call(this, e, data); - } - }, - "processActions": {}, - "_processFile": function(data, originalData) { - var that = this, dfd = $.Deferred().resolveWith(that, [ data ]), chain = dfd.promise(); - this._trigger("process", null, data); - $.each(data.processQueue, function(i, settings) { - var func = function(data) { - if (originalData.errorThrown) { - return $.Deferred().rejectWith(that, [ originalData ]).promise(); - } - return that.processActions[settings.action].call(that, data, settings); - }; - chain = chain.pipe(func, settings.always && func); - }); - chain.done(function() { - that._trigger("processdone", null, data); - that._trigger("processalways", null, data); - }).fail(function() { - that._trigger("processfail", null, data); - that._trigger("processalways", null, data); - }); - return chain; - }, - "_transformProcessQueue": function(options) { - var processQueue = []; - $.each(options.processQueue, function() { - var settings = {}, action = this.action, prefix = this.prefix === true ? action : this.prefix; - $.each(this, function(key, value) { - if ($.type(value) === "string" && value.charAt(0) === "@") { - settings[key] = options[value.slice(1) || (prefix ? prefix + key.charAt(0).toUpperCase() + key.slice(1) : key)]; - } else { - settings[key] = value; - } - }); - processQueue.push(settings); - }); - options.processQueue = processQueue; - }, - "processing": function() { - return this._processing; - }, - "process": function(data) { - var that = this, options = $.extend({}, this.options, data); - if (options.processQueue && options.processQueue.length) { - this._transformProcessQueue(options); - if (this._processing === 0) { - this._trigger("processstart"); - } - $.each(data.files, function(index) { - var opts = index ? $.extend({}, options) : options, func = function() { - if (data.errorThrown) { - return $.Deferred().rejectWith(that, [ data ]).promise(); - } - return that._processFile(opts, data); - }; - opts.index = index; - that._processing += 1; - that._processingQueue = that._processingQueue.pipe(func, func).always(function() { - that._processing -= 1; - if (that._processing === 0) { - that._trigger("processstop"); - } - }); - }); - } - return this._processingQueue; - }, - "_create": function() { - this._super(); - this._processing = 0; - this._processingQueue = $.Deferred().resolveWith(this).promise(); - } - }); -}); - -(function(factory) { - "use strict"; - if (typeof define === "function" && define.amd) { - define([ "jquery", "./jquery.fileupload-process" ], factory); - } else { - factory(window.jQuery); - } -})(function($) { - "use strict"; - $.blueimp.fileupload.prototype.options.processQueue.push({ - "action": "validate", - "always": true, - "acceptFileTypes": "@", - "maxFileSize": "@", - "minFileSize": "@", - "maxNumberOfFiles": "@", - "disabled": "@disableValidation" - }); - $.widget("blueimp.fileupload", $.blueimp.fileupload, { - "options": { - "getNumberOfFiles": $.noop, - "messages": { - "maxNumberOfFiles": "Maximum number of files exceeded", - "acceptFileTypes": "File type not allowed", - "maxFileSize": "File is too large", - "minFileSize": "File is too small" - } - }, - "processActions": { - "validate": function(data, options) { - if (options.disabled) { - return data; - } - var dfd = $.Deferred(), settings = this.options, file = data.files[data.index], fileSize; - if (options.minFileSize || options.maxFileSize) { - fileSize = file.size; - } - if ($.type(options.maxNumberOfFiles) === "number" && (settings.getNumberOfFiles() || 0) + data.files.length > options.maxNumberOfFiles) { - file.error = settings.i18n("maxNumberOfFiles"); - } else if (options.acceptFileTypes && !(options.acceptFileTypes.test(file.type) || options.acceptFileTypes.test(file.name))) { - file.error = settings.i18n("acceptFileTypes"); - } else if (fileSize > options.maxFileSize) { - file.error = settings.i18n("maxFileSize"); - } else if ($.type(fileSize) === "number" && fileSize < options.minFileSize) { - file.error = settings.i18n("minFileSize"); - } else { - delete file.error; - } - if (file.error || data.files.error) { - data.files.error = true; - dfd.rejectWith(this, [ data ]); - } else { - dfd.resolveWith(this, [ data ]); - } - return dfd.promise(); - } - } - }); -}); - -(function(factory) { - "use strict"; - if (typeof define === "function" && define.amd) { - define([ "jquery", "load-image", "./jquery.fileupload-process" ], factory); - } else { - factory(window.jQuery, window.loadImage); - } -})(function($, loadImage) { - "use strict"; - $.blueimp.fileupload.prototype.options.processQueue.unshift({ - "action": "loadAudio", - "prefix": true, - "fileTypes": "@", - "maxFileSize": "@", - "disabled": "@disableAudioPreview" - }, { - "action": "setAudio", - "name": "@audioPreviewName", - "disabled": "@disableAudioPreview" - }); - $.widget("blueimp.fileupload", $.blueimp.fileupload, { - "options": { - "loadAudioFileTypes": /^audio\/.*$/ - }, - "_audioElement": document.createElement("audio"), - "processActions": { - "loadAudio": function(data, options) { - if (options.disabled) { - return data; - } - var file = data.files[data.index], url, audio; - if (this._audioElement.canPlayType && this._audioElement.canPlayType(file.type) && ($.type(options.maxFileSize) !== "number" || file.size <= options.maxFileSize) && (!options.fileTypes || options.fileTypes.test(file.type))) { - url = loadImage.createObjectURL(file); - if (url) { - audio = this._audioElement.cloneNode(false); - audio.src = url; - audio.controls = true; - data.audio = audio; - return data; - } - } - return data; - }, - "setAudio": function(data, options) { - if (data.audio && !options.disabled) { - data.files[data.index][options.name || "preview"] = data.audio; - } - return data; - } - } - }); -}); - -(function(factory) { - "use strict"; - if (typeof define === "function" && define.amd) { - define([ "jquery", "load-image", "./jquery.fileupload-process" ], factory); - } else { - factory(window.jQuery, window.loadImage); - } -})(function($, loadImage) { - "use strict"; - $.blueimp.fileupload.prototype.options.processQueue.unshift({ - "action": "loadVideo", - "prefix": true, - "fileTypes": "@", - "maxFileSize": "@", - "disabled": "@disableVideoPreview" - }, { - "action": "setVideo", - "name": "@videoPreviewName", - "disabled": "@disableVideoPreview" - }); - $.widget("blueimp.fileupload", $.blueimp.fileupload, { - "options": { - "loadVideoFileTypes": /^video\/.*$/ - }, - "_videoElement": document.createElement("video"), - "processActions": { - "loadVideo": function(data, options) { - if (options.disabled) { - return data; - } - var file = data.files[data.index], url, video; - if (this._videoElement.canPlayType && this._videoElement.canPlayType(file.type) && ($.type(options.maxFileSize) !== "number" || file.size <= options.maxFileSize) && (!options.fileTypes || options.fileTypes.test(file.type))) { - url = loadImage.createObjectURL(file); - if (url) { - video = this._videoElement.cloneNode(false); - video.src = url; - video.controls = true; - data.video = video; - return data; - } - } - return data; - }, - "setVideo": function(data, options) { - if (data.video && !options.disabled) { - data.files[data.index][options.name || "preview"] = data.video; - } - return data; - } - } - }); -}); - -(function(factory) { - "use strict"; - if (typeof define === "function" && define.amd) { - define([ "jquery", "load-image", "load-image-meta", "load-image-exif", "load-image-ios", "canvas-to-blob", "./jquery.fileupload-process" ], factory); - } else { - factory(window.jQuery, window.loadImage); - } -})(function($, loadImage) { - "use strict"; - $.blueimp.fileupload.prototype.options.processQueue.unshift({ - "action": "loadImageMetaData", - "disableImageHead": "@", - "disableExif": "@", - "disableExifThumbnail": "@", - "disableExifSub": "@", - "disableExifGps": "@", - "disabled": "@disableImageMetaDataLoad" - }, { - "action": "loadImage", - "prefix": true, - "fileTypes": "@", - "maxFileSize": "@", - "noRevoke": "@", - "disabled": "@disableImageLoad" - }, { - "action": "resizeImage", - "prefix": "image", - "maxWidth": "@", - "maxHeight": "@", - "minWidth": "@", - "minHeight": "@", - "crop": "@", - "orientation": "@", - "forceResize": "@", - "disabled": "@disableImageResize" - }, { - "action": "saveImage", - "quality": "@imageQuality", - "type": "@imageType", - "disabled": "@disableImageResize" - }, { - "action": "saveImageMetaData", - "disabled": "@disableImageMetaDataSave" - }, { - "action": "resizeImage", - "prefix": "preview", - "maxWidth": "@", - "maxHeight": "@", - "minWidth": "@", - "minHeight": "@", - "crop": "@", - "orientation": "@", - "thumbnail": "@", - "canvas": "@", - "disabled": "@disableImagePreview" - }, { - "action": "setImage", - "name": "@imagePreviewName", - "disabled": "@disableImagePreview" - }, { - "action": "deleteImageReferences", - "disabled": "@disableImageReferencesDeletion" - }); - $.widget("blueimp.fileupload", $.blueimp.fileupload, { - "options": { - "loadImageFileTypes": /^image\/(gif|jpeg|png)$/, - "loadImageMaxFileSize": 1e7, - "imageMaxWidth": 1920, - "imageMaxHeight": 1080, - "imageOrientation": false, - "imageCrop": false, - "disableImageResize": true, - "previewMaxWidth": 80, - "previewMaxHeight": 80, - "previewOrientation": true, - "previewThumbnail": true, - "previewCrop": false, - "previewCanvas": true - }, - "processActions": { - "loadImage": function(data, options) { - if (options.disabled) { - return data; - } - var that = this, file = data.files[data.index], dfd = $.Deferred(); - if ($.type(options.maxFileSize) === "number" && file.size > options.maxFileSize || options.fileTypes && !options.fileTypes.test(file.type) || !loadImage(file, function(img) { - if (img.src) { - data.img = img; - } - dfd.resolveWith(that, [ data ]); - }, options)) { - return data; - } - return dfd.promise(); - }, - "resizeImage": function(data, options) { - if (options.disabled || !(data.canvas || data.img)) { - return data; - } - options = $.extend({ - "canvas": true - }, options); - var that = this, dfd = $.Deferred(), img = options.canvas && data.canvas || data.img, resolve = function(newImg) { - if (newImg && (newImg.width !== img.width || newImg.height !== img.height || options.forceResize)) { - data[newImg.getContext ? "canvas" : "img"] = newImg; - } - data.preview = newImg; - dfd.resolveWith(that, [ data ]); - }, thumbnail; - if (data.exif) { - if (options.orientation === true) { - options.orientation = data.exif.get("Orientation"); - } - if (options.thumbnail) { - thumbnail = data.exif.get("Thumbnail"); - if (thumbnail) { - loadImage(thumbnail, resolve, options); - return dfd.promise(); - } - } - } - if (img) { - resolve(loadImage.scale(img, options)); - return dfd.promise(); - } - return data; - }, - "saveImage": function(data, options) { - if (!data.canvas || options.disabled) { - return data; - } - var that = this, file = data.files[data.index], dfd = $.Deferred(); - if (data.canvas.toBlob) { - data.canvas.toBlob(function(blob) { - if (!blob.name) { - if (file.type === blob.type) { - blob.name = file.name; - } else if (file.name) { - blob.name = file.name.replace(/\..+$/, "." + blob.type.substr(6)); - } - } - if (file.type !== blob.type) { - delete data.imageHead; - } - data.files[data.index] = blob; - dfd.resolveWith(that, [ data ]); - }, options.type || file.type, options.quality); - } else { - return data; - } - return dfd.promise(); - }, - "loadImageMetaData": function(data, options) { - if (options.disabled) { - return data; - } - var that = this, dfd = $.Deferred(); - loadImage.parseMetaData(data.files[data.index], function(result) { - $.extend(data, result); - dfd.resolveWith(that, [ data ]); - }, options); - return dfd.promise(); - }, - "saveImageMetaData": function(data, options) { - if (!(data.imageHead && data.canvas && data.canvas.toBlob && !options.disabled)) { - return data; - } - var file = data.files[data.index], blob = new Blob([ data.imageHead, this._blobSlice.call(file, 20) ], { - "type": file.type - }); - blob.name = file.name; - data.files[data.index] = blob; - return data; - }, - "setImage": function(data, options) { - if (data.preview && !options.disabled) { - data.files[data.index][options.name || "preview"] = data.preview; - } - return data; - }, - "deleteImageReferences": function(data, options) { - if (!options.disabled) { - delete data.img; - delete data.canvas; - delete data.preview; - delete data.imageHead; - } - return data; - } - } - }); -}); - -(function(factory) { - "use strict"; - if (typeof define === "function" && define.amd) { - define([ "jquery", "angular", "./jquery.fileupload-image", "./jquery.fileupload-audio", "./jquery.fileupload-video", "./jquery.fileupload-validate" ], factory); - } else { - factory(); - } -})(function() { - "use strict"; - angular.module("blueimp.fileupload", []).provider("fileUpload", function() { - var scopeEvalAsync = function(expression) { - var scope = angular.element(this).fileupload("option", "scope"); - scope.$evalAsync(expression); - }, addFileMethods = function(scope, data) { - var files = data.files, file = files[0]; - angular.forEach(files, function(file, index) { - file._index = index; - file.$state = function() { - return data.state(); - }; - file.$processing = function() { - return data.processing(); - }; - file.$progress = function() { - return data.progress(); - }; - file.$response = function() { - return data.response(); - }; - }); - file.$submit = function() { - if (!file.error) { - return data.submit(); - } - }; - file.$cancel = function() { - return data.abort(); - }; - }, $config; - $config = this.defaults = { - "handleResponse": function(e, data) { - var files = data.result && data.result.files; - if (files) { - data.scope.replace(data.files, files); - } else if (data.errorThrown || data.textStatus === "error") { - data.files[0].error = data.errorThrown || data.textStatus; - } - }, - "add": function(e, data) { - if (e.isDefaultPrevented()) { - return false; - } - var scope = data.scope, filesCopy = []; - angular.forEach(data.files, function(file) { - filesCopy.push(file); - }); - scope.$apply(function() { - addFileMethods(scope, data); - var method = scope.option("prependFiles") ? "unshift" : "push"; - Array.prototype[method].apply(scope.queue, data.files); - }); - data.process(function() { - return scope.process(data); - }).always(function() { - scope.$apply(function() { - addFileMethods(scope, data); - scope.replace(filesCopy, data.files); - }); - }).then(function() { - if ((scope.option("autoUpload") || data.autoUpload) && data.autoUpload !== false) { - data.submit(); - } - }); - }, - "progress": function(e, data) { - if (e.isDefaultPrevented()) { - return false; - } - data.scope.$apply(); - }, - "done": function(e, data) { - if (e.isDefaultPrevented()) { - return false; - } - var that = this; - data.scope.$apply(function() { - data.handleResponse.call(that, e, data); - }); - }, - "fail": function(e, data) { - if (e.isDefaultPrevented()) { - return false; - } - var that = this, scope = data.scope; - if (data.errorThrown === "abort") { - scope.clear(data.files); - return; - } - scope.$apply(function() { - data.handleResponse.call(that, e, data); - }); - }, - "stop": scopeEvalAsync, - "processstart": scopeEvalAsync, - "processstop": scopeEvalAsync, - "getNumberOfFiles": function() { - var scope = this.scope; - return scope.queue.length - scope.processing(); - }, - "dataType": "json", - "autoUpload": false - }; - this.$get = [ function() { - return { - "defaults": $config - }; - } ]; - }).provider("formatFileSizeFilter", function() { - var $config = { - "units": [ { - "size": 1e9, - "suffix": " GB" - }, { - "size": 1e6, - "suffix": " MB" - }, { - "size": 1e3, - "suffix": " KB" - } ] - }; - this.defaults = $config; - this.$get = function() { - return function(bytes) { - if (!angular.isNumber(bytes)) { - return ""; - } - var unit = true, i = 0, prefix, suffix; - while (unit) { - unit = $config.units[i]; - prefix = unit.prefix || ""; - suffix = unit.suffix || ""; - if (i === $config.units.length - 1 || bytes >= unit.size) { - return prefix + (bytes / unit.size).toFixed(2) + suffix; - } - i += 1; - } - }; - }; - }).controller("FileUploadController", [ "$scope", "$element", "$attrs", "$window", "fileUpload", function($scope, $element, $attrs, $window, fileUpload) { - var uploadMethods = { - "progress": function() { - return $element.fileupload("progress"); - }, - "active": function() { - return $element.fileupload("active"); - }, - "option": function(option, data) { - if (arguments.length === 1) { - return $element.fileupload("option", option); - } - $element.fileupload("option", option, data); - }, - "add": function(data) { - return $element.fileupload("add", data); - }, - "send": function(data) { - return $element.fileupload("send", data); - }, - "process": function(data) { - return $element.fileupload("process", data); - }, - "processing": function(data) { - return $element.fileupload("processing", data); - } - }; - $scope.disabled = !$window.jQuery.support.fileInput; - $scope.queue = $scope.queue || []; - $scope.clear = function(files) { - var queue = this.queue, i = queue.length, file = files, length = 1; - if (angular.isArray(files)) { - file = files[0]; - length = files.length; - } - while (i) { - i -= 1; - if (queue[i] === file) { - return queue.splice(i, length); - } - } - }; - $scope.replace = function(oldFiles, newFiles) { - var queue = this.queue, file = oldFiles[0], i, j; - for (i = 0; i < queue.length; i += 1) { - if (queue[i] === file) { - for (j = 0; j < newFiles.length; j += 1) { - queue[i + j] = newFiles[j]; - } - return; - } - } - }; - $scope.applyOnQueue = function(method) { - var list = this.queue.slice(0), i, file; - for (i = 0; i < list.length; i += 1) { - file = list[i]; - if (file[method]) { - file[method](); - } - } - }; - $scope.submit = function() { - this.applyOnQueue("$submit"); - }; - $scope.cancel = function() { - this.applyOnQueue("$cancel"); - }; - angular.extend($scope, uploadMethods); - $element.fileupload(angular.extend({ - "scope": $scope - }, fileUpload.defaults)).on("fileuploadadd", function(e, data) { - data.scope = $scope; - }).on("fileuploadfail", function(e, data) { - if (data.errorThrown === "abort") { - return; - } - if (data.dataType && data.dataType.indexOf("json") === data.dataType.length - 4) { - try { - data.result = angular.fromJson(data.jqXHR.responseText); - } catch (ignore) {} - } - }).on([ "fileuploadadd", "fileuploadsubmit", "fileuploadsend", "fileuploaddone", "fileuploadfail", "fileuploadalways", "fileuploadprogress", "fileuploadprogressall", "fileuploadstart", "fileuploadstop", "fileuploadchange", "fileuploadpaste", "fileuploaddrop", "fileuploaddragover", "fileuploadchunksend", "fileuploadchunkdone", "fileuploadchunkfail", "fileuploadchunkalways", "fileuploadprocessstart", "fileuploadprocess", "fileuploadprocessdone", "fileuploadprocessfail", "fileuploadprocessalways", "fileuploadprocessstop" ].join(" "), function(e, data) { - if ($scope.$emit(e.type, data).defaultPrevented) { - e.preventDefault(); - } - }).on("remove", function() { - var method; - for (method in uploadMethods) { - if (uploadMethods.hasOwnProperty(method)) { - delete $scope[method]; - } - } - }); - $scope.$watch($attrs.fileUpload, function(newOptions) { - if (newOptions) { - $element.fileupload("option", newOptions); - } - }); - } ]).controller("FileUploadProgressController", [ "$scope", "$attrs", "$parse", function($scope, $attrs, $parse) { - var fn = $parse($attrs.fileUploadProgress), update = function() { - var progress = fn($scope); - if (!progress || !progress.total) { - return; - } - $scope.num = Math.floor(progress.loaded / progress.total * 100); - }; - update(); - $scope.$watch($attrs.fileUploadProgress + ".loaded", function(newValue, oldValue) { - if (newValue !== oldValue) { - update(); - } - }); - } ]).controller("FileUploadPreviewController", [ "$scope", "$element", "$attrs", function($scope, $element, $attrs) { - $scope.$watch($attrs.fileUploadPreview + ".preview", function(preview) { - $element.empty(); - if (preview) { - $element.append(preview); - } - }); - } ]).directive("fileUpload", function() { - return { - "controller": "FileUploadController", - "scope": true - }; - }).directive("fileUploadProgress", function() { - return { - "controller": "FileUploadProgressController", - "scope": true - }; - }).directive("fileUploadPreview", function() { - return { - "controller": "FileUploadPreviewController" - }; - }).directive("download", function() { - return function(scope, elm) { - elm.on("dragstart", function(e) { - try { - e.originalEvent.dataTransfer.setData("DownloadURL", [ "application/octet-stream", elm.prop("download"), elm.prop("href") ].join(":")); - } catch (ignore) {} - }); - }; - }); -}); \ No newline at end of file diff --git a/grails/ag-plugin/web-app/angleGrinder/scripts/angleGrinder.forms.min.js b/grails/ag-plugin/web-app/angleGrinder/scripts/angleGrinder.forms.min.js deleted file mode 100644 index 3828640a4..000000000 --- a/grails/ag-plugin/web-app/angleGrinder/scripts/angleGrinder.forms.min.js +++ /dev/null @@ -1,1178 +0,0 @@ -(function() { - var forms; - angular.module("ui.bootstrap.datepicker").config([ "$provide", function($provide) { - return $provide.decorator("daypickerDirective", function($delegate) { - var directive, oldCompile; - directive = $delegate[0]; - oldCompile = directive.compile; - directive.compile = function() { - var link; - link = oldCompile.apply(this, arguments); - return function(scope) { - link.apply(this, arguments); - return scope.$watch("rows", function() { - return angular.forEach(scope.rows, function(row) { - if (_.every(row, function(dt) { - return dt.secondary; - })) { - return _.map(row, function(dt) { - return dt.hide = true; - }); - } - }); - }); - }; - }; - return $delegate; - }); - } ]); - forms = angular.module("angleGrinder.forms", [ "ui.bootstrap", "xeditable", "angleGrinder.common" ]); - forms.run([ "datepickerConfig", "datepickerPopupConfig", function(datepickerConfig, datepickerPopupConfig) { - datepickerConfig.showWeeks = false; - datepickerConfig.formatDay = "d"; - return datepickerPopupConfig.showButtonBar = false; - } ]); - forms.run([ "$templateCache", function($templateCache) { - $templateCache.put("template/pagination/pagination.html", ''); - $templateCache.put("template/datepicker/day.html", '\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n
\n {{title}}\n
{{label.abbr}}
{{ weekNumbers[$index] }}\n \n {{dt.label}}\n \n
'); - $templateCache.put("template/datepicker/month.html", '\n \n \n \n \n \n \n \n \n \n \n \n \n
{{title}}
\n \n {{dt.label}}\n \n
'); - return $templateCache.put("template/datepicker/year.html", '\n \n \n \n \n \n \n \n \n \n \n \n \n
{{title}}
\n \n {{dt.label}}\n \n
'); - } ]); -}).call(this); - -(function() { - var app; - app = angular.module("angleGrinder.forms"); - app.directive("editableCustom", [ "editableDirectiveFactory", function(editableDirectiveFactory) { - var compile, result; - result = editableDirectiveFactory({ - "directiveName": "editableCustom" - }); - compile = result.compile; - result.compile = function(element) { - var link, templateEl, tpl; - templateEl = element.next("[editable-custom-template]"); - tpl = templateEl.html(); - templateEl.remove(); - compile.apply(this, arguments); - link = result.link; - return function(scope, element, attrs, ctrl) { - var eCtrl; - eCtrl = ctrl[0]; - eCtrl.inputTpl = tpl; - return link.apply(this, arguments); - }; - }; - return result; - } ]); -}).call(this); - -(function() { - var forms; - forms = angular.module("angleGrinder.forms"); - forms.directive("editableDatepicker", [ "editableDirectiveFactory", function(editableDirectiveFactory) { - return editableDirectiveFactory({ - "directiveName": "editableDatepicker", - "inputTpl": '', - "render": function() { - var div; - this.parent.render.call(this); - div = angular.element('
'); - this.inputEl.wrap(div); - return this.inputEl.after(''); - }, - "init": function() { - this.parent.init.call(this); - this.scope.opened = false; - return this.scope.open = function(_this) { - return function($event) { - $event.preventDefault(); - $event.stopPropagation(); - return _this.scope.opened = true; - }; - }(this); - } - }); - } ]); -}).call(this); - -(function() { - var app; - app = angular.module("angleGrinder.forms"); - app.directive("editableFormButtons", [ "$parse", function($parse) { - return { - "restrict": "A", - "scope": true, - "link": function(scope, element, attrs) { - return scope.form = $parse(attrs.editableFormButtons)(scope); - }, - "template": '
\n \n\n \n \n\n \n \n
' - }; - } ]); -}).call(this); - -(function() { - var forms; - forms = angular.module("angleGrinder.forms"); - forms.directive("editableSelect2", [ "editableDirectiveFactory", function(editableDirectiveFactory) { - return editableDirectiveFactory({ - "directiveName": "editableSelect2", - "inputTpl": '' - }); - } ]); -}).call(this); - -(function() { - var forms; - forms = angular.module("angleGrinder.forms"); - forms.config([ "$provide", function($provide) { - return $provide.decorator("editableDirectiveFactory", [ "$delegate", "validationMessages", function($delegate, validationMessages) { - var errorsFor; - errorsFor = function(model) { - var callback; - callback = function(result, invalid, error) { - if (invalid) { - result.push(validationMessages[error]); - } - return result; - }; - return _.reduce(model.$error, callback, []).join(", "); - }; - return function() { - var directive, link; - directive = $delegate.apply(this, arguments); - link = directive.link; - directive.compile = function(element, attrs) { - return function(scope, element, attrs, ctrl) { - var form, name, viewValue; - link.apply(this, arguments); - form = ctrl[1]; - name = attrs.eName; - if (form != null && name != null) { - viewValue = function() { - var _ref; - return (_ref = form[name]) != null ? _ref.$viewValue : void 0; - }; - return scope.$watch(viewValue, function() { - var model; - model = form[name]; - if (model != null ? model.$invalid : void 0) { - form.$setError(name, errorsFor(model)); - } - if (model != null ? model.$valid : void 0) { - return form.$setError(name, ""); - } - }); - } - }; - }; - return directive; - }; - } ]); - } ]); -}).call(this); - -(function() { - var forms; - forms = angular.module("angleGrinder.forms"); - forms.directive("agDeleteButton", function() { - return { - "restrict": "E", - "replace": true, - "scope": { - "whenConfirmed": "&" - }, - "controller": [ "$scope", function($scope) { - $scope.confirmation = false; - $scope.showConfirmation = function() { - return $scope.confirmation = true; - }; - return $scope.doDelete = function() { - var promise; - $scope.confirmation = false; - promise = $scope.whenConfirmed(); - $scope.deleting = true; - return promise != null ? typeof promise["finally"] === "function" ? promise["finally"](function() { - return $scope.deleting = false; - }) : void 0 : void 0; - }; - } ], - "template": '' - }; - }); -}).call(this); - -(function() { - var forms; - forms = angular.module("angleGrinder.forms"); - forms.directive("agSubmit", [ "$parse", "$log", "serverValidationErrorsHandler", function($parse, $log, serverValidationErrorsHandler) { - return { - "restrict": "A", - "require": "form", - "compile": function(element, attrs) { - var markAsSubmitted, onSubmit; - onSubmit = $parse(attrs.agSubmit); - markAsSubmitted = function(form) { - var nestedForm, nestedForms, _i, _len, _results; - form.$submitted = true; - nestedForms = _.filter(_.values(form), function(input) { - return input instanceof form.constructor; - }); - _results = []; - for (_i = 0, _len = nestedForms.length; _i < _len; _i++) { - nestedForm = nestedForms[_i]; - _results.push(markAsSubmitted(nestedForm)); - } - return _results; - }; - return function(scope, element, attrs, formCtrl) { - return element.on("submit", function(event) { - var promise, resource, result; - $log.debug("[forms] submitting form", formCtrl.$name, element, formCtrl); - scope.$apply(function() { - return markAsSubmitted(formCtrl); - }); - if (formCtrl.$invalid) { - return; - } - result = _.flatten([ onSubmit(scope, { - "$event": event - }) ]); - promise = result[0], resource = result[1]; - if (promise && angular.isObject(promise)) { - formCtrl.$saving = true; - promise["finally"](function() { - return formCtrl.$saving = false; - }); - promise.then(function() { - formCtrl.$setPristine(); - return formCtrl.$submitted = false; - }); - return promise["catch"](function(response) { - if (!angular.isFunction(resource != null ? resource.resourceName : void 0)) { - return; - } - return serverValidationErrorsHandler(formCtrl, response, resource.resourceName()); - }); - } - }); - }; - } - }; - } ]); -}).call(this); - -(function() { - var forms; - forms = angular.module("angleGrinder.forms"); - forms.directive("agSubmitButton", function() { - return { - "restrict": "E", - "replace": true, - "scope": true, - "require": "^form", - "link": function(scope, element, attrs, formCtrl) { - var isSaving; - isSaving = function() { - return formCtrl.$saving; - }; - return scope.$watch(isSaving, function(saving) { - return scope.saving = saving; - }); - }, - "template": '' - }; - }); -}).call(this); - -(function() { - var forms; - forms = angular.module("angleGrinder.forms"); - forms.directive("agDatepicker", [ "$compile", function($compile) { - return { - "restrict": "A", - "replace": true, - "scope": true, - "transclude": true, - "controller": [ "$scope", "$rootScope", function($scope, $rootScope) { - $scope.opened = false; - $scope.open = function($event) { - $event.preventDefault(); - $event.stopPropagation(); - $scope.opened = true; - return $rootScope.$broadcast("ag:closeOtherPickers", $scope.$id); - }; - return $rootScope.$on("ag:closeOtherPickers", function(event, otherId) { - if ($scope.$id !== otherId) { - return $scope.opened = false; - } - }); - } ], - "compile": function(element, attrs, transclude) { - return function(scope, element) { - return transclude(scope, function(clone) { - clone.attr("datepicker-popup", "MM/dd/yyyy"); - clone.attr("is-open", "opened"); - return $compile(clone)(scope, function(clone) { - return element.prepend(clone); - }); - }); - }; - }, - "template": '
\n\n \n
' - }; - } ]); -}).call(this); - -(function() { - var forms; - forms = angular.module("angleGrinder.forms"); - forms.directive("agCreateButton", function() { - return { - "restrict": "E", - "replace": true, - "transclude": true, - "compile": function(element, attrs, trasclude) { - return { - "pre": function(scope, element) { - return trasclude(scope, function(clone) { - if ($.trim(clone.text()) === "") { - return element.append("Create"); - } - }); - } - }; - }, - "template": '\n \n \n' - }; - }); - forms.directive("agCancelButton", function() { - return { - "restrict": "E", - "replace": true, - "template": '' - }; - }); -}).call(this); - -(function() { - var forms; - forms = angular.module("angleGrinder.forms"); - forms.value("validationMessages", { - "required": "This field is required", - "mismatch": "Does not match the confirmation", - "minlength": "This field is too short", - "maxlength": "This field is too long", - "email": "Invalid email address", - "pattern": "Invalid pattern" - }); - forms.directive("match", [ "isEmpty", function(isEmpty) { - return { - "require": "ngModel", - "link": function(scope, elem, attrs, modelCtrl) { - var validateEqual, validator; - validateEqual = function(value, otherValue) { - var allEmpty, valid; - allEmpty = _.all([ isEmpty(value), isEmpty(otherValue) ]); - valid = allEmpty || value === otherValue; - modelCtrl.$setValidity("mismatch", valid); - return value; - }; - scope.$watch(attrs.match, function(otherValue) { - return validateEqual(modelCtrl.$viewValue, otherValue); - }); - validator = function(value) { - var otherValue; - otherValue = scope.$eval(attrs.match); - return validateEqual(value, otherValue); - }; - modelCtrl.$parsers.unshift(validator); - return modelCtrl.$formatters.unshift(validator); - } - }; - } ]); - forms.directive("agFieldGroup", [ "$timeout", "$log", function($timeout, $log) { - return { - "restrict": "A", - "require": "^form", - "replace": true, - "transclude": true, - "template": '
', - "link": function(scope, element, attrs, formCtrl) { - var fields, isSubmitted, toggleErrors; - fields = (attrs["for"] || "").split(","); - toggleErrors = function() { - return $timeout(function() { - var invalid; - invalid = _.map(fields, function(field) { - var _ref, _ref1; - return ((_ref = formCtrl[field]) != null ? _ref.$invalid : void 0) || ((_ref1 = formCtrl.$serverErrors) != null ? _ref1[field] : void 0); - }); - if (_.any(invalid)) { - return element.addClass("error"); - } else { - return element.removeClass("error"); - } - }); - }; - angular.forEach(fields, function(field) { - var getViewValue; - getViewValue = function() { - var _ref; - return (_ref = formCtrl[field]) != null ? _ref.$viewValue : void 0; - }; - return scope.$watch(getViewValue, function() { - var _ref; - if (!((_ref = formCtrl[field]) != null ? _ref.$dirty : void 0)) { - return; - } - return toggleErrors(); - }); - }); - angular.forEach(fields, function(field) { - var getServerErrors, initial; - initial = true; - getServerErrors = function() { - var _ref; - return (_ref = formCtrl.$serverErrors) != null ? _ref[field] : void 0; - }; - return scope.$watch(getServerErrors, function() { - if (!initial) { - toggleErrors(); - } - return initial = false; - }); - }); - isSubmitted = function() { - return formCtrl.$submitted; - }; - return scope.$watch(isSubmitted, function(submitted) { - if (!submitted) { - return; - } - return toggleErrors(); - }); - } - }; - } ]); - forms.directive("agValidationErrors", [ "validationMessages", function(validationMessages) { - return { - "restrict": "E", - "require": "^form", - "replace": true, - "link": function(scope, element, attrs, formCtrl) { - var appendError, clearErrors, displayErrorMessages, field, fieldName, getServerErrors, getViewValue, initial, isSubmitted, isValid, messageFor; - fieldName = attrs["for"]; - field = formCtrl[fieldName]; - clearErrors = function() { - return element.html(""); - }; - messageFor = function(error) { - return attrs[error] || validationMessages[error]; - }; - appendError = function(message, klass) { - if (klass == null) { - klass = ""; - } - return element.append('' + message + ""); - }; - displayErrorMessages = function() { - var error, invalid, message, _ref, _results; - clearErrors(); - _ref = field.$error; - _results = []; - for (error in _ref) { - invalid = _ref[error]; - if (!invalid) { - continue; - } - message = messageFor(error); - if (message != null) { - _results.push(appendError(message)); - } else { - _results.push(void 0); - } - } - return _results; - }; - initial = true; - isValid = function() { - var _ref; - return (_ref = formCtrl[fieldName]) != null ? _ref.$valid : void 0; - }; - scope.$watch(isValid, function() { - if (!initial) { - displayErrorMessages(); - } - return initial = false; - }); - getViewValue = function() { - var _ref; - return (_ref = formCtrl[fieldName]) != null ? _ref.$viewValue : void 0; - }; - scope.$watch(getViewValue, function() { - if (field.$dirty) { - return displayErrorMessages(); - } - }); - isSubmitted = function() { - return formCtrl.$submitted; - }; - scope.$watch(isSubmitted, function(submitted) { - if (submitted) { - return displayErrorMessages(); - } - }); - getServerErrors = function() { - var _ref; - return (_ref = formCtrl.$serverErrors) != null ? _ref[fieldName] : void 0; - }; - return scope.$watch(getServerErrors, function(serverError) { - if (serverError != null) { - return appendError(serverError, "server-error"); - } else { - return element.find(".server-error").remove(); - } - }); - } - }; - } ]); - forms.directive("agServerValidationErrors", function() { - return { - "restrict": "A", - "require": "^form", - "link": function(scope, element, attrs, formCtrl) { - var getServerErrors; - formCtrl.$serverErrors = {}; - getServerErrors = function() { - return formCtrl.$serverErrors; - }; - return scope.$watch(getServerErrors, function(serverErrors) { - return angular.forEach(serverErrors, function(_, field) { - var getViewValue, unregister; - getViewValue = function() { - var _ref; - return (_ref = formCtrl[field]) != null ? _ref.$viewValue : void 0; - }; - return unregister = scope.$watch(getViewValue, function(oldVal, newVal) { - var _ref; - if (oldVal === newVal) { - return; - } - if ((_ref = formCtrl[field]) != null) { - _ref.$setValidity("server", true); - } - formCtrl.$serverErrors[field] = null; - return unregister(); - }); - }); - }); - } - }; - }); - forms.factory("serverValidationErrorsHandler", [ "$log", function($log) { - var setErrors; - setErrors = function(form, errors) { - var field, message, _ref, _results; - form.$serverErrors = {}; - _results = []; - for (field in errors) { - message = errors[field]; - if (typeof message === "object" && form[field] != null) { - setErrors(form[field], message); - } - if (typeof message === "string") { - if ((_ref = form[field]) != null) { - _ref.$setValidity("server", false); - } - _results.push(form.$serverErrors[field] = message); - } else { - _results.push(void 0); - } - } - return _results; - }; - return function(form, response, resourceName) { - var errors, _ref, _ref1; - errors = (_ref = response.data) != null ? (_ref1 = _ref.errors) != null ? _ref1[resourceName] : void 0 : void 0; - if (response.status !== 422 || errors == null) { - $log.warn("Response does not contain validation errors", response); - return; - } - return setErrors(form, errors); - }; - } ]); -}).call(this); - -(function() { - var forms; - forms = angular.module("angleGrinder.forms"); - forms.factory("focus", [ "$rootScope", "$timeout", function($rootScope, $timeout) { - return function(name) { - return $timeout(function() { - return $rootScope.$broadcast("focusOn", name); - }); - }; - } ]); - forms.directive("agFocus", function() { - return { - "restrict": "A", - "link": function(scope, element, attributes) { - var currentName; - currentName = attributes.agFocus; - return scope.$on("focusOn", function(event, name) { - if (currentName === name) { - element.addClass("ag-focused"); - return element[0].focus(); - } - }); - } - }; - }); -}).call(this); - -(function() { - var forms; - forms = angular.module("angleGrinder.forms"); - forms.factory("massUpdateHandler", [ "$log", function($log) { - return function(grid, result) { - var error, id, row, _i, _len, _ref, _ref1, _results; - $log.info("[forms] Mass update response", result); - if (result.data != null) { - _ref = result.data; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - row = _ref[_i]; - grid.updateRow(row.id, row); - } - } else { - $log.warn("[forms] Invalid JSON response, missing data array"); - } - if (result.errors != null) { - _ref1 = result.errors; - _results = []; - for (id in _ref1) { - error = _ref1[id]; - _results.push(grid.flashOnError(id)); - } - return _results; - } else { - return $log.warn("[forms] Invalid JSON response, missing errors assoc array"); - } - }; - } ]); -}).call(this); - -(function() { - var forms; - forms = angular.module("angleGrinder.forms"); - forms.factory("formDialog", [ "$modal", "pathWithContext", function($modal, pathWithContext) { - return { - "open": function(templateUrl, dialogOptions) { - if (dialogOptions == null) { - dialogOptions = {}; - } - return $modal.open({ - "templateUrl": pathWithContext(templateUrl), - "controller": "FormDialogCtrl", - "keyboard": false, - "backdrop": "static", - "resolve": { - "dialogOptions": function() { - return dialogOptions; - } - } - }); - } - }; - } ]); -}).call(this); - -(function() { - var FormDialogCtrl, forms, __bind = function(fn, me) { - return function() { - return fn.apply(me, arguments); - }; - }, __hasProp = {}.hasOwnProperty, __extends = function(child, parent) { - for (var key in parent) { - if (__hasProp.call(parent, key)) child[key] = parent[key]; - } - function ctor() { - this.constructor = child; - } - ctor.prototype = parent.prototype; - child.prototype = new ctor(); - child.__super__ = parent.prototype; - return child; - }; - forms = angular.module("angleGrinder.forms"); - FormDialogCtrl = function(_super) { - __extends(FormDialogCtrl, _super); - function FormDialogCtrl() { - this["delete"] = __bind(this["delete"], this); - this.save = __bind(this.save, this); - this.closeDialog = __bind(this.closeDialog, this); - return FormDialogCtrl.__super__.constructor.apply(this, arguments); - } - FormDialogCtrl.register(forms, "FormDialogCtrl"); - FormDialogCtrl.inject("$scope", "$rootScope", "$log", "$modalInstance", "dialogOptions"); - FormDialogCtrl.prototype.initialize = function() { - var resourceName, _ref; - this.$scope.dialogOptions = this.dialogOptions; - _ref = this.$scope.dialogOptions, this.record = _ref.record, this.grid = _ref.grid; - resourceName = angular.isFunction(this.record.resourceName) ? this.record.resourceName() : "record"; - this.$scope[resourceName] = this.record; - return this.expose(this.$scope, "closeDialog", "save", "delete"); - }; - FormDialogCtrl.prototype.closeDialog = function() { - this.$log.info("[ag] closing the dialog"); - return this.$modalInstance.close(this.record); - }; - FormDialogCtrl.prototype.save = function(record) { - var promise; - promise = record.save().$promise; - promise.then(function(_this) { - return function(record) { - _this.$log.info("[ag] record has been updated/created", record); - _this.grid.saveRow(record.id, record); - return _this.$scope.closeDialog(); - }; - }(this)); - return [ promise, record ]; - }; - FormDialogCtrl.prototype["delete"] = function() { - var promise; - promise = this.record["delete"]().$promise; - promise.then(function(_this) { - return function(response) { - _this.$log.info("[ag] record has been deleted", response); - _this.grid.removeRow(response.id); - return _this.$scope.closeDialog(); - }; - }(this)); - promise["catch"](function(_this) { - return function(response) { - return _this.$log.error("[ag] something went wrong", response); - }; - }(this)); - return promise; - }; - return FormDialogCtrl; - }(BaseCtrl); -}).call(this); - -(function() { - var forms; - forms = angular.module("angleGrinder.forms"); - forms.directive("agTabset", [ "$parse", "$q", function($parse, $q) { - return { - "restrict": "E", - "replace": true, - "transclude": true, - "scope": true, - "require": "agTabset", - "controller": [ "$log", "$scope", "$location", function($log, $scope, $location) { - $scope.tabs = []; - $scope.contentLoading = false; - $scope.currentTab = function() { - return _.findWhere($scope.tabs, { - "selected": true - }); - }; - $scope.currentTemplateUrl = function() { - var currentTab; - currentTab = $scope.currentTab(); - if (currentTab) { - return currentTab.tplSrc; - } - }; - $scope.contentLoaded = function() { - var tab; - $scope.contentLoading = false; - tab = $scope.currentTab(); - tab.loading = false; - if (tab.name != null) { - $location.search("tab", tab.name); - } - return $log.debug("[tabs] content loaded", tab); - }; - this.openTab = function(name) { - var deferred, tab, unregister; - deferred = $q.defer(); - tab = _.findWhere($scope.tabs, { - "name": name - }); - if (tab == null) { - return deferred.promise; - } - if (!tab.selected) { - this._selectTab(tab); - } - unregister = tab.$watch("loading", function(loading) { - if (loading) { - return; - } - deferred.resolve(tab); - return unregister(); - }); - return deferred.promise; - }; - this._selectTab = function(tab) { - angular.forEach($scope.tabs, function(tab) { - return tab.selected = tab.loading = false; - }); - tab.selected = true; - tab.loading = true; - return $scope.contentLoading = true; - }; - this._addTab = function(tab, select) { - if (select == null) { - select = false; - } - $scope.tabs.push(tab); - if (select || $scope.tabs.length === 1) { - return this._selectTab(tab); - } - }; - } ], - "link": function(scope, element, attrs, ctrl) { - var alias; - alias = attrs.name; - if (alias) { - return $parse(alias).assign(scope.$parent, ctrl); - } - }, - "template": '
\n \n
\n loading the content\n \n
\n
' - }; - } ]); - forms.directive("agTab", [ "$log", "$location", "pathWithContext", function($log, $location, pathWithContext) { - return { - "restrict": "E", - "replace": true, - "require": "^agTabset", - "transclude": true, - "scope": { - "templateUrl": "@", - "name": "@" - }, - "link": function(scope, element, attrs, tabsetCtrl) { - var active; - scope.tplSrc = pathWithContext(scope.templateUrl); - scope.selected = false; - scope.loading = false; - active = function() { - return scope.name != null && $location.search().tab === scope.name; - }; - tabsetCtrl._addTab(scope, active()); - return scope.select = function() { - if (scope.selected) { - return; - } - return tabsetCtrl._selectTab(scope); - }; - }, - "template": '
  • \n {{heading}}\n
  • ' - }; - } ]); -}).call(this); - -(function() { - var forms; - forms = angular.module("angleGrinder.forms"); - forms.value("getRealPanelHeight", function(el) { - var bodyEl, height, oldHeight; - bodyEl = el.find(".panel-body:visible"); - oldHeight = bodyEl.height(); - bodyEl.css("min-height", "auto"); - height = el.height(); - bodyEl.css("min-height", oldHeight); - return height; - }); - forms.directive("agPanelsRow", [ "getRealPanelHeight", function(getHeight) { - return { - "restrict": "C", - "controller": function() { - this.panels = []; - this.registerPanel = function(el) { - return this.panels.push($(el)); - }; - this.maxHeight = function() { - var highest; - highest = _.max(this.panels, function(el) { - return getHeight(el); - }); - return getHeight(highest); - }; - this.allEqual = function() { - var heights; - heights = _.chain(this.panels).map(function(el) { - return getHeight(el); - }).value(); - return _.all(heights, function(height) { - return height === heights[0]; - }); - }; - this.equalize = function() { - var maxHeight; - if (this.allEqual()) { - return; - } - maxHeight = this.maxHeight(); - return angular.forEach(this.panels, function(el) { - var bodyEl, paddings; - bodyEl = el.find(".panel-body"); - paddings = parseInt(bodyEl.css("padding-top")) + parseInt(bodyEl.css("padding-bottom")); - paddings += el.find(".panel-heading").outerHeight(); - paddings += el.find(".panel-footer").outerHeight(); - return bodyEl.css("min-height", maxHeight - paddings); - }); - }; - return this; - } - }; - } ]); - forms.directive("agPanel", [ "getRealPanelHeight", function(getHeight) { - return { - "restrict": "C", - "require": "^agPanelsRow", - "link": function(scope, element, attrs, ctrl) { - var elementHeight; - ctrl.registerPanel(element); - elementHeight = function() { - return getHeight(element); - }; - return scope.$watch(elementHeight, function() { - return ctrl.equalize(); - }); - } - }; - } ]); -}).call(this); - -(function() { - var app; - app = angular.module("angleGrinder.forms"); - app.service("select2Options", function() { - return function(options, dataOptions) { - var ajax, defaults; - if (options == null) { - options = {}; - } - if (dataOptions == null) { - dataOptions = {}; - } - options.ajax || (options.ajax = {}); - defaults = { - "width": "element", - "initSelection": angular.noop, - "ajax": { - "dataType": "json", - "url": angular.noop, - "data": function(term, page) { - var dataDefaults; - if (page == null) { - page = 1; - } - dataDefaults = { - "q": term, - "sort": "id", - "order": "asc", - "max": 20, - "page": page - }; - return angular.extend(dataDefaults, dataOptions); - }, - "results": function(result, page) { - return { - "results": result.rows, - "more": page < result.total - }; - } - }, - "formatResult": function(record) { - return record.name; - }, - "formatSelection": function(record) { - return record.name; - } - }; - ajax = angular.extend(defaults.ajax, options.ajax); - options = angular.extend(defaults, options); - options.ajax = ajax; - return options; - }; - }); -}).call(this); - -(function() { - var mixin; - mixin = angular.module("angleGrinder.forms"); - mixin.factory("dialogCrudCtrlMixin", [ "$log", "$parse", "formDialog", "confirmationDialog", function($log, $parse, formDialog, confirmationDialog) { - return function($scope, options) { - var Resource, extraDialogOptions, getGrid, gridName, openEditDialogFor, templateUrl; - if (options == null) { - options = {}; - } - Resource = options.Resource, gridName = options.gridName, templateUrl = options.templateUrl, - extraDialogOptions = options.extraDialogOptions; - getGrid = function() { - return $parse(gridName)($scope); - }; - openEditDialogFor = function(record) { - var dialogOptions; - dialogOptions = { - "record": record, - "grid": getGrid() - }; - return formDialog.open(templateUrl, _.extend(dialogOptions, extraDialogOptions)); - }; - $scope.editRecord = function(id) { - return Resource.get({ - "id": id - }, function(record) { - if (options.beforeEdit != null) { - record = options.beforeEdit(record); - } - return openEditDialogFor(record); - }); - }; - $scope.createRecord = function() { - var record; - record = new Resource(); - if (options.beforeCreate != null) { - record = options.beforeCreate(record); - } - return openEditDialogFor(record); - }; - return $scope.deleteRecord = function(id) { - return confirmationDialog.open().result.then(function(confirmed) { - var promise; - if (!confirmed) { - return; - } - promise = Resource["delete"]({ - "id": id - }).$promise; - promise.then(function(record) { - return getGrid().removeRow(record.id); - }); - promise["catch"](function(response) { - return $log.error("Cannot delete a resource", response); - }); - return promise; - }); - }; - }; - } ]); -}).call(this); - -(function() { - var mixin; - mixin = angular.module("angleGrinder.forms"); - mixin.factory("singlePageCrudCtrlMixin", [ "$log", "$location", "dialogCrudCtrlMixin", function($log, $location, dialogCrudCtrlMixin) { - return function($scope, args) { - var Resource, gridName, resourcePath; - if (args == null) { - args = {}; - } - resourcePath = args.resourcePath, gridName = args.gridName, Resource = args.Resource; - dialogCrudCtrlMixin($scope, { - "gridName": gridName, - "Resource": Resource - }); - $scope.createRecord = angular.noop; - $scope.showRecord = function(id) { - var showRecordPath; - showRecordPath = [ resourcePath, id ].join("/"); - return $location.path(showRecordPath); - }; - return $scope.editRecord = function(id) { - var editRecordPath; - editRecordPath = [ resourcePath, id, "edit" ].join("/"); - return $location.path(editRecordPath); - }; - }; - } ]); -}).call(this); - -(function() { - var mixin; - mixin = angular.module("angleGrinder.forms"); - mixin.factory("massUpdateFormCtrlMixin", [ "$log", "massUpdateHandler", function($log, massUpdateHandler) { - return function($scope, args) { - var Resource, beforeSave, dialog, grid, selectedIds; - if (args == null) { - args = {}; - } - dialog = args.dialog, Resource = args.Resource, selectedIds = args.selectedIds, - grid = args.grid, beforeSave = args.beforeSave; - $scope.massUpdate = function(records) { - var data, params, promise; - data = angular.copy(records); - $log.info("[forms] mass update", data); - if (angular.isFunction(beforeSave)) { - data = beforeSave(data); - } - params = { - "ids": selectedIds, - "data": data - }; - promise = Resource.massUpdate(params).$promise; - return promise.then(function(result) { - massUpdateHandler(grid, result); - $scope.closeDialog(); - return result; - }); - }; - return $scope.closeDialog = function() { - $log.info("[forms] closing the mass update dialog"); - return dialog.close(); - }; - }; - } ]); -}).call(this); - -(function() { - var mixin; - mixin = angular.module("angleGrinder.forms"); - mixin.factory("massUpdateMixin", [ "$log", "$parse", "$modal", "pathWithContext", function($log, $parse, $modal, pathWithContext) { - return function($scope, args) { - var controller, extraParams, gridName, templateUrl; - if (args == null) { - args = {}; - } - gridName = args.gridName, templateUrl = args.templateUrl, controller = args.controller, - extraParams = args.extraParams; - if (controller == null) { - controller = "MassUpdateFormCtrl"; - } - return $scope.massUpdate = function() { - var grid, selectedIds; - grid = $parse(gridName)($scope); - if (grid == null) { - throw new Error("the grid is not defined"); - } - selectedIds = grid.getSelectedRowIds(); - if (selectedIds.length === 0) { - return; - } - return $modal.open({ - "templateUrl": pathWithContext(templateUrl), - "controller": controller, - "keyboard": false, - "backdrop": "static", - "resolve": { - "selectedIds": function() { - return selectedIds; - }, - "grid": function() { - return grid; - }, - "extraParams": function() { - return extraParams; - } - } - }); - }; - }; - } ]); -}).call(this); \ No newline at end of file diff --git a/grails/ag-plugin/web-app/angleGrinder/scripts/angleGrinder.gridz.min.js b/grails/ag-plugin/web-app/angleGrinder/scripts/angleGrinder.gridz.min.js deleted file mode 100644 index 996f5b790..000000000 --- a/grails/ag-plugin/web-app/angleGrinder/scripts/angleGrinder.gridz.min.js +++ /dev/null @@ -1,855 +0,0 @@ -(function() { - var gridz; - gridz = angular.module("angleGrinder.gridz", [ "ngSanitize", "angleGrinder.common", "ui.select2" ]); - gridz.run([ "$window", "agDateFilter", "agCurrencyFilter", function($window, agDateFilter, agCurrencyFilter) { - $window.agDateFilter = agDateFilter; - return $window.agCurrencyFilter = agCurrencyFilter; - } ]); - gridz.directive("agGrid", [ "$log", "$parse", "agGridDataLoader", "actionPopupHandler", "pathWithContext", "camelize", function($log, $parse, agGridDataLoader, actionPopupHandler, pathWithContext, camelize) { - var link; - link = function(scope, element, attrs, gridCtrl) { - var alias, gridEl, initializeGrid, options, unregister; - gridEl = element.find("table.gridz"); - alias = attrs.agGridName; - if (alias) { - $parse(alias).assign(scope, gridCtrl); - } - options = $parse(attrs.agGrid)(scope); - if (!options) { - throw new Error("undefined grid options"); - } - if (attrs.agGridColModel) { - options.colModel = angular.fromJson(attrs.agGridColModel); - } - scope.$on("$destroy", function() { - $log.debug("[agGrid] destroying the grid", gridEl); - return gridEl.jqGrid("GridDestroy"); - }); - initializeGrid = function() { - $log.debug("[agGrid] initializing '" + alias + "' with", options); - if (options.url == null && options.path != null) { - options.url = pathWithContext(options.path); - } - if (options.datatype === void 0 || options.datatype === null) { - options.datatype = agGridDataLoader(options.url, gridCtrl); - } - if (options.pager !== false) { - options.pager = element.find(".gridz-pager").attr("id") || "gridz-pager"; - } - gridEl.gridz(options); - return actionPopupHandler(gridEl, scope); - }; - if (element.is(":visible")) { - return initializeGrid(); - } else { - $log.info("grid is not visible:", alias); - return unregister = scope.$watch(function() { - if (!element.is(":visible")) { - return; - } - initializeGrid(); - return unregister(); - }); - } - }; - return { - "restrict": "A", - "require": "agGrid", - "controller": "AgGridCtrl", - "template": '
    \n
    ', - "compile": function(element, attrs) { - var id; - id = attrs.agGridName != null ? camelize(attrs.agGridName) : "gridz"; - element.find("table.gridz").attr("id", id); - element.find("div.gridz-pager").attr("id", "" + id + "-pager"); - return { - "post": link - }; - } - }; - } ]); -}).call(this); - -(function() { - var AgGridCtrl, gridz, __hasProp = {}.hasOwnProperty, __extends = function(child, parent) { - for (var key in parent) { - if (__hasProp.call(parent, key)) child[key] = parent[key]; - } - function ctor() { - this.constructor = child; - } - ctor.prototype = parent.prototype; - child.prototype = new ctor(); - child.__super__ = parent.prototype; - return child; - }; - gridz = angular.module("angleGrinder.gridz"); - AgGridCtrl = function(_super) { - __extends(AgGridCtrl, _super); - function AgGridCtrl() { - return AgGridCtrl.__super__.constructor.apply(this, arguments); - } - AgGridCtrl.register(gridz); - AgGridCtrl.inject("$rootScope", "$element", "$q", "hasSearchFilters", "flatten", "xlsData"); - AgGridCtrl.prototype.getGridEl = function() { - return this.gridEl || (this.gridEl = this.$element.find("table.gridz")); - }; - AgGridCtrl.prototype.getGridId = function() { - return this.getGridEl().attr("id"); - }; - AgGridCtrl.prototype.getSelectedRowIds = function() { - return this.getParam("selarrrow"); - }; - AgGridCtrl.prototype.getRowData = function(rowId) { - if (rowId == null) { - rowId = null; - } - return this.getGridEl().getRowData(rowId); - }; - AgGridCtrl.prototype.addJSONData = function(data) { - this.getGridEl().get(0).addJSONData(data); - return this.$rootScope.$broadcast("gridz:loadComplete", data); - }; - AgGridCtrl.prototype.reload = function() { - var deferred, unregister; - deferred = this.$q.defer(); - unregister = this.$rootScope.$on("gridz:loadComplete", function(_, data) { - deferred.resolve(data); - return unregister(); - }); - this.getGridEl().trigger("reloadGrid"); - return deferred.promise; - }; - AgGridCtrl.prototype.getParam = function(name) { - return this.getGridEl().getGridParam(name); - }; - AgGridCtrl.prototype.setParam = function(params) { - return this.getGridEl().setGridParam(params); - }; - AgGridCtrl.prototype.updateRow = function(id, data) { - var diff, flatData, key, prevData, restrictedColumns, _i, _len; - flatData = this.flatten(data); - prevData = this.getRowData(id); - if (prevData != null) { - diff = _.difference(_.keys(prevData), _.keys(flatData)); - restrictedColumns = function(key) { - return !key.match(/^-/); - }; - diff = diff.filter(restrictedColumns); - for (_i = 0, _len = diff.length; _i < _len; _i++) { - key = diff[_i]; - flatData[key] = null; - } - } - this.getGridEl().setRowData(id, flatData); - return this.flashOnSuccess(id); - }; - AgGridCtrl.prototype.addRow = function(id, data, position) { - if (position == null) { - position = "first"; - } - this.getGridEl().addRowData(id, this.flatten(data), position); - this.$rootScope.$broadcast("gridz:rowAdded", id, data); - return this.flashOnSuccess(id); - }; - AgGridCtrl.prototype.hasRow = function(id) { - return !!this.getGridEl().getInd(id); - }; - AgGridCtrl.prototype.getIds = function() { - return this.getGridEl().getDataIDs(); - }; - AgGridCtrl.prototype.getCurrentPage = function() { - return this.getParam("page"); - }; - AgGridCtrl.prototype.getTotalRecords = function() { - return this.getParam("records"); - }; - AgGridCtrl.prototype.getPageSize = function() { - return this.getParam("rowNum"); - }; - AgGridCtrl.prototype.getTotalPages = function() { - return Math.ceil(this.getTotalRecords() / this.getPageSize()); - }; - AgGridCtrl.prototype.isFirstPage = function() { - var page; - page = this.getCurrentPage(); - return page === 1; - }; - AgGridCtrl.prototype.isLastPage = function() { - var page; - page = this.getCurrentPage(); - return page === this.getTotalPages(); - }; - AgGridCtrl.prototype.prevPage = function() { - var page; - if (this.isFirstPage()) { - return this.lastPage(); - } - page = this.getCurrentPage(); - return this.loadPage(page - 1); - }; - AgGridCtrl.prototype.nextPage = function() { - var page; - if (this.isLastPage()) { - return this.firstPage(); - } - page = this.getCurrentPage(); - return this.loadPage(page + 1); - }; - AgGridCtrl.prototype.firstPage = function() { - return this.loadPage(1); - }; - AgGridCtrl.prototype.lastPage = function() { - return this.loadPage(this.getTotalPages()); - }; - AgGridCtrl.prototype.loadPage = function(page) { - this.setParam({ - "page": page - }); - return this.reload(); - }; - AgGridCtrl.prototype.saveRow = function(id, data) { - if (this.hasRow(id)) { - return this.updateRow(id, data); - } else { - return this.addRow(id, data); - } - }; - AgGridCtrl.prototype.removeRow = function(id) { - return this.flashOnSuccess(id, function(_this) { - return function() { - return _this.getGridEl().delRowData(id); - }; - }(this)); - }; - AgGridCtrl.prototype.search = function(filters) { - var deferred, params, promise; - deferred = this.$q.defer(); - params = { - "search": this.hasSearchFilters(filters), - "postData": { - "filters": JSON.stringify(filters) - } - }; - this.setParam(params); - promise = this.reload(); - promise.then(function() { - return deferred.resolve(filters); - }); - return deferred.promise; - }; - AgGridCtrl.prototype.isColumnHidden = function(columnId) { - var column; - column = _.findWhere(this.getParam("colModel"), { - "name": columnId - }); - return column != null ? column.hidden : void 0; - }; - AgGridCtrl.prototype.toggleColumn = function(columnId) { - var showOrHide; - showOrHide = this.isColumnHidden(columnId) ? "showCol" : "hideCol"; - this.getGridEl().jqGrid(showOrHide, columnId); - return this._triggerResize(); - }; - AgGridCtrl.prototype.columnChooser = function(options) { - if (options == null) { - options = {}; - } - options.done = function(_this) { - return function(perm) { - var chosenColumns; - if (perm) { - _this.getGridEl().jqGrid("remapColumns", perm, true); - } - chosenColumns = _.map(_this._getColModel(), function(column) { - return _.pick(column, "name", "hidden"); - }); - return window.localStorage.setItem("gridz." + _this.getGridId() + ".chosenColumns", angular.toJson(chosenColumns)); - }; - }(this); - return this.getGridEl().jqGrid("columnChooser", options); - }; - AgGridCtrl.prototype.getXlsDataUri = function() { - return this.xlsData(this.getGridId(), this.getSelectedRowIds()); - }; - AgGridCtrl.prototype._triggerResize = function() { - return this.getGridEl().trigger("resize"); - }; - AgGridCtrl.prototype.flashOnSuccess = function(id, complete) { - if (complete == null) { - complete = angular.noop; - } - return this._flashRow(id, "#DFF0D8", complete); - }; - AgGridCtrl.prototype.flashOnError = function(id, complete) { - if (complete == null) { - complete = angular.noop; - } - return this._flashRow(id, "#FF0000", complete); - }; - AgGridCtrl.prototype._flashRow = function(id, color, complete) { - var rowEl; - if (color == null) { - color = "#DFF0D8"; - } - if (complete == null) { - complete = angular.noop; - } - rowEl = $(this.getGridEl()[0].rows.namedItem(id)); - rowEl.css("background-color", color); - rowEl.delay(250).fadeOut("medium", function() { - return rowEl.css("background-color", ""); - }); - return rowEl.fadeIn("fast", function() { - return complete(); - }); - }; - return AgGridCtrl; - }(BaseCtrl); -}).call(this); - -(function() { - var gridz; - gridz = angular.module("angleGrinder.gridz"); - gridz.service("agGridDataLoader", [ "$log", "$http", "$document", function($log, $http, $document) { - return function(url, gridCtrl) { - return function(params, loadingDivSelector) { - var loadingEl, promise; - promise = $http.get(url, { - "params": params - }); - promise.then(function(response) { - $log.debug("[gridz] grid data loaded", gridCtrl, response); - return gridCtrl.addJSONData(response.data); - }); - loadingEl = $document.find("#" + $.jgrid.jqID(loadingDivSelector)); - loadingEl.show(); - return promise["finally"](function() { - return loadingEl.hide(); - }); - }; - }; - } ]); -}).call(this); - -(function() { - var gridz; - gridz = angular.module("angleGrinder.gridz"); - gridz.constant("rootPath", "/"); - gridz.directive("agGridPlaceholder", [ "$log", "$parse", "pathWithContext", "rootPath", function($log, $parse, pathWithContext, rootPath) { - return { - "restrict": "E", - "scope": true, - "link": function(scope, element, attrs) { - scope.templateSrc = pathWithContext(attrs.src); - scope.renderGrid = false; - if (attrs.forceRenderGrid) { - scope.renderGrid = $parse(attrs.forceRenderGrid)(scope); - } - scope.showGrid = false; - return scope.$on("$routeChangeSuccess", function(event, currentRoute) { - var msg, show; - show = currentRoute.originalPath === rootPath; - if (show) { - scope.renderGrid = show; - } - scope.showGrid = show; - msg = show ? "show grid" : "hide grid"; - return $log.debug("[agGrid]", msg, currentRoute); - }); - }, - "template": '
    \n \n
    ' - }; - } ]); -}).call(this); - -(function() { - var gridz; - gridz = angular.module("angleGrinder.gridz"); - gridz.directive("agGridQuickSearch", [ function() { - return { - "restrict": "E", - "scope": { - "grid": "=for", - "filters": "=?" - }, - "link": function($scope) { - if ($scope.filters == null) { - $scope.filters = {}; - } - angular.extend($scope.filters, { - "quickSearch": "" - }); - return $scope.search = function(filters) { - return $scope.grid.search(filters); - }; - }, - "template": '' - }; - } ]); -}).call(this); - -(function() { - var gridz; - gridz = angular.module("angleGrinder.gridz"); - gridz.service("xlsTemplate", [ "$window", function($window) { - return function(_arg) { - var table, worksheet, _ref; - _ref = _arg != null ? _arg : { - "worksheet": "Worksheet" - }, worksheet = _ref.worksheet, table = _ref.table; - return $window.btoa(unescape(encodeURIComponent('\n \n \n \n \n " + table + "
    \n \n"))); - }; - } ]); - gridz.service("xlsData", [ "$document", "$sanitize", "xlsTemplate", function($document, $sanitize, xlsTemplate) { - var buildTable, findGridEl, prepareHeading, prepareRows; - findGridEl = function(gridId) { - return $document.find("div#gbox_" + gridId); - }; - prepareHeading = function(gridId) { - var el, gridEl; - gridEl = findGridEl(gridId); - el = gridEl.find(".ui-jqgrid-hbox table").clone(); - el.find("th#" + gridId + "_cb").remove(); - el.find("th#" + gridId + "_-row_action_col").remove(); - el.find("th").each(function(index, th) { - var thEl; - thEl = $(th); - return thEl.html(thEl.text().trim()); - }); - return el.html(); - }; - prepareRows = function(gridId, selectedIds) { - var el, gridEl; - gridEl = findGridEl(gridId); - el = gridEl.find("#" + gridId).clone(); - el.find("tr.jqgfirstrow").remove(); - el.find("td[aria-describedby='" + gridId + "_cb']").remove(); - el.find("td[aria-describedby='" + gridId + "_-row_action_col']").remove(); - el.find("td a").contents().unwrap(); - if (selectedIds.length > 0) { - el.find("tr").each(function(index, tr) { - var id, rowEl; - rowEl = $(tr); - id = rowEl.attr("id"); - if (!_.include(selectedIds, id)) { - return el.find("tr#" + id).remove(); - } - }); - } - return el.html(); - }; - buildTable = function(gridId, selectedRows) { - var attr, attrsToRemove, resultEl, _i, _len; - resultEl = angular.element("
    "); - resultEl.append(prepareHeading(gridId)); - resultEl.append(prepareRows(gridId, selectedRows)); - attrsToRemove = [ "id", "class", "style", "title", "aria-describedby", "aria-labelledby", "aria-multiselectable", "role", "tabindex", "sort" ]; - for (_i = 0, _len = attrsToRemove.length; _i < _len; _i++) { - attr = attrsToRemove[_i]; - resultEl.find("*").removeAttr(attr); - } - return $sanitize(resultEl.html()); - }; - return function(gridId, selectedRows) { - var data; - if (selectedRows == null) { - selectedRows = []; - } - data = xlsTemplate({ - "table": buildTable(gridId, selectedRows), - "worksheet": "Grid export" - }); - return "data:application/vnd.ms-excel;base64," + data; - }; - } ]); - gridz.directive("agGridXlsExport", [ "$window", "notificationDialog", function($window, notificationDialog) { - return { - "restrict": "A", - "scope": { - "grid": "=agGridXlsExport" - }, - "link": function(scope, element) { - return element.on("click", function(event) { - var dataUri, grid; - event.preventDefault(); - grid = scope.grid; - if (grid.getSelectedRowIds().length !== 0) { - dataUri = grid.getXlsDataUri(); - return $window.location.href = dataUri; - } else { - return notificationDialog.open("Please select at least one row."); - } - }); - } - }; - } ]); -}).call(this); - -(function() { - var gridz; - gridz = angular.module("angleGrinder.gridz"); - gridz.factory("actionPopupHandler", [ "$log", function($log) { - return function(gridEl, scope) { - var handleAction; - handleAction = function(action, id) { - if (scope[action] != null) { - $log.info("Trigger '" + action + "' for row '" + id + "'"); - return scope.$apply(function() { - return scope[action](id); - }); - } else { - return $log.warn("`$scope." + action + "` is not defined"); - } - }; - gridEl.on("showAction", function(event, id) { - event.preventDefault(); - return handleAction("showRecord", id); - }); - gridEl.on("editAction", function(event, id) { - event.preventDefault(); - return handleAction("editRecord", id); - }); - gridEl.on("deleteAction", function(event, id) { - event.preventDefault(); - return handleAction("deleteRecord", id); - }); - return gridEl.on("click", "a.editActionLink", function(event) { - var id; - event.preventDefault(); - id = $(this).parents("tr:first").attr("id"); - return handleAction("editRecord", id); - }); - }; - } ]); -}).call(this); - -(function() { - var gridz; - gridz = angular.module("angleGrinder.gridz"); - gridz.value("flatten", function(target, opts) { - var delimiter, getKey, output, step; - if (opts == null) { - opts = { - "delimiter": "." - }; - } - delimiter = opts.delimiter; - getKey = function(key, prev) { - if (prev) { - return prev + delimiter + key; - } else { - return key; - } - }; - step = function(object, prev) { - return angular.forEach(Object.keys(object), function(key) { - var isArray, isObject, type; - isArray = opts.safe && object[key] instanceof Array; - type = Object.prototype.toString.call(object[key]); - isObject = type === "[object Object]" || type === "[object Array]"; - if (!isArray && isObject) { - return step(object[key], getKey(key, prev)); - } - return output[getKey(key, prev)] = object[key]; - }); - }; - output = {}; - step(target); - return output; - }); -}).call(this); - -(function() { - var gridz; - gridz = angular.module("angleGrinder.gridz"); - gridz.value("hasSearchFilters", function(filters) { - var value, _; - for (_ in filters) { - value = filters[_]; - if (value == null) { - continue; - } - if (typeof value === "string") { - if ($.trim(value) !== "") { - return true; - } - } else { - return true; - } - } - return false; - }); - gridz.directive("agSearchButton", function() { - return { - "restrict": "E", - "replace": true, - "template": '' - }; - }); - gridz.directive("agResetSearchButton", function() { - return { - "restrict": "E", - "replace": true, - "template": '' - }; - }); - gridz.directive("agSearchForm", [ "$log", function($log) { - return { - "restrict": "A", - "scope": true, - "require": "^form", - "link": function(scope, element, attrs, form) { - return scope.searchForm = form; - }, - "controller": [ "$scope", "$parse", "$attrs", function($scope, $parse, $attrs) { - var gridSearch; - $scope.searching = false; - gridSearch = function(filters) { - var grid, promise; - if (filters == null) { - filters = {}; - } - grid = $parse($attrs.agSearchForm)($scope); - if (grid == null) { - $log.warn("[gridz] grid is not defined"); - return; - } - promise = grid.search(filters); - $scope.searching = true; - promise["finally"](function() { - return $scope.searching = false; - }); - return promise; - }; - $scope.advancedSearch = function(filters) { - var form; - if (filters == null) { - filters = {}; - } - form = $scope.searchForm; - if (form && form.$invalid) { - return $log.info("[gridz] advanced search form is invalid", form); - } - return gridSearch(filters); - }; - return $scope.resetSearch = function(filters) { - var defaultFilters; - if (filters == null) { - filters = {}; - } - defaultFilters = $scope.defaultFilters || {}; - angular.copy(defaultFilters, filters); - return gridSearch(filters); - }; - } ] - }; - } ]); -}).call(this); - -(function() { - var gridz; - gridz = angular.module("angleGrinder.gridz"); - gridz.directive("agSelect2", [ "$rootScope", "$compile", "$log", "pathWithContext", function($rootScope, $compile, $log, pathWithContext) { - return { - "restrict": "E", - "replace": true, - "transclude": true, - "scope": { - "selectOptions": "=", - "ngModel": "=" - }, - "compile": function(element, attrs, transclude) { - var resultTemplate, scope; - resultTemplate = null; - scope = $rootScope.$new(); - transclude(scope, function(clone) { - var _i, _len, _results; - _results = []; - for (_i = 0, _len = clone.length; _i < _len; _i++) { - element = clone[_i]; - if (element instanceof HTMLElement && element.getAttribute("ag-select2-result") != null) { - resultTemplate = element.outerHTML; - break; - } else { - _results.push(void 0); - } - } - return _results; - }); - return { - "pre": function(scope, element, attrs) { - var options; - options = angular.copy(scope.selectOptions || {}); - scope.options = options; - if (options.minimumInputLength == null) { - options.minimumInputLength = 1; - } - if (attrs.selectMinimumInputLength != null) { - options.minimumInputLength = parseInt(attrs.selectMinimumInputLength); - } - if (options.width == null) { - options.width = "resolve"; - } - if (options.ajax == null && attrs.selectAjaxUrl != null) { - options.ajax = { - "url": pathWithContext(attrs.selectAjaxUrl), - "data": function(term, page) { - return { - "q": term, - "max": 20, - "page": page, - "sort": "name", - "order": "asc" - }; - }, - "results": function(data, page) { - var more; - more = page < data.total; - return { - "results": data.rows, - "more": more - }; - } - }; - options.ajax.quietMillis = 500; - if (attrs.selectAjaxQuietMillis != null) { - options.ajax.quietMillis = parseInt(attrs.selectAjaxQuietMillis); - } - } - if (resultTemplate != null) { - if (options.formatResult == null) { - options.formatResult = function(item) { - options = { - "interpolate": /\{\{(.+?)\}\}/g - }; - return angular.element(_.template(resultTemplate, { - "item": item - }, options)); - }; - } - } - if (options.formatSelection == null) { - options.formatSelection = function(item) { - return item.name; - }; - } - return $log.debug("[forms] initializing AgSelect2 component", scope.options); - } - }; - }, - "template": '
    \n \n \n
    ' - }; - } ]); - gridz.directive("agSelect2Open", function() { - return { - "restrict": "E", - "replace": true, - "scope": true, - "controller": [ "$scope", "$element", function($scope, $element) { - return $scope.openSelect2 = function() { - var selectEl; - selectEl = $element.parent().find(".select2-container"); - selectEl.select2("open"); - }; - } ], - "template": '' - }; - }); -}).call(this); - -(function() { - var gridz; - gridz = angular.module("angleGrinder.gridz"); - gridz.controller("gridPagerCtrlMixin", [ "$log", "$scope", "$parse", "$location", "$q", "gridName", "currentId", "path", function($log, $scope, $parse, $location, $q, gridName, currentId, path) { - var currIdGetter, currIdSetter, getCurrent, getGrid, getGridIds, nextGridPage, prevGridPage; - currIdGetter = $parse(currentId); - currIdSetter = currIdGetter.assign; - $scope.$watch(currentId, function(id, oldId) { - if (id == null) { - return; - } - if (id === oldId) { - return; - } - return $location.path(path.replace(":id", id)); - }); - getGrid = function() { - return $parse(gridName)($scope); - }; - getGridIds = function() { - return getGrid().getIds(); - }; - prevGridPage = function() { - var deferred, promise; - deferred = $q.defer(); - promise = getGrid().prevPage(); - promise.then(function() { - var ids; - ids = getGridIds(); - $log.debug("[agGrid] previous page was loaded", ids); - return deferred.resolve(ids); - }); - return deferred.promise; - }; - nextGridPage = function() { - var deferred, promise; - deferred = $q.defer(); - promise = getGrid().nextPage(); - promise.then(function() { - var ids; - ids = getGridIds(); - $log.debug("[agGrid] next page was loaded", ids); - return deferred.resolve(ids); - }); - return deferred.promise; - }; - getCurrent = function() { - var ids; - ids = getGridIds(); - return [ ids, ids.indexOf(currIdGetter($scope).toString()) ]; - }; - this.show = function() { - return getGrid() != null; - }; - this.hasPrevRow = function() { - var ids, indx, _ref; - _ref = getCurrent(), ids = _ref[0], indx = _ref[1]; - if (!getGrid().isFirstPage()) { - return true; - } - return indx !== 0; - }; - this.hasNextRow = function() { - var ids, indx, _ref; - _ref = getCurrent(), ids = _ref[0], indx = _ref[1]; - if (!getGrid().isLastPage()) { - return true; - } - return indx !== ids.length - 1; - }; - this.prevRow = function() { - var ids, indx, _ref; - _ref = getCurrent(), ids = _ref[0], indx = _ref[1]; - if (indx > 0) { - return currIdSetter($scope, ids[indx - 1]); - } else { - return prevGridPage().then(function(ids) { - return currIdSetter($scope, ids[ids.length - 1]); - }); - } - }; - this.nextRow = function() { - var ids, indx, _ref; - _ref = getCurrent(), ids = _ref[0], indx = _ref[1]; - if (indx < ids.length - 1) { - return currIdSetter($scope, ids[indx + 1]); - } else { - return nextGridPage().then(function(ids) { - return currIdSetter($scope, ids[0]); - }); - } - }; - return this; - } ]); -}).call(this); \ No newline at end of file diff --git a/grails/ag-plugin/web-app/angleGrinder/scripts/angleGrinder.spinner.min.js b/grails/ag-plugin/web-app/angleGrinder/scripts/angleGrinder.spinner.min.js deleted file mode 100644 index cc5588493..000000000 --- a/grails/ag-plugin/web-app/angleGrinder/scripts/angleGrinder.spinner.min.js +++ /dev/null @@ -1,16 +0,0 @@ -(function() { - var spinner; - spinner = angular.module("angleGrinder.spinner", [ "angleGrinder.common" ]); - spinner.directive("agSpinner", function() { - return { - "replace": true, - "restrict": "E", - "controller": [ "$scope", "pendingRequests", function($scope, pendingRequests) { - return $scope.showSpinner = function() { - return pendingRequests.any(); - }; - } ], - "template": '
  • \n \n
  • ' - }; - }); -}).call(this); \ No newline at end of file diff --git a/grails/ag-plugin/web-app/angleGrinder/scripts/angular.xeditable.min.js b/grails/ag-plugin/web-app/angleGrinder/scripts/angular.xeditable.min.js deleted file mode 100644 index 073654998..000000000 --- a/grails/ag-plugin/web-app/angleGrinder/scripts/angular.xeditable.min.js +++ /dev/null @@ -1,918 +0,0 @@ -angular.module("xeditable", []).value("editableOptions", { - "theme": "default", - "buttons": "right", - "blurElem": "cancel", - "blurForm": "ignore", - "activate": "focus" -}); - -angular.module("xeditable").directive("editableBsdate", [ "editableDirectiveFactory", function(editableDirectiveFactory) { - return editableDirectiveFactory({ - "directiveName": "editableBsdate", - "inputTpl": '' - }); -} ]); - -angular.module("xeditable").directive("editableBstime", [ "editableDirectiveFactory", function(editableDirectiveFactory) { - return editableDirectiveFactory({ - "directiveName": "editableBstime", - "inputTpl": "", - "render": function() { - this.parent.render.call(this); - var div = angular.element('
    '); - div.attr("ng-model", this.inputEl.attr("ng-model")); - this.inputEl.removeAttr("ng-model"); - if (this.attrs.eNgChange) { - div.attr("ng-change", this.inputEl.attr("ng-change")); - this.inputEl.removeAttr("ng-change"); - } - this.inputEl.wrap(div); - } - }); -} ]); - -angular.module("xeditable").directive("editableCheckbox", [ "editableDirectiveFactory", function(editableDirectiveFactory) { - return editableDirectiveFactory({ - "directiveName": "editableCheckbox", - "inputTpl": '', - "render": function() { - this.parent.render.call(this); - if (this.attrs.eTitle) { - this.inputEl.wrap(""); - this.inputEl.after(angular.element("").text(this.attrs.eTitle)); - } - }, - "autosubmit": function() { - var self = this; - self.inputEl.bind("change", function() { - setTimeout(function() { - self.scope.$apply(function() { - self.scope.$form.$submit(); - }); - }, 500); - }); - } - }); -} ]); - -angular.module("xeditable").directive("editableChecklist", [ "editableDirectiveFactory", "editableNgOptionsParser", function(editableDirectiveFactory, editableNgOptionsParser) { - return editableDirectiveFactory({ - "directiveName": "editableChecklist", - "inputTpl": "", - "useCopy": true, - "render": function() { - this.parent.render.call(this); - var parsed = editableNgOptionsParser(this.attrs.eNgOptions); - var html = ''; - this.inputEl.removeAttr("ng-model"); - this.inputEl.removeAttr("ng-options"); - this.inputEl.html(html); - } - }); -} ]); - -(function() { - var types = "text|email|tel|number|url|search|color|date|datetime|time|month|week".split("|"); - angular.forEach(types, function(type) { - var directiveName = "editable" + type.charAt(0).toUpperCase() + type.slice(1); - angular.module("xeditable").directive(directiveName, [ "editableDirectiveFactory", function(editableDirectiveFactory) { - return editableDirectiveFactory({ - "directiveName": directiveName, - "inputTpl": '' - }); - } ]); - }); - angular.module("xeditable").directive("editableRange", [ "editableDirectiveFactory", function(editableDirectiveFactory) { - return editableDirectiveFactory({ - "directiveName": "editableRange", - "inputTpl": '', - "render": function() { - this.parent.render.call(this); - this.inputEl.after("{{$data}}"); - } - }); - } ]); -})(); - -angular.module("xeditable").directive("editableRadiolist", [ "editableDirectiveFactory", "editableNgOptionsParser", function(editableDirectiveFactory, editableNgOptionsParser) { - return editableDirectiveFactory({ - "directiveName": "editableRadiolist", - "inputTpl": "", - "render": function() { - this.parent.render.call(this); - var parsed = editableNgOptionsParser(this.attrs.eNgOptions); - var html = ''; - this.inputEl.removeAttr("ng-model"); - this.inputEl.removeAttr("ng-options"); - this.inputEl.html(html); - }, - "autosubmit": function() { - var self = this; - self.inputEl.bind("change", function() { - setTimeout(function() { - self.scope.$apply(function() { - self.scope.$form.$submit(); - }); - }, 500); - }); - } - }); -} ]); - -angular.module("xeditable").directive("editableSelect", [ "editableDirectiveFactory", function(editableDirectiveFactory) { - return editableDirectiveFactory({ - "directiveName": "editableSelect", - "inputTpl": "", - "autosubmit": function() { - var self = this; - self.inputEl.bind("change", function() { - self.scope.$apply(function() { - self.scope.$form.$submit(); - }); - }); - } - }); -} ]); - -angular.module("xeditable").directive("editableTextarea", [ "editableDirectiveFactory", function(editableDirectiveFactory) { - return editableDirectiveFactory({ - "directiveName": "editableTextarea", - "inputTpl": "", - "addListeners": function() { - var self = this; - self.parent.addListeners.call(self); - if (self.single && self.buttons !== "no") { - self.autosubmit(); - } - }, - "autosubmit": function() { - var self = this; - self.inputEl.bind("keydown", function(e) { - if ((e.ctrlKey || e.metaKey) && e.keyCode === 13) { - self.scope.$apply(function() { - self.scope.$form.$submit(); - }); - } - }); - } - }); -} ]); - -angular.module("xeditable").factory("editableController", [ "$q", "editableUtils", function($q, editableUtils) { - EditableController.$inject = [ "$scope", "$attrs", "$element", "$parse", "editableThemes", "editableOptions", "$rootScope", "$compile", "$q" ]; - function EditableController($scope, $attrs, $element, $parse, editableThemes, editableOptions, $rootScope, $compile, $q) { - var valueGetter; - var inWaiting; - var self = this; - self.scope = $scope; - self.elem = $element; - self.attrs = $attrs; - self.inputEl = null; - self.editorEl = null; - self.single = true; - self.error = ""; - self.theme = editableThemes[editableOptions.theme] || editableThemes["default"]; - self.parent = {}; - self.inputTpl = ""; - self.directiveName = ""; - self.useCopy = false; - self.single = null; - self.buttons = "right"; - self.init = function(single) { - self.single = single; - self.name = $attrs.eName || $attrs[self.directiveName]; - if ($attrs[self.directiveName]) { - valueGetter = $parse($attrs[self.directiveName]); - } else { - throw "You should provide value for `" + self.directiveName + "` in editable element!"; - } - if (!self.single) { - self.buttons = "no"; - } else { - self.buttons = self.attrs.buttons || editableOptions.buttons; - } - if ($attrs.eName) { - self.scope.$watch("$data", function(newVal) { - self.scope.$form.$data[$attrs.eName] = newVal; - }); - } - if ($attrs.onshow) { - self.onshow = function() { - return self.catchError($parse($attrs.onshow)($scope)); - }; - } - if ($attrs.onhide) { - self.onhide = function() { - return $parse($attrs.onhide)($scope); - }; - } - if ($attrs.oncancel) { - self.oncancel = function() { - return $parse($attrs.oncancel)($scope); - }; - } - if ($attrs.onbeforesave) { - self.onbeforesave = function() { - return self.catchError($parse($attrs.onbeforesave)($scope)); - }; - } - if ($attrs.onaftersave) { - self.onaftersave = function() { - return self.catchError($parse($attrs.onaftersave)($scope)); - }; - } - $scope.$parent.$watch($attrs[self.directiveName], function(newVal, oldVal) { - self.handleEmpty(); - }); - }; - self.render = function() { - var theme = self.theme; - self.inputEl = angular.element(self.inputTpl); - self.controlsEl = angular.element(theme.controlsTpl); - self.controlsEl.append(self.inputEl); - if (self.buttons !== "no") { - self.buttonsEl = angular.element(theme.buttonsTpl); - self.submitEl = angular.element(theme.submitTpl); - self.cancelEl = angular.element(theme.cancelTpl); - self.buttonsEl.append(self.submitEl).append(self.cancelEl); - self.controlsEl.append(self.buttonsEl); - self.inputEl.addClass("editable-has-buttons"); - } - self.errorEl = angular.element(theme.errorTpl); - self.controlsEl.append(self.errorEl); - self.editorEl = angular.element(self.single ? theme.formTpl : theme.noformTpl); - self.editorEl.append(self.controlsEl); - for (var k in $attrs.$attr) { - if (k.length <= 1) { - continue; - } - var transferAttr = false; - var nextLetter = k.substring(1, 2); - if (k.substring(0, 1) === "e" && nextLetter === nextLetter.toUpperCase()) { - transferAttr = k.substring(1); - } else { - continue; - } - if (transferAttr === "Form" || transferAttr === "NgSubmit") { - continue; - } - transferAttr = transferAttr.substring(0, 1).toLowerCase() + editableUtils.camelToDash(transferAttr.substring(1)); - var attrValue = $attrs[k] === "" ? transferAttr : $attrs[k]; - self.inputEl.attr(transferAttr, attrValue); - } - self.inputEl.addClass("editable-input"); - self.inputEl.attr("ng-model", "$data"); - self.editorEl.addClass(editableUtils.camelToDash(self.directiveName)); - if (self.single) { - self.editorEl.attr("editable-form", "$form"); - self.editorEl.attr("blur", self.attrs.blur || (self.buttons === "no" ? "cancel" : editableOptions.blurElem)); - } - if (angular.isFunction(theme.postrender)) { - theme.postrender.call(self); - } - }; - self.setLocalValue = function() { - self.scope.$data = self.useCopy ? angular.copy(valueGetter($scope.$parent)) : valueGetter($scope.$parent); - }; - self.show = function() { - self.setLocalValue(); - self.render(); - $element.after(self.editorEl); - $compile(self.editorEl)($scope); - self.addListeners(); - $element.addClass("editable-hide"); - return self.onshow(); - }; - self.hide = function() { - self.editorEl.remove(); - $element.removeClass("editable-hide"); - return self.onhide(); - }; - self.cancel = function() { - self.oncancel(); - }; - self.addListeners = function() { - self.inputEl.bind("keyup", function(e) { - if (!self.single) { - return; - } - switch (e.keyCode) { - case 27: - self.scope.$apply(function() { - self.scope.$form.$cancel(); - }); - break; - } - }); - if (self.single && self.buttons === "no") { - self.autosubmit(); - } - self.editorEl.bind("click", function(e) { - if (e.which !== 1) { - return; - } - if (self.scope.$form.$visible) { - self.scope.$form._clicked = true; - } - }); - }; - self.setWaiting = function(value) { - if (value) { - inWaiting = !self.inputEl.attr("disabled") && !self.inputEl.attr("ng-disabled") && !self.inputEl.attr("ng-enabled"); - if (inWaiting) { - self.inputEl.attr("disabled", "disabled"); - if (self.buttonsEl) { - self.buttonsEl.find("button").attr("disabled", "disabled"); - } - } - } else { - if (inWaiting) { - self.inputEl.removeAttr("disabled"); - if (self.buttonsEl) { - self.buttonsEl.find("button").removeAttr("disabled"); - } - } - } - }; - self.activate = function() { - setTimeout(function() { - var el = self.inputEl[0]; - if (editableOptions.activate === "focus" && el.focus) { - el.focus(); - } - if (editableOptions.activate === "select" && el.select) { - el.select(); - } - }, 0); - }; - self.setError = function(msg) { - if (!angular.isObject(msg)) { - $scope.$error = msg; - self.error = msg; - } - }; - self.catchError = function(result, noPromise) { - if (angular.isObject(result) && noPromise !== true) { - $q.when(result).then(angular.bind(this, function(r) { - this.catchError(r, true); - }), angular.bind(this, function(r) { - this.catchError(r, true); - })); - } else if (noPromise && angular.isObject(result) && result.status && result.status !== 200 && result.data && angular.isString(result.data)) { - this.setError(result.data); - result = result.data; - } else if (angular.isString(result)) { - this.setError(result); - } - return result; - }; - self.save = function() { - valueGetter.assign($scope.$parent, angular.copy(self.scope.$data)); - }; - self.handleEmpty = function() { - var val = valueGetter($scope.$parent); - var isEmpty = val === null || val === undefined || val === "" || angular.isArray(val) && val.length === 0; - $element.toggleClass("editable-empty", isEmpty); - }; - self.autosubmit = angular.noop; - self.onshow = angular.noop; - self.onhide = angular.noop; - self.oncancel = angular.noop; - self.onbeforesave = angular.noop; - self.onaftersave = angular.noop; - } - return EditableController; -} ]); - -angular.module("xeditable").factory("editableDirectiveFactory", [ "$parse", "$compile", "editableThemes", "$rootScope", "$document", "editableController", "editableFormController", function($parse, $compile, editableThemes, $rootScope, $document, editableController, editableFormController) { - return function(overwrites) { - return { - "restrict": "A", - "scope": true, - "require": [ overwrites.directiveName, "?^form" ], - "controller": editableController, - "link": function(scope, elem, attrs, ctrl) { - var eCtrl = ctrl[0]; - var eFormCtrl; - var hasForm = false; - if (ctrl[1]) { - eFormCtrl = ctrl[1]; - hasForm = true; - } else if (attrs.eForm) { - var getter = $parse(attrs.eForm)(scope); - if (getter) { - eFormCtrl = getter; - hasForm = true; - } else { - for (var i = 0; i < $document[0].forms.length; i++) { - if ($document[0].forms[i].name === attrs.eForm) { - eFormCtrl = null; - hasForm = true; - break; - } - } - } - } - angular.forEach(overwrites, function(v, k) { - if (eCtrl[k] !== undefined) { - eCtrl.parent[k] = eCtrl[k]; - } - }); - angular.extend(eCtrl, overwrites); - eCtrl.init(!hasForm); - scope.$editable = eCtrl; - elem.addClass("editable"); - if (hasForm) { - if (eFormCtrl) { - scope.$form = eFormCtrl; - if (!scope.$form.$addEditable) { - throw "Form with editable elements should have `editable-form` attribute."; - } - scope.$form.$addEditable(eCtrl); - } else { - $rootScope.$$editableBuffer = $rootScope.$$editableBuffer || {}; - $rootScope.$$editableBuffer[attrs.eForm] = $rootScope.$$editableBuffer[attrs.eForm] || []; - $rootScope.$$editableBuffer[attrs.eForm].push(eCtrl); - scope.$form = null; - } - } else { - scope.$form = editableFormController(); - scope.$form.$addEditable(eCtrl); - if (attrs.eForm) { - scope.$parent[attrs.eForm] = scope.$form; - } - if (!attrs.eForm) { - elem.addClass("editable-click"); - elem.bind("click", function(e) { - e.preventDefault(); - e.editable = eCtrl; - scope.$apply(function() { - scope.$form.$show(); - }); - }); - } - } - } - }; - }; -} ]); - -angular.module("xeditable").factory("editableFormController", [ "$parse", "$document", "$rootScope", "editablePromiseCollection", "editableUtils", function($parse, $document, $rootScope, editablePromiseCollection, editableUtils) { - var shown = []; - $document.bind("click", function(e) { - if (e.which !== 1) { - return; - } - var toCancel = []; - var toSubmit = []; - for (var i = 0; i < shown.length; i++) { - if (shown[i]._clicked) { - shown[i]._clicked = false; - continue; - } - if (shown[i].$waiting) { - continue; - } - if (shown[i]._blur === "cancel") { - toCancel.push(shown[i]); - } - if (shown[i]._blur === "submit") { - toSubmit.push(shown[i]); - } - } - if (toCancel.length || toSubmit.length) { - $rootScope.$apply(function() { - angular.forEach(toCancel, function(v) { - v.$cancel(); - }); - angular.forEach(toSubmit, function(v) { - v.$submit(); - }); - }); - } - }); - var base = { - "$addEditable": function(editable) { - this.$editables.push(editable); - editable.elem.bind("$destroy", angular.bind(this, this.$removeEditable, editable)); - if (!editable.scope.$form) { - editable.scope.$form = this; - } - if (this.$visible) { - editable.catchError(editable.show()); - } - }, - "$removeEditable": function(editable) { - for (var i = 0; i < this.$editables.length; i++) { - if (this.$editables[i] === editable) { - this.$editables.splice(i, 1); - return; - } - } - }, - "$show": function() { - if (this.$visible) { - return; - } - this.$visible = true; - var pc = editablePromiseCollection(); - pc.when(this.$onshow()); - this.$setError(null, ""); - angular.forEach(this.$editables, function(editable) { - pc.when(editable.show()); - }); - pc.then({ - "onWait": angular.bind(this, this.$setWaiting), - "onTrue": angular.bind(this, this.$activate), - "onFalse": angular.bind(this, this.$activate), - "onString": angular.bind(this, this.$activate) - }); - setTimeout(angular.bind(this, function() { - this._clicked = false; - if (editableUtils.indexOf(shown, this) === -1) { - shown.push(this); - } - }), 0); - }, - "$activate": function(name) { - var i; - if (this.$editables.length) { - if (angular.isString(name)) { - for (i = 0; i < this.$editables.length; i++) { - if (this.$editables[i].name === name) { - this.$editables[i].activate(); - return; - } - } - } - for (i = 0; i < this.$editables.length; i++) { - if (this.$editables[i].error) { - this.$editables[i].activate(); - return; - } - } - this.$editables[0].activate(); - } - }, - "$hide": function() { - if (!this.$visible) { - return; - } - this.$visible = false; - this.$onhide(); - angular.forEach(this.$editables, function(editable) { - editable.hide(); - }); - editableUtils.arrayRemove(shown, this); - }, - "$cancel": function() { - if (!this.$visible) { - return; - } - this.$oncancel(); - angular.forEach(this.$editables, function(editable) { - editable.cancel(); - }); - this.$hide(); - }, - "$setWaiting": function(value) { - this.$waiting = !!value; - angular.forEach(this.$editables, function(editable) { - editable.setWaiting(!!value); - }); - }, - "$setError": function(name, msg) { - angular.forEach(this.$editables, function(editable) { - if (!name || editable.name === name) { - editable.setError(msg); - } - }); - }, - "$submit": function() { - if (this.$waiting) { - return; - } - this.$setError(null, ""); - var pc = editablePromiseCollection(); - angular.forEach(this.$editables, function(editable) { - pc.when(editable.onbeforesave()); - }); - pc.then({ - "onWait": angular.bind(this, this.$setWaiting), - "onTrue": angular.bind(this, checkSelf, true), - "onFalse": angular.bind(this, checkSelf, false), - "onString": angular.bind(this, this.$activate) - }); - function checkSelf(childrenTrue) { - var pc = editablePromiseCollection(); - pc.when(this.$onbeforesave()); - pc.then({ - "onWait": angular.bind(this, this.$setWaiting), - "onTrue": childrenTrue ? angular.bind(this, this.$save) : angular.bind(this, this.$hide), - "onFalse": angular.bind(this, this.$hide), - "onString": angular.bind(this, this.$activate) - }); - } - }, - "$save": function() { - angular.forEach(this.$editables, function(editable) { - editable.save(); - }); - var pc = editablePromiseCollection(); - pc.when(this.$onaftersave()); - angular.forEach(this.$editables, function(editable) { - pc.when(editable.onaftersave()); - }); - pc.then({ - "onWait": angular.bind(this, this.$setWaiting), - "onTrue": angular.bind(this, this.$hide), - "onFalse": angular.bind(this, this.$hide), - "onString": angular.bind(this, this.$activate) - }); - }, - "$onshow": angular.noop, - "$oncancel": angular.noop, - "$onhide": angular.noop, - "$onbeforesave": angular.noop, - "$onaftersave": angular.noop - }; - return function() { - return angular.extend({ - "$editables": [], - "$visible": false, - "$waiting": false, - "$data": {}, - "_clicked": false, - "_blur": null - }, base); - }; -} ]); - -angular.module("xeditable").directive("editableForm", [ "$rootScope", "$parse", "editableFormController", "editableOptions", function($rootScope, $parse, editableFormController, editableOptions) { - return { - "restrict": "A", - "require": [ "form" ], - "compile": function() { - return { - "pre": function(scope, elem, attrs, ctrl) { - var form = ctrl[0]; - var eForm; - if (attrs.editableForm) { - if (scope[attrs.editableForm] && scope[attrs.editableForm].$show) { - eForm = scope[attrs.editableForm]; - angular.extend(form, eForm); - } else { - eForm = editableFormController(); - scope[attrs.editableForm] = eForm; - angular.extend(eForm, form); - } - } else { - eForm = editableFormController(); - angular.extend(form, eForm); - } - var buf = $rootScope.$$editableBuffer; - var name = form.$name; - if (name && buf && buf[name]) { - angular.forEach(buf[name], function(editable) { - eForm.$addEditable(editable); - }); - delete buf[name]; - } - }, - "post": function(scope, elem, attrs, ctrl) { - var eForm; - if (attrs.editableForm && scope[attrs.editableForm] && scope[attrs.editableForm].$show) { - eForm = scope[attrs.editableForm]; - } else { - eForm = ctrl[0]; - } - if (attrs.onshow) { - eForm.$onshow = angular.bind(eForm, $parse(attrs.onshow), scope); - } - if (attrs.onhide) { - eForm.$onhide = angular.bind(eForm, $parse(attrs.onhide), scope); - } - if (attrs.oncancel) { - eForm.$oncancel = angular.bind(eForm, $parse(attrs.oncancel), scope); - } - if (attrs.shown && $parse(attrs.shown)(scope)) { - eForm.$show(); - } - eForm._blur = attrs.blur || editableOptions.blurForm; - if (!attrs.ngSubmit && !attrs.submit) { - if (attrs.onbeforesave) { - eForm.$onbeforesave = function() { - return $parse(attrs.onbeforesave)(scope, { - "$data": eForm.$data - }); - }; - } - if (attrs.onaftersave) { - eForm.$onaftersave = function() { - return $parse(attrs.onaftersave)(scope, { - "$data": eForm.$data - }); - }; - } - elem.bind("submit", function(event) { - event.preventDefault(); - scope.$apply(function() { - eForm.$submit(); - }); - }); - } - elem.bind("click", function(e) { - if (e.which !== 1) { - return; - } - if (eForm.$visible) { - eForm._clicked = true; - } - }); - } - }; - } - }; -} ]); - -angular.module("xeditable").factory("editablePromiseCollection", [ "$q", function($q) { - function promiseCollection() { - return { - "promises": [], - "hasFalse": false, - "hasString": false, - "when": function(result, noPromise) { - if (result === false) { - this.hasFalse = true; - } else if (!noPromise && angular.isObject(result)) { - this.promises.push($q.when(result)); - } else if (angular.isString(result)) { - this.hasString = true; - } else { - return; - } - }, - "then": function(callbacks) { - callbacks = callbacks || {}; - var onTrue = callbacks.onTrue || angular.noop; - var onFalse = callbacks.onFalse || angular.noop; - var onString = callbacks.onString || angular.noop; - var onWait = callbacks.onWait || angular.noop; - var self = this; - if (this.promises.length) { - onWait(true); - $q.all(this.promises).then(function(results) { - onWait(false); - angular.forEach(results, function(result) { - self.when(result, true); - }); - applyCallback(); - }, function(error) { - onWait(false); - onString(); - }); - } else { - applyCallback(); - } - function applyCallback() { - if (!self.hasString && !self.hasFalse) { - onTrue(); - } else if (!self.hasString && self.hasFalse) { - onFalse(); - } else { - onString(); - } - } - } - }; - } - return promiseCollection; -} ]); - -angular.module("xeditable").factory("editableUtils", [ function() { - return { - "indexOf": function(array, obj) { - if (array.indexOf) return array.indexOf(obj); - for (var i = 0; i < array.length; i++) { - if (obj === array[i]) return i; - } - return -1; - }, - "arrayRemove": function(array, value) { - var index = this.indexOf(array, value); - if (index >= 0) { - array.splice(index, 1); - } - return value; - }, - "camelToDash": function(str) { - var SNAKE_CASE_REGEXP = /[A-Z]/g; - return str.replace(SNAKE_CASE_REGEXP, function(letter, pos) { - return (pos ? "-" : "") + letter.toLowerCase(); - }); - }, - "dashToCamel": function(str) { - var SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g; - var MOZ_HACK_REGEXP = /^moz([A-Z])/; - return str.replace(SPECIAL_CHARS_REGEXP, function(_, separator, letter, offset) { - return offset ? letter.toUpperCase() : letter; - }).replace(MOZ_HACK_REGEXP, "Moz$1"); - } - }; -} ]); - -angular.module("xeditable").factory("editableNgOptionsParser", [ function() { - var NG_OPTIONS_REGEXP = /^\s*(.*?)(?:\s+as\s+(.*?))?(?:\s+group\s+by\s+(.*))?\s+for\s+(?:([\$\w][\$\w]*)|(?:\(\s*([\$\w][\$\w]*)\s*,\s*([\$\w][\$\w]*)\s*\)))\s+in\s+(.*?)(?:\s+track\s+by\s+(.*?))?$/; - function parser(optionsExp) { - var match; - if (!(match = optionsExp.match(NG_OPTIONS_REGEXP))) { - throw "ng-options parse error"; - } - var displayFn = match[2] || match[1], valueName = match[4] || match[6], keyName = match[5], groupByFn = match[3] || "", valueFn = match[2] ? match[1] : valueName, valuesFn = match[7], track = match[8], trackFn = track ? match[8] : null; - var ngRepeat; - if (keyName === undefined) { - ngRepeat = valueName + " in " + valuesFn; - if (track !== undefined) { - ngRepeat += " track by " + trackFn; - } - } else { - ngRepeat = "(" + keyName + ", " + valueName + ") in " + valuesFn; - } - return { - "ngRepeat": ngRepeat, - "locals": { - "valueName": valueName, - "keyName": keyName, - "valueFn": valueFn, - "displayFn": displayFn - } - }; - } - return parser; -} ]); - -angular.module("xeditable").factory("editableThemes", function() { - var themes = { - "default": { - "formTpl": '
    ', - "noformTpl": '', - "controlsTpl": '', - "inputTpl": "", - "errorTpl": '
    ', - "buttonsTpl": '', - "submitTpl": '', - "cancelTpl": '' - }, - "bs2": { - "formTpl": '
    ', - "noformTpl": '', - "controlsTpl": '
    ', - "inputTpl": "", - "errorTpl": '
    ', - "buttonsTpl": '', - "submitTpl": '', - "cancelTpl": '" - }, - "bs3": { - "formTpl": '
    ', - "noformTpl": '', - "controlsTpl": '
    ', - "inputTpl": "", - "errorTpl": '
    ', - "buttonsTpl": '', - "submitTpl": '', - "cancelTpl": '", - "buttonsClass": "", - "inputClass": "", - "postrender": function() { - switch (this.directiveName) { - case "editableText": - case "editableSelect": - case "editableTextarea": - case "editableEmail": - case "editableTel": - case "editableNumber": - case "editableUrl": - case "editableSearch": - case "editableDate": - case "editableDatetime": - case "editableTime": - case "editableMonth": - case "editableWeek": - this.inputEl.addClass("form-control"); - if (this.theme.inputClass) { - if (this.inputEl.attr("multiple") && (this.theme.inputClass === "input-sm" || this.theme.inputClass === "input-lg")) { - break; - } - this.inputEl.addClass(this.theme.inputClass); - } - break; - } - if (this.buttonsEl && this.theme.buttonsClass) { - this.buttonsEl.find("button").addClass(this.theme.buttonsClass); - } - } - } - }; - return themes; -}); \ No newline at end of file diff --git a/grails/ag-plugin/web-app/angleGrinder/scripts/angularjs-all.min.js b/grails/ag-plugin/web-app/angleGrinder/scripts/angularjs-all.min.js deleted file mode 100644 index ce2f7f01d..000000000 --- a/grails/ag-plugin/web-app/angleGrinder/scripts/angularjs-all.min.js +++ /dev/null @@ -1,12856 +0,0 @@ -(function(window, document, undefined) { - "use strict"; - function minErr(module) { - return function() { - var code = arguments[0], prefix = "[" + (module ? module + ":" : "") + code + "] ", template = arguments[1], templateArgs = arguments, stringify = function(obj) { - if (typeof obj === "function") { - return obj.toString().replace(/ \{[\s\S]*$/, ""); - } else if (typeof obj === "undefined") { - return "undefined"; - } else if (typeof obj !== "string") { - return JSON.stringify(obj); - } - return obj; - }, message, i; - message = prefix + template.replace(/\{\d+\}/g, function(match) { - var index = +match.slice(1, -1), arg; - if (index + 2 < templateArgs.length) { - arg = templateArgs[index + 2]; - if (typeof arg === "function") { - return arg.toString().replace(/ ?\{[\s\S]*$/, ""); - } else if (typeof arg === "undefined") { - return "undefined"; - } else if (typeof arg !== "string") { - return toJson(arg); - } - return arg; - } - return match; - }); - message = message + "\nhttp://errors.angularjs.org/1.2.22/" + (module ? module + "/" : "") + code; - for (i = 2; i < arguments.length; i++) { - message = message + (i == 2 ? "?" : "&") + "p" + (i - 2) + "=" + encodeURIComponent(stringify(arguments[i])); - } - return new Error(message); - }; - } - var VALIDITY_STATE_PROPERTY = "validity"; - var lowercase = function(string) { - return isString(string) ? string.toLowerCase() : string; - }; - var hasOwnProperty = Object.prototype.hasOwnProperty; - var uppercase = function(string) { - return isString(string) ? string.toUpperCase() : string; - }; - var manualLowercase = function(s) { - return isString(s) ? s.replace(/[A-Z]/g, function(ch) { - return String.fromCharCode(ch.charCodeAt(0) | 32); - }) : s; - }; - var manualUppercase = function(s) { - return isString(s) ? s.replace(/[a-z]/g, function(ch) { - return String.fromCharCode(ch.charCodeAt(0) & ~32); - }) : s; - }; - if ("i" !== "I".toLowerCase()) { - lowercase = manualLowercase; - uppercase = manualUppercase; - } - var msie, jqLite, jQuery, slice = [].slice, push = [].push, toString = Object.prototype.toString, ngMinErr = minErr("ng"), angular = window.angular || (window.angular = {}), angularModule, nodeName_, uid = [ "0", "0", "0" ]; - msie = int((/msie (\d+)/.exec(lowercase(navigator.userAgent)) || [])[1]); - if (isNaN(msie)) { - msie = int((/trident\/.*; rv:(\d+)/.exec(lowercase(navigator.userAgent)) || [])[1]); - } - function isArrayLike(obj) { - if (obj == null || isWindow(obj)) { - return false; - } - var length = obj.length; - if (obj.nodeType === 1 && length) { - return true; - } - return isString(obj) || isArray(obj) || length === 0 || typeof length === "number" && length > 0 && length - 1 in obj; - } - function forEach(obj, iterator, context) { - var key; - if (obj) { - if (isFunction(obj)) { - for (key in obj) { - if (key != "prototype" && key != "length" && key != "name" && (!obj.hasOwnProperty || obj.hasOwnProperty(key))) { - iterator.call(context, obj[key], key); - } - } - } else if (isArray(obj) || isArrayLike(obj)) { - for (key = 0; key < obj.length; key++) { - iterator.call(context, obj[key], key); - } - } else if (obj.forEach && obj.forEach !== forEach) { - obj.forEach(iterator, context); - } else { - for (key in obj) { - if (obj.hasOwnProperty(key)) { - iterator.call(context, obj[key], key); - } - } - } - } - return obj; - } - function sortedKeys(obj) { - var keys = []; - for (var key in obj) { - if (obj.hasOwnProperty(key)) { - keys.push(key); - } - } - return keys.sort(); - } - function forEachSorted(obj, iterator, context) { - var keys = sortedKeys(obj); - for (var i = 0; i < keys.length; i++) { - iterator.call(context, obj[keys[i]], keys[i]); - } - return keys; - } - function reverseParams(iteratorFn) { - return function(value, key) { - iteratorFn(key, value); - }; - } - function nextUid() { - var index = uid.length; - var digit; - while (index) { - index--; - digit = uid[index].charCodeAt(0); - if (digit == 57) { - uid[index] = "A"; - return uid.join(""); - } - if (digit == 90) { - uid[index] = "0"; - } else { - uid[index] = String.fromCharCode(digit + 1); - return uid.join(""); - } - } - uid.unshift("0"); - return uid.join(""); - } - function setHashKey(obj, h) { - if (h) { - obj.$$hashKey = h; - } else { - delete obj.$$hashKey; - } - } - function extend(dst) { - var h = dst.$$hashKey; - forEach(arguments, function(obj) { - if (obj !== dst) { - forEach(obj, function(value, key) { - dst[key] = value; - }); - } - }); - setHashKey(dst, h); - return dst; - } - function int(str) { - return parseInt(str, 10); - } - function inherit(parent, extra) { - return extend(new (extend(function() {}, { - "prototype": parent - }))(), extra); - } - function noop() {} - noop.$inject = []; - function identity($) { - return $; - } - identity.$inject = []; - function valueFn(value) { - return function() { - return value; - }; - } - function isUndefined(value) { - return typeof value === "undefined"; - } - function isDefined(value) { - return typeof value !== "undefined"; - } - function isObject(value) { - return value != null && typeof value === "object"; - } - function isString(value) { - return typeof value === "string"; - } - function isNumber(value) { - return typeof value === "number"; - } - function isDate(value) { - return toString.call(value) === "[object Date]"; - } - var isArray = function() { - if (!isFunction(Array.isArray)) { - return function(value) { - return toString.call(value) === "[object Array]"; - }; - } - return Array.isArray; - }(); - function isFunction(value) { - return typeof value === "function"; - } - function isRegExp(value) { - return toString.call(value) === "[object RegExp]"; - } - function isWindow(obj) { - return obj && obj.document && obj.location && obj.alert && obj.setInterval; - } - function isScope(obj) { - return obj && obj.$evalAsync && obj.$watch; - } - function isFile(obj) { - return toString.call(obj) === "[object File]"; - } - function isBlob(obj) { - return toString.call(obj) === "[object Blob]"; - } - function isBoolean(value) { - return typeof value === "boolean"; - } - function isPromiseLike(obj) { - return obj && isFunction(obj.then); - } - var trim = function() { - if (!String.prototype.trim) { - return function(value) { - return isString(value) ? value.replace(/^\s\s*/, "").replace(/\s\s*$/, "") : value; - }; - } - return function(value) { - return isString(value) ? value.trim() : value; - }; - }(); - function isElement(node) { - return !!(node && (node.nodeName || node.prop && node.attr && node.find)); - } - function makeMap(str) { - var obj = {}, items = str.split(","), i; - for (i = 0; i < items.length; i++) obj[items[i]] = true; - return obj; - } - if (msie < 9) { - nodeName_ = function(element) { - element = element.nodeName ? element : element[0]; - return element.scopeName && element.scopeName != "HTML" ? uppercase(element.scopeName + ":" + element.nodeName) : element.nodeName; - }; - } else { - nodeName_ = function(element) { - return element.nodeName ? element.nodeName : element[0].nodeName; - }; - } - function map(obj, iterator, context) { - var results = []; - forEach(obj, function(value, index, list) { - results.push(iterator.call(context, value, index, list)); - }); - return results; - } - function size(obj, ownPropsOnly) { - var count = 0, key; - if (isArray(obj) || isString(obj)) { - return obj.length; - } else if (isObject(obj)) { - for (key in obj) if (!ownPropsOnly || obj.hasOwnProperty(key)) count++; - } - return count; - } - function includes(array, obj) { - return indexOf(array, obj) != -1; - } - function indexOf(array, obj) { - if (array.indexOf) return array.indexOf(obj); - for (var i = 0; i < array.length; i++) { - if (obj === array[i]) return i; - } - return -1; - } - function arrayRemove(array, value) { - var index = indexOf(array, value); - if (index >= 0) array.splice(index, 1); - return value; - } - function isLeafNode(node) { - if (node) { - switch (node.nodeName) { - case "OPTION": - case "PRE": - case "TITLE": - return true; - } - } - return false; - } - function copy(source, destination, stackSource, stackDest) { - if (isWindow(source) || isScope(source)) { - throw ngMinErr("cpws", "Can't copy! Making copies of Window or Scope instances is not supported."); - } - if (!destination) { - destination = source; - if (source) { - if (isArray(source)) { - destination = copy(source, [], stackSource, stackDest); - } else if (isDate(source)) { - destination = new Date(source.getTime()); - } else if (isRegExp(source)) { - destination = new RegExp(source.source, source.toString().match(/[^\/]*$/)[0]); - destination.lastIndex = source.lastIndex; - } else if (isObject(source)) { - destination = copy(source, {}, stackSource, stackDest); - } - } - } else { - if (source === destination) throw ngMinErr("cpi", "Can't copy! Source and destination are identical."); - stackSource = stackSource || []; - stackDest = stackDest || []; - if (isObject(source)) { - var index = indexOf(stackSource, source); - if (index !== -1) return stackDest[index]; - stackSource.push(source); - stackDest.push(destination); - } - var result; - if (isArray(source)) { - destination.length = 0; - for (var i = 0; i < source.length; i++) { - result = copy(source[i], null, stackSource, stackDest); - if (isObject(source[i])) { - stackSource.push(source[i]); - stackDest.push(result); - } - destination.push(result); - } - } else { - var h = destination.$$hashKey; - forEach(destination, function(value, key) { - delete destination[key]; - }); - for (var key in source) { - result = copy(source[key], null, stackSource, stackDest); - if (isObject(source[key])) { - stackSource.push(source[key]); - stackDest.push(result); - } - destination[key] = result; - } - setHashKey(destination, h); - } - } - return destination; - } - function shallowCopy(src, dst) { - if (isArray(src)) { - dst = dst || []; - for (var i = 0; i < src.length; i++) { - dst[i] = src[i]; - } - } else if (isObject(src)) { - dst = dst || {}; - for (var key in src) { - if (hasOwnProperty.call(src, key) && !(key.charAt(0) === "$" && key.charAt(1) === "$")) { - dst[key] = src[key]; - } - } - } - return dst || src; - } - function equals(o1, o2) { - if (o1 === o2) return true; - if (o1 === null || o2 === null) return false; - if (o1 !== o1 && o2 !== o2) return true; - var t1 = typeof o1, t2 = typeof o2, length, key, keySet; - if (t1 == t2) { - if (t1 == "object") { - if (isArray(o1)) { - if (!isArray(o2)) return false; - if ((length = o1.length) == o2.length) { - for (key = 0; key < length; key++) { - if (!equals(o1[key], o2[key])) return false; - } - return true; - } - } else if (isDate(o1)) { - return isDate(o2) && o1.getTime() == o2.getTime(); - } else if (isRegExp(o1) && isRegExp(o2)) { - return o1.toString() == o2.toString(); - } else { - if (isScope(o1) || isScope(o2) || isWindow(o1) || isWindow(o2) || isArray(o2)) return false; - keySet = {}; - for (key in o1) { - if (key.charAt(0) === "$" || isFunction(o1[key])) continue; - if (!equals(o1[key], o2[key])) return false; - keySet[key] = true; - } - for (key in o2) { - if (!keySet.hasOwnProperty(key) && key.charAt(0) !== "$" && o2[key] !== undefined && !isFunction(o2[key])) return false; - } - return true; - } - } - } - return false; - } - var csp = function() { - if (isDefined(csp.isActive_)) return csp.isActive_; - var active = !!(document.querySelector("[ng-csp]") || document.querySelector("[data-ng-csp]")); - if (!active) { - try { - new Function(""); - } catch (e) { - active = true; - } - } - return csp.isActive_ = active; - }; - function concat(array1, array2, index) { - return array1.concat(slice.call(array2, index)); - } - function sliceArgs(args, startIndex) { - return slice.call(args, startIndex || 0); - } - function bind(self, fn) { - var curryArgs = arguments.length > 2 ? sliceArgs(arguments, 2) : []; - if (isFunction(fn) && !(fn instanceof RegExp)) { - return curryArgs.length ? function() { - return arguments.length ? fn.apply(self, curryArgs.concat(slice.call(arguments, 0))) : fn.apply(self, curryArgs); - } : function() { - return arguments.length ? fn.apply(self, arguments) : fn.call(self); - }; - } else { - return fn; - } - } - function toJsonReplacer(key, value) { - var val = value; - if (typeof key === "string" && key.charAt(0) === "$") { - val = undefined; - } else if (isWindow(value)) { - val = "$WINDOW"; - } else if (value && document === value) { - val = "$DOCUMENT"; - } else if (isScope(value)) { - val = "$SCOPE"; - } - return val; - } - function toJson(obj, pretty) { - if (typeof obj === "undefined") return undefined; - return JSON.stringify(obj, toJsonReplacer, pretty ? " " : null); - } - function fromJson(json) { - return isString(json) ? JSON.parse(json) : json; - } - function toBoolean(value) { - if (typeof value === "function") { - value = true; - } else if (value && value.length !== 0) { - var v = lowercase("" + value); - value = !(v == "f" || v == "0" || v == "false" || v == "no" || v == "n" || v == "[]"); - } else { - value = false; - } - return value; - } - function startingTag(element) { - element = jqLite(element).clone(); - try { - element.empty(); - } catch (e) {} - var TEXT_NODE = 3; - var elemHtml = jqLite("
    ").append(element).html(); - try { - return element[0].nodeType === TEXT_NODE ? lowercase(elemHtml) : elemHtml.match(/^(<[^>]+>)/)[1].replace(/^<([\w\-]+)/, function(match, nodeName) { - return "<" + lowercase(nodeName); - }); - } catch (e) { - return lowercase(elemHtml); - } - } - function tryDecodeURIComponent(value) { - try { - return decodeURIComponent(value); - } catch (e) {} - } - function parseKeyValue(keyValue) { - var obj = {}, key_value, key; - forEach((keyValue || "").split("&"), function(keyValue) { - if (keyValue) { - key_value = keyValue.replace(/\+/g, "%20").split("="); - key = tryDecodeURIComponent(key_value[0]); - if (isDefined(key)) { - var val = isDefined(key_value[1]) ? tryDecodeURIComponent(key_value[1]) : true; - if (!hasOwnProperty.call(obj, key)) { - obj[key] = val; - } else if (isArray(obj[key])) { - obj[key].push(val); - } else { - obj[key] = [ obj[key], val ]; - } - } - } - }); - return obj; - } - function toKeyValue(obj) { - var parts = []; - forEach(obj, function(value, key) { - if (isArray(value)) { - forEach(value, function(arrayValue) { - parts.push(encodeUriQuery(key, true) + (arrayValue === true ? "" : "=" + encodeUriQuery(arrayValue, true))); - }); - } else { - parts.push(encodeUriQuery(key, true) + (value === true ? "" : "=" + encodeUriQuery(value, true))); - } - }); - return parts.length ? parts.join("&") : ""; - } - function encodeUriSegment(val) { - return encodeUriQuery(val, true).replace(/%26/gi, "&").replace(/%3D/gi, "=").replace(/%2B/gi, "+"); - } - function encodeUriQuery(val, pctEncodeSpaces) { - return encodeURIComponent(val).replace(/%40/gi, "@").replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, pctEncodeSpaces ? "%20" : "+"); - } - function angularInit(element, bootstrap) { - var elements = [ element ], appElement, module, names = [ "ng:app", "ng-app", "x-ng-app", "data-ng-app" ], NG_APP_CLASS_REGEXP = /\sng[:\-]app(:\s*([\w\d_]+);?)?\s/; - function append(element) { - element && elements.push(element); - } - forEach(names, function(name) { - names[name] = true; - append(document.getElementById(name)); - name = name.replace(":", "\\:"); - if (element.querySelectorAll) { - forEach(element.querySelectorAll("." + name), append); - forEach(element.querySelectorAll("." + name + "\\:"), append); - forEach(element.querySelectorAll("[" + name + "]"), append); - } - }); - forEach(elements, function(element) { - if (!appElement) { - var className = " " + element.className + " "; - var match = NG_APP_CLASS_REGEXP.exec(className); - if (match) { - appElement = element; - module = (match[2] || "").replace(/\s+/g, ","); - } else { - forEach(element.attributes, function(attr) { - if (!appElement && names[attr.name]) { - appElement = element; - module = attr.value; - } - }); - } - } - }); - if (appElement) { - bootstrap(appElement, module ? [ module ] : []); - } - } - function bootstrap(element, modules) { - var doBootstrap = function() { - element = jqLite(element); - if (element.injector()) { - var tag = element[0] === document ? "document" : startingTag(element); - throw ngMinErr("btstrpd", "App Already Bootstrapped with this Element '{0}'", tag); - } - modules = modules || []; - modules.unshift([ "$provide", function($provide) { - $provide.value("$rootElement", element); - } ]); - modules.unshift("ng"); - var injector = createInjector(modules); - injector.invoke([ "$rootScope", "$rootElement", "$compile", "$injector", "$animate", function(scope, element, compile, injector, animate) { - scope.$apply(function() { - element.data("$injector", injector); - compile(element)(scope); - }); - } ]); - return injector; - }; - var NG_DEFER_BOOTSTRAP = /^NG_DEFER_BOOTSTRAP!/; - if (window && !NG_DEFER_BOOTSTRAP.test(window.name)) { - return doBootstrap(); - } - window.name = window.name.replace(NG_DEFER_BOOTSTRAP, ""); - angular.resumeBootstrap = function(extraModules) { - forEach(extraModules, function(module) { - modules.push(module); - }); - doBootstrap(); - }; - } - var SNAKE_CASE_REGEXP = /[A-Z]/g; - function snake_case(name, separator) { - separator = separator || "_"; - return name.replace(SNAKE_CASE_REGEXP, function(letter, pos) { - return (pos ? separator : "") + letter.toLowerCase(); - }); - } - function bindJQuery() { - jQuery = window.jQuery; - if (jQuery && jQuery.fn.on) { - jqLite = jQuery; - extend(jQuery.fn, { - "scope": JQLitePrototype.scope, - "isolateScope": JQLitePrototype.isolateScope, - "controller": JQLitePrototype.controller, - "injector": JQLitePrototype.injector, - "inheritedData": JQLitePrototype.inheritedData - }); - jqLitePatchJQueryRemove("remove", true, true, false); - jqLitePatchJQueryRemove("empty", false, false, false); - jqLitePatchJQueryRemove("html", false, false, true); - } else { - jqLite = JQLite; - } - angular.element = jqLite; - } - function assertArg(arg, name, reason) { - if (!arg) { - throw ngMinErr("areq", "Argument '{0}' is {1}", name || "?", reason || "required"); - } - return arg; - } - function assertArgFn(arg, name, acceptArrayAnnotation) { - if (acceptArrayAnnotation && isArray(arg)) { - arg = arg[arg.length - 1]; - } - assertArg(isFunction(arg), name, "not a function, got " + (arg && typeof arg === "object" ? arg.constructor.name || "Object" : typeof arg)); - return arg; - } - function assertNotHasOwnProperty(name, context) { - if (name === "hasOwnProperty") { - throw ngMinErr("badname", "hasOwnProperty is not a valid {0} name", context); - } - } - function getter(obj, path, bindFnToScope) { - if (!path) return obj; - var keys = path.split("."); - var key; - var lastInstance = obj; - var len = keys.length; - for (var i = 0; i < len; i++) { - key = keys[i]; - if (obj) { - obj = (lastInstance = obj)[key]; - } - } - if (!bindFnToScope && isFunction(obj)) { - return bind(lastInstance, obj); - } - return obj; - } - function getBlockElements(nodes) { - var startNode = nodes[0], endNode = nodes[nodes.length - 1]; - if (startNode === endNode) { - return jqLite(startNode); - } - var element = startNode; - var elements = [ element ]; - do { - element = element.nextSibling; - if (!element) break; - elements.push(element); - } while (element !== endNode); - return jqLite(elements); - } - function setupModuleLoader(window) { - var $injectorMinErr = minErr("$injector"); - var ngMinErr = minErr("ng"); - function ensure(obj, name, factory) { - return obj[name] || (obj[name] = factory()); - } - var angular = ensure(window, "angular", Object); - angular.$$minErr = angular.$$minErr || minErr; - return ensure(angular, "module", function() { - var modules = {}; - return function module(name, requires, configFn) { - var assertNotHasOwnProperty = function(name, context) { - if (name === "hasOwnProperty") { - throw ngMinErr("badname", "hasOwnProperty is not a valid {0} name", context); - } - }; - assertNotHasOwnProperty(name, "module"); - if (requires && modules.hasOwnProperty(name)) { - modules[name] = null; - } - return ensure(modules, name, function() { - if (!requires) { - throw $injectorMinErr("nomod", "Module '{0}' is not available! You either misspelled " + "the module name or forgot to load it. If registering a module ensure that you " + "specify the dependencies as the second argument.", name); - } - var invokeQueue = []; - var runBlocks = []; - var config = invokeLater("$injector", "invoke"); - var moduleInstance = { - "_invokeQueue": invokeQueue, - "_runBlocks": runBlocks, - "requires": requires, - "name": name, - "provider": invokeLater("$provide", "provider"), - "factory": invokeLater("$provide", "factory"), - "service": invokeLater("$provide", "service"), - "value": invokeLater("$provide", "value"), - "constant": invokeLater("$provide", "constant", "unshift"), - "animation": invokeLater("$animateProvider", "register"), - "filter": invokeLater("$filterProvider", "register"), - "controller": invokeLater("$controllerProvider", "register"), - "directive": invokeLater("$compileProvider", "directive"), - "config": config, - "run": function(block) { - runBlocks.push(block); - return this; - } - }; - if (configFn) { - config(configFn); - } - return moduleInstance; - function invokeLater(provider, method, insertMethod) { - return function() { - invokeQueue[insertMethod || "push"]([ provider, method, arguments ]); - return moduleInstance; - }; - } - }); - }; - }); - } - var version = { - "full": "1.2.22", - "major": 1, - "minor": 2, - "dot": 22, - "codeName": "finicky-pleasure" - }; - function publishExternalAPI(angular) { - extend(angular, { - "bootstrap": bootstrap, - "copy": copy, - "extend": extend, - "equals": equals, - "element": jqLite, - "forEach": forEach, - "injector": createInjector, - "noop": noop, - "bind": bind, - "toJson": toJson, - "fromJson": fromJson, - "identity": identity, - "isUndefined": isUndefined, - "isDefined": isDefined, - "isString": isString, - "isFunction": isFunction, - "isObject": isObject, - "isNumber": isNumber, - "isElement": isElement, - "isArray": isArray, - "version": version, - "isDate": isDate, - "lowercase": lowercase, - "uppercase": uppercase, - "callbacks": { - "counter": 0 - }, - "$$minErr": minErr, - "$$csp": csp - }); - angularModule = setupModuleLoader(window); - try { - angularModule("ngLocale"); - } catch (e) { - angularModule("ngLocale", []).provider("$locale", $LocaleProvider); - } - angularModule("ng", [ "ngLocale" ], [ "$provide", function ngModule($provide) { - $provide.provider({ - "$$sanitizeUri": $$SanitizeUriProvider - }); - $provide.provider("$compile", $CompileProvider).directive({ - "a": htmlAnchorDirective, - "input": inputDirective, - "textarea": inputDirective, - "form": formDirective, - "script": scriptDirective, - "select": selectDirective, - "style": styleDirective, - "option": optionDirective, - "ngBind": ngBindDirective, - "ngBindHtml": ngBindHtmlDirective, - "ngBindTemplate": ngBindTemplateDirective, - "ngClass": ngClassDirective, - "ngClassEven": ngClassEvenDirective, - "ngClassOdd": ngClassOddDirective, - "ngCloak": ngCloakDirective, - "ngController": ngControllerDirective, - "ngForm": ngFormDirective, - "ngHide": ngHideDirective, - "ngIf": ngIfDirective, - "ngInclude": ngIncludeDirective, - "ngInit": ngInitDirective, - "ngNonBindable": ngNonBindableDirective, - "ngPluralize": ngPluralizeDirective, - "ngRepeat": ngRepeatDirective, - "ngShow": ngShowDirective, - "ngStyle": ngStyleDirective, - "ngSwitch": ngSwitchDirective, - "ngSwitchWhen": ngSwitchWhenDirective, - "ngSwitchDefault": ngSwitchDefaultDirective, - "ngOptions": ngOptionsDirective, - "ngTransclude": ngTranscludeDirective, - "ngModel": ngModelDirective, - "ngList": ngListDirective, - "ngChange": ngChangeDirective, - "required": requiredDirective, - "ngRequired": requiredDirective, - "ngValue": ngValueDirective - }).directive({ - "ngInclude": ngIncludeFillContentDirective - }).directive(ngAttributeAliasDirectives).directive(ngEventDirectives); - $provide.provider({ - "$anchorScroll": $AnchorScrollProvider, - "$animate": $AnimateProvider, - "$browser": $BrowserProvider, - "$cacheFactory": $CacheFactoryProvider, - "$controller": $ControllerProvider, - "$document": $DocumentProvider, - "$exceptionHandler": $ExceptionHandlerProvider, - "$filter": $FilterProvider, - "$interpolate": $InterpolateProvider, - "$interval": $IntervalProvider, - "$http": $HttpProvider, - "$httpBackend": $HttpBackendProvider, - "$location": $LocationProvider, - "$log": $LogProvider, - "$parse": $ParseProvider, - "$rootScope": $RootScopeProvider, - "$q": $QProvider, - "$sce": $SceProvider, - "$sceDelegate": $SceDelegateProvider, - "$sniffer": $SnifferProvider, - "$templateCache": $TemplateCacheProvider, - "$timeout": $TimeoutProvider, - "$window": $WindowProvider, - "$$rAF": $$RAFProvider, - "$$asyncCallback": $$AsyncCallbackProvider - }); - } ]); - } - JQLite.expando = "ng339"; - var jqCache = JQLite.cache = {}, jqId = 1, addEventListenerFn = window.document.addEventListener ? function(element, type, fn) { - element.addEventListener(type, fn, false); - } : function(element, type, fn) { - element.attachEvent("on" + type, fn); - }, removeEventListenerFn = window.document.removeEventListener ? function(element, type, fn) { - element.removeEventListener(type, fn, false); - } : function(element, type, fn) { - element.detachEvent("on" + type, fn); - }; - var jqData = JQLite._data = function(node) { - return this.cache[node[this.expando]] || {}; - }; - function jqNextId() { - return ++jqId; - } - var SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g; - var MOZ_HACK_REGEXP = /^moz([A-Z])/; - var jqLiteMinErr = minErr("jqLite"); - function camelCase(name) { - return name.replace(SPECIAL_CHARS_REGEXP, function(_, separator, letter, offset) { - return offset ? letter.toUpperCase() : letter; - }).replace(MOZ_HACK_REGEXP, "Moz$1"); - } - function jqLitePatchJQueryRemove(name, dispatchThis, filterElems, getterIfNoArguments) { - var originalJqFn = jQuery.fn[name]; - originalJqFn = originalJqFn.$original || originalJqFn; - removePatch.$original = originalJqFn; - jQuery.fn[name] = removePatch; - function removePatch(param) { - var list = filterElems && param ? [ this.filter(param) ] : [ this ], fireEvent = dispatchThis, set, setIndex, setLength, element, childIndex, childLength, children; - if (!getterIfNoArguments || param != null) { - while (list.length) { - set = list.shift(); - for (setIndex = 0, setLength = set.length; setIndex < setLength; setIndex++) { - element = jqLite(set[setIndex]); - if (fireEvent) { - element.triggerHandler("$destroy"); - } else { - fireEvent = !fireEvent; - } - for (childIndex = 0, childLength = (children = element.children()).length; childIndex < childLength; childIndex++) { - list.push(jQuery(children[childIndex])); - } - } - } - } - return originalJqFn.apply(this, arguments); - } - } - var SINGLE_TAG_REGEXP = /^<(\w+)\s*\/?>(?:<\/\1>|)$/; - var HTML_REGEXP = /<|&#?\w+;/; - var TAG_NAME_REGEXP = /<([\w:]+)/; - var XHTML_TAG_REGEXP = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi; - var wrapMap = { - "option": [ 1, '" ], - "thead": [ 1, "", "
    " ], - "col": [ 2, "", "
    " ], - "tr": [ 2, "", "
    " ], - "td": [ 3, "", "
    " ], - "_default": [ 0, "", "" ] - }; - wrapMap.optgroup = wrapMap.option; - wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; - wrapMap.th = wrapMap.td; - function jqLiteIsTextNode(html) { - return !HTML_REGEXP.test(html); - } - function jqLiteBuildFragment(html, context) { - var elem, tmp, tag, wrap, fragment = context.createDocumentFragment(), nodes = [], i, j, jj; - if (jqLiteIsTextNode(html)) { - nodes.push(context.createTextNode(html)); - } else { - tmp = fragment.appendChild(context.createElement("div")); - tag = (TAG_NAME_REGEXP.exec(html) || [ "", "" ])[1].toLowerCase(); - wrap = wrapMap[tag] || wrapMap._default; - tmp.innerHTML = "
     
    " + wrap[1] + html.replace(XHTML_TAG_REGEXP, "<$1>") + wrap[2]; - tmp.removeChild(tmp.firstChild); - i = wrap[0]; - while (i--) { - tmp = tmp.lastChild; - } - for (j = 0, jj = tmp.childNodes.length; j < jj; ++j) nodes.push(tmp.childNodes[j]); - tmp = fragment.firstChild; - tmp.textContent = ""; - } - fragment.textContent = ""; - fragment.innerHTML = ""; - return nodes; - } - function jqLiteParseHTML(html, context) { - context = context || document; - var parsed; - if (parsed = SINGLE_TAG_REGEXP.exec(html)) { - return [ context.createElement(parsed[1]) ]; - } - return jqLiteBuildFragment(html, context); - } - function JQLite(element) { - if (element instanceof JQLite) { - return element; - } - if (isString(element)) { - element = trim(element); - } - if (!(this instanceof JQLite)) { - if (isString(element) && element.charAt(0) != "<") { - throw jqLiteMinErr("nosel", "Looking up elements via selectors is not supported by jqLite! See: http://docs.angularjs.org/api/angular.element"); - } - return new JQLite(element); - } - if (isString(element)) { - jqLiteAddNodes(this, jqLiteParseHTML(element)); - var fragment = jqLite(document.createDocumentFragment()); - fragment.append(this); - } else { - jqLiteAddNodes(this, element); - } - } - function jqLiteClone(element) { - return element.cloneNode(true); - } - function jqLiteDealoc(element) { - jqLiteRemoveData(element); - for (var i = 0, children = element.childNodes || []; i < children.length; i++) { - jqLiteDealoc(children[i]); - } - } - function jqLiteOff(element, type, fn, unsupported) { - if (isDefined(unsupported)) throw jqLiteMinErr("offargs", "jqLite#off() does not support the `selector` argument"); - var events = jqLiteExpandoStore(element, "events"), handle = jqLiteExpandoStore(element, "handle"); - if (!handle) return; - if (isUndefined(type)) { - forEach(events, function(eventHandler, type) { - removeEventListenerFn(element, type, eventHandler); - delete events[type]; - }); - } else { - forEach(type.split(" "), function(type) { - if (isUndefined(fn)) { - removeEventListenerFn(element, type, events[type]); - delete events[type]; - } else { - arrayRemove(events[type] || [], fn); - } - }); - } - } - function jqLiteRemoveData(element, name) { - var expandoId = element.ng339, expandoStore = jqCache[expandoId]; - if (expandoStore) { - if (name) { - delete jqCache[expandoId].data[name]; - return; - } - if (expandoStore.handle) { - expandoStore.events.$destroy && expandoStore.handle({}, "$destroy"); - jqLiteOff(element); - } - delete jqCache[expandoId]; - element.ng339 = undefined; - } - } - function jqLiteExpandoStore(element, key, value) { - var expandoId = element.ng339, expandoStore = jqCache[expandoId || -1]; - if (isDefined(value)) { - if (!expandoStore) { - element.ng339 = expandoId = jqNextId(); - expandoStore = jqCache[expandoId] = {}; - } - expandoStore[key] = value; - } else { - return expandoStore && expandoStore[key]; - } - } - function jqLiteData(element, key, value) { - var data = jqLiteExpandoStore(element, "data"), isSetter = isDefined(value), keyDefined = !isSetter && isDefined(key), isSimpleGetter = keyDefined && !isObject(key); - if (!data && !isSimpleGetter) { - jqLiteExpandoStore(element, "data", data = {}); - } - if (isSetter) { - data[key] = value; - } else { - if (keyDefined) { - if (isSimpleGetter) { - return data && data[key]; - } else { - extend(data, key); - } - } else { - return data; - } - } - } - function jqLiteHasClass(element, selector) { - if (!element.getAttribute) return false; - return (" " + (element.getAttribute("class") || "") + " ").replace(/[\n\t]/g, " ").indexOf(" " + selector + " ") > -1; - } - function jqLiteRemoveClass(element, cssClasses) { - if (cssClasses && element.setAttribute) { - forEach(cssClasses.split(" "), function(cssClass) { - element.setAttribute("class", trim((" " + (element.getAttribute("class") || "") + " ").replace(/[\n\t]/g, " ").replace(" " + trim(cssClass) + " ", " "))); - }); - } - } - function jqLiteAddClass(element, cssClasses) { - if (cssClasses && element.setAttribute) { - var existingClasses = (" " + (element.getAttribute("class") || "") + " ").replace(/[\n\t]/g, " "); - forEach(cssClasses.split(" "), function(cssClass) { - cssClass = trim(cssClass); - if (existingClasses.indexOf(" " + cssClass + " ") === -1) { - existingClasses += cssClass + " "; - } - }); - element.setAttribute("class", trim(existingClasses)); - } - } - function jqLiteAddNodes(root, elements) { - if (elements) { - elements = !elements.nodeName && isDefined(elements.length) && !isWindow(elements) ? elements : [ elements ]; - for (var i = 0; i < elements.length; i++) { - root.push(elements[i]); - } - } - } - function jqLiteController(element, name) { - return jqLiteInheritedData(element, "$" + (name || "ngController") + "Controller"); - } - function jqLiteInheritedData(element, name, value) { - if (element.nodeType == 9) { - element = element.documentElement; - } - var names = isArray(name) ? name : [ name ]; - while (element) { - for (var i = 0, ii = names.length; i < ii; i++) { - if ((value = jqLite.data(element, names[i])) !== undefined) return value; - } - element = element.parentNode || element.nodeType === 11 && element.host; - } - } - function jqLiteEmpty(element) { - for (var i = 0, childNodes = element.childNodes; i < childNodes.length; i++) { - jqLiteDealoc(childNodes[i]); - } - while (element.firstChild) { - element.removeChild(element.firstChild); - } - } - var JQLitePrototype = JQLite.prototype = { - "ready": function(fn) { - var fired = false; - function trigger() { - if (fired) return; - fired = true; - fn(); - } - if (document.readyState === "complete") { - setTimeout(trigger); - } else { - this.on("DOMContentLoaded", trigger); - JQLite(window).on("load", trigger); - } - }, - "toString": function() { - var value = []; - forEach(this, function(e) { - value.push("" + e); - }); - return "[" + value.join(", ") + "]"; - }, - "eq": function(index) { - return index >= 0 ? jqLite(this[index]) : jqLite(this[this.length + index]); - }, - "length": 0, - "push": push, - "sort": [].sort, - "splice": [].splice - }; - var BOOLEAN_ATTR = {}; - forEach("multiple,selected,checked,disabled,readOnly,required,open".split(","), function(value) { - BOOLEAN_ATTR[lowercase(value)] = value; - }); - var BOOLEAN_ELEMENTS = {}; - forEach("input,select,option,textarea,button,form,details".split(","), function(value) { - BOOLEAN_ELEMENTS[uppercase(value)] = true; - }); - function getBooleanAttrName(element, name) { - var booleanAttr = BOOLEAN_ATTR[name.toLowerCase()]; - return booleanAttr && BOOLEAN_ELEMENTS[element.nodeName] && booleanAttr; - } - forEach({ - "data": jqLiteData, - "removeData": jqLiteRemoveData - }, function(fn, name) { - JQLite[name] = fn; - }); - forEach({ - "data": jqLiteData, - "inheritedData": jqLiteInheritedData, - "scope": function(element) { - return jqLite.data(element, "$scope") || jqLiteInheritedData(element.parentNode || element, [ "$isolateScope", "$scope" ]); - }, - "isolateScope": function(element) { - return jqLite.data(element, "$isolateScope") || jqLite.data(element, "$isolateScopeNoTemplate"); - }, - "controller": jqLiteController, - "injector": function(element) { - return jqLiteInheritedData(element, "$injector"); - }, - "removeAttr": function(element, name) { - element.removeAttribute(name); - }, - "hasClass": jqLiteHasClass, - "css": function(element, name, value) { - name = camelCase(name); - if (isDefined(value)) { - element.style[name] = value; - } else { - var val; - if (msie <= 8) { - val = element.currentStyle && element.currentStyle[name]; - if (val === "") val = "auto"; - } - val = val || element.style[name]; - if (msie <= 8) { - val = val === "" ? undefined : val; - } - return val; - } - }, - "attr": function(element, name, value) { - var lowercasedName = lowercase(name); - if (BOOLEAN_ATTR[lowercasedName]) { - if (isDefined(value)) { - if (!!value) { - element[name] = true; - element.setAttribute(name, lowercasedName); - } else { - element[name] = false; - element.removeAttribute(lowercasedName); - } - } else { - return element[name] || (element.attributes.getNamedItem(name) || noop).specified ? lowercasedName : undefined; - } - } else if (isDefined(value)) { - element.setAttribute(name, value); - } else if (element.getAttribute) { - var ret = element.getAttribute(name, 2); - return ret === null ? undefined : ret; - } - }, - "prop": function(element, name, value) { - if (isDefined(value)) { - element[name] = value; - } else { - return element[name]; - } - }, - "text": function() { - var NODE_TYPE_TEXT_PROPERTY = []; - if (msie < 9) { - NODE_TYPE_TEXT_PROPERTY[1] = "innerText"; - NODE_TYPE_TEXT_PROPERTY[3] = "nodeValue"; - } else { - NODE_TYPE_TEXT_PROPERTY[1] = NODE_TYPE_TEXT_PROPERTY[3] = "textContent"; - } - getText.$dv = ""; - return getText; - function getText(element, value) { - var textProp = NODE_TYPE_TEXT_PROPERTY[element.nodeType]; - if (isUndefined(value)) { - return textProp ? element[textProp] : ""; - } - element[textProp] = value; - } - }(), - "val": function(element, value) { - if (isUndefined(value)) { - if (nodeName_(element) === "SELECT" && element.multiple) { - var result = []; - forEach(element.options, function(option) { - if (option.selected) { - result.push(option.value || option.text); - } - }); - return result.length === 0 ? null : result; - } - return element.value; - } - element.value = value; - }, - "html": function(element, value) { - if (isUndefined(value)) { - return element.innerHTML; - } - for (var i = 0, childNodes = element.childNodes; i < childNodes.length; i++) { - jqLiteDealoc(childNodes[i]); - } - element.innerHTML = value; - }, - "empty": jqLiteEmpty - }, function(fn, name) { - JQLite.prototype[name] = function(arg1, arg2) { - var i, key; - var nodeCount = this.length; - if (fn !== jqLiteEmpty && (fn.length == 2 && (fn !== jqLiteHasClass && fn !== jqLiteController) ? arg1 : arg2) === undefined) { - if (isObject(arg1)) { - for (i = 0; i < nodeCount; i++) { - if (fn === jqLiteData) { - fn(this[i], arg1); - } else { - for (key in arg1) { - fn(this[i], key, arg1[key]); - } - } - } - return this; - } else { - var value = fn.$dv; - var jj = value === undefined ? Math.min(nodeCount, 1) : nodeCount; - for (var j = 0; j < jj; j++) { - var nodeValue = fn(this[j], arg1, arg2); - value = value ? value + nodeValue : nodeValue; - } - return value; - } - } else { - for (i = 0; i < nodeCount; i++) { - fn(this[i], arg1, arg2); - } - return this; - } - }; - }); - function createEventHandler(element, events) { - var eventHandler = function(event, type) { - if (!event.preventDefault) { - event.preventDefault = function() { - event.returnValue = false; - }; - } - if (!event.stopPropagation) { - event.stopPropagation = function() { - event.cancelBubble = true; - }; - } - if (!event.target) { - event.target = event.srcElement || document; - } - if (isUndefined(event.defaultPrevented)) { - var prevent = event.preventDefault; - event.preventDefault = function() { - event.defaultPrevented = true; - prevent.call(event); - }; - event.defaultPrevented = false; - } - event.isDefaultPrevented = function() { - return event.defaultPrevented || event.returnValue === false; - }; - var eventHandlersCopy = shallowCopy(events[type || event.type] || []); - forEach(eventHandlersCopy, function(fn) { - fn.call(element, event); - }); - if (msie <= 8) { - event.preventDefault = null; - event.stopPropagation = null; - event.isDefaultPrevented = null; - } else { - delete event.preventDefault; - delete event.stopPropagation; - delete event.isDefaultPrevented; - } - }; - eventHandler.elem = element; - return eventHandler; - } - forEach({ - "removeData": jqLiteRemoveData, - "dealoc": jqLiteDealoc, - "on": function onFn(element, type, fn, unsupported) { - if (isDefined(unsupported)) throw jqLiteMinErr("onargs", "jqLite#on() does not support the `selector` or `eventData` parameters"); - var events = jqLiteExpandoStore(element, "events"), handle = jqLiteExpandoStore(element, "handle"); - if (!events) jqLiteExpandoStore(element, "events", events = {}); - if (!handle) jqLiteExpandoStore(element, "handle", handle = createEventHandler(element, events)); - forEach(type.split(" "), function(type) { - var eventFns = events[type]; - if (!eventFns) { - if (type == "mouseenter" || type == "mouseleave") { - var contains = document.body.contains || document.body.compareDocumentPosition ? function(a, b) { - var adown = a.nodeType === 9 ? a.documentElement : a, bup = b && b.parentNode; - return a === bup || !!(bup && bup.nodeType === 1 && (adown.contains ? adown.contains(bup) : a.compareDocumentPosition && a.compareDocumentPosition(bup) & 16)); - } : function(a, b) { - if (b) { - while (b = b.parentNode) { - if (b === a) { - return true; - } - } - } - return false; - }; - events[type] = []; - var eventmap = { - "mouseleave": "mouseout", - "mouseenter": "mouseover" - }; - onFn(element, eventmap[type], function(event) { - var target = this, related = event.relatedTarget; - if (!related || related !== target && !contains(target, related)) { - handle(event, type); - } - }); - } else { - addEventListenerFn(element, type, handle); - events[type] = []; - } - eventFns = events[type]; - } - eventFns.push(fn); - }); - }, - "off": jqLiteOff, - "one": function(element, type, fn) { - element = jqLite(element); - element.on(type, function onFn() { - element.off(type, fn); - element.off(type, onFn); - }); - element.on(type, fn); - }, - "replaceWith": function(element, replaceNode) { - var index, parent = element.parentNode; - jqLiteDealoc(element); - forEach(new JQLite(replaceNode), function(node) { - if (index) { - parent.insertBefore(node, index.nextSibling); - } else { - parent.replaceChild(node, element); - } - index = node; - }); - }, - "children": function(element) { - var children = []; - forEach(element.childNodes, function(element) { - if (element.nodeType === 1) children.push(element); - }); - return children; - }, - "contents": function(element) { - return element.contentDocument || element.childNodes || []; - }, - "append": function(element, node) { - forEach(new JQLite(node), function(child) { - if (element.nodeType === 1 || element.nodeType === 11) { - element.appendChild(child); - } - }); - }, - "prepend": function(element, node) { - if (element.nodeType === 1) { - var index = element.firstChild; - forEach(new JQLite(node), function(child) { - element.insertBefore(child, index); - }); - } - }, - "wrap": function(element, wrapNode) { - wrapNode = jqLite(wrapNode)[0]; - var parent = element.parentNode; - if (parent) { - parent.replaceChild(wrapNode, element); - } - wrapNode.appendChild(element); - }, - "remove": function(element) { - jqLiteDealoc(element); - var parent = element.parentNode; - if (parent) parent.removeChild(element); - }, - "after": function(element, newElement) { - var index = element, parent = element.parentNode; - forEach(new JQLite(newElement), function(node) { - parent.insertBefore(node, index.nextSibling); - index = node; - }); - }, - "addClass": jqLiteAddClass, - "removeClass": jqLiteRemoveClass, - "toggleClass": function(element, selector, condition) { - if (selector) { - forEach(selector.split(" "), function(className) { - var classCondition = condition; - if (isUndefined(classCondition)) { - classCondition = !jqLiteHasClass(element, className); - } - (classCondition ? jqLiteAddClass : jqLiteRemoveClass)(element, className); - }); - } - }, - "parent": function(element) { - var parent = element.parentNode; - return parent && parent.nodeType !== 11 ? parent : null; - }, - "next": function(element) { - if (element.nextElementSibling) { - return element.nextElementSibling; - } - var elm = element.nextSibling; - while (elm != null && elm.nodeType !== 1) { - elm = elm.nextSibling; - } - return elm; - }, - "find": function(element, selector) { - if (element.getElementsByTagName) { - return element.getElementsByTagName(selector); - } else { - return []; - } - }, - "clone": jqLiteClone, - "triggerHandler": function(element, event, extraParameters) { - var dummyEvent, eventFnsCopy, handlerArgs; - var eventName = event.type || event; - var eventFns = (jqLiteExpandoStore(element, "events") || {})[eventName]; - if (eventFns) { - dummyEvent = { - "preventDefault": function() { - this.defaultPrevented = true; - }, - "isDefaultPrevented": function() { - return this.defaultPrevented === true; - }, - "stopPropagation": noop, - "type": eventName, - "target": element - }; - if (event.type) { - dummyEvent = extend(dummyEvent, event); - } - eventFnsCopy = shallowCopy(eventFns); - handlerArgs = extraParameters ? [ dummyEvent ].concat(extraParameters) : [ dummyEvent ]; - forEach(eventFnsCopy, function(fn) { - fn.apply(element, handlerArgs); - }); - } - } - }, function(fn, name) { - JQLite.prototype[name] = function(arg1, arg2, arg3) { - var value; - for (var i = 0; i < this.length; i++) { - if (isUndefined(value)) { - value = fn(this[i], arg1, arg2, arg3); - if (isDefined(value)) { - value = jqLite(value); - } - } else { - jqLiteAddNodes(value, fn(this[i], arg1, arg2, arg3)); - } - } - return isDefined(value) ? value : this; - }; - JQLite.prototype.bind = JQLite.prototype.on; - JQLite.prototype.unbind = JQLite.prototype.off; - }); - function hashKey(obj, nextUidFn) { - var objType = typeof obj, key; - if (objType == "function" || objType == "object" && obj !== null) { - if (typeof (key = obj.$$hashKey) == "function") { - key = obj.$$hashKey(); - } else if (key === undefined) { - key = obj.$$hashKey = (nextUidFn || nextUid)(); - } - } else { - key = obj; - } - return objType + ":" + key; - } - function HashMap(array, isolatedUid) { - if (isolatedUid) { - var uid = 0; - this.nextUid = function() { - return ++uid; - }; - } - forEach(array, this.put, this); - } - HashMap.prototype = { - "put": function(key, value) { - this[hashKey(key, this.nextUid)] = value; - }, - "get": function(key) { - return this[hashKey(key, this.nextUid)]; - }, - "remove": function(key) { - var value = this[key = hashKey(key, this.nextUid)]; - delete this[key]; - return value; - } - }; - var FN_ARGS = /^function\s*[^\(]*\(\s*([^\)]*)\)/m; - var FN_ARG_SPLIT = /,/; - var FN_ARG = /^\s*(_?)(\S+?)\1\s*$/; - var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm; - var $injectorMinErr = minErr("$injector"); - function annotate(fn) { - var $inject, fnText, argDecl, last; - if (typeof fn === "function") { - if (!($inject = fn.$inject)) { - $inject = []; - if (fn.length) { - fnText = fn.toString().replace(STRIP_COMMENTS, ""); - argDecl = fnText.match(FN_ARGS); - forEach(argDecl[1].split(FN_ARG_SPLIT), function(arg) { - arg.replace(FN_ARG, function(all, underscore, name) { - $inject.push(name); - }); - }); - } - fn.$inject = $inject; - } - } else if (isArray(fn)) { - last = fn.length - 1; - assertArgFn(fn[last], "fn"); - $inject = fn.slice(0, last); - } else { - assertArgFn(fn, "fn", true); - } - return $inject; - } - function createInjector(modulesToLoad) { - var INSTANTIATING = {}, providerSuffix = "Provider", path = [], loadedModules = new HashMap([], true), providerCache = { - "$provide": { - "provider": supportObject(provider), - "factory": supportObject(factory), - "service": supportObject(service), - "value": supportObject(value), - "constant": supportObject(constant), - "decorator": decorator - } - }, providerInjector = providerCache.$injector = createInternalInjector(providerCache, function() { - throw $injectorMinErr("unpr", "Unknown provider: {0}", path.join(" <- ")); - }), instanceCache = {}, instanceInjector = instanceCache.$injector = createInternalInjector(instanceCache, function(servicename) { - var provider = providerInjector.get(servicename + providerSuffix); - return instanceInjector.invoke(provider.$get, provider); - }); - forEach(loadModules(modulesToLoad), function(fn) { - instanceInjector.invoke(fn || noop); - }); - return instanceInjector; - function supportObject(delegate) { - return function(key, value) { - if (isObject(key)) { - forEach(key, reverseParams(delegate)); - } else { - return delegate(key, value); - } - }; - } - function provider(name, provider_) { - assertNotHasOwnProperty(name, "service"); - if (isFunction(provider_) || isArray(provider_)) { - provider_ = providerInjector.instantiate(provider_); - } - if (!provider_.$get) { - throw $injectorMinErr("pget", "Provider '{0}' must define $get factory method.", name); - } - return providerCache[name + providerSuffix] = provider_; - } - function factory(name, factoryFn) { - return provider(name, { - "$get": factoryFn - }); - } - function service(name, constructor) { - return factory(name, [ "$injector", function($injector) { - return $injector.instantiate(constructor); - } ]); - } - function value(name, val) { - return factory(name, valueFn(val)); - } - function constant(name, value) { - assertNotHasOwnProperty(name, "constant"); - providerCache[name] = value; - instanceCache[name] = value; - } - function decorator(serviceName, decorFn) { - var origProvider = providerInjector.get(serviceName + providerSuffix), orig$get = origProvider.$get; - origProvider.$get = function() { - var origInstance = instanceInjector.invoke(orig$get, origProvider); - return instanceInjector.invoke(decorFn, null, { - "$delegate": origInstance - }); - }; - } - function loadModules(modulesToLoad) { - var runBlocks = [], moduleFn, invokeQueue, i, ii; - forEach(modulesToLoad, function(module) { - if (loadedModules.get(module)) return; - loadedModules.put(module, true); - try { - if (isString(module)) { - moduleFn = angularModule(module); - runBlocks = runBlocks.concat(loadModules(moduleFn.requires)).concat(moduleFn._runBlocks); - for (invokeQueue = moduleFn._invokeQueue, i = 0, ii = invokeQueue.length; i < ii; i++) { - var invokeArgs = invokeQueue[i], provider = providerInjector.get(invokeArgs[0]); - provider[invokeArgs[1]].apply(provider, invokeArgs[2]); - } - } else if (isFunction(module)) { - runBlocks.push(providerInjector.invoke(module)); - } else if (isArray(module)) { - runBlocks.push(providerInjector.invoke(module)); - } else { - assertArgFn(module, "module"); - } - } catch (e) { - if (isArray(module)) { - module = module[module.length - 1]; - } - if (e.message && e.stack && e.stack.indexOf(e.message) == -1) { - e = e.message + "\n" + e.stack; - } - throw $injectorMinErr("modulerr", "Failed to instantiate module {0} due to:\n{1}", module, e.stack || e.message || e); - } - }); - return runBlocks; - } - function createInternalInjector(cache, factory) { - function getService(serviceName) { - if (cache.hasOwnProperty(serviceName)) { - if (cache[serviceName] === INSTANTIATING) { - throw $injectorMinErr("cdep", "Circular dependency found: {0}", serviceName + " <- " + path.join(" <- ")); - } - return cache[serviceName]; - } else { - try { - path.unshift(serviceName); - cache[serviceName] = INSTANTIATING; - return cache[serviceName] = factory(serviceName); - } catch (err) { - if (cache[serviceName] === INSTANTIATING) { - delete cache[serviceName]; - } - throw err; - } finally { - path.shift(); - } - } - } - function invoke(fn, self, locals) { - var args = [], $inject = annotate(fn), length, i, key; - for (i = 0, length = $inject.length; i < length; i++) { - key = $inject[i]; - if (typeof key !== "string") { - throw $injectorMinErr("itkn", "Incorrect injection token! Expected service name as string, got {0}", key); - } - args.push(locals && locals.hasOwnProperty(key) ? locals[key] : getService(key)); - } - if (isArray(fn)) { - fn = fn[length]; - } - return fn.apply(self, args); - } - function instantiate(Type, locals) { - var Constructor = function() {}, instance, returnedValue; - Constructor.prototype = (isArray(Type) ? Type[Type.length - 1] : Type).prototype; - instance = new Constructor(); - returnedValue = invoke(Type, instance, locals); - return isObject(returnedValue) || isFunction(returnedValue) ? returnedValue : instance; - } - return { - "invoke": invoke, - "instantiate": instantiate, - "get": getService, - "annotate": annotate, - "has": function(name) { - return providerCache.hasOwnProperty(name + providerSuffix) || cache.hasOwnProperty(name); - } - }; - } - } - function $AnchorScrollProvider() { - var autoScrollingEnabled = true; - this.disableAutoScrolling = function() { - autoScrollingEnabled = false; - }; - this.$get = [ "$window", "$location", "$rootScope", function($window, $location, $rootScope) { - var document = $window.document; - function getFirstAnchor(list) { - var result = null; - forEach(list, function(element) { - if (!result && lowercase(element.nodeName) === "a") result = element; - }); - return result; - } - function scroll() { - var hash = $location.hash(), elm; - if (!hash) $window.scrollTo(0, 0); else if (elm = document.getElementById(hash)) elm.scrollIntoView(); else if (elm = getFirstAnchor(document.getElementsByName(hash))) elm.scrollIntoView(); else if (hash === "top") $window.scrollTo(0, 0); - } - if (autoScrollingEnabled) { - $rootScope.$watch(function autoScrollWatch() { - return $location.hash(); - }, function autoScrollWatchAction() { - $rootScope.$evalAsync(scroll); - }); - } - return scroll; - } ]; - } - var $animateMinErr = minErr("$animate"); - var $AnimateProvider = [ "$provide", function($provide) { - this.$$selectors = {}; - this.register = function(name, factory) { - var key = name + "-animation"; - if (name && name.charAt(0) != ".") throw $animateMinErr("notcsel", "Expecting class selector starting with '.' got '{0}'.", name); - this.$$selectors[name.substr(1)] = key; - $provide.factory(key, factory); - }; - this.classNameFilter = function(expression) { - if (arguments.length === 1) { - this.$$classNameFilter = expression instanceof RegExp ? expression : null; - } - return this.$$classNameFilter; - }; - this.$get = [ "$timeout", "$$asyncCallback", function($timeout, $$asyncCallback) { - function async(fn) { - fn && $$asyncCallback(fn); - } - return { - "enter": function(element, parent, after, done) { - if (after) { - after.after(element); - } else { - if (!parent || !parent[0]) { - parent = after.parent(); - } - parent.append(element); - } - async(done); - }, - "leave": function(element, done) { - element.remove(); - async(done); - }, - "move": function(element, parent, after, done) { - this.enter(element, parent, after, done); - }, - "addClass": function(element, className, done) { - className = isString(className) ? className : isArray(className) ? className.join(" ") : ""; - forEach(element, function(element) { - jqLiteAddClass(element, className); - }); - async(done); - }, - "removeClass": function(element, className, done) { - className = isString(className) ? className : isArray(className) ? className.join(" ") : ""; - forEach(element, function(element) { - jqLiteRemoveClass(element, className); - }); - async(done); - }, - "setClass": function(element, add, remove, done) { - forEach(element, function(element) { - jqLiteAddClass(element, add); - jqLiteRemoveClass(element, remove); - }); - async(done); - }, - "enabled": noop - }; - } ]; - } ]; - function $$AsyncCallbackProvider() { - this.$get = [ "$$rAF", "$timeout", function($$rAF, $timeout) { - return $$rAF.supported ? function(fn) { - return $$rAF(fn); - } : function(fn) { - return $timeout(fn, 0, false); - }; - } ]; - } - function Browser(window, document, $log, $sniffer) { - var self = this, rawDocument = document[0], location = window.location, history = window.history, setTimeout = window.setTimeout, clearTimeout = window.clearTimeout, pendingDeferIds = {}; - self.isMock = false; - var outstandingRequestCount = 0; - var outstandingRequestCallbacks = []; - self.$$completeOutstandingRequest = completeOutstandingRequest; - self.$$incOutstandingRequestCount = function() { - outstandingRequestCount++; - }; - function completeOutstandingRequest(fn) { - try { - fn.apply(null, sliceArgs(arguments, 1)); - } finally { - outstandingRequestCount--; - if (outstandingRequestCount === 0) { - while (outstandingRequestCallbacks.length) { - try { - outstandingRequestCallbacks.pop()(); - } catch (e) { - $log.error(e); - } - } - } - } - } - self.notifyWhenNoOutstandingRequests = function(callback) { - forEach(pollFns, function(pollFn) { - pollFn(); - }); - if (outstandingRequestCount === 0) { - callback(); - } else { - outstandingRequestCallbacks.push(callback); - } - }; - var pollFns = [], pollTimeout; - self.addPollFn = function(fn) { - if (isUndefined(pollTimeout)) startPoller(100, setTimeout); - pollFns.push(fn); - return fn; - }; - function startPoller(interval, setTimeout) { - (function check() { - forEach(pollFns, function(pollFn) { - pollFn(); - }); - pollTimeout = setTimeout(check, interval); - })(); - } - var lastBrowserUrl = location.href, baseElement = document.find("base"), newLocation = null; - self.url = function(url, replace) { - if (location !== window.location) location = window.location; - if (history !== window.history) history = window.history; - if (url) { - if (lastBrowserUrl == url) return; - lastBrowserUrl = url; - if ($sniffer.history) { - if (replace) history.replaceState(null, "", url); else { - history.pushState(null, "", url); - baseElement.attr("href", baseElement.attr("href")); - } - } else { - newLocation = url; - if (replace) { - location.replace(url); - } else { - location.href = url; - } - } - return self; - } else { - return newLocation || location.href.replace(/%27/g, "'"); - } - }; - var urlChangeListeners = [], urlChangeInit = false; - function fireUrlChange() { - newLocation = null; - if (lastBrowserUrl == self.url()) return; - lastBrowserUrl = self.url(); - forEach(urlChangeListeners, function(listener) { - listener(self.url()); - }); - } - self.onUrlChange = function(callback) { - if (!urlChangeInit) { - if ($sniffer.history) jqLite(window).on("popstate", fireUrlChange); - if ($sniffer.hashchange) jqLite(window).on("hashchange", fireUrlChange); else self.addPollFn(fireUrlChange); - urlChangeInit = true; - } - urlChangeListeners.push(callback); - return callback; - }; - self.baseHref = function() { - var href = baseElement.attr("href"); - return href ? href.replace(/^(https?\:)?\/\/[^\/]*/, "") : ""; - }; - var lastCookies = {}; - var lastCookieString = ""; - var cookiePath = self.baseHref(); - self.cookies = function(name, value) { - var cookieLength, cookieArray, cookie, i, index; - if (name) { - if (value === undefined) { - rawDocument.cookie = escape(name) + "=;path=" + cookiePath + ";expires=Thu, 01 Jan 1970 00:00:00 GMT"; - } else { - if (isString(value)) { - cookieLength = (rawDocument.cookie = escape(name) + "=" + escape(value) + ";path=" + cookiePath).length + 1; - if (cookieLength > 4096) { - $log.warn("Cookie '" + name + "' possibly not set or overflowed because it was too large (" + cookieLength + " > 4096 bytes)!"); - } - } - } - } else { - if (rawDocument.cookie !== lastCookieString) { - lastCookieString = rawDocument.cookie; - cookieArray = lastCookieString.split("; "); - lastCookies = {}; - for (i = 0; i < cookieArray.length; i++) { - cookie = cookieArray[i]; - index = cookie.indexOf("="); - if (index > 0) { - name = unescape(cookie.substring(0, index)); - if (lastCookies[name] === undefined) { - lastCookies[name] = unescape(cookie.substring(index + 1)); - } - } - } - } - return lastCookies; - } - }; - self.defer = function(fn, delay) { - var timeoutId; - outstandingRequestCount++; - timeoutId = setTimeout(function() { - delete pendingDeferIds[timeoutId]; - completeOutstandingRequest(fn); - }, delay || 0); - pendingDeferIds[timeoutId] = true; - return timeoutId; - }; - self.defer.cancel = function(deferId) { - if (pendingDeferIds[deferId]) { - delete pendingDeferIds[deferId]; - clearTimeout(deferId); - completeOutstandingRequest(noop); - return true; - } - return false; - }; - } - function $BrowserProvider() { - this.$get = [ "$window", "$log", "$sniffer", "$document", function($window, $log, $sniffer, $document) { - return new Browser($window, $document, $log, $sniffer); - } ]; - } - function $CacheFactoryProvider() { - this.$get = function() { - var caches = {}; - function cacheFactory(cacheId, options) { - if (cacheId in caches) { - throw minErr("$cacheFactory")("iid", "CacheId '{0}' is already taken!", cacheId); - } - var size = 0, stats = extend({}, options, { - "id": cacheId - }), data = {}, capacity = options && options.capacity || Number.MAX_VALUE, lruHash = {}, freshEnd = null, staleEnd = null; - return caches[cacheId] = { - "put": function(key, value) { - if (capacity < Number.MAX_VALUE) { - var lruEntry = lruHash[key] || (lruHash[key] = { - "key": key - }); - refresh(lruEntry); - } - if (isUndefined(value)) return; - if (!(key in data)) size++; - data[key] = value; - if (size > capacity) { - this.remove(staleEnd.key); - } - return value; - }, - "get": function(key) { - if (capacity < Number.MAX_VALUE) { - var lruEntry = lruHash[key]; - if (!lruEntry) return; - refresh(lruEntry); - } - return data[key]; - }, - "remove": function(key) { - if (capacity < Number.MAX_VALUE) { - var lruEntry = lruHash[key]; - if (!lruEntry) return; - if (lruEntry == freshEnd) freshEnd = lruEntry.p; - if (lruEntry == staleEnd) staleEnd = lruEntry.n; - link(lruEntry.n, lruEntry.p); - delete lruHash[key]; - } - delete data[key]; - size--; - }, - "removeAll": function() { - data = {}; - size = 0; - lruHash = {}; - freshEnd = staleEnd = null; - }, - "destroy": function() { - data = null; - stats = null; - lruHash = null; - delete caches[cacheId]; - }, - "info": function() { - return extend({}, stats, { - "size": size - }); - } - }; - function refresh(entry) { - if (entry != freshEnd) { - if (!staleEnd) { - staleEnd = entry; - } else if (staleEnd == entry) { - staleEnd = entry.n; - } - link(entry.n, entry.p); - link(entry, freshEnd); - freshEnd = entry; - freshEnd.n = null; - } - } - function link(nextEntry, prevEntry) { - if (nextEntry != prevEntry) { - if (nextEntry) nextEntry.p = prevEntry; - if (prevEntry) prevEntry.n = nextEntry; - } - } - } - cacheFactory.info = function() { - var info = {}; - forEach(caches, function(cache, cacheId) { - info[cacheId] = cache.info(); - }); - return info; - }; - cacheFactory.get = function(cacheId) { - return caches[cacheId]; - }; - return cacheFactory; - }; - } - function $TemplateCacheProvider() { - this.$get = [ "$cacheFactory", function($cacheFactory) { - return $cacheFactory("templates"); - } ]; - } - var $compileMinErr = minErr("$compile"); - $CompileProvider.$inject = [ "$provide", "$$sanitizeUriProvider" ]; - function $CompileProvider($provide, $$sanitizeUriProvider) { - var hasDirectives = {}, Suffix = "Directive", COMMENT_DIRECTIVE_REGEXP = /^\s*directive\:\s*([\d\w_\-]+)\s+(.*)$/, CLASS_DIRECTIVE_REGEXP = /(([\d\w_\-]+)(?:\:([^;]+))?;?)/; - var EVENT_HANDLER_ATTR_REGEXP = /^(on[a-z]+|formaction)$/; - this.directive = function registerDirective(name, directiveFactory) { - assertNotHasOwnProperty(name, "directive"); - if (isString(name)) { - assertArg(directiveFactory, "directiveFactory"); - if (!hasDirectives.hasOwnProperty(name)) { - hasDirectives[name] = []; - $provide.factory(name + Suffix, [ "$injector", "$exceptionHandler", function($injector, $exceptionHandler) { - var directives = []; - forEach(hasDirectives[name], function(directiveFactory, index) { - try { - var directive = $injector.invoke(directiveFactory); - if (isFunction(directive)) { - directive = { - "compile": valueFn(directive) - }; - } else if (!directive.compile && directive.link) { - directive.compile = valueFn(directive.link); - } - directive.priority = directive.priority || 0; - directive.index = index; - directive.name = directive.name || name; - directive.require = directive.require || directive.controller && directive.name; - directive.restrict = directive.restrict || "A"; - directives.push(directive); - } catch (e) { - $exceptionHandler(e); - } - }); - return directives; - } ]); - } - hasDirectives[name].push(directiveFactory); - } else { - forEach(name, reverseParams(registerDirective)); - } - return this; - }; - this.aHrefSanitizationWhitelist = function(regexp) { - if (isDefined(regexp)) { - $$sanitizeUriProvider.aHrefSanitizationWhitelist(regexp); - return this; - } else { - return $$sanitizeUriProvider.aHrefSanitizationWhitelist(); - } - }; - this.imgSrcSanitizationWhitelist = function(regexp) { - if (isDefined(regexp)) { - $$sanitizeUriProvider.imgSrcSanitizationWhitelist(regexp); - return this; - } else { - return $$sanitizeUriProvider.imgSrcSanitizationWhitelist(); - } - }; - this.$get = [ "$injector", "$interpolate", "$exceptionHandler", "$http", "$templateCache", "$parse", "$controller", "$rootScope", "$document", "$sce", "$animate", "$$sanitizeUri", function($injector, $interpolate, $exceptionHandler, $http, $templateCache, $parse, $controller, $rootScope, $document, $sce, $animate, $$sanitizeUri) { - var Attributes = function(element, attr) { - this.$$element = element; - this.$attr = attr || {}; - }; - Attributes.prototype = { - "$normalize": directiveNormalize, - "$addClass": function(classVal) { - if (classVal && classVal.length > 0) { - $animate.addClass(this.$$element, classVal); - } - }, - "$removeClass": function(classVal) { - if (classVal && classVal.length > 0) { - $animate.removeClass(this.$$element, classVal); - } - }, - "$updateClass": function(newClasses, oldClasses) { - var toAdd = tokenDifference(newClasses, oldClasses); - var toRemove = tokenDifference(oldClasses, newClasses); - if (toAdd.length === 0) { - $animate.removeClass(this.$$element, toRemove); - } else if (toRemove.length === 0) { - $animate.addClass(this.$$element, toAdd); - } else { - $animate.setClass(this.$$element, toAdd, toRemove); - } - }, - "$set": function(key, value, writeAttr, attrName) { - var booleanKey = getBooleanAttrName(this.$$element[0], key), normalizedVal, nodeName; - if (booleanKey) { - this.$$element.prop(key, value); - attrName = booleanKey; - } - this[key] = value; - if (attrName) { - this.$attr[key] = attrName; - } else { - attrName = this.$attr[key]; - if (!attrName) { - this.$attr[key] = attrName = snake_case(key, "-"); - } - } - nodeName = nodeName_(this.$$element); - if (nodeName === "A" && key === "href" || nodeName === "IMG" && key === "src") { - this[key] = value = $$sanitizeUri(value, key === "src"); - } - if (writeAttr !== false) { - if (value === null || value === undefined) { - this.$$element.removeAttr(attrName); - } else { - this.$$element.attr(attrName, value); - } - } - var $$observers = this.$$observers; - $$observers && forEach($$observers[key], function(fn) { - try { - fn(value); - } catch (e) { - $exceptionHandler(e); - } - }); - }, - "$observe": function(key, fn) { - var attrs = this, $$observers = attrs.$$observers || (attrs.$$observers = {}), listeners = $$observers[key] || ($$observers[key] = []); - listeners.push(fn); - $rootScope.$evalAsync(function() { - if (!listeners.$$inter) { - fn(attrs[key]); - } - }); - return fn; - } - }; - var startSymbol = $interpolate.startSymbol(), endSymbol = $interpolate.endSymbol(), denormalizeTemplate = startSymbol == "{{" || endSymbol == "}}" ? identity : function denormalizeTemplate(template) { - return template.replace(/\{\{/g, startSymbol).replace(/}}/g, endSymbol); - }, NG_ATTR_BINDING = /^ngAttr[A-Z]/; - return compile; - function compile($compileNodes, transcludeFn, maxPriority, ignoreDirective, previousCompileContext) { - if (!($compileNodes instanceof jqLite)) { - $compileNodes = jqLite($compileNodes); - } - forEach($compileNodes, function(node, index) { - if (node.nodeType == 3 && node.nodeValue.match(/\S+/)) { - $compileNodes[index] = node = jqLite(node).wrap("").parent()[0]; - } - }); - var compositeLinkFn = compileNodes($compileNodes, transcludeFn, $compileNodes, maxPriority, ignoreDirective, previousCompileContext); - safeAddClass($compileNodes, "ng-scope"); - return function publicLinkFn(scope, cloneConnectFn, transcludeControllers, parentBoundTranscludeFn) { - assertArg(scope, "scope"); - var $linkNode = cloneConnectFn ? JQLitePrototype.clone.call($compileNodes) : $compileNodes; - forEach(transcludeControllers, function(instance, name) { - $linkNode.data("$" + name + "Controller", instance); - }); - for (var i = 0, ii = $linkNode.length; i < ii; i++) { - var node = $linkNode[i], nodeType = node.nodeType; - if (nodeType === 1 || nodeType === 9) { - $linkNode.eq(i).data("$scope", scope); - } - } - if (cloneConnectFn) cloneConnectFn($linkNode, scope); - if (compositeLinkFn) compositeLinkFn(scope, $linkNode, $linkNode, parentBoundTranscludeFn); - return $linkNode; - }; - } - function safeAddClass($element, className) { - try { - $element.addClass(className); - } catch (e) {} - } - function compileNodes(nodeList, transcludeFn, $rootElement, maxPriority, ignoreDirective, previousCompileContext) { - var linkFns = [], attrs, directives, nodeLinkFn, childNodes, childLinkFn, linkFnFound; - for (var i = 0; i < nodeList.length; i++) { - attrs = new Attributes(); - directives = collectDirectives(nodeList[i], [], attrs, i === 0 ? maxPriority : undefined, ignoreDirective); - nodeLinkFn = directives.length ? applyDirectivesToNode(directives, nodeList[i], attrs, transcludeFn, $rootElement, null, [], [], previousCompileContext) : null; - if (nodeLinkFn && nodeLinkFn.scope) { - safeAddClass(attrs.$$element, "ng-scope"); - } - childLinkFn = nodeLinkFn && nodeLinkFn.terminal || !(childNodes = nodeList[i].childNodes) || !childNodes.length ? null : compileNodes(childNodes, nodeLinkFn ? (nodeLinkFn.transcludeOnThisElement || !nodeLinkFn.templateOnThisElement) && nodeLinkFn.transclude : transcludeFn); - linkFns.push(nodeLinkFn, childLinkFn); - linkFnFound = linkFnFound || nodeLinkFn || childLinkFn; - previousCompileContext = null; - } - return linkFnFound ? compositeLinkFn : null; - function compositeLinkFn(scope, nodeList, $rootElement, parentBoundTranscludeFn) { - var nodeLinkFn, childLinkFn, node, childScope, i, ii, n, childBoundTranscludeFn; - var nodeListLength = nodeList.length, stableNodeList = new Array(nodeListLength); - for (i = 0; i < nodeListLength; i++) { - stableNodeList[i] = nodeList[i]; - } - for (i = 0, n = 0, ii = linkFns.length; i < ii; n++) { - node = stableNodeList[n]; - nodeLinkFn = linkFns[i++]; - childLinkFn = linkFns[i++]; - if (nodeLinkFn) { - if (nodeLinkFn.scope) { - childScope = scope.$new(); - jqLite.data(node, "$scope", childScope); - } else { - childScope = scope; - } - if (nodeLinkFn.transcludeOnThisElement) { - childBoundTranscludeFn = createBoundTranscludeFn(scope, nodeLinkFn.transclude, parentBoundTranscludeFn); - } else if (!nodeLinkFn.templateOnThisElement && parentBoundTranscludeFn) { - childBoundTranscludeFn = parentBoundTranscludeFn; - } else if (!parentBoundTranscludeFn && transcludeFn) { - childBoundTranscludeFn = createBoundTranscludeFn(scope, transcludeFn); - } else { - childBoundTranscludeFn = null; - } - nodeLinkFn(childLinkFn, childScope, node, $rootElement, childBoundTranscludeFn); - } else if (childLinkFn) { - childLinkFn(scope, node.childNodes, undefined, parentBoundTranscludeFn); - } - } - } - } - function createBoundTranscludeFn(scope, transcludeFn, previousBoundTranscludeFn) { - var boundTranscludeFn = function(transcludedScope, cloneFn, controllers) { - var scopeCreated = false; - if (!transcludedScope) { - transcludedScope = scope.$new(); - transcludedScope.$$transcluded = true; - scopeCreated = true; - } - var clone = transcludeFn(transcludedScope, cloneFn, controllers, previousBoundTranscludeFn); - if (scopeCreated) { - clone.on("$destroy", function() { - transcludedScope.$destroy(); - }); - } - return clone; - }; - return boundTranscludeFn; - } - function collectDirectives(node, directives, attrs, maxPriority, ignoreDirective) { - var nodeType = node.nodeType, attrsMap = attrs.$attr, match, className; - switch (nodeType) { - case 1: - addDirective(directives, directiveNormalize(nodeName_(node).toLowerCase()), "E", maxPriority, ignoreDirective); - for (var attr, name, nName, ngAttrName, value, isNgAttr, nAttrs = node.attributes, j = 0, jj = nAttrs && nAttrs.length; j < jj; j++) { - var attrStartName = false; - var attrEndName = false; - attr = nAttrs[j]; - if (!msie || msie >= 8 || attr.specified) { - name = attr.name; - value = trim(attr.value); - ngAttrName = directiveNormalize(name); - if (isNgAttr = NG_ATTR_BINDING.test(ngAttrName)) { - name = snake_case(ngAttrName.substr(6), "-"); - } - var directiveNName = ngAttrName.replace(/(Start|End)$/, ""); - if (ngAttrName === directiveNName + "Start") { - attrStartName = name; - attrEndName = name.substr(0, name.length - 5) + "end"; - name = name.substr(0, name.length - 6); - } - nName = directiveNormalize(name.toLowerCase()); - attrsMap[nName] = name; - if (isNgAttr || !attrs.hasOwnProperty(nName)) { - attrs[nName] = value; - if (getBooleanAttrName(node, nName)) { - attrs[nName] = true; - } - } - addAttrInterpolateDirective(node, directives, value, nName); - addDirective(directives, nName, "A", maxPriority, ignoreDirective, attrStartName, attrEndName); - } - } - className = node.className; - if (isString(className) && className !== "") { - while (match = CLASS_DIRECTIVE_REGEXP.exec(className)) { - nName = directiveNormalize(match[2]); - if (addDirective(directives, nName, "C", maxPriority, ignoreDirective)) { - attrs[nName] = trim(match[3]); - } - className = className.substr(match.index + match[0].length); - } - } - break; - - case 3: - addTextInterpolateDirective(directives, node.nodeValue); - break; - - case 8: - try { - match = COMMENT_DIRECTIVE_REGEXP.exec(node.nodeValue); - if (match) { - nName = directiveNormalize(match[1]); - if (addDirective(directives, nName, "M", maxPriority, ignoreDirective)) { - attrs[nName] = trim(match[2]); - } - } - } catch (e) {} - break; - } - directives.sort(byPriority); - return directives; - } - function groupScan(node, attrStart, attrEnd) { - var nodes = []; - var depth = 0; - if (attrStart && node.hasAttribute && node.hasAttribute(attrStart)) { - var startNode = node; - do { - if (!node) { - throw $compileMinErr("uterdir", "Unterminated attribute, found '{0}' but no matching '{1}' found.", attrStart, attrEnd); - } - if (node.nodeType == 1) { - if (node.hasAttribute(attrStart)) depth++; - if (node.hasAttribute(attrEnd)) depth--; - } - nodes.push(node); - node = node.nextSibling; - } while (depth > 0); - } else { - nodes.push(node); - } - return jqLite(nodes); - } - function groupElementsLinkFnWrapper(linkFn, attrStart, attrEnd) { - return function(scope, element, attrs, controllers, transcludeFn) { - element = groupScan(element[0], attrStart, attrEnd); - return linkFn(scope, element, attrs, controllers, transcludeFn); - }; - } - function applyDirectivesToNode(directives, compileNode, templateAttrs, transcludeFn, jqCollection, originalReplaceDirective, preLinkFns, postLinkFns, previousCompileContext) { - previousCompileContext = previousCompileContext || {}; - var terminalPriority = -Number.MAX_VALUE, newScopeDirective, controllerDirectives = previousCompileContext.controllerDirectives, newIsolateScopeDirective = previousCompileContext.newIsolateScopeDirective, templateDirective = previousCompileContext.templateDirective, nonTlbTranscludeDirective = previousCompileContext.nonTlbTranscludeDirective, hasTranscludeDirective = false, hasTemplate = false, hasElementTranscludeDirective = previousCompileContext.hasElementTranscludeDirective, $compileNode = templateAttrs.$$element = jqLite(compileNode), directive, directiveName, $template, replaceDirective = originalReplaceDirective, childTranscludeFn = transcludeFn, linkFn, directiveValue; - for (var i = 0, ii = directives.length; i < ii; i++) { - directive = directives[i]; - var attrStart = directive.$$start; - var attrEnd = directive.$$end; - if (attrStart) { - $compileNode = groupScan(compileNode, attrStart, attrEnd); - } - $template = undefined; - if (terminalPriority > directive.priority) { - break; - } - if (directiveValue = directive.scope) { - newScopeDirective = newScopeDirective || directive; - if (!directive.templateUrl) { - assertNoDuplicate("new/isolated scope", newIsolateScopeDirective, directive, $compileNode); - if (isObject(directiveValue)) { - newIsolateScopeDirective = directive; - } - } - } - directiveName = directive.name; - if (!directive.templateUrl && directive.controller) { - directiveValue = directive.controller; - controllerDirectives = controllerDirectives || {}; - assertNoDuplicate("'" + directiveName + "' controller", controllerDirectives[directiveName], directive, $compileNode); - controllerDirectives[directiveName] = directive; - } - if (directiveValue = directive.transclude) { - hasTranscludeDirective = true; - if (!directive.$$tlb) { - assertNoDuplicate("transclusion", nonTlbTranscludeDirective, directive, $compileNode); - nonTlbTranscludeDirective = directive; - } - if (directiveValue == "element") { - hasElementTranscludeDirective = true; - terminalPriority = directive.priority; - $template = $compileNode; - $compileNode = templateAttrs.$$element = jqLite(document.createComment(" " + directiveName + ": " + templateAttrs[directiveName] + " ")); - compileNode = $compileNode[0]; - replaceWith(jqCollection, sliceArgs($template), compileNode); - childTranscludeFn = compile($template, transcludeFn, terminalPriority, replaceDirective && replaceDirective.name, { - "nonTlbTranscludeDirective": nonTlbTranscludeDirective - }); - } else { - $template = jqLite(jqLiteClone(compileNode)).contents(); - $compileNode.empty(); - childTranscludeFn = compile($template, transcludeFn); - } - } - if (directive.template) { - hasTemplate = true; - assertNoDuplicate("template", templateDirective, directive, $compileNode); - templateDirective = directive; - directiveValue = isFunction(directive.template) ? directive.template($compileNode, templateAttrs) : directive.template; - directiveValue = denormalizeTemplate(directiveValue); - if (directive.replace) { - replaceDirective = directive; - if (jqLiteIsTextNode(directiveValue)) { - $template = []; - } else { - $template = jqLite(trim(directiveValue)); - } - compileNode = $template[0]; - if ($template.length != 1 || compileNode.nodeType !== 1) { - throw $compileMinErr("tplrt", "Template for directive '{0}' must have exactly one root element. {1}", directiveName, ""); - } - replaceWith(jqCollection, $compileNode, compileNode); - var newTemplateAttrs = { - "$attr": {} - }; - var templateDirectives = collectDirectives(compileNode, [], newTemplateAttrs); - var unprocessedDirectives = directives.splice(i + 1, directives.length - (i + 1)); - if (newIsolateScopeDirective) { - markDirectivesAsIsolate(templateDirectives); - } - directives = directives.concat(templateDirectives).concat(unprocessedDirectives); - mergeTemplateAttributes(templateAttrs, newTemplateAttrs); - ii = directives.length; - } else { - $compileNode.html(directiveValue); - } - } - if (directive.templateUrl) { - hasTemplate = true; - assertNoDuplicate("template", templateDirective, directive, $compileNode); - templateDirective = directive; - if (directive.replace) { - replaceDirective = directive; - } - nodeLinkFn = compileTemplateUrl(directives.splice(i, directives.length - i), $compileNode, templateAttrs, jqCollection, hasTranscludeDirective && childTranscludeFn, preLinkFns, postLinkFns, { - "controllerDirectives": controllerDirectives, - "newIsolateScopeDirective": newIsolateScopeDirective, - "templateDirective": templateDirective, - "nonTlbTranscludeDirective": nonTlbTranscludeDirective - }); - ii = directives.length; - } else if (directive.compile) { - try { - linkFn = directive.compile($compileNode, templateAttrs, childTranscludeFn); - if (isFunction(linkFn)) { - addLinkFns(null, linkFn, attrStart, attrEnd); - } else if (linkFn) { - addLinkFns(linkFn.pre, linkFn.post, attrStart, attrEnd); - } - } catch (e) { - $exceptionHandler(e, startingTag($compileNode)); - } - } - if (directive.terminal) { - nodeLinkFn.terminal = true; - terminalPriority = Math.max(terminalPriority, directive.priority); - } - } - nodeLinkFn.scope = newScopeDirective && newScopeDirective.scope === true; - nodeLinkFn.transcludeOnThisElement = hasTranscludeDirective; - nodeLinkFn.templateOnThisElement = hasTemplate; - nodeLinkFn.transclude = childTranscludeFn; - previousCompileContext.hasElementTranscludeDirective = hasElementTranscludeDirective; - return nodeLinkFn; - function addLinkFns(pre, post, attrStart, attrEnd) { - if (pre) { - if (attrStart) pre = groupElementsLinkFnWrapper(pre, attrStart, attrEnd); - pre.require = directive.require; - pre.directiveName = directiveName; - if (newIsolateScopeDirective === directive || directive.$$isolateScope) { - pre = cloneAndAnnotateFn(pre, { - "isolateScope": true - }); - } - preLinkFns.push(pre); - } - if (post) { - if (attrStart) post = groupElementsLinkFnWrapper(post, attrStart, attrEnd); - post.require = directive.require; - post.directiveName = directiveName; - if (newIsolateScopeDirective === directive || directive.$$isolateScope) { - post = cloneAndAnnotateFn(post, { - "isolateScope": true - }); - } - postLinkFns.push(post); - } - } - function getControllers(directiveName, require, $element, elementControllers) { - var value, retrievalMethod = "data", optional = false; - if (isString(require)) { - while ((value = require.charAt(0)) == "^" || value == "?") { - require = require.substr(1); - if (value == "^") { - retrievalMethod = "inheritedData"; - } - optional = optional || value == "?"; - } - value = null; - if (elementControllers && retrievalMethod === "data") { - value = elementControllers[require]; - } - value = value || $element[retrievalMethod]("$" + require + "Controller"); - if (!value && !optional) { - throw $compileMinErr("ctreq", "Controller '{0}', required by directive '{1}', can't be found!", require, directiveName); - } - return value; - } else if (isArray(require)) { - value = []; - forEach(require, function(require) { - value.push(getControllers(directiveName, require, $element, elementControllers)); - }); - } - return value; - } - function nodeLinkFn(childLinkFn, scope, linkNode, $rootElement, boundTranscludeFn) { - var attrs, $element, i, ii, linkFn, controller, isolateScope, elementControllers = {}, transcludeFn; - attrs = compileNode === linkNode ? templateAttrs : shallowCopy(templateAttrs, new Attributes(jqLite(linkNode), templateAttrs.$attr)); - $element = attrs.$$element; - if (newIsolateScopeDirective) { - var LOCAL_REGEXP = /^\s*([@=&])(\??)\s*(\w*)\s*$/; - isolateScope = scope.$new(true); - if (templateDirective && (templateDirective === newIsolateScopeDirective || templateDirective === newIsolateScopeDirective.$$originalDirective)) { - $element.data("$isolateScope", isolateScope); - } else { - $element.data("$isolateScopeNoTemplate", isolateScope); - } - safeAddClass($element, "ng-isolate-scope"); - forEach(newIsolateScopeDirective.scope, function(definition, scopeName) { - var match = definition.match(LOCAL_REGEXP) || [], attrName = match[3] || scopeName, optional = match[2] == "?", mode = match[1], lastValue, parentGet, parentSet, compare; - isolateScope.$$isolateBindings[scopeName] = mode + attrName; - switch (mode) { - case "@": - attrs.$observe(attrName, function(value) { - isolateScope[scopeName] = value; - }); - attrs.$$observers[attrName].$$scope = scope; - if (attrs[attrName]) { - isolateScope[scopeName] = $interpolate(attrs[attrName])(scope); - } - break; - - case "=": - if (optional && !attrs[attrName]) { - return; - } - parentGet = $parse(attrs[attrName]); - if (parentGet.literal) { - compare = equals; - } else { - compare = function(a, b) { - return a === b || a !== a && b !== b; - }; - } - parentSet = parentGet.assign || function() { - lastValue = isolateScope[scopeName] = parentGet(scope); - throw $compileMinErr("nonassign", "Expression '{0}' used with directive '{1}' is non-assignable!", attrs[attrName], newIsolateScopeDirective.name); - }; - lastValue = isolateScope[scopeName] = parentGet(scope); - isolateScope.$watch(function parentValueWatch() { - var parentValue = parentGet(scope); - if (!compare(parentValue, isolateScope[scopeName])) { - if (!compare(parentValue, lastValue)) { - isolateScope[scopeName] = parentValue; - } else { - parentSet(scope, parentValue = isolateScope[scopeName]); - } - } - return lastValue = parentValue; - }, null, parentGet.literal); - break; - - case "&": - parentGet = $parse(attrs[attrName]); - isolateScope[scopeName] = function(locals) { - return parentGet(scope, locals); - }; - break; - - default: - throw $compileMinErr("iscp", "Invalid isolate scope definition for directive '{0}'." + " Definition: {... {1}: '{2}' ...}", newIsolateScopeDirective.name, scopeName, definition); - } - }); - } - transcludeFn = boundTranscludeFn && controllersBoundTransclude; - if (controllerDirectives) { - forEach(controllerDirectives, function(directive) { - var locals = { - "$scope": directive === newIsolateScopeDirective || directive.$$isolateScope ? isolateScope : scope, - "$element": $element, - "$attrs": attrs, - "$transclude": transcludeFn - }, controllerInstance; - controller = directive.controller; - if (controller == "@") { - controller = attrs[directive.name]; - } - controllerInstance = $controller(controller, locals); - elementControllers[directive.name] = controllerInstance; - if (!hasElementTranscludeDirective) { - $element.data("$" + directive.name + "Controller", controllerInstance); - } - if (directive.controllerAs) { - locals.$scope[directive.controllerAs] = controllerInstance; - } - }); - } - for (i = 0, ii = preLinkFns.length; i < ii; i++) { - try { - linkFn = preLinkFns[i]; - linkFn(linkFn.isolateScope ? isolateScope : scope, $element, attrs, linkFn.require && getControllers(linkFn.directiveName, linkFn.require, $element, elementControllers), transcludeFn); - } catch (e) { - $exceptionHandler(e, startingTag($element)); - } - } - var scopeToChild = scope; - if (newIsolateScopeDirective && (newIsolateScopeDirective.template || newIsolateScopeDirective.templateUrl === null)) { - scopeToChild = isolateScope; - } - childLinkFn && childLinkFn(scopeToChild, linkNode.childNodes, undefined, boundTranscludeFn); - for (i = postLinkFns.length - 1; i >= 0; i--) { - try { - linkFn = postLinkFns[i]; - linkFn(linkFn.isolateScope ? isolateScope : scope, $element, attrs, linkFn.require && getControllers(linkFn.directiveName, linkFn.require, $element, elementControllers), transcludeFn); - } catch (e) { - $exceptionHandler(e, startingTag($element)); - } - } - function controllersBoundTransclude(scope, cloneAttachFn) { - var transcludeControllers; - if (arguments.length < 2) { - cloneAttachFn = scope; - scope = undefined; - } - if (hasElementTranscludeDirective) { - transcludeControllers = elementControllers; - } - return boundTranscludeFn(scope, cloneAttachFn, transcludeControllers); - } - } - } - function markDirectivesAsIsolate(directives) { - for (var j = 0, jj = directives.length; j < jj; j++) { - directives[j] = inherit(directives[j], { - "$$isolateScope": true - }); - } - } - function addDirective(tDirectives, name, location, maxPriority, ignoreDirective, startAttrName, endAttrName) { - if (name === ignoreDirective) return null; - var match = null; - if (hasDirectives.hasOwnProperty(name)) { - for (var directive, directives = $injector.get(name + Suffix), i = 0, ii = directives.length; i < ii; i++) { - try { - directive = directives[i]; - if ((maxPriority === undefined || maxPriority > directive.priority) && directive.restrict.indexOf(location) != -1) { - if (startAttrName) { - directive = inherit(directive, { - "$$start": startAttrName, - "$$end": endAttrName - }); - } - tDirectives.push(directive); - match = directive; - } - } catch (e) { - $exceptionHandler(e); - } - } - } - return match; - } - function mergeTemplateAttributes(dst, src) { - var srcAttr = src.$attr, dstAttr = dst.$attr, $element = dst.$$element; - forEach(dst, function(value, key) { - if (key.charAt(0) != "$") { - if (src[key] && src[key] !== value) { - value += (key === "style" ? ";" : " ") + src[key]; - } - dst.$set(key, value, true, srcAttr[key]); - } - }); - forEach(src, function(value, key) { - if (key == "class") { - safeAddClass($element, value); - dst["class"] = (dst["class"] ? dst["class"] + " " : "") + value; - } else if (key == "style") { - $element.attr("style", $element.attr("style") + ";" + value); - dst["style"] = (dst["style"] ? dst["style"] + ";" : "") + value; - } else if (key.charAt(0) != "$" && !dst.hasOwnProperty(key)) { - dst[key] = value; - dstAttr[key] = srcAttr[key]; - } - }); - } - function compileTemplateUrl(directives, $compileNode, tAttrs, $rootElement, childTranscludeFn, preLinkFns, postLinkFns, previousCompileContext) { - var linkQueue = [], afterTemplateNodeLinkFn, afterTemplateChildLinkFn, beforeTemplateCompileNode = $compileNode[0], origAsyncDirective = directives.shift(), derivedSyncDirective = extend({}, origAsyncDirective, { - "templateUrl": null, - "transclude": null, - "replace": null, - "$$originalDirective": origAsyncDirective - }), templateUrl = isFunction(origAsyncDirective.templateUrl) ? origAsyncDirective.templateUrl($compileNode, tAttrs) : origAsyncDirective.templateUrl; - $compileNode.empty(); - $http.get($sce.getTrustedResourceUrl(templateUrl), { - "cache": $templateCache - }).success(function(content) { - var compileNode, tempTemplateAttrs, $template, childBoundTranscludeFn; - content = denormalizeTemplate(content); - if (origAsyncDirective.replace) { - if (jqLiteIsTextNode(content)) { - $template = []; - } else { - $template = jqLite(trim(content)); - } - compileNode = $template[0]; - if ($template.length != 1 || compileNode.nodeType !== 1) { - throw $compileMinErr("tplrt", "Template for directive '{0}' must have exactly one root element. {1}", origAsyncDirective.name, templateUrl); - } - tempTemplateAttrs = { - "$attr": {} - }; - replaceWith($rootElement, $compileNode, compileNode); - var templateDirectives = collectDirectives(compileNode, [], tempTemplateAttrs); - if (isObject(origAsyncDirective.scope)) { - markDirectivesAsIsolate(templateDirectives); - } - directives = templateDirectives.concat(directives); - mergeTemplateAttributes(tAttrs, tempTemplateAttrs); - } else { - compileNode = beforeTemplateCompileNode; - $compileNode.html(content); - } - directives.unshift(derivedSyncDirective); - afterTemplateNodeLinkFn = applyDirectivesToNode(directives, compileNode, tAttrs, childTranscludeFn, $compileNode, origAsyncDirective, preLinkFns, postLinkFns, previousCompileContext); - forEach($rootElement, function(node, i) { - if (node == compileNode) { - $rootElement[i] = $compileNode[0]; - } - }); - afterTemplateChildLinkFn = compileNodes($compileNode[0].childNodes, childTranscludeFn); - while (linkQueue.length) { - var scope = linkQueue.shift(), beforeTemplateLinkNode = linkQueue.shift(), linkRootElement = linkQueue.shift(), boundTranscludeFn = linkQueue.shift(), linkNode = $compileNode[0]; - if (beforeTemplateLinkNode !== beforeTemplateCompileNode) { - var oldClasses = beforeTemplateLinkNode.className; - if (!(previousCompileContext.hasElementTranscludeDirective && origAsyncDirective.replace)) { - linkNode = jqLiteClone(compileNode); - } - replaceWith(linkRootElement, jqLite(beforeTemplateLinkNode), linkNode); - safeAddClass(jqLite(linkNode), oldClasses); - } - if (afterTemplateNodeLinkFn.transcludeOnThisElement) { - childBoundTranscludeFn = createBoundTranscludeFn(scope, afterTemplateNodeLinkFn.transclude, boundTranscludeFn); - } else { - childBoundTranscludeFn = boundTranscludeFn; - } - afterTemplateNodeLinkFn(afterTemplateChildLinkFn, scope, linkNode, $rootElement, childBoundTranscludeFn); - } - linkQueue = null; - }).error(function(response, code, headers, config) { - throw $compileMinErr("tpload", "Failed to load template: {0}", config.url); - }); - return function delayedNodeLinkFn(ignoreChildLinkFn, scope, node, rootElement, boundTranscludeFn) { - var childBoundTranscludeFn = boundTranscludeFn; - if (linkQueue) { - linkQueue.push(scope); - linkQueue.push(node); - linkQueue.push(rootElement); - linkQueue.push(childBoundTranscludeFn); - } else { - if (afterTemplateNodeLinkFn.transcludeOnThisElement) { - childBoundTranscludeFn = createBoundTranscludeFn(scope, afterTemplateNodeLinkFn.transclude, boundTranscludeFn); - } - afterTemplateNodeLinkFn(afterTemplateChildLinkFn, scope, node, rootElement, childBoundTranscludeFn); - } - }; - } - function byPriority(a, b) { - var diff = b.priority - a.priority; - if (diff !== 0) return diff; - if (a.name !== b.name) return a.name < b.name ? -1 : 1; - return a.index - b.index; - } - function assertNoDuplicate(what, previousDirective, directive, element) { - if (previousDirective) { - throw $compileMinErr("multidir", "Multiple directives [{0}, {1}] asking for {2} on: {3}", previousDirective.name, directive.name, what, startingTag(element)); - } - } - function addTextInterpolateDirective(directives, text) { - var interpolateFn = $interpolate(text, true); - if (interpolateFn) { - directives.push({ - "priority": 0, - "compile": function textInterpolateCompileFn(templateNode) { - var parent = templateNode.parent(), hasCompileParent = parent.length; - if (hasCompileParent) safeAddClass(templateNode.parent(), "ng-binding"); - return function textInterpolateLinkFn(scope, node) { - var parent = node.parent(), bindings = parent.data("$binding") || []; - bindings.push(interpolateFn); - parent.data("$binding", bindings); - if (!hasCompileParent) safeAddClass(parent, "ng-binding"); - scope.$watch(interpolateFn, function interpolateFnWatchAction(value) { - node[0].nodeValue = value; - }); - }; - } - }); - } - } - function getTrustedContext(node, attrNormalizedName) { - if (attrNormalizedName == "srcdoc") { - return $sce.HTML; - } - var tag = nodeName_(node); - if (attrNormalizedName == "xlinkHref" || tag == "FORM" && attrNormalizedName == "action" || tag != "IMG" && (attrNormalizedName == "src" || attrNormalizedName == "ngSrc")) { - return $sce.RESOURCE_URL; - } - } - function addAttrInterpolateDirective(node, directives, value, name) { - var interpolateFn = $interpolate(value, true); - if (!interpolateFn) return; - if (name === "multiple" && nodeName_(node) === "SELECT") { - throw $compileMinErr("selmulti", "Binding to the 'multiple' attribute is not supported. Element: {0}", startingTag(node)); - } - directives.push({ - "priority": 100, - "compile": function() { - return { - "pre": function attrInterpolatePreLinkFn(scope, element, attr) { - var $$observers = attr.$$observers || (attr.$$observers = {}); - if (EVENT_HANDLER_ATTR_REGEXP.test(name)) { - throw $compileMinErr("nodomevents", "Interpolations for HTML DOM event attributes are disallowed. Please use the " + "ng- versions (such as ng-click instead of onclick) instead."); - } - interpolateFn = $interpolate(attr[name], true, getTrustedContext(node, name)); - if (!interpolateFn) return; - attr[name] = interpolateFn(scope); - ($$observers[name] || ($$observers[name] = [])).$$inter = true; - (attr.$$observers && attr.$$observers[name].$$scope || scope).$watch(interpolateFn, function interpolateFnWatchAction(newValue, oldValue) { - if (name === "class" && newValue != oldValue) { - attr.$updateClass(newValue, oldValue); - } else { - attr.$set(name, newValue); - } - }); - } - }; - } - }); - } - function replaceWith($rootElement, elementsToRemove, newNode) { - var firstElementToRemove = elementsToRemove[0], removeCount = elementsToRemove.length, parent = firstElementToRemove.parentNode, i, ii; - if ($rootElement) { - for (i = 0, ii = $rootElement.length; i < ii; i++) { - if ($rootElement[i] == firstElementToRemove) { - $rootElement[i++] = newNode; - for (var j = i, j2 = j + removeCount - 1, jj = $rootElement.length; j < jj; j++, - j2++) { - if (j2 < jj) { - $rootElement[j] = $rootElement[j2]; - } else { - delete $rootElement[j]; - } - } - $rootElement.length -= removeCount - 1; - break; - } - } - } - if (parent) { - parent.replaceChild(newNode, firstElementToRemove); - } - var fragment = document.createDocumentFragment(); - fragment.appendChild(firstElementToRemove); - newNode[jqLite.expando] = firstElementToRemove[jqLite.expando]; - for (var k = 1, kk = elementsToRemove.length; k < kk; k++) { - var element = elementsToRemove[k]; - jqLite(element).remove(); - fragment.appendChild(element); - delete elementsToRemove[k]; - } - elementsToRemove[0] = newNode; - elementsToRemove.length = 1; - } - function cloneAndAnnotateFn(fn, annotation) { - return extend(function() { - return fn.apply(null, arguments); - }, fn, annotation); - } - } ]; - } - var PREFIX_REGEXP = /^(x[\:\-_]|data[\:\-_])/i; - function directiveNormalize(name) { - return camelCase(name.replace(PREFIX_REGEXP, "")); - } - function nodesetLinkingFn(scope, nodeList, rootElement, boundTranscludeFn) {} - function directiveLinkingFn(nodesetLinkingFn, scope, node, rootElement, boundTranscludeFn) {} - function tokenDifference(str1, str2) { - var values = "", tokens1 = str1.split(/\s+/), tokens2 = str2.split(/\s+/); - outer: for (var i = 0; i < tokens1.length; i++) { - var token = tokens1[i]; - for (var j = 0; j < tokens2.length; j++) { - if (token == tokens2[j]) continue outer; - } - values += (values.length > 0 ? " " : "") + token; - } - return values; - } - function $ControllerProvider() { - var controllers = {}, CNTRL_REG = /^(\S+)(\s+as\s+(\w+))?$/; - this.register = function(name, constructor) { - assertNotHasOwnProperty(name, "controller"); - if (isObject(name)) { - extend(controllers, name); - } else { - controllers[name] = constructor; - } - }; - this.$get = [ "$injector", "$window", function($injector, $window) { - return function(expression, locals) { - var instance, match, constructor, identifier; - if (isString(expression)) { - match = expression.match(CNTRL_REG), constructor = match[1], identifier = match[3]; - expression = controllers.hasOwnProperty(constructor) ? controllers[constructor] : getter(locals.$scope, constructor, true) || getter($window, constructor, true); - assertArgFn(expression, constructor, true); - } - instance = $injector.instantiate(expression, locals); - if (identifier) { - if (!(locals && typeof locals.$scope === "object")) { - throw minErr("$controller")("noscp", "Cannot export controller '{0}' as '{1}'! No $scope object provided via `locals`.", constructor || expression.name, identifier); - } - locals.$scope[identifier] = instance; - } - return instance; - }; - } ]; - } - function $DocumentProvider() { - this.$get = [ "$window", function(window) { - return jqLite(window.document); - } ]; - } - function $ExceptionHandlerProvider() { - this.$get = [ "$log", function($log) { - return function(exception, cause) { - $log.error.apply($log, arguments); - }; - } ]; - } - function parseHeaders(headers) { - var parsed = {}, key, val, i; - if (!headers) return parsed; - forEach(headers.split("\n"), function(line) { - i = line.indexOf(":"); - key = lowercase(trim(line.substr(0, i))); - val = trim(line.substr(i + 1)); - if (key) { - parsed[key] = parsed[key] ? parsed[key] + ", " + val : val; - } - }); - return parsed; - } - function headersGetter(headers) { - var headersObj = isObject(headers) ? headers : undefined; - return function(name) { - if (!headersObj) headersObj = parseHeaders(headers); - if (name) { - return headersObj[lowercase(name)] || null; - } - return headersObj; - }; - } - function transformData(data, headers, fns) { - if (isFunction(fns)) return fns(data, headers); - forEach(fns, function(fn) { - data = fn(data, headers); - }); - return data; - } - function isSuccess(status) { - return 200 <= status && status < 300; - } - function $HttpProvider() { - var JSON_START = /^\s*(\[|\{[^\{])/, JSON_END = /[\}\]]\s*$/, PROTECTION_PREFIX = /^\)\]\}',?\n/, CONTENT_TYPE_APPLICATION_JSON = { - "Content-Type": "application/json;charset=utf-8" - }; - var defaults = this.defaults = { - "transformResponse": [ function(data) { - if (isString(data)) { - data = data.replace(PROTECTION_PREFIX, ""); - if (JSON_START.test(data) && JSON_END.test(data)) data = fromJson(data); - } - return data; - } ], - "transformRequest": [ function(d) { - return isObject(d) && !isFile(d) && !isBlob(d) ? toJson(d) : d; - } ], - "headers": { - "common": { - "Accept": "application/json, text/plain, */*" - }, - "post": shallowCopy(CONTENT_TYPE_APPLICATION_JSON), - "put": shallowCopy(CONTENT_TYPE_APPLICATION_JSON), - "patch": shallowCopy(CONTENT_TYPE_APPLICATION_JSON) - }, - "xsrfCookieName": "XSRF-TOKEN", - "xsrfHeaderName": "X-XSRF-TOKEN" - }; - var interceptorFactories = this.interceptors = []; - var responseInterceptorFactories = this.responseInterceptors = []; - this.$get = [ "$httpBackend", "$browser", "$cacheFactory", "$rootScope", "$q", "$injector", function($httpBackend, $browser, $cacheFactory, $rootScope, $q, $injector) { - var defaultCache = $cacheFactory("$http"); - var reversedInterceptors = []; - forEach(interceptorFactories, function(interceptorFactory) { - reversedInterceptors.unshift(isString(interceptorFactory) ? $injector.get(interceptorFactory) : $injector.invoke(interceptorFactory)); - }); - forEach(responseInterceptorFactories, function(interceptorFactory, index) { - var responseFn = isString(interceptorFactory) ? $injector.get(interceptorFactory) : $injector.invoke(interceptorFactory); - reversedInterceptors.splice(index, 0, { - "response": function(response) { - return responseFn($q.when(response)); - }, - "responseError": function(response) { - return responseFn($q.reject(response)); - } - }); - }); - function $http(requestConfig) { - var config = { - "method": "get", - "transformRequest": defaults.transformRequest, - "transformResponse": defaults.transformResponse - }; - var headers = mergeHeaders(requestConfig); - extend(config, requestConfig); - config.headers = headers; - config.method = uppercase(config.method); - var serverRequest = function(config) { - headers = config.headers; - var reqData = transformData(config.data, headersGetter(headers), config.transformRequest); - if (isUndefined(reqData)) { - forEach(headers, function(value, header) { - if (lowercase(header) === "content-type") { - delete headers[header]; - } - }); - } - if (isUndefined(config.withCredentials) && !isUndefined(defaults.withCredentials)) { - config.withCredentials = defaults.withCredentials; - } - return sendReq(config, reqData, headers).then(transformResponse, transformResponse); - }; - var chain = [ serverRequest, undefined ]; - var promise = $q.when(config); - forEach(reversedInterceptors, function(interceptor) { - if (interceptor.request || interceptor.requestError) { - chain.unshift(interceptor.request, interceptor.requestError); - } - if (interceptor.response || interceptor.responseError) { - chain.push(interceptor.response, interceptor.responseError); - } - }); - while (chain.length) { - var thenFn = chain.shift(); - var rejectFn = chain.shift(); - promise = promise.then(thenFn, rejectFn); - } - promise.success = function(fn) { - promise.then(function(response) { - fn(response.data, response.status, response.headers, config); - }); - return promise; - }; - promise.error = function(fn) { - promise.then(null, function(response) { - fn(response.data, response.status, response.headers, config); - }); - return promise; - }; - return promise; - function transformResponse(response) { - var resp = extend({}, response, { - "data": transformData(response.data, response.headers, config.transformResponse) - }); - return isSuccess(response.status) ? resp : $q.reject(resp); - } - function mergeHeaders(config) { - var defHeaders = defaults.headers, reqHeaders = extend({}, config.headers), defHeaderName, lowercaseDefHeaderName, reqHeaderName; - defHeaders = extend({}, defHeaders.common, defHeaders[lowercase(config.method)]); - defaultHeadersIteration: for (defHeaderName in defHeaders) { - lowercaseDefHeaderName = lowercase(defHeaderName); - for (reqHeaderName in reqHeaders) { - if (lowercase(reqHeaderName) === lowercaseDefHeaderName) { - continue defaultHeadersIteration; - } - } - reqHeaders[defHeaderName] = defHeaders[defHeaderName]; - } - execHeaders(reqHeaders); - return reqHeaders; - function execHeaders(headers) { - var headerContent; - forEach(headers, function(headerFn, header) { - if (isFunction(headerFn)) { - headerContent = headerFn(); - if (headerContent != null) { - headers[header] = headerContent; - } else { - delete headers[header]; - } - } - }); - } - } - } - $http.pendingRequests = []; - createShortMethods("get", "delete", "head", "jsonp"); - createShortMethodsWithData("post", "put"); - $http.defaults = defaults; - return $http; - function createShortMethods(names) { - forEach(arguments, function(name) { - $http[name] = function(url, config) { - return $http(extend(config || {}, { - "method": name, - "url": url - })); - }; - }); - } - function createShortMethodsWithData(name) { - forEach(arguments, function(name) { - $http[name] = function(url, data, config) { - return $http(extend(config || {}, { - "method": name, - "url": url, - "data": data - })); - }; - }); - } - function sendReq(config, reqData, reqHeaders) { - var deferred = $q.defer(), promise = deferred.promise, cache, cachedResp, url = buildUrl(config.url, config.params); - $http.pendingRequests.push(config); - promise.then(removePendingReq, removePendingReq); - if ((config.cache || defaults.cache) && config.cache !== false && (config.method === "GET" || config.method === "JSONP")) { - cache = isObject(config.cache) ? config.cache : isObject(defaults.cache) ? defaults.cache : defaultCache; - } - if (cache) { - cachedResp = cache.get(url); - if (isDefined(cachedResp)) { - if (isPromiseLike(cachedResp)) { - cachedResp.then(removePendingReq, removePendingReq); - return cachedResp; - } else { - if (isArray(cachedResp)) { - resolvePromise(cachedResp[1], cachedResp[0], shallowCopy(cachedResp[2]), cachedResp[3]); - } else { - resolvePromise(cachedResp, 200, {}, "OK"); - } - } - } else { - cache.put(url, promise); - } - } - if (isUndefined(cachedResp)) { - var xsrfValue = urlIsSameOrigin(config.url) ? $browser.cookies()[config.xsrfCookieName || defaults.xsrfCookieName] : undefined; - if (xsrfValue) { - reqHeaders[config.xsrfHeaderName || defaults.xsrfHeaderName] = xsrfValue; - } - $httpBackend(config.method, url, reqData, done, reqHeaders, config.timeout, config.withCredentials, config.responseType); - } - return promise; - function done(status, response, headersString, statusText) { - if (cache) { - if (isSuccess(status)) { - cache.put(url, [ status, response, parseHeaders(headersString), statusText ]); - } else { - cache.remove(url); - } - } - resolvePromise(response, status, headersString, statusText); - if (!$rootScope.$$phase) $rootScope.$apply(); - } - function resolvePromise(response, status, headers, statusText) { - status = Math.max(status, 0); - (isSuccess(status) ? deferred.resolve : deferred.reject)({ - "data": response, - "status": status, - "headers": headersGetter(headers), - "config": config, - "statusText": statusText - }); - } - function removePendingReq() { - var idx = indexOf($http.pendingRequests, config); - if (idx !== -1) $http.pendingRequests.splice(idx, 1); - } - } - function buildUrl(url, params) { - if (!params) return url; - var parts = []; - forEachSorted(params, function(value, key) { - if (value === null || isUndefined(value)) return; - if (!isArray(value)) value = [ value ]; - forEach(value, function(v) { - if (isObject(v)) { - if (isDate(v)) { - v = v.toISOString(); - } else if (isObject(v)) { - v = toJson(v); - } - } - parts.push(encodeUriQuery(key) + "=" + encodeUriQuery(v)); - }); - }); - if (parts.length > 0) { - url += (url.indexOf("?") == -1 ? "?" : "&") + parts.join("&"); - } - return url; - } - } ]; - } - function createXhr(method) { - if (msie <= 8 && (!method.match(/^(get|post|head|put|delete|options)$/i) || !window.XMLHttpRequest)) { - return new window.ActiveXObject("Microsoft.XMLHTTP"); - } else if (window.XMLHttpRequest) { - return new window.XMLHttpRequest(); - } - throw minErr("$httpBackend")("noxhr", "This browser does not support XMLHttpRequest."); - } - function $HttpBackendProvider() { - this.$get = [ "$browser", "$window", "$document", function($browser, $window, $document) { - return createHttpBackend($browser, createXhr, $browser.defer, $window.angular.callbacks, $document[0]); - } ]; - } - function createHttpBackend($browser, createXhr, $browserDefer, callbacks, rawDocument) { - var ABORTED = -1; - return function(method, url, post, callback, headers, timeout, withCredentials, responseType) { - var status; - $browser.$$incOutstandingRequestCount(); - url = url || $browser.url(); - if (lowercase(method) == "jsonp") { - var callbackId = "_" + (callbacks.counter++).toString(36); - callbacks[callbackId] = function(data) { - callbacks[callbackId].data = data; - callbacks[callbackId].called = true; - }; - var jsonpDone = jsonpReq(url.replace("JSON_CALLBACK", "angular.callbacks." + callbackId), callbackId, function(status, text) { - completeRequest(callback, status, callbacks[callbackId].data, "", text); - callbacks[callbackId] = noop; - }); - } else { - var xhr = createXhr(method); - xhr.open(method, url, true); - forEach(headers, function(value, key) { - if (isDefined(value)) { - xhr.setRequestHeader(key, value); - } - }); - xhr.onreadystatechange = function() { - if (xhr && xhr.readyState == 4) { - var responseHeaders = null, response = null, statusText = ""; - if (status !== ABORTED) { - responseHeaders = xhr.getAllResponseHeaders(); - response = "response" in xhr ? xhr.response : xhr.responseText; - } - if (!(status === ABORTED && msie < 10)) { - statusText = xhr.statusText; - } - completeRequest(callback, status || xhr.status, response, responseHeaders, statusText); - } - }; - if (withCredentials) { - xhr.withCredentials = true; - } - if (responseType) { - try { - xhr.responseType = responseType; - } catch (e) { - if (responseType !== "json") { - throw e; - } - } - } - xhr.send(post || null); - } - if (timeout > 0) { - var timeoutId = $browserDefer(timeoutRequest, timeout); - } else if (isPromiseLike(timeout)) { - timeout.then(timeoutRequest); - } - function timeoutRequest() { - status = ABORTED; - jsonpDone && jsonpDone(); - xhr && xhr.abort(); - } - function completeRequest(callback, status, response, headersString, statusText) { - timeoutId && $browserDefer.cancel(timeoutId); - jsonpDone = xhr = null; - if (status === 0) { - status = response ? 200 : urlResolve(url).protocol == "file" ? 404 : 0; - } - status = status === 1223 ? 204 : status; - statusText = statusText || ""; - callback(status, response, headersString, statusText); - $browser.$$completeOutstandingRequest(noop); - } - }; - function jsonpReq(url, callbackId, done) { - var script = rawDocument.createElement("script"), callback = null; - script.type = "text/javascript"; - script.src = url; - script.async = true; - callback = function(event) { - removeEventListenerFn(script, "load", callback); - removeEventListenerFn(script, "error", callback); - rawDocument.body.removeChild(script); - script = null; - var status = -1; - var text = "unknown"; - if (event) { - if (event.type === "load" && !callbacks[callbackId].called) { - event = { - "type": "error" - }; - } - text = event.type; - status = event.type === "error" ? 404 : 200; - } - if (done) { - done(status, text); - } - }; - addEventListenerFn(script, "load", callback); - addEventListenerFn(script, "error", callback); - if (msie <= 8) { - script.onreadystatechange = function() { - if (isString(script.readyState) && /loaded|complete/.test(script.readyState)) { - script.onreadystatechange = null; - callback({ - "type": "load" - }); - } - }; - } - rawDocument.body.appendChild(script); - return callback; - } - } - var $interpolateMinErr = minErr("$interpolate"); - function $InterpolateProvider() { - var startSymbol = "{{"; - var endSymbol = "}}"; - this.startSymbol = function(value) { - if (value) { - startSymbol = value; - return this; - } else { - return startSymbol; - } - }; - this.endSymbol = function(value) { - if (value) { - endSymbol = value; - return this; - } else { - return endSymbol; - } - }; - this.$get = [ "$parse", "$exceptionHandler", "$sce", function($parse, $exceptionHandler, $sce) { - var startSymbolLength = startSymbol.length, endSymbolLength = endSymbol.length; - function $interpolate(text, mustHaveExpression, trustedContext) { - var startIndex, endIndex, index = 0, parts = [], length = text.length, hasInterpolation = false, fn, exp, concat = []; - while (index < length) { - if ((startIndex = text.indexOf(startSymbol, index)) != -1 && (endIndex = text.indexOf(endSymbol, startIndex + startSymbolLength)) != -1) { - index != startIndex && parts.push(text.substring(index, startIndex)); - parts.push(fn = $parse(exp = text.substring(startIndex + startSymbolLength, endIndex))); - fn.exp = exp; - index = endIndex + endSymbolLength; - hasInterpolation = true; - } else { - index != length && parts.push(text.substring(index)); - index = length; - } - } - if (!(length = parts.length)) { - parts.push(""); - length = 1; - } - if (trustedContext && parts.length > 1) { - throw $interpolateMinErr("noconcat", "Error while interpolating: {0}\nStrict Contextual Escaping disallows " + "interpolations that concatenate multiple expressions when a trusted value is " + "required. See http://docs.angularjs.org/api/ng.$sce", text); - } - if (!mustHaveExpression || hasInterpolation) { - concat.length = length; - fn = function(context) { - try { - for (var i = 0, ii = length, part; i < ii; i++) { - if (typeof (part = parts[i]) == "function") { - part = part(context); - if (trustedContext) { - part = $sce.getTrusted(trustedContext, part); - } else { - part = $sce.valueOf(part); - } - if (part == null) { - part = ""; - } else { - switch (typeof part) { - case "string": - { - break; - } - - case "number": - { - part = "" + part; - break; - } - - default: - { - part = toJson(part); - } - } - } - } - concat[i] = part; - } - return concat.join(""); - } catch (err) { - var newErr = $interpolateMinErr("interr", "Can't interpolate: {0}\n{1}", text, err.toString()); - $exceptionHandler(newErr); - } - }; - fn.exp = text; - fn.parts = parts; - return fn; - } - } - $interpolate.startSymbol = function() { - return startSymbol; - }; - $interpolate.endSymbol = function() { - return endSymbol; - }; - return $interpolate; - } ]; - } - function $IntervalProvider() { - this.$get = [ "$rootScope", "$window", "$q", function($rootScope, $window, $q) { - var intervals = {}; - function interval(fn, delay, count, invokeApply) { - var setInterval = $window.setInterval, clearInterval = $window.clearInterval, deferred = $q.defer(), promise = deferred.promise, iteration = 0, skipApply = isDefined(invokeApply) && !invokeApply; - count = isDefined(count) ? count : 0; - promise.then(null, null, fn); - promise.$$intervalId = setInterval(function tick() { - deferred.notify(iteration++); - if (count > 0 && iteration >= count) { - deferred.resolve(iteration); - clearInterval(promise.$$intervalId); - delete intervals[promise.$$intervalId]; - } - if (!skipApply) $rootScope.$apply(); - }, delay); - intervals[promise.$$intervalId] = deferred; - return promise; - } - interval.cancel = function(promise) { - if (promise && promise.$$intervalId in intervals) { - intervals[promise.$$intervalId].reject("canceled"); - $window.clearInterval(promise.$$intervalId); - delete intervals[promise.$$intervalId]; - return true; - } - return false; - }; - return interval; - } ]; - } - function $LocaleProvider() { - this.$get = function() { - return { - "id": "en-us", - "NUMBER_FORMATS": { - "DECIMAL_SEP": ".", - "GROUP_SEP": ",", - "PATTERNS": [ { - "minInt": 1, - "minFrac": 0, - "maxFrac": 3, - "posPre": "", - "posSuf": "", - "negPre": "-", - "negSuf": "", - "gSize": 3, - "lgSize": 3 - }, { - "minInt": 1, - "minFrac": 2, - "maxFrac": 2, - "posPre": "\xa4", - "posSuf": "", - "negPre": "(\xa4", - "negSuf": ")", - "gSize": 3, - "lgSize": 3 - } ], - "CURRENCY_SYM": "$" - }, - "DATETIME_FORMATS": { - "MONTH": "January,February,March,April,May,June,July,August,September,October,November,December".split(","), - "SHORTMONTH": "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","), - "DAY": "Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","), - "SHORTDAY": "Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(","), - "AMPMS": [ "AM", "PM" ], - "medium": "MMM d, y h:mm:ss a", - "short": "M/d/yy h:mm a", - "fullDate": "EEEE, MMMM d, y", - "longDate": "MMMM d, y", - "mediumDate": "MMM d, y", - "shortDate": "M/d/yy", - "mediumTime": "h:mm:ss a", - "shortTime": "h:mm a" - }, - "pluralCat": function(num) { - if (num === 1) { - return "one"; - } - return "other"; - } - }; - }; - } - var PATH_MATCH = /^([^\?#]*)(\?([^#]*))?(#(.*))?$/, DEFAULT_PORTS = { - "http": 80, - "https": 443, - "ftp": 21 - }; - var $locationMinErr = minErr("$location"); - function encodePath(path) { - var segments = path.split("/"), i = segments.length; - while (i--) { - segments[i] = encodeUriSegment(segments[i]); - } - return segments.join("/"); - } - function parseAbsoluteUrl(absoluteUrl, locationObj, appBase) { - var parsedUrl = urlResolve(absoluteUrl, appBase); - locationObj.$$protocol = parsedUrl.protocol; - locationObj.$$host = parsedUrl.hostname; - locationObj.$$port = int(parsedUrl.port) || DEFAULT_PORTS[parsedUrl.protocol] || null; - } - function parseAppUrl(relativeUrl, locationObj, appBase) { - var prefixed = relativeUrl.charAt(0) !== "/"; - if (prefixed) { - relativeUrl = "/" + relativeUrl; - } - var match = urlResolve(relativeUrl, appBase); - locationObj.$$path = decodeURIComponent(prefixed && match.pathname.charAt(0) === "/" ? match.pathname.substring(1) : match.pathname); - locationObj.$$search = parseKeyValue(match.search); - locationObj.$$hash = decodeURIComponent(match.hash); - if (locationObj.$$path && locationObj.$$path.charAt(0) != "/") { - locationObj.$$path = "/" + locationObj.$$path; - } - } - function beginsWith(begin, whole) { - if (whole.indexOf(begin) === 0) { - return whole.substr(begin.length); - } - } - function stripHash(url) { - var index = url.indexOf("#"); - return index == -1 ? url : url.substr(0, index); - } - function stripFile(url) { - return url.substr(0, stripHash(url).lastIndexOf("/") + 1); - } - function serverBase(url) { - return url.substring(0, url.indexOf("/", url.indexOf("//") + 2)); - } - function LocationHtml5Url(appBase, basePrefix) { - this.$$html5 = true; - basePrefix = basePrefix || ""; - var appBaseNoFile = stripFile(appBase); - parseAbsoluteUrl(appBase, this, appBase); - this.$$parse = function(url) { - var pathUrl = beginsWith(appBaseNoFile, url); - if (!isString(pathUrl)) { - throw $locationMinErr("ipthprfx", 'Invalid url "{0}", missing path prefix "{1}".', url, appBaseNoFile); - } - parseAppUrl(pathUrl, this, appBase); - if (!this.$$path) { - this.$$path = "/"; - } - this.$$compose(); - }; - this.$$compose = function() { - var search = toKeyValue(this.$$search), hash = this.$$hash ? "#" + encodeUriSegment(this.$$hash) : ""; - this.$$url = encodePath(this.$$path) + (search ? "?" + search : "") + hash; - this.$$absUrl = appBaseNoFile + this.$$url.substr(1); - }; - this.$$rewrite = function(url) { - var appUrl, prevAppUrl; - if ((appUrl = beginsWith(appBase, url)) !== undefined) { - prevAppUrl = appUrl; - if ((appUrl = beginsWith(basePrefix, appUrl)) !== undefined) { - return appBaseNoFile + (beginsWith("/", appUrl) || appUrl); - } else { - return appBase + prevAppUrl; - } - } else if ((appUrl = beginsWith(appBaseNoFile, url)) !== undefined) { - return appBaseNoFile + appUrl; - } else if (appBaseNoFile == url + "/") { - return appBaseNoFile; - } - }; - } - function LocationHashbangUrl(appBase, hashPrefix) { - var appBaseNoFile = stripFile(appBase); - parseAbsoluteUrl(appBase, this, appBase); - this.$$parse = function(url) { - var withoutBaseUrl = beginsWith(appBase, url) || beginsWith(appBaseNoFile, url); - var withoutHashUrl = withoutBaseUrl.charAt(0) == "#" ? beginsWith(hashPrefix, withoutBaseUrl) : this.$$html5 ? withoutBaseUrl : ""; - if (!isString(withoutHashUrl)) { - throw $locationMinErr("ihshprfx", 'Invalid url "{0}", missing hash prefix "{1}".', url, hashPrefix); - } - parseAppUrl(withoutHashUrl, this, appBase); - this.$$path = removeWindowsDriveName(this.$$path, withoutHashUrl, appBase); - this.$$compose(); - function removeWindowsDriveName(path, url, base) { - var windowsFilePathExp = /^\/[A-Z]:(\/.*)/; - var firstPathSegmentMatch; - if (url.indexOf(base) === 0) { - url = url.replace(base, ""); - } - if (windowsFilePathExp.exec(url)) { - return path; - } - firstPathSegmentMatch = windowsFilePathExp.exec(path); - return firstPathSegmentMatch ? firstPathSegmentMatch[1] : path; - } - }; - this.$$compose = function() { - var search = toKeyValue(this.$$search), hash = this.$$hash ? "#" + encodeUriSegment(this.$$hash) : ""; - this.$$url = encodePath(this.$$path) + (search ? "?" + search : "") + hash; - this.$$absUrl = appBase + (this.$$url ? hashPrefix + this.$$url : ""); - }; - this.$$rewrite = function(url) { - if (stripHash(appBase) == stripHash(url)) { - return url; - } - }; - } - function LocationHashbangInHtml5Url(appBase, hashPrefix) { - this.$$html5 = true; - LocationHashbangUrl.apply(this, arguments); - var appBaseNoFile = stripFile(appBase); - this.$$rewrite = function(url) { - var appUrl; - if (appBase == stripHash(url)) { - return url; - } else if (appUrl = beginsWith(appBaseNoFile, url)) { - return appBase + hashPrefix + appUrl; - } else if (appBaseNoFile === url + "/") { - return appBaseNoFile; - } - }; - this.$$compose = function() { - var search = toKeyValue(this.$$search), hash = this.$$hash ? "#" + encodeUriSegment(this.$$hash) : ""; - this.$$url = encodePath(this.$$path) + (search ? "?" + search : "") + hash; - this.$$absUrl = appBase + hashPrefix + this.$$url; - }; - } - LocationHashbangInHtml5Url.prototype = LocationHashbangUrl.prototype = LocationHtml5Url.prototype = { - "$$html5": false, - "$$replace": false, - "absUrl": locationGetter("$$absUrl"), - "url": function(url, replace) { - if (isUndefined(url)) return this.$$url; - var match = PATH_MATCH.exec(url); - if (match[1]) this.path(decodeURIComponent(match[1])); - if (match[2] || match[1]) this.search(match[3] || ""); - this.hash(match[5] || "", replace); - return this; - }, - "protocol": locationGetter("$$protocol"), - "host": locationGetter("$$host"), - "port": locationGetter("$$port"), - "path": locationGetterSetter("$$path", function(path) { - return path.charAt(0) == "/" ? path : "/" + path; - }), - "search": function(search, paramValue) { - switch (arguments.length) { - case 0: - return this.$$search; - - case 1: - if (isString(search)) { - this.$$search = parseKeyValue(search); - } else if (isObject(search)) { - forEach(search, function(value, key) { - if (value == null) delete search[key]; - }); - this.$$search = search; - } else { - throw $locationMinErr("isrcharg", "The first argument of the `$location#search()` call must be a string or an object."); - } - break; - - default: - if (isUndefined(paramValue) || paramValue === null) { - delete this.$$search[search]; - } else { - this.$$search[search] = paramValue; - } - } - this.$$compose(); - return this; - }, - "hash": locationGetterSetter("$$hash", identity), - "replace": function() { - this.$$replace = true; - return this; - } - }; - function locationGetter(property) { - return function() { - return this[property]; - }; - } - function locationGetterSetter(property, preprocess) { - return function(value) { - if (isUndefined(value)) return this[property]; - this[property] = preprocess(value); - this.$$compose(); - return this; - }; - } - function $LocationProvider() { - var hashPrefix = "", html5Mode = false; - this.hashPrefix = function(prefix) { - if (isDefined(prefix)) { - hashPrefix = prefix; - return this; - } else { - return hashPrefix; - } - }; - this.html5Mode = function(mode) { - if (isDefined(mode)) { - html5Mode = mode; - return this; - } else { - return html5Mode; - } - }; - this.$get = [ "$rootScope", "$browser", "$sniffer", "$rootElement", function($rootScope, $browser, $sniffer, $rootElement) { - var $location, LocationMode, baseHref = $browser.baseHref(), initialUrl = $browser.url(), appBase; - if (html5Mode) { - appBase = serverBase(initialUrl) + (baseHref || "/"); - LocationMode = $sniffer.history ? LocationHtml5Url : LocationHashbangInHtml5Url; - } else { - appBase = stripHash(initialUrl); - LocationMode = LocationHashbangUrl; - } - $location = new LocationMode(appBase, "#" + hashPrefix); - $location.$$parse($location.$$rewrite(initialUrl)); - var IGNORE_URI_REGEXP = /^\s*(javascript|mailto):/i; - $rootElement.on("click", function(event) { - if (event.ctrlKey || event.metaKey || event.which == 2) return; - var elm = jqLite(event.target); - while (lowercase(elm[0].nodeName) !== "a") { - if (elm[0] === $rootElement[0] || !(elm = elm.parent())[0]) return; - } - var absHref = elm.prop("href"); - if (isObject(absHref) && absHref.toString() === "[object SVGAnimatedString]") { - absHref = urlResolve(absHref.animVal).href; - } - if (IGNORE_URI_REGEXP.test(absHref)) return; - if (LocationMode === LocationHashbangInHtml5Url) { - var href = elm.attr("href") || elm.attr("xlink:href"); - if (href.indexOf("://") < 0) { - var prefix = "#" + hashPrefix; - if (href[0] == "/") { - absHref = appBase + prefix + href; - } else if (href[0] == "#") { - absHref = appBase + prefix + ($location.path() || "/") + href; - } else { - var stack = $location.path().split("/"), parts = href.split("/"); - for (var i = 0; i < parts.length; i++) { - if (parts[i] == ".") continue; else if (parts[i] == "..") stack.pop(); else if (parts[i].length) stack.push(parts[i]); - } - absHref = appBase + prefix + stack.join("/"); - } - } - } - var rewrittenUrl = $location.$$rewrite(absHref); - if (absHref && !elm.attr("target") && rewrittenUrl && !event.isDefaultPrevented()) { - event.preventDefault(); - if (rewrittenUrl != $browser.url()) { - $location.$$parse(rewrittenUrl); - $rootScope.$apply(); - window.angular["ff-684208-preventDefault"] = true; - } - } - }); - if ($location.absUrl() != initialUrl) { - $browser.url($location.absUrl(), true); - } - $browser.onUrlChange(function(newUrl) { - if ($location.absUrl() != newUrl) { - $rootScope.$evalAsync(function() { - var oldUrl = $location.absUrl(); - $location.$$parse(newUrl); - if ($rootScope.$broadcast("$locationChangeStart", newUrl, oldUrl).defaultPrevented) { - $location.$$parse(oldUrl); - $browser.url(oldUrl); - } else { - afterLocationChange(oldUrl); - } - }); - if (!$rootScope.$$phase) $rootScope.$digest(); - } - }); - var changeCounter = 0; - $rootScope.$watch(function $locationWatch() { - var oldUrl = $browser.url(); - var currentReplace = $location.$$replace; - if (!changeCounter || oldUrl != $location.absUrl()) { - changeCounter++; - $rootScope.$evalAsync(function() { - if ($rootScope.$broadcast("$locationChangeStart", $location.absUrl(), oldUrl).defaultPrevented) { - $location.$$parse(oldUrl); - } else { - $browser.url($location.absUrl(), currentReplace); - afterLocationChange(oldUrl); - } - }); - } - $location.$$replace = false; - return changeCounter; - }); - return $location; - function afterLocationChange(oldUrl) { - $rootScope.$broadcast("$locationChangeSuccess", $location.absUrl(), oldUrl); - } - } ]; - } - function $LogProvider() { - var debug = true, self = this; - this.debugEnabled = function(flag) { - if (isDefined(flag)) { - debug = flag; - return this; - } else { - return debug; - } - }; - this.$get = [ "$window", function($window) { - return { - "log": consoleLog("log"), - "info": consoleLog("info"), - "warn": consoleLog("warn"), - "error": consoleLog("error"), - "debug": function() { - var fn = consoleLog("debug"); - return function() { - if (debug) { - fn.apply(self, arguments); - } - }; - }() - }; - function formatError(arg) { - if (arg instanceof Error) { - if (arg.stack) { - arg = arg.message && arg.stack.indexOf(arg.message) === -1 ? "Error: " + arg.message + "\n" + arg.stack : arg.stack; - } else if (arg.sourceURL) { - arg = arg.message + "\n" + arg.sourceURL + ":" + arg.line; - } - } - return arg; - } - function consoleLog(type) { - var console = $window.console || {}, logFn = console[type] || console.log || noop, hasApply = false; - try { - hasApply = !!logFn.apply; - } catch (e) {} - if (hasApply) { - return function() { - var args = []; - forEach(arguments, function(arg) { - args.push(formatError(arg)); - }); - return logFn.apply(console, args); - }; - } - return function(arg1, arg2) { - logFn(arg1, arg2 == null ? "" : arg2); - }; - } - } ]; - } - var $parseMinErr = minErr("$parse"); - var promiseWarningCache = {}; - var promiseWarning; - function ensureSafeMemberName(name, fullExpression) { - if (name === "__defineGetter__" || name === "__defineSetter__" || name === "__lookupGetter__" || name === "__lookupSetter__" || name === "__proto__") { - throw $parseMinErr("isecfld", "Attempting to access a disallowed field in Angular expressions! " + "Expression: {0}", fullExpression); - } - return name; - } - function ensureSafeObject(obj, fullExpression) { - if (obj) { - if (obj.constructor === obj) { - throw $parseMinErr("isecfn", "Referencing Function in Angular expressions is disallowed! Expression: {0}", fullExpression); - } else if (obj.document && obj.location && obj.alert && obj.setInterval) { - throw $parseMinErr("isecwindow", "Referencing the Window in Angular expressions is disallowed! Expression: {0}", fullExpression); - } else if (obj.children && (obj.nodeName || obj.prop && obj.attr && obj.find)) { - throw $parseMinErr("isecdom", "Referencing DOM nodes in Angular expressions is disallowed! Expression: {0}", fullExpression); - } else if (obj === Object) { - throw $parseMinErr("isecobj", "Referencing Object in Angular expressions is disallowed! Expression: {0}", fullExpression); - } - } - return obj; - } - var CALL = Function.prototype.call; - var APPLY = Function.prototype.apply; - var BIND = Function.prototype.bind; - function ensureSafeFunction(obj, fullExpression) { - if (obj) { - if (obj.constructor === obj) { - throw $parseMinErr("isecfn", "Referencing Function in Angular expressions is disallowed! Expression: {0}", fullExpression); - } else if (obj === CALL || obj === APPLY || BIND && obj === BIND) { - throw $parseMinErr("isecff", "Referencing call, apply or bind in Angular expressions is disallowed! Expression: {0}", fullExpression); - } - } - } - var OPERATORS = { - "null": function() { - return null; - }, - "true": function() { - return true; - }, - "false": function() { - return false; - }, - "undefined": noop, - "+": function(self, locals, a, b) { - a = a(self, locals); - b = b(self, locals); - if (isDefined(a)) { - if (isDefined(b)) { - return a + b; - } - return a; - } - return isDefined(b) ? b : undefined; - }, - "-": function(self, locals, a, b) { - a = a(self, locals); - b = b(self, locals); - return (isDefined(a) ? a : 0) - (isDefined(b) ? b : 0); - }, - "*": function(self, locals, a, b) { - return a(self, locals) * b(self, locals); - }, - "/": function(self, locals, a, b) { - return a(self, locals) / b(self, locals); - }, - "%": function(self, locals, a, b) { - return a(self, locals) % b(self, locals); - }, - "^": function(self, locals, a, b) { - return a(self, locals) ^ b(self, locals); - }, - "=": noop, - "===": function(self, locals, a, b) { - return a(self, locals) === b(self, locals); - }, - "!==": function(self, locals, a, b) { - return a(self, locals) !== b(self, locals); - }, - "==": function(self, locals, a, b) { - return a(self, locals) == b(self, locals); - }, - "!=": function(self, locals, a, b) { - return a(self, locals) != b(self, locals); - }, - "<": function(self, locals, a, b) { - return a(self, locals) < b(self, locals); - }, - ">": function(self, locals, a, b) { - return a(self, locals) > b(self, locals); - }, - "<=": function(self, locals, a, b) { - return a(self, locals) <= b(self, locals); - }, - ">=": function(self, locals, a, b) { - return a(self, locals) >= b(self, locals); - }, - "&&": function(self, locals, a, b) { - return a(self, locals) && b(self, locals); - }, - "||": function(self, locals, a, b) { - return a(self, locals) || b(self, locals); - }, - "&": function(self, locals, a, b) { - return a(self, locals) & b(self, locals); - }, - "|": function(self, locals, a, b) { - return b(self, locals)(self, locals, a(self, locals)); - }, - "!": function(self, locals, a) { - return !a(self, locals); - } - }; - var ESCAPE = { - "n": "\n", - "f": "\f", - "r": "\r", - "t": " ", - "v": " ", - "'": "'", - '"': '"' - }; - var Lexer = function(options) { - this.options = options; - }; - Lexer.prototype = { - "constructor": Lexer, - "lex": function(text) { - this.text = text; - this.index = 0; - this.ch = undefined; - this.lastCh = ":"; - this.tokens = []; - while (this.index < this.text.length) { - this.ch = this.text.charAt(this.index); - if (this.is("\"'")) { - this.readString(this.ch); - } else if (this.isNumber(this.ch) || this.is(".") && this.isNumber(this.peek())) { - this.readNumber(); - } else if (this.isIdent(this.ch)) { - this.readIdent(); - } else if (this.is("(){}[].,;:?")) { - this.tokens.push({ - "index": this.index, - "text": this.ch - }); - this.index++; - } else if (this.isWhitespace(this.ch)) { - this.index++; - continue; - } else { - var ch2 = this.ch + this.peek(); - var ch3 = ch2 + this.peek(2); - var fn = OPERATORS[this.ch]; - var fn2 = OPERATORS[ch2]; - var fn3 = OPERATORS[ch3]; - if (fn3) { - this.tokens.push({ - "index": this.index, - "text": ch3, - "fn": fn3 - }); - this.index += 3; - } else if (fn2) { - this.tokens.push({ - "index": this.index, - "text": ch2, - "fn": fn2 - }); - this.index += 2; - } else if (fn) { - this.tokens.push({ - "index": this.index, - "text": this.ch, - "fn": fn - }); - this.index += 1; - } else { - this.throwError("Unexpected next character ", this.index, this.index + 1); - } - } - this.lastCh = this.ch; - } - return this.tokens; - }, - "is": function(chars) { - return chars.indexOf(this.ch) !== -1; - }, - "was": function(chars) { - return chars.indexOf(this.lastCh) !== -1; - }, - "peek": function(i) { - var num = i || 1; - return this.index + num < this.text.length ? this.text.charAt(this.index + num) : false; - }, - "isNumber": function(ch) { - return "0" <= ch && ch <= "9"; - }, - "isWhitespace": function(ch) { - return ch === " " || ch === "\r" || ch === " " || ch === "\n" || ch === " " || ch === "\xa0"; - }, - "isIdent": function(ch) { - return "a" <= ch && ch <= "z" || "A" <= ch && ch <= "Z" || "_" === ch || ch === "$"; - }, - "isExpOperator": function(ch) { - return ch === "-" || ch === "+" || this.isNumber(ch); - }, - "throwError": function(error, start, end) { - end = end || this.index; - var colStr = isDefined(start) ? "s " + start + "-" + this.index + " [" + this.text.substring(start, end) + "]" : " " + end; - throw $parseMinErr("lexerr", "Lexer Error: {0} at column{1} in expression [{2}].", error, colStr, this.text); - }, - "readNumber": function() { - var number = ""; - var start = this.index; - while (this.index < this.text.length) { - var ch = lowercase(this.text.charAt(this.index)); - if (ch == "." || this.isNumber(ch)) { - number += ch; - } else { - var peekCh = this.peek(); - if (ch == "e" && this.isExpOperator(peekCh)) { - number += ch; - } else if (this.isExpOperator(ch) && peekCh && this.isNumber(peekCh) && number.charAt(number.length - 1) == "e") { - number += ch; - } else if (this.isExpOperator(ch) && (!peekCh || !this.isNumber(peekCh)) && number.charAt(number.length - 1) == "e") { - this.throwError("Invalid exponent"); - } else { - break; - } - } - this.index++; - } - number = 1 * number; - this.tokens.push({ - "index": start, - "text": number, - "literal": true, - "constant": true, - "fn": function() { - return number; - } - }); - }, - "readIdent": function() { - var parser = this; - var ident = ""; - var start = this.index; - var lastDot, peekIndex, methodName, ch; - while (this.index < this.text.length) { - ch = this.text.charAt(this.index); - if (ch === "." || this.isIdent(ch) || this.isNumber(ch)) { - if (ch === ".") lastDot = this.index; - ident += ch; - } else { - break; - } - this.index++; - } - if (lastDot) { - peekIndex = this.index; - while (peekIndex < this.text.length) { - ch = this.text.charAt(peekIndex); - if (ch === "(") { - methodName = ident.substr(lastDot - start + 1); - ident = ident.substr(0, lastDot - start); - this.index = peekIndex; - break; - } - if (this.isWhitespace(ch)) { - peekIndex++; - } else { - break; - } - } - } - var token = { - "index": start, - "text": ident - }; - if (OPERATORS.hasOwnProperty(ident)) { - token.fn = OPERATORS[ident]; - token.literal = true; - token.constant = true; - } else { - var getter = getterFn(ident, this.options, this.text); - token.fn = extend(function(self, locals) { - return getter(self, locals); - }, { - "assign": function(self, value) { - return setter(self, ident, value, parser.text, parser.options); - } - }); - } - this.tokens.push(token); - if (methodName) { - this.tokens.push({ - "index": lastDot, - "text": "." - }); - this.tokens.push({ - "index": lastDot + 1, - "text": methodName - }); - } - }, - "readString": function(quote) { - var start = this.index; - this.index++; - var string = ""; - var rawString = quote; - var escape = false; - while (this.index < this.text.length) { - var ch = this.text.charAt(this.index); - rawString += ch; - if (escape) { - if (ch === "u") { - var hex = this.text.substring(this.index + 1, this.index + 5); - if (!hex.match(/[\da-f]{4}/i)) this.throwError("Invalid unicode escape [\\u" + hex + "]"); - this.index += 4; - string += String.fromCharCode(parseInt(hex, 16)); - } else { - var rep = ESCAPE[ch]; - string = string + (rep || ch); - } - escape = false; - } else if (ch === "\\") { - escape = true; - } else if (ch === quote) { - this.index++; - this.tokens.push({ - "index": start, - "text": rawString, - "string": string, - "literal": true, - "constant": true, - "fn": function() { - return string; - } - }); - return; - } else { - string += ch; - } - this.index++; - } - this.throwError("Unterminated quote", start); - } - }; - var Parser = function(lexer, $filter, options) { - this.lexer = lexer; - this.$filter = $filter; - this.options = options; - }; - Parser.ZERO = extend(function() { - return 0; - }, { - "constant": true - }); - Parser.prototype = { - "constructor": Parser, - "parse": function(text) { - this.text = text; - this.tokens = this.lexer.lex(text); - var value = this.statements(); - if (this.tokens.length !== 0) { - this.throwError("is an unexpected token", this.tokens[0]); - } - value.literal = !!value.literal; - value.constant = !!value.constant; - return value; - }, - "primary": function() { - var primary; - if (this.expect("(")) { - primary = this.filterChain(); - this.consume(")"); - } else if (this.expect("[")) { - primary = this.arrayDeclaration(); - } else if (this.expect("{")) { - primary = this.object(); - } else { - var token = this.expect(); - primary = token.fn; - if (!primary) { - this.throwError("not a primary expression", token); - } - primary.literal = !!token.literal; - primary.constant = !!token.constant; - } - var next, context; - while (next = this.expect("(", "[", ".")) { - if (next.text === "(") { - primary = this.functionCall(primary, context); - context = null; - } else if (next.text === "[") { - context = primary; - primary = this.objectIndex(primary); - } else if (next.text === ".") { - context = primary; - primary = this.fieldAccess(primary); - } else { - this.throwError("IMPOSSIBLE"); - } - } - return primary; - }, - "throwError": function(msg, token) { - throw $parseMinErr("syntax", "Syntax Error: Token '{0}' {1} at column {2} of the expression [{3}] starting at [{4}].", token.text, msg, token.index + 1, this.text, this.text.substring(token.index)); - }, - "peekToken": function() { - if (this.tokens.length === 0) throw $parseMinErr("ueoe", "Unexpected end of expression: {0}", this.text); - return this.tokens[0]; - }, - "peek": function(e1, e2, e3, e4) { - if (this.tokens.length > 0) { - var token = this.tokens[0]; - var t = token.text; - if (t === e1 || t === e2 || t === e3 || t === e4 || !e1 && !e2 && !e3 && !e4) { - return token; - } - } - return false; - }, - "expect": function(e1, e2, e3, e4) { - var token = this.peek(e1, e2, e3, e4); - if (token) { - this.tokens.shift(); - return token; - } - return false; - }, - "consume": function(e1) { - if (!this.expect(e1)) { - this.throwError("is unexpected, expecting [" + e1 + "]", this.peek()); - } - }, - "unaryFn": function(fn, right) { - return extend(function(self, locals) { - return fn(self, locals, right); - }, { - "constant": right.constant - }); - }, - "ternaryFn": function(left, middle, right) { - return extend(function(self, locals) { - return left(self, locals) ? middle(self, locals) : right(self, locals); - }, { - "constant": left.constant && middle.constant && right.constant - }); - }, - "binaryFn": function(left, fn, right) { - return extend(function(self, locals) { - return fn(self, locals, left, right); - }, { - "constant": left.constant && right.constant - }); - }, - "statements": function() { - var statements = []; - while (true) { - if (this.tokens.length > 0 && !this.peek("}", ")", ";", "]")) statements.push(this.filterChain()); - if (!this.expect(";")) { - return statements.length === 1 ? statements[0] : function(self, locals) { - var value; - for (var i = 0; i < statements.length; i++) { - var statement = statements[i]; - if (statement) { - value = statement(self, locals); - } - } - return value; - }; - } - } - }, - "filterChain": function() { - var left = this.expression(); - var token; - while (true) { - if (token = this.expect("|")) { - left = this.binaryFn(left, token.fn, this.filter()); - } else { - return left; - } - } - }, - "filter": function() { - var token = this.expect(); - var fn = this.$filter(token.text); - var argsFn = []; - while (true) { - if (token = this.expect(":")) { - argsFn.push(this.expression()); - } else { - var fnInvoke = function(self, locals, input) { - var args = [ input ]; - for (var i = 0; i < argsFn.length; i++) { - args.push(argsFn[i](self, locals)); - } - return fn.apply(self, args); - }; - return function() { - return fnInvoke; - }; - } - } - }, - "expression": function() { - return this.assignment(); - }, - "assignment": function() { - var left = this.ternary(); - var right; - var token; - if (token = this.expect("=")) { - if (!left.assign) { - this.throwError("implies assignment but [" + this.text.substring(0, token.index) + "] can not be assigned to", token); - } - right = this.ternary(); - return function(scope, locals) { - return left.assign(scope, right(scope, locals), locals); - }; - } - return left; - }, - "ternary": function() { - var left = this.logicalOR(); - var middle; - var token; - if (token = this.expect("?")) { - middle = this.assignment(); - if (token = this.expect(":")) { - return this.ternaryFn(left, middle, this.assignment()); - } else { - this.throwError("expected :", token); - } - } else { - return left; - } - }, - "logicalOR": function() { - var left = this.logicalAND(); - var token; - while (true) { - if (token = this.expect("||")) { - left = this.binaryFn(left, token.fn, this.logicalAND()); - } else { - return left; - } - } - }, - "logicalAND": function() { - var left = this.equality(); - var token; - if (token = this.expect("&&")) { - left = this.binaryFn(left, token.fn, this.logicalAND()); - } - return left; - }, - "equality": function() { - var left = this.relational(); - var token; - if (token = this.expect("==", "!=", "===", "!==")) { - left = this.binaryFn(left, token.fn, this.equality()); - } - return left; - }, - "relational": function() { - var left = this.additive(); - var token; - if (token = this.expect("<", ">", "<=", ">=")) { - left = this.binaryFn(left, token.fn, this.relational()); - } - return left; - }, - "additive": function() { - var left = this.multiplicative(); - var token; - while (token = this.expect("+", "-")) { - left = this.binaryFn(left, token.fn, this.multiplicative()); - } - return left; - }, - "multiplicative": function() { - var left = this.unary(); - var token; - while (token = this.expect("*", "/", "%")) { - left = this.binaryFn(left, token.fn, this.unary()); - } - return left; - }, - "unary": function() { - var token; - if (this.expect("+")) { - return this.primary(); - } else if (token = this.expect("-")) { - return this.binaryFn(Parser.ZERO, token.fn, this.unary()); - } else if (token = this.expect("!")) { - return this.unaryFn(token.fn, this.unary()); - } else { - return this.primary(); - } - }, - "fieldAccess": function(object) { - var parser = this; - var field = this.expect().text; - var getter = getterFn(field, this.options, this.text); - return extend(function(scope, locals, self) { - return getter(self || object(scope, locals)); - }, { - "assign": function(scope, value, locals) { - var o = object(scope, locals); - if (!o) object.assign(scope, o = {}); - return setter(o, field, value, parser.text, parser.options); - } - }); - }, - "objectIndex": function(obj) { - var parser = this; - var indexFn = this.expression(); - this.consume("]"); - return extend(function(self, locals) { - var o = obj(self, locals), i = indexFn(self, locals), v, p; - ensureSafeMemberName(i, parser.text); - if (!o) return undefined; - v = ensureSafeObject(o[i], parser.text); - if (v && v.then && parser.options.unwrapPromises) { - p = v; - if (!("$$v" in v)) { - p.$$v = undefined; - p.then(function(val) { - p.$$v = val; - }); - } - v = v.$$v; - } - return v; - }, { - "assign": function(self, value, locals) { - var key = ensureSafeMemberName(indexFn(self, locals), parser.text); - var o = ensureSafeObject(obj(self, locals), parser.text); - if (!o) obj.assign(self, o = {}); - return o[key] = value; - } - }); - }, - "functionCall": function(fn, contextGetter) { - var argsFn = []; - if (this.peekToken().text !== ")") { - do { - argsFn.push(this.expression()); - } while (this.expect(",")); - } - this.consume(")"); - var parser = this; - return function(scope, locals) { - var args = []; - var context = contextGetter ? contextGetter(scope, locals) : scope; - for (var i = 0; i < argsFn.length; i++) { - args.push(argsFn[i](scope, locals)); - } - var fnPtr = fn(scope, locals, context) || noop; - ensureSafeObject(context, parser.text); - ensureSafeFunction(fnPtr, parser.text); - var v = fnPtr.apply ? fnPtr.apply(context, args) : fnPtr(args[0], args[1], args[2], args[3], args[4]); - return ensureSafeObject(v, parser.text); - }; - }, - "arrayDeclaration": function() { - var elementFns = []; - var allConstant = true; - if (this.peekToken().text !== "]") { - do { - if (this.peek("]")) { - break; - } - var elementFn = this.expression(); - elementFns.push(elementFn); - if (!elementFn.constant) { - allConstant = false; - } - } while (this.expect(",")); - } - this.consume("]"); - return extend(function(self, locals) { - var array = []; - for (var i = 0; i < elementFns.length; i++) { - array.push(elementFns[i](self, locals)); - } - return array; - }, { - "literal": true, - "constant": allConstant - }); - }, - "object": function() { - var keyValues = []; - var allConstant = true; - if (this.peekToken().text !== "}") { - do { - if (this.peek("}")) { - break; - } - var token = this.expect(), key = token.string || token.text; - this.consume(":"); - var value = this.expression(); - keyValues.push({ - "key": key, - "value": value - }); - if (!value.constant) { - allConstant = false; - } - } while (this.expect(",")); - } - this.consume("}"); - return extend(function(self, locals) { - var object = {}; - for (var i = 0; i < keyValues.length; i++) { - var keyValue = keyValues[i]; - object[keyValue.key] = keyValue.value(self, locals); - } - return object; - }, { - "literal": true, - "constant": allConstant - }); - } - }; - function setter(obj, path, setValue, fullExp, options) { - options = options || {}; - var element = path.split("."), key; - for (var i = 0; element.length > 1; i++) { - key = ensureSafeMemberName(element.shift(), fullExp); - var propertyObj = obj[key]; - if (!propertyObj) { - propertyObj = {}; - obj[key] = propertyObj; - } - obj = propertyObj; - if (obj.then && options.unwrapPromises) { - promiseWarning(fullExp); - if (!("$$v" in obj)) { - (function(promise) { - promise.then(function(val) { - promise.$$v = val; - }); - })(obj); - } - if (obj.$$v === undefined) { - obj.$$v = {}; - } - obj = obj.$$v; - } - } - key = ensureSafeMemberName(element.shift(), fullExp); - ensureSafeObject(obj, fullExp); - ensureSafeObject(obj[key], fullExp); - obj[key] = setValue; - return setValue; - } - var getterFnCache = {}; - function cspSafeGetterFn(key0, key1, key2, key3, key4, fullExp, options) { - ensureSafeMemberName(key0, fullExp); - ensureSafeMemberName(key1, fullExp); - ensureSafeMemberName(key2, fullExp); - ensureSafeMemberName(key3, fullExp); - ensureSafeMemberName(key4, fullExp); - return !options.unwrapPromises ? function cspSafeGetter(scope, locals) { - var pathVal = locals && locals.hasOwnProperty(key0) ? locals : scope; - if (pathVal == null) return pathVal; - pathVal = pathVal[key0]; - if (!key1) return pathVal; - if (pathVal == null) return undefined; - pathVal = pathVal[key1]; - if (!key2) return pathVal; - if (pathVal == null) return undefined; - pathVal = pathVal[key2]; - if (!key3) return pathVal; - if (pathVal == null) return undefined; - pathVal = pathVal[key3]; - if (!key4) return pathVal; - if (pathVal == null) return undefined; - pathVal = pathVal[key4]; - return pathVal; - } : function cspSafePromiseEnabledGetter(scope, locals) { - var pathVal = locals && locals.hasOwnProperty(key0) ? locals : scope, promise; - if (pathVal == null) return pathVal; - pathVal = pathVal[key0]; - if (pathVal && pathVal.then) { - promiseWarning(fullExp); - if (!("$$v" in pathVal)) { - promise = pathVal; - promise.$$v = undefined; - promise.then(function(val) { - promise.$$v = val; - }); - } - pathVal = pathVal.$$v; - } - if (!key1) return pathVal; - if (pathVal == null) return undefined; - pathVal = pathVal[key1]; - if (pathVal && pathVal.then) { - promiseWarning(fullExp); - if (!("$$v" in pathVal)) { - promise = pathVal; - promise.$$v = undefined; - promise.then(function(val) { - promise.$$v = val; - }); - } - pathVal = pathVal.$$v; - } - if (!key2) return pathVal; - if (pathVal == null) return undefined; - pathVal = pathVal[key2]; - if (pathVal && pathVal.then) { - promiseWarning(fullExp); - if (!("$$v" in pathVal)) { - promise = pathVal; - promise.$$v = undefined; - promise.then(function(val) { - promise.$$v = val; - }); - } - pathVal = pathVal.$$v; - } - if (!key3) return pathVal; - if (pathVal == null) return undefined; - pathVal = pathVal[key3]; - if (pathVal && pathVal.then) { - promiseWarning(fullExp); - if (!("$$v" in pathVal)) { - promise = pathVal; - promise.$$v = undefined; - promise.then(function(val) { - promise.$$v = val; - }); - } - pathVal = pathVal.$$v; - } - if (!key4) return pathVal; - if (pathVal == null) return undefined; - pathVal = pathVal[key4]; - if (pathVal && pathVal.then) { - promiseWarning(fullExp); - if (!("$$v" in pathVal)) { - promise = pathVal; - promise.$$v = undefined; - promise.then(function(val) { - promise.$$v = val; - }); - } - pathVal = pathVal.$$v; - } - return pathVal; - }; - } - function getterFn(path, options, fullExp) { - if (getterFnCache.hasOwnProperty(path)) { - return getterFnCache[path]; - } - var pathKeys = path.split("."), pathKeysLength = pathKeys.length, fn; - if (options.csp) { - if (pathKeysLength < 6) { - fn = cspSafeGetterFn(pathKeys[0], pathKeys[1], pathKeys[2], pathKeys[3], pathKeys[4], fullExp, options); - } else { - fn = function(scope, locals) { - var i = 0, val; - do { - val = cspSafeGetterFn(pathKeys[i++], pathKeys[i++], pathKeys[i++], pathKeys[i++], pathKeys[i++], fullExp, options)(scope, locals); - locals = undefined; - scope = val; - } while (i < pathKeysLength); - return val; - }; - } - } else { - var code = "var p;\n"; - forEach(pathKeys, function(key, index) { - ensureSafeMemberName(key, fullExp); - code += "if(s == null) return undefined;\n" + "s=" + (index ? "s" : '((k&&k.hasOwnProperty("' + key + '"))?k:s)') + '["' + key + '"]' + ";\n" + (options.unwrapPromises ? "if (s && s.then) {\n" + ' pw("' + fullExp.replace(/(["\r\n])/g, "\\$1") + '");\n' + ' if (!("$$v" in s)) {\n' + " p=s;\n" + " p.$$v = undefined;\n" + " p.then(function(v) {p.$$v=v;});\n" + "}\n" + " s=s.$$v\n" + "}\n" : ""); - }); - code += "return s;"; - var evaledFnGetter = new Function("s", "k", "pw", code); - evaledFnGetter.toString = valueFn(code); - fn = options.unwrapPromises ? function(scope, locals) { - return evaledFnGetter(scope, locals, promiseWarning); - } : evaledFnGetter; - } - if (path !== "hasOwnProperty") { - getterFnCache[path] = fn; - } - return fn; - } - function $ParseProvider() { - var cache = {}; - var $parseOptions = { - "csp": false, - "unwrapPromises": false, - "logPromiseWarnings": true - }; - this.unwrapPromises = function(value) { - if (isDefined(value)) { - $parseOptions.unwrapPromises = !!value; - return this; - } else { - return $parseOptions.unwrapPromises; - } - }; - this.logPromiseWarnings = function(value) { - if (isDefined(value)) { - $parseOptions.logPromiseWarnings = value; - return this; - } else { - return $parseOptions.logPromiseWarnings; - } - }; - this.$get = [ "$filter", "$sniffer", "$log", function($filter, $sniffer, $log) { - $parseOptions.csp = $sniffer.csp; - promiseWarning = function promiseWarningFn(fullExp) { - if (!$parseOptions.logPromiseWarnings || promiseWarningCache.hasOwnProperty(fullExp)) return; - promiseWarningCache[fullExp] = true; - $log.warn("[$parse] Promise found in the expression `" + fullExp + "`. " + "Automatic unwrapping of promises in Angular expressions is deprecated."); - }; - return function(exp) { - var parsedExpression; - switch (typeof exp) { - case "string": - if (cache.hasOwnProperty(exp)) { - return cache[exp]; - } - var lexer = new Lexer($parseOptions); - var parser = new Parser(lexer, $filter, $parseOptions); - parsedExpression = parser.parse(exp); - if (exp !== "hasOwnProperty") { - cache[exp] = parsedExpression; - } - return parsedExpression; - - case "function": - return exp; - - default: - return noop; - } - }; - } ]; - } - function $QProvider() { - this.$get = [ "$rootScope", "$exceptionHandler", function($rootScope, $exceptionHandler) { - return qFactory(function(callback) { - $rootScope.$evalAsync(callback); - }, $exceptionHandler); - } ]; - } - function qFactory(nextTick, exceptionHandler) { - var defer = function() { - var pending = [], value, deferred; - deferred = { - "resolve": function(val) { - if (pending) { - var callbacks = pending; - pending = undefined; - value = ref(val); - if (callbacks.length) { - nextTick(function() { - var callback; - for (var i = 0, ii = callbacks.length; i < ii; i++) { - callback = callbacks[i]; - value.then(callback[0], callback[1], callback[2]); - } - }); - } - } - }, - "reject": function(reason) { - deferred.resolve(createInternalRejectedPromise(reason)); - }, - "notify": function(progress) { - if (pending) { - var callbacks = pending; - if (pending.length) { - nextTick(function() { - var callback; - for (var i = 0, ii = callbacks.length; i < ii; i++) { - callback = callbacks[i]; - callback[2](progress); - } - }); - } - } - }, - "promise": { - "then": function(callback, errback, progressback) { - var result = defer(); - var wrappedCallback = function(value) { - try { - result.resolve((isFunction(callback) ? callback : defaultCallback)(value)); - } catch (e) { - result.reject(e); - exceptionHandler(e); - } - }; - var wrappedErrback = function(reason) { - try { - result.resolve((isFunction(errback) ? errback : defaultErrback)(reason)); - } catch (e) { - result.reject(e); - exceptionHandler(e); - } - }; - var wrappedProgressback = function(progress) { - try { - result.notify((isFunction(progressback) ? progressback : defaultCallback)(progress)); - } catch (e) { - exceptionHandler(e); - } - }; - if (pending) { - pending.push([ wrappedCallback, wrappedErrback, wrappedProgressback ]); - } else { - value.then(wrappedCallback, wrappedErrback, wrappedProgressback); - } - return result.promise; - }, - "catch": function(callback) { - return this.then(null, callback); - }, - "finally": function(callback) { - function makePromise(value, resolved) { - var result = defer(); - if (resolved) { - result.resolve(value); - } else { - result.reject(value); - } - return result.promise; - } - function handleCallback(value, isResolved) { - var callbackOutput = null; - try { - callbackOutput = (callback || defaultCallback)(); - } catch (e) { - return makePromise(e, false); - } - if (isPromiseLike(callbackOutput)) { - return callbackOutput.then(function() { - return makePromise(value, isResolved); - }, function(error) { - return makePromise(error, false); - }); - } else { - return makePromise(value, isResolved); - } - } - return this.then(function(value) { - return handleCallback(value, true); - }, function(error) { - return handleCallback(error, false); - }); - } - } - }; - return deferred; - }; - var ref = function(value) { - if (isPromiseLike(value)) return value; - return { - "then": function(callback) { - var result = defer(); - nextTick(function() { - result.resolve(callback(value)); - }); - return result.promise; - } - }; - }; - var reject = function(reason) { - var result = defer(); - result.reject(reason); - return result.promise; - }; - var createInternalRejectedPromise = function(reason) { - return { - "then": function(callback, errback) { - var result = defer(); - nextTick(function() { - try { - result.resolve((isFunction(errback) ? errback : defaultErrback)(reason)); - } catch (e) { - result.reject(e); - exceptionHandler(e); - } - }); - return result.promise; - } - }; - }; - var when = function(value, callback, errback, progressback) { - var result = defer(), done; - var wrappedCallback = function(value) { - try { - return (isFunction(callback) ? callback : defaultCallback)(value); - } catch (e) { - exceptionHandler(e); - return reject(e); - } - }; - var wrappedErrback = function(reason) { - try { - return (isFunction(errback) ? errback : defaultErrback)(reason); - } catch (e) { - exceptionHandler(e); - return reject(e); - } - }; - var wrappedProgressback = function(progress) { - try { - return (isFunction(progressback) ? progressback : defaultCallback)(progress); - } catch (e) { - exceptionHandler(e); - } - }; - nextTick(function() { - ref(value).then(function(value) { - if (done) return; - done = true; - result.resolve(ref(value).then(wrappedCallback, wrappedErrback, wrappedProgressback)); - }, function(reason) { - if (done) return; - done = true; - result.resolve(wrappedErrback(reason)); - }, function(progress) { - if (done) return; - result.notify(wrappedProgressback(progress)); - }); - }); - return result.promise; - }; - function defaultCallback(value) { - return value; - } - function defaultErrback(reason) { - return reject(reason); - } - function all(promises) { - var deferred = defer(), counter = 0, results = isArray(promises) ? [] : {}; - forEach(promises, function(promise, key) { - counter++; - ref(promise).then(function(value) { - if (results.hasOwnProperty(key)) return; - results[key] = value; - if (!--counter) deferred.resolve(results); - }, function(reason) { - if (results.hasOwnProperty(key)) return; - deferred.reject(reason); - }); - }); - if (counter === 0) { - deferred.resolve(results); - } - return deferred.promise; - } - return { - "defer": defer, - "reject": reject, - "when": when, - "all": all - }; - } - function $$RAFProvider() { - this.$get = [ "$window", "$timeout", function($window, $timeout) { - var requestAnimationFrame = $window.requestAnimationFrame || $window.webkitRequestAnimationFrame || $window.mozRequestAnimationFrame; - var cancelAnimationFrame = $window.cancelAnimationFrame || $window.webkitCancelAnimationFrame || $window.mozCancelAnimationFrame || $window.webkitCancelRequestAnimationFrame; - var rafSupported = !!requestAnimationFrame; - var raf = rafSupported ? function(fn) { - var id = requestAnimationFrame(fn); - return function() { - cancelAnimationFrame(id); - }; - } : function(fn) { - var timer = $timeout(fn, 16.66, false); - return function() { - $timeout.cancel(timer); - }; - }; - raf.supported = rafSupported; - return raf; - } ]; - } - function $RootScopeProvider() { - var TTL = 10; - var $rootScopeMinErr = minErr("$rootScope"); - var lastDirtyWatch = null; - this.digestTtl = function(value) { - if (arguments.length) { - TTL = value; - } - return TTL; - }; - this.$get = [ "$injector", "$exceptionHandler", "$parse", "$browser", function($injector, $exceptionHandler, $parse, $browser) { - function Scope() { - this.$id = nextUid(); - this.$$phase = this.$parent = this.$$watchers = this.$$nextSibling = this.$$prevSibling = this.$$childHead = this.$$childTail = null; - this["this"] = this.$root = this; - this.$$destroyed = false; - this.$$asyncQueue = []; - this.$$postDigestQueue = []; - this.$$listeners = {}; - this.$$listenerCount = {}; - this.$$isolateBindings = {}; - } - Scope.prototype = { - "constructor": Scope, - "$new": function(isolate) { - var ChildScope, child; - if (isolate) { - child = new Scope(); - child.$root = this.$root; - child.$$asyncQueue = this.$$asyncQueue; - child.$$postDigestQueue = this.$$postDigestQueue; - } else { - if (!this.$$childScopeClass) { - this.$$childScopeClass = function() { - this.$$watchers = this.$$nextSibling = this.$$childHead = this.$$childTail = null; - this.$$listeners = {}; - this.$$listenerCount = {}; - this.$id = nextUid(); - this.$$childScopeClass = null; - }; - this.$$childScopeClass.prototype = this; - } - child = new this.$$childScopeClass(); - } - child["this"] = child; - child.$parent = this; - child.$$prevSibling = this.$$childTail; - if (this.$$childHead) { - this.$$childTail.$$nextSibling = child; - this.$$childTail = child; - } else { - this.$$childHead = this.$$childTail = child; - } - return child; - }, - "$watch": function(watchExp, listener, objectEquality) { - var scope = this, get = compileToFn(watchExp, "watch"), array = scope.$$watchers, watcher = { - "fn": listener, - "last": initWatchVal, - "get": get, - "exp": watchExp, - "eq": !!objectEquality - }; - lastDirtyWatch = null; - if (!isFunction(listener)) { - var listenFn = compileToFn(listener || noop, "listener"); - watcher.fn = function(newVal, oldVal, scope) { - listenFn(scope); - }; - } - if (typeof watchExp == "string" && get.constant) { - var originalFn = watcher.fn; - watcher.fn = function(newVal, oldVal, scope) { - originalFn.call(this, newVal, oldVal, scope); - arrayRemove(array, watcher); - }; - } - if (!array) { - array = scope.$$watchers = []; - } - array.unshift(watcher); - return function deregisterWatch() { - arrayRemove(array, watcher); - lastDirtyWatch = null; - }; - }, - "$watchCollection": function(obj, listener) { - var self = this; - var newValue; - var oldValue; - var veryOldValue; - var trackVeryOldValue = listener.length > 1; - var changeDetected = 0; - var objGetter = $parse(obj); - var internalArray = []; - var internalObject = {}; - var initRun = true; - var oldLength = 0; - function $watchCollectionWatch() { - newValue = objGetter(self); - var newLength, key, bothNaN; - if (!isObject(newValue)) { - if (oldValue !== newValue) { - oldValue = newValue; - changeDetected++; - } - } else if (isArrayLike(newValue)) { - if (oldValue !== internalArray) { - oldValue = internalArray; - oldLength = oldValue.length = 0; - changeDetected++; - } - newLength = newValue.length; - if (oldLength !== newLength) { - changeDetected++; - oldValue.length = oldLength = newLength; - } - for (var i = 0; i < newLength; i++) { - bothNaN = oldValue[i] !== oldValue[i] && newValue[i] !== newValue[i]; - if (!bothNaN && oldValue[i] !== newValue[i]) { - changeDetected++; - oldValue[i] = newValue[i]; - } - } - } else { - if (oldValue !== internalObject) { - oldValue = internalObject = {}; - oldLength = 0; - changeDetected++; - } - newLength = 0; - for (key in newValue) { - if (newValue.hasOwnProperty(key)) { - newLength++; - if (oldValue.hasOwnProperty(key)) { - bothNaN = oldValue[key] !== oldValue[key] && newValue[key] !== newValue[key]; - if (!bothNaN && oldValue[key] !== newValue[key]) { - changeDetected++; - oldValue[key] = newValue[key]; - } - } else { - oldLength++; - oldValue[key] = newValue[key]; - changeDetected++; - } - } - } - if (oldLength > newLength) { - changeDetected++; - for (key in oldValue) { - if (oldValue.hasOwnProperty(key) && !newValue.hasOwnProperty(key)) { - oldLength--; - delete oldValue[key]; - } - } - } - } - return changeDetected; - } - function $watchCollectionAction() { - if (initRun) { - initRun = false; - listener(newValue, newValue, self); - } else { - listener(newValue, veryOldValue, self); - } - if (trackVeryOldValue) { - if (!isObject(newValue)) { - veryOldValue = newValue; - } else if (isArrayLike(newValue)) { - veryOldValue = new Array(newValue.length); - for (var i = 0; i < newValue.length; i++) { - veryOldValue[i] = newValue[i]; - } - } else { - veryOldValue = {}; - for (var key in newValue) { - if (hasOwnProperty.call(newValue, key)) { - veryOldValue[key] = newValue[key]; - } - } - } - } - } - return this.$watch($watchCollectionWatch, $watchCollectionAction); - }, - "$digest": function() { - var watch, value, last, watchers, asyncQueue = this.$$asyncQueue, postDigestQueue = this.$$postDigestQueue, length, dirty, ttl = TTL, next, current, target = this, watchLog = [], logIdx, logMsg, asyncTask; - beginPhase("$digest"); - lastDirtyWatch = null; - do { - dirty = false; - current = target; - while (asyncQueue.length) { - try { - asyncTask = asyncQueue.shift(); - asyncTask.scope.$eval(asyncTask.expression); - } catch (e) { - clearPhase(); - $exceptionHandler(e); - } - lastDirtyWatch = null; - } - traverseScopesLoop: do { - if (watchers = current.$$watchers) { - length = watchers.length; - while (length--) { - try { - watch = watchers[length]; - if (watch) { - if ((value = watch.get(current)) !== (last = watch.last) && !(watch.eq ? equals(value, last) : typeof value === "number" && typeof last === "number" && isNaN(value) && isNaN(last))) { - dirty = true; - lastDirtyWatch = watch; - watch.last = watch.eq ? copy(value, null) : value; - watch.fn(value, last === initWatchVal ? value : last, current); - if (ttl < 5) { - logIdx = 4 - ttl; - if (!watchLog[logIdx]) watchLog[logIdx] = []; - logMsg = isFunction(watch.exp) ? "fn: " + (watch.exp.name || watch.exp.toString()) : watch.exp; - logMsg += "; newVal: " + toJson(value) + "; oldVal: " + toJson(last); - watchLog[logIdx].push(logMsg); - } - } else if (watch === lastDirtyWatch) { - dirty = false; - break traverseScopesLoop; - } - } - } catch (e) { - clearPhase(); - $exceptionHandler(e); - } - } - } - if (!(next = current.$$childHead || current !== target && current.$$nextSibling)) { - while (current !== target && !(next = current.$$nextSibling)) { - current = current.$parent; - } - } - } while (current = next); - if ((dirty || asyncQueue.length) && !ttl--) { - clearPhase(); - throw $rootScopeMinErr("infdig", "{0} $digest() iterations reached. Aborting!\n" + "Watchers fired in the last 5 iterations: {1}", TTL, toJson(watchLog)); - } - } while (dirty || asyncQueue.length); - clearPhase(); - while (postDigestQueue.length) { - try { - postDigestQueue.shift()(); - } catch (e) { - $exceptionHandler(e); - } - } - }, - "$destroy": function() { - if (this.$$destroyed) return; - var parent = this.$parent; - this.$broadcast("$destroy"); - this.$$destroyed = true; - if (this === $rootScope) return; - forEach(this.$$listenerCount, bind(null, decrementListenerCount, this)); - if (parent.$$childHead == this) parent.$$childHead = this.$$nextSibling; - if (parent.$$childTail == this) parent.$$childTail = this.$$prevSibling; - if (this.$$prevSibling) this.$$prevSibling.$$nextSibling = this.$$nextSibling; - if (this.$$nextSibling) this.$$nextSibling.$$prevSibling = this.$$prevSibling; - this.$parent = this.$$nextSibling = this.$$prevSibling = this.$$childHead = this.$$childTail = this.$root = null; - this.$$listeners = {}; - this.$$watchers = this.$$asyncQueue = this.$$postDigestQueue = []; - this.$destroy = this.$digest = this.$apply = noop; - this.$on = this.$watch = function() { - return noop; - }; - }, - "$eval": function(expr, locals) { - return $parse(expr)(this, locals); - }, - "$evalAsync": function(expr) { - if (!$rootScope.$$phase && !$rootScope.$$asyncQueue.length) { - $browser.defer(function() { - if ($rootScope.$$asyncQueue.length) { - $rootScope.$digest(); - } - }); - } - this.$$asyncQueue.push({ - "scope": this, - "expression": expr - }); - }, - "$$postDigest": function(fn) { - this.$$postDigestQueue.push(fn); - }, - "$apply": function(expr) { - try { - beginPhase("$apply"); - return this.$eval(expr); - } catch (e) { - $exceptionHandler(e); - } finally { - clearPhase(); - try { - $rootScope.$digest(); - } catch (e) { - $exceptionHandler(e); - throw e; - } - } - }, - "$on": function(name, listener) { - var namedListeners = this.$$listeners[name]; - if (!namedListeners) { - this.$$listeners[name] = namedListeners = []; - } - namedListeners.push(listener); - var current = this; - do { - if (!current.$$listenerCount[name]) { - current.$$listenerCount[name] = 0; - } - current.$$listenerCount[name]++; - } while (current = current.$parent); - var self = this; - return function() { - namedListeners[indexOf(namedListeners, listener)] = null; - decrementListenerCount(self, 1, name); - }; - }, - "$emit": function(name, args) { - var empty = [], namedListeners, scope = this, stopPropagation = false, event = { - "name": name, - "targetScope": scope, - "stopPropagation": function() { - stopPropagation = true; - }, - "preventDefault": function() { - event.defaultPrevented = true; - }, - "defaultPrevented": false - }, listenerArgs = concat([ event ], arguments, 1), i, length; - do { - namedListeners = scope.$$listeners[name] || empty; - event.currentScope = scope; - for (i = 0, length = namedListeners.length; i < length; i++) { - if (!namedListeners[i]) { - namedListeners.splice(i, 1); - i--; - length--; - continue; - } - try { - namedListeners[i].apply(null, listenerArgs); - } catch (e) { - $exceptionHandler(e); - } - } - if (stopPropagation) return event; - scope = scope.$parent; - } while (scope); - return event; - }, - "$broadcast": function(name, args) { - var target = this, current = target, next = target, event = { - "name": name, - "targetScope": target, - "preventDefault": function() { - event.defaultPrevented = true; - }, - "defaultPrevented": false - }, listenerArgs = concat([ event ], arguments, 1), listeners, i, length; - while (current = next) { - event.currentScope = current; - listeners = current.$$listeners[name] || []; - for (i = 0, length = listeners.length; i < length; i++) { - if (!listeners[i]) { - listeners.splice(i, 1); - i--; - length--; - continue; - } - try { - listeners[i].apply(null, listenerArgs); - } catch (e) { - $exceptionHandler(e); - } - } - if (!(next = current.$$listenerCount[name] && current.$$childHead || current !== target && current.$$nextSibling)) { - while (current !== target && !(next = current.$$nextSibling)) { - current = current.$parent; - } - } - } - return event; - } - }; - var $rootScope = new Scope(); - return $rootScope; - function beginPhase(phase) { - if ($rootScope.$$phase) { - throw $rootScopeMinErr("inprog", "{0} already in progress", $rootScope.$$phase); - } - $rootScope.$$phase = phase; - } - function clearPhase() { - $rootScope.$$phase = null; - } - function compileToFn(exp, name) { - var fn = $parse(exp); - assertArgFn(fn, name); - return fn; - } - function decrementListenerCount(current, count, name) { - do { - current.$$listenerCount[name] -= count; - if (current.$$listenerCount[name] === 0) { - delete current.$$listenerCount[name]; - } - } while (current = current.$parent); - } - function initWatchVal() {} - } ]; - } - function $$SanitizeUriProvider() { - var aHrefSanitizationWhitelist = /^\s*(https?|ftp|mailto|tel|file):/, imgSrcSanitizationWhitelist = /^\s*(https?|ftp|file):|data:image\//; - this.aHrefSanitizationWhitelist = function(regexp) { - if (isDefined(regexp)) { - aHrefSanitizationWhitelist = regexp; - return this; - } - return aHrefSanitizationWhitelist; - }; - this.imgSrcSanitizationWhitelist = function(regexp) { - if (isDefined(regexp)) { - imgSrcSanitizationWhitelist = regexp; - return this; - } - return imgSrcSanitizationWhitelist; - }; - this.$get = function() { - return function sanitizeUri(uri, isImage) { - var regex = isImage ? imgSrcSanitizationWhitelist : aHrefSanitizationWhitelist; - var normalizedVal; - if (!msie || msie >= 8) { - normalizedVal = urlResolve(uri).href; - if (normalizedVal !== "" && !normalizedVal.match(regex)) { - return "unsafe:" + normalizedVal; - } - } - return uri; - }; - }; - } - var $sceMinErr = minErr("$sce"); - var SCE_CONTEXTS = { - "HTML": "html", - "CSS": "css", - "URL": "url", - "RESOURCE_URL": "resourceUrl", - "JS": "js" - }; - function escapeForRegexp(s) { - return s.replace(/([-()\[\]{}+?*.$\^|,:# -1) { - throw $sceMinErr("iwcard", "Illegal sequence *** in string matcher. String: {0}", matcher); - } - matcher = escapeForRegexp(matcher).replace("\\*\\*", ".*").replace("\\*", "[^:/.?&;]*"); - return new RegExp("^" + matcher + "$"); - } else if (isRegExp(matcher)) { - return new RegExp("^" + matcher.source + "$"); - } else { - throw $sceMinErr("imatcher", 'Matchers may only be "self", string patterns or RegExp objects'); - } - } - function adjustMatchers(matchers) { - var adjustedMatchers = []; - if (isDefined(matchers)) { - forEach(matchers, function(matcher) { - adjustedMatchers.push(adjustMatcher(matcher)); - }); - } - return adjustedMatchers; - } - function $SceDelegateProvider() { - this.SCE_CONTEXTS = SCE_CONTEXTS; - var resourceUrlWhitelist = [ "self" ], resourceUrlBlacklist = []; - this.resourceUrlWhitelist = function(value) { - if (arguments.length) { - resourceUrlWhitelist = adjustMatchers(value); - } - return resourceUrlWhitelist; - }; - this.resourceUrlBlacklist = function(value) { - if (arguments.length) { - resourceUrlBlacklist = adjustMatchers(value); - } - return resourceUrlBlacklist; - }; - this.$get = [ "$injector", function($injector) { - var htmlSanitizer = function htmlSanitizer(html) { - throw $sceMinErr("unsafe", "Attempting to use an unsafe value in a safe context."); - }; - if ($injector.has("$sanitize")) { - htmlSanitizer = $injector.get("$sanitize"); - } - function matchUrl(matcher, parsedUrl) { - if (matcher === "self") { - return urlIsSameOrigin(parsedUrl); - } else { - return !!matcher.exec(parsedUrl.href); - } - } - function isResourceUrlAllowedByPolicy(url) { - var parsedUrl = urlResolve(url.toString()); - var i, n, allowed = false; - for (i = 0, n = resourceUrlWhitelist.length; i < n; i++) { - if (matchUrl(resourceUrlWhitelist[i], parsedUrl)) { - allowed = true; - break; - } - } - if (allowed) { - for (i = 0, n = resourceUrlBlacklist.length; i < n; i++) { - if (matchUrl(resourceUrlBlacklist[i], parsedUrl)) { - allowed = false; - break; - } - } - } - return allowed; - } - function generateHolderType(Base) { - var holderType = function TrustedValueHolderType(trustedValue) { - this.$$unwrapTrustedValue = function() { - return trustedValue; - }; - }; - if (Base) { - holderType.prototype = new Base(); - } - holderType.prototype.valueOf = function sceValueOf() { - return this.$$unwrapTrustedValue(); - }; - holderType.prototype.toString = function sceToString() { - return this.$$unwrapTrustedValue().toString(); - }; - return holderType; - } - var trustedValueHolderBase = generateHolderType(), byType = {}; - byType[SCE_CONTEXTS.HTML] = generateHolderType(trustedValueHolderBase); - byType[SCE_CONTEXTS.CSS] = generateHolderType(trustedValueHolderBase); - byType[SCE_CONTEXTS.URL] = generateHolderType(trustedValueHolderBase); - byType[SCE_CONTEXTS.JS] = generateHolderType(trustedValueHolderBase); - byType[SCE_CONTEXTS.RESOURCE_URL] = generateHolderType(byType[SCE_CONTEXTS.URL]); - function trustAs(type, trustedValue) { - var Constructor = byType.hasOwnProperty(type) ? byType[type] : null; - if (!Constructor) { - throw $sceMinErr("icontext", "Attempted to trust a value in invalid context. Context: {0}; Value: {1}", type, trustedValue); - } - if (trustedValue === null || trustedValue === undefined || trustedValue === "") { - return trustedValue; - } - if (typeof trustedValue !== "string") { - throw $sceMinErr("itype", "Attempted to trust a non-string value in a content requiring a string: Context: {0}", type); - } - return new Constructor(trustedValue); - } - function valueOf(maybeTrusted) { - if (maybeTrusted instanceof trustedValueHolderBase) { - return maybeTrusted.$$unwrapTrustedValue(); - } else { - return maybeTrusted; - } - } - function getTrusted(type, maybeTrusted) { - if (maybeTrusted === null || maybeTrusted === undefined || maybeTrusted === "") { - return maybeTrusted; - } - var constructor = byType.hasOwnProperty(type) ? byType[type] : null; - if (constructor && maybeTrusted instanceof constructor) { - return maybeTrusted.$$unwrapTrustedValue(); - } - if (type === SCE_CONTEXTS.RESOURCE_URL) { - if (isResourceUrlAllowedByPolicy(maybeTrusted)) { - return maybeTrusted; - } else { - throw $sceMinErr("insecurl", "Blocked loading resource from url not allowed by $sceDelegate policy. URL: {0}", maybeTrusted.toString()); - } - } else if (type === SCE_CONTEXTS.HTML) { - return htmlSanitizer(maybeTrusted); - } - throw $sceMinErr("unsafe", "Attempting to use an unsafe value in a safe context."); - } - return { - "trustAs": trustAs, - "getTrusted": getTrusted, - "valueOf": valueOf - }; - } ]; - } - function $SceProvider() { - var enabled = true; - this.enabled = function(value) { - if (arguments.length) { - enabled = !!value; - } - return enabled; - }; - this.$get = [ "$parse", "$sniffer", "$sceDelegate", function($parse, $sniffer, $sceDelegate) { - if (enabled && $sniffer.msie && $sniffer.msieDocumentMode < 8) { - throw $sceMinErr("iequirks", "Strict Contextual Escaping does not support Internet Explorer version < 9 in quirks " + "mode. You can fix this by adding the text to the top of your HTML " + "document. See http://docs.angularjs.org/api/ng.$sce for more information."); - } - var sce = shallowCopy(SCE_CONTEXTS); - sce.isEnabled = function() { - return enabled; - }; - sce.trustAs = $sceDelegate.trustAs; - sce.getTrusted = $sceDelegate.getTrusted; - sce.valueOf = $sceDelegate.valueOf; - if (!enabled) { - sce.trustAs = sce.getTrusted = function(type, value) { - return value; - }; - sce.valueOf = identity; - } - sce.parseAs = function sceParseAs(type, expr) { - var parsed = $parse(expr); - if (parsed.literal && parsed.constant) { - return parsed; - } else { - return function sceParseAsTrusted(self, locals) { - return sce.getTrusted(type, parsed(self, locals)); - }; - } - }; - var parse = sce.parseAs, getTrusted = sce.getTrusted, trustAs = sce.trustAs; - forEach(SCE_CONTEXTS, function(enumValue, name) { - var lName = lowercase(name); - sce[camelCase("parse_as_" + lName)] = function(expr) { - return parse(enumValue, expr); - }; - sce[camelCase("get_trusted_" + lName)] = function(value) { - return getTrusted(enumValue, value); - }; - sce[camelCase("trust_as_" + lName)] = function(value) { - return trustAs(enumValue, value); - }; - }); - return sce; - } ]; - } - function $SnifferProvider() { - this.$get = [ "$window", "$document", function($window, $document) { - var eventSupport = {}, android = int((/android (\d+)/.exec(lowercase(($window.navigator || {}).userAgent)) || [])[1]), boxee = /Boxee/i.test(($window.navigator || {}).userAgent), document = $document[0] || {}, documentMode = document.documentMode, vendorPrefix, vendorRegex = /^(Moz|webkit|O|ms)(?=[A-Z])/, bodyStyle = document.body && document.body.style, transitions = false, animations = false, match; - if (bodyStyle) { - for (var prop in bodyStyle) { - if (match = vendorRegex.exec(prop)) { - vendorPrefix = match[0]; - vendorPrefix = vendorPrefix.substr(0, 1).toUpperCase() + vendorPrefix.substr(1); - break; - } - } - if (!vendorPrefix) { - vendorPrefix = "WebkitOpacity" in bodyStyle && "webkit"; - } - transitions = !!("transition" in bodyStyle || vendorPrefix + "Transition" in bodyStyle); - animations = !!("animation" in bodyStyle || vendorPrefix + "Animation" in bodyStyle); - if (android && (!transitions || !animations)) { - transitions = isString(document.body.style.webkitTransition); - animations = isString(document.body.style.webkitAnimation); - } - } - return { - "history": !!($window.history && $window.history.pushState && !(android < 4) && !boxee), - "hashchange": "onhashchange" in $window && (!documentMode || documentMode > 7), - "hasEvent": function(event) { - if (event == "input" && msie == 9) return false; - if (isUndefined(eventSupport[event])) { - var divElm = document.createElement("div"); - eventSupport[event] = "on" + event in divElm; - } - return eventSupport[event]; - }, - "csp": csp(), - "vendorPrefix": vendorPrefix, - "transitions": transitions, - "animations": animations, - "android": android, - "msie": msie, - "msieDocumentMode": documentMode - }; - } ]; - } - function $TimeoutProvider() { - this.$get = [ "$rootScope", "$browser", "$q", "$exceptionHandler", function($rootScope, $browser, $q, $exceptionHandler) { - var deferreds = {}; - function timeout(fn, delay, invokeApply) { - var deferred = $q.defer(), promise = deferred.promise, skipApply = isDefined(invokeApply) && !invokeApply, timeoutId; - timeoutId = $browser.defer(function() { - try { - deferred.resolve(fn()); - } catch (e) { - deferred.reject(e); - $exceptionHandler(e); - } finally { - delete deferreds[promise.$$timeoutId]; - } - if (!skipApply) $rootScope.$apply(); - }, delay); - promise.$$timeoutId = timeoutId; - deferreds[timeoutId] = deferred; - return promise; - } - timeout.cancel = function(promise) { - if (promise && promise.$$timeoutId in deferreds) { - deferreds[promise.$$timeoutId].reject("canceled"); - delete deferreds[promise.$$timeoutId]; - return $browser.defer.cancel(promise.$$timeoutId); - } - return false; - }; - return timeout; - } ]; - } - var urlParsingNode = document.createElement("a"); - var originUrl = urlResolve(window.location.href, true); - function urlResolve(url, base) { - var href = url; - if (msie) { - urlParsingNode.setAttribute("href", href); - href = urlParsingNode.href; - } - urlParsingNode.setAttribute("href", href); - return { - "href": urlParsingNode.href, - "protocol": urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, "") : "", - "host": urlParsingNode.host, - "search": urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, "") : "", - "hash": urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, "") : "", - "hostname": urlParsingNode.hostname, - "port": urlParsingNode.port, - "pathname": urlParsingNode.pathname.charAt(0) === "/" ? urlParsingNode.pathname : "/" + urlParsingNode.pathname - }; - } - function urlIsSameOrigin(requestUrl) { - var parsed = isString(requestUrl) ? urlResolve(requestUrl) : requestUrl; - return parsed.protocol === originUrl.protocol && parsed.host === originUrl.host; - } - function $WindowProvider() { - this.$get = valueFn(window); - } - $FilterProvider.$inject = [ "$provide" ]; - function $FilterProvider($provide) { - var suffix = "Filter"; - function register(name, factory) { - if (isObject(name)) { - var filters = {}; - forEach(name, function(filter, key) { - filters[key] = register(key, filter); - }); - return filters; - } else { - return $provide.factory(name + suffix, factory); - } - } - this.register = register; - this.$get = [ "$injector", function($injector) { - return function(name) { - return $injector.get(name + suffix); - }; - } ]; - register("currency", currencyFilter); - register("date", dateFilter); - register("filter", filterFilter); - register("json", jsonFilter); - register("limitTo", limitToFilter); - register("lowercase", lowercaseFilter); - register("number", numberFilter); - register("orderBy", orderByFilter); - register("uppercase", uppercaseFilter); - } - function filterFilter() { - return function(array, expression, comparator) { - if (!isArray(array)) return array; - var comparatorType = typeof comparator, predicates = []; - predicates.check = function(value) { - for (var j = 0; j < predicates.length; j++) { - if (!predicates[j](value)) { - return false; - } - } - return true; - }; - if (comparatorType !== "function") { - if (comparatorType === "boolean" && comparator) { - comparator = function(obj, text) { - return angular.equals(obj, text); - }; - } else { - comparator = function(obj, text) { - if (obj && text && typeof obj === "object" && typeof text === "object") { - for (var objKey in obj) { - if (objKey.charAt(0) !== "$" && hasOwnProperty.call(obj, objKey) && comparator(obj[objKey], text[objKey])) { - return true; - } - } - return false; - } - text = ("" + text).toLowerCase(); - return ("" + obj).toLowerCase().indexOf(text) > -1; - }; - } - } - var search = function(obj, text) { - if (typeof text == "string" && text.charAt(0) === "!") { - return !search(obj, text.substr(1)); - } - switch (typeof obj) { - case "boolean": - case "number": - case "string": - return comparator(obj, text); - - case "object": - switch (typeof text) { - case "object": - return comparator(obj, text); - - default: - for (var objKey in obj) { - if (objKey.charAt(0) !== "$" && search(obj[objKey], text)) { - return true; - } - } - break; - } - return false; - - case "array": - for (var i = 0; i < obj.length; i++) { - if (search(obj[i], text)) { - return true; - } - } - return false; - - default: - return false; - } - }; - switch (typeof expression) { - case "boolean": - case "number": - case "string": - expression = { - "$": expression - }; - - case "object": - for (var key in expression) { - (function(path) { - if (typeof expression[path] === "undefined") return; - predicates.push(function(value) { - return search(path == "$" ? value : value && value[path], expression[path]); - }); - })(key); - } - break; - - case "function": - predicates.push(expression); - break; - - default: - return array; - } - var filtered = []; - for (var j = 0; j < array.length; j++) { - var value = array[j]; - if (predicates.check(value)) { - filtered.push(value); - } - } - return filtered; - }; - } - currencyFilter.$inject = [ "$locale" ]; - function currencyFilter($locale) { - var formats = $locale.NUMBER_FORMATS; - return function(amount, currencySymbol) { - if (isUndefined(currencySymbol)) currencySymbol = formats.CURRENCY_SYM; - return formatNumber(amount, formats.PATTERNS[1], formats.GROUP_SEP, formats.DECIMAL_SEP, 2).replace(/\u00A4/g, currencySymbol); - }; - } - numberFilter.$inject = [ "$locale" ]; - function numberFilter($locale) { - var formats = $locale.NUMBER_FORMATS; - return function(number, fractionSize) { - return formatNumber(number, formats.PATTERNS[0], formats.GROUP_SEP, formats.DECIMAL_SEP, fractionSize); - }; - } - var DECIMAL_SEP = "."; - function formatNumber(number, pattern, groupSep, decimalSep, fractionSize) { - if (number == null || !isFinite(number) || isObject(number)) return ""; - var isNegative = number < 0; - number = Math.abs(number); - var numStr = number + "", formatedText = "", parts = []; - var hasExponent = false; - if (numStr.indexOf("e") !== -1) { - var match = numStr.match(/([\d\.]+)e(-?)(\d+)/); - if (match && match[2] == "-" && match[3] > fractionSize + 1) { - numStr = "0"; - number = 0; - } else { - formatedText = numStr; - hasExponent = true; - } - } - if (!hasExponent) { - var fractionLen = (numStr.split(DECIMAL_SEP)[1] || "").length; - if (isUndefined(fractionSize)) { - fractionSize = Math.min(Math.max(pattern.minFrac, fractionLen), pattern.maxFrac); - } - number = +(Math.round(+(number.toString() + "e" + fractionSize)).toString() + "e" + -fractionSize); - var fraction = ("" + number).split(DECIMAL_SEP); - var whole = fraction[0]; - fraction = fraction[1] || ""; - var i, pos = 0, lgroup = pattern.lgSize, group = pattern.gSize; - if (whole.length >= lgroup + group) { - pos = whole.length - lgroup; - for (i = 0; i < pos; i++) { - if ((pos - i) % group === 0 && i !== 0) { - formatedText += groupSep; - } - formatedText += whole.charAt(i); - } - } - for (i = pos; i < whole.length; i++) { - if ((whole.length - i) % lgroup === 0 && i !== 0) { - formatedText += groupSep; - } - formatedText += whole.charAt(i); - } - while (fraction.length < fractionSize) { - fraction += "0"; - } - if (fractionSize && fractionSize !== "0") formatedText += decimalSep + fraction.substr(0, fractionSize); - } else { - if (fractionSize > 0 && number > -1 && number < 1) { - formatedText = number.toFixed(fractionSize); - } - } - parts.push(isNegative ? pattern.negPre : pattern.posPre); - parts.push(formatedText); - parts.push(isNegative ? pattern.negSuf : pattern.posSuf); - return parts.join(""); - } - function padNumber(num, digits, trim) { - var neg = ""; - if (num < 0) { - neg = "-"; - num = -num; - } - num = "" + num; - while (num.length < digits) num = "0" + num; - if (trim) num = num.substr(num.length - digits); - return neg + num; - } - function dateGetter(name, size, offset, trim) { - offset = offset || 0; - return function(date) { - var value = date["get" + name](); - if (offset > 0 || value > -offset) value += offset; - if (value === 0 && offset == -12) value = 12; - return padNumber(value, size, trim); - }; - } - function dateStrGetter(name, shortForm) { - return function(date, formats) { - var value = date["get" + name](); - var get = uppercase(shortForm ? "SHORT" + name : name); - return formats[get][value]; - }; - } - function timeZoneGetter(date) { - var zone = -1 * date.getTimezoneOffset(); - var paddedZone = zone >= 0 ? "+" : ""; - paddedZone += padNumber(Math[zone > 0 ? "floor" : "ceil"](zone / 60), 2) + padNumber(Math.abs(zone % 60), 2); - return paddedZone; - } - function ampmGetter(date, formats) { - return date.getHours() < 12 ? formats.AMPMS[0] : formats.AMPMS[1]; - } - var DATE_FORMATS = { - "yyyy": dateGetter("FullYear", 4), - "yy": dateGetter("FullYear", 2, 0, true), - "y": dateGetter("FullYear", 1), - "MMMM": dateStrGetter("Month"), - "MMM": dateStrGetter("Month", true), - "MM": dateGetter("Month", 2, 1), - "M": dateGetter("Month", 1, 1), - "dd": dateGetter("Date", 2), - "d": dateGetter("Date", 1), - "HH": dateGetter("Hours", 2), - "H": dateGetter("Hours", 1), - "hh": dateGetter("Hours", 2, -12), - "h": dateGetter("Hours", 1, -12), - "mm": dateGetter("Minutes", 2), - "m": dateGetter("Minutes", 1), - "ss": dateGetter("Seconds", 2), - "s": dateGetter("Seconds", 1), - "sss": dateGetter("Milliseconds", 3), - "EEEE": dateStrGetter("Day"), - "EEE": dateStrGetter("Day", true), - "a": ampmGetter, - "Z": timeZoneGetter - }; - var DATE_FORMATS_SPLIT = /((?:[^yMdHhmsaZE']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+|H+|h+|m+|s+|a|Z))(.*)/, NUMBER_STRING = /^\-?\d+$/; - dateFilter.$inject = [ "$locale" ]; - function dateFilter($locale) { - var R_ISO8601_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/; - function jsonStringToDate(string) { - var match; - if (match = string.match(R_ISO8601_STR)) { - var date = new Date(0), tzHour = 0, tzMin = 0, dateSetter = match[8] ? date.setUTCFullYear : date.setFullYear, timeSetter = match[8] ? date.setUTCHours : date.setHours; - if (match[9]) { - tzHour = int(match[9] + match[10]); - tzMin = int(match[9] + match[11]); - } - dateSetter.call(date, int(match[1]), int(match[2]) - 1, int(match[3])); - var h = int(match[4] || 0) - tzHour; - var m = int(match[5] || 0) - tzMin; - var s = int(match[6] || 0); - var ms = Math.round(parseFloat("0." + (match[7] || 0)) * 1e3); - timeSetter.call(date, h, m, s, ms); - return date; - } - return string; - } - return function(date, format) { - var text = "", parts = [], fn, match; - format = format || "mediumDate"; - format = $locale.DATETIME_FORMATS[format] || format; - if (isString(date)) { - date = NUMBER_STRING.test(date) ? int(date) : jsonStringToDate(date); - } - if (isNumber(date)) { - date = new Date(date); - } - if (!isDate(date)) { - return date; - } - while (format) { - match = DATE_FORMATS_SPLIT.exec(format); - if (match) { - parts = concat(parts, match, 1); - format = parts.pop(); - } else { - parts.push(format); - format = null; - } - } - forEach(parts, function(value) { - fn = DATE_FORMATS[value]; - text += fn ? fn(date, $locale.DATETIME_FORMATS) : value.replace(/(^'|'$)/g, "").replace(/''/g, "'"); - }); - return text; - }; - } - function jsonFilter() { - return function(object) { - return toJson(object, true); - }; - } - var lowercaseFilter = valueFn(lowercase); - var uppercaseFilter = valueFn(uppercase); - function limitToFilter() { - return function(input, limit) { - if (!isArray(input) && !isString(input)) return input; - if (Math.abs(Number(limit)) === Infinity) { - limit = Number(limit); - } else { - limit = int(limit); - } - if (isString(input)) { - if (limit) { - return limit >= 0 ? input.slice(0, limit) : input.slice(limit, input.length); - } else { - return ""; - } - } - var out = [], i, n; - if (limit > input.length) limit = input.length; else if (limit < -input.length) limit = -input.length; - if (limit > 0) { - i = 0; - n = limit; - } else { - i = input.length + limit; - n = input.length; - } - for (;i < n; i++) { - out.push(input[i]); - } - return out; - }; - } - orderByFilter.$inject = [ "$parse" ]; - function orderByFilter($parse) { - return function(array, sortPredicate, reverseOrder) { - if (!isArray(array)) return array; - if (!sortPredicate) return array; - sortPredicate = isArray(sortPredicate) ? sortPredicate : [ sortPredicate ]; - sortPredicate = map(sortPredicate, function(predicate) { - var descending = false, get = predicate || identity; - if (isString(predicate)) { - if (predicate.charAt(0) == "+" || predicate.charAt(0) == "-") { - descending = predicate.charAt(0) == "-"; - predicate = predicate.substring(1); - } - get = $parse(predicate); - if (get.constant) { - var key = get(); - return reverseComparator(function(a, b) { - return compare(a[key], b[key]); - }, descending); - } - } - return reverseComparator(function(a, b) { - return compare(get(a), get(b)); - }, descending); - }); - var arrayCopy = []; - for (var i = 0; i < array.length; i++) { - arrayCopy.push(array[i]); - } - return arrayCopy.sort(reverseComparator(comparator, reverseOrder)); - function comparator(o1, o2) { - for (var i = 0; i < sortPredicate.length; i++) { - var comp = sortPredicate[i](o1, o2); - if (comp !== 0) return comp; - } - return 0; - } - function reverseComparator(comp, descending) { - return toBoolean(descending) ? function(a, b) { - return comp(b, a); - } : comp; - } - function compare(v1, v2) { - var t1 = typeof v1; - var t2 = typeof v2; - if (t1 == t2) { - if (isDate(v1) && isDate(v2)) { - v1 = v1.valueOf(); - v2 = v2.valueOf(); - } - if (t1 == "string") { - v1 = v1.toLowerCase(); - v2 = v2.toLowerCase(); - } - if (v1 === v2) return 0; - return v1 < v2 ? -1 : 1; - } else { - return t1 < t2 ? -1 : 1; - } - } - }; - } - function ngDirective(directive) { - if (isFunction(directive)) { - directive = { - "link": directive - }; - } - directive.restrict = directive.restrict || "AC"; - return valueFn(directive); - } - var htmlAnchorDirective = valueFn({ - "restrict": "E", - "compile": function(element, attr) { - if (msie <= 8) { - if (!attr.href && !attr.name) { - attr.$set("href", ""); - } - element.append(document.createComment("IE fix")); - } - if (!attr.href && !attr.xlinkHref && !attr.name) { - return function(scope, element) { - var href = toString.call(element.prop("href")) === "[object SVGAnimatedString]" ? "xlink:href" : "href"; - element.on("click", function(event) { - if (!element.attr(href)) { - event.preventDefault(); - } - }); - }; - } - } - }); - var ngAttributeAliasDirectives = {}; - forEach(BOOLEAN_ATTR, function(propName, attrName) { - if (propName == "multiple") return; - var normalized = directiveNormalize("ng-" + attrName); - ngAttributeAliasDirectives[normalized] = function() { - return { - "priority": 100, - "link": function(scope, element, attr) { - scope.$watch(attr[normalized], function ngBooleanAttrWatchAction(value) { - attr.$set(attrName, !!value); - }); - } - }; - }; - }); - forEach([ "src", "srcset", "href" ], function(attrName) { - var normalized = directiveNormalize("ng-" + attrName); - ngAttributeAliasDirectives[normalized] = function() { - return { - "priority": 99, - "link": function(scope, element, attr) { - var propName = attrName, name = attrName; - if (attrName === "href" && toString.call(element.prop("href")) === "[object SVGAnimatedString]") { - name = "xlinkHref"; - attr.$attr[name] = "xlink:href"; - propName = null; - } - attr.$observe(normalized, function(value) { - if (!value) return; - attr.$set(name, value); - if (msie && propName) element.prop(propName, attr[name]); - }); - } - }; - }; - }); - var nullFormCtrl = { - "$addControl": noop, - "$removeControl": noop, - "$setValidity": noop, - "$setDirty": noop, - "$setPristine": noop - }; - FormController.$inject = [ "$element", "$attrs", "$scope", "$animate" ]; - function FormController(element, attrs, $scope, $animate) { - var form = this, parentForm = element.parent().controller("form") || nullFormCtrl, invalidCount = 0, errors = form.$error = {}, controls = []; - form.$name = attrs.name || attrs.ngForm; - form.$dirty = false; - form.$pristine = true; - form.$valid = true; - form.$invalid = false; - parentForm.$addControl(form); - element.addClass(PRISTINE_CLASS); - toggleValidCss(true); - function toggleValidCss(isValid, validationErrorKey) { - validationErrorKey = validationErrorKey ? "-" + snake_case(validationErrorKey, "-") : ""; - $animate.removeClass(element, (isValid ? INVALID_CLASS : VALID_CLASS) + validationErrorKey); - $animate.addClass(element, (isValid ? VALID_CLASS : INVALID_CLASS) + validationErrorKey); - } - form.$addControl = function(control) { - assertNotHasOwnProperty(control.$name, "input"); - controls.push(control); - if (control.$name) { - form[control.$name] = control; - } - }; - form.$removeControl = function(control) { - if (control.$name && form[control.$name] === control) { - delete form[control.$name]; - } - forEach(errors, function(queue, validationToken) { - form.$setValidity(validationToken, true, control); - }); - arrayRemove(controls, control); - }; - form.$setValidity = function(validationToken, isValid, control) { - var queue = errors[validationToken]; - if (isValid) { - if (queue) { - arrayRemove(queue, control); - if (!queue.length) { - invalidCount--; - if (!invalidCount) { - toggleValidCss(isValid); - form.$valid = true; - form.$invalid = false; - } - errors[validationToken] = false; - toggleValidCss(true, validationToken); - parentForm.$setValidity(validationToken, true, form); - } - } - } else { - if (!invalidCount) { - toggleValidCss(isValid); - } - if (queue) { - if (includes(queue, control)) return; - } else { - errors[validationToken] = queue = []; - invalidCount++; - toggleValidCss(false, validationToken); - parentForm.$setValidity(validationToken, false, form); - } - queue.push(control); - form.$valid = false; - form.$invalid = true; - } - }; - form.$setDirty = function() { - $animate.removeClass(element, PRISTINE_CLASS); - $animate.addClass(element, DIRTY_CLASS); - form.$dirty = true; - form.$pristine = false; - parentForm.$setDirty(); - }; - form.$setPristine = function() { - $animate.removeClass(element, DIRTY_CLASS); - $animate.addClass(element, PRISTINE_CLASS); - form.$dirty = false; - form.$pristine = true; - forEach(controls, function(control) { - control.$setPristine(); - }); - }; - } - var formDirectiveFactory = function(isNgForm) { - return [ "$timeout", function($timeout) { - var formDirective = { - "name": "form", - "restrict": isNgForm ? "EAC" : "E", - "controller": FormController, - "compile": function() { - return { - "pre": function(scope, formElement, attr, controller) { - if (!attr.action) { - var preventDefaultListener = function(event) { - event.preventDefault ? event.preventDefault() : event.returnValue = false; - }; - addEventListenerFn(formElement[0], "submit", preventDefaultListener); - formElement.on("$destroy", function() { - $timeout(function() { - removeEventListenerFn(formElement[0], "submit", preventDefaultListener); - }, 0, false); - }); - } - var parentFormCtrl = formElement.parent().controller("form"), alias = attr.name || attr.ngForm; - if (alias) { - setter(scope, alias, controller, alias); - } - if (parentFormCtrl) { - formElement.on("$destroy", function() { - parentFormCtrl.$removeControl(controller); - if (alias) { - setter(scope, alias, undefined, alias); - } - extend(controller, nullFormCtrl); - }); - } - } - }; - } - }; - return formDirective; - } ]; - }; - var formDirective = formDirectiveFactory(); - var ngFormDirective = formDirectiveFactory(true); - var URL_REGEXP = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/; - var EMAIL_REGEXP = /^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i; - var NUMBER_REGEXP = /^\s*(\-|\+)?(\d+|(\d*(\.\d*)))\s*$/; - var inputType = { - "text": textInputType, - "number": numberInputType, - "url": urlInputType, - "email": emailInputType, - "radio": radioInputType, - "checkbox": checkboxInputType, - "hidden": noop, - "button": noop, - "submit": noop, - "reset": noop, - "file": noop - }; - function validate(ctrl, validatorName, validity, value) { - ctrl.$setValidity(validatorName, validity); - return validity ? value : undefined; - } - function testFlags(validity, flags) { - var i, flag; - if (flags) { - for (i = 0; i < flags.length; ++i) { - flag = flags[i]; - if (validity[flag]) { - return true; - } - } - } - return false; - } - function addNativeHtml5Validators(ctrl, validatorName, badFlags, ignoreFlags, validity) { - if (isObject(validity)) { - ctrl.$$hasNativeValidators = true; - var validator = function(value) { - if (!ctrl.$error[validatorName] && !testFlags(validity, ignoreFlags) && testFlags(validity, badFlags)) { - ctrl.$setValidity(validatorName, false); - return; - } - return value; - }; - ctrl.$parsers.push(validator); - } - } - function textInputType(scope, element, attr, ctrl, $sniffer, $browser) { - var validity = element.prop(VALIDITY_STATE_PROPERTY); - var placeholder = element[0].placeholder, noevent = {}; - ctrl.$$validityState = validity; - if (!$sniffer.android) { - var composing = false; - element.on("compositionstart", function(data) { - composing = true; - }); - element.on("compositionend", function() { - composing = false; - listener(); - }); - } - var listener = function(ev) { - if (composing) return; - var value = element.val(); - if (msie && (ev || noevent).type === "input" && element[0].placeholder !== placeholder) { - placeholder = element[0].placeholder; - return; - } - if (toBoolean(attr.ngTrim || "T")) { - value = trim(value); - } - var revalidate = validity && ctrl.$$hasNativeValidators; - if (ctrl.$viewValue !== value || value === "" && revalidate) { - if (scope.$$phase) { - ctrl.$setViewValue(value); - } else { - scope.$apply(function() { - ctrl.$setViewValue(value); - }); - } - } - }; - if ($sniffer.hasEvent("input")) { - element.on("input", listener); - } else { - var timeout; - var deferListener = function() { - if (!timeout) { - timeout = $browser.defer(function() { - listener(); - timeout = null; - }); - } - }; - element.on("keydown", function(event) { - var key = event.keyCode; - if (key === 91 || 15 < key && key < 19 || 37 <= key && key <= 40) return; - deferListener(); - }); - if ($sniffer.hasEvent("paste")) { - element.on("paste cut", deferListener); - } - } - element.on("change", listener); - ctrl.$render = function() { - element.val(ctrl.$isEmpty(ctrl.$viewValue) ? "" : ctrl.$viewValue); - }; - var pattern = attr.ngPattern, patternValidator, match; - if (pattern) { - var validateRegex = function(regexp, value) { - return validate(ctrl, "pattern", ctrl.$isEmpty(value) || regexp.test(value), value); - }; - match = pattern.match(/^\/(.*)\/([gim]*)$/); - if (match) { - pattern = new RegExp(match[1], match[2]); - patternValidator = function(value) { - return validateRegex(pattern, value); - }; - } else { - patternValidator = function(value) { - var patternObj = scope.$eval(pattern); - if (!patternObj || !patternObj.test) { - throw minErr("ngPattern")("noregexp", "Expected {0} to be a RegExp but was {1}. Element: {2}", pattern, patternObj, startingTag(element)); - } - return validateRegex(patternObj, value); - }; - } - ctrl.$formatters.push(patternValidator); - ctrl.$parsers.push(patternValidator); - } - if (attr.ngMinlength) { - var minlength = int(attr.ngMinlength); - var minLengthValidator = function(value) { - return validate(ctrl, "minlength", ctrl.$isEmpty(value) || value.length >= minlength, value); - }; - ctrl.$parsers.push(minLengthValidator); - ctrl.$formatters.push(minLengthValidator); - } - if (attr.ngMaxlength) { - var maxlength = int(attr.ngMaxlength); - var maxLengthValidator = function(value) { - return validate(ctrl, "maxlength", ctrl.$isEmpty(value) || value.length <= maxlength, value); - }; - ctrl.$parsers.push(maxLengthValidator); - ctrl.$formatters.push(maxLengthValidator); - } - } - var numberBadFlags = [ "badInput" ]; - function numberInputType(scope, element, attr, ctrl, $sniffer, $browser) { - textInputType(scope, element, attr, ctrl, $sniffer, $browser); - ctrl.$parsers.push(function(value) { - var empty = ctrl.$isEmpty(value); - if (empty || NUMBER_REGEXP.test(value)) { - ctrl.$setValidity("number", true); - return value === "" ? null : empty ? value : parseFloat(value); - } else { - ctrl.$setValidity("number", false); - return undefined; - } - }); - addNativeHtml5Validators(ctrl, "number", numberBadFlags, null, ctrl.$$validityState); - ctrl.$formatters.push(function(value) { - return ctrl.$isEmpty(value) ? "" : "" + value; - }); - if (attr.min) { - var minValidator = function(value) { - var min = parseFloat(attr.min); - return validate(ctrl, "min", ctrl.$isEmpty(value) || value >= min, value); - }; - ctrl.$parsers.push(minValidator); - ctrl.$formatters.push(minValidator); - } - if (attr.max) { - var maxValidator = function(value) { - var max = parseFloat(attr.max); - return validate(ctrl, "max", ctrl.$isEmpty(value) || value <= max, value); - }; - ctrl.$parsers.push(maxValidator); - ctrl.$formatters.push(maxValidator); - } - ctrl.$formatters.push(function(value) { - return validate(ctrl, "number", ctrl.$isEmpty(value) || isNumber(value), value); - }); - } - function urlInputType(scope, element, attr, ctrl, $sniffer, $browser) { - textInputType(scope, element, attr, ctrl, $sniffer, $browser); - var urlValidator = function(value) { - return validate(ctrl, "url", ctrl.$isEmpty(value) || URL_REGEXP.test(value), value); - }; - ctrl.$formatters.push(urlValidator); - ctrl.$parsers.push(urlValidator); - } - function emailInputType(scope, element, attr, ctrl, $sniffer, $browser) { - textInputType(scope, element, attr, ctrl, $sniffer, $browser); - var emailValidator = function(value) { - return validate(ctrl, "email", ctrl.$isEmpty(value) || EMAIL_REGEXP.test(value), value); - }; - ctrl.$formatters.push(emailValidator); - ctrl.$parsers.push(emailValidator); - } - function radioInputType(scope, element, attr, ctrl) { - if (isUndefined(attr.name)) { - element.attr("name", nextUid()); - } - element.on("click", function() { - if (element[0].checked) { - scope.$apply(function() { - ctrl.$setViewValue(attr.value); - }); - } - }); - ctrl.$render = function() { - var value = attr.value; - element[0].checked = value == ctrl.$viewValue; - }; - attr.$observe("value", ctrl.$render); - } - function checkboxInputType(scope, element, attr, ctrl) { - var trueValue = attr.ngTrueValue, falseValue = attr.ngFalseValue; - if (!isString(trueValue)) trueValue = true; - if (!isString(falseValue)) falseValue = false; - element.on("click", function() { - scope.$apply(function() { - ctrl.$setViewValue(element[0].checked); - }); - }); - ctrl.$render = function() { - element[0].checked = ctrl.$viewValue; - }; - ctrl.$isEmpty = function(value) { - return value !== trueValue; - }; - ctrl.$formatters.push(function(value) { - return value === trueValue; - }); - ctrl.$parsers.push(function(value) { - return value ? trueValue : falseValue; - }); - } - var inputDirective = [ "$browser", "$sniffer", function($browser, $sniffer) { - return { - "restrict": "E", - "require": "?ngModel", - "link": function(scope, element, attr, ctrl) { - if (ctrl) { - (inputType[lowercase(attr.type)] || inputType.text)(scope, element, attr, ctrl, $sniffer, $browser); - } - } - }; - } ]; - var VALID_CLASS = "ng-valid", INVALID_CLASS = "ng-invalid", PRISTINE_CLASS = "ng-pristine", DIRTY_CLASS = "ng-dirty"; - var NgModelController = [ "$scope", "$exceptionHandler", "$attrs", "$element", "$parse", "$animate", function($scope, $exceptionHandler, $attr, $element, $parse, $animate) { - this.$viewValue = Number.NaN; - this.$modelValue = Number.NaN; - this.$parsers = []; - this.$formatters = []; - this.$viewChangeListeners = []; - this.$pristine = true; - this.$dirty = false; - this.$valid = true; - this.$invalid = false; - this.$name = $attr.name; - var ngModelGet = $parse($attr.ngModel), ngModelSet = ngModelGet.assign; - if (!ngModelSet) { - throw minErr("ngModel")("nonassign", "Expression '{0}' is non-assignable. Element: {1}", $attr.ngModel, startingTag($element)); - } - this.$render = noop; - this.$isEmpty = function(value) { - return isUndefined(value) || value === "" || value === null || value !== value; - }; - var parentForm = $element.inheritedData("$formController") || nullFormCtrl, invalidCount = 0, $error = this.$error = {}; - $element.addClass(PRISTINE_CLASS); - toggleValidCss(true); - function toggleValidCss(isValid, validationErrorKey) { - validationErrorKey = validationErrorKey ? "-" + snake_case(validationErrorKey, "-") : ""; - $animate.removeClass($element, (isValid ? INVALID_CLASS : VALID_CLASS) + validationErrorKey); - $animate.addClass($element, (isValid ? VALID_CLASS : INVALID_CLASS) + validationErrorKey); - } - this.$setValidity = function(validationErrorKey, isValid) { - if ($error[validationErrorKey] === !isValid) return; - if (isValid) { - if ($error[validationErrorKey]) invalidCount--; - if (!invalidCount) { - toggleValidCss(true); - this.$valid = true; - this.$invalid = false; - } - } else { - toggleValidCss(false); - this.$invalid = true; - this.$valid = false; - invalidCount++; - } - $error[validationErrorKey] = !isValid; - toggleValidCss(isValid, validationErrorKey); - parentForm.$setValidity(validationErrorKey, isValid, this); - }; - this.$setPristine = function() { - this.$dirty = false; - this.$pristine = true; - $animate.removeClass($element, DIRTY_CLASS); - $animate.addClass($element, PRISTINE_CLASS); - }; - this.$setViewValue = function(value) { - this.$viewValue = value; - if (this.$pristine) { - this.$dirty = true; - this.$pristine = false; - $animate.removeClass($element, PRISTINE_CLASS); - $animate.addClass($element, DIRTY_CLASS); - parentForm.$setDirty(); - } - forEach(this.$parsers, function(fn) { - value = fn(value); - }); - if (this.$modelValue !== value) { - this.$modelValue = value; - ngModelSet($scope, value); - forEach(this.$viewChangeListeners, function(listener) { - try { - listener(); - } catch (e) { - $exceptionHandler(e); - } - }); - } - }; - var ctrl = this; - $scope.$watch(function ngModelWatch() { - var value = ngModelGet($scope); - if (ctrl.$modelValue !== value) { - var formatters = ctrl.$formatters, idx = formatters.length; - ctrl.$modelValue = value; - while (idx--) { - value = formatters[idx](value); - } - if (ctrl.$viewValue !== value) { - ctrl.$viewValue = value; - ctrl.$render(); - } - } - return value; - }); - } ]; - var ngModelDirective = function() { - return { - "require": [ "ngModel", "^?form" ], - "controller": NgModelController, - "link": function(scope, element, attr, ctrls) { - var modelCtrl = ctrls[0], formCtrl = ctrls[1] || nullFormCtrl; - formCtrl.$addControl(modelCtrl); - scope.$on("$destroy", function() { - formCtrl.$removeControl(modelCtrl); - }); - } - }; - }; - var ngChangeDirective = valueFn({ - "require": "ngModel", - "link": function(scope, element, attr, ctrl) { - ctrl.$viewChangeListeners.push(function() { - scope.$eval(attr.ngChange); - }); - } - }); - var requiredDirective = function() { - return { - "require": "?ngModel", - "link": function(scope, elm, attr, ctrl) { - if (!ctrl) return; - attr.required = true; - var validator = function(value) { - if (attr.required && ctrl.$isEmpty(value)) { - ctrl.$setValidity("required", false); - return; - } else { - ctrl.$setValidity("required", true); - return value; - } - }; - ctrl.$formatters.push(validator); - ctrl.$parsers.unshift(validator); - attr.$observe("required", function() { - validator(ctrl.$viewValue); - }); - } - }; - }; - var ngListDirective = function() { - return { - "require": "ngModel", - "link": function(scope, element, attr, ctrl) { - var match = /\/(.*)\//.exec(attr.ngList), separator = match && new RegExp(match[1]) || attr.ngList || ","; - var parse = function(viewValue) { - if (isUndefined(viewValue)) return; - var list = []; - if (viewValue) { - forEach(viewValue.split(separator), function(value) { - if (value) list.push(trim(value)); - }); - } - return list; - }; - ctrl.$parsers.push(parse); - ctrl.$formatters.push(function(value) { - if (isArray(value)) { - return value.join(", "); - } - return undefined; - }); - ctrl.$isEmpty = function(value) { - return !value || !value.length; - }; - } - }; - }; - var CONSTANT_VALUE_REGEXP = /^(true|false|\d+)$/; - var ngValueDirective = function() { - return { - "priority": 100, - "compile": function(tpl, tplAttr) { - if (CONSTANT_VALUE_REGEXP.test(tplAttr.ngValue)) { - return function ngValueConstantLink(scope, elm, attr) { - attr.$set("value", scope.$eval(attr.ngValue)); - }; - } else { - return function ngValueLink(scope, elm, attr) { - scope.$watch(attr.ngValue, function valueWatchAction(value) { - attr.$set("value", value); - }); - }; - } - } - }; - }; - var ngBindDirective = ngDirective({ - "compile": function(templateElement) { - templateElement.addClass("ng-binding"); - return function(scope, element, attr) { - element.data("$binding", attr.ngBind); - scope.$watch(attr.ngBind, function ngBindWatchAction(value) { - element.text(value == undefined ? "" : value); - }); - }; - } - }); - var ngBindTemplateDirective = [ "$interpolate", function($interpolate) { - return function(scope, element, attr) { - var interpolateFn = $interpolate(element.attr(attr.$attr.ngBindTemplate)); - element.addClass("ng-binding").data("$binding", interpolateFn); - attr.$observe("ngBindTemplate", function(value) { - element.text(value); - }); - }; - } ]; - var ngBindHtmlDirective = [ "$sce", "$parse", function($sce, $parse) { - return { - "compile": function(tElement) { - tElement.addClass("ng-binding"); - return function(scope, element, attr) { - element.data("$binding", attr.ngBindHtml); - var parsed = $parse(attr.ngBindHtml); - function getStringValue() { - return (parsed(scope) || "").toString(); - } - scope.$watch(getStringValue, function ngBindHtmlWatchAction(value) { - element.html($sce.getTrustedHtml(parsed(scope)) || ""); - }); - }; - } - }; - } ]; - function classDirective(name, selector) { - name = "ngClass" + name; - return [ "$animate", function($animate) { - return { - "restrict": "AC", - "link": function(scope, element, attr) { - var oldVal; - scope.$watch(attr[name], ngClassWatchAction, true); - attr.$observe("class", function(value) { - ngClassWatchAction(scope.$eval(attr[name])); - }); - if (name !== "ngClass") { - scope.$watch("$index", function($index, old$index) { - var mod = $index & 1; - if (mod !== (old$index & 1)) { - var classes = arrayClasses(scope.$eval(attr[name])); - mod === selector ? addClasses(classes) : removeClasses(classes); - } - }); - } - function addClasses(classes) { - var newClasses = digestClassCounts(classes, 1); - attr.$addClass(newClasses); - } - function removeClasses(classes) { - var newClasses = digestClassCounts(classes, -1); - attr.$removeClass(newClasses); - } - function digestClassCounts(classes, count) { - var classCounts = element.data("$classCounts") || {}; - var classesToUpdate = []; - forEach(classes, function(className) { - if (count > 0 || classCounts[className]) { - classCounts[className] = (classCounts[className] || 0) + count; - if (classCounts[className] === +(count > 0)) { - classesToUpdate.push(className); - } - } - }); - element.data("$classCounts", classCounts); - return classesToUpdate.join(" "); - } - function updateClasses(oldClasses, newClasses) { - var toAdd = arrayDifference(newClasses, oldClasses); - var toRemove = arrayDifference(oldClasses, newClasses); - toRemove = digestClassCounts(toRemove, -1); - toAdd = digestClassCounts(toAdd, 1); - if (toAdd.length === 0) { - $animate.removeClass(element, toRemove); - } else if (toRemove.length === 0) { - $animate.addClass(element, toAdd); - } else { - $animate.setClass(element, toAdd, toRemove); - } - } - function ngClassWatchAction(newVal) { - if (selector === true || scope.$index % 2 === selector) { - var newClasses = arrayClasses(newVal || []); - if (!oldVal) { - addClasses(newClasses); - } else if (!equals(newVal, oldVal)) { - var oldClasses = arrayClasses(oldVal); - updateClasses(oldClasses, newClasses); - } - } - oldVal = shallowCopy(newVal); - } - } - }; - function arrayDifference(tokens1, tokens2) { - var values = []; - outer: for (var i = 0; i < tokens1.length; i++) { - var token = tokens1[i]; - for (var j = 0; j < tokens2.length; j++) { - if (token == tokens2[j]) continue outer; - } - values.push(token); - } - return values; - } - function arrayClasses(classVal) { - if (isArray(classVal)) { - return classVal; - } else if (isString(classVal)) { - return classVal.split(" "); - } else if (isObject(classVal)) { - var classes = [], i = 0; - forEach(classVal, function(v, k) { - if (v) { - classes = classes.concat(k.split(" ")); - } - }); - return classes; - } - return classVal; - } - } ]; - } - var ngClassDirective = classDirective("", true); - var ngClassOddDirective = classDirective("Odd", 0); - var ngClassEvenDirective = classDirective("Even", 1); - var ngCloakDirective = ngDirective({ - "compile": function(element, attr) { - attr.$set("ngCloak", undefined); - element.removeClass("ng-cloak"); - } - }); - var ngControllerDirective = [ function() { - return { - "scope": true, - "controller": "@", - "priority": 500 - }; - } ]; - var ngEventDirectives = {}; - forEach("click dblclick mousedown mouseup mouseover mouseout mousemove mouseenter mouseleave keydown keyup keypress submit focus blur copy cut paste".split(" "), function(name) { - var directiveName = directiveNormalize("ng-" + name); - ngEventDirectives[directiveName] = [ "$parse", function($parse) { - return { - "compile": function($element, attr) { - var fn = $parse(attr[directiveName]); - return function ngEventHandler(scope, element) { - element.on(lowercase(name), function(event) { - scope.$apply(function() { - fn(scope, { - "$event": event - }); - }); - }); - }; - } - }; - } ]; - }); - var ngIfDirective = [ "$animate", function($animate) { - return { - "transclude": "element", - "priority": 600, - "terminal": true, - "restrict": "A", - "$$tlb": true, - "link": function($scope, $element, $attr, ctrl, $transclude) { - var block, childScope, previousElements; - $scope.$watch($attr.ngIf, function ngIfWatchAction(value) { - if (toBoolean(value)) { - if (!childScope) { - childScope = $scope.$new(); - $transclude(childScope, function(clone) { - clone[clone.length++] = document.createComment(" end ngIf: " + $attr.ngIf + " "); - block = { - "clone": clone - }; - $animate.enter(clone, $element.parent(), $element); - }); - } - } else { - if (previousElements) { - previousElements.remove(); - previousElements = null; - } - if (childScope) { - childScope.$destroy(); - childScope = null; - } - if (block) { - previousElements = getBlockElements(block.clone); - $animate.leave(previousElements, function() { - previousElements = null; - }); - block = null; - } - } - }); - } - }; - } ]; - var ngIncludeDirective = [ "$http", "$templateCache", "$anchorScroll", "$animate", "$sce", function($http, $templateCache, $anchorScroll, $animate, $sce) { - return { - "restrict": "ECA", - "priority": 400, - "terminal": true, - "transclude": "element", - "controller": angular.noop, - "compile": function(element, attr) { - var srcExp = attr.ngInclude || attr.src, onloadExp = attr.onload || "", autoScrollExp = attr.autoscroll; - return function(scope, $element, $attr, ctrl, $transclude) { - var changeCounter = 0, currentScope, previousElement, currentElement; - var cleanupLastIncludeContent = function() { - if (previousElement) { - previousElement.remove(); - previousElement = null; - } - if (currentScope) { - currentScope.$destroy(); - currentScope = null; - } - if (currentElement) { - $animate.leave(currentElement, function() { - previousElement = null; - }); - previousElement = currentElement; - currentElement = null; - } - }; - scope.$watch($sce.parseAsResourceUrl(srcExp), function ngIncludeWatchAction(src) { - var afterAnimation = function() { - if (isDefined(autoScrollExp) && (!autoScrollExp || scope.$eval(autoScrollExp))) { - $anchorScroll(); - } - }; - var thisChangeId = ++changeCounter; - if (src) { - $http.get(src, { - "cache": $templateCache - }).success(function(response) { - if (thisChangeId !== changeCounter) return; - var newScope = scope.$new(); - ctrl.template = response; - var clone = $transclude(newScope, function(clone) { - cleanupLastIncludeContent(); - $animate.enter(clone, null, $element, afterAnimation); - }); - currentScope = newScope; - currentElement = clone; - currentScope.$emit("$includeContentLoaded"); - scope.$eval(onloadExp); - }).error(function() { - if (thisChangeId === changeCounter) cleanupLastIncludeContent(); - }); - scope.$emit("$includeContentRequested"); - } else { - cleanupLastIncludeContent(); - ctrl.template = null; - } - }); - }; - } - }; - } ]; - var ngIncludeFillContentDirective = [ "$compile", function($compile) { - return { - "restrict": "ECA", - "priority": -400, - "require": "ngInclude", - "link": function(scope, $element, $attr, ctrl) { - $element.html(ctrl.template); - $compile($element.contents())(scope); - } - }; - } ]; - var ngInitDirective = ngDirective({ - "priority": 450, - "compile": function() { - return { - "pre": function(scope, element, attrs) { - scope.$eval(attrs.ngInit); - } - }; - } - }); - var ngNonBindableDirective = ngDirective({ - "terminal": true, - "priority": 1e3 - }); - var ngPluralizeDirective = [ "$locale", "$interpolate", function($locale, $interpolate) { - var BRACE = /{}/g; - return { - "restrict": "EA", - "link": function(scope, element, attr) { - var numberExp = attr.count, whenExp = attr.$attr.when && element.attr(attr.$attr.when), offset = attr.offset || 0, whens = scope.$eval(whenExp) || {}, whensExpFns = {}, startSymbol = $interpolate.startSymbol(), endSymbol = $interpolate.endSymbol(), isWhen = /^when(Minus)?(.+)$/; - forEach(attr, function(expression, attributeName) { - if (isWhen.test(attributeName)) { - whens[lowercase(attributeName.replace("when", "").replace("Minus", "-"))] = element.attr(attr.$attr[attributeName]); - } - }); - forEach(whens, function(expression, key) { - whensExpFns[key] = $interpolate(expression.replace(BRACE, startSymbol + numberExp + "-" + offset + endSymbol)); - }); - scope.$watch(function ngPluralizeWatch() { - var value = parseFloat(scope.$eval(numberExp)); - if (!isNaN(value)) { - if (!(value in whens)) value = $locale.pluralCat(value - offset); - return whensExpFns[value](scope, element, true); - } else { - return ""; - } - }, function ngPluralizeWatchAction(newVal) { - element.text(newVal); - }); - } - }; - } ]; - var ngRepeatDirective = [ "$parse", "$animate", function($parse, $animate) { - var NG_REMOVED = "$$NG_REMOVED"; - var ngRepeatMinErr = minErr("ngRepeat"); - return { - "transclude": "element", - "priority": 1e3, - "terminal": true, - "$$tlb": true, - "link": function($scope, $element, $attr, ctrl, $transclude) { - var expression = $attr.ngRepeat; - var match = expression.match(/^\s*([\s\S]+?)\s+in\s+([\s\S]+?)(?:\s+track\s+by\s+([\s\S]+?))?\s*$/), trackByExp, trackByExpGetter, trackByIdExpFn, trackByIdArrayFn, trackByIdObjFn, lhs, rhs, valueIdentifier, keyIdentifier, hashFnLocals = { - "$id": hashKey - }; - if (!match) { - throw ngRepeatMinErr("iexp", "Expected expression in form of '_item_ in _collection_[ track by _id_]' but got '{0}'.", expression); - } - lhs = match[1]; - rhs = match[2]; - trackByExp = match[3]; - if (trackByExp) { - trackByExpGetter = $parse(trackByExp); - trackByIdExpFn = function(key, value, index) { - if (keyIdentifier) hashFnLocals[keyIdentifier] = key; - hashFnLocals[valueIdentifier] = value; - hashFnLocals.$index = index; - return trackByExpGetter($scope, hashFnLocals); - }; - } else { - trackByIdArrayFn = function(key, value) { - return hashKey(value); - }; - trackByIdObjFn = function(key) { - return key; - }; - } - match = lhs.match(/^(?:([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\))$/); - if (!match) { - throw ngRepeatMinErr("iidexp", "'_item_' in '_item_ in _collection_' should be an identifier or '(_key_, _value_)' expression, but got '{0}'.", lhs); - } - valueIdentifier = match[3] || match[1]; - keyIdentifier = match[2]; - var lastBlockMap = {}; - $scope.$watchCollection(rhs, function ngRepeatAction(collection) { - var index, length, previousNode = $element[0], nextNode, nextBlockMap = {}, arrayLength, childScope, key, value, trackById, trackByIdFn, collectionKeys, block, nextBlockOrder = [], elementsToRemove; - if (isArrayLike(collection)) { - collectionKeys = collection; - trackByIdFn = trackByIdExpFn || trackByIdArrayFn; - } else { - trackByIdFn = trackByIdExpFn || trackByIdObjFn; - collectionKeys = []; - for (key in collection) { - if (collection.hasOwnProperty(key) && key.charAt(0) != "$") { - collectionKeys.push(key); - } - } - collectionKeys.sort(); - } - arrayLength = collectionKeys.length; - length = nextBlockOrder.length = collectionKeys.length; - for (index = 0; index < length; index++) { - key = collection === collectionKeys ? index : collectionKeys[index]; - value = collection[key]; - trackById = trackByIdFn(key, value, index); - assertNotHasOwnProperty(trackById, "`track by` id"); - if (lastBlockMap.hasOwnProperty(trackById)) { - block = lastBlockMap[trackById]; - delete lastBlockMap[trackById]; - nextBlockMap[trackById] = block; - nextBlockOrder[index] = block; - } else if (nextBlockMap.hasOwnProperty(trackById)) { - forEach(nextBlockOrder, function(block) { - if (block && block.scope) lastBlockMap[block.id] = block; - }); - throw ngRepeatMinErr("dupes", "Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: {0}, Duplicate key: {1}", expression, trackById); - } else { - nextBlockOrder[index] = { - "id": trackById - }; - nextBlockMap[trackById] = false; - } - } - for (key in lastBlockMap) { - if (lastBlockMap.hasOwnProperty(key)) { - block = lastBlockMap[key]; - elementsToRemove = getBlockElements(block.clone); - $animate.leave(elementsToRemove); - forEach(elementsToRemove, function(element) { - element[NG_REMOVED] = true; - }); - block.scope.$destroy(); - } - } - for (index = 0, length = collectionKeys.length; index < length; index++) { - key = collection === collectionKeys ? index : collectionKeys[index]; - value = collection[key]; - block = nextBlockOrder[index]; - if (nextBlockOrder[index - 1]) previousNode = getBlockEnd(nextBlockOrder[index - 1]); - if (block.scope) { - childScope = block.scope; - nextNode = previousNode; - do { - nextNode = nextNode.nextSibling; - } while (nextNode && nextNode[NG_REMOVED]); - if (getBlockStart(block) != nextNode) { - $animate.move(getBlockElements(block.clone), null, jqLite(previousNode)); - } - previousNode = getBlockEnd(block); - } else { - childScope = $scope.$new(); - } - childScope[valueIdentifier] = value; - if (keyIdentifier) childScope[keyIdentifier] = key; - childScope.$index = index; - childScope.$first = index === 0; - childScope.$last = index === arrayLength - 1; - childScope.$middle = !(childScope.$first || childScope.$last); - childScope.$odd = !(childScope.$even = (index & 1) === 0); - if (!block.scope) { - $transclude(childScope, function(clone) { - clone[clone.length++] = document.createComment(" end ngRepeat: " + expression + " "); - $animate.enter(clone, null, jqLite(previousNode)); - previousNode = clone; - block.scope = childScope; - block.clone = clone; - nextBlockMap[block.id] = block; - }); - } - } - lastBlockMap = nextBlockMap; - }); - } - }; - function getBlockStart(block) { - return block.clone[0]; - } - function getBlockEnd(block) { - return block.clone[block.clone.length - 1]; - } - } ]; - var ngShowDirective = [ "$animate", function($animate) { - return function(scope, element, attr) { - scope.$watch(attr.ngShow, function ngShowWatchAction(value) { - $animate[toBoolean(value) ? "removeClass" : "addClass"](element, "ng-hide"); - }); - }; - } ]; - var ngHideDirective = [ "$animate", function($animate) { - return function(scope, element, attr) { - scope.$watch(attr.ngHide, function ngHideWatchAction(value) { - $animate[toBoolean(value) ? "addClass" : "removeClass"](element, "ng-hide"); - }); - }; - } ]; - var ngStyleDirective = ngDirective(function(scope, element, attr) { - scope.$watch(attr.ngStyle, function ngStyleWatchAction(newStyles, oldStyles) { - if (oldStyles && newStyles !== oldStyles) { - forEach(oldStyles, function(val, style) { - element.css(style, ""); - }); - } - if (newStyles) element.css(newStyles); - }, true); - }); - var ngSwitchDirective = [ "$animate", function($animate) { - return { - "restrict": "EA", - "require": "ngSwitch", - "controller": [ "$scope", function ngSwitchController() { - this.cases = {}; - } ], - "link": function(scope, element, attr, ngSwitchController) { - var watchExpr = attr.ngSwitch || attr.on, selectedTranscludes = [], selectedElements = [], previousElements = [], selectedScopes = []; - scope.$watch(watchExpr, function ngSwitchWatchAction(value) { - var i, ii; - for (i = 0, ii = previousElements.length; i < ii; ++i) { - previousElements[i].remove(); - } - previousElements.length = 0; - for (i = 0, ii = selectedScopes.length; i < ii; ++i) { - var selected = selectedElements[i]; - selectedScopes[i].$destroy(); - previousElements[i] = selected; - $animate.leave(selected, function() { - previousElements.splice(i, 1); - }); - } - selectedElements.length = 0; - selectedScopes.length = 0; - if (selectedTranscludes = ngSwitchController.cases["!" + value] || ngSwitchController.cases["?"]) { - scope.$eval(attr.change); - forEach(selectedTranscludes, function(selectedTransclude) { - var selectedScope = scope.$new(); - selectedScopes.push(selectedScope); - selectedTransclude.transclude(selectedScope, function(caseElement) { - var anchor = selectedTransclude.element; - selectedElements.push(caseElement); - $animate.enter(caseElement, anchor.parent(), anchor); - }); - }); - } - }); - } - }; - } ]; - var ngSwitchWhenDirective = ngDirective({ - "transclude": "element", - "priority": 800, - "require": "^ngSwitch", - "link": function(scope, element, attrs, ctrl, $transclude) { - ctrl.cases["!" + attrs.ngSwitchWhen] = ctrl.cases["!" + attrs.ngSwitchWhen] || []; - ctrl.cases["!" + attrs.ngSwitchWhen].push({ - "transclude": $transclude, - "element": element - }); - } - }); - var ngSwitchDefaultDirective = ngDirective({ - "transclude": "element", - "priority": 800, - "require": "^ngSwitch", - "link": function(scope, element, attr, ctrl, $transclude) { - ctrl.cases["?"] = ctrl.cases["?"] || []; - ctrl.cases["?"].push({ - "transclude": $transclude, - "element": element - }); - } - }); - var ngTranscludeDirective = ngDirective({ - "link": function($scope, $element, $attrs, controller, $transclude) { - if (!$transclude) { - throw minErr("ngTransclude")("orphan", "Illegal use of ngTransclude directive in the template! " + "No parent directive that requires a transclusion found. " + "Element: {0}", startingTag($element)); - } - $transclude(function(clone) { - $element.empty(); - $element.append(clone); - }); - } - }); - var scriptDirective = [ "$templateCache", function($templateCache) { - return { - "restrict": "E", - "terminal": true, - "compile": function(element, attr) { - if (attr.type == "text/ng-template") { - var templateUrl = attr.id, text = element[0].text; - $templateCache.put(templateUrl, text); - } - } - }; - } ]; - var ngOptionsMinErr = minErr("ngOptions"); - var ngOptionsDirective = valueFn({ - "terminal": true - }); - var selectDirective = [ "$compile", "$parse", function($compile, $parse) { - var NG_OPTIONS_REGEXP = /^\s*([\s\S]+?)(?:\s+as\s+([\s\S]+?))?(?:\s+group\s+by\s+([\s\S]+?))?\s+for\s+(?:([\$\w][\$\w]*)|(?:\(\s*([\$\w][\$\w]*)\s*,\s*([\$\w][\$\w]*)\s*\)))\s+in\s+([\s\S]+?)(?:\s+track\s+by\s+([\s\S]+?))?$/, nullModelCtrl = { - "$setViewValue": noop - }; - return { - "restrict": "E", - "require": [ "select", "?ngModel" ], - "controller": [ "$element", "$scope", "$attrs", function($element, $scope, $attrs) { - var self = this, optionsMap = {}, ngModelCtrl = nullModelCtrl, nullOption, unknownOption; - self.databound = $attrs.ngModel; - self.init = function(ngModelCtrl_, nullOption_, unknownOption_) { - ngModelCtrl = ngModelCtrl_; - nullOption = nullOption_; - unknownOption = unknownOption_; - }; - self.addOption = function(value) { - assertNotHasOwnProperty(value, '"option value"'); - optionsMap[value] = true; - if (ngModelCtrl.$viewValue == value) { - $element.val(value); - if (unknownOption.parent()) unknownOption.remove(); - } - }; - self.removeOption = function(value) { - if (this.hasOption(value)) { - delete optionsMap[value]; - if (ngModelCtrl.$viewValue == value) { - this.renderUnknownOption(value); - } - } - }; - self.renderUnknownOption = function(val) { - var unknownVal = "? " + hashKey(val) + " ?"; - unknownOption.val(unknownVal); - $element.prepend(unknownOption); - $element.val(unknownVal); - unknownOption.prop("selected", true); - }; - self.hasOption = function(value) { - return optionsMap.hasOwnProperty(value); - }; - $scope.$on("$destroy", function() { - self.renderUnknownOption = noop; - }); - } ], - "link": function(scope, element, attr, ctrls) { - if (!ctrls[1]) return; - var selectCtrl = ctrls[0], ngModelCtrl = ctrls[1], multiple = attr.multiple, optionsExp = attr.ngOptions, nullOption = false, emptyOption, optionTemplate = jqLite(document.createElement("option")), optGroupTemplate = jqLite(document.createElement("optgroup")), unknownOption = optionTemplate.clone(); - for (var i = 0, children = element.children(), ii = children.length; i < ii; i++) { - if (children[i].value === "") { - emptyOption = nullOption = children.eq(i); - break; - } - } - selectCtrl.init(ngModelCtrl, nullOption, unknownOption); - if (multiple) { - ngModelCtrl.$isEmpty = function(value) { - return !value || value.length === 0; - }; - } - if (optionsExp) setupAsOptions(scope, element, ngModelCtrl); else if (multiple) setupAsMultiple(scope, element, ngModelCtrl); else setupAsSingle(scope, element, ngModelCtrl, selectCtrl); - function setupAsSingle(scope, selectElement, ngModelCtrl, selectCtrl) { - ngModelCtrl.$render = function() { - var viewValue = ngModelCtrl.$viewValue; - if (selectCtrl.hasOption(viewValue)) { - if (unknownOption.parent()) unknownOption.remove(); - selectElement.val(viewValue); - if (viewValue === "") emptyOption.prop("selected", true); - } else { - if (isUndefined(viewValue) && emptyOption) { - selectElement.val(""); - } else { - selectCtrl.renderUnknownOption(viewValue); - } - } - }; - selectElement.on("change", function() { - scope.$apply(function() { - if (unknownOption.parent()) unknownOption.remove(); - ngModelCtrl.$setViewValue(selectElement.val()); - }); - }); - } - function setupAsMultiple(scope, selectElement, ctrl) { - var lastView; - ctrl.$render = function() { - var items = new HashMap(ctrl.$viewValue); - forEach(selectElement.find("option"), function(option) { - option.selected = isDefined(items.get(option.value)); - }); - }; - scope.$watch(function selectMultipleWatch() { - if (!equals(lastView, ctrl.$viewValue)) { - lastView = shallowCopy(ctrl.$viewValue); - ctrl.$render(); - } - }); - selectElement.on("change", function() { - scope.$apply(function() { - var array = []; - forEach(selectElement.find("option"), function(option) { - if (option.selected) { - array.push(option.value); - } - }); - ctrl.$setViewValue(array); - }); - }); - } - function setupAsOptions(scope, selectElement, ctrl) { - var match; - if (!(match = optionsExp.match(NG_OPTIONS_REGEXP))) { - throw ngOptionsMinErr("iexp", "Expected expression in form of " + "'_select_ (as _label_)? for (_key_,)?_value_ in _collection_'" + " but got '{0}'. Element: {1}", optionsExp, startingTag(selectElement)); - } - var displayFn = $parse(match[2] || match[1]), valueName = match[4] || match[6], keyName = match[5], groupByFn = $parse(match[3] || ""), valueFn = $parse(match[2] ? match[1] : valueName), valuesFn = $parse(match[7]), track = match[8], trackFn = track ? $parse(match[8]) : null, optionGroupsCache = [ [ { - "element": selectElement, - "label": "" - } ] ]; - if (nullOption) { - $compile(nullOption)(scope); - nullOption.removeClass("ng-scope"); - nullOption.remove(); - } - selectElement.empty(); - selectElement.on("change", function() { - scope.$apply(function() { - var optionGroup, collection = valuesFn(scope) || [], locals = {}, key, value, optionElement, index, groupIndex, length, groupLength, trackIndex; - if (multiple) { - value = []; - for (groupIndex = 0, groupLength = optionGroupsCache.length; groupIndex < groupLength; groupIndex++) { - optionGroup = optionGroupsCache[groupIndex]; - for (index = 1, length = optionGroup.length; index < length; index++) { - if ((optionElement = optionGroup[index].element)[0].selected) { - key = optionElement.val(); - if (keyName) locals[keyName] = key; - if (trackFn) { - for (trackIndex = 0; trackIndex < collection.length; trackIndex++) { - locals[valueName] = collection[trackIndex]; - if (trackFn(scope, locals) == key) break; - } - } else { - locals[valueName] = collection[key]; - } - value.push(valueFn(scope, locals)); - } - } - } - } else { - key = selectElement.val(); - if (key == "?") { - value = undefined; - } else if (key === "") { - value = null; - } else { - if (trackFn) { - for (trackIndex = 0; trackIndex < collection.length; trackIndex++) { - locals[valueName] = collection[trackIndex]; - if (trackFn(scope, locals) == key) { - value = valueFn(scope, locals); - break; - } - } - } else { - locals[valueName] = collection[key]; - if (keyName) locals[keyName] = key; - value = valueFn(scope, locals); - } - } - } - ctrl.$setViewValue(value); - render(); - }); - }); - ctrl.$render = render; - scope.$watchCollection(valuesFn, render); - if (multiple) { - scope.$watchCollection(function() { - return ctrl.$modelValue; - }, render); - } - function getSelectedSet() { - var selectedSet = false; - if (multiple) { - var modelValue = ctrl.$modelValue; - if (trackFn && isArray(modelValue)) { - selectedSet = new HashMap([]); - var locals = {}; - for (var trackIndex = 0; trackIndex < modelValue.length; trackIndex++) { - locals[valueName] = modelValue[trackIndex]; - selectedSet.put(trackFn(scope, locals), modelValue[trackIndex]); - } - } else { - selectedSet = new HashMap(modelValue); - } - } - return selectedSet; - } - function render() { - var optionGroups = { - "": [] - }, optionGroupNames = [ "" ], optionGroupName, optionGroup, option, existingParent, existingOptions, existingOption, modelValue = ctrl.$modelValue, values = valuesFn(scope) || [], keys = keyName ? sortedKeys(values) : values, key, groupLength, length, groupIndex, index, locals = {}, selected, selectedSet = getSelectedSet(), lastElement, element, label; - for (index = 0; length = keys.length, index < length; index++) { - key = index; - if (keyName) { - key = keys[index]; - if (key.charAt(0) === "$") continue; - locals[keyName] = key; - } - locals[valueName] = values[key]; - optionGroupName = groupByFn(scope, locals) || ""; - if (!(optionGroup = optionGroups[optionGroupName])) { - optionGroup = optionGroups[optionGroupName] = []; - optionGroupNames.push(optionGroupName); - } - if (multiple) { - selected = isDefined(selectedSet.remove(trackFn ? trackFn(scope, locals) : valueFn(scope, locals))); - } else { - if (trackFn) { - var modelCast = {}; - modelCast[valueName] = modelValue; - selected = trackFn(scope, modelCast) === trackFn(scope, locals); - } else { - selected = modelValue === valueFn(scope, locals); - } - selectedSet = selectedSet || selected; - } - label = displayFn(scope, locals); - label = isDefined(label) ? label : ""; - optionGroup.push({ - "id": trackFn ? trackFn(scope, locals) : keyName ? keys[index] : index, - "label": label, - "selected": selected - }); - } - if (!multiple) { - if (nullOption || modelValue === null) { - optionGroups[""].unshift({ - "id": "", - "label": "", - "selected": !selectedSet - }); - } else if (!selectedSet) { - optionGroups[""].unshift({ - "id": "?", - "label": "", - "selected": true - }); - } - } - for (groupIndex = 0, groupLength = optionGroupNames.length; groupIndex < groupLength; groupIndex++) { - optionGroupName = optionGroupNames[groupIndex]; - optionGroup = optionGroups[optionGroupName]; - if (optionGroupsCache.length <= groupIndex) { - existingParent = { - "element": optGroupTemplate.clone().attr("label", optionGroupName), - "label": optionGroup.label - }; - existingOptions = [ existingParent ]; - optionGroupsCache.push(existingOptions); - selectElement.append(existingParent.element); - } else { - existingOptions = optionGroupsCache[groupIndex]; - existingParent = existingOptions[0]; - if (existingParent.label != optionGroupName) { - existingParent.element.attr("label", existingParent.label = optionGroupName); - } - } - lastElement = null; - for (index = 0, length = optionGroup.length; index < length; index++) { - option = optionGroup[index]; - if (existingOption = existingOptions[index + 1]) { - lastElement = existingOption.element; - if (existingOption.label !== option.label) { - lastElement.text(existingOption.label = option.label); - } - if (existingOption.id !== option.id) { - lastElement.val(existingOption.id = option.id); - } - if (lastElement[0].selected !== option.selected) { - lastElement.prop("selected", existingOption.selected = option.selected); - if (msie) { - lastElement.prop("selected", existingOption.selected); - } - } - } else { - if (option.id === "" && nullOption) { - element = nullOption; - } else { - (element = optionTemplate.clone()).val(option.id).prop("selected", option.selected).attr("selected", option.selected).text(option.label); - } - existingOptions.push(existingOption = { - "element": element, - "label": option.label, - "id": option.id, - "selected": option.selected - }); - if (lastElement) { - lastElement.after(element); - } else { - existingParent.element.append(element); - } - lastElement = element; - } - } - index++; - while (existingOptions.length > index) { - existingOptions.pop().element.remove(); - } - } - while (optionGroupsCache.length > groupIndex) { - optionGroupsCache.pop()[0].element.remove(); - } - } - } - } - }; - } ]; - var optionDirective = [ "$interpolate", function($interpolate) { - var nullSelectCtrl = { - "addOption": noop, - "removeOption": noop - }; - return { - "restrict": "E", - "priority": 100, - "compile": function(element, attr) { - if (isUndefined(attr.value)) { - var interpolateFn = $interpolate(element.text(), true); - if (!interpolateFn) { - attr.$set("value", element.text()); - } - } - return function(scope, element, attr) { - var selectCtrlName = "$selectController", parent = element.parent(), selectCtrl = parent.data(selectCtrlName) || parent.parent().data(selectCtrlName); - if (selectCtrl && selectCtrl.databound) { - element.prop("selected", false); - } else { - selectCtrl = nullSelectCtrl; - } - if (interpolateFn) { - scope.$watch(interpolateFn, function interpolateWatchAction(newVal, oldVal) { - attr.$set("value", newVal); - if (newVal !== oldVal) selectCtrl.removeOption(oldVal); - selectCtrl.addOption(newVal); - }); - } else { - selectCtrl.addOption(attr.value); - } - element.on("$destroy", function() { - selectCtrl.removeOption(attr.value); - }); - }; - } - }; - } ]; - var styleDirective = valueFn({ - "restrict": "E", - "terminal": true - }); - if (window.angular.bootstrap) { - console.log("WARNING: Tried to load angular more than once."); - return; - } - bindJQuery(); - publishExternalAPI(angular); - jqLite(document).ready(function() { - angularInit(document, bootstrap); - }); -})(window, document); - -!window.angular.$$csp() && window.angular.element(document).find("head").prepend(''); - -(function(window, angular, undefined) { - "use strict"; - angular.module("ngAnimate", [ "ng" ]).directive("ngAnimateChildren", function() { - var NG_ANIMATE_CHILDREN = "$$ngAnimateChildren"; - return function(scope, element, attrs) { - var val = attrs.ngAnimateChildren; - if (angular.isString(val) && val.length === 0) { - element.data(NG_ANIMATE_CHILDREN, true); - } else { - scope.$watch(val, function(value) { - element.data(NG_ANIMATE_CHILDREN, !!value); - }); - } - }; - }).factory("$$animateReflow", [ "$$rAF", "$document", function($$rAF, $document) { - var bod = $document[0].body; - return function(fn) { - return $$rAF(function() { - var a = bod.offsetWidth + 1; - fn(); - }); - }; - } ]).config([ "$provide", "$animateProvider", function($provide, $animateProvider) { - var noop = angular.noop; - var forEach = angular.forEach; - var selectors = $animateProvider.$$selectors; - var ELEMENT_NODE = 1; - var NG_ANIMATE_STATE = "$$ngAnimateState"; - var NG_ANIMATE_CHILDREN = "$$ngAnimateChildren"; - var NG_ANIMATE_CLASS_NAME = "ng-animate"; - var rootAnimateState = { - "running": true - }; - function extractElementNode(element) { - for (var i = 0; i < element.length; i++) { - var elm = element[i]; - if (elm.nodeType == ELEMENT_NODE) { - return elm; - } - } - } - function prepareElement(element) { - return element && angular.element(element); - } - function stripCommentsFromElement(element) { - return angular.element(extractElementNode(element)); - } - function isMatchingElement(elm1, elm2) { - return extractElementNode(elm1) == extractElementNode(elm2); - } - $provide.decorator("$animate", [ "$delegate", "$injector", "$sniffer", "$rootElement", "$$asyncCallback", "$rootScope", "$document", function($delegate, $injector, $sniffer, $rootElement, $$asyncCallback, $rootScope, $document) { - var globalAnimationCounter = 0; - $rootElement.data(NG_ANIMATE_STATE, rootAnimateState); - $rootScope.$$postDigest(function() { - $rootScope.$$postDigest(function() { - rootAnimateState.running = false; - }); - }); - var classNameFilter = $animateProvider.classNameFilter(); - var isAnimatableClassName = !classNameFilter ? function() { - return true; - } : function(className) { - return classNameFilter.test(className); - }; - function blockElementAnimations(element) { - var data = element.data(NG_ANIMATE_STATE) || {}; - data.running = true; - element.data(NG_ANIMATE_STATE, data); - } - function lookup(name) { - if (name) { - var matches = [], flagMap = {}, classes = name.substr(1).split("."); - if ($sniffer.transitions || $sniffer.animations) { - matches.push($injector.get(selectors[""])); - } - for (var i = 0; i < classes.length; i++) { - var klass = classes[i], selectorFactoryName = selectors[klass]; - if (selectorFactoryName && !flagMap[klass]) { - matches.push($injector.get(selectorFactoryName)); - flagMap[klass] = true; - } - } - return matches; - } - } - function animationRunner(element, animationEvent, className) { - var node = element[0]; - if (!node) { - return; - } - var isSetClassOperation = animationEvent == "setClass"; - var isClassBased = isSetClassOperation || animationEvent == "addClass" || animationEvent == "removeClass"; - var classNameAdd, classNameRemove; - if (angular.isArray(className)) { - classNameAdd = className[0]; - classNameRemove = className[1]; - className = classNameAdd + " " + classNameRemove; - } - var currentClassName = element.attr("class"); - var classes = currentClassName + " " + className; - if (!isAnimatableClassName(classes)) { - return; - } - var beforeComplete = noop, beforeCancel = [], before = [], afterComplete = noop, afterCancel = [], after = []; - var animationLookup = (" " + classes).replace(/\s+/g, "."); - forEach(lookup(animationLookup), function(animationFactory) { - var created = registerAnimation(animationFactory, animationEvent); - if (!created && isSetClassOperation) { - registerAnimation(animationFactory, "addClass"); - registerAnimation(animationFactory, "removeClass"); - } - }); - function registerAnimation(animationFactory, event) { - var afterFn = animationFactory[event]; - var beforeFn = animationFactory["before" + event.charAt(0).toUpperCase() + event.substr(1)]; - if (afterFn || beforeFn) { - if (event == "leave") { - beforeFn = afterFn; - afterFn = null; - } - after.push({ - "event": event, - "fn": afterFn - }); - before.push({ - "event": event, - "fn": beforeFn - }); - return true; - } - } - function run(fns, cancellations, allCompleteFn) { - var animations = []; - forEach(fns, function(animation) { - animation.fn && animations.push(animation); - }); - var count = 0; - function afterAnimationComplete(index) { - if (cancellations) { - (cancellations[index] || noop)(); - if (++count < animations.length) return; - cancellations = null; - } - allCompleteFn(); - } - forEach(animations, function(animation, index) { - var progress = function() { - afterAnimationComplete(index); - }; - switch (animation.event) { - case "setClass": - cancellations.push(animation.fn(element, classNameAdd, classNameRemove, progress)); - break; - - case "addClass": - cancellations.push(animation.fn(element, classNameAdd || className, progress)); - break; - - case "removeClass": - cancellations.push(animation.fn(element, classNameRemove || className, progress)); - break; - - default: - cancellations.push(animation.fn(element, progress)); - break; - } - }); - if (cancellations && cancellations.length === 0) { - allCompleteFn(); - } - } - return { - "node": node, - "event": animationEvent, - "className": className, - "isClassBased": isClassBased, - "isSetClassOperation": isSetClassOperation, - "before": function(allCompleteFn) { - beforeComplete = allCompleteFn; - run(before, beforeCancel, function() { - beforeComplete = noop; - allCompleteFn(); - }); - }, - "after": function(allCompleteFn) { - afterComplete = allCompleteFn; - run(after, afterCancel, function() { - afterComplete = noop; - allCompleteFn(); - }); - }, - "cancel": function() { - if (beforeCancel) { - forEach(beforeCancel, function(cancelFn) { - (cancelFn || noop)(true); - }); - beforeComplete(true); - } - if (afterCancel) { - forEach(afterCancel, function(cancelFn) { - (cancelFn || noop)(true); - }); - afterComplete(true); - } - } - }; - } - return { - "enter": function(element, parentElement, afterElement, doneCallback) { - element = angular.element(element); - parentElement = prepareElement(parentElement); - afterElement = prepareElement(afterElement); - blockElementAnimations(element); - $delegate.enter(element, parentElement, afterElement); - $rootScope.$$postDigest(function() { - element = stripCommentsFromElement(element); - performAnimation("enter", "ng-enter", element, parentElement, afterElement, noop, doneCallback); - }); - }, - "leave": function(element, doneCallback) { - element = angular.element(element); - cancelChildAnimations(element); - blockElementAnimations(element); - $rootScope.$$postDigest(function() { - performAnimation("leave", "ng-leave", stripCommentsFromElement(element), null, null, function() { - $delegate.leave(element); - }, doneCallback); - }); - }, - "move": function(element, parentElement, afterElement, doneCallback) { - element = angular.element(element); - parentElement = prepareElement(parentElement); - afterElement = prepareElement(afterElement); - cancelChildAnimations(element); - blockElementAnimations(element); - $delegate.move(element, parentElement, afterElement); - $rootScope.$$postDigest(function() { - element = stripCommentsFromElement(element); - performAnimation("move", "ng-move", element, parentElement, afterElement, noop, doneCallback); - }); - }, - "addClass": function(element, className, doneCallback) { - element = angular.element(element); - element = stripCommentsFromElement(element); - performAnimation("addClass", className, element, null, null, function() { - $delegate.addClass(element, className); - }, doneCallback); - }, - "removeClass": function(element, className, doneCallback) { - element = angular.element(element); - element = stripCommentsFromElement(element); - performAnimation("removeClass", className, element, null, null, function() { - $delegate.removeClass(element, className); - }, doneCallback); - }, - "setClass": function(element, add, remove, doneCallback) { - element = angular.element(element); - element = stripCommentsFromElement(element); - performAnimation("setClass", [ add, remove ], element, null, null, function() { - $delegate.setClass(element, add, remove); - }, doneCallback); - }, - "enabled": function(value, element) { - switch (arguments.length) { - case 2: - if (value) { - cleanup(element); - } else { - var data = element.data(NG_ANIMATE_STATE) || {}; - data.disabled = true; - element.data(NG_ANIMATE_STATE, data); - } - break; - - case 1: - rootAnimateState.disabled = !value; - break; - - default: - value = !rootAnimateState.disabled; - break; - } - return !!value; - } - }; - function performAnimation(animationEvent, className, element, parentElement, afterElement, domOperation, doneCallback) { - var runner = animationRunner(element, animationEvent, className); - if (!runner) { - fireDOMOperation(); - fireBeforeCallbackAsync(); - fireAfterCallbackAsync(); - closeAnimation(); - return; - } - className = runner.className; - var elementEvents = angular.element._data(runner.node); - elementEvents = elementEvents && elementEvents.events; - if (!parentElement) { - parentElement = afterElement ? afterElement.parent() : element.parent(); - } - var ngAnimateState = element.data(NG_ANIMATE_STATE) || {}; - var runningAnimations = ngAnimateState.active || {}; - var totalActiveAnimations = ngAnimateState.totalActive || 0; - var lastAnimation = ngAnimateState.last; - var skipAnimations; - if (runner.isClassBased) { - skipAnimations = ngAnimateState.running || ngAnimateState.disabled || lastAnimation && !lastAnimation.isClassBased; - } - if (skipAnimations || animationsDisabled(element, parentElement)) { - fireDOMOperation(); - fireBeforeCallbackAsync(); - fireAfterCallbackAsync(); - closeAnimation(); - return; - } - var skipAnimation = false; - if (totalActiveAnimations > 0) { - var animationsToCancel = []; - if (!runner.isClassBased) { - if (animationEvent == "leave" && runningAnimations["ng-leave"]) { - skipAnimation = true; - } else { - for (var klass in runningAnimations) { - animationsToCancel.push(runningAnimations[klass]); - cleanup(element, klass); - } - runningAnimations = {}; - totalActiveAnimations = 0; - } - } else if (lastAnimation.event == "setClass") { - animationsToCancel.push(lastAnimation); - cleanup(element, className); - } else if (runningAnimations[className]) { - var current = runningAnimations[className]; - if (current.event == animationEvent) { - skipAnimation = true; - } else { - animationsToCancel.push(current); - cleanup(element, className); - } - } - if (animationsToCancel.length > 0) { - forEach(animationsToCancel, function(operation) { - operation.cancel(); - }); - } - } - if (runner.isClassBased && !runner.isSetClassOperation && !skipAnimation) { - skipAnimation = animationEvent == "addClass" == element.hasClass(className); - } - if (skipAnimation) { - fireDOMOperation(); - fireBeforeCallbackAsync(); - fireAfterCallbackAsync(); - fireDoneCallbackAsync(); - return; - } - if (animationEvent == "leave") { - element.one("$destroy", function(e) { - var element = angular.element(this); - var state = element.data(NG_ANIMATE_STATE); - if (state) { - var activeLeaveAnimation = state.active["ng-leave"]; - if (activeLeaveAnimation) { - activeLeaveAnimation.cancel(); - cleanup(element, "ng-leave"); - } - } - }); - } - element.addClass(NG_ANIMATE_CLASS_NAME); - var localAnimationCount = globalAnimationCounter++; - totalActiveAnimations++; - runningAnimations[className] = runner; - element.data(NG_ANIMATE_STATE, { - "last": runner, - "active": runningAnimations, - "index": localAnimationCount, - "totalActive": totalActiveAnimations - }); - fireBeforeCallbackAsync(); - runner.before(function(cancelled) { - var data = element.data(NG_ANIMATE_STATE); - cancelled = cancelled || !data || !data.active[className] || runner.isClassBased && data.active[className].event != animationEvent; - fireDOMOperation(); - if (cancelled === true) { - closeAnimation(); - } else { - fireAfterCallbackAsync(); - runner.after(closeAnimation); - } - }); - function fireDOMCallback(animationPhase) { - var eventName = "$animate:" + animationPhase; - if (elementEvents && elementEvents[eventName] && elementEvents[eventName].length > 0) { - $$asyncCallback(function() { - element.triggerHandler(eventName, { - "event": animationEvent, - "className": className - }); - }); - } - } - function fireBeforeCallbackAsync() { - fireDOMCallback("before"); - } - function fireAfterCallbackAsync() { - fireDOMCallback("after"); - } - function fireDoneCallbackAsync() { - fireDOMCallback("close"); - if (doneCallback) { - $$asyncCallback(function() { - doneCallback(); - }); - } - } - function fireDOMOperation() { - if (!fireDOMOperation.hasBeenRun) { - fireDOMOperation.hasBeenRun = true; - domOperation(); - } - } - function closeAnimation() { - if (!closeAnimation.hasBeenRun) { - closeAnimation.hasBeenRun = true; - var data = element.data(NG_ANIMATE_STATE); - if (data) { - if (runner && runner.isClassBased) { - cleanup(element, className); - } else { - $$asyncCallback(function() { - var data = element.data(NG_ANIMATE_STATE) || {}; - if (localAnimationCount == data.index) { - cleanup(element, className, animationEvent); - } - }); - element.data(NG_ANIMATE_STATE, data); - } - } - fireDoneCallbackAsync(); - } - } - } - function cancelChildAnimations(element) { - var node = extractElementNode(element); - if (node) { - var nodes = angular.isFunction(node.getElementsByClassName) ? node.getElementsByClassName(NG_ANIMATE_CLASS_NAME) : node.querySelectorAll("." + NG_ANIMATE_CLASS_NAME); - forEach(nodes, function(element) { - element = angular.element(element); - var data = element.data(NG_ANIMATE_STATE); - if (data && data.active) { - forEach(data.active, function(runner) { - runner.cancel(); - }); - } - }); - } - } - function cleanup(element, className) { - if (isMatchingElement(element, $rootElement)) { - if (!rootAnimateState.disabled) { - rootAnimateState.running = false; - rootAnimateState.structural = false; - } - } else if (className) { - var data = element.data(NG_ANIMATE_STATE) || {}; - var removeAnimations = className === true; - if (!removeAnimations && data.active && data.active[className]) { - data.totalActive--; - delete data.active[className]; - } - if (removeAnimations || !data.totalActive) { - element.removeClass(NG_ANIMATE_CLASS_NAME); - element.removeData(NG_ANIMATE_STATE); - } - } - } - function animationsDisabled(element, parentElement) { - if (rootAnimateState.disabled) { - return true; - } - if (isMatchingElement(element, $rootElement)) { - return rootAnimateState.running; - } - var allowChildAnimations, parentRunningAnimation, hasParent; - do { - if (parentElement.length === 0) break; - var isRoot = isMatchingElement(parentElement, $rootElement); - var state = isRoot ? rootAnimateState : parentElement.data(NG_ANIMATE_STATE) || {}; - if (state.disabled) { - return true; - } - if (isRoot) { - hasParent = true; - } - if (allowChildAnimations !== false) { - var animateChildrenFlag = parentElement.data(NG_ANIMATE_CHILDREN); - if (angular.isDefined(animateChildrenFlag)) { - allowChildAnimations = animateChildrenFlag; - } - } - parentRunningAnimation = parentRunningAnimation || state.running || state.last && !state.last.isClassBased; - } while (parentElement = parentElement.parent()); - return !hasParent || !allowChildAnimations && parentRunningAnimation; - } - } ]); - $animateProvider.register("", [ "$window", "$sniffer", "$timeout", "$$animateReflow", function($window, $sniffer, $timeout, $$animateReflow) { - var CSS_PREFIX = "", TRANSITION_PROP, TRANSITIONEND_EVENT, ANIMATION_PROP, ANIMATIONEND_EVENT; - if (window.ontransitionend === undefined && window.onwebkittransitionend !== undefined) { - CSS_PREFIX = "-webkit-"; - TRANSITION_PROP = "WebkitTransition"; - TRANSITIONEND_EVENT = "webkitTransitionEnd transitionend"; - } else { - TRANSITION_PROP = "transition"; - TRANSITIONEND_EVENT = "transitionend"; - } - if (window.onanimationend === undefined && window.onwebkitanimationend !== undefined) { - CSS_PREFIX = "-webkit-"; - ANIMATION_PROP = "WebkitAnimation"; - ANIMATIONEND_EVENT = "webkitAnimationEnd animationend"; - } else { - ANIMATION_PROP = "animation"; - ANIMATIONEND_EVENT = "animationend"; - } - var DURATION_KEY = "Duration"; - var PROPERTY_KEY = "Property"; - var DELAY_KEY = "Delay"; - var ANIMATION_ITERATION_COUNT_KEY = "IterationCount"; - var NG_ANIMATE_PARENT_KEY = "$$ngAnimateKey"; - var NG_ANIMATE_CSS_DATA_KEY = "$$ngAnimateCSS3Data"; - var NG_ANIMATE_BLOCK_CLASS_NAME = "ng-animate-block-transitions"; - var ELAPSED_TIME_MAX_DECIMAL_PLACES = 3; - var CLOSING_TIME_BUFFER = 1.5; - var ONE_SECOND = 1e3; - var lookupCache = {}; - var parentCounter = 0; - var animationReflowQueue = []; - var cancelAnimationReflow; - function afterReflow(element, callback) { - if (cancelAnimationReflow) { - cancelAnimationReflow(); - } - animationReflowQueue.push(callback); - cancelAnimationReflow = $$animateReflow(function() { - forEach(animationReflowQueue, function(fn) { - fn(); - }); - animationReflowQueue = []; - cancelAnimationReflow = null; - lookupCache = {}; - }); - } - var closingTimer = null; - var closingTimestamp = 0; - var animationElementQueue = []; - function animationCloseHandler(element, totalTime) { - var node = extractElementNode(element); - element = angular.element(node); - animationElementQueue.push(element); - var futureTimestamp = Date.now() + totalTime; - if (futureTimestamp <= closingTimestamp) { - return; - } - $timeout.cancel(closingTimer); - closingTimestamp = futureTimestamp; - closingTimer = $timeout(function() { - closeAllAnimations(animationElementQueue); - animationElementQueue = []; - }, totalTime, false); - } - function closeAllAnimations(elements) { - forEach(elements, function(element) { - var elementData = element.data(NG_ANIMATE_CSS_DATA_KEY); - if (elementData) { - (elementData.closeAnimationFn || noop)(); - } - }); - } - function getElementAnimationDetails(element, cacheKey) { - var data = cacheKey ? lookupCache[cacheKey] : null; - if (!data) { - var transitionDuration = 0; - var transitionDelay = 0; - var animationDuration = 0; - var animationDelay = 0; - var transitionDelayStyle; - var animationDelayStyle; - var transitionDurationStyle; - var transitionPropertyStyle; - forEach(element, function(element) { - if (element.nodeType == ELEMENT_NODE) { - var elementStyles = $window.getComputedStyle(element) || {}; - transitionDurationStyle = elementStyles[TRANSITION_PROP + DURATION_KEY]; - transitionDuration = Math.max(parseMaxTime(transitionDurationStyle), transitionDuration); - transitionPropertyStyle = elementStyles[TRANSITION_PROP + PROPERTY_KEY]; - transitionDelayStyle = elementStyles[TRANSITION_PROP + DELAY_KEY]; - transitionDelay = Math.max(parseMaxTime(transitionDelayStyle), transitionDelay); - animationDelayStyle = elementStyles[ANIMATION_PROP + DELAY_KEY]; - animationDelay = Math.max(parseMaxTime(animationDelayStyle), animationDelay); - var aDuration = parseMaxTime(elementStyles[ANIMATION_PROP + DURATION_KEY]); - if (aDuration > 0) { - aDuration *= parseInt(elementStyles[ANIMATION_PROP + ANIMATION_ITERATION_COUNT_KEY], 10) || 1; - } - animationDuration = Math.max(aDuration, animationDuration); - } - }); - data = { - "total": 0, - "transitionPropertyStyle": transitionPropertyStyle, - "transitionDurationStyle": transitionDurationStyle, - "transitionDelayStyle": transitionDelayStyle, - "transitionDelay": transitionDelay, - "transitionDuration": transitionDuration, - "animationDelayStyle": animationDelayStyle, - "animationDelay": animationDelay, - "animationDuration": animationDuration - }; - if (cacheKey) { - lookupCache[cacheKey] = data; - } - } - return data; - } - function parseMaxTime(str) { - var maxValue = 0; - var values = angular.isString(str) ? str.split(/\s*,\s*/) : []; - forEach(values, function(value) { - maxValue = Math.max(parseFloat(value) || 0, maxValue); - }); - return maxValue; - } - function getCacheKey(element) { - var parentElement = element.parent(); - var parentID = parentElement.data(NG_ANIMATE_PARENT_KEY); - if (!parentID) { - parentElement.data(NG_ANIMATE_PARENT_KEY, ++parentCounter); - parentID = parentCounter; - } - return parentID + "-" + extractElementNode(element).getAttribute("class"); - } - function animateSetup(animationEvent, element, className, calculationDecorator) { - var cacheKey = getCacheKey(element); - var eventCacheKey = cacheKey + " " + className; - var itemIndex = lookupCache[eventCacheKey] ? ++lookupCache[eventCacheKey].total : 0; - var stagger = {}; - if (itemIndex > 0) { - var staggerClassName = className + "-stagger"; - var staggerCacheKey = cacheKey + " " + staggerClassName; - var applyClasses = !lookupCache[staggerCacheKey]; - applyClasses && element.addClass(staggerClassName); - stagger = getElementAnimationDetails(element, staggerCacheKey); - applyClasses && element.removeClass(staggerClassName); - } - calculationDecorator = calculationDecorator || function(fn) { - return fn(); - }; - element.addClass(className); - var formerData = element.data(NG_ANIMATE_CSS_DATA_KEY) || {}; - var timings = calculationDecorator(function() { - return getElementAnimationDetails(element, eventCacheKey); - }); - var transitionDuration = timings.transitionDuration; - var animationDuration = timings.animationDuration; - if (transitionDuration === 0 && animationDuration === 0) { - element.removeClass(className); - return false; - } - element.data(NG_ANIMATE_CSS_DATA_KEY, { - "running": formerData.running || 0, - "itemIndex": itemIndex, - "stagger": stagger, - "timings": timings, - "closeAnimationFn": noop - }); - var isCurrentlyAnimating = formerData.running > 0 || animationEvent == "setClass"; - if (transitionDuration > 0) { - blockTransitions(element, className, isCurrentlyAnimating); - } - if (animationDuration > 0 && stagger.animationDelay > 0 && stagger.animationDuration === 0) { - blockKeyframeAnimations(element); - } - return true; - } - function isStructuralAnimation(className) { - return className == "ng-enter" || className == "ng-move" || className == "ng-leave"; - } - function blockTransitions(element, className, isAnimating) { - if (isStructuralAnimation(className) || !isAnimating) { - extractElementNode(element).style[TRANSITION_PROP + PROPERTY_KEY] = "none"; - } else { - element.addClass(NG_ANIMATE_BLOCK_CLASS_NAME); - } - } - function blockKeyframeAnimations(element) { - extractElementNode(element).style[ANIMATION_PROP] = "none 0s"; - } - function unblockTransitions(element, className) { - var prop = TRANSITION_PROP + PROPERTY_KEY; - var node = extractElementNode(element); - if (node.style[prop] && node.style[prop].length > 0) { - node.style[prop] = ""; - } - element.removeClass(NG_ANIMATE_BLOCK_CLASS_NAME); - } - function unblockKeyframeAnimations(element) { - var prop = ANIMATION_PROP; - var node = extractElementNode(element); - if (node.style[prop] && node.style[prop].length > 0) { - node.style[prop] = ""; - } - } - function animateRun(animationEvent, element, className, activeAnimationComplete) { - var node = extractElementNode(element); - var elementData = element.data(NG_ANIMATE_CSS_DATA_KEY); - if (node.getAttribute("class").indexOf(className) == -1 || !elementData) { - activeAnimationComplete(); - return; - } - var activeClassName = ""; - forEach(className.split(" "), function(klass, i) { - activeClassName += (i > 0 ? " " : "") + klass + "-active"; - }); - var stagger = elementData.stagger; - var timings = elementData.timings; - var itemIndex = elementData.itemIndex; - var maxDuration = Math.max(timings.transitionDuration, timings.animationDuration); - var maxDelay = Math.max(timings.transitionDelay, timings.animationDelay); - var maxDelayTime = maxDelay * ONE_SECOND; - var startTime = Date.now(); - var css3AnimationEvents = ANIMATIONEND_EVENT + " " + TRANSITIONEND_EVENT; - var style = "", appliedStyles = []; - if (timings.transitionDuration > 0) { - var propertyStyle = timings.transitionPropertyStyle; - if (propertyStyle.indexOf("all") == -1) { - style += CSS_PREFIX + "transition-property: " + propertyStyle + ";"; - style += CSS_PREFIX + "transition-duration: " + timings.transitionDurationStyle + ";"; - appliedStyles.push(CSS_PREFIX + "transition-property"); - appliedStyles.push(CSS_PREFIX + "transition-duration"); - } - } - if (itemIndex > 0) { - if (stagger.transitionDelay > 0 && stagger.transitionDuration === 0) { - var delayStyle = timings.transitionDelayStyle; - style += CSS_PREFIX + "transition-delay: " + prepareStaggerDelay(delayStyle, stagger.transitionDelay, itemIndex) + "; "; - appliedStyles.push(CSS_PREFIX + "transition-delay"); - } - if (stagger.animationDelay > 0 && stagger.animationDuration === 0) { - style += CSS_PREFIX + "animation-delay: " + prepareStaggerDelay(timings.animationDelayStyle, stagger.animationDelay, itemIndex) + "; "; - appliedStyles.push(CSS_PREFIX + "animation-delay"); - } - } - if (appliedStyles.length > 0) { - var oldStyle = node.getAttribute("style") || ""; - node.setAttribute("style", oldStyle + "; " + style); - } - element.on(css3AnimationEvents, onAnimationProgress); - element.addClass(activeClassName); - elementData.closeAnimationFn = function() { - onEnd(); - activeAnimationComplete(); - }; - var staggerTime = itemIndex * (Math.max(stagger.animationDelay, stagger.transitionDelay) || 0); - var animationTime = (maxDelay + maxDuration) * CLOSING_TIME_BUFFER; - var totalTime = (staggerTime + animationTime) * ONE_SECOND; - elementData.running++; - animationCloseHandler(element, totalTime); - return onEnd; - function onEnd(cancelled) { - element.off(css3AnimationEvents, onAnimationProgress); - element.removeClass(activeClassName); - animateClose(element, className); - var node = extractElementNode(element); - for (var i in appliedStyles) { - node.style.removeProperty(appliedStyles[i]); - } - } - function onAnimationProgress(event) { - event.stopPropagation(); - var ev = event.originalEvent || event; - var timeStamp = ev.$manualTimeStamp || ev.timeStamp || Date.now(); - var elapsedTime = parseFloat(ev.elapsedTime.toFixed(ELAPSED_TIME_MAX_DECIMAL_PLACES)); - if (Math.max(timeStamp - startTime, 0) >= maxDelayTime && elapsedTime >= maxDuration) { - activeAnimationComplete(); - } - } - } - function prepareStaggerDelay(delayStyle, staggerDelay, index) { - var style = ""; - forEach(delayStyle.split(","), function(val, i) { - style += (i > 0 ? "," : "") + (index * staggerDelay + parseInt(val, 10)) + "s"; - }); - return style; - } - function animateBefore(animationEvent, element, className, calculationDecorator) { - if (animateSetup(animationEvent, element, className, calculationDecorator)) { - return function(cancelled) { - cancelled && animateClose(element, className); - }; - } - } - function animateAfter(animationEvent, element, className, afterAnimationComplete) { - if (element.data(NG_ANIMATE_CSS_DATA_KEY)) { - return animateRun(animationEvent, element, className, afterAnimationComplete); - } else { - animateClose(element, className); - afterAnimationComplete(); - } - } - function animate(animationEvent, element, className, animationComplete) { - var preReflowCancellation = animateBefore(animationEvent, element, className); - if (!preReflowCancellation) { - animationComplete(); - return; - } - var cancel = preReflowCancellation; - afterReflow(element, function() { - unblockTransitions(element, className); - unblockKeyframeAnimations(element); - cancel = animateAfter(animationEvent, element, className, animationComplete); - }); - return function(cancelled) { - (cancel || noop)(cancelled); - }; - } - function animateClose(element, className) { - element.removeClass(className); - var data = element.data(NG_ANIMATE_CSS_DATA_KEY); - if (data) { - if (data.running) { - data.running--; - } - if (!data.running || data.running === 0) { - element.removeData(NG_ANIMATE_CSS_DATA_KEY); - } - } - } - return { - "enter": function(element, animationCompleted) { - return animate("enter", element, "ng-enter", animationCompleted); - }, - "leave": function(element, animationCompleted) { - return animate("leave", element, "ng-leave", animationCompleted); - }, - "move": function(element, animationCompleted) { - return animate("move", element, "ng-move", animationCompleted); - }, - "beforeSetClass": function(element, add, remove, animationCompleted) { - var className = suffixClasses(remove, "-remove") + " " + suffixClasses(add, "-add"); - var cancellationMethod = animateBefore("setClass", element, className, function(fn) { - var klass = element.attr("class"); - element.removeClass(remove); - element.addClass(add); - var timings = fn(); - element.attr("class", klass); - return timings; - }); - if (cancellationMethod) { - afterReflow(element, function() { - unblockTransitions(element, className); - unblockKeyframeAnimations(element); - animationCompleted(); - }); - return cancellationMethod; - } - animationCompleted(); - }, - "beforeAddClass": function(element, className, animationCompleted) { - var cancellationMethod = animateBefore("addClass", element, suffixClasses(className, "-add"), function(fn) { - element.addClass(className); - var timings = fn(); - element.removeClass(className); - return timings; - }); - if (cancellationMethod) { - afterReflow(element, function() { - unblockTransitions(element, className); - unblockKeyframeAnimations(element); - animationCompleted(); - }); - return cancellationMethod; - } - animationCompleted(); - }, - "setClass": function(element, add, remove, animationCompleted) { - remove = suffixClasses(remove, "-remove"); - add = suffixClasses(add, "-add"); - var className = remove + " " + add; - return animateAfter("setClass", element, className, animationCompleted); - }, - "addClass": function(element, className, animationCompleted) { - return animateAfter("addClass", element, suffixClasses(className, "-add"), animationCompleted); - }, - "beforeRemoveClass": function(element, className, animationCompleted) { - var cancellationMethod = animateBefore("removeClass", element, suffixClasses(className, "-remove"), function(fn) { - var klass = element.attr("class"); - element.removeClass(className); - var timings = fn(); - element.attr("class", klass); - return timings; - }); - if (cancellationMethod) { - afterReflow(element, function() { - unblockTransitions(element, className); - unblockKeyframeAnimations(element); - animationCompleted(); - }); - return cancellationMethod; - } - animationCompleted(); - }, - "removeClass": function(element, className, animationCompleted) { - return animateAfter("removeClass", element, suffixClasses(className, "-remove"), animationCompleted); - } - }; - function suffixClasses(classes, suffix) { - var className = ""; - classes = angular.isArray(classes) ? classes : classes.split(/\s+/); - forEach(classes, function(klass, i) { - if (klass && klass.length > 0) { - className += (i > 0 ? " " : "") + klass + suffix; - } - }); - return className; - } - } ]); - } ]); -})(window, window.angular); - -(function(window, angular, undefined) { - "use strict"; - var $resourceMinErr = angular.$$minErr("$resource"); - var MEMBER_NAME_REGEX = /^(\.[a-zA-Z_$][0-9a-zA-Z_$]*)+$/; - function isValidDottedPath(path) { - return path != null && path !== "" && path !== "hasOwnProperty" && MEMBER_NAME_REGEX.test("." + path); - } - function lookupDottedPath(obj, path) { - if (!isValidDottedPath(path)) { - throw $resourceMinErr("badmember", 'Dotted member path "@{0}" is invalid.', path); - } - var keys = path.split("."); - for (var i = 0, ii = keys.length; i < ii && obj !== undefined; i++) { - var key = keys[i]; - obj = obj !== null ? obj[key] : undefined; - } - return obj; - } - function shallowClearAndCopy(src, dst) { - dst = dst || {}; - angular.forEach(dst, function(value, key) { - delete dst[key]; - }); - for (var key in src) { - if (src.hasOwnProperty(key) && !(key.charAt(0) === "$" && key.charAt(1) === "$")) { - dst[key] = src[key]; - } - } - return dst; - } - angular.module("ngResource", [ "ng" ]).factory("$resource", [ "$http", "$q", function($http, $q) { - var DEFAULT_ACTIONS = { - "get": { - "method": "GET" - }, - "save": { - "method": "POST" - }, - "query": { - "method": "GET", - "isArray": true - }, - "remove": { - "method": "DELETE" - }, - "delete": { - "method": "DELETE" - } - }; - var noop = angular.noop, forEach = angular.forEach, extend = angular.extend, copy = angular.copy, isFunction = angular.isFunction; - function encodeUriSegment(val) { - return encodeUriQuery(val, true).replace(/%26/gi, "&").replace(/%3D/gi, "=").replace(/%2B/gi, "+"); - } - function encodeUriQuery(val, pctEncodeSpaces) { - return encodeURIComponent(val).replace(/%40/gi, "@").replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, pctEncodeSpaces ? "%20" : "+"); - } - function Route(template, defaults) { - this.template = template; - this.defaults = defaults || {}; - this.urlParams = {}; - } - Route.prototype = { - "setUrlParams": function(config, params, actionUrl) { - var self = this, url = actionUrl || self.template, val, encodedVal; - var urlParams = self.urlParams = {}; - forEach(url.split(/\W/), function(param) { - if (param === "hasOwnProperty") { - throw $resourceMinErr("badname", "hasOwnProperty is not a valid parameter name."); - } - if (!new RegExp("^\\d+$").test(param) && param && new RegExp("(^|[^\\\\]):" + param + "(\\W|$)").test(url)) { - urlParams[param] = true; - } - }); - url = url.replace(/\\:/g, ":"); - params = params || {}; - forEach(self.urlParams, function(_, urlParam) { - val = params.hasOwnProperty(urlParam) ? params[urlParam] : self.defaults[urlParam]; - if (angular.isDefined(val) && val !== null) { - encodedVal = encodeUriSegment(val); - url = url.replace(new RegExp(":" + urlParam + "(\\W|$)", "g"), function(match, p1) { - return encodedVal + p1; - }); - } else { - url = url.replace(new RegExp("(/?):" + urlParam + "(\\W|$)", "g"), function(match, leadingSlashes, tail) { - if (tail.charAt(0) == "/") { - return tail; - } else { - return leadingSlashes + tail; - } - }); - } - }); - url = url.replace(/\/+$/, "") || "/"; - url = url.replace(/\/\.(?=\w+($|\?))/, "."); - config.url = url.replace(/\/\\\./, "/."); - forEach(params, function(value, key) { - if (!self.urlParams[key]) { - config.params = config.params || {}; - config.params[key] = value; - } - }); - } - }; - function resourceFactory(url, paramDefaults, actions) { - var route = new Route(url); - actions = extend({}, DEFAULT_ACTIONS, actions); - function extractParams(data, actionParams) { - var ids = {}; - actionParams = extend({}, paramDefaults, actionParams); - forEach(actionParams, function(value, key) { - if (isFunction(value)) { - value = value(); - } - ids[key] = value && value.charAt && value.charAt(0) == "@" ? lookupDottedPath(data, value.substr(1)) : value; - }); - return ids; - } - function defaultResponseInterceptor(response) { - return response.resource; - } - function Resource(value) { - shallowClearAndCopy(value || {}, this); - } - forEach(actions, function(action, name) { - var hasBody = /^(POST|PUT|PATCH)$/i.test(action.method); - Resource[name] = function(a1, a2, a3, a4) { - var params = {}, data, success, error; - switch (arguments.length) { - case 4: - error = a4; - success = a3; - - case 3: - case 2: - if (isFunction(a2)) { - if (isFunction(a1)) { - success = a1; - error = a2; - break; - } - success = a2; - error = a3; - } else { - params = a1; - data = a2; - success = a3; - break; - } - - case 1: - if (isFunction(a1)) success = a1; else if (hasBody) data = a1; else params = a1; - break; - - case 0: - break; - - default: - throw $resourceMinErr("badargs", "Expected up to 4 arguments [params, data, success, error], got {0} arguments", arguments.length); - } - var isInstanceCall = this instanceof Resource; - var value = isInstanceCall ? data : action.isArray ? [] : new Resource(data); - var httpConfig = {}; - var responseInterceptor = action.interceptor && action.interceptor.response || defaultResponseInterceptor; - var responseErrorInterceptor = action.interceptor && action.interceptor.responseError || undefined; - forEach(action, function(value, key) { - if (key != "params" && key != "isArray" && key != "interceptor") { - httpConfig[key] = copy(value); - } - }); - if (hasBody) httpConfig.data = data; - route.setUrlParams(httpConfig, extend({}, extractParams(data, action.params || {}), params), action.url); - var promise = $http(httpConfig).then(function(response) { - var data = response.data, promise = value.$promise; - if (data) { - if (angular.isArray(data) !== !!action.isArray) { - throw $resourceMinErr("badcfg", "Error in resource configuration. Expected " + "response to contain an {0} but got an {1}", action.isArray ? "array" : "object", angular.isArray(data) ? "array" : "object"); - } - if (action.isArray) { - value.length = 0; - forEach(data, function(item) { - if (typeof item === "object") { - value.push(new Resource(item)); - } else { - value.push(item); - } - }); - } else { - shallowClearAndCopy(data, value); - value.$promise = promise; - } - } - value.$resolved = true; - response.resource = value; - return response; - }, function(response) { - value.$resolved = true; - (error || noop)(response); - return $q.reject(response); - }); - promise = promise.then(function(response) { - var value = responseInterceptor(response); - (success || noop)(value, response.headers); - return value; - }, responseErrorInterceptor); - if (!isInstanceCall) { - value.$promise = promise; - value.$resolved = false; - return value; - } - return promise; - }; - Resource.prototype["$" + name] = function(params, success, error) { - if (isFunction(params)) { - error = success; - success = params; - params = {}; - } - var result = Resource[name].call(this, params, this, success, error); - return result.$promise || result; - }; - }); - Resource.bind = function(additionalParamDefaults) { - return resourceFactory(url, extend({}, paramDefaults, additionalParamDefaults), actions); - }; - return Resource; - } - return resourceFactory; - } ]); -})(window, window.angular); - -(function(window, angular, undefined) { - "use strict"; - var ngRouteModule = angular.module("ngRoute", [ "ng" ]).provider("$route", $RouteProvider); - function $RouteProvider() { - function inherit(parent, extra) { - return angular.extend(new (angular.extend(function() {}, { - "prototype": parent - }))(), extra); - } - var routes = {}; - this.when = function(path, route) { - routes[path] = angular.extend({ - "reloadOnSearch": true - }, route, path && pathRegExp(path, route)); - if (path) { - var redirectPath = path[path.length - 1] == "/" ? path.substr(0, path.length - 1) : path + "/"; - routes[redirectPath] = angular.extend({ - "redirectTo": path - }, pathRegExp(redirectPath, route)); - } - return this; - }; - function pathRegExp(path, opts) { - var insensitive = opts.caseInsensitiveMatch, ret = { - "originalPath": path, - "regexp": path - }, keys = ret.keys = []; - path = path.replace(/([().])/g, "\\$1").replace(/(\/)?:(\w+)([\?\*])?/g, function(_, slash, key, option) { - var optional = option === "?" ? option : null; - var star = option === "*" ? option : null; - keys.push({ - "name": key, - "optional": !!optional - }); - slash = slash || ""; - return "" + (optional ? "" : slash) + "(?:" + (optional ? slash : "") + (star && "(.+?)" || "([^/]+)") + (optional || "") + ")" + (optional || ""); - }).replace(/([\/$\*])/g, "\\$1"); - ret.regexp = new RegExp("^" + path + "$", insensitive ? "i" : ""); - return ret; - } - this.otherwise = function(params) { - this.when(null, params); - return this; - }; - this.$get = [ "$rootScope", "$location", "$routeParams", "$q", "$injector", "$http", "$templateCache", "$sce", function($rootScope, $location, $routeParams, $q, $injector, $http, $templateCache, $sce) { - var forceReload = false, $route = { - "routes": routes, - "reload": function() { - forceReload = true; - $rootScope.$evalAsync(updateRoute); - } - }; - $rootScope.$on("$locationChangeSuccess", updateRoute); - return $route; - function switchRouteMatcher(on, route) { - var keys = route.keys, params = {}; - if (!route.regexp) return null; - var m = route.regexp.exec(on); - if (!m) return null; - for (var i = 1, len = m.length; i < len; ++i) { - var key = keys[i - 1]; - var val = m[i]; - if (key && val) { - params[key.name] = val; - } - } - return params; - } - function updateRoute() { - var next = parseRoute(), last = $route.current; - if (next && last && next.$$route === last.$$route && angular.equals(next.pathParams, last.pathParams) && !next.reloadOnSearch && !forceReload) { - last.params = next.params; - angular.copy(last.params, $routeParams); - $rootScope.$broadcast("$routeUpdate", last); - } else if (next || last) { - forceReload = false; - $rootScope.$broadcast("$routeChangeStart", next, last); - $route.current = next; - if (next) { - if (next.redirectTo) { - if (angular.isString(next.redirectTo)) { - $location.path(interpolate(next.redirectTo, next.params)).search(next.params).replace(); - } else { - $location.url(next.redirectTo(next.pathParams, $location.path(), $location.search())).replace(); - } - } - } - $q.when(next).then(function() { - if (next) { - var locals = angular.extend({}, next.resolve), template, templateUrl; - angular.forEach(locals, function(value, key) { - locals[key] = angular.isString(value) ? $injector.get(value) : $injector.invoke(value); - }); - if (angular.isDefined(template = next.template)) { - if (angular.isFunction(template)) { - template = template(next.params); - } - } else if (angular.isDefined(templateUrl = next.templateUrl)) { - if (angular.isFunction(templateUrl)) { - templateUrl = templateUrl(next.params); - } - templateUrl = $sce.getTrustedResourceUrl(templateUrl); - if (angular.isDefined(templateUrl)) { - next.loadedTemplateUrl = templateUrl; - template = $http.get(templateUrl, { - "cache": $templateCache - }).then(function(response) { - return response.data; - }); - } - } - if (angular.isDefined(template)) { - locals["$template"] = template; - } - return $q.all(locals); - } - }).then(function(locals) { - if (next == $route.current) { - if (next) { - next.locals = locals; - angular.copy(next.params, $routeParams); - } - $rootScope.$broadcast("$routeChangeSuccess", next, last); - } - }, function(error) { - if (next == $route.current) { - $rootScope.$broadcast("$routeChangeError", next, last, error); - } - }); - } - } - function parseRoute() { - var params, match; - angular.forEach(routes, function(route, path) { - if (!match && (params = switchRouteMatcher($location.path(), route))) { - match = inherit(route, { - "params": angular.extend({}, $location.search(), params), - "pathParams": params - }); - match.$$route = route; - } - }); - return match || routes[null] && inherit(routes[null], { - "params": {}, - "pathParams": {} - }); - } - function interpolate(string, params) { - var result = []; - angular.forEach((string || "").split(":"), function(segment, i) { - if (i === 0) { - result.push(segment); - } else { - var segmentMatch = segment.match(/(\w+)(.*)/); - var key = segmentMatch[1]; - result.push(params[key]); - result.push(segmentMatch[2] || ""); - delete params[key]; - } - }); - return result.join(""); - } - } ]; - } - ngRouteModule.provider("$routeParams", $RouteParamsProvider); - function $RouteParamsProvider() { - this.$get = function() { - return {}; - }; - } - ngRouteModule.directive("ngView", ngViewFactory); - ngRouteModule.directive("ngView", ngViewFillContentFactory); - ngViewFactory.$inject = [ "$route", "$anchorScroll", "$animate" ]; - function ngViewFactory($route, $anchorScroll, $animate) { - return { - "restrict": "ECA", - "terminal": true, - "priority": 400, - "transclude": "element", - "link": function(scope, $element, attr, ctrl, $transclude) { - var currentScope, currentElement, previousElement, autoScrollExp = attr.autoscroll, onloadExp = attr.onload || ""; - scope.$on("$routeChangeSuccess", update); - update(); - function cleanupLastView() { - if (previousElement) { - previousElement.remove(); - previousElement = null; - } - if (currentScope) { - currentScope.$destroy(); - currentScope = null; - } - if (currentElement) { - $animate.leave(currentElement, function() { - previousElement = null; - }); - previousElement = currentElement; - currentElement = null; - } - } - function update() { - var locals = $route.current && $route.current.locals, template = locals && locals.$template; - if (angular.isDefined(template)) { - var newScope = scope.$new(); - var current = $route.current; - var clone = $transclude(newScope, function(clone) { - $animate.enter(clone, null, currentElement || $element, function onNgViewEnter() { - if (angular.isDefined(autoScrollExp) && (!autoScrollExp || scope.$eval(autoScrollExp))) { - $anchorScroll(); - } - }); - cleanupLastView(); - }); - currentElement = clone; - currentScope = current.scope = newScope; - currentScope.$emit("$viewContentLoaded"); - currentScope.$eval(onloadExp); - } else { - cleanupLastView(); - } - } - } - }; - } - ngViewFillContentFactory.$inject = [ "$compile", "$controller", "$route" ]; - function ngViewFillContentFactory($compile, $controller, $route) { - return { - "restrict": "ECA", - "priority": -400, - "link": function(scope, $element) { - var current = $route.current, locals = current.locals; - $element.html(locals.$template); - var link = $compile($element.contents()); - if (current.controller) { - locals.$scope = scope; - var controller = $controller(current.controller, locals); - if (current.controllerAs) { - scope[current.controllerAs] = controller; - } - $element.data("$ngControllerController", controller); - $element.children().data("$ngControllerController", controller); - } - link(scope); - } - }; - } -})(window, window.angular); - -(function(window, angular, undefined) { - "use strict"; - var $sanitizeMinErr = angular.$$minErr("$sanitize"); - function $SanitizeProvider() { - this.$get = [ "$$sanitizeUri", function($$sanitizeUri) { - return function(html) { - var buf = []; - htmlParser(html, htmlSanitizeWriter(buf, function(uri, isImage) { - return !/^unsafe/.test($$sanitizeUri(uri, isImage)); - })); - return buf.join(""); - }; - } ]; - } - function sanitizeText(chars) { - var buf = []; - var writer = htmlSanitizeWriter(buf, angular.noop); - writer.chars(chars); - return buf.join(""); - } - var START_TAG_REGEXP = /^<((?:[a-zA-Z])[\w:-]*)((?:\s+[\w:-]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)\s*(>?)/, END_TAG_REGEXP = /^<\/\s*([\w:-]+)[^>]*>/, ATTR_REGEXP = /([\w:-]+)(?:\s*=\s*(?:(?:"((?:[^"])*)")|(?:'((?:[^'])*)')|([^>\s]+)))?/g, BEGIN_TAG_REGEXP = /^/g, DOCTYPE_REGEXP = /]*?)>/i, CDATA_REGEXP = //g, SURROGATE_PAIR_REGEXP = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g, NON_ALPHANUMERIC_REGEXP = /([^\#-~| |!])/g; - var voidElements = makeMap("area,br,col,hr,img,wbr"); - var optionalEndTagBlockElements = makeMap("colgroup,dd,dt,li,p,tbody,td,tfoot,th,thead,tr"), optionalEndTagInlineElements = makeMap("rp,rt"), optionalEndTagElements = angular.extend({}, optionalEndTagInlineElements, optionalEndTagBlockElements); - var blockElements = angular.extend({}, optionalEndTagBlockElements, makeMap("address,article," + "aside,blockquote,caption,center,del,dir,div,dl,figure,figcaption,footer,h1,h2,h3,h4,h5," + "h6,header,hgroup,hr,ins,map,menu,nav,ol,pre,script,section,table,ul")); - var inlineElements = angular.extend({}, optionalEndTagInlineElements, makeMap("a,abbr,acronym,b," + "bdi,bdo,big,br,cite,code,del,dfn,em,font,i,img,ins,kbd,label,map,mark,q,ruby,rp,rt,s," + "samp,small,span,strike,strong,sub,sup,time,tt,u,var")); - var specialElements = makeMap("script,style"); - var validElements = angular.extend({}, voidElements, blockElements, inlineElements, optionalEndTagElements); - var uriAttrs = makeMap("background,cite,href,longdesc,src,usemap"); - var validAttrs = angular.extend({}, uriAttrs, makeMap("abbr,align,alt,axis,bgcolor,border,cellpadding,cellspacing,class,clear," + "color,cols,colspan,compact,coords,dir,face,headers,height,hreflang,hspace," + "ismap,lang,language,nohref,nowrap,rel,rev,rows,rowspan,rules," + "scope,scrolling,shape,size,span,start,summary,target,title,type," + "valign,value,vspace,width")); - function makeMap(str) { - var obj = {}, items = str.split(","), i; - for (i = 0; i < items.length; i++) obj[items[i]] = true; - return obj; - } - function htmlParser(html, handler) { - if (typeof html !== "string") { - if (html === null || typeof html === "undefined") { - html = ""; - } else { - html = "" + html; - } - } - var index, chars, match, stack = [], last = html, text; - stack.last = function() { - return stack[stack.length - 1]; - }; - while (html) { - text = ""; - chars = true; - if (!stack.last() || !specialElements[stack.last()]) { - if (html.indexOf("", index) === index) { - if (handler.comment) handler.comment(html.substring(4, index)); - html = html.substring(index + 3); - chars = false; - } - } else if (DOCTYPE_REGEXP.test(html)) { - match = html.match(DOCTYPE_REGEXP); - if (match) { - html = html.replace(match[0], ""); - chars = false; - } - } else if (BEGING_END_TAGE_REGEXP.test(html)) { - match = html.match(END_TAG_REGEXP); - if (match) { - html = html.substring(match[0].length); - match[0].replace(END_TAG_REGEXP, parseEndTag); - chars = false; - } - } else if (BEGIN_TAG_REGEXP.test(html)) { - match = html.match(START_TAG_REGEXP); - if (match) { - if (match[4]) { - html = html.substring(match[0].length); - match[0].replace(START_TAG_REGEXP, parseStartTag); - } - chars = false; - } else { - text += "<"; - html = html.substring(1); - } - } - if (chars) { - index = html.indexOf("<"); - text += index < 0 ? html : html.substring(0, index); - html = index < 0 ? "" : html.substring(index); - if (handler.chars) handler.chars(decodeEntities(text)); - } - } else { - html = html.replace(new RegExp("(.*)<\\s*\\/\\s*" + stack.last() + "[^>]*>", "i"), function(all, text) { - text = text.replace(COMMENT_REGEXP, "$1").replace(CDATA_REGEXP, "$1"); - if (handler.chars) handler.chars(decodeEntities(text)); - return ""; - }); - parseEndTag("", stack.last()); - } - if (html == last) { - throw $sanitizeMinErr("badparse", "The sanitizer was unable to parse the following block " + "of html: {0}", html); - } - last = html; - } - parseEndTag(); - function parseStartTag(tag, tagName, rest, unary) { - tagName = angular.lowercase(tagName); - if (blockElements[tagName]) { - while (stack.last() && inlineElements[stack.last()]) { - parseEndTag("", stack.last()); - } - } - if (optionalEndTagElements[tagName] && stack.last() == tagName) { - parseEndTag("", tagName); - } - unary = voidElements[tagName] || !!unary; - if (!unary) stack.push(tagName); - var attrs = {}; - rest.replace(ATTR_REGEXP, function(match, name, doubleQuotedValue, singleQuotedValue, unquotedValue) { - var value = doubleQuotedValue || singleQuotedValue || unquotedValue || ""; - attrs[name] = decodeEntities(value); - }); - if (handler.start) handler.start(tagName, attrs, unary); - } - function parseEndTag(tag, tagName) { - var pos = 0, i; - tagName = angular.lowercase(tagName); - if (tagName) for (pos = stack.length - 1; pos >= 0; pos--) if (stack[pos] == tagName) break; - if (pos >= 0) { - for (i = stack.length - 1; i >= pos; i--) if (handler.end) handler.end(stack[i]); - stack.length = pos; - } - } - } - var hiddenPre = document.createElement("pre"); - var spaceRe = /^(\s*)([\s\S]*?)(\s*)$/; - function decodeEntities(value) { - if (!value) { - return ""; - } - var parts = spaceRe.exec(value); - var spaceBefore = parts[1]; - var spaceAfter = parts[3]; - var content = parts[2]; - if (content) { - hiddenPre.innerHTML = content.replace(//g, ">"); - } - function htmlSanitizeWriter(buf, uriValidator) { - var ignore = false; - var out = angular.bind(buf, buf.push); - return { - "start": function(tag, attrs, unary) { - tag = angular.lowercase(tag); - if (!ignore && specialElements[tag]) { - ignore = tag; - } - if (!ignore && validElements[tag] === true) { - out("<"); - out(tag); - angular.forEach(attrs, function(value, key) { - var lkey = angular.lowercase(key); - var isImage = tag === "img" && lkey === "src" || lkey === "background"; - if (validAttrs[lkey] === true && (uriAttrs[lkey] !== true || uriValidator(value, isImage))) { - out(" "); - out(key); - out('="'); - out(encodeEntities(value)); - out('"'); - } - }); - out(unary ? "/>" : ">"); - } - }, - "end": function(tag) { - tag = angular.lowercase(tag); - if (!ignore && validElements[tag] === true) { - out(""); - } - if (tag == ignore) { - ignore = false; - } - }, - "chars": function(chars) { - if (!ignore) { - out(encodeEntities(chars)); - } - } - }; - } - angular.module("ngSanitize", []).provider("$sanitize", $SanitizeProvider); - angular.module("ngSanitize").filter("linky", [ "$sanitize", function($sanitize) { - var LINKY_URL_REGEXP = /((ftp|https?):\/\/|(mailto:)?[A-Za-z0-9._%+-]+@)\S*[^\s.;,(){}<>]/, MAILTO_REGEXP = /^mailto:/; - return function(text, target) { - if (!text) return text; - var match; - var raw = text; - var html = []; - var url; - var i; - while (match = raw.match(LINKY_URL_REGEXP)) { - url = match[0]; - if (match[2] == match[3]) url = "mailto:" + url; - i = match.index; - addText(raw.substr(0, i)); - addLink(url, match[0].replace(MAILTO_REGEXP, "")); - raw = raw.substring(i + match[0].length); - } - addText(raw); - return $sanitize(html.join("")); - function addText(text) { - if (!text) { - return; - } - html.push(sanitizeText(text)); - } - function addLink(url, text) { - html.push("'); - addText(text); - html.push(""); - } - }; - } ]); -})(window, window.angular); - -angular.module("$strap.config", []).value("$strapConfig", {}); - -angular.module("$strap.filters", [ "$strap.config" ]); - -angular.module("$strap.directives", [ "$strap.config" ]); - -angular.module("$strap", [ "$strap.filters", "$strap.directives", "$strap.config" ]); - -"use strict"; - -angular.module("$strap.directives").directive("bsPopover", function($parse, $compile, $http, $timeout, $q, $templateCache) { - var type = "popover", dataPrefix = !!$.fn.emulateTransitionEnd ? "bs." : "", evSuffix = dataPrefix ? "." + dataPrefix + type : ""; - $("body").on("keyup", function(ev) { - if (ev.keyCode === 27) { - $(".popover.in").popover("hide"); - } - }); - return { - "restrict": "A", - "scope": true, - "link": function postLink(scope, element, attr, ctrl) { - var getter = $parse(attr.bsPopover), setter = getter.assign, value = getter(scope), options = {}; - if (angular.isObject(value)) { - options = value; - } - $q.when(options.content || $templateCache.get(value) || $http.get(value, { - "cache": true - })).then(function onSuccess(template) { - if (angular.isObject(template)) { - template = template.data; - } - angular.forEach([ "placement", "trigger" ], function(name) { - if (!!attr[name]) { - options[name] = attr[name]; - } - }); - if (!!attr.unique) { - element.on("show" + evSuffix, function(ev) { - $(".popover.in").not(element).popover("hide"); - }); - } - if (!!attr.hide) { - scope.$watch(attr.hide, function(newValue, oldValue) { - if (!!newValue) { - popover.hide(); - } else if (newValue !== oldValue) { - $timeout(function() { - popover.show(); - }); - } - }); - } - if (!!attr.show) { - scope.$watch(attr.show, function(newValue, oldValue) { - if (!!newValue) { - $timeout(function() { - popover.show(); - }); - } else if (newValue !== oldValue) { - popover.hide(); - } - }); - } - element.popover(angular.extend({}, options, { - "content": template, - "html": true - })); - var popover = element.data(dataPrefix + type); - popover.hasContent = function() { - return this.getTitle() || template; - }; - popover.getPosition = function() { - var r = $.fn.popover.Constructor.prototype.getPosition.apply(this, arguments); - $compile(this.$tip)(scope); - scope.$digest(); - this.$tip.data(dataPrefix + type, this); - return r; - }; - scope.$popover = function(name) { - popover(name); - }; - angular.forEach([ "show", "hide" ], function(name) { - scope[name] = function() { - popover[name](); - }; - }); - scope.dismiss = scope.hide; - angular.forEach([ "show", "shown", "hide", "hidden" ], function(name) { - element.on(name + evSuffix, function(ev) { - scope.$emit("popover-" + name, ev); - }); - }); - }); - } - }; -}); - -angular.module("ui.bootstrap", [ "ui.bootstrap.tpls", "ui.bootstrap.transition", "ui.bootstrap.collapse", "ui.bootstrap.accordion", "ui.bootstrap.alert", "ui.bootstrap.bindHtml", "ui.bootstrap.buttons", "ui.bootstrap.carousel", "ui.bootstrap.dateparser", "ui.bootstrap.position", "ui.bootstrap.datepicker", "ui.bootstrap.dropdown", "ui.bootstrap.modal", "ui.bootstrap.pagination", "ui.bootstrap.tooltip", "ui.bootstrap.popover", "ui.bootstrap.progressbar", "ui.bootstrap.rating", "ui.bootstrap.tabs", "ui.bootstrap.timepicker", "ui.bootstrap.typeahead" ]); - -angular.module("ui.bootstrap.tpls", [ "template/accordion/accordion-group.html", "template/accordion/accordion.html", "template/alert/alert.html", "template/carousel/carousel.html", "template/carousel/slide.html", "template/datepicker/datepicker.html", "template/datepicker/day.html", "template/datepicker/month.html", "template/datepicker/popup.html", "template/datepicker/year.html", "template/modal/backdrop.html", "template/modal/window.html", "template/pagination/pager.html", "template/pagination/pagination.html", "template/tooltip/tooltip-html-unsafe-popup.html", "template/tooltip/tooltip-popup.html", "template/popover/popover.html", "template/progressbar/bar.html", "template/progressbar/progress.html", "template/progressbar/progressbar.html", "template/rating/rating.html", "template/tabs/tab.html", "template/tabs/tabset.html", "template/timepicker/timepicker.html", "template/typeahead/typeahead-match.html", "template/typeahead/typeahead-popup.html" ]); - -angular.module("ui.bootstrap.transition", []).factory("$transition", [ "$q", "$timeout", "$rootScope", function($q, $timeout, $rootScope) { - var $transition = function(element, trigger, options) { - options = options || {}; - var deferred = $q.defer(); - var endEventName = $transition[options.animation ? "animationEndEventName" : "transitionEndEventName"]; - var transitionEndHandler = function(event) { - $rootScope.$apply(function() { - element.unbind(endEventName, transitionEndHandler); - deferred.resolve(element); - }); - }; - if (endEventName) { - element.bind(endEventName, transitionEndHandler); - } - $timeout(function() { - if (angular.isString(trigger)) { - element.addClass(trigger); - } else if (angular.isFunction(trigger)) { - trigger(element); - } else if (angular.isObject(trigger)) { - element.css(trigger); - } - if (!endEventName) { - deferred.resolve(element); - } - }); - deferred.promise.cancel = function() { - if (endEventName) { - element.unbind(endEventName, transitionEndHandler); - } - deferred.reject("Transition cancelled"); - }; - return deferred.promise; - }; - var transElement = document.createElement("trans"); - var transitionEndEventNames = { - "WebkitTransition": "webkitTransitionEnd", - "MozTransition": "transitionend", - "OTransition": "oTransitionEnd", - "transition": "transitionend" - }; - var animationEndEventNames = { - "WebkitTransition": "webkitAnimationEnd", - "MozTransition": "animationend", - "OTransition": "oAnimationEnd", - "transition": "animationend" - }; - function findEndEventName(endEventNames) { - for (var name in endEventNames) { - if (transElement.style[name] !== undefined) { - return endEventNames[name]; - } - } - } - $transition.transitionEndEventName = findEndEventName(transitionEndEventNames); - $transition.animationEndEventName = findEndEventName(animationEndEventNames); - return $transition; -} ]); - -angular.module("ui.bootstrap.collapse", [ "ui.bootstrap.transition" ]).directive("collapse", [ "$transition", function($transition) { - return { - "link": function(scope, element, attrs) { - var initialAnimSkip = true; - var currentTransition; - function doTransition(change) { - var newTransition = $transition(element, change); - if (currentTransition) { - currentTransition.cancel(); - } - currentTransition = newTransition; - newTransition.then(newTransitionDone, newTransitionDone); - return newTransition; - function newTransitionDone() { - if (currentTransition === newTransition) { - currentTransition = undefined; - } - } - } - function expand() { - if (initialAnimSkip) { - initialAnimSkip = false; - expandDone(); - } else { - element.removeClass("collapse").addClass("collapsing"); - doTransition({ - "height": element[0].scrollHeight + "px" - }).then(expandDone); - } - } - function expandDone() { - element.removeClass("collapsing"); - element.addClass("collapse in"); - element.css({ - "height": "auto" - }); - } - function collapse() { - if (initialAnimSkip) { - initialAnimSkip = false; - collapseDone(); - element.css({ - "height": 0 - }); - } else { - element.css({ - "height": element[0].scrollHeight + "px" - }); - var x = element[0].offsetWidth; - element.removeClass("collapse in").addClass("collapsing"); - doTransition({ - "height": 0 - }).then(collapseDone); - } - } - function collapseDone() { - element.removeClass("collapsing"); - element.addClass("collapse"); - } - scope.$watch(attrs.collapse, function(shouldCollapse) { - if (shouldCollapse) { - collapse(); - } else { - expand(); - } - }); - } - }; -} ]); - -angular.module("ui.bootstrap.accordion", [ "ui.bootstrap.collapse" ]).constant("accordionConfig", { - "closeOthers": true -}).controller("AccordionController", [ "$scope", "$attrs", "accordionConfig", function($scope, $attrs, accordionConfig) { - this.groups = []; - this.closeOthers = function(openGroup) { - var closeOthers = angular.isDefined($attrs.closeOthers) ? $scope.$eval($attrs.closeOthers) : accordionConfig.closeOthers; - if (closeOthers) { - angular.forEach(this.groups, function(group) { - if (group !== openGroup) { - group.isOpen = false; - } - }); - } - }; - this.addGroup = function(groupScope) { - var that = this; - this.groups.push(groupScope); - groupScope.$on("$destroy", function(event) { - that.removeGroup(groupScope); - }); - }; - this.removeGroup = function(group) { - var index = this.groups.indexOf(group); - if (index !== -1) { - this.groups.splice(index, 1); - } - }; -} ]).directive("accordion", function() { - return { - "restrict": "EA", - "controller": "AccordionController", - "transclude": true, - "replace": false, - "templateUrl": "template/accordion/accordion.html" - }; -}).directive("accordionGroup", function() { - return { - "require": "^accordion", - "restrict": "EA", - "transclude": true, - "replace": true, - "templateUrl": "template/accordion/accordion-group.html", - "scope": { - "heading": "@", - "isOpen": "=?", - "isDisabled": "=?" - }, - "controller": function() { - this.setHeading = function(element) { - this.heading = element; - }; - }, - "link": function(scope, element, attrs, accordionCtrl) { - accordionCtrl.addGroup(scope); - scope.$watch("isOpen", function(value) { - if (value) { - accordionCtrl.closeOthers(scope); - } - }); - scope.toggleOpen = function() { - if (!scope.isDisabled) { - scope.isOpen = !scope.isOpen; - } - }; - } - }; -}).directive("accordionHeading", function() { - return { - "restrict": "EA", - "transclude": true, - "template": "", - "replace": true, - "require": "^accordionGroup", - "link": function(scope, element, attr, accordionGroupCtrl, transclude) { - accordionGroupCtrl.setHeading(transclude(scope, function() {})); - } - }; -}).directive("accordionTransclude", function() { - return { - "require": "^accordionGroup", - "link": function(scope, element, attr, controller) { - scope.$watch(function() { - return controller[attr.accordionTransclude]; - }, function(heading) { - if (heading) { - element.html(""); - element.append(heading); - } - }); - } - }; -}); - -angular.module("ui.bootstrap.alert", []).controller("AlertController", [ "$scope", "$attrs", function($scope, $attrs) { - $scope.closeable = "close" in $attrs; -} ]).directive("alert", function() { - return { - "restrict": "EA", - "controller": "AlertController", - "templateUrl": "template/alert/alert.html", - "transclude": true, - "replace": true, - "scope": { - "type": "@", - "close": "&" - } - }; -}); - -angular.module("ui.bootstrap.bindHtml", []).directive("bindHtmlUnsafe", function() { - return function(scope, element, attr) { - element.addClass("ng-binding").data("$binding", attr.bindHtmlUnsafe); - scope.$watch(attr.bindHtmlUnsafe, function bindHtmlUnsafeWatchAction(value) { - element.html(value || ""); - }); - }; -}); - -angular.module("ui.bootstrap.buttons", []).constant("buttonConfig", { - "activeClass": "active", - "toggleEvent": "click" -}).controller("ButtonsController", [ "buttonConfig", function(buttonConfig) { - this.activeClass = buttonConfig.activeClass || "active"; - this.toggleEvent = buttonConfig.toggleEvent || "click"; -} ]).directive("btnRadio", function() { - return { - "require": [ "btnRadio", "ngModel" ], - "controller": "ButtonsController", - "link": function(scope, element, attrs, ctrls) { - var buttonsCtrl = ctrls[0], ngModelCtrl = ctrls[1]; - ngModelCtrl.$render = function() { - element.toggleClass(buttonsCtrl.activeClass, angular.equals(ngModelCtrl.$modelValue, scope.$eval(attrs.btnRadio))); - }; - element.bind(buttonsCtrl.toggleEvent, function() { - var isActive = element.hasClass(buttonsCtrl.activeClass); - if (!isActive || angular.isDefined(attrs.uncheckable)) { - scope.$apply(function() { - ngModelCtrl.$setViewValue(isActive ? null : scope.$eval(attrs.btnRadio)); - ngModelCtrl.$render(); - }); - } - }); - } - }; -}).directive("btnCheckbox", function() { - return { - "require": [ "btnCheckbox", "ngModel" ], - "controller": "ButtonsController", - "link": function(scope, element, attrs, ctrls) { - var buttonsCtrl = ctrls[0], ngModelCtrl = ctrls[1]; - function getTrueValue() { - return getCheckboxValue(attrs.btnCheckboxTrue, true); - } - function getFalseValue() { - return getCheckboxValue(attrs.btnCheckboxFalse, false); - } - function getCheckboxValue(attributeValue, defaultValue) { - var val = scope.$eval(attributeValue); - return angular.isDefined(val) ? val : defaultValue; - } - ngModelCtrl.$render = function() { - element.toggleClass(buttonsCtrl.activeClass, angular.equals(ngModelCtrl.$modelValue, getTrueValue())); - }; - element.bind(buttonsCtrl.toggleEvent, function() { - scope.$apply(function() { - ngModelCtrl.$setViewValue(element.hasClass(buttonsCtrl.activeClass) ? getFalseValue() : getTrueValue()); - ngModelCtrl.$render(); - }); - }); - } - }; -}); - -angular.module("ui.bootstrap.carousel", [ "ui.bootstrap.transition" ]).controller("CarouselController", [ "$scope", "$timeout", "$transition", function($scope, $timeout, $transition) { - var self = this, slides = self.slides = $scope.slides = [], currentIndex = -1, currentTimeout, isPlaying; - self.currentSlide = null; - var destroyed = false; - self.select = $scope.select = function(nextSlide, direction) { - var nextIndex = slides.indexOf(nextSlide); - if (direction === undefined) { - direction = nextIndex > currentIndex ? "next" : "prev"; - } - if (nextSlide && nextSlide !== self.currentSlide) { - if ($scope.$currentTransition) { - $scope.$currentTransition.cancel(); - $timeout(goNext); - } else { - goNext(); - } - } - function goNext() { - if (destroyed) { - return; - } - if (self.currentSlide && angular.isString(direction) && !$scope.noTransition && nextSlide.$element) { - nextSlide.$element.addClass(direction); - var reflow = nextSlide.$element[0].offsetWidth; - angular.forEach(slides, function(slide) { - angular.extend(slide, { - "direction": "", - "entering": false, - "leaving": false, - "active": false - }); - }); - angular.extend(nextSlide, { - "direction": direction, - "active": true, - "entering": true - }); - angular.extend(self.currentSlide || {}, { - "direction": direction, - "leaving": true - }); - $scope.$currentTransition = $transition(nextSlide.$element, {}); - (function(next, current) { - $scope.$currentTransition.then(function() { - transitionDone(next, current); - }, function() { - transitionDone(next, current); - }); - })(nextSlide, self.currentSlide); - } else { - transitionDone(nextSlide, self.currentSlide); - } - self.currentSlide = nextSlide; - currentIndex = nextIndex; - restartTimer(); - } - function transitionDone(next, current) { - angular.extend(next, { - "direction": "", - "active": true, - "leaving": false, - "entering": false - }); - angular.extend(current || {}, { - "direction": "", - "active": false, - "leaving": false, - "entering": false - }); - $scope.$currentTransition = null; - } - }; - $scope.$on("$destroy", function() { - destroyed = true; - }); - self.indexOfSlide = function(slide) { - return slides.indexOf(slide); - }; - $scope.next = function() { - var newIndex = (currentIndex + 1) % slides.length; - if (!$scope.$currentTransition) { - return self.select(slides[newIndex], "next"); - } - }; - $scope.prev = function() { - var newIndex = currentIndex - 1 < 0 ? slides.length - 1 : currentIndex - 1; - if (!$scope.$currentTransition) { - return self.select(slides[newIndex], "prev"); - } - }; - $scope.isActive = function(slide) { - return self.currentSlide === slide; - }; - $scope.$watch("interval", restartTimer); - $scope.$on("$destroy", resetTimer); - function restartTimer() { - resetTimer(); - var interval = +$scope.interval; - if (!isNaN(interval) && interval >= 0) { - currentTimeout = $timeout(timerFn, interval); - } - } - function resetTimer() { - if (currentTimeout) { - $timeout.cancel(currentTimeout); - currentTimeout = null; - } - } - function timerFn() { - if (isPlaying) { - $scope.next(); - restartTimer(); - } else { - $scope.pause(); - } - } - $scope.play = function() { - if (!isPlaying) { - isPlaying = true; - restartTimer(); - } - }; - $scope.pause = function() { - if (!$scope.noPause) { - isPlaying = false; - resetTimer(); - } - }; - self.addSlide = function(slide, element) { - slide.$element = element; - slides.push(slide); - if (slides.length === 1 || slide.active) { - self.select(slides[slides.length - 1]); - if (slides.length == 1) { - $scope.play(); - } - } else { - slide.active = false; - } - }; - self.removeSlide = function(slide) { - var index = slides.indexOf(slide); - slides.splice(index, 1); - if (slides.length > 0 && slide.active) { - if (index >= slides.length) { - self.select(slides[index - 1]); - } else { - self.select(slides[index]); - } - } else if (currentIndex > index) { - currentIndex--; - } - }; -} ]).directive("carousel", [ function() { - return { - "restrict": "EA", - "transclude": true, - "replace": true, - "controller": "CarouselController", - "require": "carousel", - "templateUrl": "template/carousel/carousel.html", - "scope": { - "interval": "=", - "noTransition": "=", - "noPause": "=" - } - }; -} ]).directive("slide", function() { - return { - "require": "^carousel", - "restrict": "EA", - "transclude": true, - "replace": true, - "templateUrl": "template/carousel/slide.html", - "scope": { - "active": "=?" - }, - "link": function(scope, element, attrs, carouselCtrl) { - carouselCtrl.addSlide(scope, element); - scope.$on("$destroy", function() { - carouselCtrl.removeSlide(scope); - }); - scope.$watch("active", function(active) { - if (active) { - carouselCtrl.select(scope); - } - }); - } - }; -}); - -angular.module("ui.bootstrap.dateparser", []).service("dateParser", [ "$locale", "orderByFilter", function($locale, orderByFilter) { - this.parsers = {}; - var formatCodeToRegex = { - "yyyy": { - "regex": "\\d{4}", - "apply": function(value) { - this.year = +value; - } - }, - "yy": { - "regex": "\\d{2}", - "apply": function(value) { - this.year = +value + 2e3; - } - }, - "y": { - "regex": "\\d{1,4}", - "apply": function(value) { - this.year = +value; - } - }, - "MMMM": { - "regex": $locale.DATETIME_FORMATS.MONTH.join("|"), - "apply": function(value) { - this.month = $locale.DATETIME_FORMATS.MONTH.indexOf(value); - } - }, - "MMM": { - "regex": $locale.DATETIME_FORMATS.SHORTMONTH.join("|"), - "apply": function(value) { - this.month = $locale.DATETIME_FORMATS.SHORTMONTH.indexOf(value); - } - }, - "MM": { - "regex": "0[1-9]|1[0-2]", - "apply": function(value) { - this.month = value - 1; - } - }, - "M": { - "regex": "[1-9]|1[0-2]", - "apply": function(value) { - this.month = value - 1; - } - }, - "dd": { - "regex": "[0-2][0-9]{1}|3[0-1]{1}", - "apply": function(value) { - this.date = +value; - } - }, - "d": { - "regex": "[1-2]?[0-9]{1}|3[0-1]{1}", - "apply": function(value) { - this.date = +value; - } - }, - "EEEE": { - "regex": $locale.DATETIME_FORMATS.DAY.join("|") - }, - "EEE": { - "regex": $locale.DATETIME_FORMATS.SHORTDAY.join("|") - } - }; - function createParser(format) { - var map = [], regex = format.split(""); - angular.forEach(formatCodeToRegex, function(data, code) { - var index = format.indexOf(code); - if (index > -1) { - format = format.split(""); - regex[index] = "(" + data.regex + ")"; - format[index] = "$"; - for (var i = index + 1, n = index + code.length; i < n; i++) { - regex[i] = ""; - format[i] = "$"; - } - format = format.join(""); - map.push({ - "index": index, - "apply": data.apply - }); - } - }); - return { - "regex": new RegExp("^" + regex.join("") + "$"), - "map": orderByFilter(map, "index") - }; - } - this.parse = function(input, format) { - if (!angular.isString(input) || !format) { - return input; - } - format = $locale.DATETIME_FORMATS[format] || format; - if (!this.parsers[format]) { - this.parsers[format] = createParser(format); - } - var parser = this.parsers[format], regex = parser.regex, map = parser.map, results = input.match(regex); - if (results && results.length) { - var fields = { - "year": 1900, - "month": 0, - "date": 1, - "hours": 0 - }, dt; - for (var i = 1, n = results.length; i < n; i++) { - var mapper = map[i - 1]; - if (mapper.apply) { - mapper.apply.call(fields, results[i]); - } - } - if (isValid(fields.year, fields.month, fields.date)) { - dt = new Date(fields.year, fields.month, fields.date, fields.hours); - } - return dt; - } - }; - function isValid(year, month, date) { - if (month === 1 && date > 28) { - return date === 29 && (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0); - } - if (month === 3 || month === 5 || month === 8 || month === 10) { - return date < 31; - } - return true; - } -} ]); - -angular.module("ui.bootstrap.position", []).factory("$position", [ "$document", "$window", function($document, $window) { - function getStyle(el, cssprop) { - if (el.currentStyle) { - return el.currentStyle[cssprop]; - } else if ($window.getComputedStyle) { - return $window.getComputedStyle(el)[cssprop]; - } - return el.style[cssprop]; - } - function isStaticPositioned(element) { - return (getStyle(element, "position") || "static") === "static"; - } - var parentOffsetEl = function(element) { - var docDomEl = $document[0]; - var offsetParent = element.offsetParent || docDomEl; - while (offsetParent && offsetParent !== docDomEl && isStaticPositioned(offsetParent)) { - offsetParent = offsetParent.offsetParent; - } - return offsetParent || docDomEl; - }; - return { - "position": function(element) { - var elBCR = this.offset(element); - var offsetParentBCR = { - "top": 0, - "left": 0 - }; - var offsetParentEl = parentOffsetEl(element[0]); - if (offsetParentEl != $document[0]) { - offsetParentBCR = this.offset(angular.element(offsetParentEl)); - offsetParentBCR.top += offsetParentEl.clientTop - offsetParentEl.scrollTop; - offsetParentBCR.left += offsetParentEl.clientLeft - offsetParentEl.scrollLeft; - } - var boundingClientRect = element[0].getBoundingClientRect(); - return { - "width": boundingClientRect.width || element.prop("offsetWidth"), - "height": boundingClientRect.height || element.prop("offsetHeight"), - "top": elBCR.top - offsetParentBCR.top, - "left": elBCR.left - offsetParentBCR.left - }; - }, - "offset": function(element) { - var boundingClientRect = element[0].getBoundingClientRect(); - return { - "width": boundingClientRect.width || element.prop("offsetWidth"), - "height": boundingClientRect.height || element.prop("offsetHeight"), - "top": boundingClientRect.top + ($window.pageYOffset || $document[0].documentElement.scrollTop), - "left": boundingClientRect.left + ($window.pageXOffset || $document[0].documentElement.scrollLeft) - }; - }, - "positionElements": function(hostEl, targetEl, positionStr, appendToBody) { - var positionStrParts = positionStr.split("-"); - var pos0 = positionStrParts[0], pos1 = positionStrParts[1] || "center"; - var hostElPos, targetElWidth, targetElHeight, targetElPos; - hostElPos = appendToBody ? this.offset(hostEl) : this.position(hostEl); - targetElWidth = targetEl.prop("offsetWidth"); - targetElHeight = targetEl.prop("offsetHeight"); - var shiftWidth = { - "center": function() { - return hostElPos.left + hostElPos.width / 2 - targetElWidth / 2; - }, - "left": function() { - return hostElPos.left; - }, - "right": function() { - return hostElPos.left + hostElPos.width; - } - }; - var shiftHeight = { - "center": function() { - return hostElPos.top + hostElPos.height / 2 - targetElHeight / 2; - }, - "top": function() { - return hostElPos.top; - }, - "bottom": function() { - return hostElPos.top + hostElPos.height; - } - }; - switch (pos0) { - case "right": - targetElPos = { - "top": shiftHeight[pos1](), - "left": shiftWidth[pos0]() - }; - break; - - case "left": - targetElPos = { - "top": shiftHeight[pos1](), - "left": hostElPos.left - targetElWidth - }; - break; - - case "bottom": - targetElPos = { - "top": shiftHeight[pos0](), - "left": shiftWidth[pos1]() - }; - break; - - default: - targetElPos = { - "top": hostElPos.top - targetElHeight, - "left": shiftWidth[pos1]() - }; - break; - } - return targetElPos; - } - }; -} ]); - -angular.module("ui.bootstrap.datepicker", [ "ui.bootstrap.dateparser", "ui.bootstrap.position" ]).constant("datepickerConfig", { - "formatDay": "dd", - "formatMonth": "MMMM", - "formatYear": "yyyy", - "formatDayHeader": "EEE", - "formatDayTitle": "MMMM yyyy", - "formatMonthTitle": "yyyy", - "datepickerMode": "day", - "minMode": "day", - "maxMode": "year", - "showWeeks": true, - "startingDay": 0, - "yearRange": 20, - "minDate": null, - "maxDate": null -}).controller("DatepickerController", [ "$scope", "$attrs", "$parse", "$interpolate", "$timeout", "$log", "dateFilter", "datepickerConfig", function($scope, $attrs, $parse, $interpolate, $timeout, $log, dateFilter, datepickerConfig) { - var self = this, ngModelCtrl = { - "$setViewValue": angular.noop - }; - this.modes = [ "day", "month", "year" ]; - angular.forEach([ "formatDay", "formatMonth", "formatYear", "formatDayHeader", "formatDayTitle", "formatMonthTitle", "minMode", "maxMode", "showWeeks", "startingDay", "yearRange" ], function(key, index) { - self[key] = angular.isDefined($attrs[key]) ? index < 8 ? $interpolate($attrs[key])($scope.$parent) : $scope.$parent.$eval($attrs[key]) : datepickerConfig[key]; - }); - angular.forEach([ "minDate", "maxDate" ], function(key) { - if ($attrs[key]) { - $scope.$parent.$watch($parse($attrs[key]), function(value) { - self[key] = value ? new Date(value) : null; - self.refreshView(); - }); - } else { - self[key] = datepickerConfig[key] ? new Date(datepickerConfig[key]) : null; - } - }); - $scope.datepickerMode = $scope.datepickerMode || datepickerConfig.datepickerMode; - $scope.uniqueId = "datepicker-" + $scope.$id + "-" + Math.floor(Math.random() * 1e4); - this.activeDate = angular.isDefined($attrs.initDate) ? $scope.$parent.$eval($attrs.initDate) : new Date(); - $scope.isActive = function(dateObject) { - if (self.compare(dateObject.date, self.activeDate) === 0) { - $scope.activeDateId = dateObject.uid; - return true; - } - return false; - }; - this.init = function(ngModelCtrl_) { - ngModelCtrl = ngModelCtrl_; - ngModelCtrl.$render = function() { - self.render(); - }; - }; - this.render = function() { - if (ngModelCtrl.$modelValue) { - var date = new Date(ngModelCtrl.$modelValue), isValid = !isNaN(date); - if (isValid) { - this.activeDate = date; - } else { - $log.error('Datepicker directive: "ng-model" value must be a Date object, a number of milliseconds since 01.01.1970 or a string representing an RFC2822 or ISO 8601 date.'); - } - ngModelCtrl.$setValidity("date", isValid); - } - this.refreshView(); - }; - this.refreshView = function() { - if (this.element) { - this._refreshView(); - var date = ngModelCtrl.$modelValue ? new Date(ngModelCtrl.$modelValue) : null; - ngModelCtrl.$setValidity("date-disabled", !date || this.element && !this.isDisabled(date)); - } - }; - this.createDateObject = function(date, format) { - var model = ngModelCtrl.$modelValue ? new Date(ngModelCtrl.$modelValue) : null; - return { - "date": date, - "label": dateFilter(date, format), - "selected": model && this.compare(date, model) === 0, - "disabled": this.isDisabled(date), - "current": this.compare(date, new Date()) === 0 - }; - }; - this.isDisabled = function(date) { - return this.minDate && this.compare(date, this.minDate) < 0 || this.maxDate && this.compare(date, this.maxDate) > 0 || $attrs.dateDisabled && $scope.dateDisabled({ - "date": date, - "mode": $scope.datepickerMode - }); - }; - this.split = function(arr, size) { - var arrays = []; - while (arr.length > 0) { - arrays.push(arr.splice(0, size)); - } - return arrays; - }; - $scope.select = function(date) { - if ($scope.datepickerMode === self.minMode) { - var dt = ngModelCtrl.$modelValue ? new Date(ngModelCtrl.$modelValue) : new Date(0, 0, 0, 0, 0, 0, 0); - dt.setFullYear(date.getFullYear(), date.getMonth(), date.getDate()); - ngModelCtrl.$setViewValue(dt); - ngModelCtrl.$render(); - } else { - self.activeDate = date; - $scope.datepickerMode = self.modes[self.modes.indexOf($scope.datepickerMode) - 1]; - } - }; - $scope.move = function(direction) { - var year = self.activeDate.getFullYear() + direction * (self.step.years || 0), month = self.activeDate.getMonth() + direction * (self.step.months || 0); - self.activeDate.setFullYear(year, month, 1); - self.refreshView(); - }; - $scope.toggleMode = function(direction) { - direction = direction || 1; - if ($scope.datepickerMode === self.maxMode && direction === 1 || $scope.datepickerMode === self.minMode && direction === -1) { - return; - } - $scope.datepickerMode = self.modes[self.modes.indexOf($scope.datepickerMode) + direction]; - }; - $scope.keys = { - "13": "enter", - "32": "space", - "33": "pageup", - "34": "pagedown", - "35": "end", - "36": "home", - "37": "left", - "38": "up", - "39": "right", - "40": "down" - }; - var focusElement = function() { - $timeout(function() { - self.element[0].focus(); - }, 0, false); - }; - $scope.$on("datepicker.focus", focusElement); - $scope.keydown = function(evt) { - var key = $scope.keys[evt.which]; - if (!key || evt.shiftKey || evt.altKey) { - return; - } - evt.preventDefault(); - evt.stopPropagation(); - if (key === "enter" || key === "space") { - if (self.isDisabled(self.activeDate)) { - return; - } - $scope.select(self.activeDate); - focusElement(); - } else if (evt.ctrlKey && (key === "up" || key === "down")) { - $scope.toggleMode(key === "up" ? 1 : -1); - focusElement(); - } else { - self.handleKeyDown(key, evt); - self.refreshView(); - } - }; -} ]).directive("datepicker", function() { - return { - "restrict": "EA", - "replace": true, - "templateUrl": "template/datepicker/datepicker.html", - "scope": { - "datepickerMode": "=?", - "dateDisabled": "&" - }, - "require": [ "datepicker", "?^ngModel" ], - "controller": "DatepickerController", - "link": function(scope, element, attrs, ctrls) { - var datepickerCtrl = ctrls[0], ngModelCtrl = ctrls[1]; - if (ngModelCtrl) { - datepickerCtrl.init(ngModelCtrl); - } - } - }; -}).directive("daypicker", [ "dateFilter", function(dateFilter) { - return { - "restrict": "EA", - "replace": true, - "templateUrl": "template/datepicker/day.html", - "require": "^datepicker", - "link": function(scope, element, attrs, ctrl) { - scope.showWeeks = ctrl.showWeeks; - ctrl.step = { - "months": 1 - }; - ctrl.element = element; - var DAYS_IN_MONTH = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ]; - function getDaysInMonth(year, month) { - return month === 1 && year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0) ? 29 : DAYS_IN_MONTH[month]; - } - function getDates(startDate, n) { - var dates = new Array(n), current = new Date(startDate), i = 0; - current.setHours(12); - while (i < n) { - dates[i++] = new Date(current); - current.setDate(current.getDate() + 1); - } - return dates; - } - ctrl._refreshView = function() { - var year = ctrl.activeDate.getFullYear(), month = ctrl.activeDate.getMonth(), firstDayOfMonth = new Date(year, month, 1), difference = ctrl.startingDay - firstDayOfMonth.getDay(), numDisplayedFromPreviousMonth = difference > 0 ? 7 - difference : -difference, firstDate = new Date(firstDayOfMonth); - if (numDisplayedFromPreviousMonth > 0) { - firstDate.setDate(-numDisplayedFromPreviousMonth + 1); - } - var days = getDates(firstDate, 42); - for (var i = 0; i < 42; i++) { - days[i] = angular.extend(ctrl.createDateObject(days[i], ctrl.formatDay), { - "secondary": days[i].getMonth() !== month, - "uid": scope.uniqueId + "-" + i - }); - } - scope.labels = new Array(7); - for (var j = 0; j < 7; j++) { - scope.labels[j] = { - "abbr": dateFilter(days[j].date, ctrl.formatDayHeader), - "full": dateFilter(days[j].date, "EEEE") - }; - } - scope.title = dateFilter(ctrl.activeDate, ctrl.formatDayTitle); - scope.rows = ctrl.split(days, 7); - if (scope.showWeeks) { - scope.weekNumbers = []; - var weekNumber = getISO8601WeekNumber(scope.rows[0][0].date), numWeeks = scope.rows.length; - while (scope.weekNumbers.push(weekNumber++) < numWeeks) {} - } - }; - ctrl.compare = function(date1, date2) { - return new Date(date1.getFullYear(), date1.getMonth(), date1.getDate()) - new Date(date2.getFullYear(), date2.getMonth(), date2.getDate()); - }; - function getISO8601WeekNumber(date) { - var checkDate = new Date(date); - checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7)); - var time = checkDate.getTime(); - checkDate.setMonth(0); - checkDate.setDate(1); - return Math.floor(Math.round((time - checkDate) / 864e5) / 7) + 1; - } - ctrl.handleKeyDown = function(key, evt) { - var date = ctrl.activeDate.getDate(); - if (key === "left") { - date = date - 1; - } else if (key === "up") { - date = date - 7; - } else if (key === "right") { - date = date + 1; - } else if (key === "down") { - date = date + 7; - } else if (key === "pageup" || key === "pagedown") { - var month = ctrl.activeDate.getMonth() + (key === "pageup" ? -1 : 1); - ctrl.activeDate.setMonth(month, 1); - date = Math.min(getDaysInMonth(ctrl.activeDate.getFullYear(), ctrl.activeDate.getMonth()), date); - } else if (key === "home") { - date = 1; - } else if (key === "end") { - date = getDaysInMonth(ctrl.activeDate.getFullYear(), ctrl.activeDate.getMonth()); - } - ctrl.activeDate.setDate(date); - }; - ctrl.refreshView(); - } - }; -} ]).directive("monthpicker", [ "dateFilter", function(dateFilter) { - return { - "restrict": "EA", - "replace": true, - "templateUrl": "template/datepicker/month.html", - "require": "^datepicker", - "link": function(scope, element, attrs, ctrl) { - ctrl.step = { - "years": 1 - }; - ctrl.element = element; - ctrl._refreshView = function() { - var months = new Array(12), year = ctrl.activeDate.getFullYear(); - for (var i = 0; i < 12; i++) { - months[i] = angular.extend(ctrl.createDateObject(new Date(year, i, 1), ctrl.formatMonth), { - "uid": scope.uniqueId + "-" + i - }); - } - scope.title = dateFilter(ctrl.activeDate, ctrl.formatMonthTitle); - scope.rows = ctrl.split(months, 3); - }; - ctrl.compare = function(date1, date2) { - return new Date(date1.getFullYear(), date1.getMonth()) - new Date(date2.getFullYear(), date2.getMonth()); - }; - ctrl.handleKeyDown = function(key, evt) { - var date = ctrl.activeDate.getMonth(); - if (key === "left") { - date = date - 1; - } else if (key === "up") { - date = date - 3; - } else if (key === "right") { - date = date + 1; - } else if (key === "down") { - date = date + 3; - } else if (key === "pageup" || key === "pagedown") { - var year = ctrl.activeDate.getFullYear() + (key === "pageup" ? -1 : 1); - ctrl.activeDate.setFullYear(year); - } else if (key === "home") { - date = 0; - } else if (key === "end") { - date = 11; - } - ctrl.activeDate.setMonth(date); - }; - ctrl.refreshView(); - } - }; -} ]).directive("yearpicker", [ "dateFilter", function(dateFilter) { - return { - "restrict": "EA", - "replace": true, - "templateUrl": "template/datepicker/year.html", - "require": "^datepicker", - "link": function(scope, element, attrs, ctrl) { - var range = ctrl.yearRange; - ctrl.step = { - "years": range - }; - ctrl.element = element; - function getStartingYear(year) { - return parseInt((year - 1) / range, 10) * range + 1; - } - ctrl._refreshView = function() { - var years = new Array(range); - for (var i = 0, start = getStartingYear(ctrl.activeDate.getFullYear()); i < range; i++) { - years[i] = angular.extend(ctrl.createDateObject(new Date(start + i, 0, 1), ctrl.formatYear), { - "uid": scope.uniqueId + "-" + i - }); - } - scope.title = [ years[0].label, years[range - 1].label ].join(" - "); - scope.rows = ctrl.split(years, 5); - }; - ctrl.compare = function(date1, date2) { - return date1.getFullYear() - date2.getFullYear(); - }; - ctrl.handleKeyDown = function(key, evt) { - var date = ctrl.activeDate.getFullYear(); - if (key === "left") { - date = date - 1; - } else if (key === "up") { - date = date - 5; - } else if (key === "right") { - date = date + 1; - } else if (key === "down") { - date = date + 5; - } else if (key === "pageup" || key === "pagedown") { - date += (key === "pageup" ? -1 : 1) * ctrl.step.years; - } else if (key === "home") { - date = getStartingYear(ctrl.activeDate.getFullYear()); - } else if (key === "end") { - date = getStartingYear(ctrl.activeDate.getFullYear()) + range - 1; - } - ctrl.activeDate.setFullYear(date); - }; - ctrl.refreshView(); - } - }; -} ]).constant("datepickerPopupConfig", { - "datepickerPopup": "yyyy-MM-dd", - "currentText": "Today", - "clearText": "Clear", - "closeText": "Done", - "closeOnDateSelection": true, - "appendToBody": false, - "showButtonBar": true -}).directive("datepickerPopup", [ "$compile", "$parse", "$document", "$position", "dateFilter", "dateParser", "datepickerPopupConfig", function($compile, $parse, $document, $position, dateFilter, dateParser, datepickerPopupConfig) { - return { - "restrict": "EA", - "require": "ngModel", - "scope": { - "isOpen": "=?", - "currentText": "@", - "clearText": "@", - "closeText": "@", - "dateDisabled": "&" - }, - "link": function(scope, element, attrs, ngModel) { - var dateFormat, closeOnDateSelection = angular.isDefined(attrs.closeOnDateSelection) ? scope.$parent.$eval(attrs.closeOnDateSelection) : datepickerPopupConfig.closeOnDateSelection, appendToBody = angular.isDefined(attrs.datepickerAppendToBody) ? scope.$parent.$eval(attrs.datepickerAppendToBody) : datepickerPopupConfig.appendToBody; - scope.showButtonBar = angular.isDefined(attrs.showButtonBar) ? scope.$parent.$eval(attrs.showButtonBar) : datepickerPopupConfig.showButtonBar; - scope.getText = function(key) { - return scope[key + "Text"] || datepickerPopupConfig[key + "Text"]; - }; - attrs.$observe("datepickerPopup", function(value) { - dateFormat = value || datepickerPopupConfig.datepickerPopup; - ngModel.$render(); - }); - var popupEl = angular.element("
    "); - popupEl.attr({ - "ng-model": "date", - "ng-change": "dateSelection()" - }); - function cameltoDash(string) { - return string.replace(/([A-Z])/g, function($1) { - return "-" + $1.toLowerCase(); - }); - } - var datepickerEl = angular.element(popupEl.children()[0]); - if (attrs.datepickerOptions) { - angular.forEach(scope.$parent.$eval(attrs.datepickerOptions), function(value, option) { - datepickerEl.attr(cameltoDash(option), value); - }); - } - scope.watchData = {}; - angular.forEach([ "minDate", "maxDate", "datepickerMode" ], function(key) { - if (attrs[key]) { - var getAttribute = $parse(attrs[key]); - scope.$parent.$watch(getAttribute, function(value) { - scope.watchData[key] = value; - }); - datepickerEl.attr(cameltoDash(key), "watchData." + key); - if (key === "datepickerMode") { - var setAttribute = getAttribute.assign; - scope.$watch("watchData." + key, function(value, oldvalue) { - if (value !== oldvalue) { - setAttribute(scope.$parent, value); - } - }); - } - } - }); - if (attrs.dateDisabled) { - datepickerEl.attr("date-disabled", "dateDisabled({ date: date, mode: mode })"); - } - function parseDate(viewValue) { - if (!viewValue) { - ngModel.$setValidity("date", true); - return null; - } else if (angular.isDate(viewValue) && !isNaN(viewValue)) { - ngModel.$setValidity("date", true); - return viewValue; - } else if (angular.isString(viewValue)) { - var date = dateParser.parse(viewValue, dateFormat) || new Date(viewValue); - if (isNaN(date)) { - ngModel.$setValidity("date", false); - return undefined; - } else { - ngModel.$setValidity("date", true); - return date; - } - } else { - ngModel.$setValidity("date", false); - return undefined; - } - } - ngModel.$parsers.unshift(parseDate); - scope.dateSelection = function(dt) { - if (angular.isDefined(dt)) { - scope.date = dt; - } - ngModel.$setViewValue(scope.date); - ngModel.$render(); - if (closeOnDateSelection) { - scope.isOpen = false; - element[0].focus(); - } - }; - element.bind("input change keyup", function() { - scope.$apply(function() { - scope.date = ngModel.$modelValue; - }); - }); - ngModel.$render = function() { - var date = ngModel.$viewValue ? dateFilter(ngModel.$viewValue, dateFormat) : ""; - element.val(date); - scope.date = parseDate(ngModel.$modelValue); - }; - var documentClickBind = function(event) { - if (scope.isOpen && event.target !== element[0]) { - scope.$apply(function() { - scope.isOpen = false; - }); - } - }; - var keydown = function(evt, noApply) { - scope.keydown(evt); - }; - element.bind("keydown", keydown); - scope.keydown = function(evt) { - if (evt.which === 27) { - evt.preventDefault(); - evt.stopPropagation(); - scope.close(); - } else if (evt.which === 40 && !scope.isOpen) { - scope.isOpen = true; - } - }; - scope.$watch("isOpen", function(value) { - if (value) { - scope.$broadcast("datepicker.focus"); - scope.position = appendToBody ? $position.offset(element) : $position.position(element); - scope.position.top = scope.position.top + element.prop("offsetHeight"); - $document.bind("click", documentClickBind); - } else { - $document.unbind("click", documentClickBind); - } - }); - scope.select = function(date) { - if (date === "today") { - var today = new Date(); - if (angular.isDate(ngModel.$modelValue)) { - date = new Date(ngModel.$modelValue); - date.setFullYear(today.getFullYear(), today.getMonth(), today.getDate()); - } else { - date = new Date(today.setHours(0, 0, 0, 0)); - } - } - scope.dateSelection(date); - }; - scope.close = function() { - scope.isOpen = false; - element[0].focus(); - }; - var $popup = $compile(popupEl)(scope); - popupEl.remove(); - if (appendToBody) { - $document.find("body").append($popup); - } else { - element.after($popup); - } - scope.$on("$destroy", function() { - $popup.remove(); - element.unbind("keydown", keydown); - $document.unbind("click", documentClickBind); - }); - } - }; -} ]).directive("datepickerPopupWrap", function() { - return { - "restrict": "EA", - "replace": true, - "transclude": true, - "templateUrl": "template/datepicker/popup.html", - "link": function(scope, element, attrs) { - element.bind("click", function(event) { - event.preventDefault(); - event.stopPropagation(); - }); - } - }; -}); - -angular.module("ui.bootstrap.dropdown", []).constant("dropdownConfig", { - "openClass": "open" -}).service("dropdownService", [ "$document", function($document) { - var openScope = null; - this.open = function(dropdownScope) { - if (!openScope) { - $document.bind("click", closeDropdown); - $document.bind("keydown", escapeKeyBind); - } - if (openScope && openScope !== dropdownScope) { - openScope.isOpen = false; - } - openScope = dropdownScope; - }; - this.close = function(dropdownScope) { - if (openScope === dropdownScope) { - openScope = null; - $document.unbind("click", closeDropdown); - $document.unbind("keydown", escapeKeyBind); - } - }; - var closeDropdown = function(evt) { - var toggleElement = openScope.getToggleElement(); - if (evt && toggleElement && toggleElement[0].contains(evt.target)) { - return; - } - openScope.$apply(function() { - openScope.isOpen = false; - }); - }; - var escapeKeyBind = function(evt) { - if (evt.which === 27) { - openScope.focusToggleElement(); - closeDropdown(); - } - }; -} ]).controller("DropdownController", [ "$scope", "$attrs", "$parse", "dropdownConfig", "dropdownService", "$animate", function($scope, $attrs, $parse, dropdownConfig, dropdownService, $animate) { - var self = this, scope = $scope.$new(), openClass = dropdownConfig.openClass, getIsOpen, setIsOpen = angular.noop, toggleInvoker = $attrs.onToggle ? $parse($attrs.onToggle) : angular.noop; - this.init = function(element) { - self.$element = element; - if ($attrs.isOpen) { - getIsOpen = $parse($attrs.isOpen); - setIsOpen = getIsOpen.assign; - $scope.$watch(getIsOpen, function(value) { - scope.isOpen = !!value; - }); - } - }; - this.toggle = function(open) { - return scope.isOpen = arguments.length ? !!open : !scope.isOpen; - }; - this.isOpen = function() { - return scope.isOpen; - }; - scope.getToggleElement = function() { - return self.toggleElement; - }; - scope.focusToggleElement = function() { - if (self.toggleElement) { - self.toggleElement[0].focus(); - } - }; - scope.$watch("isOpen", function(isOpen, wasOpen) { - $animate[isOpen ? "addClass" : "removeClass"](self.$element, openClass); - if (isOpen) { - scope.focusToggleElement(); - dropdownService.open(scope); - } else { - dropdownService.close(scope); - } - setIsOpen($scope, isOpen); - if (angular.isDefined(isOpen) && isOpen !== wasOpen) { - toggleInvoker($scope, { - "open": !!isOpen - }); - } - }); - $scope.$on("$locationChangeSuccess", function() { - scope.isOpen = false; - }); - $scope.$on("$destroy", function() { - scope.$destroy(); - }); -} ]).directive("dropdown", function() { - return { - "restrict": "CA", - "controller": "DropdownController", - "link": function(scope, element, attrs, dropdownCtrl) { - dropdownCtrl.init(element); - } - }; -}).directive("dropdownToggle", function() { - return { - "restrict": "CA", - "require": "?^dropdown", - "link": function(scope, element, attrs, dropdownCtrl) { - if (!dropdownCtrl) { - return; - } - dropdownCtrl.toggleElement = element; - var toggleDropdown = function(event) { - event.preventDefault(); - if (!element.hasClass("disabled") && !attrs.disabled) { - scope.$apply(function() { - dropdownCtrl.toggle(); - }); - } - }; - element.bind("click", toggleDropdown); - element.attr({ - "aria-haspopup": true, - "aria-expanded": false - }); - scope.$watch(dropdownCtrl.isOpen, function(isOpen) { - element.attr("aria-expanded", !!isOpen); - }); - scope.$on("$destroy", function() { - element.unbind("click", toggleDropdown); - }); - } - }; -}); - -angular.module("ui.bootstrap.modal", [ "ui.bootstrap.transition" ]).factory("$$stackedMap", function() { - return { - "createNew": function() { - var stack = []; - return { - "add": function(key, value) { - stack.push({ - "key": key, - "value": value - }); - }, - "get": function(key) { - for (var i = 0; i < stack.length; i++) { - if (key == stack[i].key) { - return stack[i]; - } - } - }, - "keys": function() { - var keys = []; - for (var i = 0; i < stack.length; i++) { - keys.push(stack[i].key); - } - return keys; - }, - "top": function() { - return stack[stack.length - 1]; - }, - "remove": function(key) { - var idx = -1; - for (var i = 0; i < stack.length; i++) { - if (key == stack[i].key) { - idx = i; - break; - } - } - return stack.splice(idx, 1)[0]; - }, - "removeTop": function() { - return stack.splice(stack.length - 1, 1)[0]; - }, - "length": function() { - return stack.length; - } - }; - } - }; -}).directive("modalBackdrop", [ "$timeout", function($timeout) { - return { - "restrict": "EA", - "replace": true, - "templateUrl": "template/modal/backdrop.html", - "link": function(scope, element, attrs) { - scope.backdropClass = attrs.backdropClass || ""; - scope.animate = false; - $timeout(function() { - scope.animate = true; - }); - } - }; -} ]).directive("modalWindow", [ "$modalStack", "$timeout", function($modalStack, $timeout) { - return { - "restrict": "EA", - "scope": { - "index": "@", - "animate": "=" - }, - "replace": true, - "transclude": true, - "templateUrl": function(tElement, tAttrs) { - return tAttrs.templateUrl || "template/modal/window.html"; - }, - "link": function(scope, element, attrs) { - element.addClass(attrs.windowClass || ""); - scope.size = attrs.size; - $timeout(function() { - scope.animate = true; - if (!element[0].querySelectorAll("[autofocus]").length) { - element[0].focus(); - } - }); - scope.close = function(evt) { - var modal = $modalStack.getTop(); - if (modal && modal.value.backdrop && modal.value.backdrop != "static" && evt.target === evt.currentTarget) { - evt.preventDefault(); - evt.stopPropagation(); - $modalStack.dismiss(modal.key, "backdrop click"); - } - }; - } - }; -} ]).directive("modalTransclude", function() { - return { - "link": function($scope, $element, $attrs, controller, $transclude) { - $transclude($scope.$parent, function(clone) { - $element.empty(); - $element.append(clone); - }); - } - }; -}).factory("$modalStack", [ "$transition", "$timeout", "$document", "$compile", "$rootScope", "$$stackedMap", function($transition, $timeout, $document, $compile, $rootScope, $$stackedMap) { - var OPENED_MODAL_CLASS = "modal-open"; - var backdropDomEl, backdropScope; - var openedWindows = $$stackedMap.createNew(); - var $modalStack = {}; - function backdropIndex() { - var topBackdropIndex = -1; - var opened = openedWindows.keys(); - for (var i = 0; i < opened.length; i++) { - if (openedWindows.get(opened[i]).value.backdrop) { - topBackdropIndex = i; - } - } - return topBackdropIndex; - } - $rootScope.$watch(backdropIndex, function(newBackdropIndex) { - if (backdropScope) { - backdropScope.index = newBackdropIndex; - } - }); - function removeModalWindow(modalInstance) { - var body = $document.find("body").eq(0); - var modalWindow = openedWindows.get(modalInstance).value; - openedWindows.remove(modalInstance); - removeAfterAnimate(modalWindow.modalDomEl, modalWindow.modalScope, 300, function() { - modalWindow.modalScope.$destroy(); - body.toggleClass(OPENED_MODAL_CLASS, openedWindows.length() > 0); - checkRemoveBackdrop(); - }); - } - function checkRemoveBackdrop() { - if (backdropDomEl && backdropIndex() == -1) { - var backdropScopeRef = backdropScope; - removeAfterAnimate(backdropDomEl, backdropScope, 150, function() { - backdropScopeRef.$destroy(); - backdropScopeRef = null; - }); - backdropDomEl = undefined; - backdropScope = undefined; - } - } - function removeAfterAnimate(domEl, scope, emulateTime, done) { - scope.animate = false; - var transitionEndEventName = $transition.transitionEndEventName; - if (transitionEndEventName) { - var timeout = $timeout(afterAnimating, emulateTime); - domEl.bind(transitionEndEventName, function() { - $timeout.cancel(timeout); - afterAnimating(); - scope.$apply(); - }); - } else { - $timeout(afterAnimating); - } - function afterAnimating() { - if (afterAnimating.done) { - return; - } - afterAnimating.done = true; - domEl.remove(); - if (done) { - done(); - } - } - } - $document.bind("keydown", function(evt) { - var modal; - if (evt.which === 27) { - modal = openedWindows.top(); - if (modal && modal.value.keyboard) { - evt.preventDefault(); - $rootScope.$apply(function() { - $modalStack.dismiss(modal.key, "escape key press"); - }); - } - } - }); - $modalStack.open = function(modalInstance, modal) { - openedWindows.add(modalInstance, { - "deferred": modal.deferred, - "modalScope": modal.scope, - "backdrop": modal.backdrop, - "keyboard": modal.keyboard - }); - var body = $document.find("body").eq(0), currBackdropIndex = backdropIndex(); - if (currBackdropIndex >= 0 && !backdropDomEl) { - backdropScope = $rootScope.$new(true); - backdropScope.index = currBackdropIndex; - var angularBackgroundDomEl = angular.element("
    "); - angularBackgroundDomEl.attr("backdrop-class", modal.backdropClass); - backdropDomEl = $compile(angularBackgroundDomEl)(backdropScope); - body.append(backdropDomEl); - } - var angularDomEl = angular.element("
    "); - angularDomEl.attr({ - "template-url": modal.windowTemplateUrl, - "window-class": modal.windowClass, - "size": modal.size, - "index": openedWindows.length() - 1, - "animate": "animate" - }).html(modal.content); - var modalDomEl = $compile(angularDomEl)(modal.scope); - openedWindows.top().value.modalDomEl = modalDomEl; - body.append(modalDomEl); - body.addClass(OPENED_MODAL_CLASS); - }; - $modalStack.close = function(modalInstance, result) { - var modalWindow = openedWindows.get(modalInstance); - if (modalWindow) { - modalWindow.value.deferred.resolve(result); - removeModalWindow(modalInstance); - } - }; - $modalStack.dismiss = function(modalInstance, reason) { - var modalWindow = openedWindows.get(modalInstance); - if (modalWindow) { - modalWindow.value.deferred.reject(reason); - removeModalWindow(modalInstance); - } - }; - $modalStack.dismissAll = function(reason) { - var topModal = this.getTop(); - while (topModal) { - this.dismiss(topModal.key, reason); - topModal = this.getTop(); - } - }; - $modalStack.getTop = function() { - return openedWindows.top(); - }; - return $modalStack; -} ]).provider("$modal", function() { - var $modalProvider = { - "options": { - "backdrop": true, - "keyboard": true - }, - "$get": [ "$injector", "$rootScope", "$q", "$http", "$templateCache", "$controller", "$modalStack", function($injector, $rootScope, $q, $http, $templateCache, $controller, $modalStack) { - var $modal = {}; - function getTemplatePromise(options) { - return options.template ? $q.when(options.template) : $http.get(angular.isFunction(options.templateUrl) ? options.templateUrl() : options.templateUrl, { - "cache": $templateCache - }).then(function(result) { - return result.data; - }); - } - function getResolvePromises(resolves) { - var promisesArr = []; - angular.forEach(resolves, function(value) { - if (angular.isFunction(value) || angular.isArray(value)) { - promisesArr.push($q.when($injector.invoke(value))); - } - }); - return promisesArr; - } - $modal.open = function(modalOptions) { - var modalResultDeferred = $q.defer(); - var modalOpenedDeferred = $q.defer(); - var modalInstance = { - "result": modalResultDeferred.promise, - "opened": modalOpenedDeferred.promise, - "close": function(result) { - $modalStack.close(modalInstance, result); - }, - "dismiss": function(reason) { - $modalStack.dismiss(modalInstance, reason); - } - }; - modalOptions = angular.extend({}, $modalProvider.options, modalOptions); - modalOptions.resolve = modalOptions.resolve || {}; - if (!modalOptions.template && !modalOptions.templateUrl) { - throw new Error("One of template or templateUrl options is required."); - } - var templateAndResolvePromise = $q.all([ getTemplatePromise(modalOptions) ].concat(getResolvePromises(modalOptions.resolve))); - templateAndResolvePromise.then(function resolveSuccess(tplAndVars) { - var modalScope = (modalOptions.scope || $rootScope).$new(); - modalScope.$close = modalInstance.close; - modalScope.$dismiss = modalInstance.dismiss; - var ctrlInstance, ctrlLocals = {}; - var resolveIter = 1; - if (modalOptions.controller) { - ctrlLocals.$scope = modalScope; - ctrlLocals.$modalInstance = modalInstance; - angular.forEach(modalOptions.resolve, function(value, key) { - ctrlLocals[key] = tplAndVars[resolveIter++]; - }); - ctrlInstance = $controller(modalOptions.controller, ctrlLocals); - if (modalOptions.controllerAs) { - modalScope[modalOptions.controllerAs] = ctrlInstance; - } - } - $modalStack.open(modalInstance, { - "scope": modalScope, - "deferred": modalResultDeferred, - "content": tplAndVars[0], - "backdrop": modalOptions.backdrop, - "keyboard": modalOptions.keyboard, - "backdropClass": modalOptions.backdropClass, - "windowClass": modalOptions.windowClass, - "windowTemplateUrl": modalOptions.windowTemplateUrl, - "size": modalOptions.size - }); - }, function resolveError(reason) { - modalResultDeferred.reject(reason); - }); - templateAndResolvePromise.then(function() { - modalOpenedDeferred.resolve(true); - }, function() { - modalOpenedDeferred.reject(false); - }); - return modalInstance; - }; - return $modal; - } ] - }; - return $modalProvider; -}); - -angular.module("ui.bootstrap.pagination", []).controller("PaginationController", [ "$scope", "$attrs", "$parse", function($scope, $attrs, $parse) { - var self = this, ngModelCtrl = { - "$setViewValue": angular.noop - }, setNumPages = $attrs.numPages ? $parse($attrs.numPages).assign : angular.noop; - this.init = function(ngModelCtrl_, config) { - ngModelCtrl = ngModelCtrl_; - this.config = config; - ngModelCtrl.$render = function() { - self.render(); - }; - if ($attrs.itemsPerPage) { - $scope.$parent.$watch($parse($attrs.itemsPerPage), function(value) { - self.itemsPerPage = parseInt(value, 10); - $scope.totalPages = self.calculateTotalPages(); - }); - } else { - this.itemsPerPage = config.itemsPerPage; - } - }; - this.calculateTotalPages = function() { - var totalPages = this.itemsPerPage < 1 ? 1 : Math.ceil($scope.totalItems / this.itemsPerPage); - return Math.max(totalPages || 0, 1); - }; - this.render = function() { - $scope.page = parseInt(ngModelCtrl.$viewValue, 10) || 1; - }; - $scope.selectPage = function(page) { - if ($scope.page !== page && page > 0 && page <= $scope.totalPages) { - ngModelCtrl.$setViewValue(page); - ngModelCtrl.$render(); - } - }; - $scope.getText = function(key) { - return $scope[key + "Text"] || self.config[key + "Text"]; - }; - $scope.noPrevious = function() { - return $scope.page === 1; - }; - $scope.noNext = function() { - return $scope.page === $scope.totalPages; - }; - $scope.$watch("totalItems", function() { - $scope.totalPages = self.calculateTotalPages(); - }); - $scope.$watch("totalPages", function(value) { - setNumPages($scope.$parent, value); - if ($scope.page > value) { - $scope.selectPage(value); - } else { - ngModelCtrl.$render(); - } - }); -} ]).constant("paginationConfig", { - "itemsPerPage": 10, - "boundaryLinks": false, - "directionLinks": true, - "firstText": "First", - "previousText": "Previous", - "nextText": "Next", - "lastText": "Last", - "rotate": true -}).directive("pagination", [ "$parse", "paginationConfig", function($parse, paginationConfig) { - return { - "restrict": "EA", - "scope": { - "totalItems": "=", - "firstText": "@", - "previousText": "@", - "nextText": "@", - "lastText": "@" - }, - "require": [ "pagination", "?ngModel" ], - "controller": "PaginationController", - "templateUrl": "template/pagination/pagination.html", - "replace": true, - "link": function(scope, element, attrs, ctrls) { - var paginationCtrl = ctrls[0], ngModelCtrl = ctrls[1]; - if (!ngModelCtrl) { - return; - } - var maxSize = angular.isDefined(attrs.maxSize) ? scope.$parent.$eval(attrs.maxSize) : paginationConfig.maxSize, rotate = angular.isDefined(attrs.rotate) ? scope.$parent.$eval(attrs.rotate) : paginationConfig.rotate; - scope.boundaryLinks = angular.isDefined(attrs.boundaryLinks) ? scope.$parent.$eval(attrs.boundaryLinks) : paginationConfig.boundaryLinks; - scope.directionLinks = angular.isDefined(attrs.directionLinks) ? scope.$parent.$eval(attrs.directionLinks) : paginationConfig.directionLinks; - paginationCtrl.init(ngModelCtrl, paginationConfig); - if (attrs.maxSize) { - scope.$parent.$watch($parse(attrs.maxSize), function(value) { - maxSize = parseInt(value, 10); - paginationCtrl.render(); - }); - } - function makePage(number, text, isActive) { - return { - "number": number, - "text": text, - "active": isActive - }; - } - function getPages(currentPage, totalPages) { - var pages = []; - var startPage = 1, endPage = totalPages; - var isMaxSized = angular.isDefined(maxSize) && maxSize < totalPages; - if (isMaxSized) { - if (rotate) { - startPage = Math.max(currentPage - Math.floor(maxSize / 2), 1); - endPage = startPage + maxSize - 1; - if (endPage > totalPages) { - endPage = totalPages; - startPage = endPage - maxSize + 1; - } - } else { - startPage = (Math.ceil(currentPage / maxSize) - 1) * maxSize + 1; - endPage = Math.min(startPage + maxSize - 1, totalPages); - } - } - for (var number = startPage; number <= endPage; number++) { - var page = makePage(number, number, number === currentPage); - pages.push(page); - } - if (isMaxSized && !rotate) { - if (startPage > 1) { - var previousPageSet = makePage(startPage - 1, "...", false); - pages.unshift(previousPageSet); - } - if (endPage < totalPages) { - var nextPageSet = makePage(endPage + 1, "...", false); - pages.push(nextPageSet); - } - } - return pages; - } - var originalRender = paginationCtrl.render; - paginationCtrl.render = function() { - originalRender(); - if (scope.page > 0 && scope.page <= scope.totalPages) { - scope.pages = getPages(scope.page, scope.totalPages); - } - }; - } - }; -} ]).constant("pagerConfig", { - "itemsPerPage": 10, - "previousText": "\xab Previous", - "nextText": "Next \xbb", - "align": true -}).directive("pager", [ "pagerConfig", function(pagerConfig) { - return { - "restrict": "EA", - "scope": { - "totalItems": "=", - "previousText": "@", - "nextText": "@" - }, - "require": [ "pager", "?ngModel" ], - "controller": "PaginationController", - "templateUrl": "template/pagination/pager.html", - "replace": true, - "link": function(scope, element, attrs, ctrls) { - var paginationCtrl = ctrls[0], ngModelCtrl = ctrls[1]; - if (!ngModelCtrl) { - return; - } - scope.align = angular.isDefined(attrs.align) ? scope.$parent.$eval(attrs.align) : pagerConfig.align; - paginationCtrl.init(ngModelCtrl, pagerConfig); - } - }; -} ]); - -angular.module("ui.bootstrap.tooltip", [ "ui.bootstrap.position", "ui.bootstrap.bindHtml" ]).provider("$tooltip", function() { - var defaultOptions = { - "placement": "top", - "animation": true, - "popupDelay": 0 - }; - var triggerMap = { - "mouseenter": "mouseleave", - "click": "click", - "focus": "blur" - }; - var globalOptions = {}; - this.options = function(value) { - angular.extend(globalOptions, value); - }; - this.setTriggers = function setTriggers(triggers) { - angular.extend(triggerMap, triggers); - }; - function snake_case(name) { - var regexp = /[A-Z]/g; - var separator = "-"; - return name.replace(regexp, function(letter, pos) { - return (pos ? separator : "") + letter.toLowerCase(); - }); - } - this.$get = [ "$window", "$compile", "$timeout", "$parse", "$document", "$position", "$interpolate", function($window, $compile, $timeout, $parse, $document, $position, $interpolate) { - return function $tooltip(type, prefix, defaultTriggerShow) { - var options = angular.extend({}, defaultOptions, globalOptions); - function getTriggers(trigger) { - var show = trigger || options.trigger || defaultTriggerShow; - var hide = triggerMap[show] || show; - return { - "show": show, - "hide": hide - }; - } - var directiveName = snake_case(type); - var startSym = $interpolate.startSymbol(); - var endSym = $interpolate.endSymbol(); - var template = "
    " + "
    "; - return { - "restrict": "EA", - "scope": true, - "compile": function(tElem, tAttrs) { - var tooltipLinker = $compile(template); - return function link(scope, element, attrs) { - var tooltip; - var transitionTimeout; - var popupTimeout; - var appendToBody = angular.isDefined(options.appendToBody) ? options.appendToBody : false; - var triggers = getTriggers(undefined); - var hasEnableExp = angular.isDefined(attrs[prefix + "Enable"]); - var positionTooltip = function() { - var ttPosition = $position.positionElements(element, tooltip, scope.tt_placement, appendToBody); - ttPosition.top += "px"; - ttPosition.left += "px"; - tooltip.css(ttPosition); - }; - scope.tt_isOpen = false; - function toggleTooltipBind() { - if (!scope.tt_isOpen) { - showTooltipBind(); - } else { - hideTooltipBind(); - } - } - function showTooltipBind() { - if (hasEnableExp && !scope.$eval(attrs[prefix + "Enable"])) { - return; - } - if (scope.tt_popupDelay) { - if (!popupTimeout) { - popupTimeout = $timeout(show, scope.tt_popupDelay, false); - popupTimeout.then(function(reposition) { - reposition(); - }); - } - } else { - show()(); - } - } - function hideTooltipBind() { - scope.$apply(function() { - hide(); - }); - } - function show() { - popupTimeout = null; - if (transitionTimeout) { - $timeout.cancel(transitionTimeout); - transitionTimeout = null; - } - if (!scope.tt_content) { - return angular.noop; - } - createTooltip(); - tooltip.css({ - "top": 0, - "left": 0, - "display": "block" - }); - if (appendToBody) { - $document.find("body").append(tooltip); - } else { - element.after(tooltip); - } - positionTooltip(); - scope.tt_isOpen = true; - scope.$digest(); - return positionTooltip; - } - function hide() { - scope.tt_isOpen = false; - $timeout.cancel(popupTimeout); - popupTimeout = null; - if (scope.tt_animation) { - if (!transitionTimeout) { - transitionTimeout = $timeout(removeTooltip, 500); - } - } else { - removeTooltip(); - } - } - function createTooltip() { - if (tooltip) { - removeTooltip(); - } - tooltip = tooltipLinker(scope, function() {}); - scope.$digest(); - } - function removeTooltip() { - transitionTimeout = null; - if (tooltip) { - tooltip.remove(); - tooltip = null; - } - } - attrs.$observe(type, function(val) { - scope.tt_content = val; - if (!val && scope.tt_isOpen) { - hide(); - } - }); - attrs.$observe(prefix + "Title", function(val) { - scope.tt_title = val; - }); - attrs.$observe(prefix + "Placement", function(val) { - scope.tt_placement = angular.isDefined(val) ? val : options.placement; - }); - attrs.$observe(prefix + "PopupDelay", function(val) { - var delay = parseInt(val, 10); - scope.tt_popupDelay = !isNaN(delay) ? delay : options.popupDelay; - }); - var unregisterTriggers = function() { - element.unbind(triggers.show, showTooltipBind); - element.unbind(triggers.hide, hideTooltipBind); - }; - attrs.$observe(prefix + "Trigger", function(val) { - unregisterTriggers(); - triggers = getTriggers(val); - if (triggers.show === triggers.hide) { - element.bind(triggers.show, toggleTooltipBind); - } else { - element.bind(triggers.show, showTooltipBind); - element.bind(triggers.hide, hideTooltipBind); - } - }); - var animation = scope.$eval(attrs[prefix + "Animation"]); - scope.tt_animation = angular.isDefined(animation) ? !!animation : options.animation; - attrs.$observe(prefix + "AppendToBody", function(val) { - appendToBody = angular.isDefined(val) ? $parse(val)(scope) : appendToBody; - }); - if (appendToBody) { - scope.$on("$locationChangeSuccess", function closeTooltipOnLocationChangeSuccess() { - if (scope.tt_isOpen) { - hide(); - } - }); - } - scope.$on("$destroy", function onDestroyTooltip() { - $timeout.cancel(transitionTimeout); - $timeout.cancel(popupTimeout); - unregisterTriggers(); - removeTooltip(); - }); - }; - } - }; - }; - } ]; -}).directive("tooltipPopup", function() { - return { - "restrict": "EA", - "replace": true, - "scope": { - "content": "@", - "placement": "@", - "animation": "&", - "isOpen": "&" - }, - "templateUrl": "template/tooltip/tooltip-popup.html" - }; -}).directive("tooltip", [ "$tooltip", function($tooltip) { - return $tooltip("tooltip", "tooltip", "mouseenter"); -} ]).directive("tooltipHtmlUnsafePopup", function() { - return { - "restrict": "EA", - "replace": true, - "scope": { - "content": "@", - "placement": "@", - "animation": "&", - "isOpen": "&" - }, - "templateUrl": "template/tooltip/tooltip-html-unsafe-popup.html" - }; -}).directive("tooltipHtmlUnsafe", [ "$tooltip", function($tooltip) { - return $tooltip("tooltipHtmlUnsafe", "tooltip", "mouseenter"); -} ]); - -angular.module("ui.bootstrap.popover", [ "ui.bootstrap.tooltip" ]).directive("popoverPopup", function() { - return { - "restrict": "EA", - "replace": true, - "scope": { - "title": "@", - "content": "@", - "placement": "@", - "animation": "&", - "isOpen": "&" - }, - "templateUrl": "template/popover/popover.html" - }; -}).directive("popover", [ "$tooltip", function($tooltip) { - return $tooltip("popover", "popover", "click"); -} ]); - -angular.module("ui.bootstrap.progressbar", []).constant("progressConfig", { - "animate": true, - "max": 100 -}).controller("ProgressController", [ "$scope", "$attrs", "progressConfig", function($scope, $attrs, progressConfig) { - var self = this, animate = angular.isDefined($attrs.animate) ? $scope.$parent.$eval($attrs.animate) : progressConfig.animate; - this.bars = []; - $scope.max = angular.isDefined($attrs.max) ? $scope.$parent.$eval($attrs.max) : progressConfig.max; - this.addBar = function(bar, element) { - if (!animate) { - element.css({ - "transition": "none" - }); - } - this.bars.push(bar); - bar.$watch("value", function(value) { - bar.percent = +(100 * value / $scope.max).toFixed(2); - }); - bar.$on("$destroy", function() { - element = null; - self.removeBar(bar); - }); - }; - this.removeBar = function(bar) { - this.bars.splice(this.bars.indexOf(bar), 1); - }; -} ]).directive("progress", function() { - return { - "restrict": "EA", - "replace": true, - "transclude": true, - "controller": "ProgressController", - "require": "progress", - "scope": {}, - "templateUrl": "template/progressbar/progress.html" - }; -}).directive("bar", function() { - return { - "restrict": "EA", - "replace": true, - "transclude": true, - "require": "^progress", - "scope": { - "value": "=", - "type": "@" - }, - "templateUrl": "template/progressbar/bar.html", - "link": function(scope, element, attrs, progressCtrl) { - progressCtrl.addBar(scope, element); - } - }; -}).directive("progressbar", function() { - return { - "restrict": "EA", - "replace": true, - "transclude": true, - "controller": "ProgressController", - "scope": { - "value": "=", - "type": "@" - }, - "templateUrl": "template/progressbar/progressbar.html", - "link": function(scope, element, attrs, progressCtrl) { - progressCtrl.addBar(scope, angular.element(element.children()[0])); - } - }; -}); - -angular.module("ui.bootstrap.rating", []).constant("ratingConfig", { - "max": 5, - "stateOn": null, - "stateOff": null -}).controller("RatingController", [ "$scope", "$attrs", "ratingConfig", function($scope, $attrs, ratingConfig) { - var ngModelCtrl = { - "$setViewValue": angular.noop - }; - this.init = function(ngModelCtrl_) { - ngModelCtrl = ngModelCtrl_; - ngModelCtrl.$render = this.render; - this.stateOn = angular.isDefined($attrs.stateOn) ? $scope.$parent.$eval($attrs.stateOn) : ratingConfig.stateOn; - this.stateOff = angular.isDefined($attrs.stateOff) ? $scope.$parent.$eval($attrs.stateOff) : ratingConfig.stateOff; - var ratingStates = angular.isDefined($attrs.ratingStates) ? $scope.$parent.$eval($attrs.ratingStates) : new Array(angular.isDefined($attrs.max) ? $scope.$parent.$eval($attrs.max) : ratingConfig.max); - $scope.range = this.buildTemplateObjects(ratingStates); - }; - this.buildTemplateObjects = function(states) { - for (var i = 0, n = states.length; i < n; i++) { - states[i] = angular.extend({ - "index": i - }, { - "stateOn": this.stateOn, - "stateOff": this.stateOff - }, states[i]); - } - return states; - }; - $scope.rate = function(value) { - if (!$scope.readonly && value >= 0 && value <= $scope.range.length) { - ngModelCtrl.$setViewValue(value); - ngModelCtrl.$render(); - } - }; - $scope.enter = function(value) { - if (!$scope.readonly) { - $scope.value = value; - } - $scope.onHover({ - "value": value - }); - }; - $scope.reset = function() { - $scope.value = ngModelCtrl.$viewValue; - $scope.onLeave(); - }; - $scope.onKeydown = function(evt) { - if (/(37|38|39|40)/.test(evt.which)) { - evt.preventDefault(); - evt.stopPropagation(); - $scope.rate($scope.value + (evt.which === 38 || evt.which === 39 ? 1 : -1)); - } - }; - this.render = function() { - $scope.value = ngModelCtrl.$viewValue; - }; -} ]).directive("rating", function() { - return { - "restrict": "EA", - "require": [ "rating", "ngModel" ], - "scope": { - "readonly": "=?", - "onHover": "&", - "onLeave": "&" - }, - "controller": "RatingController", - "templateUrl": "template/rating/rating.html", - "replace": true, - "link": function(scope, element, attrs, ctrls) { - var ratingCtrl = ctrls[0], ngModelCtrl = ctrls[1]; - if (ngModelCtrl) { - ratingCtrl.init(ngModelCtrl); - } - } - }; -}); - -angular.module("ui.bootstrap.tabs", []).controller("TabsetController", [ "$scope", function TabsetCtrl($scope) { - var ctrl = this, tabs = ctrl.tabs = $scope.tabs = []; - ctrl.select = function(selectedTab) { - angular.forEach(tabs, function(tab) { - if (tab.active && tab !== selectedTab) { - tab.active = false; - tab.onDeselect(); - } - }); - selectedTab.active = true; - selectedTab.onSelect(); - }; - ctrl.addTab = function addTab(tab) { - tabs.push(tab); - if (tabs.length === 1) { - tab.active = true; - } else if (tab.active) { - ctrl.select(tab); - } - }; - ctrl.removeTab = function removeTab(tab) { - var index = tabs.indexOf(tab); - if (tab.active && tabs.length > 1) { - var newActiveIndex = index == tabs.length - 1 ? index - 1 : index + 1; - ctrl.select(tabs[newActiveIndex]); - } - tabs.splice(index, 1); - }; -} ]).directive("tabset", function() { - return { - "restrict": "EA", - "transclude": true, - "replace": true, - "scope": { - "type": "@" - }, - "controller": "TabsetController", - "templateUrl": "template/tabs/tabset.html", - "link": function(scope, element, attrs) { - scope.vertical = angular.isDefined(attrs.vertical) ? scope.$parent.$eval(attrs.vertical) : false; - scope.justified = angular.isDefined(attrs.justified) ? scope.$parent.$eval(attrs.justified) : false; - } - }; -}).directive("tab", [ "$parse", function($parse) { - return { - "require": "^tabset", - "restrict": "EA", - "replace": true, - "templateUrl": "template/tabs/tab.html", - "transclude": true, - "scope": { - "active": "=?", - "heading": "@", - "onSelect": "&select", - "onDeselect": "&deselect" - }, - "controller": function() {}, - "compile": function(elm, attrs, transclude) { - return function postLink(scope, elm, attrs, tabsetCtrl) { - scope.$watch("active", function(active) { - if (active) { - tabsetCtrl.select(scope); - } - }); - scope.disabled = false; - if (attrs.disabled) { - scope.$parent.$watch($parse(attrs.disabled), function(value) { - scope.disabled = !!value; - }); - } - scope.select = function() { - if (!scope.disabled) { - scope.active = true; - } - }; - tabsetCtrl.addTab(scope); - scope.$on("$destroy", function() { - tabsetCtrl.removeTab(scope); - }); - scope.$transcludeFn = transclude; - }; - } - }; -} ]).directive("tabHeadingTransclude", [ function() { - return { - "restrict": "A", - "require": "^tab", - "link": function(scope, elm, attrs, tabCtrl) { - scope.$watch("headingElement", function updateHeadingElement(heading) { - if (heading) { - elm.html(""); - elm.append(heading); - } - }); - } - }; -} ]).directive("tabContentTransclude", function() { - return { - "restrict": "A", - "require": "^tabset", - "link": function(scope, elm, attrs) { - var tab = scope.$eval(attrs.tabContentTransclude); - tab.$transcludeFn(tab.$parent, function(contents) { - angular.forEach(contents, function(node) { - if (isTabHeading(node)) { - tab.headingElement = node; - } else { - elm.append(node); - } - }); - }); - } - }; - function isTabHeading(node) { - return node.tagName && (node.hasAttribute("tab-heading") || node.hasAttribute("data-tab-heading") || node.tagName.toLowerCase() === "tab-heading" || node.tagName.toLowerCase() === "data-tab-heading"); - } -}); - -angular.module("ui.bootstrap.timepicker", []).constant("timepickerConfig", { - "hourStep": 1, - "minuteStep": 1, - "showMeridian": true, - "meridians": null, - "readonlyInput": false, - "mousewheel": true -}).controller("TimepickerController", [ "$scope", "$attrs", "$parse", "$log", "$locale", "timepickerConfig", function($scope, $attrs, $parse, $log, $locale, timepickerConfig) { - var selected = new Date(), ngModelCtrl = { - "$setViewValue": angular.noop - }, meridians = angular.isDefined($attrs.meridians) ? $scope.$parent.$eval($attrs.meridians) : timepickerConfig.meridians || $locale.DATETIME_FORMATS.AMPMS; - this.init = function(ngModelCtrl_, inputs) { - ngModelCtrl = ngModelCtrl_; - ngModelCtrl.$render = this.render; - var hoursInputEl = inputs.eq(0), minutesInputEl = inputs.eq(1); - var mousewheel = angular.isDefined($attrs.mousewheel) ? $scope.$parent.$eval($attrs.mousewheel) : timepickerConfig.mousewheel; - if (mousewheel) { - this.setupMousewheelEvents(hoursInputEl, minutesInputEl); - } - $scope.readonlyInput = angular.isDefined($attrs.readonlyInput) ? $scope.$parent.$eval($attrs.readonlyInput) : timepickerConfig.readonlyInput; - this.setupInputEvents(hoursInputEl, minutesInputEl); - }; - var hourStep = timepickerConfig.hourStep; - if ($attrs.hourStep) { - $scope.$parent.$watch($parse($attrs.hourStep), function(value) { - hourStep = parseInt(value, 10); - }); - } - var minuteStep = timepickerConfig.minuteStep; - if ($attrs.minuteStep) { - $scope.$parent.$watch($parse($attrs.minuteStep), function(value) { - minuteStep = parseInt(value, 10); - }); - } - $scope.showMeridian = timepickerConfig.showMeridian; - if ($attrs.showMeridian) { - $scope.$parent.$watch($parse($attrs.showMeridian), function(value) { - $scope.showMeridian = !!value; - if (ngModelCtrl.$error.time) { - var hours = getHoursFromTemplate(), minutes = getMinutesFromTemplate(); - if (angular.isDefined(hours) && angular.isDefined(minutes)) { - selected.setHours(hours); - refresh(); - } - } else { - updateTemplate(); - } - }); - } - function getHoursFromTemplate() { - var hours = parseInt($scope.hours, 10); - var valid = $scope.showMeridian ? hours > 0 && hours < 13 : hours >= 0 && hours < 24; - if (!valid) { - return undefined; - } - if ($scope.showMeridian) { - if (hours === 12) { - hours = 0; - } - if ($scope.meridian === meridians[1]) { - hours = hours + 12; - } - } - return hours; - } - function getMinutesFromTemplate() { - var minutes = parseInt($scope.minutes, 10); - return minutes >= 0 && minutes < 60 ? minutes : undefined; - } - function pad(value) { - return angular.isDefined(value) && value.toString().length < 2 ? "0" + value : value; - } - this.setupMousewheelEvents = function(hoursInputEl, minutesInputEl) { - var isScrollingUp = function(e) { - if (e.originalEvent) { - e = e.originalEvent; - } - var delta = e.wheelDelta ? e.wheelDelta : -e.deltaY; - return e.detail || delta > 0; - }; - hoursInputEl.bind("mousewheel wheel", function(e) { - $scope.$apply(isScrollingUp(e) ? $scope.incrementHours() : $scope.decrementHours()); - e.preventDefault(); - }); - minutesInputEl.bind("mousewheel wheel", function(e) { - $scope.$apply(isScrollingUp(e) ? $scope.incrementMinutes() : $scope.decrementMinutes()); - e.preventDefault(); - }); - }; - this.setupInputEvents = function(hoursInputEl, minutesInputEl) { - if ($scope.readonlyInput) { - $scope.updateHours = angular.noop; - $scope.updateMinutes = angular.noop; - return; - } - var invalidate = function(invalidHours, invalidMinutes) { - ngModelCtrl.$setViewValue(null); - ngModelCtrl.$setValidity("time", false); - if (angular.isDefined(invalidHours)) { - $scope.invalidHours = invalidHours; - } - if (angular.isDefined(invalidMinutes)) { - $scope.invalidMinutes = invalidMinutes; - } - }; - $scope.updateHours = function() { - var hours = getHoursFromTemplate(); - if (angular.isDefined(hours)) { - selected.setHours(hours); - refresh("h"); - } else { - invalidate(true); - } - }; - hoursInputEl.bind("blur", function(e) { - if (!$scope.invalidHours && $scope.hours < 10) { - $scope.$apply(function() { - $scope.hours = pad($scope.hours); - }); - } - }); - $scope.updateMinutes = function() { - var minutes = getMinutesFromTemplate(); - if (angular.isDefined(minutes)) { - selected.setMinutes(minutes); - refresh("m"); - } else { - invalidate(undefined, true); - } - }; - minutesInputEl.bind("blur", function(e) { - if (!$scope.invalidMinutes && $scope.minutes < 10) { - $scope.$apply(function() { - $scope.minutes = pad($scope.minutes); - }); - } - }); - }; - this.render = function() { - var date = ngModelCtrl.$modelValue ? new Date(ngModelCtrl.$modelValue) : null; - if (isNaN(date)) { - ngModelCtrl.$setValidity("time", false); - $log.error('Timepicker directive: "ng-model" value must be a Date object, a number of milliseconds since 01.01.1970 or a string representing an RFC2822 or ISO 8601 date.'); - } else { - if (date) { - selected = date; - } - makeValid(); - updateTemplate(); - } - }; - function refresh(keyboardChange) { - makeValid(); - ngModelCtrl.$setViewValue(new Date(selected)); - updateTemplate(keyboardChange); - } - function makeValid() { - ngModelCtrl.$setValidity("time", true); - $scope.invalidHours = false; - $scope.invalidMinutes = false; - } - function updateTemplate(keyboardChange) { - var hours = selected.getHours(), minutes = selected.getMinutes(); - if ($scope.showMeridian) { - hours = hours === 0 || hours === 12 ? 12 : hours % 12; - } - $scope.hours = keyboardChange === "h" ? hours : pad(hours); - $scope.minutes = keyboardChange === "m" ? minutes : pad(minutes); - $scope.meridian = selected.getHours() < 12 ? meridians[0] : meridians[1]; - } - function addMinutes(minutes) { - var dt = new Date(selected.getTime() + minutes * 6e4); - selected.setHours(dt.getHours(), dt.getMinutes()); - refresh(); - } - $scope.incrementHours = function() { - addMinutes(hourStep * 60); - }; - $scope.decrementHours = function() { - addMinutes(-hourStep * 60); - }; - $scope.incrementMinutes = function() { - addMinutes(minuteStep); - }; - $scope.decrementMinutes = function() { - addMinutes(-minuteStep); - }; - $scope.toggleMeridian = function() { - addMinutes(12 * 60 * (selected.getHours() < 12 ? 1 : -1)); - }; -} ]).directive("timepicker", function() { - return { - "restrict": "EA", - "require": [ "timepicker", "?^ngModel" ], - "controller": "TimepickerController", - "replace": true, - "scope": {}, - "templateUrl": "template/timepicker/timepicker.html", - "link": function(scope, element, attrs, ctrls) { - var timepickerCtrl = ctrls[0], ngModelCtrl = ctrls[1]; - if (ngModelCtrl) { - timepickerCtrl.init(ngModelCtrl, element.find("input")); - } - } - }; -}); - -angular.module("ui.bootstrap.typeahead", [ "ui.bootstrap.position", "ui.bootstrap.bindHtml" ]).factory("typeaheadParser", [ "$parse", function($parse) { - var TYPEAHEAD_REGEXP = /^\s*([\s\S]+?)(?:\s+as\s+([\s\S]+?))?\s+for\s+(?:([\$\w][\$\w\d]*))\s+in\s+([\s\S]+?)$/; - return { - "parse": function(input) { - var match = input.match(TYPEAHEAD_REGEXP); - if (!match) { - throw new Error('Expected typeahead specification in form of "_modelValue_ (as _label_)? for _item_ in _collection_"' + ' but got "' + input + '".'); - } - return { - "itemName": match[3], - "source": $parse(match[4]), - "viewMapper": $parse(match[2] || match[1]), - "modelMapper": $parse(match[1]) - }; - } - }; -} ]).directive("typeahead", [ "$compile", "$parse", "$q", "$timeout", "$document", "$position", "typeaheadParser", function($compile, $parse, $q, $timeout, $document, $position, typeaheadParser) { - var HOT_KEYS = [ 9, 13, 27, 38, 40 ]; - return { - "require": "ngModel", - "link": function(originalScope, element, attrs, modelCtrl) { - var minSearch = originalScope.$eval(attrs.typeaheadMinLength) || 1; - var waitTime = originalScope.$eval(attrs.typeaheadWaitMs) || 0; - var isEditable = originalScope.$eval(attrs.typeaheadEditable) !== false; - var isLoadingSetter = $parse(attrs.typeaheadLoading).assign || angular.noop; - var onSelectCallback = $parse(attrs.typeaheadOnSelect); - var inputFormatter = attrs.typeaheadInputFormatter ? $parse(attrs.typeaheadInputFormatter) : undefined; - var appendToBody = attrs.typeaheadAppendToBody ? originalScope.$eval(attrs.typeaheadAppendToBody) : false; - var $setModelValue = $parse(attrs.ngModel).assign; - var parserResult = typeaheadParser.parse(attrs.typeahead); - var hasFocus; - var scope = originalScope.$new(); - originalScope.$on("$destroy", function() { - scope.$destroy(); - }); - var popupId = "typeahead-" + scope.$id + "-" + Math.floor(Math.random() * 1e4); - element.attr({ - "aria-autocomplete": "list", - "aria-expanded": false, - "aria-owns": popupId - }); - var popUpEl = angular.element("
    "); - popUpEl.attr({ - "id": popupId, - "matches": "matches", - "active": "activeIdx", - "select": "select(activeIdx)", - "query": "query", - "position": "position" - }); - if (angular.isDefined(attrs.typeaheadTemplateUrl)) { - popUpEl.attr("template-url", attrs.typeaheadTemplateUrl); - } - var resetMatches = function() { - scope.matches = []; - scope.activeIdx = -1; - element.attr("aria-expanded", false); - }; - var getMatchId = function(index) { - return popupId + "-option-" + index; - }; - scope.$watch("activeIdx", function(index) { - if (index < 0) { - element.removeAttr("aria-activedescendant"); - } else { - element.attr("aria-activedescendant", getMatchId(index)); - } - }); - var getMatchesAsync = function(inputValue) { - var locals = { - "$viewValue": inputValue - }; - isLoadingSetter(originalScope, true); - $q.when(parserResult.source(originalScope, locals)).then(function(matches) { - var onCurrentRequest = inputValue === modelCtrl.$viewValue; - if (onCurrentRequest && hasFocus) { - if (matches.length > 0) { - scope.activeIdx = 0; - scope.matches.length = 0; - for (var i = 0; i < matches.length; i++) { - locals[parserResult.itemName] = matches[i]; - scope.matches.push({ - "id": getMatchId(i), - "label": parserResult.viewMapper(scope, locals), - "model": matches[i] - }); - } - scope.query = inputValue; - scope.position = appendToBody ? $position.offset(element) : $position.position(element); - scope.position.top = scope.position.top + element.prop("offsetHeight"); - element.attr("aria-expanded", true); - } else { - resetMatches(); - } - } - if (onCurrentRequest) { - isLoadingSetter(originalScope, false); - } - }, function() { - resetMatches(); - isLoadingSetter(originalScope, false); - }); - }; - resetMatches(); - scope.query = undefined; - var timeoutPromise; - var scheduleSearchWithTimeout = function(inputValue) { - timeoutPromise = $timeout(function() { - getMatchesAsync(inputValue); - }, waitTime); - }; - var cancelPreviousTimeout = function() { - if (timeoutPromise) { - $timeout.cancel(timeoutPromise); - } - }; - modelCtrl.$parsers.unshift(function(inputValue) { - hasFocus = true; - if (inputValue && inputValue.length >= minSearch) { - if (waitTime > 0) { - cancelPreviousTimeout(); - scheduleSearchWithTimeout(inputValue); - } else { - getMatchesAsync(inputValue); - } - } else { - isLoadingSetter(originalScope, false); - cancelPreviousTimeout(); - resetMatches(); - } - if (isEditable) { - return inputValue; - } else { - if (!inputValue) { - modelCtrl.$setValidity("editable", true); - return inputValue; - } else { - modelCtrl.$setValidity("editable", false); - return undefined; - } - } - }); - modelCtrl.$formatters.push(function(modelValue) { - var candidateViewValue, emptyViewValue; - var locals = {}; - if (inputFormatter) { - locals["$model"] = modelValue; - return inputFormatter(originalScope, locals); - } else { - locals[parserResult.itemName] = modelValue; - candidateViewValue = parserResult.viewMapper(originalScope, locals); - locals[parserResult.itemName] = undefined; - emptyViewValue = parserResult.viewMapper(originalScope, locals); - return candidateViewValue !== emptyViewValue ? candidateViewValue : modelValue; - } - }); - scope.select = function(activeIdx) { - var locals = {}; - var model, item; - locals[parserResult.itemName] = item = scope.matches[activeIdx].model; - model = parserResult.modelMapper(originalScope, locals); - $setModelValue(originalScope, model); - modelCtrl.$setValidity("editable", true); - onSelectCallback(originalScope, { - "$item": item, - "$model": model, - "$label": parserResult.viewMapper(originalScope, locals) - }); - resetMatches(); - $timeout(function() { - element[0].focus(); - }, 0, false); - }; - element.bind("keydown", function(evt) { - if (scope.matches.length === 0 || HOT_KEYS.indexOf(evt.which) === -1) { - return; - } - evt.preventDefault(); - if (evt.which === 40) { - scope.activeIdx = (scope.activeIdx + 1) % scope.matches.length; - scope.$digest(); - } else if (evt.which === 38) { - scope.activeIdx = (scope.activeIdx ? scope.activeIdx : scope.matches.length) - 1; - scope.$digest(); - } else if (evt.which === 13 || evt.which === 9) { - scope.$apply(function() { - scope.select(scope.activeIdx); - }); - } else if (evt.which === 27) { - evt.stopPropagation(); - resetMatches(); - scope.$digest(); - } - }); - element.bind("blur", function(evt) { - hasFocus = false; - }); - var dismissClickHandler = function(evt) { - if (element[0] !== evt.target) { - resetMatches(); - scope.$digest(); - } - }; - $document.bind("click", dismissClickHandler); - originalScope.$on("$destroy", function() { - $document.unbind("click", dismissClickHandler); - }); - var $popup = $compile(popUpEl)(scope); - if (appendToBody) { - $document.find("body").append($popup); - } else { - element.after($popup); - } - } - }; -} ]).directive("typeaheadPopup", function() { - return { - "restrict": "EA", - "scope": { - "matches": "=", - "query": "=", - "active": "=", - "position": "=", - "select": "&" - }, - "replace": true, - "templateUrl": "template/typeahead/typeahead-popup.html", - "link": function(scope, element, attrs) { - scope.templateUrl = attrs.templateUrl; - scope.isOpen = function() { - return scope.matches.length > 0; - }; - scope.isActive = function(matchIdx) { - return scope.active == matchIdx; - }; - scope.selectActive = function(matchIdx) { - scope.active = matchIdx; - }; - scope.selectMatch = function(activeIdx) { - scope.select({ - "activeIdx": activeIdx - }); - }; - } - }; -}).directive("typeaheadMatch", [ "$http", "$templateCache", "$compile", "$parse", function($http, $templateCache, $compile, $parse) { - return { - "restrict": "EA", - "scope": { - "index": "=", - "match": "=", - "query": "=" - }, - "link": function(scope, element, attrs) { - var tplUrl = $parse(attrs.templateUrl)(scope.$parent) || "template/typeahead/typeahead-match.html"; - $http.get(tplUrl, { - "cache": $templateCache - }).success(function(tplContent) { - element.replaceWith($compile(tplContent.trim())(scope)); - }); - } - }; -} ]).filter("typeaheadHighlight", function() { - function escapeRegexp(queryToEscape) { - return queryToEscape.replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1"); - } - return function(matchItem, query) { - return query ? ("" + matchItem).replace(new RegExp(escapeRegexp(query), "gi"), "$&") : matchItem; - }; -}); - -angular.module("template/accordion/accordion-group.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/accordion/accordion-group.html", '
    \n' + '
    \n' + '

    \n' + ' {{heading}}\n' + "

    \n" + "
    \n" + '
    \n' + '
    \n' + "
    \n" + "
    "); -} ]); - -angular.module("template/accordion/accordion.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/accordion/accordion.html", '
    '); -} ]); - -angular.module("template/alert/alert.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/alert/alert.html", "
    \n" + ' \n" + "
    \n" + "
    \n" + ""); -} ]); - -angular.module("template/carousel/carousel.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/carousel/carousel.html", '\n" + ""); -} ]); - -angular.module("template/carousel/slide.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/carousel/slide.html", '
    \n' + ""); -} ]); - -angular.module("template/datepicker/datepicker.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/datepicker/datepicker.html", '
    \n' + ' \n' + ' \n' + ' \n' + "
    "); -} ]); - -angular.module("template/datepicker/day.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/datepicker/day.html", '\n' + " \n" + " \n" + ' \n' + ' \n' + ' \n' + " \n" + " \n" + ' \n' + ' \n' + " \n" + " \n" + " \n" + ' \n' + ' \n' + ' \n" + " \n" + " \n" + "
    {{label.abbr}}
    {{ weekNumbers[$index] }}\n' + ' \n' + "
    \n" + ""); -} ]); - -angular.module("template/datepicker/month.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/datepicker/month.html", '\n' + " \n" + " \n" + ' \n' + ' \n' + ' \n' + " \n" + " \n" + " \n" + ' \n' + ' \n" + " \n" + " \n" + "
    \n' + ' \n' + "
    \n" + ""); -} ]); - -angular.module("template/datepicker/popup.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/datepicker/popup.html", "\n" + ""); -} ]); - -angular.module("template/datepicker/year.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/datepicker/year.html", '\n' + " \n" + " \n" + ' \n' + ' \n' + ' \n' + " \n" + " \n" + " \n" + ' \n' + ' \n" + " \n" + " \n" + "
    \n' + ' \n' + "
    \n" + ""); -} ]); - -angular.module("template/modal/backdrop.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/modal/backdrop.html", '\n" + ""); -} ]); - -angular.module("template/modal/window.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/modal/window.html", '"); -} ]); - -angular.module("template/pagination/pager.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/pagination/pager.html", '"); -} ]); - -angular.module("template/pagination/pagination.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/pagination/pagination.html", '"); -} ]); - -angular.module("template/tooltip/tooltip-html-unsafe-popup.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/tooltip/tooltip-html-unsafe-popup.html", '
    \n' + '
    \n' + '
    \n' + "
    \n" + ""); -} ]); - -angular.module("template/tooltip/tooltip-popup.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/tooltip/tooltip-popup.html", '
    \n' + '
    \n' + '
    \n' + "
    \n" + ""); -} ]); - -angular.module("template/popover/popover.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/popover/popover.html", '
    \n' + '
    \n' + "\n" + '
    \n' + '

    \n' + '
    \n' + "
    \n" + "
    \n" + ""); -} ]); - -angular.module("template/progressbar/bar.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/progressbar/bar.html", '
    '); -} ]); - -angular.module("template/progressbar/progress.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/progressbar/progress.html", '
    '); -} ]); - -angular.module("template/progressbar/progressbar.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/progressbar/progressbar.html", '
    \n' + '
    \n' + "
    "); -} ]); - -angular.module("template/rating/rating.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/rating/rating.html", '\n' + ' \n' + " ({{ $index < value ? '*' : ' ' }})\n" + " \n" + ""); -} ]); - -angular.module("template/tabs/tab.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/tabs/tab.html", '
  • \n' + ' {{heading}}\n' + "
  • \n" + ""); -} ]); - -angular.module("template/tabs/tabset.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/tabs/tabset.html", "
    \n" + " \n" + '
    \n' + '
    \n' + "
    \n" + "
    \n" + "
    \n" + ""); -} ]); - -angular.module("template/timepicker/timepicker.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/timepicker/timepicker.html", "\n" + " \n" + ' \n' + ' \n' + " \n" + ' \n' + ' \n' + " \n" + " \n" + ' \n" + " \n" + ' \n" + ' \n' + " \n" + ' \n' + ' \n' + " \n" + ' \n' + ' \n' + " \n" + " \n" + "
     
    \n' + ' \n' + " :\n' + ' \n' + "
     
    \n" + ""); -} ]); - -angular.module("template/typeahead/typeahead-match.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/typeahead/typeahead-match.html", ''); -} ]); - -angular.module("template/typeahead/typeahead-popup.html", []).run([ "$templateCache", function($templateCache) { - $templateCache.put("template/typeahead/typeahead-popup.html", '\n" + ""); -} ]); - -angular.module("ui.select2", []).value("uiSelect2Config", {}).directive("uiSelect2", [ "uiSelect2Config", "$timeout", function(uiSelect2Config, $timeout) { - var options = {}; - if (uiSelect2Config) { - angular.extend(options, uiSelect2Config); - } - return { - "require": "ngModel", - "priority": 1, - "compile": function(tElm, tAttrs) { - var watch, repeatOption, repeatAttr, isSelect = tElm.is("select"), isMultiple = angular.isDefined(tAttrs.multiple); - if (tElm.is("select")) { - repeatOption = tElm.find("option[ng-repeat], option[data-ng-repeat]"); - if (repeatOption.length) { - repeatAttr = repeatOption.attr("ng-repeat") || repeatOption.attr("data-ng-repeat"); - watch = jQuery.trim(repeatAttr.split("|")[0]).split(" ").pop(); - } - } - return function(scope, elm, attrs, controller) { - var opts = angular.extend({}, options, scope.$eval(attrs.uiSelect2)); - var convertToAngularModel = function(select2_data) { - var model; - if (opts.simple_tags) { - model = []; - angular.forEach(select2_data, function(value, index) { - model.push(value.id); - }); - } else { - model = select2_data; - } - return model; - }; - var convertToSelect2Model = function(angular_data) { - var model = []; - if (!angular_data) { - return model; - } - if (opts.simple_tags) { - model = []; - angular.forEach(angular_data, function(value, index) { - model.push({ - "id": value, - "text": value - }); - }); - } else { - model = angular_data; - } - return model; - }; - if (isSelect) { - delete opts.multiple; - delete opts.initSelection; - } else if (isMultiple) { - opts.multiple = true; - } - if (controller) { - scope.$watch(tAttrs.ngModel, function(current, old) { - if (!current) { - return; - } - if (current === old) { - return; - } - controller.$render(); - }, true); - controller.$render = function() { - if (isSelect) { - elm.select2("val", controller.$viewValue); - } else { - if (opts.multiple) { - var viewValue = controller.$viewValue; - if (angular.isString(viewValue)) { - viewValue = viewValue.split(","); - } - elm.select2("data", convertToSelect2Model(viewValue)); - } else { - if (angular.isObject(controller.$viewValue)) { - elm.select2("data", controller.$viewValue); - } else if (!controller.$viewValue) { - elm.select2("data", null); - } else { - elm.select2("val", controller.$viewValue); - } - } - } - }; - if (watch) { - scope.$watch(watch, function(newVal, oldVal, scope) { - if (angular.equals(newVal, oldVal)) { - return; - } - $timeout(function() { - elm.select2("val", controller.$viewValue); - elm.trigger("change"); - if (newVal && !oldVal && controller.$setPristine) { - controller.$setPristine(true); - } - }); - }); - } - controller.$parsers.push(function(value) { - var div = elm.prev(); - div.toggleClass("ng-invalid", !controller.$valid).toggleClass("ng-valid", controller.$valid).toggleClass("ng-invalid-required", !controller.$valid).toggleClass("ng-valid-required", controller.$valid).toggleClass("ng-dirty", controller.$dirty).toggleClass("ng-pristine", controller.$pristine); - return value; - }); - if (!isSelect) { - elm.bind("change", function(e) { - e.stopImmediatePropagation(); - if (scope.$$phase || scope.$root.$$phase) { - return; - } - scope.$apply(function() { - controller.$setViewValue(convertToAngularModel(elm.select2("data"))); - }); - }); - if (opts.initSelection) { - var initSelection = opts.initSelection; - opts.initSelection = function(element, callback) { - initSelection(element, function(value) { - controller.$setViewValue(convertToAngularModel(value)); - callback(value); - }); - }; - } - } - } - elm.bind("$destroy", function() { - elm.select2("destroy"); - }); - attrs.$observe("disabled", function(value) { - elm.select2("enable", !value); - }); - attrs.$observe("readonly", function(value) { - elm.select2("readonly", !!value); - }); - if (attrs.ngMultiple) { - scope.$watch(attrs.ngMultiple, function(newVal) { - attrs.$set("multiple", !!newVal); - elm.select2(opts); - }); - } - $timeout(function() { - elm.select2(opts); - elm.val(controller.$viewValue); - controller.$render(); - if (!opts.initSelection && !isSelect) { - controller.$setViewValue(convertToAngularModel(elm.select2("data"))); - } - }); - }; - } - }; -} ]); - -(function() { - var __slice = [].slice; - this.BaseCtrl = function() { - BaseCtrl.register = function(app, name) { - var _ref; - if (name == null) { - name = this.name || ((_ref = this.toString().match(/function\s*(.*?)\(/)) != null ? _ref[1] : void 0); - } - if (typeof app === "string") { - app = angular.module(app); - } - return app.controller(name, this); - }; - BaseCtrl.inject = function() { - var ANNOTATION_REG, annotations; - annotations = 1 <= arguments.length ? __slice.call(arguments, 0) : []; - ANNOTATION_REG = /^(\S+)(\s+as\s+(\w+))?$/; - this.annotations = _.map(annotations, function(annotation) { - var match; - match = annotation.match(ANNOTATION_REG); - return { - "name": match[1], - "identifier": match[3] || match[1] - }; - }); - return this.$inject = _.map(this.annotations, function(annotation) { - return annotation.name; - }); - }; - BaseCtrl.prototype.expose = function() { - var $scope, members; - $scope = arguments[0], members = 2 <= arguments.length ? __slice.call(arguments, 1) : []; - return _.chain(members).map(function(_this) { - return function(field) { - return [ field, _this[field] ]; - }; - }(this)).each(function(_this) { - return function(_arg) { - var entity, field; - field = _arg[0], entity = _arg[1]; - return $scope[field] = typeof entity === "function" ? _.bind(entity, _this) : entity; - }; - }(this)); - }; - function BaseCtrl() { - var annotation, dependencies, index, _i, _len, _ref; - dependencies = 1 <= arguments.length ? __slice.call(arguments, 0) : []; - _ref = this.constructor.annotations; - for (index = _i = 0, _len = _ref.length; _i < _len; index = ++_i) { - annotation = _ref[index]; - this[annotation.identifier] = dependencies[index]; - } - if (typeof this.initialize === "function") { - this.initialize(); - } - } - return BaseCtrl; - }(); -}).call(this); \ No newline at end of file diff --git a/grails/ag-plugin/web-app/angleGrinder/scripts/bootstrap-extras.min.js b/grails/ag-plugin/web-app/angleGrinder/scripts/bootstrap-extras.min.js deleted file mode 100644 index 63ec737b1..000000000 --- a/grails/ag-plugin/web-app/angleGrinder/scripts/bootstrap-extras.min.js +++ /dev/null @@ -1,9878 +0,0 @@ -(function(e, t) { - function i(t, n) { - var r, i, o, u = t.nodeName.toLowerCase(); - return "area" === u ? (r = t.parentNode, i = r.name, !t.href || !i || r.nodeName.toLowerCase() !== "map" ? !1 : (o = e("img[usemap=#" + i + "]")[0], - !!o && s(o))) : (/input|select|textarea|button|object/.test(u) ? !t.disabled : "a" === u ? t.href || n : n) && s(t); - } - function s(t) { - return e.expr.filters.visible(t) && !e(t).parents().addBack().filter(function() { - return e.css(this, "visibility") === "hidden"; - }).length; - } - var n = 0, r = /^ui-id-\d+$/; - e.ui = e.ui || {}; - if (e.ui.version) return; - e.extend(e.ui, { - "version": "1.10.1", - "keyCode": { - "BACKSPACE": 8, - "COMMA": 188, - "DELETE": 46, - "DOWN": 40, - "END": 35, - "ENTER": 13, - "ESCAPE": 27, - "HOME": 36, - "LEFT": 37, - "NUMPAD_ADD": 107, - "NUMPAD_DECIMAL": 110, - "NUMPAD_DIVIDE": 111, - "NUMPAD_ENTER": 108, - "NUMPAD_MULTIPLY": 106, - "NUMPAD_SUBTRACT": 109, - "PAGE_DOWN": 34, - "PAGE_UP": 33, - "PERIOD": 190, - "RIGHT": 39, - "SPACE": 32, - "TAB": 9, - "UP": 38 - } - }), e.fn.extend({ - "_focus": e.fn.focus, - "focus": function(t, n) { - return typeof t == "number" ? this.each(function() { - var r = this; - setTimeout(function() { - e(r).focus(), n && n.call(r); - }, t); - }) : this._focus.apply(this, arguments); - }, - "scrollParent": function() { - var t; - return e.ui.ie && /(static|relative)/.test(this.css("position")) || /absolute/.test(this.css("position")) ? t = this.parents().filter(function() { - return /(relative|absolute|fixed)/.test(e.css(this, "position")) && /(auto|scroll)/.test(e.css(this, "overflow") + e.css(this, "overflow-y") + e.css(this, "overflow-x")); - }).eq(0) : t = this.parents().filter(function() { - return /(auto|scroll)/.test(e.css(this, "overflow") + e.css(this, "overflow-y") + e.css(this, "overflow-x")); - }).eq(0), /fixed/.test(this.css("position")) || !t.length ? e(document) : t; - }, - "zIndex": function(n) { - if (n !== t) return this.css("zIndex", n); - if (this.length) { - var r = e(this[0]), i, s; - while (r.length && r[0] !== document) { - i = r.css("position"); - if (i === "absolute" || i === "relative" || i === "fixed") { - s = parseInt(r.css("zIndex"), 10); - if (!isNaN(s) && s !== 0) return s; - } - r = r.parent(); - } - } - return 0; - }, - "uniqueId": function() { - return this.each(function() { - this.id || (this.id = "ui-id-" + ++n); - }); - }, - "removeUniqueId": function() { - return this.each(function() { - r.test(this.id) && e(this).removeAttr("id"); - }); - } - }), e.extend(e.expr[":"], { - "data": e.expr.createPseudo ? e.expr.createPseudo(function(t) { - return function(n) { - return !!e.data(n, t); - }; - }) : function(t, n, r) { - return !!e.data(t, r[3]); - }, - "focusable": function(t) { - return i(t, !isNaN(e.attr(t, "tabindex"))); - }, - "tabbable": function(t) { - var n = e.attr(t, "tabindex"), r = isNaN(n); - return (r || n >= 0) && i(t, !r); - } - }), e("").outerWidth(1).jquery || e.each([ "Width", "Height" ], function(n, r) { - function u(t, n, r, s) { - return e.each(i, function() { - n -= parseFloat(e.css(t, "padding" + this)) || 0, r && (n -= parseFloat(e.css(t, "border" + this + "Width")) || 0), - s && (n -= parseFloat(e.css(t, "margin" + this)) || 0); - }), n; - } - var i = r === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ], s = r.toLowerCase(), o = { - "innerWidth": e.fn.innerWidth, - "innerHeight": e.fn.innerHeight, - "outerWidth": e.fn.outerWidth, - "outerHeight": e.fn.outerHeight - }; - e.fn["inner" + r] = function(n) { - return n === t ? o["inner" + r].call(this) : this.each(function() { - e(this).css(s, u(this, n) + "px"); - }); - }, e.fn["outer" + r] = function(t, n) { - return typeof t != "number" ? o["outer" + r].call(this, t) : this.each(function() { - e(this).css(s, u(this, t, !0, n) + "px"); - }); - }; - }), e.fn.addBack || (e.fn.addBack = function(e) { - return this.add(e == null ? this.prevObject : this.prevObject.filter(e)); - }), e("").data("a-b", "a").removeData("a-b").data("a-b") && (e.fn.removeData = function(t) { - return function(n) { - return arguments.length ? t.call(this, e.camelCase(n)) : t.call(this); - }; - }(e.fn.removeData)), e.ui.ie = !!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase()), - e.support.selectstart = "onselectstart" in document.createElement("div"), e.fn.extend({ - "disableSelection": function() { - return this.bind((e.support.selectstart ? "selectstart" : "mousedown") + ".ui-disableSelection", function(e) { - e.preventDefault(); - }); - }, - "enableSelection": function() { - return this.unbind(".ui-disableSelection"); - } - }), e.extend(e.ui, { - "plugin": { - "add": function(t, n, r) { - var i, s = e.ui[t].prototype; - for (i in r) s.plugins[i] = s.plugins[i] || [], s.plugins[i].push([ n, r[i] ]); - }, - "call": function(e, t, n) { - var r, i = e.plugins[t]; - if (!i || !e.element[0].parentNode || e.element[0].parentNode.nodeType === 11) return; - for (r = 0; r < i.length; r++) e.options[i[r][0]] && i[r][1].apply(e.element, n); - } - }, - "hasScroll": function(t, n) { - if (e(t).css("overflow") === "hidden") return !1; - var r = n && n === "left" ? "scrollLeft" : "scrollTop", i = !1; - return t[r] > 0 ? !0 : (t[r] = 1, i = t[r] > 0, t[r] = 0, i); - } - }); -})(jQuery); - -(function(e, t) { - var n = 0, r = Array.prototype.slice, i = e.cleanData; - e.cleanData = function(t) { - for (var n = 0, r; (r = t[n]) != null; n++) try { - e(r).triggerHandler("remove"); - } catch (s) {} - i(t); - }, e.widget = function(t, n, r) { - var i, s, o, u, a = {}, f = t.split(".")[0]; - t = t.split(".")[1], i = f + "-" + t, r || (r = n, n = e.Widget), e.expr[":"][i.toLowerCase()] = function(t) { - return !!e.data(t, i); - }, e[f] = e[f] || {}, s = e[f][t], o = e[f][t] = function(e, t) { - if (!this._createWidget) return new o(e, t); - arguments.length && this._createWidget(e, t); - }, e.extend(o, s, { - "version": r.version, - "_proto": e.extend({}, r), - "_childConstructors": [] - }), u = new n(), u.options = e.widget.extend({}, u.options), e.each(r, function(t, r) { - if (!e.isFunction(r)) { - a[t] = r; - return; - } - a[t] = function() { - var e = function() { - return n.prototype[t].apply(this, arguments); - }, i = function(e) { - return n.prototype[t].apply(this, e); - }; - return function() { - var t = this._super, n = this._superApply, s; - return this._super = e, this._superApply = i, s = r.apply(this, arguments), this._super = t, - this._superApply = n, s; - }; - }(); - }), o.prototype = e.widget.extend(u, { - "widgetEventPrefix": s ? u.widgetEventPrefix : t - }, a, { - "constructor": o, - "namespace": f, - "widgetName": t, - "widgetFullName": i - }), s ? (e.each(s._childConstructors, function(t, n) { - var r = n.prototype; - e.widget(r.namespace + "." + r.widgetName, o, n._proto); - }), delete s._childConstructors) : n._childConstructors.push(o), e.widget.bridge(t, o); - }, e.widget.extend = function(n) { - var i = r.call(arguments, 1), s = 0, o = i.length, u, a; - for (;s < o; s++) for (u in i[s]) a = i[s][u], i[s].hasOwnProperty(u) && a !== t && (e.isPlainObject(a) ? n[u] = e.isPlainObject(n[u]) ? e.widget.extend({}, n[u], a) : e.widget.extend({}, a) : n[u] = a); - return n; - }, e.widget.bridge = function(n, i) { - var s = i.prototype.widgetFullName || n; - e.fn[n] = function(o) { - var u = typeof o == "string", a = r.call(arguments, 1), f = this; - return o = !u && a.length ? e.widget.extend.apply(null, [ o ].concat(a)) : o, u ? this.each(function() { - var r, i = e.data(this, s); - if (!i) return e.error("cannot call methods on " + n + " prior to initialization; " + "attempted to call method '" + o + "'"); - if (!e.isFunction(i[o]) || o.charAt(0) === "_") return e.error("no such method '" + o + "' for " + n + " widget instance"); - r = i[o].apply(i, a); - if (r !== i && r !== t) return f = r && r.jquery ? f.pushStack(r.get()) : r, !1; - }) : this.each(function() { - var t = e.data(this, s); - t ? t.option(o || {})._init() : e.data(this, s, new i(o, this)); - }), f; - }; - }, e.Widget = function() {}, e.Widget._childConstructors = [], e.Widget.prototype = { - "widgetName": "widget", - "widgetEventPrefix": "", - "defaultElement": "
    ", - "options": { - "disabled": !1, - "create": null - }, - "_createWidget": function(t, r) { - r = e(r || this.defaultElement || this)[0], this.element = e(r), this.uuid = n++, - this.eventNamespace = "." + this.widgetName + this.uuid, this.options = e.widget.extend({}, this.options, this._getCreateOptions(), t), - this.bindings = e(), this.hoverable = e(), this.focusable = e(), r !== this && (e.data(r, this.widgetFullName, this), - this._on(!0, this.element, { - "remove": function(e) { - e.target === r && this.destroy(); - } - }), this.document = e(r.style ? r.ownerDocument : r.document || r), this.window = e(this.document[0].defaultView || this.document[0].parentWindow)), - this._create(), this._trigger("create", null, this._getCreateEventData()), this._init(); - }, - "_getCreateOptions": e.noop, - "_getCreateEventData": e.noop, - "_create": e.noop, - "_init": e.noop, - "destroy": function() { - this._destroy(), this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData(e.camelCase(this.widgetFullName)), - this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName + "-disabled " + "ui-state-disabled"), - this.bindings.unbind(this.eventNamespace), this.hoverable.removeClass("ui-state-hover"), - this.focusable.removeClass("ui-state-focus"); - }, - "_destroy": e.noop, - "widget": function() { - return this.element; - }, - "option": function(n, r) { - var i = n, s, o, u; - if (arguments.length === 0) return e.widget.extend({}, this.options); - if (typeof n == "string") { - i = {}, s = n.split("."), n = s.shift(); - if (s.length) { - o = i[n] = e.widget.extend({}, this.options[n]); - for (u = 0; u < s.length - 1; u++) o[s[u]] = o[s[u]] || {}, o = o[s[u]]; - n = s.pop(); - if (r === t) return o[n] === t ? null : o[n]; - o[n] = r; - } else { - if (r === t) return this.options[n] === t ? null : this.options[n]; - i[n] = r; - } - } - return this._setOptions(i), this; - }, - "_setOptions": function(e) { - var t; - for (t in e) this._setOption(t, e[t]); - return this; - }, - "_setOption": function(e, t) { - return this.options[e] = t, e === "disabled" && (this.widget().toggleClass(this.widgetFullName + "-disabled ui-state-disabled", !!t).attr("aria-disabled", t), - this.hoverable.removeClass("ui-state-hover"), this.focusable.removeClass("ui-state-focus")), - this; - }, - "enable": function() { - return this._setOption("disabled", !1); - }, - "disable": function() { - return this._setOption("disabled", !0); - }, - "_on": function(t, n, r) { - var i, s = this; - typeof t != "boolean" && (r = n, n = t, t = !1), r ? (n = i = e(n), this.bindings = this.bindings.add(n)) : (r = n, - n = this.element, i = this.widget()), e.each(r, function(r, o) { - function u() { - if (!t && (s.options.disabled === !0 || e(this).hasClass("ui-state-disabled"))) return; - return (typeof o == "string" ? s[o] : o).apply(s, arguments); - } - typeof o != "string" && (u.guid = o.guid = o.guid || u.guid || e.guid++); - var a = r.match(/^(\w+)\s*(.*)$/), f = a[1] + s.eventNamespace, l = a[2]; - l ? i.delegate(l, f, u) : n.bind(f, u); - }); - }, - "_off": function(e, t) { - t = (t || "").split(" ").join(this.eventNamespace + " ") + this.eventNamespace, - e.unbind(t).undelegate(t); - }, - "_delay": function(e, t) { - function n() { - return (typeof e == "string" ? r[e] : e).apply(r, arguments); - } - var r = this; - return setTimeout(n, t || 0); - }, - "_hoverable": function(t) { - this.hoverable = this.hoverable.add(t), this._on(t, { - "mouseenter": function(t) { - e(t.currentTarget).addClass("ui-state-hover"); - }, - "mouseleave": function(t) { - e(t.currentTarget).removeClass("ui-state-hover"); - } - }); - }, - "_focusable": function(t) { - this.focusable = this.focusable.add(t), this._on(t, { - "focusin": function(t) { - e(t.currentTarget).addClass("ui-state-focus"); - }, - "focusout": function(t) { - e(t.currentTarget).removeClass("ui-state-focus"); - } - }); - }, - "_trigger": function(t, n, r) { - var i, s, o = this.options[t]; - r = r || {}, n = e.Event(n), n.type = (t === this.widgetEventPrefix ? t : this.widgetEventPrefix + t).toLowerCase(), - n.target = this.element[0], s = n.originalEvent; - if (s) for (i in s) i in n || (n[i] = s[i]); - return this.element.trigger(n, r), !(e.isFunction(o) && o.apply(this.element[0], [ n ].concat(r)) === !1 || n.isDefaultPrevented()); - } - }, e.each({ - "show": "fadeIn", - "hide": "fadeOut" - }, function(t, n) { - e.Widget.prototype["_" + t] = function(r, i, s) { - typeof i == "string" && (i = { - "effect": i - }); - var o, u = i ? i === !0 || typeof i == "number" ? n : i.effect || n : t; - i = i || {}, typeof i == "number" && (i = { - "duration": i - }), o = !e.isEmptyObject(i), i.complete = s, i.delay && r.delay(i.delay), o && e.effects && e.effects.effect[u] ? r[t](i) : u !== t && r[u] ? r[u](i.duration, i.easing, s) : r.queue(function(n) { - e(this)[t](), s && s.call(r[0]), n(); - }); - }; - }); -})(jQuery); - -(function(e, t) { - var n = !1; - e(document).mouseup(function() { - n = !1; - }), e.widget("ui.mouse", { - "version": "1.10.1", - "options": { - "cancel": "input,textarea,button,select,option", - "distance": 1, - "delay": 0 - }, - "_mouseInit": function() { - var t = this; - this.element.bind("mousedown." + this.widgetName, function(e) { - return t._mouseDown(e); - }).bind("click." + this.widgetName, function(n) { - if (!0 === e.data(n.target, t.widgetName + ".preventClickEvent")) return e.removeData(n.target, t.widgetName + ".preventClickEvent"), - n.stopImmediatePropagation(), !1; - }), this.started = !1; - }, - "_mouseDestroy": function() { - this.element.unbind("." + this.widgetName), this._mouseMoveDelegate && e(document).unbind("mousemove." + this.widgetName, this._mouseMoveDelegate).unbind("mouseup." + this.widgetName, this._mouseUpDelegate); - }, - "_mouseDown": function(t) { - if (n) return; - this._mouseStarted && this._mouseUp(t), this._mouseDownEvent = t; - var r = this, i = t.which === 1, s = typeof this.options.cancel == "string" && t.target.nodeName ? e(t.target).closest(this.options.cancel).length : !1; - if (!i || s || !this._mouseCapture(t)) return !0; - this.mouseDelayMet = !this.options.delay, this.mouseDelayMet || (this._mouseDelayTimer = setTimeout(function() { - r.mouseDelayMet = !0; - }, this.options.delay)); - if (this._mouseDistanceMet(t) && this._mouseDelayMet(t)) { - this._mouseStarted = this._mouseStart(t) !== !1; - if (!this._mouseStarted) return t.preventDefault(), !0; - } - return !0 === e.data(t.target, this.widgetName + ".preventClickEvent") && e.removeData(t.target, this.widgetName + ".preventClickEvent"), - this._mouseMoveDelegate = function(e) { - return r._mouseMove(e); - }, this._mouseUpDelegate = function(e) { - return r._mouseUp(e); - }, e(document).bind("mousemove." + this.widgetName, this._mouseMoveDelegate).bind("mouseup." + this.widgetName, this._mouseUpDelegate), - t.preventDefault(), n = !0, !0; - }, - "_mouseMove": function(t) { - return e.ui.ie && (!document.documentMode || document.documentMode < 9) && !t.button ? this._mouseUp(t) : this._mouseStarted ? (this._mouseDrag(t), - t.preventDefault()) : (this._mouseDistanceMet(t) && this._mouseDelayMet(t) && (this._mouseStarted = this._mouseStart(this._mouseDownEvent, t) !== !1, - this._mouseStarted ? this._mouseDrag(t) : this._mouseUp(t)), !this._mouseStarted); - }, - "_mouseUp": function(t) { - return e(document).unbind("mousemove." + this.widgetName, this._mouseMoveDelegate).unbind("mouseup." + this.widgetName, this._mouseUpDelegate), - this._mouseStarted && (this._mouseStarted = !1, t.target === this._mouseDownEvent.target && e.data(t.target, this.widgetName + ".preventClickEvent", !0), - this._mouseStop(t)), !1; - }, - "_mouseDistanceMet": function(e) { - return Math.max(Math.abs(this._mouseDownEvent.pageX - e.pageX), Math.abs(this._mouseDownEvent.pageY - e.pageY)) >= this.options.distance; - }, - "_mouseDelayMet": function() { - return this.mouseDelayMet; - }, - "_mouseStart": function() {}, - "_mouseDrag": function() {}, - "_mouseStop": function() {}, - "_mouseCapture": function() { - return !0; - } - }); -})(jQuery); - -(function(e, t) { - function h(e, t, n) { - return [ parseFloat(e[0]) * (l.test(e[0]) ? t / 100 : 1), parseFloat(e[1]) * (l.test(e[1]) ? n / 100 : 1) ]; - } - function p(t, n) { - return parseInt(e.css(t, n), 10) || 0; - } - function d(t) { - var n = t[0]; - return n.nodeType === 9 ? { - "width": t.width(), - "height": t.height(), - "offset": { - "top": 0, - "left": 0 - } - } : e.isWindow(n) ? { - "width": t.width(), - "height": t.height(), - "offset": { - "top": t.scrollTop(), - "left": t.scrollLeft() - } - } : n.preventDefault ? { - "width": 0, - "height": 0, - "offset": { - "top": n.pageY, - "left": n.pageX - } - } : { - "width": t.outerWidth(), - "height": t.outerHeight(), - "offset": t.offset() - }; - } - e.ui = e.ui || {}; - var n, r = Math.max, i = Math.abs, s = Math.round, o = /left|center|right/, u = /top|center|bottom/, a = /[\+\-]\d+(\.[\d]+)?%?/, f = /^\w+/, l = /%$/, c = e.fn.position; - e.position = { - "scrollbarWidth": function() { - if (n !== t) return n; - var r, i, s = e("
    "), o = s.children()[0]; - return e("body").append(s), r = o.offsetWidth, s.css("overflow", "scroll"), i = o.offsetWidth, - r === i && (i = s[0].clientWidth), s.remove(), n = r - i; - }, - "getScrollInfo": function(t) { - var n = t.isWindow ? "" : t.element.css("overflow-x"), r = t.isWindow ? "" : t.element.css("overflow-y"), i = n === "scroll" || n === "auto" && t.width < t.element[0].scrollWidth, s = r === "scroll" || r === "auto" && t.height < t.element[0].scrollHeight; - return { - "width": i ? e.position.scrollbarWidth() : 0, - "height": s ? e.position.scrollbarWidth() : 0 - }; - }, - "getWithinInfo": function(t) { - var n = e(t || window), r = e.isWindow(n[0]); - return { - "element": n, - "isWindow": r, - "offset": n.offset() || { - "left": 0, - "top": 0 - }, - "scrollLeft": n.scrollLeft(), - "scrollTop": n.scrollTop(), - "width": r ? n.width() : n.outerWidth(), - "height": r ? n.height() : n.outerHeight() - }; - } - }, e.fn.position = function(t) { - if (!t || !t.of) return c.apply(this, arguments); - t = e.extend({}, t); - var n, l, v, m, g, y, b = e(t.of), w = e.position.getWithinInfo(t.within), E = e.position.getScrollInfo(w), S = (t.collision || "flip").split(" "), x = {}; - return y = d(b), b[0].preventDefault && (t.at = "left top"), l = y.width, v = y.height, - m = y.offset, g = e.extend({}, m), e.each([ "my", "at" ], function() { - var e = (t[this] || "").split(" "), n, r; - e.length === 1 && (e = o.test(e[0]) ? e.concat([ "center" ]) : u.test(e[0]) ? [ "center" ].concat(e) : [ "center", "center" ]), - e[0] = o.test(e[0]) ? e[0] : "center", e[1] = u.test(e[1]) ? e[1] : "center", n = a.exec(e[0]), - r = a.exec(e[1]), x[this] = [ n ? n[0] : 0, r ? r[0] : 0 ], t[this] = [ f.exec(e[0])[0], f.exec(e[1])[0] ]; - }), S.length === 1 && (S[1] = S[0]), t.at[0] === "right" ? g.left += l : t.at[0] === "center" && (g.left += l / 2), - t.at[1] === "bottom" ? g.top += v : t.at[1] === "center" && (g.top += v / 2), n = h(x.at, l, v), - g.left += n[0], g.top += n[1], this.each(function() { - var o, u, a = e(this), f = a.outerWidth(), c = a.outerHeight(), d = p(this, "marginLeft"), y = p(this, "marginTop"), T = f + d + p(this, "marginRight") + E.width, N = c + y + p(this, "marginBottom") + E.height, C = e.extend({}, g), k = h(x.my, a.outerWidth(), a.outerHeight()); - t.my[0] === "right" ? C.left -= f : t.my[0] === "center" && (C.left -= f / 2), t.my[1] === "bottom" ? C.top -= c : t.my[1] === "center" && (C.top -= c / 2), - C.left += k[0], C.top += k[1], e.support.offsetFractions || (C.left = s(C.left), - C.top = s(C.top)), o = { - "marginLeft": d, - "marginTop": y - }, e.each([ "left", "top" ], function(r, i) { - e.ui.position[S[r]] && e.ui.position[S[r]][i](C, { - "targetWidth": l, - "targetHeight": v, - "elemWidth": f, - "elemHeight": c, - "collisionPosition": o, - "collisionWidth": T, - "collisionHeight": N, - "offset": [ n[0] + k[0], n[1] + k[1] ], - "my": t.my, - "at": t.at, - "within": w, - "elem": a - }); - }), t.using && (u = function(e) { - var n = m.left - C.left, s = n + l - f, o = m.top - C.top, u = o + v - c, h = { - "target": { - "element": b, - "left": m.left, - "top": m.top, - "width": l, - "height": v - }, - "element": { - "element": a, - "left": C.left, - "top": C.top, - "width": f, - "height": c - }, - "horizontal": s < 0 ? "left" : n > 0 ? "right" : "center", - "vertical": u < 0 ? "top" : o > 0 ? "bottom" : "middle" - }; - l < f && i(n + s) < l && (h.horizontal = "center"), v < c && i(o + u) < v && (h.vertical = "middle"), - r(i(n), i(s)) > r(i(o), i(u)) ? h.important = "horizontal" : h.important = "vertical", - t.using.call(this, e, h); - }), a.offset(e.extend(C, { - "using": u - })); - }); - }, e.ui.position = { - "fit": { - "left": function(e, t) { - var n = t.within, i = n.isWindow ? n.scrollLeft : n.offset.left, s = n.width, o = e.left - t.collisionPosition.marginLeft, u = i - o, a = o + t.collisionWidth - s - i, f; - t.collisionWidth > s ? u > 0 && a <= 0 ? (f = e.left + u + t.collisionWidth - s - i, - e.left += u - f) : a > 0 && u <= 0 ? e.left = i : u > a ? e.left = i + s - t.collisionWidth : e.left = i : u > 0 ? e.left += u : a > 0 ? e.left -= a : e.left = r(e.left - o, e.left); - }, - "top": function(e, t) { - var n = t.within, i = n.isWindow ? n.scrollTop : n.offset.top, s = t.within.height, o = e.top - t.collisionPosition.marginTop, u = i - o, a = o + t.collisionHeight - s - i, f; - t.collisionHeight > s ? u > 0 && a <= 0 ? (f = e.top + u + t.collisionHeight - s - i, - e.top += u - f) : a > 0 && u <= 0 ? e.top = i : u > a ? e.top = i + s - t.collisionHeight : e.top = i : u > 0 ? e.top += u : a > 0 ? e.top -= a : e.top = r(e.top - o, e.top); - } - }, - "flip": { - "left": function(e, t) { - var n = t.within, r = n.offset.left + n.scrollLeft, s = n.width, o = n.isWindow ? n.scrollLeft : n.offset.left, u = e.left - t.collisionPosition.marginLeft, a = u - o, f = u + t.collisionWidth - s - o, l = t.my[0] === "left" ? -t.elemWidth : t.my[0] === "right" ? t.elemWidth : 0, c = t.at[0] === "left" ? t.targetWidth : t.at[0] === "right" ? -t.targetWidth : 0, h = -2 * t.offset[0], p, d; - if (a < 0) { - p = e.left + l + c + h + t.collisionWidth - s - r; - if (p < 0 || p < i(a)) e.left += l + c + h; - } else if (f > 0) { - d = e.left - t.collisionPosition.marginLeft + l + c + h - o; - if (d > 0 || i(d) < f) e.left += l + c + h; - } - }, - "top": function(e, t) { - var n = t.within, r = n.offset.top + n.scrollTop, s = n.height, o = n.isWindow ? n.scrollTop : n.offset.top, u = e.top - t.collisionPosition.marginTop, a = u - o, f = u + t.collisionHeight - s - o, l = t.my[1] === "top", c = l ? -t.elemHeight : t.my[1] === "bottom" ? t.elemHeight : 0, h = t.at[1] === "top" ? t.targetHeight : t.at[1] === "bottom" ? -t.targetHeight : 0, p = -2 * t.offset[1], d, v; - a < 0 ? (v = e.top + c + h + p + t.collisionHeight - s - r, e.top + c + h + p > a && (v < 0 || v < i(a)) && (e.top += c + h + p)) : f > 0 && (d = e.top - t.collisionPosition.marginTop + c + h + p - o, - e.top + c + h + p > f && (d > 0 || i(d) < f) && (e.top += c + h + p)); - } - }, - "flipfit": { - "left": function() { - e.ui.position.flip.left.apply(this, arguments), e.ui.position.fit.left.apply(this, arguments); - }, - "top": function() { - e.ui.position.flip.top.apply(this, arguments), e.ui.position.fit.top.apply(this, arguments); - } - } - }, function() { - var t, n, r, i, s, o = document.getElementsByTagName("body")[0], u = document.createElement("div"); - t = document.createElement(o ? "div" : "body"), r = { - "visibility": "hidden", - "width": 0, - "height": 0, - "border": 0, - "margin": 0, - "background": "none" - }, o && e.extend(r, { - "position": "absolute", - "left": "-1000px", - "top": "-1000px" - }); - for (s in r) t.style[s] = r[s]; - t.appendChild(u), n = o || document.documentElement, n.insertBefore(t, n.firstChild), - u.style.cssText = "position: absolute; left: 10.7432222px;", i = e(u).offset().left, - e.support.offsetFractions = i > 10 && i < 11, t.innerHTML = "", n.removeChild(t); - }(); -})(jQuery); - -(function(e, t) { - var n = 0, r = {}, i = {}; - r.height = r.paddingTop = r.paddingBottom = r.borderTopWidth = r.borderBottomWidth = "hide", - i.height = i.paddingTop = i.paddingBottom = i.borderTopWidth = i.borderBottomWidth = "show", - e.widget("ui.accordion", { - "version": "1.10.1", - "options": { - "active": 0, - "animate": {}, - "collapsible": !1, - "event": "click", - "header": "> li > :first-child,> :not(li):even", - "heightStyle": "auto", - "icons": { - "activeHeader": "ui-icon-triangle-1-s", - "header": "ui-icon-triangle-1-e" - }, - "activate": null, - "beforeActivate": null - }, - "_create": function() { - var t = this.options; - this.prevShow = this.prevHide = e(), this.element.addClass("ui-accordion ui-widget ui-helper-reset").attr("role", "tablist"), - !t.collapsible && (t.active === !1 || t.active == null) && (t.active = 0), this._processPanels(), - t.active < 0 && (t.active += this.headers.length), this._refresh(); - }, - "_getCreateEventData": function() { - return { - "header": this.active, - "panel": this.active.length ? this.active.next() : e(), - "content": this.active.length ? this.active.next() : e() - }; - }, - "_createIcons": function() { - var t = this.options.icons; - t && (e("").addClass("ui-accordion-header-icon ui-icon " + t.header).prependTo(this.headers), - this.active.children(".ui-accordion-header-icon").removeClass(t.header).addClass(t.activeHeader), - this.headers.addClass("ui-accordion-icons")); - }, - "_destroyIcons": function() { - this.headers.removeClass("ui-accordion-icons").children(".ui-accordion-header-icon").remove(); - }, - "_destroy": function() { - var e; - this.element.removeClass("ui-accordion ui-widget ui-helper-reset").removeAttr("role"), - this.headers.removeClass("ui-accordion-header ui-accordion-header-active ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top").removeAttr("role").removeAttr("aria-selected").removeAttr("aria-controls").removeAttr("tabIndex").each(function() { - /^ui-accordion/.test(this.id) && this.removeAttribute("id"); - }), this._destroyIcons(), e = this.headers.next().css("display", "").removeAttr("role").removeAttr("aria-expanded").removeAttr("aria-hidden").removeAttr("aria-labelledby").removeClass("ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled").each(function() { - /^ui-accordion/.test(this.id) && this.removeAttribute("id"); - }), this.options.heightStyle !== "content" && e.css("height", ""); - }, - "_setOption": function(e, t) { - if (e === "active") { - this._activate(t); - return; - } - e === "event" && (this.options.event && this._off(this.headers, this.options.event), - this._setupEvents(t)), this._super(e, t), e === "collapsible" && !t && this.options.active === !1 && this._activate(0), - e === "icons" && (this._destroyIcons(), t && this._createIcons()), e === "disabled" && this.headers.add(this.headers.next()).toggleClass("ui-state-disabled", !!t); - }, - "_keydown": function(t) { - if (t.altKey || t.ctrlKey) return; - var n = e.ui.keyCode, r = this.headers.length, i = this.headers.index(t.target), s = !1; - switch (t.keyCode) { - case n.RIGHT: - case n.DOWN: - s = this.headers[(i + 1) % r]; - break; - - case n.LEFT: - case n.UP: - s = this.headers[(i - 1 + r) % r]; - break; - - case n.SPACE: - case n.ENTER: - this._eventHandler(t); - break; - - case n.HOME: - s = this.headers[0]; - break; - - case n.END: - s = this.headers[r - 1]; - } - s && (e(t.target).attr("tabIndex", -1), e(s).attr("tabIndex", 0), s.focus(), t.preventDefault()); - }, - "_panelKeyDown": function(t) { - t.keyCode === e.ui.keyCode.UP && t.ctrlKey && e(t.currentTarget).prev().focus(); - }, - "refresh": function() { - var t = this.options; - this._processPanels(); - if (t.active === !1 && t.collapsible === !0 || !this.headers.length) t.active = !1, - this.active = e(); - t.active === !1 ? this._activate(0) : this.active.length && !e.contains(this.element[0], this.active[0]) ? this.headers.length === this.headers.find(".ui-state-disabled").length ? (t.active = !1, - this.active = e()) : this._activate(Math.max(0, t.active - 1)) : t.active = this.headers.index(this.active), - this._destroyIcons(), this._refresh(); - }, - "_processPanels": function() { - this.headers = this.element.find(this.options.header).addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all"), - this.headers.next().addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom").filter(":not(.ui-accordion-content-active)").hide(); - }, - "_refresh": function() { - var t, r = this.options, i = r.heightStyle, s = this.element.parent(), o = this.accordionId = "ui-accordion-" + (this.element.attr("id") || ++n); - this.active = this._findActive(r.active).addClass("ui-accordion-header-active ui-state-active ui-corner-top").removeClass("ui-corner-all"), - this.active.next().addClass("ui-accordion-content-active").show(), this.headers.attr("role", "tab").each(function(t) { - var n = e(this), r = n.attr("id"), i = n.next(), s = i.attr("id"); - r || (r = o + "-header-" + t, n.attr("id", r)), s || (s = o + "-panel-" + t, i.attr("id", s)), - n.attr("aria-controls", s), i.attr("aria-labelledby", r); - }).next().attr("role", "tabpanel"), this.headers.not(this.active).attr({ - "aria-selected": "false", - "tabIndex": -1 - }).next().attr({ - "aria-expanded": "false", - "aria-hidden": "true" - }).hide(), this.active.length ? this.active.attr({ - "aria-selected": "true", - "tabIndex": 0 - }).next().attr({ - "aria-expanded": "true", - "aria-hidden": "false" - }) : this.headers.eq(0).attr("tabIndex", 0), this._createIcons(), this._setupEvents(r.event), - i === "fill" ? (t = s.height(), this.element.siblings(":visible").each(function() { - var n = e(this), r = n.css("position"); - if (r === "absolute" || r === "fixed") return; - t -= n.outerHeight(!0); - }), this.headers.each(function() { - t -= e(this).outerHeight(!0); - }), this.headers.next().each(function() { - e(this).height(Math.max(0, t - e(this).innerHeight() + e(this).height())); - }).css("overflow", "auto")) : i === "auto" && (t = 0, this.headers.next().each(function() { - t = Math.max(t, e(this).css("height", "").height()); - }).height(t)); - }, - "_activate": function(t) { - var n = this._findActive(t)[0]; - if (n === this.active[0]) return; - n = n || this.active[0], this._eventHandler({ - "target": n, - "currentTarget": n, - "preventDefault": e.noop - }); - }, - "_findActive": function(t) { - return typeof t == "number" ? this.headers.eq(t) : e(); - }, - "_setupEvents": function(t) { - var n = { - "keydown": "_keydown" - }; - t && e.each(t.split(" "), function(e, t) { - n[t] = "_eventHandler"; - }), this._off(this.headers.add(this.headers.next())), this._on(this.headers, n), - this._on(this.headers.next(), { - "keydown": "_panelKeyDown" - }), this._hoverable(this.headers), this._focusable(this.headers); - }, - "_eventHandler": function(t) { - var n = this.options, r = this.active, i = e(t.currentTarget), s = i[0] === r[0], o = s && n.collapsible, u = o ? e() : i.next(), a = r.next(), f = { - "oldHeader": r, - "oldPanel": a, - "newHeader": o ? e() : i, - "newPanel": u - }; - t.preventDefault(); - if (s && !n.collapsible || this._trigger("beforeActivate", t, f) === !1) return; - n.active = o ? !1 : this.headers.index(i), this.active = s ? e() : i, this._toggle(f), - r.removeClass("ui-accordion-header-active ui-state-active"), n.icons && r.children(".ui-accordion-header-icon").removeClass(n.icons.activeHeader).addClass(n.icons.header), - s || (i.removeClass("ui-corner-all").addClass("ui-accordion-header-active ui-state-active ui-corner-top"), - n.icons && i.children(".ui-accordion-header-icon").removeClass(n.icons.header).addClass(n.icons.activeHeader), - i.next().addClass("ui-accordion-content-active")); - }, - "_toggle": function(t) { - var n = t.newPanel, r = this.prevShow.length ? this.prevShow : t.oldPanel; - this.prevShow.add(this.prevHide).stop(!0, !0), this.prevShow = n, this.prevHide = r, - this.options.animate ? this._animate(n, r, t) : (r.hide(), n.show(), this._toggleComplete(t)), - r.attr({ - "aria-expanded": "false", - "aria-hidden": "true" - }), r.prev().attr("aria-selected", "false"), n.length && r.length ? r.prev().attr("tabIndex", -1) : n.length && this.headers.filter(function() { - return e(this).attr("tabIndex") === 0; - }).attr("tabIndex", -1), n.attr({ - "aria-expanded": "true", - "aria-hidden": "false" - }).prev().attr({ - "aria-selected": "true", - "tabIndex": 0 - }); - }, - "_animate": function(e, t, n) { - var s, o, u, a = this, f = 0, l = e.length && (!t.length || e.index() < t.index()), c = this.options.animate || {}, h = l && c.down || c, p = function() { - a._toggleComplete(n); - }; - typeof h == "number" && (u = h), typeof h == "string" && (o = h), o = o || h.easing || c.easing, - u = u || h.duration || c.duration; - if (!t.length) return e.animate(i, u, o, p); - if (!e.length) return t.animate(r, u, o, p); - s = e.show().outerHeight(), t.animate(r, { - "duration": u, - "easing": o, - "step": function(e, t) { - t.now = Math.round(e); - } - }), e.hide().animate(i, { - "duration": u, - "easing": o, - "complete": p, - "step": function(e, n) { - n.now = Math.round(e), n.prop !== "height" ? f += n.now : a.options.heightStyle !== "content" && (n.now = Math.round(s - t.outerHeight() - f), - f = 0); - } - }); - }, - "_toggleComplete": function(e) { - var t = e.oldPanel; - t.removeClass("ui-accordion-content-active").prev().removeClass("ui-corner-top").addClass("ui-corner-all"), - t.length && (t.parent()[0].className = t.parent()[0].className), this._trigger("activate", null, e); - } - }); -})(jQuery); - -(function(e, t) { - var n = 0; - e.widget("ui.autocomplete", { - "version": "1.10.1", - "defaultElement": "", - "options": { - "appendTo": null, - "autoFocus": !1, - "delay": 300, - "minLength": 1, - "position": { - "my": "left top", - "at": "left bottom", - "collision": "none" - }, - "source": null, - "change": null, - "close": null, - "focus": null, - "open": null, - "response": null, - "search": null, - "select": null - }, - "pending": 0, - "_create": function() { - var t, n, r, i = this.element[0].nodeName.toLowerCase(), s = i === "textarea", o = i === "input"; - this.isMultiLine = s ? !0 : o ? !1 : this.element.prop("isContentEditable"), this.valueMethod = this.element[s || o ? "val" : "text"], - this.isNewMenu = !0, this.element.addClass("ui-autocomplete-input").attr("autocomplete", "off"), - this._on(this.element, { - "keydown": function(i) { - if (this.element.prop("readOnly")) { - t = !0, r = !0, n = !0; - return; - } - t = !1, r = !1, n = !1; - var s = e.ui.keyCode; - switch (i.keyCode) { - case s.PAGE_UP: - t = !0, this._move("previousPage", i); - break; - - case s.PAGE_DOWN: - t = !0, this._move("nextPage", i); - break; - - case s.UP: - t = !0, this._keyEvent("previous", i); - break; - - case s.DOWN: - t = !0, this._keyEvent("next", i); - break; - - case s.ENTER: - case s.NUMPAD_ENTER: - this.menu.active && (t = !0, i.preventDefault(), this.menu.select(i)); - break; - - case s.TAB: - this.menu.active && this.menu.select(i); - break; - - case s.ESCAPE: - this.menu.element.is(":visible") && (this._value(this.term), this.close(i), i.preventDefault()); - break; - - default: - n = !0, this._searchTimeout(i); - } - }, - "keypress": function(r) { - if (t) { - t = !1, r.preventDefault(); - return; - } - if (n) return; - var i = e.ui.keyCode; - switch (r.keyCode) { - case i.PAGE_UP: - this._move("previousPage", r); - break; - - case i.PAGE_DOWN: - this._move("nextPage", r); - break; - - case i.UP: - this._keyEvent("previous", r); - break; - - case i.DOWN: - this._keyEvent("next", r); - } - }, - "input": function(e) { - if (r) { - r = !1, e.preventDefault(); - return; - } - this._searchTimeout(e); - }, - "focus": function() { - this.selectedItem = null, this.previous = this._value(); - }, - "blur": function(e) { - if (this.cancelBlur) { - delete this.cancelBlur; - return; - } - clearTimeout(this.searching), this.close(e), this._change(e); - } - }), this._initSource(), this.menu = e("