diff --git a/CHANGELOG.md b/CHANGELOG.md index b8e655a..2e8e742 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,24 @@ +# v0.6.0 (2014/12/4) +## Features +- Support AngularJS v1.3+ + +## Bug Fixes +- **macAutocomplete:** Fixed $animate API changes due to AngularJS v1.3 +([d6c69cd7](https://github.com/angular-macgyver/MacGyver/commit/d6c69cd7dedbf0ef3d8620b4b0be29339c8a1a9e)) +- **macModal:** Fixed not able to close with escape key +([373d6647](https://github.com/angular-macgyver/MacGyver/commit/373d6647c00e6c02eed374618cbc0b3d8594393b)) + +## Optimizations +- **Mac:** Initial 1.3 changes +([58207495](https://github.com/angular-macgyver/MacGyver/commit/582074950b5f034b3a8c4839534f5888f9c8821c)) + +## Breaking Changes +- **macModal:** modalView provider has been removed and should be switched to use modalProvider instead Related to #4 +([c5fb9815](https://github.com/angular-macgyver/MacGyver/commit/c5fb98153e9f4f423019de545decb20f2cf1f274)) +- **macPopover:** popoverView provider has been removed and should be switched to use popoverProvider instead Related to #4 +([f38cb92f](https://github.com/angular-macgyver/MacGyver/commit/f38cb92f132ccc81d1ef6501e02421cb412e984e)) + + # v0.5.1 (2014/12/2) ## Bug Fixes - **macTooltip:** Fixed appending multiple tooltips diff --git a/bower.json b/bower.json index 1555d3d..d2726e6 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "MacGyver", - "version": "0.5.1", + "version": "0.6.0", "main": [ "lib/macgyver-core.js", "lib/macgyver-filters.js", @@ -30,4 +30,4 @@ "angular-animate": "~1.3.0", "underscore.string": "~2.3.3" } -} +} \ No newline at end of file diff --git a/lib/macgyver-core.js b/lib/macgyver-core.js index 4e18651..a009f80 100644 --- a/lib/macgyver-core.js +++ b/lib/macgyver-core.js @@ -1,5 +1,5 @@ /** - * MacGyver v0.5.1 + * MacGyver v0.6.0 * @link http://angular-macgyver.github.io/MacGyver * @license MIT */ @@ -862,8 +862,9 @@ angular.module("Mac").directive("macAutocomplete", [ @description Adding menu to DOM @param {Function} callback Callback after enter animation completes + @returns {Promise} Animation promise */ - appendMenu = function(callback) { + appendMenu = function() { if (!isMenuAppended) { element.bind("blur", blurHandler); menuEl.on('mousedown', function(event) { @@ -872,9 +873,9 @@ angular.module("Mac").directive("macAutocomplete", [ } isMenuAppended = true; if (inside) { - return $animate.enter(menuEl, void 0, element, callback); + return $animate.enter(menuEl, void 0, element); } else { - return $animate.enter(menuEl, angular.element(document.body), void 0, callback); + return $animate.enter(menuEl, angular.element(document.body)); } }; @@ -883,9 +884,10 @@ angular.module("Mac").directive("macAutocomplete", [ @name reset @description Resetting autocomplete + @returns {Promise} Leave animation promise */ reset = function() { - $animate.leave(menuEl, function() { + return $animate.leave(menuEl).then(function() { $menuScope.index = 0; $menuScope.items.length = 0; menuEl[0].style.top = ""; @@ -943,7 +945,7 @@ angular.module("Mac").directive("macAutocomplete", [ }; } }); - return appendMenu(positionMenu); + return appendMenu().then(positionMenu); } else { return reset(); } @@ -1185,6 +1187,36 @@ angular.module("Mac").directive("macMenu", [ /* @chalk overview +@name Modal + */ + +/* +@chalk provider +@name Modal Provider + +@description +Configure modal options in config block + +@param {Object} defaults Modal default +```js +{ + keyboard: false, + overlayClose: false, + resize: true, + position: true, + open: angular.noop, + topOffset: 20, + attributes: {}, + beforeShow: angular.noop, + afterShow: angular.noop, + beforeHide: angular.noop, + afterHide: angular.noop +} +``` + */ + +/* +@chalk service @name Modal Service @description @@ -1217,30 +1249,59 @@ There are multiple components used by modal. @param {Function} clearWaiting Remove certain modal id from waiting list - {String} id ID of the modal */ -angular.module("Mac").service("modal", [ - "$rootScope", "$animate", "$templateCache", "$compile", "$http", "$controller", "modalViews", "keys", function($rootScope, $animate, $templateCache, $compile, $http, $controller, modalViews, keys) { - return { - registered: modalViews.registered, - waiting: null, - opened: null, - modalTemplate: "
\n
\n \n
\n
\n
", - show: function(id, triggerOptions) { - var modalObject, options, path, renderModal, showModal, showOptions, template; - if (triggerOptions == null) { - triggerOptions = {}; +angular.module("Mac").provider("modal", function() { + var defaults, registered; + this.registered = registered = {}; + this.defaults = defaults = { + keyboard: false, + overlayClose: false, + resize: true, + position: true, + open: angular.noop, + topOffset: 20, + attributes: {}, + beforeShow: angular.noop, + afterShow: angular.noop, + beforeHide: angular.noop, + afterHide: angular.noop + }; + this.$get = [ + "$animate", "$compile", "$controller", "$document", "$http", "$rootScope", "$templateCache", "keys", function($animate, $compile, $controller, $document, $http, $rootScope, $templateCache, keys) { + var escapeKeyHandler, resizeHandler, service; + escapeKeyHandler = function(event) { + var scope; + if (event.keyCode === keys.ESCAPE && service.opened) { + scope = service.opened.element.scope(); + return scope.$apply(function() { + return service.hide(); + }); } - if ((this.registered[id] != null) && (this.opened != null)) { - return this.hide(); - } else if (this.registered[id] != null) { - modalObject = this.registered[id]; - options = modalObject.options; - showOptions = {}; - angular.extend(showOptions, options, triggerOptions); - showModal = (function(_this) { - return function(element) { - showOptions.beforeShow(element.scope()); - return $animate.removeClass(element, "hide", function() { - return $animate.addClass(element, "visible", function() { + }; + resizeHandler = function() { + return service.resize(); + }; + service = { + registered: registered, + defaults: defaults, + waiting: null, + opened: null, + modalTemplate: "
\n
\n \n
\n
\n
", + show: function(id, triggerOptions) { + var modalObject, options, path, renderModal, showModal, showOptions, template; + if (triggerOptions == null) { + triggerOptions = {}; + } + if ((this.registered[id] != null) && (this.opened != null)) { + return this.hide(); + } else if (this.registered[id] != null) { + modalObject = this.registered[id]; + options = modalObject.options; + showOptions = {}; + angular.extend(showOptions, options, triggerOptions); + showModal = (function(_this) { + return function(element) { + showOptions.beforeShow(element.scope()); + return $animate.addClass(element, "visible").then(function() { _this.opened = { id: id, element: element, @@ -1253,220 +1314,190 @@ angular.module("Mac").service("modal", [ $rootScope.$broadcast("modalWasShown", id); return _this.clearWaiting(); }); - }); - }; - })(this); - if (showOptions.moduleMethod != null) { - renderModal = (function(_this) { - return function(template) { - var element, viewScope, wrapper; - if (isScope(showOptions.scope)) { - viewScope = showOptions.scope; - } else { - viewScope = $rootScope.$new(true); - if (angular.isObject(showOptions.scope)) { - angular.extend(viewScope, showOptions.scope); - } - } - angular.extend(showOptions.attributes, { - id: id - }); - element = angular.element(_this.modalTemplate).attr(showOptions.attributes); - wrapper = angular.element(element[0].getElementsByClassName("mac-modal-content-wrapper")); - wrapper.html(template); - if (showOptions.overlayClose) { - element.bind("click", function($event) { - if (angular.element($event.target).hasClass("mac-modal-overlay")) { - return viewScope.$apply(function() { - return _this.hide(); - }); + }; + })(this); + if (showOptions.moduleMethod != null) { + renderModal = (function(_this) { + return function(template) { + var element, viewScope, wrapper; + if (isScope(showOptions.scope)) { + viewScope = showOptions.scope; + } else { + viewScope = $rootScope.$new(true); + if (angular.isObject(showOptions.scope)) { + angular.extend(viewScope, showOptions.scope); } + } + angular.extend(showOptions.attributes, { + id: id }); - } - if (showOptions.controller) { - $controller(showOptions.controller, { - $scope: viewScope, - $element: element, - macModalOptions: showOptions + element = angular.element(_this.modalTemplate).attr(showOptions.attributes); + wrapper = angular.element(element[0].getElementsByClassName("mac-modal-content-wrapper")); + wrapper.html(template); + if (showOptions.overlayClose) { + element.bind("click", function($event) { + if (angular.element($event.target).hasClass("mac-modal-overlay")) { + return viewScope.$apply(function() { + return _this.hide(); + }); + } + }); + } + if (showOptions.controller) { + $controller(showOptions.controller, { + $scope: viewScope, + $element: element, + macModalOptions: showOptions + }); + } + $animate.enter(element, angular.element(document.body)); + $compile(element)(viewScope); + return showModal(element); + }; + })(this); + if ((path = showOptions.templateUrl)) { + template = $templateCache.get(path); + if (template) { + return renderModal(template); + } else { + return $http.get(path).then(function(resp) { + $templateCache.put(path, resp.data); + return renderModal(resp.data); + }, function() { + throw Error("Failed to load template: " + path); }); } - $animate.enter(element, angular.element(document.body)); - $compile(element)(viewScope); - return showModal(element); - }; - })(this); - if ((path = showOptions.templateUrl)) { - template = $templateCache.get(path); - if (template) { + } else if ((template = showOptions.template)) { return renderModal(template); - } else { - return $http.get(path).then(function(resp) { - $templateCache.put(path, resp.data); - return renderModal(resp.data); - }, function() { - throw Error("Failed to load template: " + path); - }); } - } else if ((template = showOptions.template)) { - return renderModal(template); + } else if (modalObject.element != null) { + return showModal(modalObject.element); } - } else if (modalObject.element != null) { - return showModal(modalObject.element); + } else { + return this.waiting = { + id: id, + options: triggerOptions + }; } - } else { - return this.waiting = { - id: id, - options: triggerOptions + }, + resize: function(modalObject) { + var css, element, height, modal, options, width; + if (modalObject == null) { + modalObject = this.opened; + } + if (modalObject == null) { + return; + } + element = modalObject.element; + options = modalObject.options; + if (!options.position) { + return; + } + modal = angular.element(element[0].querySelector(".mac-modal")); + height = modal.outerHeight(); + width = modal.outerWidth(); + css = angular.element(window).height() > height ? { + marginTop: -height / 2 + } : { + top: options.topOffset }; - } - }, - resize: function(modalObject) { - var css, element, height, modal, options, width; - if (modalObject == null) { - modalObject = this.opened; - } - if (modalObject == null) { - return; - } - element = modalObject.element; - options = modalObject.options; - if (!options.position) { - return; - } - modal = angular.element(element[0].getElementsByClassName("mac-modal")).attr("style", ""); - height = modal.outerHeight(); - width = modal.outerWidth(); - css = angular.element(window).height() > height ? { - marginTop: -height / 2 - } : { - top: options.topOffset - }; - css.marginLeft = -width / 2; - return angular.forEach(css, function(value, key) { - if (!isNaN(+value) && angular.isNumber(+value)) { - value = "" + value + "px"; + css.marginLeft = -width / 2; + return angular.forEach(css, function(value, key) { + if (!isNaN(+value) && angular.isNumber(+value)) { + value = "" + value + "px"; + } + return modal.css(key, value); + }); + }, + hide: function() { + var element, id, options, self, _ref; + if (this.opened == null) { + return; } - return modal.css(key, value); - }); - }, - hide: function(callback) { - var element, id, options, _ref; - if (this.opened == null) { - return; - } - _ref = this.opened, id = _ref.id, options = _ref.options, element = _ref.element; - options.beforeHide(element.scope()); - return $animate.removeClass(element, "visible", (function(_this) { - return function() { - _this.bindingEvents("unbind"); - _this.opened = null; + _ref = this.opened, id = _ref.id, options = _ref.options, element = _ref.element; + options.beforeHide(element.scope()); + self = this; + return $animate.removeClass(element, "visible").then(function() { + var modal; + self.bindingEvents("unbind"); + self.opened = null; if (options.moduleMethod) { if (!isScope(options.scope)) { element.scope().$destroy(); } $animate.leave(element); } else { - $animate.addClass(element, "hide"); + modal = element[0].querySelector(".mac-modal"); + modal.removeAttribute("style"); } options.afterHide(element.scope()); - $rootScope.$broadcast("modalWasHidden", id); - return callback && callback(); - }; - })(this)); - }, - bindingEvents: function(action) { - var escapeKeyHandler, options, resizeHandler; - if (action == null) { - action = "bind"; - } - if (!((action === "bind" || action === "unbind") && (this.opened != null))) { - return; - } - escapeKeyHandler = (function(_this) { - return function(event) { - if (event.which === keys.ESCAPE) { - return _this.hide(); - } - }; - })(this); - resizeHandler = (function(_this) { - return function(event) { - return _this.resize(); + return $rootScope.$broadcast("modalWasHidden", id); + }); + }, + bindingEvents: function(action) { + var options; + if (action == null) { + action = "bind"; + } + if (!((action === "bind" || action === "unbind") && (this.opened != null))) { + return; + } + options = this.opened.options; + if (options.keyboard) { + $document[action]("keydown", escapeKeyHandler); + } + if (options.resize) { + return angular.element(window)[action]("resize", resizeHandler); + } + }, + register: function(id, element, options) { + var modalOpts; + if (this.registered[id] != null) { + throw new Error("Modal " + id + " already registered"); + } + modalOpts = {}; + angular.extend(modalOpts, defaults, options); + this.registered[id] = { + id: id, + element: element, + options: modalOpts }; - })(this); - options = this.opened.options; - if (options.keyboard) { - angular.element(document)[action]("keydown", escapeKeyHandler); - } - if (options.resize) { - return angular.element(window)[action]("resize", resizeHandler); - } - }, - register: function(id, element, options) { - var modalOpts; - if (this.registered[id] != null) { - throw new Error("Modal " + id + " already registered"); - } - modalOpts = {}; - angular.extend(modalOpts, modalViews.defaults, options); - this.registered[id] = { - id: id, - element: element, - options: modalOpts - }; - if ((this.waiting != null) && this.waiting.id === id) { - return this.show(id, this.waiting.options); - } - }, - unregister: function(id) { - var _ref; - if (this.registered[id] == null) { - throw new Error("Modal " + id + " is not registered"); - } - if (((_ref = this.opened) != null ? _ref.id : void 0) === id) { - this.hide(); - } - this.clearWaiting(id); - return delete this.registered[id]; - }, - clearWaiting: function(id) { - var _ref; - if ((id != null) && ((_ref = this.waiting) != null ? _ref.id : void 0) !== id) { - return; + if ((this.waiting != null) && this.waiting.id === id) { + return this.show(id, this.waiting.options); + } + }, + unregister: function(id) { + var _ref; + if (this.registered[id] == null) { + throw new Error("Modal " + id + " is not registered"); + } + if (((_ref = this.opened) != null ? _ref.id : void 0) === id) { + this.hide(); + } + this.clearWaiting(id); + return delete this.registered[id]; + }, + clearWaiting: function(id) { + var _ref; + if ((id != null) && ((_ref = this.waiting) != null ? _ref.id : void 0) !== id) { + return; + } + return this.waiting = null; } - return this.waiting = null; - } - }; - } -]).provider("modalViews", function() { - this.registered = {}; - this.defaults = { - keyboard: false, - overlayClose: false, - resize: true, - position: true, - open: angular.noop, - topOffset: 20, - attributes: {}, - beforeShow: angular.noop, - afterShow: angular.noop, - beforeHide: angular.noop, - afterHide: angular.noop - }; - this.$get = function() { - return this; - }; - return this; + }; + return service; + } + ]; }).config([ - "modalViewsProvider", function(modalViews) { + "modalProvider", function(modal) { return angular.module("Mac").modal = function(id, modalOptions) { var options; - if (modalViews.registered[id] == null) { + if (modal.registered[id] == null) { options = {}; - angular.extend(options, modalViews.defaults, modalOptions, { + angular.extend(options, modal.defaults, modalOptions, { moduleMethod: true }); - return modalViews.registered[id] = { + return modal.registered[id] = { id: id, options: options }; @@ -1478,10 +1509,55 @@ angular.module("Mac").service("modal", [ /* @chalk overview +@name Popover + */ + +/* +@chalk provider +@name Popover Provider + +@description +Configurate popover options in config block. + +@param {Object} defaults Popover defaults +```js +{ + fixed: false, + childPopover: false, + offsetY: 0, + offsetX: 0, + trigger: "click" +} +``` + +@param {Object} popoverDefaults Popover trigger defaults +```js +{ + footer: false, + header: false, + title: "", + direction: "above left" +} +``` + +@param {String} template Popover template +```js +"
+
+
+
{{macPopoverTitle}}
+
+
+
"; +``` + */ + +/* +@chalk service @name Popover Service @description -A popover service to keep state of opened popover. Allowing user to hide certain +Popover service to keep state of opened popover. Allowing user to hide certain or all popovers @param {Array} popoverList The popover that's currently being shown @@ -1533,16 +1609,17 @@ last opened popover is hidden @param {Function} hideAll Hide all popovers */ -angular.module("Mac").provider("popoverViews", function() { - this.registered = {}; - this.defaults = { +angular.module("Mac").provider("popover", function() { + var defaults, popoverDefaults, popoverTemplate, registered; + this.registered = registered = {}; + this.defaults = defaults = { fixed: false, childPopover: false, offsetY: 0, offsetX: 0, trigger: "click" }; - this.popoverDefaults = { + this.popoverDefaults = popoverDefaults = { footer: false, header: false, title: "", @@ -1554,311 +1631,311 @@ angular.module("Mac").provider("popoverViews", function() { @description Popover template */ - this.template = "
\n
\n
\n
{{macPopoverTitle}}
\n
\n
\n
"; - this.$get = function() { - return this; - }; - return this; -}).service("popover", [ - "$animate", "$compile", "$controller", "$http", "$rootScope", "$templateCache", "$timeout", "popoverViews", function($animate, $compile, $controller, $http, $rootScope, $templateCache, $timeout, popoverViews) { - var service; - service = { - popoverList: [], - registered: popoverViews.registered, - last: function() { - return this.popoverList[this.popoverList.length - 1]; - }, - register: function(id, options) { - var exist; - if (!(exist = this.registered[id] != null)) { - this.registered[id] = options; - } - return !exist; - }, - unregister: function(id) { - var exist; - if (exist = this.registered[id] != null) { - delete this.registered[id]; - } - return exist; - }, - add: function(id, popover, element, options) { - var newObject; - newObject = { - id: id, - popover: popover, - element: element, - options: options - }; - this.popoverList.push(newObject); - return newObject; - }, - pop: function() { - return this.popoverList.pop(); - }, - show: function(id, element, options) { - var addPopover, popoverOptions; - if (options == null) { - options = {}; - } - popoverOptions = this.registered[id]; - if (!popoverOptions) { - return false; - } - addPopover = function() { - var path, showPopover, template; - showPopover = function(template) { - var popover, popoverObj, viewScope; - if (isScope(options.scope)) { - viewScope = options.scope.$new(); - } else { - viewScope = $rootScope.$new(true); - if (angular.isObject(options.scope)) { - angular.extend(viewScope, options.scope); + this.template = popoverTemplate = "
\n
\n
\n
{{macPopoverTitle}}
\n
\n
\n
"; + this.$get = [ + "$animate", "$compile", "$controller", "$http", "$rootScope", "$templateCache", "$timeout", function($animate, $compile, $controller, $http, $rootScope, $templateCache, $timeout) { + var service; + service = { + popoverList: [], + registered: registered, + defaults: defaults, + popoverDefaults: popoverDefaults, + template: popoverTemplate, + last: function() { + return this.popoverList[this.popoverList.length - 1]; + }, + register: function(id, options) { + var exist; + if (!(exist = this.registered[id] != null)) { + this.registered[id] = options; + } + return !exist; + }, + unregister: function(id) { + var exist; + if (exist = this.registered[id] != null) { + delete this.registered[id]; + } + return exist; + }, + add: function(id, popover, element, options) { + var newObject; + newObject = { + id: id, + popover: popover, + element: element, + options: options + }; + this.popoverList.push(newObject); + return newObject; + }, + pop: function() { + return this.popoverList.pop(); + }, + show: function(id, element, options) { + var addPopover, popoverOptions; + if (options == null) { + options = {}; + } + popoverOptions = this.registered[id]; + if (!popoverOptions) { + return false; + } + addPopover = function() { + var path, showPopover, template; + showPopover = function(template) { + var popover, popoverObj, viewScope; + if (isScope(options.scope)) { + viewScope = options.scope.$new(); + } else { + viewScope = $rootScope.$new(true); + if (angular.isObject(options.scope)) { + angular.extend(viewScope, options.scope); + } } - } - if (popoverOptions.refreshOn) { - viewScope.$on(popoverOptions.refreshOn, function() { - return service.resize(id); + if (popoverOptions.refreshOn) { + viewScope.$on(popoverOptions.refreshOn, function() { + return service.resize(id); + }); + } + if (popoverOptions.controller) { + $controller(popoverOptions.controller, { + $scope: viewScope + }); + } + angular.extend(viewScope, { + macPopoverClasses: { + footer: popoverOptions.footer || false, + header: popoverOptions.header || !!popoverOptions.title || false, + fixed: popoverOptions.fixed || false + }, + macPopoverTitle: popoverOptions.title || "", + macPopoverTemplate: template }); - } - if (popoverOptions.controller) { - $controller(popoverOptions.controller, { - $scope: viewScope + popover = $compile(popoverTemplate)(viewScope); + popover.attr({ + id: id, + direction: popoverOptions.direction || "below left" }); + popoverObj = service.add(id, popover, element, options); + $animate.addClass(element, "active"); + $rootScope.$broadcast("popoverWasShown", id); + return $animate.enter(popover, angular.element(document.body)).then(function() { + return service.resize(popoverObj); + }); + }; + if ((template = popoverOptions.template)) { + return showPopover(template); + } else if ((path = popoverOptions.templateUrl)) { + template = $templateCache.get(path); + if (template) { + return showPopover(template); + } else { + return $http.get(path).then(function(resp) { + $templateCache.put(path, resp.data); + return showPopover(resp.data); + }, function() { + throw new Error('Failed to load template: #{path}'); + }); + } } - angular.extend(viewScope, { - macPopoverClasses: { - footer: popoverOptions.footer || false, - header: popoverOptions.header || !!popoverOptions.title || false, - fixed: popoverOptions.fixed || false - }, - macPopoverTitle: popoverOptions.title || "", - macPopoverTemplate: template - }); - popover = $compile(popoverViews.template)(viewScope); - popover.attr({ - id: id, - direction: popoverOptions.direction || "below left" - }); - popoverObj = service.add(id, popover, element, options); - $animate.addClass(element, "active"); - $rootScope.$broadcast("popoverWasShown", id); - return $animate.enter(popover, angular.element(document.body), null, function() { - return service.resize(popoverObj); - }); }; - if ((template = popoverOptions.template)) { - return showPopover(template); - } else if ((path = popoverOptions.templateUrl)) { - template = $templateCache.get(path); - if (template) { - return showPopover(template); - } else { - return $http.get(path).then(function(resp) { - $templateCache.put(path, resp.data); - return showPopover(resp.data); - }, function() { - throw new Error('Failed to load template: #{path}'); - }); + if (service.popoverList.length && !!!options.childPopover) { + service.hide(addPopover); + } else { + addPopover(); + } + return true; + }, + getById: function(id, element) { + var item, sameTrigger, _i, _len, _ref; + _ref = this.popoverList; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + item = _ref[_i]; + sameTrigger = (element == null) || item.element === element; + if (item.id === id && sameTrigger) { + return item; } } - }; - if (service.popoverList.length && !!!options.childPopover) { - service.hide(addPopover); - } else { - addPopover(); - } - return true; - }, - getById: function(id, element) { - var item, sameTrigger, _i, _len, _ref; - _ref = this.popoverList; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - item = _ref[_i]; - sameTrigger = (element == null) || item.element === element; - if (item.id === id && sameTrigger) { - return item; + }, + resize: function(popoverObj) { + var $window, action, current, currentPopover, diff, left, leftScroll, offset, options, position, relative, relativeElement, setOverflowPosition, top, topScroll, updateOffset; + if (angular.isString(popoverObj)) { + popoverObj = service.getById(popoverObj); } - } - }, - resize: function(popoverObj) { - var $window, action, current, currentPopover, diff, left, leftScroll, offset, options, position, relative, relativeElement, setOverflowPosition, top, topScroll, updateOffset; - if (angular.isString(popoverObj)) { - popoverObj = service.getById(popoverObj); - } - if (popoverObj == null) { - return; - } - currentPopover = popoverObj.popover; - relativeElement = popoverObj.element; - options = popoverObj.options; - $window = angular.element(window); - offset = relativeElement.offset(); - if (options.fixed) { - offset.top = relativeElement.position().top; - } - relative = { - height: relativeElement.outerHeight(), - width: relativeElement.outerWidth() - }; - current = { - height: currentPopover.outerHeight(), - width: currentPopover.outerWidth() - }; - top = 0; - left = 0; - position = (currentPopover.attr("direction") || "top left").trim(); - setOverflowPosition = function(offset) { - var tip, tipOffset; - if (offset == null) { - offset = 0; - } - tip = angular.element(currentPopover[0].getElementsByClassName("tip")); - top -= offset; - tipOffset = +tip.css("margin-top").replace("px", ""); - return tip.css("margin-top", tipOffset + offset); - }; - updateOffset = function() { - switch (position) { - case "above left": - top = -(current.height + 10); - return left = -25 + relative.width / 2; - case "above right": - top = -(current.height + 10); - return left = 25 + relative.width / 2 - current.width; - case "below left": - top = relative.height + 10; - return left = -25 + relative.width / 2; - case "below right": - top = relative.height + 10; - return left = 25 + relative.width / 2 - current.width; - case "middle right": - top = relative.height / 2 - current.height / 2; - return left = relative.width + 10; - case "middle left": - top = relative.height / 2 - current.height / 2; - return left = -(current.width + 10); + if (popoverObj == null) { + return; } - }; - updateOffset(); - topScroll = options.fixed ? 0 : $window.scrollTop(); - leftScroll = options.fixed ? 0 : $window.scrollLeft(); - action = {}; - if (position.indexOf("middle") === -1) { - if (offset.top + top - topScroll < 0) { + currentPopover = popoverObj.popover; + relativeElement = popoverObj.element; + options = popoverObj.options; + $window = angular.element(window); + offset = relativeElement.offset(); + if (options.fixed) { + offset.top = relativeElement.position().top; + } + relative = { + height: relativeElement.outerHeight(), + width: relativeElement.outerWidth() + }; + current = { + height: currentPopover.outerHeight(), + width: currentPopover.outerWidth() + }; + top = 0; + left = 0; + position = (currentPopover.attr("direction") || "top left").trim(); + setOverflowPosition = function(offset) { + var tip, tipOffset; + if (offset == null) { + offset = 0; + } + tip = angular.element(currentPopover[0].getElementsByClassName("tip")); + top -= offset; + tipOffset = +tip.css("margin-top").replace("px", ""); + return tip.css("margin-top", tipOffset + offset); + }; + updateOffset = function() { + switch (position) { + case "above left": + top = -(current.height + 10); + return left = -25 + relative.width / 2; + case "above right": + top = -(current.height + 10); + return left = 25 + relative.width / 2 - current.width; + case "below left": + top = relative.height + 10; + return left = -25 + relative.width / 2; + case "below right": + top = relative.height + 10; + return left = 25 + relative.width / 2 - current.width; + case "middle right": + top = relative.height / 2 - current.height / 2; + return left = relative.width + 10; + case "middle left": + top = relative.height / 2 - current.height / 2; + return left = -(current.width + 10); + } + }; + updateOffset(); + topScroll = options.fixed ? 0 : $window.scrollTop(); + leftScroll = options.fixed ? 0 : $window.scrollLeft(); + action = {}; + if (position.indexOf("middle") === -1) { + if (offset.top + top - topScroll < 0) { + action = { + remove: "above", + add: "below" + }; + } else if (offset.top + top + current.height - topScroll > $window.height()) { + action = { + remove: "below", + add: "above" + }; + } + } else { + if ((diff = offset.top + top - topScroll) < 0) { + setOverflowPosition(diff); + } else if ((diff = offset.top + top + currentPopover.outerHeight() - topScroll - $window.height()) > 0) { + setOverflowPosition(diff); + } + } + if (action.remove && action.add) { + position = position.replace(action.remove, action.add); + } + action = {}; + if (offset.left + left - leftScroll < 0) { action = { - remove: "above", - add: "below" + remove: "right", + add: "left" }; - } else if (offset.top + top + current.height - topScroll > $window.height()) { + } else if (offset.left + left + currentPopover.outerWidth() - leftScroll > $window.width()) { action = { - remove: "below", - add: "above" + remove: "left", + add: "right" }; } - } else { - if ((diff = offset.top + top - topScroll) < 0) { - setOverflowPosition(diff); - } else if ((diff = offset.top + top + currentPopover.outerHeight() - topScroll - $window.height()) > 0) { - setOverflowPosition(diff); + if (action.remove && action.add) { + position = position.replace(action.remove, action.add); } - } - if (action.remove && action.add) { - position = position.replace(action.remove, action.add); - } - action = {}; - if (offset.left + left - leftScroll < 0) { - action = { - remove: "right", - add: "left" - }; - } else if (offset.left + left + currentPopover.outerWidth() - leftScroll > $window.width()) { - action = { - remove: "left", - add: "right" - }; - } - if (action.remove && action.add) { - position = position.replace(action.remove, action.add); - } - updateOffset(); - offset.top += top; - offset.left += left; - if (options.offsetX != null) { - offset.left += options.offsetX; - } - if (options.offsetY != null) { - offset.top += options.offsetY; - } - angular.forEach(offset, function(value, key) { - if (!isNaN(+value)) { - value = "" + value + "px"; + updateOffset(); + offset.top += top; + offset.left += left; + if (options.offsetX != null) { + offset.left += options.offsetX; } - return currentPopover.css(key, value); - }); - return currentPopover.addClass("visible " + position); - }, - hide: function(selector, callback) { - var comparator, i, index, popoverObj, removeScope, _i, _ref; - if (!this.popoverList.length) { - return typeof callback === "function" ? callback() : void 0; - } - if (angular.isFunction(selector)) { - callback = selector; - selector = null; - } - if (selector != null) { - comparator = angular.isString(selector) ? function(item) { - return item.id === selector; - } : angular.isElement(selector) ? function(item) { - return item.element === selector; - } : void 0; - index = -1; - for (i = _i = _ref = this.popoverList.length - 1; _i >= 0; i = _i += -1) { - if (!(comparator(this.popoverList[i]))) { - continue; + if (options.offsetY != null) { + offset.top += options.offsetY; + } + angular.forEach(offset, function(value, key) { + if (!isNaN(+value)) { + value = "" + value + "px"; } - popoverObj = this.popoverList[i]; - index = i; - break; + return currentPopover.css(key, value); + }); + return currentPopover.addClass("visible " + position); + }, + hide: function(selector, callback) { + var comparator, i, index, popoverObj, removeScope, _i, _ref; + if (!this.popoverList.length) { + return typeof callback === "function" ? callback() : void 0; + } + if (angular.isFunction(selector)) { + callback = selector; + selector = null; + } + if (selector != null) { + comparator = angular.isString(selector) ? function(item) { + return item.id === selector; + } : angular.isElement(selector) ? function(item) { + return item.element === selector; + } : void 0; + index = -1; + for (i = _i = _ref = this.popoverList.length - 1; _i >= 0; i = _i += -1) { + if (!(comparator(this.popoverList[i]))) { + continue; + } + popoverObj = this.popoverList[i]; + index = i; + break; + } + if (index > -1) { + this.popoverList.splice(index, 1); + } + } else { + popoverObj = this.pop(); } - if (index > -1) { - this.popoverList.splice(index, 1); + if (popoverObj == null) { + return; } - } else { - popoverObj = this.pop(); - } - if (popoverObj == null) { - return; - } - $rootScope.$broadcast("popoverBeforeHide", popoverObj.id); - removeScope = popoverObj.popover.scope(); - return $animate.leave(popoverObj.popover, function() { + $rootScope.$broadcast("popoverBeforeHide", popoverObj.id); $animate.removeClass(popoverObj.element, "active"); - $rootScope.$broadcast("popoverWasHidden", popoverObj.id); - removeScope.$destroy(); - return typeof callback === "function" ? callback() : void 0; - }); - }, - hideAll: function() { - while (this.popoverList.length) { - this.hide(); + removeScope = popoverObj.popover.scope(); + return $animate.leave(popoverObj.popover).then(function() { + $rootScope.$broadcast("popoverWasHidden", popoverObj.id); + removeScope.$destroy(); + return typeof callback === "function" ? callback() : void 0; + }); + }, + hideAll: function() { + while (this.popoverList.length) { + this.hide(); + } } - } - }; - return service; - } -]).config([ - "popoverViewsProvider", function(popoverViews) { + }; + return service; + } + ]; +}).config([ + "popoverProvider", function(popoverProvider) { return angular.module("Mac").popover = function(name, options) { var opts; - if (popoverViews.registered[name] == null) { + if (popoverProvider.registered[name] == null) { opts = {}; - angular.extend(opts, popoverViews.popoverDefaults, options, { + angular.extend(opts, popoverProvider.popoverDefaults, options, { id: name }); - return popoverViews.registered[name] = opts; + return popoverProvider.registered[name] = opts; } }; } @@ -1884,7 +1961,7 @@ modal template @param {Boolean} mac-modal-position Calculate size and position with JS (default true) */ angular.module("Mac").directive("macModal", [ - "$parse", "modal", "modalViews", "util", function($parse, modal, modalViews, util) { + "$parse", "modal", "util", function($parse, modal, util) { return { restrict: "E", template: modal.modalTemplate, @@ -1895,7 +1972,7 @@ angular.module("Mac").directive("macModal", [ transclude($scope, function(clone) { return angular.element(element[0].getElementsByClassName("mac-modal-content-wrapper")).replaceWith(clone); }); - opts = util.extendAttributes("macModal", modalViews.defaults, attrs); + opts = util.extendAttributes("macModal", modal.defaults, attrs); regId = null; if (opts.overlayClose) { element.on("click", function($event) { @@ -1991,12 +2068,12 @@ popover will be closed automatically var __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; angular.module("Mac").directive("macPopover", [ - "$timeout", "popover", "util", "popoverViews", function($timeout, popover, util, popoverViews) { + "$timeout", "popover", "util", function($timeout, popover, util) { return { restrict: "A", link: function(scope, element, attrs) { var clearDelays, closeDelayId, delayId, exclude, excludeList, hide, options, show; - options = util.extendAttributes("macPopover", popoverViews.defaults, attrs); + options = util.extendAttributes("macPopover", popover.defaults, attrs); exclude = attrs.macPopoverExclude || ""; excludeList = exclude ? exclude.split(",") : []; delayId = null; @@ -2061,7 +2138,7 @@ angular.module("Mac").directive("macPopover", [ }; } ]).directive("macPopover", [ - "popover", "popoverViews", "util", function(popover, popoverViews, util) { + "popover", "util", function(popover, util) { return { restrict: "E", compile: function(element, attrs) { @@ -2069,7 +2146,7 @@ angular.module("Mac").directive("macPopover", [ if (!attrs.id) { throw Error("macPopover: Missing id"); } - opts = util.extendAttributes("macPopover", popoverViews.popoverDefaults, attrs); + opts = util.extendAttributes("macPopover", popover.popoverDefaults, attrs); angular.extend(opts, { template: element.html() }); diff --git a/lib/macgyver-filters.js b/lib/macgyver-filters.js index 232eefc..8bea985 100644 --- a/lib/macgyver-filters.js +++ b/lib/macgyver-filters.js @@ -1,5 +1,5 @@ /** - * MacGyver v0.5.1 + * MacGyver v0.6.0 * @link http://angular-macgyver.github.io/MacGyver * @license MIT */ diff --git a/lib/macgyver-string-filter.js b/lib/macgyver-string-filter.js index e29da8f..dbb53f2 100644 --- a/lib/macgyver-string-filter.js +++ b/lib/macgyver-string-filter.js @@ -1,5 +1,5 @@ /** - * MacGyver v0.5.1 + * MacGyver v0.6.0 * @link http://angular-macgyver.github.io/MacGyver * @license MIT */ diff --git a/lib/macgyver.css b/lib/macgyver.css index 39ed1d2..60a867b 100644 --- a/lib/macgyver.css +++ b/lib/macgyver.css @@ -1,7 +1,7 @@ -.mac-date-time.ng-invalid-date,.mac-date-time.ng-invalid-time{background:#ffe2e2;border:solid 1px #dea9a9}.close,.close-modal{width:18px;height:18px;-webkit-border-radius:9px;border-radius:9px;display:block;background:#bdc0c7;position:relative;opacity:1;-ms-filter:none;filter:none;}.close:after,.close-modal:after{content:'';display:block;width:2px;height:10px;background:#fff;position:absolute;top:4px;left:8px;-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);-o-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg)}.close:before,.close-modal:before{content:'';display:block;width:2px;height:10px;background:#fff;position:absolute;top:4px;left:8px;-webkit-transform:rotate(-45deg);-moz-transform:rotate(-45deg);-o-transform:rotate(-45deg);-ms-transform:rotate(-45deg);transform:rotate(-45deg)}.close:hover,.close-modal:hover{background:#828590}.hide{display:none}.affix{position:fixed;}.affix-bottom{position:absolute} -.mac-menu{position:absolute;top:0;left:0;min-width:200px;background:#fff;-webkit-box-shadow:0 3px 6px rgba(0,0,0,0.2);box-shadow:0 3px 6px rgba(0,0,0,0.2);border:1px solid #d1d3d8;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;max-height:325px;overflow-y:auto;opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);visibility:hidden;-webkit-transition:opacity 0.1s ease-out, visibility 0.1s ease-out;-moz-transition:opacity 0.1s ease-out, visibility 0.1s ease-out;-o-transition:opacity 0.1s ease-out, visibility 0.1s ease-out;-ms-transition:opacity 0.1s ease-out, visibility 0.1s ease-out;transition:opacity 0.1s ease-out, visibility 0.1s ease-out;}.mac-menu.visible{visibility:visible;opacity:1;-ms-filter:none;filter:none}.mac-menu ul{list-style:none;margin:0;padding-left:0;}.mac-menu ul .mac-menu-item{display:block;padding:5px 10px;-webkit-transition:background 0.1s ease-out;-moz-transition:background 0.1s ease-out;-o-transition:background 0.1s ease-out;-ms-transition:background 0.1s ease-out;transition:background 0.1s ease-out;color:#000;cursor:pointer;}.mac-menu ul .mac-menu-item.active{background:#e0e8fb;-webkit-transition:0;-moz-transition:0;-o-transition:0;-ms-transition:0;transition:0;text-decoration:none} -.mac-modal-overlay{background-color:rgba(245,246,250,0.75);position:fixed;top:0;left:0;right:0;bottom:0;opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);overflow-y:auto;z-index:3;}.mac-modal-overlay.visible,.mac-modal-overlay.visible-add-active{opacity:1;-ms-filter:none;filter:none;}.mac-modal-overlay.visible .mac-modal,.mac-modal-overlay.visible-add-active .mac-modal{top:50%}.mac-modal-overlay.visible-add,.mac-modal-overlay.visible-remove{-webkit-transition:0.2s ease-out all;-moz-transition:0.2s ease-out all;-o-transition:0.2s ease-out all;-ms-transition:0.2s ease-out all;transition:0.2s ease-out all}.mac-modal-overlay.visible-remove-active{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0)}.mac-modal-overlay .mac-modal{position:absolute;top:0;left:50%;width:500px;margin-left:-251px;background:#fff;border:1px solid #d1d3d8;-webkit-box-shadow:0 4px 10px rgba(0,0,0,0.15);box-shadow:0 4px 10px rgba(0,0,0,0.15);-webkit-transition:all 0.2s ease-out;-moz-transition:all 0.2s ease-out;-o-transition:all 0.2s ease-out;-ms-transition:all 0.2s ease-out;transition:all 0.2s ease-out;-webkit-border-radius:3px;border-radius:3px;-webkit-transform:rotateX(0) rotateY(0);-moz-transform:rotateX(0) rotateY(0);-o-transform:rotateX(0) rotateY(0);-ms-transform:rotateX(0) rotateY(0);transform:rotateX(0) rotateY(0);}.mac-modal-overlay .mac-modal:after{content:"";display:block;position:absolute;bottom:-20px;height:20px;width:1px}.mac-modal-overlay .mac-modal .mac-close-modal{position:absolute;top:-5px;right:-5px;width:18px;height:18px;-webkit-border-radius:9px;border-radius:9px;display:block;background:#bdc0c7;cursor:pointer;}.mac-modal-overlay .mac-modal .mac-close-modal:before,.mac-modal-overlay .mac-modal .mac-close-modal:after{content:'';display:block;width:2px;height:10px;background:#fff;position:absolute;top:4px;left:8px}.mac-modal-overlay .mac-modal .mac-close-modal:before{-webkit-transform:rotate(-45deg);-moz-transform:rotate(-45deg);-o-transform:rotate(-45deg);-ms-transform:rotate(-45deg);transform:rotate(-45deg)}.mac-modal-overlay .mac-modal .mac-close-modal:after{-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);-o-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg)}.mac-modal-overlay .mac-modal .mac-modal-content{padding:20px} -.mac-popover{position:absolute;top:0;left:0;background:#fff;-webkit-box-shadow:0 3px 6px rgba(0,0,0,0.2);box-shadow:0 3px 6px rgba(0,0,0,0.2);border:1px solid #d1d3d8;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transform:scale3d(0,0,0);-moz-transform:scale3d(0,0,0);-o-transform:scale3d(0,0,0);-ms-transform:scale3d(0,0,0);transform:scale3d(0,0,0);opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);-webkit-transform-origin:left top;-moz-transform-origin:left top;-o-transform-origin:left top;-ms-transform-origin:left top;transform-origin:left top;visibility:hidden;-webkit-border-radius:3px;border-radius:3px;z-index:2;}.mac-popover.fixed{position:fixed}.mac-popover.visible{opacity:1;-ms-filter:none;filter:none;visibility:visible;-webkit-transform:scale3d(1,1,1);-moz-transform:scale3d(1,1,1);-o-transform:scale3d(1,1,1);-ms-transform:scale3d(1,1,1);transform:scale3d(1,1,1);-webkit-transition:-webkit-transform 0.1s ease-out, opacity 0.1s ease-in, visibility 0.1s ease-out;-moz-transition:-moz-transform 0.1s ease-out, opacity 0.1s ease-in, visibility 0.1s ease-out;-o-transition:-o-transform 0.1s ease-out, opacity 0.1s ease-in, visibility 0.1s ease-out;-ms-transition:-ms-transform 0.1s ease-out, opacity 0.1s ease-in, visibility 0.1s ease-out;transition:transform 0.1s ease-out, opacity 0.1s ease-in, visibility 0.1s ease-out}.mac-popover.ng-leave{-webkit-transition:-webkit-transform 0.1s ease-out, opacity 0.1s ease-in, visibility 0.1s ease-out;-moz-transition:-moz-transform 0.1s ease-out, opacity 0.1s ease-in, visibility 0.1s ease-out;-o-transition:-o-transform 0.1s ease-out, opacity 0.1s ease-in, visibility 0.1s ease-out;-ms-transition:-ms-transform 0.1s ease-out, opacity 0.1s ease-in, visibility 0.1s ease-out;transition:transform 0.1s ease-out, opacity 0.1s ease-in, visibility 0.1s ease-out;}.mac-popover.ng-leave.ng-leave-active{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);-webkit-transform:scale3d(0,0,0);-moz-transform:scale3d(0,0,0);-o-transform:scale3d(0,0,0);-ms-transform:scale3d(0,0,0);transform:scale3d(0,0,0);visibility:hidden}.mac-popover .tip{display:block;width:0;height:0;border-bottom:9px solid #d1d3d8;border-left:9px solid rgba(255,255,255,0);border-right:9px solid rgba(255,255,255,0);position:absolute;top:-9px;left:15px;}.mac-popover .tip:after{content:'';display:block;width:0;height:0;border-bottom:8px solid #fff;border-left:8px solid rgba(255,255,255,0);border-right:8px solid rgba(255,255,255,0);position:absolute;top:1px;left:-8px}.mac-popover.above{-webkit-transform-origin:left bottom;-moz-transform-origin:left bottom;-o-transform-origin:left bottom;-ms-transform-origin:left bottom;transform-origin:left bottom;}.mac-popover.above .tip{top:auto;bottom:-9px;border-top:9px solid #d1d3d8;border-bottom:0;}.mac-popover.above .tip:after{top:auto;bottom:1px;border-top:8px solid #fff;border-bottom:0}.mac-popover.above.right{-webkit-transform-origin:right bottom;-moz-transform-origin:right bottom;-o-transform-origin:right bottom;-ms-transform-origin:right bottom;transform-origin:right bottom;}.mac-popover.above.right .tip{left:auto;right:15px}.mac-popover.below.right{-webkit-transform-origin:right top;-moz-transform-origin:right top;-o-transform-origin:right top;-ms-transform-origin:right top;transform-origin:right top;}.mac-popover.below.right .tip{left:auto;right:15px}.mac-popover.middle .tip{top:50%;margin-top:-9px;border-top:9px solid rgba(255,255,255,0);border-bottom:9px solid rgba(255,255,255,0);}.mac-popover.middle .tip:after{border-top:8px solid rgba(255,255,255,0);border-bottom:8px solid rgba(255,255,255,0);top:-8px}.mac-popover.middle.right{-webkit-transform-origin:left center;-moz-transform-origin:left center;-o-transform-origin:left center;-ms-transform-origin:left center;transform-origin:left center;}.mac-popover.middle.right .tip{border-left:0;border-right:9px solid #d1d3d8;left:-9px;}.mac-popover.middle.right .tip:after{border-left:0;border-right:8px solid #fff;left:1px}.mac-popover.middle.left{-webkit-transform-origin:right center;-moz-transform-origin:right center;-o-transform-origin:right center;-ms-transform-origin:right center;transform-origin:right center;}.mac-popover.middle.left .tip{border-right:0;border-left:9px solid #d1d3d8;right:-9px;left:auto;}.mac-popover.middle.left .tip:after{border-right:0;border-left:8px solid #fff;right:1px;left:auto}.mac-popover .popover-header{background:#eaecf1;display:none;}.mac-popover .popover-header .title{font-size:13px;font-weight:bold;line-height:33px;padding-left:10px;padding-top:1px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;white-space:nowrap;overflow:hidden;-o-text-overflow:ellipsis;text-overflow:ellipsis;margin-right:40px}.mac-popover .popover-header .close{float:right;margin:7px 10px 0 0;display:none}.mac-popover .popover-content{max-height:415px;overflow-y:auto;overflow-x:hidden;position:relative}.mac-popover .popover-footer{display:none}.mac-popover.footer{padding-bottom:42px;}.mac-popover.footer .popover-footer{display:block;position:absolute;bottom:0;left:0;right:0;padding:10px;-webkit-box-shadow:0 -1px 5px rgba(0,0,0,0.15);box-shadow:0 -1px 5px rgba(0,0,0,0.15)}.mac-popover.header .popover-header{display:block}.mac-popover.header.below .tip:after{border-bottom:8px solid #eaecf1}.mac-popover.header.middle.left .tip:after{border-left:8px solid #eaecf1}.mac-popover.header.middle.right .tip:after{border-right:8px solid #eaecf1} -.mac-spinner,.mac-cspinner{display:inline-block;position:relative;}.mac-spinner.block,.mac-cspinner.block{display:block;margin:0 auto}@-moz-keyframes fade{0%{opacity:1;-ms-filter:none;filter:none}100%{opacity:.02;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=2)";filter:alpha(opacity=2)}}@-webkit-keyframes fade{0%{opacity:1;-ms-filter:none;filter:none}100%{opacity:.02;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=2)";filter:alpha(opacity=2)}}@-o-keyframes fade{0%{opacity:1;-ms-filter:none;filter:none}100%{opacity:.02;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=2)";filter:alpha(opacity=2)}}@keyframes fade{0%{opacity:1;-ms-filter:none;filter:none}100%{opacity:.02;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=2)";filter:alpha(opacity=2)}} -.mac-tag-autocomplete{position:relative;display:inline-block;border:1px solid #aaa;background:#fff;margin:0;padding:0;}.mac-tag-autocomplete .mac-tag-list{margin:0;padding-left:0;}.mac-tag-autocomplete .mac-tag-list .mac-tag{padding:3px 20px 3px 5px;margin:3px;position:relative;display:inline-block;list-style:none;font-size:13px;line-height:13px;-webkit-border-radius:3px;border-radius:3px;}.mac-tag-autocomplete .mac-tag-list .mac-tag.mac-label{background:-webkit-linear-gradient(top, #eaf0ff, #dee8ff);background:-moz-linear-gradient(top, #eaf0ff, #dee8ff);background:-o-linear-gradient(top, #eaf0ff, #dee8ff);background:-ms-linear-gradient(top, #eaf0ff, #dee8ff);background:linear-gradient(to bottom, #eaf0ff, #dee8ff);border:1px solid #bfc9e1;text-shadow:none;color:#000;font-weight:normal;-webkit-box-shadow:0 0 2px #fff inset,0 1px 0 rgba(0,0,0,0.05);box-shadow:0 0 2px #fff inset,0 1px 0 rgba(0,0,0,0.05)}.mac-tag-autocomplete .mac-tag-list .mac-tag .mac-tag-close{position:absolute;right:6px;color:#9da6b7;cursor:pointer}.mac-tag-autocomplete .mac-tag-list .mac-tag.mac-input-tag{white-space:nowrap;padding:0;}.mac-tag-autocomplete .mac-tag-list .mac-tag.mac-input-tag .text-input{color:#666;background:transparent;padding:5px;margin:0;border:none !important;-webkit-box-shadow:none;box-shadow:none}.mac-tag-autocomplete .mac-tag-list .mac-tag.mac-input-tag.fullwidth{width:100%;}.mac-tag-autocomplete .mac-tag-list .mac-tag.mac-input-tag.fullwidth .text-input{width:90%} -.mac-tooltip{background:rgba(47,48,53,0.75);text-align:center;color:#fff;padding:5px 7px;position:absolute;top:100px;left:100px;font-size:12px;opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);visibility:hidden;-webkit-transition:opacity 0.1s ease-out, visibility 0.1s ease-out, margin 0.1s ease-out;-moz-transition:opacity 0.1s ease-out, visibility 0.1s ease-out, margin 0.1s ease-out;-o-transition:opacity 0.1s ease-out, visibility 0.1s ease-out, margin 0.1s ease-out;-ms-transition:opacity 0.1s ease-out, visibility 0.1s ease-out, margin 0.1s ease-out;transition:opacity 0.1s ease-out, visibility 0.1s ease-out, margin 0.1s ease-out;margin-top:5px;-webkit-border-radius:3px;border-radius:3px;z-index:7;}.mac-tooltip.visible{visibility:visible;opacity:1;-ms-filter:none;filter:none;margin-top:0}.mac-tooltip:after{content:'';display:block;width:0;height:0;position:absolute}.mac-tooltip.top:after{border-top:6px solid rgba(47,48,53,0.75);border-left:6px solid transparent;border-right:6px solid transparent;bottom:-6px;left:50%;margin-left:-6px}.mac-tooltip.bottom:after{border-bottom:6px solid rgba(47,48,53,0.75);border-left:6px solid transparent;border-right:6px solid transparent;top:-6px;left:50%;margin-left:-6px}.mac-tooltip.left:after{border-left:6px solid rgba(47,48,53,0.75);border-top:6px solid transparent;border-bottom:6px solid transparent;right:-6px;top:50%;margin-top:-6px}.mac-tooltip.right:after{border-right:6px solid rgba(47,48,53,0.75);border-top:6px solid transparent;border-bottom:6px solid transparent;left:-6px;top:50%;margin-top:-6px} \ No newline at end of file +.mac-date-time.ng-invalid-date,.mac-date-time.ng-invalid-time{background:#ffe2e2;border:solid 1px #dea9a9}.close,.close-modal{width:18px;height:18px;border-radius:9px;display:block;background:#bdc0c7;position:relative;opacity:1;}.close:after,.close-modal:after{content:'';display:block;width:2px;height:10px;background:#fff;position:absolute;top:4px;left:8px;transform:rotate(45deg)}.close:before,.close-modal:before{content:'';display:block;width:2px;height:10px;background:#fff;position:absolute;top:4px;left:8px;transform:rotate(-45deg)}.close:hover,.close-modal:hover{background:#828590}.hide{display:none}.affix{position:fixed;}.affix-bottom{position:absolute} +.mac-menu{position:absolute;top:0;left:0;min-width:200px;background:#fff;box-shadow:0 3px 6px rgba(0,0,0,0.2);border:1px solid #d1d3d8;box-sizing:border-box;max-height:325px;overflow-y:auto;opacity:0;visibility:hidden;transition:opacity .1s ease-out,visibility .1s ease-out;z-index:4;}.mac-menu.visible{visibility:visible;opacity:1}.mac-menu ul{list-style:none;margin:0;padding-left:0;}.mac-menu ul .mac-menu-item{display:block;padding:5px 10px;transition:background .1s ease-out;color:#000;cursor:pointer;}.mac-menu ul .mac-menu-item.active{background:#e0e8fb;transition:0;text-decoration:none} +.mac-modal-overlay{background-color:rgba(245,246,250,0.75);position:fixed;top:0;left:0;right:0;bottom:0;opacity:0;display:none;overflow-y:auto;z-index:3;}.mac-modal-overlay.ng-animate{display:block;transition:.2s ease-out all}.mac-modal-overlay.visible{opacity:1;display:block;}.mac-modal-overlay.visible .mac-modal{top:50%}.mac-modal{position:absolute;top:0;left:50%;width:500px;margin-left:-251px;background:#fff;border:1px solid #d1d3d8;box-shadow:0 4px 10px rgba(0,0,0,0.15);transition:top .2s ease-out;border-radius:3px;transform:rotateX(0) rotateY(0);}.mac-modal:after{content:"";display:block;position:absolute;bottom:-20px;height:20px;width:1px}.mac-close-modal{position:absolute;top:-5px;right:-5px;width:18px;height:18px;border-radius:9px;display:block;background:#bdc0c7;cursor:pointer;}.mac-close-modal:before,.mac-close-modal:after{content:'';display:block;width:2px;height:10px;background:#fff;position:absolute;top:4px;left:8px}.mac-close-modal:before{transform:rotate(-45deg)}.mac-close-modal:after{transform:rotate(45deg)}.mac-modal-content{padding:20px} +.mac-popover{position:absolute;top:0;left:0;background:#fff;box-shadow:0 3px 6px rgba(0,0,0,0.2);border:1px solid #d1d3d8;box-sizing:border-box;transform:scale3d(0,0,0);opacity:0;transform-origin:left top;visibility:hidden;border-radius:3px;z-index:2;}.mac-popover.fixed{position:fixed}.mac-popover.visible{opacity:1;visibility:visible;transform:scale3d(1,1,1);transition:transform .1s ease-out,opacity .1s ease-in,visibility .1s ease-out}.mac-popover.ng-leave-active{opacity:0;transform:scale3d(0,0,0);visibility:hidden}.mac-popover .tip{display:block;width:0;height:0;border-bottom:9px solid #d1d3d8;border-left:9px solid rgba(255,255,255,0);border-right:9px solid rgba(255,255,255,0);position:absolute;top:-9px;left:15px;}.mac-popover .tip:after{content:'';display:block;width:0;height:0;border-bottom:8px solid #fff;border-left:8px solid rgba(255,255,255,0);border-right:8px solid rgba(255,255,255,0);position:absolute;top:1px;left:-8px}.mac-popover.above{transform-origin:left bottom;}.mac-popover.above .tip{top:auto;bottom:-9px;border-top:9px solid #d1d3d8;border-bottom:0;}.mac-popover.above .tip:after{top:auto;bottom:1px;border-top:8px solid #fff;border-bottom:0}.mac-popover.above.right{transform-origin:right bottom;}.mac-popover.above.right .tip{left:auto;right:15px}.mac-popover.below.right{transform-origin:right top;}.mac-popover.below.right .tip{left:auto;right:15px}.mac-popover.middle .tip{top:50%;margin-top:-9px;border-top:9px solid rgba(255,255,255,0);border-bottom:9px solid rgba(255,255,255,0);}.mac-popover.middle .tip:after{border-top:8px solid rgba(255,255,255,0);border-bottom:8px solid rgba(255,255,255,0);top:-8px}.mac-popover.middle.right{transform-origin:left center;}.mac-popover.middle.right .tip{border-left:0;border-right:9px solid #d1d3d8;left:-9px;}.mac-popover.middle.right .tip:after{border-left:0;border-right:8px solid #fff;left:1px}.mac-popover.middle.left{transform-origin:right center;}.mac-popover.middle.left .tip{border-right:0;border-left:9px solid #d1d3d8;right:-9px;left:auto;}.mac-popover.middle.left .tip:after{border-right:0;border-left:8px solid #fff;right:1px;left:auto}.mac-popover .popover-header{background:#eaecf1;display:none;}.mac-popover .popover-header .title{font-size:13px;font-weight:bold;line-height:33px;padding-left:10px;padding-top:1px;user-select:none;overflow:ellipsis;margin-right:40px}.mac-popover .popover-header .close{float:right;margin:7px 10px 0 0;display:none}.mac-popover .popover-content{max-height:415px;overflow-y:auto;overflow-x:hidden;position:relative}.mac-popover .popover-footer{display:none}.mac-popover.footer{padding-bottom:42px;}.mac-popover.footer .popover-footer{display:block;position:absolute;bottom:0;left:0;right:0;padding:10px;box-shadow:0 -1px 5px rgba(0,0,0,0.15)}.mac-popover.header .popover-header{display:block}.mac-popover.header.below .tip:after{border-bottom:8px solid #eaecf1}.mac-popover.header.middle.left .tip:after{border-left:8px solid #eaecf1}.mac-popover.header.middle.right .tip:after{border-right:8px solid #eaecf1} +.mac-spinner,.mac-cspinner{display:inline-block;position:relative;}.mac-spinner.block,.mac-cspinner.block{display:block;margin:0 auto}@-moz-keyframes fade{0%{opacity:1}100%{opacity:.02}}@-webkit-keyframes fade{0%{opacity:1}100%{opacity:.02}}@-o-keyframes fade{0%{opacity:1}100%{opacity:.02}}@keyframes fade{0%{opacity:1}100%{opacity:.02}} +.mac-tag-autocomplete{position:relative;display:inline-block;border:1px solid #aaa;background:#fff;margin:0;padding:0;}.mac-tag-autocomplete .mac-tag-list{margin:0;padding-left:0;}.mac-tag-autocomplete .mac-tag-list .mac-tag{padding:3px 20px 3px 5px;margin:3px;position:relative;display:inline-block;list-style:none;font-size:13px;line-height:13px;border-radius:3px;}.mac-tag-autocomplete .mac-tag-list .mac-tag.mac-label{background:linear-gradient(top,#eaf0ff,#dee8ff);border:1px solid #bfc9e1;text-shadow:none;color:#000;font-weight:normal;box-shadow:0 0 2px #fff inset,0 1px 0 rgba(0,0,0,0.05)}.mac-tag-autocomplete .mac-tag-list .mac-tag .mac-tag-close{position:absolute;right:6px;color:#9da6b7;cursor:pointer}.mac-tag-autocomplete .mac-tag-list .mac-tag.mac-input-tag{white-space:nowrap;padding:0;}.mac-tag-autocomplete .mac-tag-list .mac-tag.mac-input-tag .text-input{color:#666;background:transparent;padding:5px;margin:0;border:none !important;box-shadow:none}.mac-tag-autocomplete .mac-tag-list .mac-tag.mac-input-tag.fullwidth{width:100%;}.mac-tag-autocomplete .mac-tag-list .mac-tag.mac-input-tag.fullwidth .text-input{width:90%} +.mac-tooltip{background:rgba(47,48,53,0.75);text-align:center;color:#fff;padding:5px 7px;position:absolute;top:100px;left:100px;font-size:12px;opacity:0;visibility:hidden;transition:opacity .1s ease-out,visibility .1s ease-out,margin .1s ease-out;margin-top:5px;border-radius:3px;z-index:7;}.mac-tooltip.visible{visibility:visible;opacity:1;margin-top:0}.mac-tooltip:after{content:'';display:block;width:0;height:0;position:absolute}.mac-tooltip.top:after{border-top:6px solid rgba(47,48,53,0.75);border-left:6px solid transparent;border-right:6px solid transparent;bottom:-6px;left:50%;margin-left:-6px}.mac-tooltip.bottom:after{border-bottom:6px solid rgba(47,48,53,0.75);border-left:6px solid transparent;border-right:6px solid transparent;top:-6px;left:50%;margin-left:-6px}.mac-tooltip.left:after{border-left:6px solid rgba(47,48,53,0.75);border-top:6px solid transparent;border-bottom:6px solid transparent;right:-6px;top:50%;margin-top:-6px}.mac-tooltip.right:after{border-right:6px solid rgba(47,48,53,0.75);border-top:6px solid transparent;border-bottom:6px solid transparent;left:-6px;top:50%;margin-top:-6px} \ No newline at end of file diff --git a/lib/macgyver.js b/lib/macgyver.js index 5271652..9e73ffc 100644 --- a/lib/macgyver.js +++ b/lib/macgyver.js @@ -1,5 +1,5 @@ /** - * MacGyver v0.5.1 + * MacGyver v0.6.0 * @link http://angular-macgyver.github.io/MacGyver * @license MIT */ @@ -503,8 +503,9 @@ angular.module("Mac").directive("macAutocomplete", [ @description Adding menu to DOM @param {Function} callback Callback after enter animation completes + @returns {Promise} Animation promise */ - appendMenu = function(callback) { + appendMenu = function() { if (!isMenuAppended) { element.bind("blur", blurHandler); menuEl.on('mousedown', function(event) { @@ -513,9 +514,9 @@ angular.module("Mac").directive("macAutocomplete", [ } isMenuAppended = true; if (inside) { - return $animate.enter(menuEl, void 0, element, callback); + return $animate.enter(menuEl, void 0, element); } else { - return $animate.enter(menuEl, angular.element(document.body), void 0, callback); + return $animate.enter(menuEl, angular.element(document.body)); } }; @@ -524,9 +525,10 @@ angular.module("Mac").directive("macAutocomplete", [ @name reset @description Resetting autocomplete + @returns {Promise} Leave animation promise */ reset = function() { - $animate.leave(menuEl, function() { + return $animate.leave(menuEl).then(function() { $menuScope.index = 0; $menuScope.items.length = 0; menuEl[0].style.top = ""; @@ -584,7 +586,7 @@ angular.module("Mac").directive("macAutocomplete", [ }; } }); - return appendMenu(positionMenu); + return appendMenu().then(positionMenu); } else { return reset(); } @@ -1240,7 +1242,7 @@ modal template @param {Boolean} mac-modal-position Calculate size and position with JS (default true) */ angular.module("Mac").directive("macModal", [ - "$parse", "modal", "modalViews", "util", function($parse, modal, modalViews, util) { + "$parse", "modal", "util", function($parse, modal, util) { return { restrict: "E", template: modal.modalTemplate, @@ -1251,7 +1253,7 @@ angular.module("Mac").directive("macModal", [ transclude($scope, function(clone) { return angular.element(element[0].getElementsByClassName("mac-modal-content-wrapper")).replaceWith(clone); }); - opts = util.extendAttributes("macModal", modalViews.defaults, attrs); + opts = util.extendAttributes("macModal", modal.defaults, attrs); regId = null; if (opts.overlayClose) { element.on("click", function($event) { @@ -1368,12 +1370,12 @@ popover will be closed automatically var __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; angular.module("Mac").directive("macPopover", [ - "$timeout", "popover", "util", "popoverViews", function($timeout, popover, util, popoverViews) { + "$timeout", "popover", "util", function($timeout, popover, util) { return { restrict: "A", link: function(scope, element, attrs) { var clearDelays, closeDelayId, delayId, exclude, excludeList, hide, options, show; - options = util.extendAttributes("macPopover", popoverViews.defaults, attrs); + options = util.extendAttributes("macPopover", popover.defaults, attrs); exclude = attrs.macPopoverExclude || ""; excludeList = exclude ? exclude.split(",") : []; delayId = null; @@ -1438,7 +1440,7 @@ angular.module("Mac").directive("macPopover", [ }; } ]).directive("macPopover", [ - "popover", "popoverViews", "util", function(popover, popoverViews, util) { + "popover", "util", function(popover, util) { return { restrict: "E", compile: function(element, attrs) { @@ -1446,7 +1448,7 @@ angular.module("Mac").directive("macPopover", [ if (!attrs.id) { throw Error("macPopover: Missing id"); } - opts = util.extendAttributes("macPopover", popoverViews.popoverDefaults, attrs); + opts = util.extendAttributes("macPopover", popover.popoverDefaults, attrs); angular.extend(opts, { template: element.html() }); @@ -2534,6 +2536,36 @@ angular.module("Mac").filter("underscoreString", function() { /* @chalk overview +@name Modal + */ + +/* +@chalk provider +@name Modal Provider + +@description +Configure modal options in config block + +@param {Object} defaults Modal default +```js +{ + keyboard: false, + overlayClose: false, + resize: true, + position: true, + open: angular.noop, + topOffset: 20, + attributes: {}, + beforeShow: angular.noop, + afterShow: angular.noop, + beforeHide: angular.noop, + afterHide: angular.noop +} +``` + */ + +/* +@chalk service @name Modal Service @description @@ -2566,30 +2598,59 @@ There are multiple components used by modal. @param {Function} clearWaiting Remove certain modal id from waiting list - {String} id ID of the modal */ -angular.module("Mac").service("modal", [ - "$rootScope", "$animate", "$templateCache", "$compile", "$http", "$controller", "modalViews", "keys", function($rootScope, $animate, $templateCache, $compile, $http, $controller, modalViews, keys) { - return { - registered: modalViews.registered, - waiting: null, - opened: null, - modalTemplate: "
\n
\n \n
\n
\n
", - show: function(id, triggerOptions) { - var modalObject, options, path, renderModal, showModal, showOptions, template; - if (triggerOptions == null) { - triggerOptions = {}; +angular.module("Mac").provider("modal", function() { + var defaults, registered; + this.registered = registered = {}; + this.defaults = defaults = { + keyboard: false, + overlayClose: false, + resize: true, + position: true, + open: angular.noop, + topOffset: 20, + attributes: {}, + beforeShow: angular.noop, + afterShow: angular.noop, + beforeHide: angular.noop, + afterHide: angular.noop + }; + this.$get = [ + "$animate", "$compile", "$controller", "$document", "$http", "$rootScope", "$templateCache", "keys", function($animate, $compile, $controller, $document, $http, $rootScope, $templateCache, keys) { + var escapeKeyHandler, resizeHandler, service; + escapeKeyHandler = function(event) { + var scope; + if (event.keyCode === keys.ESCAPE && service.opened) { + scope = service.opened.element.scope(); + return scope.$apply(function() { + return service.hide(); + }); } - if ((this.registered[id] != null) && (this.opened != null)) { - return this.hide(); - } else if (this.registered[id] != null) { - modalObject = this.registered[id]; - options = modalObject.options; - showOptions = {}; - angular.extend(showOptions, options, triggerOptions); - showModal = (function(_this) { - return function(element) { - showOptions.beforeShow(element.scope()); - return $animate.removeClass(element, "hide", function() { - return $animate.addClass(element, "visible", function() { + }; + resizeHandler = function() { + return service.resize(); + }; + service = { + registered: registered, + defaults: defaults, + waiting: null, + opened: null, + modalTemplate: "
\n
\n \n
\n
\n
", + show: function(id, triggerOptions) { + var modalObject, options, path, renderModal, showModal, showOptions, template; + if (triggerOptions == null) { + triggerOptions = {}; + } + if ((this.registered[id] != null) && (this.opened != null)) { + return this.hide(); + } else if (this.registered[id] != null) { + modalObject = this.registered[id]; + options = modalObject.options; + showOptions = {}; + angular.extend(showOptions, options, triggerOptions); + showModal = (function(_this) { + return function(element) { + showOptions.beforeShow(element.scope()); + return $animate.addClass(element, "visible").then(function() { _this.opened = { id: id, element: element, @@ -2602,220 +2663,190 @@ angular.module("Mac").service("modal", [ $rootScope.$broadcast("modalWasShown", id); return _this.clearWaiting(); }); - }); - }; - })(this); - if (showOptions.moduleMethod != null) { - renderModal = (function(_this) { - return function(template) { - var element, viewScope, wrapper; - if (isScope(showOptions.scope)) { - viewScope = showOptions.scope; - } else { - viewScope = $rootScope.$new(true); - if (angular.isObject(showOptions.scope)) { - angular.extend(viewScope, showOptions.scope); - } - } - angular.extend(showOptions.attributes, { - id: id - }); - element = angular.element(_this.modalTemplate).attr(showOptions.attributes); - wrapper = angular.element(element[0].getElementsByClassName("mac-modal-content-wrapper")); - wrapper.html(template); - if (showOptions.overlayClose) { - element.bind("click", function($event) { - if (angular.element($event.target).hasClass("mac-modal-overlay")) { - return viewScope.$apply(function() { - return _this.hide(); - }); + }; + })(this); + if (showOptions.moduleMethod != null) { + renderModal = (function(_this) { + return function(template) { + var element, viewScope, wrapper; + if (isScope(showOptions.scope)) { + viewScope = showOptions.scope; + } else { + viewScope = $rootScope.$new(true); + if (angular.isObject(showOptions.scope)) { + angular.extend(viewScope, showOptions.scope); } + } + angular.extend(showOptions.attributes, { + id: id }); - } - if (showOptions.controller) { - $controller(showOptions.controller, { - $scope: viewScope, - $element: element, - macModalOptions: showOptions + element = angular.element(_this.modalTemplate).attr(showOptions.attributes); + wrapper = angular.element(element[0].getElementsByClassName("mac-modal-content-wrapper")); + wrapper.html(template); + if (showOptions.overlayClose) { + element.bind("click", function($event) { + if (angular.element($event.target).hasClass("mac-modal-overlay")) { + return viewScope.$apply(function() { + return _this.hide(); + }); + } + }); + } + if (showOptions.controller) { + $controller(showOptions.controller, { + $scope: viewScope, + $element: element, + macModalOptions: showOptions + }); + } + $animate.enter(element, angular.element(document.body)); + $compile(element)(viewScope); + return showModal(element); + }; + })(this); + if ((path = showOptions.templateUrl)) { + template = $templateCache.get(path); + if (template) { + return renderModal(template); + } else { + return $http.get(path).then(function(resp) { + $templateCache.put(path, resp.data); + return renderModal(resp.data); + }, function() { + throw Error("Failed to load template: " + path); }); } - $animate.enter(element, angular.element(document.body)); - $compile(element)(viewScope); - return showModal(element); - }; - })(this); - if ((path = showOptions.templateUrl)) { - template = $templateCache.get(path); - if (template) { + } else if ((template = showOptions.template)) { return renderModal(template); - } else { - return $http.get(path).then(function(resp) { - $templateCache.put(path, resp.data); - return renderModal(resp.data); - }, function() { - throw Error("Failed to load template: " + path); - }); } - } else if ((template = showOptions.template)) { - return renderModal(template); + } else if (modalObject.element != null) { + return showModal(modalObject.element); } - } else if (modalObject.element != null) { - return showModal(modalObject.element); + } else { + return this.waiting = { + id: id, + options: triggerOptions + }; } - } else { - return this.waiting = { - id: id, - options: triggerOptions + }, + resize: function(modalObject) { + var css, element, height, modal, options, width; + if (modalObject == null) { + modalObject = this.opened; + } + if (modalObject == null) { + return; + } + element = modalObject.element; + options = modalObject.options; + if (!options.position) { + return; + } + modal = angular.element(element[0].querySelector(".mac-modal")); + height = modal.outerHeight(); + width = modal.outerWidth(); + css = angular.element(window).height() > height ? { + marginTop: -height / 2 + } : { + top: options.topOffset }; - } - }, - resize: function(modalObject) { - var css, element, height, modal, options, width; - if (modalObject == null) { - modalObject = this.opened; - } - if (modalObject == null) { - return; - } - element = modalObject.element; - options = modalObject.options; - if (!options.position) { - return; - } - modal = angular.element(element[0].getElementsByClassName("mac-modal")).attr("style", ""); - height = modal.outerHeight(); - width = modal.outerWidth(); - css = angular.element(window).height() > height ? { - marginTop: -height / 2 - } : { - top: options.topOffset - }; - css.marginLeft = -width / 2; - return angular.forEach(css, function(value, key) { - if (!isNaN(+value) && angular.isNumber(+value)) { - value = "" + value + "px"; + css.marginLeft = -width / 2; + return angular.forEach(css, function(value, key) { + if (!isNaN(+value) && angular.isNumber(+value)) { + value = "" + value + "px"; + } + return modal.css(key, value); + }); + }, + hide: function() { + var element, id, options, self, _ref; + if (this.opened == null) { + return; } - return modal.css(key, value); - }); - }, - hide: function(callback) { - var element, id, options, _ref; - if (this.opened == null) { - return; - } - _ref = this.opened, id = _ref.id, options = _ref.options, element = _ref.element; - options.beforeHide(element.scope()); - return $animate.removeClass(element, "visible", (function(_this) { - return function() { - _this.bindingEvents("unbind"); - _this.opened = null; + _ref = this.opened, id = _ref.id, options = _ref.options, element = _ref.element; + options.beforeHide(element.scope()); + self = this; + return $animate.removeClass(element, "visible").then(function() { + var modal; + self.bindingEvents("unbind"); + self.opened = null; if (options.moduleMethod) { if (!isScope(options.scope)) { element.scope().$destroy(); } $animate.leave(element); } else { - $animate.addClass(element, "hide"); + modal = element[0].querySelector(".mac-modal"); + modal.removeAttribute("style"); } options.afterHide(element.scope()); - $rootScope.$broadcast("modalWasHidden", id); - return callback && callback(); - }; - })(this)); - }, - bindingEvents: function(action) { - var escapeKeyHandler, options, resizeHandler; - if (action == null) { - action = "bind"; - } - if (!((action === "bind" || action === "unbind") && (this.opened != null))) { - return; - } - escapeKeyHandler = (function(_this) { - return function(event) { - if (event.which === keys.ESCAPE) { - return _this.hide(); - } - }; - })(this); - resizeHandler = (function(_this) { - return function(event) { - return _this.resize(); + return $rootScope.$broadcast("modalWasHidden", id); + }); + }, + bindingEvents: function(action) { + var options; + if (action == null) { + action = "bind"; + } + if (!((action === "bind" || action === "unbind") && (this.opened != null))) { + return; + } + options = this.opened.options; + if (options.keyboard) { + $document[action]("keydown", escapeKeyHandler); + } + if (options.resize) { + return angular.element(window)[action]("resize", resizeHandler); + } + }, + register: function(id, element, options) { + var modalOpts; + if (this.registered[id] != null) { + throw new Error("Modal " + id + " already registered"); + } + modalOpts = {}; + angular.extend(modalOpts, defaults, options); + this.registered[id] = { + id: id, + element: element, + options: modalOpts }; - })(this); - options = this.opened.options; - if (options.keyboard) { - angular.element(document)[action]("keydown", escapeKeyHandler); - } - if (options.resize) { - return angular.element(window)[action]("resize", resizeHandler); - } - }, - register: function(id, element, options) { - var modalOpts; - if (this.registered[id] != null) { - throw new Error("Modal " + id + " already registered"); - } - modalOpts = {}; - angular.extend(modalOpts, modalViews.defaults, options); - this.registered[id] = { - id: id, - element: element, - options: modalOpts - }; - if ((this.waiting != null) && this.waiting.id === id) { - return this.show(id, this.waiting.options); - } - }, - unregister: function(id) { - var _ref; - if (this.registered[id] == null) { - throw new Error("Modal " + id + " is not registered"); - } - if (((_ref = this.opened) != null ? _ref.id : void 0) === id) { - this.hide(); - } - this.clearWaiting(id); - return delete this.registered[id]; - }, - clearWaiting: function(id) { - var _ref; - if ((id != null) && ((_ref = this.waiting) != null ? _ref.id : void 0) !== id) { - return; + if ((this.waiting != null) && this.waiting.id === id) { + return this.show(id, this.waiting.options); + } + }, + unregister: function(id) { + var _ref; + if (this.registered[id] == null) { + throw new Error("Modal " + id + " is not registered"); + } + if (((_ref = this.opened) != null ? _ref.id : void 0) === id) { + this.hide(); + } + this.clearWaiting(id); + return delete this.registered[id]; + }, + clearWaiting: function(id) { + var _ref; + if ((id != null) && ((_ref = this.waiting) != null ? _ref.id : void 0) !== id) { + return; + } + return this.waiting = null; } - return this.waiting = null; - } - }; - } -]).provider("modalViews", function() { - this.registered = {}; - this.defaults = { - keyboard: false, - overlayClose: false, - resize: true, - position: true, - open: angular.noop, - topOffset: 20, - attributes: {}, - beforeShow: angular.noop, - afterShow: angular.noop, - beforeHide: angular.noop, - afterHide: angular.noop - }; - this.$get = function() { - return this; - }; - return this; + }; + return service; + } + ]; }).config([ - "modalViewsProvider", function(modalViews) { + "modalProvider", function(modal) { return angular.module("Mac").modal = function(id, modalOptions) { var options; - if (modalViews.registered[id] == null) { + if (modal.registered[id] == null) { options = {}; - angular.extend(options, modalViews.defaults, modalOptions, { + angular.extend(options, modal.defaults, modalOptions, { moduleMethod: true }); - return modalViews.registered[id] = { + return modal.registered[id] = { id: id, options: options }; @@ -2827,10 +2858,55 @@ angular.module("Mac").service("modal", [ /* @chalk overview +@name Popover + */ + +/* +@chalk provider +@name Popover Provider + +@description +Configurate popover options in config block. + +@param {Object} defaults Popover defaults +```js +{ + fixed: false, + childPopover: false, + offsetY: 0, + offsetX: 0, + trigger: "click" +} +``` + +@param {Object} popoverDefaults Popover trigger defaults +```js +{ + footer: false, + header: false, + title: "", + direction: "above left" +} +``` + +@param {String} template Popover template +```js +"
+
+
+
{{macPopoverTitle}}
+
+
+
"; +``` + */ + +/* +@chalk service @name Popover Service @description -A popover service to keep state of opened popover. Allowing user to hide certain +Popover service to keep state of opened popover. Allowing user to hide certain or all popovers @param {Array} popoverList The popover that's currently being shown @@ -2882,16 +2958,17 @@ last opened popover is hidden @param {Function} hideAll Hide all popovers */ -angular.module("Mac").provider("popoverViews", function() { - this.registered = {}; - this.defaults = { +angular.module("Mac").provider("popover", function() { + var defaults, popoverDefaults, popoverTemplate, registered; + this.registered = registered = {}; + this.defaults = defaults = { fixed: false, childPopover: false, offsetY: 0, offsetX: 0, trigger: "click" }; - this.popoverDefaults = { + this.popoverDefaults = popoverDefaults = { footer: false, header: false, title: "", @@ -2903,311 +2980,311 @@ angular.module("Mac").provider("popoverViews", function() { @description Popover template */ - this.template = "
\n
\n
\n
{{macPopoverTitle}}
\n
\n
\n
"; - this.$get = function() { - return this; - }; - return this; -}).service("popover", [ - "$animate", "$compile", "$controller", "$http", "$rootScope", "$templateCache", "$timeout", "popoverViews", function($animate, $compile, $controller, $http, $rootScope, $templateCache, $timeout, popoverViews) { - var service; - service = { - popoverList: [], - registered: popoverViews.registered, - last: function() { - return this.popoverList[this.popoverList.length - 1]; - }, - register: function(id, options) { - var exist; - if (!(exist = this.registered[id] != null)) { - this.registered[id] = options; - } - return !exist; - }, - unregister: function(id) { - var exist; - if (exist = this.registered[id] != null) { - delete this.registered[id]; - } - return exist; - }, - add: function(id, popover, element, options) { - var newObject; - newObject = { - id: id, - popover: popover, - element: element, - options: options - }; - this.popoverList.push(newObject); - return newObject; - }, - pop: function() { - return this.popoverList.pop(); - }, - show: function(id, element, options) { - var addPopover, popoverOptions; - if (options == null) { - options = {}; - } - popoverOptions = this.registered[id]; - if (!popoverOptions) { - return false; - } - addPopover = function() { - var path, showPopover, template; - showPopover = function(template) { - var popover, popoverObj, viewScope; - if (isScope(options.scope)) { - viewScope = options.scope.$new(); - } else { - viewScope = $rootScope.$new(true); - if (angular.isObject(options.scope)) { - angular.extend(viewScope, options.scope); + this.template = popoverTemplate = "
\n
\n
\n
{{macPopoverTitle}}
\n
\n
\n
"; + this.$get = [ + "$animate", "$compile", "$controller", "$http", "$rootScope", "$templateCache", "$timeout", function($animate, $compile, $controller, $http, $rootScope, $templateCache, $timeout) { + var service; + service = { + popoverList: [], + registered: registered, + defaults: defaults, + popoverDefaults: popoverDefaults, + template: popoverTemplate, + last: function() { + return this.popoverList[this.popoverList.length - 1]; + }, + register: function(id, options) { + var exist; + if (!(exist = this.registered[id] != null)) { + this.registered[id] = options; + } + return !exist; + }, + unregister: function(id) { + var exist; + if (exist = this.registered[id] != null) { + delete this.registered[id]; + } + return exist; + }, + add: function(id, popover, element, options) { + var newObject; + newObject = { + id: id, + popover: popover, + element: element, + options: options + }; + this.popoverList.push(newObject); + return newObject; + }, + pop: function() { + return this.popoverList.pop(); + }, + show: function(id, element, options) { + var addPopover, popoverOptions; + if (options == null) { + options = {}; + } + popoverOptions = this.registered[id]; + if (!popoverOptions) { + return false; + } + addPopover = function() { + var path, showPopover, template; + showPopover = function(template) { + var popover, popoverObj, viewScope; + if (isScope(options.scope)) { + viewScope = options.scope.$new(); + } else { + viewScope = $rootScope.$new(true); + if (angular.isObject(options.scope)) { + angular.extend(viewScope, options.scope); + } } - } - if (popoverOptions.refreshOn) { - viewScope.$on(popoverOptions.refreshOn, function() { - return service.resize(id); + if (popoverOptions.refreshOn) { + viewScope.$on(popoverOptions.refreshOn, function() { + return service.resize(id); + }); + } + if (popoverOptions.controller) { + $controller(popoverOptions.controller, { + $scope: viewScope + }); + } + angular.extend(viewScope, { + macPopoverClasses: { + footer: popoverOptions.footer || false, + header: popoverOptions.header || !!popoverOptions.title || false, + fixed: popoverOptions.fixed || false + }, + macPopoverTitle: popoverOptions.title || "", + macPopoverTemplate: template }); - } - if (popoverOptions.controller) { - $controller(popoverOptions.controller, { - $scope: viewScope + popover = $compile(popoverTemplate)(viewScope); + popover.attr({ + id: id, + direction: popoverOptions.direction || "below left" }); + popoverObj = service.add(id, popover, element, options); + $animate.addClass(element, "active"); + $rootScope.$broadcast("popoverWasShown", id); + return $animate.enter(popover, angular.element(document.body)).then(function() { + return service.resize(popoverObj); + }); + }; + if ((template = popoverOptions.template)) { + return showPopover(template); + } else if ((path = popoverOptions.templateUrl)) { + template = $templateCache.get(path); + if (template) { + return showPopover(template); + } else { + return $http.get(path).then(function(resp) { + $templateCache.put(path, resp.data); + return showPopover(resp.data); + }, function() { + throw new Error('Failed to load template: #{path}'); + }); + } } - angular.extend(viewScope, { - macPopoverClasses: { - footer: popoverOptions.footer || false, - header: popoverOptions.header || !!popoverOptions.title || false, - fixed: popoverOptions.fixed || false - }, - macPopoverTitle: popoverOptions.title || "", - macPopoverTemplate: template - }); - popover = $compile(popoverViews.template)(viewScope); - popover.attr({ - id: id, - direction: popoverOptions.direction || "below left" - }); - popoverObj = service.add(id, popover, element, options); - $animate.addClass(element, "active"); - $rootScope.$broadcast("popoverWasShown", id); - return $animate.enter(popover, angular.element(document.body), null, function() { - return service.resize(popoverObj); - }); }; - if ((template = popoverOptions.template)) { - return showPopover(template); - } else if ((path = popoverOptions.templateUrl)) { - template = $templateCache.get(path); - if (template) { - return showPopover(template); - } else { - return $http.get(path).then(function(resp) { - $templateCache.put(path, resp.data); - return showPopover(resp.data); - }, function() { - throw new Error('Failed to load template: #{path}'); - }); + if (service.popoverList.length && !!!options.childPopover) { + service.hide(addPopover); + } else { + addPopover(); + } + return true; + }, + getById: function(id, element) { + var item, sameTrigger, _i, _len, _ref; + _ref = this.popoverList; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + item = _ref[_i]; + sameTrigger = (element == null) || item.element === element; + if (item.id === id && sameTrigger) { + return item; } } - }; - if (service.popoverList.length && !!!options.childPopover) { - service.hide(addPopover); - } else { - addPopover(); - } - return true; - }, - getById: function(id, element) { - var item, sameTrigger, _i, _len, _ref; - _ref = this.popoverList; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - item = _ref[_i]; - sameTrigger = (element == null) || item.element === element; - if (item.id === id && sameTrigger) { - return item; + }, + resize: function(popoverObj) { + var $window, action, current, currentPopover, diff, left, leftScroll, offset, options, position, relative, relativeElement, setOverflowPosition, top, topScroll, updateOffset; + if (angular.isString(popoverObj)) { + popoverObj = service.getById(popoverObj); } - } - }, - resize: function(popoverObj) { - var $window, action, current, currentPopover, diff, left, leftScroll, offset, options, position, relative, relativeElement, setOverflowPosition, top, topScroll, updateOffset; - if (angular.isString(popoverObj)) { - popoverObj = service.getById(popoverObj); - } - if (popoverObj == null) { - return; - } - currentPopover = popoverObj.popover; - relativeElement = popoverObj.element; - options = popoverObj.options; - $window = angular.element(window); - offset = relativeElement.offset(); - if (options.fixed) { - offset.top = relativeElement.position().top; - } - relative = { - height: relativeElement.outerHeight(), - width: relativeElement.outerWidth() - }; - current = { - height: currentPopover.outerHeight(), - width: currentPopover.outerWidth() - }; - top = 0; - left = 0; - position = (currentPopover.attr("direction") || "top left").trim(); - setOverflowPosition = function(offset) { - var tip, tipOffset; - if (offset == null) { - offset = 0; - } - tip = angular.element(currentPopover[0].getElementsByClassName("tip")); - top -= offset; - tipOffset = +tip.css("margin-top").replace("px", ""); - return tip.css("margin-top", tipOffset + offset); - }; - updateOffset = function() { - switch (position) { - case "above left": - top = -(current.height + 10); - return left = -25 + relative.width / 2; - case "above right": - top = -(current.height + 10); - return left = 25 + relative.width / 2 - current.width; - case "below left": - top = relative.height + 10; - return left = -25 + relative.width / 2; - case "below right": - top = relative.height + 10; - return left = 25 + relative.width / 2 - current.width; - case "middle right": - top = relative.height / 2 - current.height / 2; - return left = relative.width + 10; - case "middle left": - top = relative.height / 2 - current.height / 2; - return left = -(current.width + 10); + if (popoverObj == null) { + return; } - }; - updateOffset(); - topScroll = options.fixed ? 0 : $window.scrollTop(); - leftScroll = options.fixed ? 0 : $window.scrollLeft(); - action = {}; - if (position.indexOf("middle") === -1) { - if (offset.top + top - topScroll < 0) { + currentPopover = popoverObj.popover; + relativeElement = popoverObj.element; + options = popoverObj.options; + $window = angular.element(window); + offset = relativeElement.offset(); + if (options.fixed) { + offset.top = relativeElement.position().top; + } + relative = { + height: relativeElement.outerHeight(), + width: relativeElement.outerWidth() + }; + current = { + height: currentPopover.outerHeight(), + width: currentPopover.outerWidth() + }; + top = 0; + left = 0; + position = (currentPopover.attr("direction") || "top left").trim(); + setOverflowPosition = function(offset) { + var tip, tipOffset; + if (offset == null) { + offset = 0; + } + tip = angular.element(currentPopover[0].getElementsByClassName("tip")); + top -= offset; + tipOffset = +tip.css("margin-top").replace("px", ""); + return tip.css("margin-top", tipOffset + offset); + }; + updateOffset = function() { + switch (position) { + case "above left": + top = -(current.height + 10); + return left = -25 + relative.width / 2; + case "above right": + top = -(current.height + 10); + return left = 25 + relative.width / 2 - current.width; + case "below left": + top = relative.height + 10; + return left = -25 + relative.width / 2; + case "below right": + top = relative.height + 10; + return left = 25 + relative.width / 2 - current.width; + case "middle right": + top = relative.height / 2 - current.height / 2; + return left = relative.width + 10; + case "middle left": + top = relative.height / 2 - current.height / 2; + return left = -(current.width + 10); + } + }; + updateOffset(); + topScroll = options.fixed ? 0 : $window.scrollTop(); + leftScroll = options.fixed ? 0 : $window.scrollLeft(); + action = {}; + if (position.indexOf("middle") === -1) { + if (offset.top + top - topScroll < 0) { + action = { + remove: "above", + add: "below" + }; + } else if (offset.top + top + current.height - topScroll > $window.height()) { + action = { + remove: "below", + add: "above" + }; + } + } else { + if ((diff = offset.top + top - topScroll) < 0) { + setOverflowPosition(diff); + } else if ((diff = offset.top + top + currentPopover.outerHeight() - topScroll - $window.height()) > 0) { + setOverflowPosition(diff); + } + } + if (action.remove && action.add) { + position = position.replace(action.remove, action.add); + } + action = {}; + if (offset.left + left - leftScroll < 0) { action = { - remove: "above", - add: "below" + remove: "right", + add: "left" }; - } else if (offset.top + top + current.height - topScroll > $window.height()) { + } else if (offset.left + left + currentPopover.outerWidth() - leftScroll > $window.width()) { action = { - remove: "below", - add: "above" + remove: "left", + add: "right" }; } - } else { - if ((diff = offset.top + top - topScroll) < 0) { - setOverflowPosition(diff); - } else if ((diff = offset.top + top + currentPopover.outerHeight() - topScroll - $window.height()) > 0) { - setOverflowPosition(diff); + if (action.remove && action.add) { + position = position.replace(action.remove, action.add); } - } - if (action.remove && action.add) { - position = position.replace(action.remove, action.add); - } - action = {}; - if (offset.left + left - leftScroll < 0) { - action = { - remove: "right", - add: "left" - }; - } else if (offset.left + left + currentPopover.outerWidth() - leftScroll > $window.width()) { - action = { - remove: "left", - add: "right" - }; - } - if (action.remove && action.add) { - position = position.replace(action.remove, action.add); - } - updateOffset(); - offset.top += top; - offset.left += left; - if (options.offsetX != null) { - offset.left += options.offsetX; - } - if (options.offsetY != null) { - offset.top += options.offsetY; - } - angular.forEach(offset, function(value, key) { - if (!isNaN(+value)) { - value = "" + value + "px"; + updateOffset(); + offset.top += top; + offset.left += left; + if (options.offsetX != null) { + offset.left += options.offsetX; } - return currentPopover.css(key, value); - }); - return currentPopover.addClass("visible " + position); - }, - hide: function(selector, callback) { - var comparator, i, index, popoverObj, removeScope, _i, _ref; - if (!this.popoverList.length) { - return typeof callback === "function" ? callback() : void 0; - } - if (angular.isFunction(selector)) { - callback = selector; - selector = null; - } - if (selector != null) { - comparator = angular.isString(selector) ? function(item) { - return item.id === selector; - } : angular.isElement(selector) ? function(item) { - return item.element === selector; - } : void 0; - index = -1; - for (i = _i = _ref = this.popoverList.length - 1; _i >= 0; i = _i += -1) { - if (!(comparator(this.popoverList[i]))) { - continue; + if (options.offsetY != null) { + offset.top += options.offsetY; + } + angular.forEach(offset, function(value, key) { + if (!isNaN(+value)) { + value = "" + value + "px"; } - popoverObj = this.popoverList[i]; - index = i; - break; + return currentPopover.css(key, value); + }); + return currentPopover.addClass("visible " + position); + }, + hide: function(selector, callback) { + var comparator, i, index, popoverObj, removeScope, _i, _ref; + if (!this.popoverList.length) { + return typeof callback === "function" ? callback() : void 0; + } + if (angular.isFunction(selector)) { + callback = selector; + selector = null; + } + if (selector != null) { + comparator = angular.isString(selector) ? function(item) { + return item.id === selector; + } : angular.isElement(selector) ? function(item) { + return item.element === selector; + } : void 0; + index = -1; + for (i = _i = _ref = this.popoverList.length - 1; _i >= 0; i = _i += -1) { + if (!(comparator(this.popoverList[i]))) { + continue; + } + popoverObj = this.popoverList[i]; + index = i; + break; + } + if (index > -1) { + this.popoverList.splice(index, 1); + } + } else { + popoverObj = this.pop(); } - if (index > -1) { - this.popoverList.splice(index, 1); + if (popoverObj == null) { + return; } - } else { - popoverObj = this.pop(); - } - if (popoverObj == null) { - return; - } - $rootScope.$broadcast("popoverBeforeHide", popoverObj.id); - removeScope = popoverObj.popover.scope(); - return $animate.leave(popoverObj.popover, function() { + $rootScope.$broadcast("popoverBeforeHide", popoverObj.id); $animate.removeClass(popoverObj.element, "active"); - $rootScope.$broadcast("popoverWasHidden", popoverObj.id); - removeScope.$destroy(); - return typeof callback === "function" ? callback() : void 0; - }); - }, - hideAll: function() { - while (this.popoverList.length) { - this.hide(); + removeScope = popoverObj.popover.scope(); + return $animate.leave(popoverObj.popover).then(function() { + $rootScope.$broadcast("popoverWasHidden", popoverObj.id); + removeScope.$destroy(); + return typeof callback === "function" ? callback() : void 0; + }); + }, + hideAll: function() { + while (this.popoverList.length) { + this.hide(); + } } - } - }; - return service; - } -]).config([ - "popoverViewsProvider", function(popoverViews) { + }; + return service; + } + ]; +}).config([ + "popoverProvider", function(popoverProvider) { return angular.module("Mac").popover = function(name, options) { var opts; - if (popoverViews.registered[name] == null) { + if (popoverProvider.registered[name] == null) { opts = {}; - angular.extend(opts, popoverViews.popoverDefaults, options, { + angular.extend(opts, popoverProvider.popoverDefaults, options, { id: name }); - return popoverViews.registered[name] = opts; + return popoverProvider.registered[name] = opts; } }; } diff --git a/lib/macgyver.min.js b/lib/macgyver.min.js index 08bf208..a13107f 100644 --- a/lib/macgyver.min.js +++ b/lib/macgyver.min.js @@ -1,2 +1,2 @@ -!function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n;m=["Mac.Util"];try{b.module("ngAnimate"),m.push("ngAnimate")}catch(o){}b.module("Mac",m),e=["Top","Right","Bottom","Left"],d=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,n=new RegExp("^("+d+")(?!px)[a-z%]+$","i"),g=function(b){return a.getComputedStyle(b,null)},k=function(a){return a&&a.document&&a.location&&a.alert&&a.setInterval},j=function(a){return a&&null!=a.$evalAsync&&null!=a.$watch},i=function(a){return k(a)?a:9===a.nodeType&&a.defaultView},c=function(a,b,c,d,f){var g,h,i,j;if(c===(d?"border":"content"))return 0;for(i=0,h="Width"===b?1:0,g=j=h;3>=j;g=j+=2)"margin"===c&&(i+=parseFloat(f[""+c+e[g]])),d?("content"===c&&(i-=parseFloat(f["padding"+e[g]])),"margin"!==c&&(i-=parseFloat(f["border"+e[g]]))):(i+=parseFloat(f["padding"+e[g]]),"padding"!==c&&(i+=parseFloat(f["border"+e+"Width"])));return i},h=function(a,b,d){return function(e){var f,h,i,j,l,m,o,p;if(f=function(){switch(b){case"inner":return"padding";case"outer":return"";default:return"content"}}(),i=f||(e===!0?"margin":"border"),k(d))return d.document.documentElement["client"+a];if(9===d.nodeType)return h=d.documentElement,Math.max(d.body["scroll"+a],h["scroll"+a],d.body["offset"+a],h["offset"+a],h["client"+a]);if(p=!0,m=g(d),l=a.toLowerCase(),o="Height"===a?d.offsetHeight:d.offsetWidth,j="border-box"===d.style.boxSizing,0>=o||null===o){if(o=m[l],(0>o||null===o)&&(o=d.style[l]),n.test(o))return o;p=j,o=parseFloat(o)||0}return o+c(d,a,i||(j?"border":"content"),p,m)}},l={height:function(a){return h("Height","",a)()},width:function(a){return h("Width","",a)()},outerHeight:function(a,b){return h("Height","outer",a)(b)},outerWidth:function(a,b){return h("Width","outer",a)(b)},offset:function(a){var b,c,d,e;return b={top:0,left:0},(c=a&&a.ownerDocument)?(d=c.documentElement,null!=a.getBoundingClientRect&&(b=a.getBoundingClientRect()),e=i(c),{top:b.top+e.pageYOffset-d.clientTop,left:b.left+e.pageXOffset-d.clientLeft}):void 0},scrollTop:function(b,c){var d;return d=i(b),null==c?d?d.pageYOffset:b.scrollTop:d?d.scrollTo(a.pageYOffset,c):b.scrollTop=c},scrollLeft:function(b,c){var d;return d=i(b),null==c?d?d.pageXOffset:b.scrollLeft:d?d.scrollTo(a.pageXOffset,c):b.scrollLeft=c}},f=function(){var c;if(null==a.jQuery||null==b.element.prototype.offset)return c=b.element,b.forEach(l,function(a,b){return c.prototype[b]=function(b,c){return this.length?a(this[0],b,c):void 0}})},f(),b.module("Mac").directive("macAffix",["$document","$window",function(a,c){return{link:function(d,e,f){var g,h,i,j,k,l,m,n,o,p;return g={top:0,bottom:0,disabled:!1,classes:"affix affix-top affix-bottom"},k={top:g.top,bottom:g.bottom},h=g.disabled,j=null,o=null,l=null,p=b.element(c),n=function(a,b,c){return null==c&&(c=!1),c&&null==b&&(b=g[a]),null==b||isNaN(+b)?void 0:k[a]=+b},null!=f.macAffixTop&&(n("top",d.$eval(f.macAffixTop),!0),d.$watch(f.macAffixTop,function(a){return n("top",a)})),null!=f.macAffixBottom&&(n("bottom",d.$eval(f.macAffixBottom),!0),d.$watch(f.macAffixBottom,function(a){return n("bottom",a)})),i=function(){var b;return null!=l?l:(e.removeClass(g.classes).addClass("affix"),b=a.height(),l=b-e.outerHeight()-k.bottom)},m=function(){var b,c,d,f,h,l;if(!(e[0].offsetHeight<=0&&e[0].offsetWidth<=0)&&(f=e.offset(),l=p.scrollTop(),h=a.height(),d=e.outerHeight(),b=null!=o&&o>=l?!1:null!=k.bottom&&l>h-d-k.bottom?"bottom":null!=k.top&&l<=k.top?"top":!1,b!==j))return o&&e.css("top",""),j=b,o="bottom"===b?i():null,e.removeClass(g.classes).addClass("affix"+(b?"-"+b:"")),"bottom"===b&&(c=e.offset(),e.css("top",o-c.top)),!0},null!=f.macAffixDisabled&&(h=d.$eval(f.macAffixDisabled)||g.disabled,d.$watch(f.macAffixDisabled,function(a){var b;if(null!=a&&a!==h)return h=a,b=a?"unbind":"bind",p[b]("scroll",m),h?(j=null,o=null,e.css("top","").removeClass(g.classes)):m()})),h||p.bind("scroll",m),d.$on("refresh-mac-affix",function(){var a;return a=e.offset()}),d.$on("$destroy",function(){return p.unbind("scroll",m)})}}}]),b.module("Mac").directive("macAutocomplete",["$animate","$compile","$filter","$http","$parse","$rootScope","$timeout","keys",function(c,d,e,f,g,h,i,j){return{restrict:"EA",template:'',transclude:!0,replace:!0,require:"ngModel",link:function(h,k,l,m,n){var o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L;return z=l.macAutocompleteLabel||"name",y=g(z),H=l.macAutocompleteQuery||"q",t=+(l.macAutocompleteDelay||800),w=null!=l.macAutocompleteInside,q=g(l.macAutocompleteUrl),C=g(l.macAutocompleteOnSelect),D=g(l.macAutocompleteOnSuccess),B=g(l.macAutocompleteOnError),J=g(l.macAutocompleteSource),u=g(l.macAutocompleteDisabled),s=[],K=null,x=!1,F=!1,o=h.$new(),o.items=[],o.index=0,o.select=function(a){var b,c;return c=s[a],C(h,{selected:c}),b=o.items[a].label||"",F=!0,null!=l.ngModel&&(m.$setViewValue(b),m.$render()),I()},A=b.element(document.createElement("mac-menu")),A.attr({"ng-class":l.macMenuClass||"","mac-menu-items":"items","mac-menu-select":"select(index)","mac-menu-index":"index"}),n(o,function(a){return A.append(a)}),d(A)(o),m.$parsers.push(function(a){return!a||u(h)||F?I():(null!=K&&i.cancel(K),t>0?K=i(function(){return G(a)},t):G(a)),F=!1,a}),r=function(){return h.$apply(function(){return I()})},p=function(a){return x||(k.bind("blur",r),A.on("mousedown",function(a){return a.preventDefault()})),x=!0,w?c.enter(A,void 0,k,a):c.enter(A,b.element(document.body),void 0,a)},I=function(){c.leave(A,function(){return o.index=0,o.items.length=0,A[0].style.top="",A[0].style.left="",x=!1,k.unbind("blur",r)})},E=function(){var c,d,e;return d=w?k[0]:document.body,e=a.getComputedStyle(d),c=k.offset(),c.left-=parseInt(e.marginLeft),c.top+=k.outerHeight()-parseInt(e.marginTop),c.minWidth=k.outerWidth(),b.forEach(c,function(a,c){return!isNaN(+a)&&b.isNumber(+a)&&(a=""+a+"px"),A[0].style[c]=a})},L=function(a){return(null!=a?a.length:void 0)>0?(s=a,o.items=a.map(function(a){return b.isObject(a)?(null==a.value&&(a.value=y(a)||""),null==a.label&&(a.label=y(a)||""),a):{label:a,value:a}}),p(E)):I()},v=function(a,b){var c;return c={method:"GET",url:a,params:{}},c.params[H]=b,f(c).success(function(a,b,c){var d;return d=D(h,{data:a,status:b,headers:c}),null==d&&(d=a.data),L(d)}).error(function(a,b,c){return B(h,{data:a,status:b,headers:c})})},G=function(a){var c,d;return d=q(h),d?v(d,a):(c=J(h),b.isArray(c)?L(e("filter")(c,a)):b.isString(c)?v(c,a):b.isFunction(c)?c(a,L):void 0)},k.bind("keydown",function(a){if(0===o.items.length)return!0;switch(a.which){case j.DOWN:h.$apply(function(){return o.index=(o.index+1)%o.items.length,a.preventDefault()});break;case j.UP:h.$apply(function(){return o.index=(o.index?o.index:o.items.length)-1,a.preventDefault()});break;case j.ENTER:h.$apply(function(){return o.select(o.index),a.preventDefault()});break;case j.ESCAPE:h.$apply(function(){return I(),a.preventDefault()})}return!0}),h.$on("$destroy",function(){return o.$destroy(),I()}),h.$on("reset-mac-autocomplete",function(){return I()})}}}]),b.module("Mac").directive("macCspinner",["$timeout","util",function(c,d){return{restrict:"E",replace:"true",template:'
',compile:function(e,f){var g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F;if(!a.HTMLCanvasElement)return console.log("Browser does not support canvas");if(j={width:2,height:5,border:1,radius:4,bars:10,padding:3,speed:100,color:"#2f3035",size:20},q=d.extendAttributes("macCspinner",j,f),null!=f.macCspinnerSize&&(x=!isNaN(+f.macCspinnerSize)&&+f.macCspinnerSize))for(t=x/j.size,E=["width","height","border","radius"],B=0,D=E.length;D>B;B++)r=E[B],q[r]=j[r]*t;for(A=q.width,k=q.height,s=q.border,o=q.radius+k,n=Math.max(A,o),h=Math.ceil(Math.max(n,d.pyth(o,A/2))),h+=q.padding,y=b.element(""),i=y[0].getContext("2d"),v=d.radian(360/q.bars),i.translate(h,h),z=-o,m=-A/2,u=d.hex2rgb(q.color),l=C=0,F=q.bars-1;F>=0?F>=C:C>=F;l=F>=0?++C:--C)p=1-.8/q.bars*l,i.fillStyle="rgba("+u.r+", "+u.g+", "+u.b+", "+p+")",i.beginPath(),i.moveTo(m+s,z),i.arc(m+A-s,z+s,s,d.radian(-90),d.radian(0),!1),i.arc(m+A-s,z+k-s,s,d.radian(0),d.radian(90),!1),i.arc(m+s,z+k-s,s,d.radian(90),d.radian(180),!1),i.arc(m+s,z+s,s,d.radian(-180),d.radian(-90),!1),i.closePath(),i.fill(),i.rotate(v);return g=b.element(""),g.attr({width:2*h,height:2*h}),w=g[0].getContext("2d"),w.translate(h,h),e.append(g),function(a,b,e){var f,g,i,j;return f=null,g=!1,j=function(){return g=!1,null!=f?c.cancel(f):void 0},i=function(){var a,e;if(!g)return g=!0,e=d.radian(360/q.bars),(a=function(d){return null==d&&(d=!1),w.clearRect(-h,-h,2*h,2*h),w.rotate(e),w.drawImage(y[0],-h,-h),g?!d&&b[0].offsetHeight<=0&&b[0].offsetWidth<=0?j():f=c(a,q.speed,!1):void 0})(!0)},null!=e.macCspinnerSpin?a.$watch(e.macCspinnerSpin,function(a){return a&&!g?i():j()}):i(),e.ngShow?a.$watch(e.ngShow,function(a){return a?i():j()}):e.ngHide&&a.$watch(e.ngHide,function(a){return a?j():i()}),a.$on("$destroy",function(){return j()})}}}}]);var p,q,r,s,t;for(t=["Enter","Escape","Space","Left","Up","Right","Down"],q=function(a){return b.module("Mac").directive("macKeydown"+a,["$parse","keys",function(b,c){return{restrict:"A",link:function(d,e,f){var g;return g=b(f["macKeydown"+a]),e.bind("keydown",function(b){return b.which===c[""+a.toUpperCase()]?(b.preventDefault(),d.$apply(function(){return g(d,{$event:b})})):void 0})}}}])},r=0,s=t.length;s>r;r++)p=t[r],q(p);b.module("Mac").directive("macPauseTyping",["$parse","$timeout",function(a,b){return{restrict:"A",link:function(c,d,e){var f,g,h;return g=a(e.macPauseTyping),f=c.$eval(e.macPauseTypingDelay)||800,h=null,d.bind("keyup",function(a){return null!=h&&b.cancel(h),h=b(function(){return g(c,{$event:a})},f)})}}}]),b.module("Mac").directive("macWindowResize",["$parse","$window",function(a,c){return{restrict:"A",link:function(d,e,f){var g;return g=function(b){var c;return c=a(f.macWindowResize),d.$apply(function(){return c(d,{$event:b})}),!0},b.element(c).bind("resize",g),d.$on("destroy",function(){return b.element(c).unbind("resize",g)})}}}]),b.module("Mac").directive("macFocusOnEvent",["$timeout",function(b){return function(c,d,e){return c.$on(e.macFocusOnEvent,function(){return b(function(){var b,c;return d.focus(),e.macFocusOnEventScroll?(b=a.scrollX,c=a.scrollY,a.scrollTo(b,c)):void 0},0,!1)})}}]),b.module("Mac").factory("keys",function(){return{CANCEL:3,HELP:6,BACKSPACE:8,TAB:9,CLEAR:12,ENTER:13,RETURN:13,SHIFT:16,CONTROL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,ESCAPE:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PRINT_SCREEN:44,INSERT:45,DELETE:46,ZERO:48,ONE:49,TWO:50,THREE:51,FOUR:52,FIVE:53,SIX:54,SEVEN:55,EIGHT:56,NINE:57,SEMICOLON:59,EQUALS:61,COMMAND:91,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,CONTEXT_MENU:93,NUMPAD0:96,NUMPAD1:97,NUMPAD2:98,NUMPAD3:99,NUMPAD4:100,NUMPAD5:101,NUMPAD6:102,NUMPAD7:103,NUMPAD8:104,NUMPAD9:105,MULTIPLY:106,ADD:107,SEPARATOR:108,SUBTRACT:109,DECIMAL:110,DIVIDE:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,F13:124,F14:125,F15:126,F16:127,F17:128,F18:129,F19:130,F20:131,F21:132,F22:133,F23:134,F24:135,NUM_LOCK:144,SCROLL_LOCK:145,COMMA:188,PERIOD:190,SLASH:191,BACK_QUOTE:192,OPEN_BRACKET:219,BACK_SLASH:220,CLOSE_BRACKET:221,QUOTE:222,META:224}}),b.module("Mac").directive("macMenu",[function(){return{restrict:"EA",replace:!0,template:'
',transclude:!0,controller:b.noop,scope:{items:"=macMenuItems",style:"=macMenuStyle",select:"&macMenuSelect",pIndex:"=macMenuIndex"},link:function(a,b,c){return a.selectItem=function(b){return a.select({index:b})},a.setIndex=function(b){return a.index=b,null!=c.macMenuIndex?a.pIndex=parseInt(b):void 0},null!=c.macMenuIndex&&a.$watch("pIndex",function(b){return a.index=parseInt(b)}),a.$watch("items.length",function(a){return a?c.$addClass("visible"):c.$removeClass("visible")})}}}]).directive("macMenuTransclude",["$compile",function(a){return{link:function(b,c,d,e,f){return f(b,function(d){return c.empty(),0===d.length&&(d=a("{{item.label}}")(b)),c.append(d)})}}}]),b.module("Mac").directive("macModal",["$parse","modal","modalViews","util",function(a,c,d,e){return{restrict:"E",template:c.modalTemplate,replace:!0,transclude:!0,link:function(f,g,h,i,j){var k,l,m,n,o,p,q,r;for(j(f,function(a){return b.element(g[0].getElementsByClassName("mac-modal-content-wrapper")).replaceWith(a)}),m=e.extendAttributes("macModal",d.defaults,h),n=null,m.overlayClose&&g.on("click",function(a){return b.element(a.target).hasClass("mac-modal-overlay")?f.$apply(function(){return c.hide()}):void 0}),r=["beforeShow","afterShow","beforeHide","afterHide","open"],p=0,q=r.length;q>p;p++)k=r[p],l="macModal"+e.capitalize(k),m[k]=a(h[l])||b.noop;return o=function(a){return null!=a&&a?(n=a,c.register(a,g,m)):void 0},h.id?o(h.id):h.$observe("macModal",function(a){return o(a)}),f.$on("$destroy",function(){return n?c.unregister(n):void 0})}}}]).directive("macModal",["$parse","modal",function(a,b){return{restrict:"A",link:function(c,d,e){e.macModal&&d.bind("click",function(){return c.$apply(function(){var d;return d=a(e.macModalData)(c)||{},b.show(e.macModal,{data:d,scope:c})})})}}}]).directive("macModalClose",["modal",function(a){return{restrict:"A",link:function(b,c){return c.bind("click",function(){return b.$apply(function(){return a.hide()})})}}}]),b.module("Mac").directive("macPlaceholder",function(){return{restrict:"A",link:function(a,b,c){return a.$watch(c.macPlaceholder,function(a){return c.$set("placeholder",a)})}}});var u=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};b.module("Mac").directive("macPopover",["$timeout","popover","util","popoverViews",function(a,b,c,d){return{restrict:"A",link:function(e,f,g){var h,i,j,k,l,m,n,o;return n=c.extendAttributes("macPopover",d.defaults,g),k=g.macPopoverExclude||"",l=k?k.split(","):[],j=null,i=null,h=function(){return null!=j&&a.cancel(j),null!=i?a.cancel(i):void 0},o=function(c,d){return null==d&&(d=0),h(),j=a(function(){var a,d;return a=b.last(),null!=a&&(!l.length||(d=a.id,u.call(l,d)>=0)||a.id===c)&&(b.hide(),f[0]===a.element[0])?!0:(n.scope=e,b.show(c,f,n))},d),!0},m=function(c,d){return null==d&&(d=0),h(),i=a(function(){return b.hide(c)},d)},g.$observe("macPopover",function(a){var b,c;if(a)return"click"===n.trigger?f.bind("click",function(){return o(a,0)}):(c="focus"===n.trigger?"focusin":"mouseenter",b="focus"===n.trigger?"focusout":"mouseleave",f.bind(c,function(){return o(a,400)}),f.bind(b,function(){return m(f,500)}))})}}}]).directive("macPopover",["popover","popoverViews","util",function(a,c,d){return{restrict:"E",compile:function(e,f){var g;if(!f.id)throw Error("macPopover: Missing id");return g=d.extendAttributes("macPopover",c.popoverDefaults,f),b.extend(g,{template:e.html()}),function(b,c,d){return d.$observe("id",function(b){return a.register(b,g),c.replaceWith(document.createComment("macPopover: "+d.id))})}}}}]).directive("macPopoverFillContent",["$compile",function(a){return{restrict:"A",link:function(b,c){return c.html(b.macPopoverTemplate),a(c.contents())(b)}}}]),b.module("Mac").directive("macScrollSpy",["$window","scrollSpy","scrollSpyDefaults","util",function(a,c,d,e){return{link:function(f,g,h){var i,j;return i=e.extendAttributes("macScrollSpy",d,h),j="BODY"===g[0].tagName?b.element(a):g,j.bind("scroll",function(){var a,b,d,e,h,k,l;if(h=j.scrollTop()+i.offset,e=this.scrollHeight||g[0].scrollHeight,d=e-j.height(),!c.registered.length)return!0;if(h>=d)return c.setActive(c.last());for(b=k=0,l=c.registered.length-1;l>=0?l>=k:k>=l;b=l>=0?++k:--k)if(a=c.registered,c.active.id!==a[b].id&&h>=a[b].top&&(!a[b+1]||h<=a[b+1].top))return f.$apply(function(){return c.setActive(a[b])}),!0})}}}]).directive("macScrollSpyAnchor",["scrollSpy",function(a){return{link:function(b,c,d){var e,f,g,h;if(e=d.id||d.macScrollSpyAnchor,g=!1,!e)throw new Error("Missing scroll spy anchor id");return h=function(){return a.register(e,c),g||b.$on("$destroy",function(){return a.unregister(e)}),g=!0},b.$on("refresh-scroll-spy",h),/{{(.*)}}/.test(e)?(f=d.id?"id":"macScrollSpyAnchor",d.$observe(f,function(a){return null!=a&&a?(e=a,h()):void 0})):h()}}}]).directive("macScrollSpyTarget",["scrollSpy",function(a){return{link:function(b,c,d){var e,f,g,h;if(h=d.macScrollSpyTarget,e=d.macScrollSpyTargetClass||"active",g=!1,!h)throw new Error("Missing scroll spy target name");return f=function(d){var f;if(d)return f=function(a){var b;return b=d===a.id?"addClass":"removeClass",c[b](e)},null!=a.active&&f(a.active),g?void 0:(a.addListener(f),b.$on("$destroy",function(){return a.removeListener(f)}))},/{{(.*)}}/.test(h)?d.$observe("macScrollSpyTarget",function(a){return f(a)}):f(h)}}}]),b.module("Mac").directive("macSpinner",["util",function(a){return{restrict:"E",replace:!0,template:'
',compile:function(c){var d,e,f,g,h,i,j,k,l,m,n,o;for(j=["webkit","Moz","ms","O"],f=[],n=function(b,c){var d,e,f;for(c=a.capitalize(c),e=0,f=j.length;f>e;e++)if(d=j[e],null!=b.style[d+c])return d+c;return c},m=function(a,c){var d,e,g,h,i,j;{if(!b.isObject(a)){for(j=[],h=0,i=f.length;i>h;h++)d=f[h],j.push(d.style[a]=c);return j}for(e in a)g=a[e],m(e,g)}},d=n(c[0],"animation"),l=n(c[0],"transform"),i=o=0;9>=o;i=++o)h=.1*i-1+!i,g=36*i,k={},e=b.element('
'),f.push(e[0]),k[d]="fade 1s linear infinite "+h+"s",k[l]="rotate("+g+"deg) translate(0, 130%)",e.css(k),c.append(e);return function(a,c,d){var e,f;return e={size:16,zIndex:"inherit",color:"#2f3035"},f=function(a){return m({height:.32*a+"px",left:.445*a+"px",top:.37*a+"px",width:.13*a+"px",borderRadius:.32*a*2+"px",position:"absolute"}),!isNaN(+a)&&b.isNumber(+a)&&(a=""+a+"px"),c.css({height:a,width:a})},null!=d.macSpinnerSize?d.$observe("macSpinnerSize",function(a){return null!=a&&a?f(a):void 0}):f(e.size),d.$observe("macSpinnerZIndex",function(a){return null!=a&&a?c.css("z-index",a):void 0}),null!=d.macSpinnerColor?d.$observe("macSpinnerColor",function(a){return null!=a&&a?m("background",a):void 0}):m("background",e.color)}}}}]);var u=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};b.module("Mac").directive("macTagAutocomplete",["$parse","$timeout","keys","util",function(a,c,d,e){return{restrict:"E",template:'
',replace:!0,priority:800,scope:{url:"=macTagAutocompleteUrl",placeholder:"=macTagAutocompletePlaceholder",selected:"=macTagAutocompleteSelected",source:"=macTagAutocompleteSource",disabled:"=macTagAutocompleteDisabled",model:"=macTagAutocompleteModel",onEnter:"&macTagAutocompleteOnEnter",onKeydown:"&macTagAutocompleteOnKeydown"},compile:function(f,g){var h,i,j,k,l,m,n,o,p;return p=g.macTagAutocompleteValue,null==p&&(p="id"),o=a(p),k=g.macTagAutocompleteLabel,null==k&&(k="name"),j=a(k),l=g.macTagAutocompleteQuery||"q",i=+g.macTagAutocompleteDelay||800,n=!1,m=b.element(f[0].getElementsByClassName("mac-autocomplete")),h={"mac-autocomplete-label":k,"mac-autocomplete-query":l,"mac-autocomplete-delay":i},null!=g.macTagAutocompleteUrl?h["mac-autocomplete-url"]="url":(n=null!=g.macTagAutocompleteSource)&&(h["mac-autocomplete-source"]="autocompleteSource"),m.attr(h),function(f,g,h){var i,l;return f.textInput="",f.autocompleteSource=b.isArray(f.source)?[]:f.source,null!=h.macTagAutocompleteModel&&(f.$watch("textInput",function(a){return f.model=a}),f.$watch("model",function(a){return f.textInput=a})),g.bind("click",function(){var a;return a=g[0].getElementsByClassName("mac-autocomplete"),a[0].focus()}),f.getTagLabel=function(a){return k?j(a):a},c(function(){var c,d,i,j,k,l,n,o;if(i=h.macTagAutocompleteEvents){for(m=b.element(g[0].getElementsByClassName("text-input")),n=i.split(","),o=[],k=0,l=n.length;l>k;k++)j=n[k],j=e.trim(j),c=e.capitalize(j),d=h["macTagAutocompleteOn"+c],d&&"keydown"!==j&&o.push(function(b,c){return m.bind(b,function(b){var d;return d=a(c),f.$apply(function(){return d(f.$parent,{$event:b,item:f.textInput})})})}(j,d));return o}},0,!1),i=function(){var a,c,d,e,g;return f.autocompletePlaceholder=(null!=(g=f.selected)?g.length:void 0)?"":f.placeholder,n&&b.isArray(f.source)?(e=function(){var a,b,d,e;for(d=f.source||[],e=[],a=0,b=d.length;b>a;a++)c=d[a],e.push(o(c));return e}(),d=function(){var a,b,d,e;for(d=f.selected||[],e=[],a=0,b=d.length;b>a;a++)c=d[a],e.push(o(c));return e}(),a=function(){var a,b,f;for(f=[],a=0,b=e.length;b>a;a++)c=e[a],u.call(d,c)<0&&f.push(c);return f}(),f.autocompleteSource=function(){var b,d,e,g,h;for(e=f.source||[],h=[],b=0,d=e.length;d>b;b++)c=e[b],g=o(c),u.call(a,g)>=0&&h.push(c);return h}()):void(f.autocompleteSource=f.source)},n&&(l=b.isArray(f.source)?"$watchCollection":"$watch",f[l]("source",i)),f.$watchCollection("selected",i),f.onKeyDown=function(a){var b,c;switch(b=a.which||a.keyCode){case d.BACKSPACE:f.textInput||"function"==typeof(c=f.selected).pop&&c.pop();break;case d.ENTER:f.textInput.length>0&&f.disabled&&f.onSelect(f.textInput)}return null!=h.macTagAutocompleteOnKeydown&&"function"==typeof f.onKeydown&&f.onKeydown({$event:a,value:f.textInput}),!0},f.onSuccess=function(a){var b,c;return b=function(){var a,b,d,e;for(d=f.selected||[],e=[],a=0,b=d.length;b>a;a++)c=d[a],e.push(o(c));return e}(),function(){var d,e,f,g,h;for(f=a.data,h=[],d=0,e=f.length;e>d;d++)c=f[d],g=o(c)||c,u.call(b,g)<0&&h.push(c);return h}()},f.onSelect=function(a){return null!=h.macTagAutocompleteOnEnter&&(a=f.onEnter({item:a})),a&&f.selected.push(a),c(function(){return f.textInput=""},0)},f.$on("mac-tag-autocomplete-clear-input",function(){return f.textInput=""})}}}}]),b.module("Mac").directive("macTime",["$filter","$timeout","keys","util",function(a,b,c,d){var e;return e={"default":"12:00 AM"},{restrict:"E",require:"ngModel",replace:!0,template:'',link:function(f,g,h,i){var j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;return n=d.extendAttributes("macTime",e,h),v=null,h.placeholder||h.$set("placeholder","--:--"),w=function(a){return!a||d.timeRegex.exec(a)?(i.$setValidity("time",!0),a):void i.$setValidity("time",!1)},i.$formatters.push(w),i.$parsers.push(w),(m=function(){var a;return a=(new Date).toDateString(),v=new Date(a+" "+n["default"]),isNaN(v.getTime())?v=new Date(a+" "+e["default"]):void 0})(),j=function(){var a;switch(a=g[0].selectionStart,!1){case!(a>=0&&3>a):return"hour";case!(a>=3&&6>a):return"minute";case!(a>=6&&9>a):return"meridian"}},t=function(a,c){return b(function(){return g[0].setSelectionRange(a,c)},0,!1)},o=function(){return t(0,2)},q=function(){return t(3,5)},p=function(){return t(6,8)},r=function(){switch(j()){case"hour":return q();case"minute":case"meridian":return p()}},s=function(){switch(j()){case"hour":case"minute":return o();case"meridian":return q()}},u=function(a){var b;return b=v.getHours(),b>=12&&"AM"===a&&(b-=12),12>b&&"PM"===a&&(b+=12),v.setHours(b)},x=function(){var a;return a=v.getHours(),v.setHours((a+12)%24)},k=function(a){return v.setHours(v.getHours()+a)},l=function(a){return v.setMinutes(v.getMinutes()+a)},y=function(){var b;return b=a("date")(v.getTime(),"hh:mm a"),b!==i.$viewValue?(i.$setViewValue(b),i.$render()):void 0},z=function(){var a,b,c,e;return(e=d.timeRegex.exec(i.$modelValue))?(a=+e[1],c=+e[2],b=e[3],"PM"===b&&12!==a&&(a+=12),"AM"===b&&12===a&&(a=0),v.setHours(a,c)):void 0},g.on("blur",function(){return f.$apply(function(){return y()})}),g.on("click",function(){return f.$apply(function(){switch(z(),y(),j()){case"hour":return o();case"minute":return q();case"meridian":return p()}})}),g.on("keydown",function(a){var b;return b=a.which,b!==c.UP&&b!==c.DOWN&&b!==c.LEFT&&b!==c.RIGHT&&b!==c.A&&b!==c.P?!0:(a.preventDefault(),f.$apply(function(){var a,d;switch(b){case c.UP:case c.DOWN:switch(a=b===c.UP?1:-1,j()){case"hour":k(a),o();break;case"minute":l(a),q();break;case"meridian":x(),p()}return y();case c.LEFT:case c.RIGHT:switch(b){case c.LEFT:s();break;case c.RIGHT:r()}return y();case c.A:case c.P:switch(d="meridian"===j(),!1){case!(d&&b===c.A):u("AM");break;case!(d&&b===c.P):u("PM")}return y(),p()}}))}),g.on("keyup",function(a){var b;return b=a.which,c.NUMPAD0<=b&&b<=c.NUMPAD9||c.ZERO<=b&&b<=c.NINE||a.preventDefault(),f.$apply(function(){return z()})})}}}]),b.module("Mac").directive("macTooltip",["$timeout","util",function(a,c){return{restrict:"A",link:function(d,e,f){var g,h,i,j,k,l,m,n,o,p;return p=null,n="",j=!1,i=!1,g=null,h={direction:"top",trigger:"hover",inside:!1},k=c.extendAttributes("macTooltip",h,f),m=function(){var a,c,d,f;if(i||!n||null!=p)return!0;switch(d=k.inside?e:b.element(document.body),l(0),p=b.element('
'+n+"
"),d.append(p),c=k.inside?{top:0,left:0}:e.offset(),a={width:e.outerWidth(),height:e.outerHeight()},f={width:p.outerWidth(),height:p.outerHeight()},k.direction){case"bottom":case"top":c.left+=a.width/2-f.width/2;break;case"left":case"right":c.top+=a.height/2-f.height/2}switch(k.direction){case"bottom":c.top+=a.height;break;case"top":c.top-=f.height;break;case"left":c.left-=f.width;break;case"right":c.left+=a.width}return c.top=Math.max(0,c.top),c.left=Math.max(0,c.left),b.forEach(c,function(a,c){return!isNaN(+a)&&b.isNumber(+a)&&(a=""+a+"px"),p.css(c,a)}),p.addClass("visible"),!0},l=function(b){return null==b&&(b=100),null!=p&&null==g&&(p.removeClass("visible"),g=a(function(){return null!=p&&p.remove(),p=null,g=null},b,!1)),!0},o=function(){return null!=p?l():m()},f.$observe("macTooltip",function(a){var b;if(null!=a&&(n=a,!j)){if("hover"!==(b=k.trigger)&&"click"!==b)throw"Invalid trigger";switch(k.trigger){case"click":e.bind("click",o);break;case"hover":e.bind("mouseenter",m),e.bind("mouseleave click",function(){return l()})}return j=!0}}),null!=f.macTooltipDisabled&&d.$watch(f.macTooltipDisabled,function(a){return i=a}),d.$on("$destroy",function(){return null!=p?l(0):void 0})}}}]),b.module("Mac").filter("boolean",function(){return function(a,b,c){return null==b&&(b="true"),null==c&&(c="false"),a?b:c}}),b.module("Mac").filter("true",function(){return function(a,b){return null==b&&(b="true"),a?b:""}}),b.module("Mac").filter("false",function(){return function(a,b){return null==b&&(b="false"),a?"":b}}),b.module("Mac").filter("list",[function(){return function(a,b){return null==b&&(b=", "),a.join(b)}}]),b.module("Mac").filter("pluralize",["util",function(a){return function(b,c,d){return null==d&&(d=!0),a.pluralize(b,c,d)}}]),b.module("Mac").filter("timestamp",["util",function(a){var b;return b=function(b,c){return c=a.pluralize(c,b),""+b+" "+c+" ago"},function(a){var c,d,e,f,g,h,i,j;return a=+a,c=Math.round(Date.now()/1e3),h=c-a,45>h?"just now":120>h?"about a minute ago":(j=Math.floor(h/31536e3),j>0?b(j,"year"):(g=Math.floor(h/2678400),g>0?b(g,"month"):(i=Math.floor(h/604800),i>0?b(i,"week"):(d=Math.floor(h/86400),d>0?b(d,"day"):(e=Math.floor(h/3600),e>0?b(e,"hour"):(f=Math.floor(h/60),f>0?b(f,"min"):""+h+" seconds ago"))))))}}]);var v=[].slice;b.module("Mac").filter("underscoreString",function(){return function(){var a,b,c;return c=arguments[0],a=arguments[1],b=3<=arguments.length?v.call(arguments,2):[],b.unshift(c),_.string[a].apply(this,b)}}),b.module("Mac").service("modal",["$rootScope","$animate","$templateCache","$compile","$http","$controller","modalViews","keys",function(c,d,e,f,g,h,i,k){return{registered:i.registered,waiting:null,opened:null,modalTemplate:'
\n
\n \n
\n
\n
',show:function(a,i){var k,l,m,n,o,p,q;if(null==i&&(i={}),null!=this.registered[a]&&null!=this.opened)return this.hide();if(null==this.registered[a])return this.waiting={id:a,options:i};if(k=this.registered[a],l=k.options,p={},b.extend(p,l,i),o=function(b){return function(e){return p.beforeShow(e.scope()),d.removeClass(e,"hide",function(){return d.addClass(e,"visible",function(){return b.opened={id:a,element:e,options:p},b.resize(b.opened),b.bindingEvents(),p.open(e.scope()),p.afterShow(e.scope()),c.$broadcast("modalWasShown",a),b.clearWaiting()})})}}(this),null!=p.moduleMethod){if(n=function(e){return function(g){var i,k,l;return j(p.scope)?k=p.scope:(k=c.$new(!0),b.isObject(p.scope)&&b.extend(k,p.scope)),b.extend(p.attributes,{id:a}),i=b.element(e.modalTemplate).attr(p.attributes),l=b.element(i[0].getElementsByClassName("mac-modal-content-wrapper")),l.html(g),p.overlayClose&&i.bind("click",function(a){return b.element(a.target).hasClass("mac-modal-overlay")?k.$apply(function(){return e.hide()}):void 0}),p.controller&&h(p.controller,{$scope:k,$element:i,macModalOptions:p}),d.enter(i,b.element(document.body)),f(i)(k),o(i)}}(this),m=p.templateUrl)return q=e.get(m),q?n(q):g.get(m).then(function(a){return e.put(m,a.data),n(a.data)},function(){throw Error("Failed to load template: "+m)});if(q=p.template)return n(q)}else if(null!=k.element)return o(k.element)},resize:function(c){var d,e,f,g,h,i;return null==c&&(c=this.opened),null!=c&&(e=c.element,h=c.options,h.position)?(g=b.element(e[0].getElementsByClassName("mac-modal")).attr("style",""),f=g.outerHeight(),i=g.outerWidth(),d=b.element(a).height()>f?{marginTop:-f/2}:{top:h.topOffset},d.marginLeft=-i/2,b.forEach(d,function(a,c){return!isNaN(+a)&&b.isNumber(+a)&&(a=""+a+"px"),g.css(c,a)})):void 0},hide:function(a){var b,e,f,g;if(null!=this.opened)return g=this.opened,e=g.id,f=g.options,b=g.element,f.beforeHide(b.scope()),d.removeClass(b,"visible",function(g){return function(){return g.bindingEvents("unbind"),g.opened=null,f.moduleMethod?(j(f.scope)||b.scope().$destroy(),d.leave(b)):d.addClass(b,"hide"),f.afterHide(b.scope()),c.$broadcast("modalWasHidden",e),a&&a()}}(this))},bindingEvents:function(c){var d,e,f;return null==c&&(c="bind"),"bind"!==c&&"unbind"!==c||null==this.opened?void 0:(d=function(a){return function(b){return b.which===k.ESCAPE?a.hide():void 0}}(this),f=function(a){return function(){return a.resize()}}(this),e=this.opened.options,e.keyboard&&b.element(document)[c]("keydown",d),e.resize?b.element(a)[c]("resize",f):void 0)},register:function(a,c,d){var e;if(null!=this.registered[a])throw new Error("Modal "+a+" already registered");return e={},b.extend(e,i.defaults,d),this.registered[a]={id:a,element:c,options:e},null!=this.waiting&&this.waiting.id===a?this.show(a,this.waiting.options):void 0},unregister:function(a){var b;if(null==this.registered[a])throw new Error("Modal "+a+" is not registered");return(null!=(b=this.opened)?b.id:void 0)===a&&this.hide(),this.clearWaiting(a),delete this.registered[a]},clearWaiting:function(a){var b;if(null==a||(null!=(b=this.waiting)?b.id:void 0)===a)return this.waiting=null}}}]).provider("modalViews",function(){return this.registered={},this.defaults={keyboard:!1,overlayClose:!1,resize:!0,position:!0,open:b.noop,topOffset:20,attributes:{},beforeShow:b.noop,afterShow:b.noop,beforeHide:b.noop,afterHide:b.noop},this.$get=function(){return this -},this}).config(["modalViewsProvider",function(a){return b.module("Mac").modal=function(c,d){var e;return null==a.registered[c]?(e={},b.extend(e,a.defaults,d,{moduleMethod:!0}),a.registered[c]={id:c,options:e}):void 0}}]),b.module("Mac").provider("popoverViews",function(){return this.registered={},this.defaults={fixed:!1,childPopover:!1,offsetY:0,offsetX:0,trigger:"click"},this.popoverDefaults={footer:!1,header:!1,title:"",direction:"above left"},this.template='
\n
\n
\n
{{macPopoverTitle}}
\n
\n
\n
',this.$get=function(){return this},this}).service("popover",["$animate","$compile","$controller","$http","$rootScope","$templateCache","$timeout","popoverViews",function(c,d,e,f,g,h,i,k){var l;return l={popoverList:[],registered:k.registered,last:function(){return this.popoverList[this.popoverList.length-1]},register:function(a,b){var c;return(c=null!=this.registered[a])||(this.registered[a]=b),!c},unregister:function(a){var b;return(b=null!=this.registered[a])&&delete this.registered[a],b},add:function(a,b,c,d){var e;return e={id:a,popover:b,element:c,options:d},this.popoverList.push(e),e},pop:function(){return this.popoverList.pop()},show:function(a,i,m){var n,o;return null==m&&(m={}),(o=this.registered[a])?(n=function(){var n,p,q;return p=function(f){var h,n,p;return j(m.scope)?p=m.scope.$new():(p=g.$new(!0),b.isObject(m.scope)&&b.extend(p,m.scope)),o.refreshOn&&p.$on(o.refreshOn,function(){return l.resize(a)}),o.controller&&e(o.controller,{$scope:p}),b.extend(p,{macPopoverClasses:{footer:o.footer||!1,header:o.header||!!o.title||!1,fixed:o.fixed||!1},macPopoverTitle:o.title||"",macPopoverTemplate:f}),h=d(k.template)(p),h.attr({id:a,direction:o.direction||"below left"}),n=l.add(a,h,i,m),c.addClass(i,"active"),g.$broadcast("popoverWasShown",a),c.enter(h,b.element(document.body),null,function(){return l.resize(n)})},(q=o.template)?p(q):(n=o.templateUrl)?(q=h.get(n),q?p(q):f.get(n).then(function(a){return h.put(n,a.data),p(a.data)},function(){throw new Error("Failed to load template: #{path}")})):void 0},l.popoverList.length&&!m.childPopover?l.hide(n):n(),!0):!1},getById:function(a,b){var c,d,e,f,g;for(g=this.popoverList,e=0,f=g.length;f>e;e++)if(c=g[e],d=null==b||c.element===b,c.id===a&&d)return c},resize:function(c){var d,e,f,g,h,i,j,k,m,n,o,p,q,r,s,t;return b.isString(c)&&(c=l.getById(c)),null!=c?(g=c.popover,p=c.element,m=c.options,d=b.element(a),k=p.offset(),m.fixed&&(k.top=p.position().top),o={height:p.outerHeight(),width:p.outerWidth()},f={height:g.outerHeight(),width:g.outerWidth()},r=0,i=0,n=(g.attr("direction")||"top left").trim(),q=function(a){var c,d;return null==a&&(a=0),c=b.element(g[0].getElementsByClassName("tip")),r-=a,d=+c.css("margin-top").replace("px",""),c.css("margin-top",d+a)},t=function(){switch(n){case"above left":return r=-(f.height+10),i=-25+o.width/2;case"above right":return r=-(f.height+10),i=25+o.width/2-f.width;case"below left":return r=o.height+10,i=-25+o.width/2;case"below right":return r=o.height+10,i=25+o.width/2-f.width;case"middle right":return r=o.height/2-f.height/2,i=o.width+10;case"middle left":return r=o.height/2-f.height/2,i=-(f.width+10)}},t(),s=m.fixed?0:d.scrollTop(),j=m.fixed?0:d.scrollLeft(),e={},-1===n.indexOf("middle")?k.top+r-s<0?e={remove:"above",add:"below"}:k.top+r+f.height-s>d.height()&&(e={remove:"below",add:"above"}):(h=k.top+r-s)<0?q(h):(h=k.top+r+g.outerHeight()-s-d.height())>0&&q(h),e.remove&&e.add&&(n=n.replace(e.remove,e.add)),e={},k.left+i-j<0?e={remove:"right",add:"left"}:k.left+i+g.outerWidth()-j>d.width()&&(e={remove:"left",add:"right"}),e.remove&&e.add&&(n=n.replace(e.remove,e.add)),t(),k.top+=r,k.left+=i,null!=m.offsetX&&(k.left+=m.offsetX),null!=m.offsetY&&(k.top+=m.offsetY),b.forEach(k,function(a,b){return isNaN(+a)||(a=""+a+"px"),g.css(b,a)}),g.addClass("visible "+n)):void 0},hide:function(a,d){var e,f,h,i,j,k,l;if(!this.popoverList.length)return"function"==typeof d?d():void 0;if(b.isFunction(a)&&(d=a,a=null),null!=a){for(e=b.isString(a)?function(b){return b.id===a}:b.isElement(a)?function(b){return b.element===a}:void 0,h=-1,f=k=l=this.popoverList.length-1;k>=0;f=k+=-1)if(e(this.popoverList[f])){i=this.popoverList[f],h=f;break}h>-1&&this.popoverList.splice(h,1)}else i=this.pop();return null!=i?(g.$broadcast("popoverBeforeHide",i.id),j=i.popover.scope(),c.leave(i.popover,function(){return c.removeClass(i.element,"active"),g.$broadcast("popoverWasHidden",i.id),j.$destroy(),"function"==typeof d?d():void 0})):void 0},hideAll:function(){for(;this.popoverList.length;)this.hide()}}}]).config(["popoverViewsProvider",function(a){return b.module("Mac").popover=function(c,d){var e;return null==a.registered[c]?(e={},b.extend(e,a.popoverDefaults,d,{id:c}),a.registered[c]=e):void 0}}]),b.module("Mac").service("scrollSpy",[function(){return{registered:[],active:{},listeners:[],register:function(a,b){var c,d,e,f,g,h,i;for(e=!1,f=b.offset().top,i=this.registered,d=g=0,h=i.length;h>g;d=++g)if(c=i[d],c.id===a){this.registered[d]={id:a,element:b,top:f},e=!0;break}return e||this.registered.push({id:a,element:b,top:f}),this.registered.sort(function(a,b){return a.top>b.top?1:a.topd;c=++d)if(b=f[c],b.id===a){[].splice.apply(this.registered,[c,c-c+1].concat(g=[])),g;break}return h},last:function(){return this.registered[this.registered.length-1]},setActive:function(a){var b,c,d,e,f;for(this.active=a,e=this.listeners,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(b(a));return f},addListener:function(a){return this.listeners.push(a)},removeListener:function(a){var b,c;return b=this.listeners.indexOf(a),-1!==b?([].splice.apply(this.listeners,[b,b-b+1].concat(c=[])),c):void 0}}}]).constant("scrollSpyDefaults",{offset:0});var w={}.hasOwnProperty;b.module("Mac.Util",[]).factory("util",["$filter",function(a){return{_inflectionConstants:{uncountables:["sheep","fish","moose","series","species","money","rice","information","info","equipment","min"],irregulars:{child:"children",man:"men",woman:"women",person:"people",ox:"oxen",goose:"geese"},pluralizers:[[/(quiz)$/i,"$1zes"],[/([m|l])ouse$/i,"$1ice"],[/(matr|vert|ind)(ix|ex)$/i,"$1ices"],[/(x|ch|ss|sh)$/i,"$1es"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/(?:([^f])fe|([lr])f)$/i,"$1$2ves"],[/sis$/i,"ses"],[/([ti])um$/i,"$1a"],[/(buffal|tomat)o$/i,"$1oes"],[/(bu)s$/i,"$1ses"],[/(alias|status)$/i,"$1es"],[/(octop|vir)us$/i,"$1i"],[/(ax|test)is$/i,"$1es"],[/x$/i,"xes"],[/s$/i,"s"],[/$/,"s"]]},pluralize:function(c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q;if(null==c&&(c=""),null==e&&(e=!1),!b.isString(c)||0===this.trim(c).length)return c;if(e&&isNaN(+d))return"";if(null==d&&(d=2),q=this._inflectionConstants,l=q.pluralizers,m=q.uncountables,f=q.irregulars,n=c.split(/\s/).pop(),g=n.toUpperCase()===n,h=n.toLowerCase(),j=1===d||m.indexOf(h)>=0?n:null,null==j&&null!=f[h]&&(j=f[h]),null==j)for(o=0,p=l.length;p>o;o++)if(k=l[o],k[0].test(h)){j=n.replace(k[0],k[1]);break}return j||(j=n),g&&(j=j.toUpperCase()),i=c.slice(0,-n.length)+j,e?""+a("number")(d)+" "+i:i},trim:function(a){var b;return b=String(a)||"",null!=String.prototype.trim?b.trim():b.replace(/^\s+|\s+$/gm,"")},capitalize:function(a){var b;return b=String(a)||"",b.charAt(0).toUpperCase()+b.substring(1)},uncapitalize:function(a){var b;return b=String(a)||"",b.charAt(0).toLowerCase()+b.substring(1)},toCamelCase:function(a){return null==a&&(a=""),this.trim(a).replace(/[-_\s]+(.)?/g,function(a,b){return b.toUpperCase()})},toSnakeCase:function(a){return null==a&&(a=""),this.trim(a).replace(/([a-z\d])([A-Z]+)/g,"$1_$2").replace(/[-\s]+/g,"_").toLowerCase()},convertKeysToCamelCase:function(a){var b,c,d;c={};for(b in a)w.call(a,b)&&(d=a[b],b=this.toCamelCase(b),"object"==typeof d&&(null!=d?d.constructor:void 0)!==Array&&(d=this.convertKeysToCamelCase(d)),c[b]=d);return c},convertKeysToSnakeCase:function(a){var b,c,d;c={};for(b in a)w.call(a,b)&&(d=a[b],b=this.toSnakeCase(b),"object"==typeof d&&(null!=d?d.constructor:void 0)!==Array&&(d=this.convertKeysToSnakeCase(d)),c[b]=d);return c},pyth:function(a,b){return Math.sqrt(a*a+b*b)},degrees:function(a){return 180*a/Math.PI},radian:function(a){return a*Math.PI/180},hex2rgb:function(a){var b,c,d;0===a.indexOf("#")&&(a=a.substring(1)),a=a.toLowerCase(),c={},3===a.length?(c.r=a.charAt(0)+a.charAt(0),c.g=a.charAt(1)+a.charAt(1),c.b=a.charAt(2)+a.charAt(2)):(c.r=a.substring(0,2),c.g=a.substring(2,4),c.b=a.substring(4));for(b in c)d=c[b],c[b]=parseInt(d,16);return c},timeRegex:/^(0?[1-9]|1[0-2]):([0-5][0-9])[\s]([AP]M)$/,_urlRegex:/(?:(http[s]?):\/\/)?(?:(www|[\d\w\-]+)\.)?([\d\w\-]+)\.([A-Za-z]{2,6})(:[\d]*)?([:\/?#\[\]@!$&'()*+,;=\w\d-._~%\\]*)?/i,_emailRegex:/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/,validateUrl:function(a){var b;return b=this._urlRegex.exec(a),null!=b&&(b={url:b[0],protocol:b[1]||"http",subdomain:b[2],name:b[3],domain:b[4],port:b[5],path:b[6]||"/"},b.url=b.url),b},validateEmail:function(a){return this._emailRegex.test(a)},getQueryString:function(a,b){var c,d,e;return null==b&&(b=""),b=b.replace(/[[]/,"[").replace(/[]]/,"]"),d="[?&]"+b+"=([^&#]*)",c=new RegExp(d),e=c.exec(a),null!=e?e[1]:""},parseUrlPath:function(a){var b,c,d,e,f,g,h,i,j,k,l;if(g=a.split("?"),c=g[0].split("/"),b=c.slice(0,c.length-1).join("/"),i=c[c.length-1],d={},g.length>1)for(f=g[g.length-1],l=f.split("&"),j=0,k=l.length;k>j;j++)e=l[j],h=e.split("="),d[h[0]]=null!=h[1]?h[1]:"";return{fullPath:a,path:b,pathComponents:c,verb:i,queries:d}},extendAttributes:function(a,b,c){var d,e,f,g,h,i,j;null==a&&(a=""),g={};for(e in b)w.call(b,e)&&(h=b[e],d=a?this.capitalize(e):e,f=""+a+d,g[e]=null!=c[f]?c[f]||!0:h,"true"===(i=g[e])||"false"===i?g[e]="true"===g[e]:(null!=(j=g[e])?j.length:void 0)>0&&!isNaN(+g[e])&&(g[e]=+g[e]));return g}}}])}(window,window.angular); \ No newline at end of file +!function(a,b){var c,d,e,f,g,h,i,j,k,l,m,n;m=["Mac.Util"];try{b.module("ngAnimate"),m.push("ngAnimate")}catch(o){}b.module("Mac",m),e=["Top","Right","Bottom","Left"],d=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,n=new RegExp("^("+d+")(?!px)[a-z%]+$","i"),g=function(b){return a.getComputedStyle(b,null)},k=function(a){return a&&a.document&&a.location&&a.alert&&a.setInterval},j=function(a){return a&&null!=a.$evalAsync&&null!=a.$watch},i=function(a){return k(a)?a:9===a.nodeType&&a.defaultView},c=function(a,b,c,d,f){var g,h,i,j;if(c===(d?"border":"content"))return 0;for(i=0,h="Width"===b?1:0,g=j=h;3>=j;g=j+=2)"margin"===c&&(i+=parseFloat(f[""+c+e[g]])),d?("content"===c&&(i-=parseFloat(f["padding"+e[g]])),"margin"!==c&&(i-=parseFloat(f["border"+e[g]]))):(i+=parseFloat(f["padding"+e[g]]),"padding"!==c&&(i+=parseFloat(f["border"+e+"Width"])));return i},h=function(a,b,d){return function(e){var f,h,i,j,l,m,o,p;if(f=function(){switch(b){case"inner":return"padding";case"outer":return"";default:return"content"}}(),i=f||(e===!0?"margin":"border"),k(d))return d.document.documentElement["client"+a];if(9===d.nodeType)return h=d.documentElement,Math.max(d.body["scroll"+a],h["scroll"+a],d.body["offset"+a],h["offset"+a],h["client"+a]);if(p=!0,m=g(d),l=a.toLowerCase(),o="Height"===a?d.offsetHeight:d.offsetWidth,j="border-box"===d.style.boxSizing,0>=o||null===o){if(o=m[l],(0>o||null===o)&&(o=d.style[l]),n.test(o))return o;p=j,o=parseFloat(o)||0}return o+c(d,a,i||(j?"border":"content"),p,m)}},l={height:function(a){return h("Height","",a)()},width:function(a){return h("Width","",a)()},outerHeight:function(a,b){return h("Height","outer",a)(b)},outerWidth:function(a,b){return h("Width","outer",a)(b)},offset:function(a){var b,c,d,e;return b={top:0,left:0},(c=a&&a.ownerDocument)?(d=c.documentElement,null!=a.getBoundingClientRect&&(b=a.getBoundingClientRect()),e=i(c),{top:b.top+e.pageYOffset-d.clientTop,left:b.left+e.pageXOffset-d.clientLeft}):void 0},scrollTop:function(b,c){var d;return d=i(b),null==c?d?d.pageYOffset:b.scrollTop:d?d.scrollTo(a.pageYOffset,c):b.scrollTop=c},scrollLeft:function(b,c){var d;return d=i(b),null==c?d?d.pageXOffset:b.scrollLeft:d?d.scrollTo(a.pageXOffset,c):b.scrollLeft=c}},f=function(){var c;if(null==a.jQuery||null==b.element.prototype.offset)return c=b.element,b.forEach(l,function(a,b){return c.prototype[b]=function(b,c){return this.length?a(this[0],b,c):void 0}})},f(),b.module("Mac").directive("macAffix",["$document","$window",function(a,c){return{link:function(d,e,f){var g,h,i,j,k,l,m,n,o,p;return g={top:0,bottom:0,disabled:!1,classes:"affix affix-top affix-bottom"},k={top:g.top,bottom:g.bottom},h=g.disabled,j=null,o=null,l=null,p=b.element(c),n=function(a,b,c){return null==c&&(c=!1),c&&null==b&&(b=g[a]),null==b||isNaN(+b)?void 0:k[a]=+b},null!=f.macAffixTop&&(n("top",d.$eval(f.macAffixTop),!0),d.$watch(f.macAffixTop,function(a){return n("top",a)})),null!=f.macAffixBottom&&(n("bottom",d.$eval(f.macAffixBottom),!0),d.$watch(f.macAffixBottom,function(a){return n("bottom",a)})),i=function(){var b;return null!=l?l:(e.removeClass(g.classes).addClass("affix"),b=a.height(),l=b-e.outerHeight()-k.bottom)},m=function(){var b,c,d,f,h,l;if(!(e[0].offsetHeight<=0&&e[0].offsetWidth<=0)&&(f=e.offset(),l=p.scrollTop(),h=a.height(),d=e.outerHeight(),b=null!=o&&o>=l?!1:null!=k.bottom&&l>h-d-k.bottom?"bottom":null!=k.top&&l<=k.top?"top":!1,b!==j))return o&&e.css("top",""),j=b,o="bottom"===b?i():null,e.removeClass(g.classes).addClass("affix"+(b?"-"+b:"")),"bottom"===b&&(c=e.offset(),e.css("top",o-c.top)),!0},null!=f.macAffixDisabled&&(h=d.$eval(f.macAffixDisabled)||g.disabled,d.$watch(f.macAffixDisabled,function(a){var b;if(null!=a&&a!==h)return h=a,b=a?"unbind":"bind",p[b]("scroll",m),h?(j=null,o=null,e.css("top","").removeClass(g.classes)):m()})),h||p.bind("scroll",m),d.$on("refresh-mac-affix",function(){var a;return a=e.offset()}),d.$on("$destroy",function(){return p.unbind("scroll",m)})}}}]),b.module("Mac").directive("macAutocomplete",["$animate","$compile","$filter","$http","$parse","$rootScope","$timeout","keys",function(c,d,e,f,g,h,i,j){return{restrict:"EA",template:'',transclude:!0,replace:!0,require:"ngModel",link:function(h,k,l,m,n){var o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L;return z=l.macAutocompleteLabel||"name",y=g(z),H=l.macAutocompleteQuery||"q",t=+(l.macAutocompleteDelay||800),w=null!=l.macAutocompleteInside,q=g(l.macAutocompleteUrl),C=g(l.macAutocompleteOnSelect),D=g(l.macAutocompleteOnSuccess),B=g(l.macAutocompleteOnError),J=g(l.macAutocompleteSource),u=g(l.macAutocompleteDisabled),s=[],K=null,x=!1,F=!1,o=h.$new(),o.items=[],o.index=0,o.select=function(a){var b,c;return c=s[a],C(h,{selected:c}),b=o.items[a].label||"",F=!0,null!=l.ngModel&&(m.$setViewValue(b),m.$render()),I()},A=b.element(document.createElement("mac-menu")),A.attr({"ng-class":l.macMenuClass||"","mac-menu-items":"items","mac-menu-select":"select(index)","mac-menu-index":"index"}),n(o,function(a){return A.append(a)}),d(A)(o),m.$parsers.push(function(a){return!a||u(h)||F?I():(null!=K&&i.cancel(K),t>0?K=i(function(){return G(a)},t):G(a)),F=!1,a}),r=function(){return h.$apply(function(){return I()})},p=function(){return x||(k.bind("blur",r),A.on("mousedown",function(a){return a.preventDefault()})),x=!0,w?c.enter(A,void 0,k):c.enter(A,b.element(document.body))},I=function(){return c.leave(A).then(function(){return o.index=0,o.items.length=0,A[0].style.top="",A[0].style.left="",x=!1,k.unbind("blur",r)})},E=function(){var c,d,e;return d=w?k[0]:document.body,e=a.getComputedStyle(d),c=k.offset(),c.left-=parseInt(e.marginLeft),c.top+=k.outerHeight()-parseInt(e.marginTop),c.minWidth=k.outerWidth(),b.forEach(c,function(a,c){return!isNaN(+a)&&b.isNumber(+a)&&(a=""+a+"px"),A[0].style[c]=a})},L=function(a){return(null!=a?a.length:void 0)>0?(s=a,o.items=a.map(function(a){return b.isObject(a)?(null==a.value&&(a.value=y(a)||""),null==a.label&&(a.label=y(a)||""),a):{label:a,value:a}}),p().then(E)):I()},v=function(a,b){var c;return c={method:"GET",url:a,params:{}},c.params[H]=b,f(c).success(function(a,b,c){var d;return d=D(h,{data:a,status:b,headers:c}),null==d&&(d=a.data),L(d)}).error(function(a,b,c){return B(h,{data:a,status:b,headers:c})})},G=function(a){var c,d;return d=q(h),d?v(d,a):(c=J(h),b.isArray(c)?L(e("filter")(c,a)):b.isString(c)?v(c,a):b.isFunction(c)?c(a,L):void 0)},k.bind("keydown",function(a){if(0===o.items.length)return!0;switch(a.which){case j.DOWN:h.$apply(function(){return o.index=(o.index+1)%o.items.length,a.preventDefault()});break;case j.UP:h.$apply(function(){return o.index=(o.index?o.index:o.items.length)-1,a.preventDefault()});break;case j.ENTER:h.$apply(function(){return o.select(o.index),a.preventDefault()});break;case j.ESCAPE:h.$apply(function(){return I(),a.preventDefault()})}return!0}),h.$on("$destroy",function(){return o.$destroy(),I()}),h.$on("reset-mac-autocomplete",function(){return I()})}}}]),b.module("Mac").directive("macCspinner",["$timeout","util",function(c,d){return{restrict:"E",replace:"true",template:'
',compile:function(e,f){var g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F;if(!a.HTMLCanvasElement)return console.log("Browser does not support canvas");if(j={width:2,height:5,border:1,radius:4,bars:10,padding:3,speed:100,color:"#2f3035",size:20},q=d.extendAttributes("macCspinner",j,f),null!=f.macCspinnerSize&&(x=!isNaN(+f.macCspinnerSize)&&+f.macCspinnerSize))for(t=x/j.size,E=["width","height","border","radius"],B=0,D=E.length;D>B;B++)r=E[B],q[r]=j[r]*t;for(A=q.width,k=q.height,s=q.border,o=q.radius+k,n=Math.max(A,o),h=Math.ceil(Math.max(n,d.pyth(o,A/2))),h+=q.padding,y=b.element(""),i=y[0].getContext("2d"),v=d.radian(360/q.bars),i.translate(h,h),z=-o,m=-A/2,u=d.hex2rgb(q.color),l=C=0,F=q.bars-1;F>=0?F>=C:C>=F;l=F>=0?++C:--C)p=1-.8/q.bars*l,i.fillStyle="rgba("+u.r+", "+u.g+", "+u.b+", "+p+")",i.beginPath(),i.moveTo(m+s,z),i.arc(m+A-s,z+s,s,d.radian(-90),d.radian(0),!1),i.arc(m+A-s,z+k-s,s,d.radian(0),d.radian(90),!1),i.arc(m+s,z+k-s,s,d.radian(90),d.radian(180),!1),i.arc(m+s,z+s,s,d.radian(-180),d.radian(-90),!1),i.closePath(),i.fill(),i.rotate(v);return g=b.element(""),g.attr({width:2*h,height:2*h}),w=g[0].getContext("2d"),w.translate(h,h),e.append(g),function(a,b,e){var f,g,i,j;return f=null,g=!1,j=function(){return g=!1,null!=f?c.cancel(f):void 0},i=function(){var a,e;if(!g)return g=!0,e=d.radian(360/q.bars),(a=function(d){return null==d&&(d=!1),w.clearRect(-h,-h,2*h,2*h),w.rotate(e),w.drawImage(y[0],-h,-h),g?!d&&b[0].offsetHeight<=0&&b[0].offsetWidth<=0?j():f=c(a,q.speed,!1):void 0})(!0)},null!=e.macCspinnerSpin?a.$watch(e.macCspinnerSpin,function(a){return a&&!g?i():j()}):i(),e.ngShow?a.$watch(e.ngShow,function(a){return a?i():j()}):e.ngHide&&a.$watch(e.ngHide,function(a){return a?j():i()}),a.$on("$destroy",function(){return j()})}}}}]);var p,q,r,s,t;for(t=["Enter","Escape","Space","Left","Up","Right","Down"],q=function(a){return b.module("Mac").directive("macKeydown"+a,["$parse","keys",function(b,c){return{restrict:"A",link:function(d,e,f){var g;return g=b(f["macKeydown"+a]),e.bind("keydown",function(b){return b.which===c[""+a.toUpperCase()]?(b.preventDefault(),d.$apply(function(){return g(d,{$event:b})})):void 0})}}}])},r=0,s=t.length;s>r;r++)p=t[r],q(p);b.module("Mac").directive("macPauseTyping",["$parse","$timeout",function(a,b){return{restrict:"A",link:function(c,d,e){var f,g,h;return g=a(e.macPauseTyping),f=c.$eval(e.macPauseTypingDelay)||800,h=null,d.bind("keyup",function(a){return null!=h&&b.cancel(h),h=b(function(){return g(c,{$event:a})},f)})}}}]),b.module("Mac").directive("macWindowResize",["$parse","$window",function(a,c){return{restrict:"A",link:function(d,e,f){var g;return g=function(b){var c;return c=a(f.macWindowResize),d.$apply(function(){return c(d,{$event:b})}),!0},b.element(c).bind("resize",g),d.$on("destroy",function(){return b.element(c).unbind("resize",g)})}}}]),b.module("Mac").directive("macFocusOnEvent",["$timeout",function(b){return function(c,d,e){return c.$on(e.macFocusOnEvent,function(){return b(function(){var b,c;return d.focus(),e.macFocusOnEventScroll?(b=a.scrollX,c=a.scrollY,a.scrollTo(b,c)):void 0},0,!1)})}}]),b.module("Mac").factory("keys",function(){return{CANCEL:3,HELP:6,BACKSPACE:8,TAB:9,CLEAR:12,ENTER:13,RETURN:13,SHIFT:16,CONTROL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,ESCAPE:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PRINT_SCREEN:44,INSERT:45,DELETE:46,ZERO:48,ONE:49,TWO:50,THREE:51,FOUR:52,FIVE:53,SIX:54,SEVEN:55,EIGHT:56,NINE:57,SEMICOLON:59,EQUALS:61,COMMAND:91,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,CONTEXT_MENU:93,NUMPAD0:96,NUMPAD1:97,NUMPAD2:98,NUMPAD3:99,NUMPAD4:100,NUMPAD5:101,NUMPAD6:102,NUMPAD7:103,NUMPAD8:104,NUMPAD9:105,MULTIPLY:106,ADD:107,SEPARATOR:108,SUBTRACT:109,DECIMAL:110,DIVIDE:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,F13:124,F14:125,F15:126,F16:127,F17:128,F18:129,F19:130,F20:131,F21:132,F22:133,F23:134,F24:135,NUM_LOCK:144,SCROLL_LOCK:145,COMMA:188,PERIOD:190,SLASH:191,BACK_QUOTE:192,OPEN_BRACKET:219,BACK_SLASH:220,CLOSE_BRACKET:221,QUOTE:222,META:224}}),b.module("Mac").directive("macMenu",[function(){return{restrict:"EA",replace:!0,template:'
',transclude:!0,controller:b.noop,scope:{items:"=macMenuItems",style:"=macMenuStyle",select:"&macMenuSelect",pIndex:"=macMenuIndex"},link:function(a,b,c){return a.selectItem=function(b){return a.select({index:b})},a.setIndex=function(b){return a.index=b,null!=c.macMenuIndex?a.pIndex=parseInt(b):void 0},null!=c.macMenuIndex&&a.$watch("pIndex",function(b){return a.index=parseInt(b)}),a.$watch("items.length",function(a){return a?c.$addClass("visible"):c.$removeClass("visible")})}}}]).directive("macMenuTransclude",["$compile",function(a){return{link:function(b,c,d,e,f){return f(b,function(d){return c.empty(),0===d.length&&(d=a("{{item.label}}")(b)),c.append(d)})}}}]),b.module("Mac").directive("macModal",["$parse","modal","util",function(a,c,d){return{restrict:"E",template:c.modalTemplate,replace:!0,transclude:!0,link:function(e,f,g,h,i){var j,k,l,m,n,o,p,q;for(i(e,function(a){return b.element(f[0].getElementsByClassName("mac-modal-content-wrapper")).replaceWith(a)}),l=d.extendAttributes("macModal",c.defaults,g),m=null,l.overlayClose&&f.on("click",function(a){return b.element(a.target).hasClass("mac-modal-overlay")?e.$apply(function(){return c.hide()}):void 0}),q=["beforeShow","afterShow","beforeHide","afterHide","open"],o=0,p=q.length;p>o;o++)j=q[o],k="macModal"+d.capitalize(j),l[j]=a(g[k])||b.noop;return n=function(a){return null!=a&&a?(m=a,c.register(a,f,l)):void 0},g.id?n(g.id):g.$observe("macModal",function(a){return n(a)}),e.$on("$destroy",function(){return m?c.unregister(m):void 0})}}}]).directive("macModal",["$parse","modal",function(a,b){return{restrict:"A",link:function(c,d,e){e.macModal&&d.bind("click",function(){return c.$apply(function(){var d;return d=a(e.macModalData)(c)||{},b.show(e.macModal,{data:d,scope:c})})})}}}]).directive("macModalClose",["modal",function(a){return{restrict:"A",link:function(b,c){return c.bind("click",function(){return b.$apply(function(){return a.hide()})})}}}]),b.module("Mac").directive("macPlaceholder",function(){return{restrict:"A",link:function(a,b,c){return a.$watch(c.macPlaceholder,function(a){return c.$set("placeholder",a)})}}});var u=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};b.module("Mac").directive("macPopover",["$timeout","popover","util",function(a,b,c){return{restrict:"A",link:function(d,e,f){var g,h,i,j,k,l,m,n;return m=c.extendAttributes("macPopover",b.defaults,f),j=f.macPopoverExclude||"",k=j?j.split(","):[],i=null,h=null,g=function(){return null!=i&&a.cancel(i),null!=h?a.cancel(h):void 0},n=function(c,f){return null==f&&(f=0),g(),i=a(function(){var a,f;return a=b.last(),null!=a&&(!k.length||(f=a.id,u.call(k,f)>=0)||a.id===c)&&(b.hide(),e[0]===a.element[0])?!0:(m.scope=d,b.show(c,e,m))},f),!0},l=function(c,d){return null==d&&(d=0),g(),h=a(function(){return b.hide(c)},d)},f.$observe("macPopover",function(a){var b,c;if(a)return"click"===m.trigger?e.bind("click",function(){return n(a,0)}):(c="focus"===m.trigger?"focusin":"mouseenter",b="focus"===m.trigger?"focusout":"mouseleave",e.bind(c,function(){return n(a,400)}),e.bind(b,function(){return l(e,500)}))})}}}]).directive("macPopover",["popover","util",function(a,c){return{restrict:"E",compile:function(d,e){var f;if(!e.id)throw Error("macPopover: Missing id");return f=c.extendAttributes("macPopover",a.popoverDefaults,e),b.extend(f,{template:d.html()}),function(b,c,d){return d.$observe("id",function(b){return a.register(b,f),c.replaceWith(document.createComment("macPopover: "+d.id))})}}}}]).directive("macPopoverFillContent",["$compile",function(a){return{restrict:"A",link:function(b,c){return c.html(b.macPopoverTemplate),a(c.contents())(b)}}}]),b.module("Mac").directive("macScrollSpy",["$window","scrollSpy","scrollSpyDefaults","util",function(a,c,d,e){return{link:function(f,g,h){var i,j;return i=e.extendAttributes("macScrollSpy",d,h),j="BODY"===g[0].tagName?b.element(a):g,j.bind("scroll",function(){var a,b,d,e,h,k,l;if(h=j.scrollTop()+i.offset,e=this.scrollHeight||g[0].scrollHeight,d=e-j.height(),!c.registered.length)return!0;if(h>=d)return c.setActive(c.last());for(b=k=0,l=c.registered.length-1;l>=0?l>=k:k>=l;b=l>=0?++k:--k)if(a=c.registered,c.active.id!==a[b].id&&h>=a[b].top&&(!a[b+1]||h<=a[b+1].top))return f.$apply(function(){return c.setActive(a[b])}),!0})}}}]).directive("macScrollSpyAnchor",["scrollSpy",function(a){return{link:function(b,c,d){var e,f,g,h;if(e=d.id||d.macScrollSpyAnchor,g=!1,!e)throw new Error("Missing scroll spy anchor id");return h=function(){return a.register(e,c),g||b.$on("$destroy",function(){return a.unregister(e)}),g=!0},b.$on("refresh-scroll-spy",h),/{{(.*)}}/.test(e)?(f=d.id?"id":"macScrollSpyAnchor",d.$observe(f,function(a){return null!=a&&a?(e=a,h()):void 0})):h()}}}]).directive("macScrollSpyTarget",["scrollSpy",function(a){return{link:function(b,c,d){var e,f,g,h;if(h=d.macScrollSpyTarget,e=d.macScrollSpyTargetClass||"active",g=!1,!h)throw new Error("Missing scroll spy target name");return f=function(d){var f;if(d)return f=function(a){var b;return b=d===a.id?"addClass":"removeClass",c[b](e)},null!=a.active&&f(a.active),g?void 0:(a.addListener(f),b.$on("$destroy",function(){return a.removeListener(f)}))},/{{(.*)}}/.test(h)?d.$observe("macScrollSpyTarget",function(a){return f(a)}):f(h)}}}]),b.module("Mac").directive("macSpinner",["util",function(a){return{restrict:"E",replace:!0,template:'
',compile:function(c){var d,e,f,g,h,i,j,k,l,m,n,o;for(j=["webkit","Moz","ms","O"],f=[],n=function(b,c){var d,e,f;for(c=a.capitalize(c),e=0,f=j.length;f>e;e++)if(d=j[e],null!=b.style[d+c])return d+c;return c},m=function(a,c){var d,e,g,h,i,j;{if(!b.isObject(a)){for(j=[],h=0,i=f.length;i>h;h++)d=f[h],j.push(d.style[a]=c);return j}for(e in a)g=a[e],m(e,g)}},d=n(c[0],"animation"),l=n(c[0],"transform"),i=o=0;9>=o;i=++o)h=.1*i-1+!i,g=36*i,k={},e=b.element('
'),f.push(e[0]),k[d]="fade 1s linear infinite "+h+"s",k[l]="rotate("+g+"deg) translate(0, 130%)",e.css(k),c.append(e);return function(a,c,d){var e,f;return e={size:16,zIndex:"inherit",color:"#2f3035"},f=function(a){return m({height:.32*a+"px",left:.445*a+"px",top:.37*a+"px",width:.13*a+"px",borderRadius:.32*a*2+"px",position:"absolute"}),!isNaN(+a)&&b.isNumber(+a)&&(a=""+a+"px"),c.css({height:a,width:a})},null!=d.macSpinnerSize?d.$observe("macSpinnerSize",function(a){return null!=a&&a?f(a):void 0}):f(e.size),d.$observe("macSpinnerZIndex",function(a){return null!=a&&a?c.css("z-index",a):void 0}),null!=d.macSpinnerColor?d.$observe("macSpinnerColor",function(a){return null!=a&&a?m("background",a):void 0}):m("background",e.color)}}}}]);var u=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};b.module("Mac").directive("macTagAutocomplete",["$parse","$timeout","keys","util",function(a,c,d,e){return{restrict:"E",template:'
',replace:!0,priority:800,scope:{url:"=macTagAutocompleteUrl",placeholder:"=macTagAutocompletePlaceholder",selected:"=macTagAutocompleteSelected",source:"=macTagAutocompleteSource",disabled:"=macTagAutocompleteDisabled",model:"=macTagAutocompleteModel",onEnter:"&macTagAutocompleteOnEnter",onKeydown:"&macTagAutocompleteOnKeydown"},compile:function(f,g){var h,i,j,k,l,m,n,o,p;return p=g.macTagAutocompleteValue,null==p&&(p="id"),o=a(p),k=g.macTagAutocompleteLabel,null==k&&(k="name"),j=a(k),l=g.macTagAutocompleteQuery||"q",i=+g.macTagAutocompleteDelay||800,n=!1,m=b.element(f[0].getElementsByClassName("mac-autocomplete")),h={"mac-autocomplete-label":k,"mac-autocomplete-query":l,"mac-autocomplete-delay":i},null!=g.macTagAutocompleteUrl?h["mac-autocomplete-url"]="url":(n=null!=g.macTagAutocompleteSource)&&(h["mac-autocomplete-source"]="autocompleteSource"),m.attr(h),function(f,g,h){var i,l;return f.textInput="",f.autocompleteSource=b.isArray(f.source)?[]:f.source,null!=h.macTagAutocompleteModel&&(f.$watch("textInput",function(a){return f.model=a}),f.$watch("model",function(a){return f.textInput=a})),g.bind("click",function(){var a;return a=g[0].getElementsByClassName("mac-autocomplete"),a[0].focus()}),f.getTagLabel=function(a){return k?j(a):a},c(function(){var c,d,i,j,k,l,n,o;if(i=h.macTagAutocompleteEvents){for(m=b.element(g[0].getElementsByClassName("text-input")),n=i.split(","),o=[],k=0,l=n.length;l>k;k++)j=n[k],j=e.trim(j),c=e.capitalize(j),d=h["macTagAutocompleteOn"+c],d&&"keydown"!==j&&o.push(function(b,c){return m.bind(b,function(b){var d;return d=a(c),f.$apply(function(){return d(f.$parent,{$event:b,item:f.textInput})})})}(j,d));return o}},0,!1),i=function(){var a,c,d,e,g;return f.autocompletePlaceholder=(null!=(g=f.selected)?g.length:void 0)?"":f.placeholder,n&&b.isArray(f.source)?(e=function(){var a,b,d,e;for(d=f.source||[],e=[],a=0,b=d.length;b>a;a++)c=d[a],e.push(o(c));return e}(),d=function(){var a,b,d,e;for(d=f.selected||[],e=[],a=0,b=d.length;b>a;a++)c=d[a],e.push(o(c));return e}(),a=function(){var a,b,f;for(f=[],a=0,b=e.length;b>a;a++)c=e[a],u.call(d,c)<0&&f.push(c);return f}(),f.autocompleteSource=function(){var b,d,e,g,h;for(e=f.source||[],h=[],b=0,d=e.length;d>b;b++)c=e[b],g=o(c),u.call(a,g)>=0&&h.push(c);return h}()):void(f.autocompleteSource=f.source)},n&&(l=b.isArray(f.source)?"$watchCollection":"$watch",f[l]("source",i)),f.$watchCollection("selected",i),f.onKeyDown=function(a){var b,c;switch(b=a.which||a.keyCode){case d.BACKSPACE:f.textInput||"function"==typeof(c=f.selected).pop&&c.pop();break;case d.ENTER:f.textInput.length>0&&f.disabled&&f.onSelect(f.textInput)}return null!=h.macTagAutocompleteOnKeydown&&"function"==typeof f.onKeydown&&f.onKeydown({$event:a,value:f.textInput}),!0},f.onSuccess=function(a){var b,c;return b=function(){var a,b,d,e;for(d=f.selected||[],e=[],a=0,b=d.length;b>a;a++)c=d[a],e.push(o(c));return e}(),function(){var d,e,f,g,h;for(f=a.data,h=[],d=0,e=f.length;e>d;d++)c=f[d],g=o(c)||c,u.call(b,g)<0&&h.push(c);return h}()},f.onSelect=function(a){return null!=h.macTagAutocompleteOnEnter&&(a=f.onEnter({item:a})),a&&f.selected.push(a),c(function(){return f.textInput=""},0)},f.$on("mac-tag-autocomplete-clear-input",function(){return f.textInput=""})}}}}]),b.module("Mac").directive("macTime",["$filter","$timeout","keys","util",function(a,b,c,d){var e;return e={"default":"12:00 AM"},{restrict:"E",require:"ngModel",replace:!0,template:'',link:function(f,g,h,i){var j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;return n=d.extendAttributes("macTime",e,h),v=null,h.placeholder||h.$set("placeholder","--:--"),w=function(a){return!a||d.timeRegex.exec(a)?(i.$setValidity("time",!0),a):void i.$setValidity("time",!1)},i.$formatters.push(w),i.$parsers.push(w),(m=function(){var a;return a=(new Date).toDateString(),v=new Date(a+" "+n["default"]),isNaN(v.getTime())?v=new Date(a+" "+e["default"]):void 0})(),j=function(){var a;switch(a=g[0].selectionStart,!1){case!(a>=0&&3>a):return"hour";case!(a>=3&&6>a):return"minute";case!(a>=6&&9>a):return"meridian"}},t=function(a,c){return b(function(){return g[0].setSelectionRange(a,c)},0,!1)},o=function(){return t(0,2)},q=function(){return t(3,5)},p=function(){return t(6,8)},r=function(){switch(j()){case"hour":return q();case"minute":case"meridian":return p()}},s=function(){switch(j()){case"hour":case"minute":return o();case"meridian":return q()}},u=function(a){var b;return b=v.getHours(),b>=12&&"AM"===a&&(b-=12),12>b&&"PM"===a&&(b+=12),v.setHours(b)},x=function(){var a;return a=v.getHours(),v.setHours((a+12)%24)},k=function(a){return v.setHours(v.getHours()+a)},l=function(a){return v.setMinutes(v.getMinutes()+a)},y=function(){var b;return b=a("date")(v.getTime(),"hh:mm a"),b!==i.$viewValue?(i.$setViewValue(b),i.$render()):void 0},z=function(){var a,b,c,e;return(e=d.timeRegex.exec(i.$modelValue))?(a=+e[1],c=+e[2],b=e[3],"PM"===b&&12!==a&&(a+=12),"AM"===b&&12===a&&(a=0),v.setHours(a,c)):void 0},g.on("blur",function(){return f.$apply(function(){return y()})}),g.on("click",function(){return f.$apply(function(){switch(z(),y(),j()){case"hour":return o();case"minute":return q();case"meridian":return p()}})}),g.on("keydown",function(a){var b;return b=a.which,b!==c.UP&&b!==c.DOWN&&b!==c.LEFT&&b!==c.RIGHT&&b!==c.A&&b!==c.P?!0:(a.preventDefault(),f.$apply(function(){var a,d;switch(b){case c.UP:case c.DOWN:switch(a=b===c.UP?1:-1,j()){case"hour":k(a),o();break;case"minute":l(a),q();break;case"meridian":x(),p()}return y();case c.LEFT:case c.RIGHT:switch(b){case c.LEFT:s();break;case c.RIGHT:r()}return y();case c.A:case c.P:switch(d="meridian"===j(),!1){case!(d&&b===c.A):u("AM");break;case!(d&&b===c.P):u("PM")}return y(),p()}}))}),g.on("keyup",function(a){var b;return b=a.which,c.NUMPAD0<=b&&b<=c.NUMPAD9||c.ZERO<=b&&b<=c.NINE||a.preventDefault(),f.$apply(function(){return z()})})}}}]),b.module("Mac").directive("macTooltip",["$timeout","util",function(a,c){return{restrict:"A",link:function(d,e,f){var g,h,i,j,k,l,m,n,o,p;return p=null,n="",j=!1,i=!1,g=null,h={direction:"top",trigger:"hover",inside:!1},k=c.extendAttributes("macTooltip",h,f),m=function(){var a,c,d,f;if(i||!n||null!=p)return!0;switch(d=k.inside?e:b.element(document.body),l(0),p=b.element('
'+n+"
"),d.append(p),c=k.inside?{top:0,left:0}:e.offset(),a={width:e.outerWidth(),height:e.outerHeight()},f={width:p.outerWidth(),height:p.outerHeight()},k.direction){case"bottom":case"top":c.left+=a.width/2-f.width/2;break;case"left":case"right":c.top+=a.height/2-f.height/2}switch(k.direction){case"bottom":c.top+=a.height;break;case"top":c.top-=f.height;break;case"left":c.left-=f.width;break;case"right":c.left+=a.width}return c.top=Math.max(0,c.top),c.left=Math.max(0,c.left),b.forEach(c,function(a,c){return!isNaN(+a)&&b.isNumber(+a)&&(a=""+a+"px"),p.css(c,a)}),p.addClass("visible"),!0},l=function(b){return null==b&&(b=100),null!=p&&null==g&&(p.removeClass("visible"),g=a(function(){return null!=p&&p.remove(),p=null,g=null},b,!1)),!0},o=function(){return null!=p?l():m()},f.$observe("macTooltip",function(a){var b;if(null!=a&&(n=a,!j)){if("hover"!==(b=k.trigger)&&"click"!==b)throw"Invalid trigger";switch(k.trigger){case"click":e.bind("click",o);break;case"hover":e.bind("mouseenter",m),e.bind("mouseleave click",function(){return l()})}return j=!0}}),null!=f.macTooltipDisabled&&d.$watch(f.macTooltipDisabled,function(a){return i=a}),d.$on("$destroy",function(){return null!=p?l(0):void 0})}}}]),b.module("Mac").filter("boolean",function(){return function(a,b,c){return null==b&&(b="true"),null==c&&(c="false"),a?b:c}}),b.module("Mac").filter("true",function(){return function(a,b){return null==b&&(b="true"),a?b:""}}),b.module("Mac").filter("false",function(){return function(a,b){return null==b&&(b="false"),a?"":b}}),b.module("Mac").filter("list",[function(){return function(a,b){return null==b&&(b=", "),a.join(b)}}]),b.module("Mac").filter("pluralize",["util",function(a){return function(b,c,d){return null==d&&(d=!0),a.pluralize(b,c,d)}}]),b.module("Mac").filter("timestamp",["util",function(a){var b;return b=function(b,c){return c=a.pluralize(c,b),""+b+" "+c+" ago"},function(a){var c,d,e,f,g,h,i,j;return a=+a,c=Math.round(Date.now()/1e3),h=c-a,45>h?"just now":120>h?"about a minute ago":(j=Math.floor(h/31536e3),j>0?b(j,"year"):(g=Math.floor(h/2678400),g>0?b(g,"month"):(i=Math.floor(h/604800),i>0?b(i,"week"):(d=Math.floor(h/86400),d>0?b(d,"day"):(e=Math.floor(h/3600),e>0?b(e,"hour"):(f=Math.floor(h/60),f>0?b(f,"min"):""+h+" seconds ago"))))))}}]);var v=[].slice;b.module("Mac").filter("underscoreString",function(){return function(){var a,b,c;return c=arguments[0],a=arguments[1],b=3<=arguments.length?v.call(arguments,2):[],b.unshift(c),_.string[a].apply(this,b)}}),b.module("Mac").provider("modal",function(){var c,d;this.registered=d={},this.defaults=c={keyboard:!1,overlayClose:!1,resize:!0,position:!0,open:b.noop,topOffset:20,attributes:{},beforeShow:b.noop,afterShow:b.noop,beforeHide:b.noop,afterHide:b.noop},this.$get=["$animate","$compile","$controller","$document","$http","$rootScope","$templateCache","keys",function(e,f,g,h,i,k,l,m){var n,o,p;return n=function(a){var b;return a.keyCode===m.ESCAPE&&p.opened?(b=p.opened.element.scope(),b.$apply(function(){return p.hide()})):void 0},o=function(){return p.resize()},p={registered:d,defaults:c,waiting:null,opened:null,modalTemplate:'
\n
\n \n
\n
\n
',show:function(a,c){var d,h,m,n,o,p,q;if(null==c&&(c={}),null!=this.registered[a]&&null!=this.opened)return this.hide();if(null==this.registered[a])return this.waiting={id:a,options:c};if(d=this.registered[a],h=d.options,p={},b.extend(p,h,c),o=function(b){return function(c){return p.beforeShow(c.scope()),e.addClass(c,"visible").then(function(){return b.opened={id:a,element:c,options:p},b.resize(b.opened),b.bindingEvents(),p.open(c.scope()),p.afterShow(c.scope()),k.$broadcast("modalWasShown",a),b.clearWaiting()})}}(this),null!=p.moduleMethod){if(n=function(c){return function(d){var h,i,l;return j(p.scope)?i=p.scope:(i=k.$new(!0),b.isObject(p.scope)&&b.extend(i,p.scope)),b.extend(p.attributes,{id:a}),h=b.element(c.modalTemplate).attr(p.attributes),l=b.element(h[0].getElementsByClassName("mac-modal-content-wrapper")),l.html(d),p.overlayClose&&h.bind("click",function(a){return b.element(a.target).hasClass("mac-modal-overlay")?i.$apply(function(){return c.hide()}):void 0}),p.controller&&g(p.controller,{$scope:i,$element:h,macModalOptions:p}),e.enter(h,b.element(document.body)),f(h)(i),o(h)}}(this),m=p.templateUrl)return q=l.get(m),q?n(q):i.get(m).then(function(a){return l.put(m,a.data),n(a.data)},function(){throw Error("Failed to load template: "+m)});if(q=p.template)return n(q)}else if(null!=d.element)return o(d.element)},resize:function(c){var d,e,f,g,h,i;return null==c&&(c=this.opened),null!=c&&(e=c.element,h=c.options,h.position)?(g=b.element(e[0].querySelector(".mac-modal")),f=g.outerHeight(),i=g.outerWidth(),d=b.element(a).height()>f?{marginTop:-f/2}:{top:h.topOffset},d.marginLeft=-i/2,b.forEach(d,function(a,c){return!isNaN(+a)&&b.isNumber(+a)&&(a=""+a+"px"),g.css(c,a)})):void 0},hide:function(){var a,b,c,d,f;if(null!=this.opened)return f=this.opened,b=f.id,c=f.options,a=f.element,c.beforeHide(a.scope()),d=this,e.removeClass(a,"visible").then(function(){var f;return d.bindingEvents("unbind"),d.opened=null,c.moduleMethod?(j(c.scope)||a.scope().$destroy(),e.leave(a)):(f=a[0].querySelector(".mac-modal"),f.removeAttribute("style")),c.afterHide(a.scope()),k.$broadcast("modalWasHidden",b)})},bindingEvents:function(c){var d;return null==c&&(c="bind"),"bind"!==c&&"unbind"!==c||null==this.opened?void 0:(d=this.opened.options,d.keyboard&&h[c]("keydown",n),d.resize?b.element(a)[c]("resize",o):void 0)},register:function(a,d,e){var f;if(null!=this.registered[a])throw new Error("Modal "+a+" already registered");return f={},b.extend(f,c,e),this.registered[a]={id:a,element:d,options:f},null!=this.waiting&&this.waiting.id===a?this.show(a,this.waiting.options):void 0},unregister:function(a){var b;if(null==this.registered[a])throw new Error("Modal "+a+" is not registered");return(null!=(b=this.opened)?b.id:void 0)===a&&this.hide(),this.clearWaiting(a),delete this.registered[a]},clearWaiting:function(a){var b;if(null==a||(null!=(b=this.waiting)?b.id:void 0)===a)return this.waiting=null}}}]}).config(["modalProvider",function(a){return b.module("Mac").modal=function(c,d){var e; +return null==a.registered[c]?(e={},b.extend(e,a.defaults,d,{moduleMethod:!0}),a.registered[c]={id:c,options:e}):void 0}}]),b.module("Mac").provider("popover",function(){var c,d,e,f;this.registered=f={},this.defaults=c={fixed:!1,childPopover:!1,offsetY:0,offsetX:0,trigger:"click"},this.popoverDefaults=d={footer:!1,header:!1,title:"",direction:"above left"},this.template=e='
\n
\n
\n
{{macPopoverTitle}}
\n
\n
\n
',this.$get=["$animate","$compile","$controller","$http","$rootScope","$templateCache","$timeout",function(g,h,i,k,l,m){var n;return n={popoverList:[],registered:f,defaults:c,popoverDefaults:d,template:e,last:function(){return this.popoverList[this.popoverList.length-1]},register:function(a,b){var c;return(c=null!=this.registered[a])||(this.registered[a]=b),!c},unregister:function(a){var b;return(b=null!=this.registered[a])&&delete this.registered[a],b},add:function(a,b,c,d){var e;return e={id:a,popover:b,element:c,options:d},this.popoverList.push(e),e},pop:function(){return this.popoverList.pop()},show:function(a,c,d){var f,o;return null==d&&(d={}),(o=this.registered[a])?(f=function(){var f,p,q;return p=function(f){var k,m,p;return j(d.scope)?p=d.scope.$new():(p=l.$new(!0),b.isObject(d.scope)&&b.extend(p,d.scope)),o.refreshOn&&p.$on(o.refreshOn,function(){return n.resize(a)}),o.controller&&i(o.controller,{$scope:p}),b.extend(p,{macPopoverClasses:{footer:o.footer||!1,header:o.header||!!o.title||!1,fixed:o.fixed||!1},macPopoverTitle:o.title||"",macPopoverTemplate:f}),k=h(e)(p),k.attr({id:a,direction:o.direction||"below left"}),m=n.add(a,k,c,d),g.addClass(c,"active"),l.$broadcast("popoverWasShown",a),g.enter(k,b.element(document.body)).then(function(){return n.resize(m)})},(q=o.template)?p(q):(f=o.templateUrl)?(q=m.get(f),q?p(q):k.get(f).then(function(a){return m.put(f,a.data),p(a.data)},function(){throw new Error("Failed to load template: #{path}")})):void 0},n.popoverList.length&&!d.childPopover?n.hide(f):f(),!0):!1},getById:function(a,b){var c,d,e,f,g;for(g=this.popoverList,e=0,f=g.length;f>e;e++)if(c=g[e],d=null==b||c.element===b,c.id===a&&d)return c},resize:function(c){var d,e,f,g,h,i,j,k,l,m,o,p,q,r,s,t;return b.isString(c)&&(c=n.getById(c)),null!=c?(g=c.popover,p=c.element,l=c.options,d=b.element(a),k=p.offset(),l.fixed&&(k.top=p.position().top),o={height:p.outerHeight(),width:p.outerWidth()},f={height:g.outerHeight(),width:g.outerWidth()},r=0,i=0,m=(g.attr("direction")||"top left").trim(),q=function(a){var c,d;return null==a&&(a=0),c=b.element(g[0].getElementsByClassName("tip")),r-=a,d=+c.css("margin-top").replace("px",""),c.css("margin-top",d+a)},t=function(){switch(m){case"above left":return r=-(f.height+10),i=-25+o.width/2;case"above right":return r=-(f.height+10),i=25+o.width/2-f.width;case"below left":return r=o.height+10,i=-25+o.width/2;case"below right":return r=o.height+10,i=25+o.width/2-f.width;case"middle right":return r=o.height/2-f.height/2,i=o.width+10;case"middle left":return r=o.height/2-f.height/2,i=-(f.width+10)}},t(),s=l.fixed?0:d.scrollTop(),j=l.fixed?0:d.scrollLeft(),e={},-1===m.indexOf("middle")?k.top+r-s<0?e={remove:"above",add:"below"}:k.top+r+f.height-s>d.height()&&(e={remove:"below",add:"above"}):(h=k.top+r-s)<0?q(h):(h=k.top+r+g.outerHeight()-s-d.height())>0&&q(h),e.remove&&e.add&&(m=m.replace(e.remove,e.add)),e={},k.left+i-j<0?e={remove:"right",add:"left"}:k.left+i+g.outerWidth()-j>d.width()&&(e={remove:"left",add:"right"}),e.remove&&e.add&&(m=m.replace(e.remove,e.add)),t(),k.top+=r,k.left+=i,null!=l.offsetX&&(k.left+=l.offsetX),null!=l.offsetY&&(k.top+=l.offsetY),b.forEach(k,function(a,b){return isNaN(+a)||(a=""+a+"px"),g.css(b,a)}),g.addClass("visible "+m)):void 0},hide:function(a,c){var d,e,f,h,i,j,k;if(!this.popoverList.length)return"function"==typeof c?c():void 0;if(b.isFunction(a)&&(c=a,a=null),null!=a){for(d=b.isString(a)?function(b){return b.id===a}:b.isElement(a)?function(b){return b.element===a}:void 0,f=-1,e=j=k=this.popoverList.length-1;j>=0;e=j+=-1)if(d(this.popoverList[e])){h=this.popoverList[e],f=e;break}f>-1&&this.popoverList.splice(f,1)}else h=this.pop();return null!=h?(l.$broadcast("popoverBeforeHide",h.id),g.removeClass(h.element,"active"),i=h.popover.scope(),g.leave(h.popover).then(function(){return l.$broadcast("popoverWasHidden",h.id),i.$destroy(),"function"==typeof c?c():void 0})):void 0},hideAll:function(){for(;this.popoverList.length;)this.hide()}}}]}).config(["popoverProvider",function(a){return b.module("Mac").popover=function(c,d){var e;return null==a.registered[c]?(e={},b.extend(e,a.popoverDefaults,d,{id:c}),a.registered[c]=e):void 0}}]),b.module("Mac").service("scrollSpy",[function(){return{registered:[],active:{},listeners:[],register:function(a,b){var c,d,e,f,g,h,i;for(e=!1,f=b.offset().top,i=this.registered,d=g=0,h=i.length;h>g;d=++g)if(c=i[d],c.id===a){this.registered[d]={id:a,element:b,top:f},e=!0;break}return e||this.registered.push({id:a,element:b,top:f}),this.registered.sort(function(a,b){return a.top>b.top?1:a.topd;c=++d)if(b=f[c],b.id===a){[].splice.apply(this.registered,[c,c-c+1].concat(g=[])),g;break}return h},last:function(){return this.registered[this.registered.length-1]},setActive:function(a){var b,c,d,e,f;for(this.active=a,e=this.listeners,f=[],c=0,d=e.length;d>c;c++)b=e[c],f.push(b(a));return f},addListener:function(a){return this.listeners.push(a)},removeListener:function(a){var b,c;return b=this.listeners.indexOf(a),-1!==b?([].splice.apply(this.listeners,[b,b-b+1].concat(c=[])),c):void 0}}}]).constant("scrollSpyDefaults",{offset:0});var w={}.hasOwnProperty;b.module("Mac.Util",[]).factory("util",["$filter",function(a){return{_inflectionConstants:{uncountables:["sheep","fish","moose","series","species","money","rice","information","info","equipment","min"],irregulars:{child:"children",man:"men",woman:"women",person:"people",ox:"oxen",goose:"geese"},pluralizers:[[/(quiz)$/i,"$1zes"],[/([m|l])ouse$/i,"$1ice"],[/(matr|vert|ind)(ix|ex)$/i,"$1ices"],[/(x|ch|ss|sh)$/i,"$1es"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/(?:([^f])fe|([lr])f)$/i,"$1$2ves"],[/sis$/i,"ses"],[/([ti])um$/i,"$1a"],[/(buffal|tomat)o$/i,"$1oes"],[/(bu)s$/i,"$1ses"],[/(alias|status)$/i,"$1es"],[/(octop|vir)us$/i,"$1i"],[/(ax|test)is$/i,"$1es"],[/x$/i,"xes"],[/s$/i,"s"],[/$/,"s"]]},pluralize:function(c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q;if(null==c&&(c=""),null==e&&(e=!1),!b.isString(c)||0===this.trim(c).length)return c;if(e&&isNaN(+d))return"";if(null==d&&(d=2),q=this._inflectionConstants,l=q.pluralizers,m=q.uncountables,f=q.irregulars,n=c.split(/\s/).pop(),g=n.toUpperCase()===n,h=n.toLowerCase(),j=1===d||m.indexOf(h)>=0?n:null,null==j&&null!=f[h]&&(j=f[h]),null==j)for(o=0,p=l.length;p>o;o++)if(k=l[o],k[0].test(h)){j=n.replace(k[0],k[1]);break}return j||(j=n),g&&(j=j.toUpperCase()),i=c.slice(0,-n.length)+j,e?""+a("number")(d)+" "+i:i},trim:function(a){var b;return b=String(a)||"",null!=String.prototype.trim?b.trim():b.replace(/^\s+|\s+$/gm,"")},capitalize:function(a){var b;return b=String(a)||"",b.charAt(0).toUpperCase()+b.substring(1)},uncapitalize:function(a){var b;return b=String(a)||"",b.charAt(0).toLowerCase()+b.substring(1)},toCamelCase:function(a){return null==a&&(a=""),this.trim(a).replace(/[-_\s]+(.)?/g,function(a,b){return b.toUpperCase()})},toSnakeCase:function(a){return null==a&&(a=""),this.trim(a).replace(/([a-z\d])([A-Z]+)/g,"$1_$2").replace(/[-\s]+/g,"_").toLowerCase()},convertKeysToCamelCase:function(a){var b,c,d;c={};for(b in a)w.call(a,b)&&(d=a[b],b=this.toCamelCase(b),"object"==typeof d&&(null!=d?d.constructor:void 0)!==Array&&(d=this.convertKeysToCamelCase(d)),c[b]=d);return c},convertKeysToSnakeCase:function(a){var b,c,d;c={};for(b in a)w.call(a,b)&&(d=a[b],b=this.toSnakeCase(b),"object"==typeof d&&(null!=d?d.constructor:void 0)!==Array&&(d=this.convertKeysToSnakeCase(d)),c[b]=d);return c},pyth:function(a,b){return Math.sqrt(a*a+b*b)},degrees:function(a){return 180*a/Math.PI},radian:function(a){return a*Math.PI/180},hex2rgb:function(a){var b,c,d;0===a.indexOf("#")&&(a=a.substring(1)),a=a.toLowerCase(),c={},3===a.length?(c.r=a.charAt(0)+a.charAt(0),c.g=a.charAt(1)+a.charAt(1),c.b=a.charAt(2)+a.charAt(2)):(c.r=a.substring(0,2),c.g=a.substring(2,4),c.b=a.substring(4));for(b in c)d=c[b],c[b]=parseInt(d,16);return c},timeRegex:/^(0?[1-9]|1[0-2]):([0-5][0-9])[\s]([AP]M)$/,_urlRegex:/(?:(http[s]?):\/\/)?(?:(www|[\d\w\-]+)\.)?([\d\w\-]+)\.([A-Za-z]{2,6})(:[\d]*)?([:\/?#\[\]@!$&'()*+,;=\w\d-._~%\\]*)?/i,_emailRegex:/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/,validateUrl:function(a){var b;return b=this._urlRegex.exec(a),null!=b&&(b={url:b[0],protocol:b[1]||"http",subdomain:b[2],name:b[3],domain:b[4],port:b[5],path:b[6]||"/"},b.url=b.url),b},validateEmail:function(a){return this._emailRegex.test(a)},getQueryString:function(a,b){var c,d,e;return null==b&&(b=""),b=b.replace(/[[]/,"[").replace(/[]]/,"]"),d="[?&]"+b+"=([^&#]*)",c=new RegExp(d),e=c.exec(a),null!=e?e[1]:""},parseUrlPath:function(a){var b,c,d,e,f,g,h,i,j,k,l;if(g=a.split("?"),c=g[0].split("/"),b=c.slice(0,c.length-1).join("/"),i=c[c.length-1],d={},g.length>1)for(f=g[g.length-1],l=f.split("&"),j=0,k=l.length;k>j;j++)e=l[j],h=e.split("="),d[h[0]]=null!=h[1]?h[1]:"";return{fullPath:a,path:b,pathComponents:c,verb:i,queries:d}},extendAttributes:function(a,b,c){var d,e,f,g,h,i,j;null==a&&(a=""),g={};for(e in b)w.call(b,e)&&(h=b[e],d=a?this.capitalize(e):e,f=""+a+d,g[e]=null!=c[f]?c[f]||!0:h,"true"===(i=g[e])||"false"===i?g[e]="true"===g[e]:(null!=(j=g[e])?j.length:void 0)>0&&!isNaN(+g[e])&&(g[e]=+g[e]));return g}}}])}(window,window.angular); \ No newline at end of file diff --git a/package.json b/package.json index 7999b4d..0841e27 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "author": "Adrian Lee ", "name": "MacGyver", "description": "A library of shared directives", - "version": "0.5.1", + "version": "0.6.0", "homepage": "http://angular-macgyver.github.io/MacGyver", "repository": { "type": "git",