diff --git a/.gitignore b/.gitignore index f53b43e..957badc 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,6 @@ client/plugins/ client/resources/ client/dist client/www/js/config.js -client/www/lib/* _whiteboards server/node_modules server/logs/logs.log diff --git a/client/www/index.html b/client/www/index.html index 8ed83ec..53478a8 100644 --- a/client/www/index.html +++ b/client/www/index.html @@ -8,7 +8,7 @@ - + diff --git a/client/www/js/controllers/addPoiController.js b/client/www/js/controllers/addPoiController.js index b4744ea..ad33edf 100644 --- a/client/www/js/controllers/addPoiController.js +++ b/client/www/js/controllers/addPoiController.js @@ -111,7 +111,7 @@ angular.module('amblr.addPOI', []) .then(function(routes) { //routes returns an array of objects. //Need to loop through and create an object with the id as keys for easy look up to add to markers - for (let route of routes) { + for (var route of routes) { //make key of allRoutes equal to the route's id and the value equal to the name $scope.allRoutes[route._id] = route.name; } @@ -158,4 +158,4 @@ angular.module('amblr.addPOI', []) $scope.modal.hide(); }); -}); \ No newline at end of file +}); diff --git a/client/www/js/controllers/mapController.js b/client/www/js/controllers/mapController.js index 6e9cd64..f4ca590 100644 --- a/client/www/js/controllers/mapController.js +++ b/client/www/js/controllers/mapController.js @@ -158,7 +158,7 @@ angular.module('amblr.map', ['uiGmapgoogle-maps']) .then(function(routes) { //routes returns an array of objects. //Need to loop through and create an object with the id as keys for easy look up to add to markers - for (let route of routes) { + for (var route of routes) { //make key of allRoutes equal to the route's id and the value equal to the name $scope.allRoutes[route._id] = route.name; } diff --git a/client/www/lib/angular-animate/.bower.json b/client/www/lib/angular-animate/.bower.json new file mode 100644 index 0000000..8322386 --- /dev/null +++ b/client/www/lib/angular-animate/.bower.json @@ -0,0 +1,19 @@ +{ + "name": "angular-animate", + "version": "1.4.3", + "main": "./angular-animate.js", + "ignore": [], + "dependencies": { + "angular": "1.4.3" + }, + "homepage": "https://github.com/angular/bower-angular-animate", + "_release": "1.4.3", + "_resolution": { + "type": "version", + "tag": "v1.4.3", + "commit": "4ce2a76359401102d2e0146ccf69e6c060799ff8" + }, + "_source": "https://github.com/angular/bower-angular-animate.git", + "_target": "1.4.3", + "_originalSource": "angular-animate" +} \ No newline at end of file diff --git a/client/www/lib/angular-animate/README.md b/client/www/lib/angular-animate/README.md new file mode 100644 index 0000000..8313da6 --- /dev/null +++ b/client/www/lib/angular-animate/README.md @@ -0,0 +1,68 @@ +# packaged angular-animate + +This repo is for distribution on `npm` and `bower`. The source for this module is in the +[main AngularJS repo](https://github.com/angular/angular.js/tree/master/src/ngAnimate). +Please file issues and pull requests against that repo. + +## Install + +You can install this package either with `npm` or with `bower`. + +### npm + +```shell +npm install angular-animate +``` + +Then add `ngAnimate` as a dependency for your app: + +```javascript +angular.module('myApp', [require('angular-animate')]); +``` + +### bower + +```shell +bower install angular-animate +``` + +Then add a ` +``` + +Then add `ngAnimate` as a dependency for your app: + +```javascript +angular.module('myApp', ['ngAnimate']); +``` + +## Documentation + +Documentation is available on the +[AngularJS docs site](http://docs.angularjs.org/api/ngAnimate). + +## License + +The MIT License + +Copyright (c) 2010-2015 Google, Inc. http://angularjs.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/client/www/lib/angular-animate/angular-animate.js b/client/www/lib/angular-animate/angular-animate.js new file mode 100644 index 0000000..fc0e217 --- /dev/null +++ b/client/www/lib/angular-animate/angular-animate.js @@ -0,0 +1,3721 @@ +/** + * @license AngularJS v1.4.3 + * (c) 2010-2015 Google, Inc. http://angularjs.org + * License: MIT + */ +(function(window, angular, undefined) {'use strict'; + +/* jshint ignore:start */ +var noop = angular.noop; +var extend = angular.extend; +var jqLite = angular.element; +var forEach = angular.forEach; +var isArray = angular.isArray; +var isString = angular.isString; +var isObject = angular.isObject; +var isUndefined = angular.isUndefined; +var isDefined = angular.isDefined; +var isFunction = angular.isFunction; +var isElement = angular.isElement; + +var ELEMENT_NODE = 1; +var COMMENT_NODE = 8; + +var NG_ANIMATE_CLASSNAME = 'ng-animate'; +var NG_ANIMATE_CHILDREN_DATA = '$$ngAnimateChildren'; + +var isPromiseLike = function(p) { + return p && p.then ? true : false; +} + +function assertArg(arg, name, reason) { + if (!arg) { + throw ngMinErr('areq', "Argument '{0}' is {1}", (name || '?'), (reason || "required")); + } + return arg; +} + +function mergeClasses(a,b) { + if (!a && !b) return ''; + if (!a) return b; + if (!b) return a; + if (isArray(a)) a = a.join(' '); + if (isArray(b)) b = b.join(' '); + return a + ' ' + b; +} + +function packageStyles(options) { + var styles = {}; + if (options && (options.to || options.from)) { + styles.to = options.to; + styles.from = options.from; + } + return styles; +} + +function pendClasses(classes, fix, isPrefix) { + var className = ''; + classes = isArray(classes) + ? classes + : classes && isString(classes) && classes.length + ? classes.split(/\s+/) + : []; + forEach(classes, function(klass, i) { + if (klass && klass.length > 0) { + className += (i > 0) ? ' ' : ''; + className += isPrefix ? fix + klass + : klass + fix; + } + }); + return className; +} + +function removeFromArray(arr, val) { + var index = arr.indexOf(val); + if (val >= 0) { + arr.splice(index, 1); + } +} + +function stripCommentsFromElement(element) { + if (element instanceof jqLite) { + switch (element.length) { + case 0: + return []; + break; + + case 1: + // there is no point of stripping anything if the element + // is the only element within the jqLite wrapper. + // (it's important that we retain the element instance.) + if (element[0].nodeType === ELEMENT_NODE) { + return element; + } + break; + + default: + return jqLite(extractElementNode(element)); + break; + } + } + + if (element.nodeType === ELEMENT_NODE) { + return jqLite(element); + } +} + +function extractElementNode(element) { + if (!element[0]) return element; + for (var i = 0; i < element.length; i++) { + var elm = element[i]; + if (elm.nodeType == ELEMENT_NODE) { + return elm; + } + } +} + +function $$addClass($$jqLite, element, className) { + forEach(element, function(elm) { + $$jqLite.addClass(elm, className); + }); +} + +function $$removeClass($$jqLite, element, className) { + forEach(element, function(elm) { + $$jqLite.removeClass(elm, className); + }); +} + +function applyAnimationClassesFactory($$jqLite) { + return function(element, options) { + if (options.addClass) { + $$addClass($$jqLite, element, options.addClass); + options.addClass = null; + } + if (options.removeClass) { + $$removeClass($$jqLite, element, options.removeClass); + options.removeClass = null; + } + } +} + +function prepareAnimationOptions(options) { + options = options || {}; + if (!options.$$prepared) { + var domOperation = options.domOperation || noop; + options.domOperation = function() { + options.$$domOperationFired = true; + domOperation(); + domOperation = noop; + }; + options.$$prepared = true; + } + return options; +} + +function applyAnimationStyles(element, options) { + applyAnimationFromStyles(element, options); + applyAnimationToStyles(element, options); +} + +function applyAnimationFromStyles(element, options) { + if (options.from) { + element.css(options.from); + options.from = null; + } +} + +function applyAnimationToStyles(element, options) { + if (options.to) { + element.css(options.to); + options.to = null; + } +} + +function mergeAnimationOptions(element, target, newOptions) { + var toAdd = (target.addClass || '') + ' ' + (newOptions.addClass || ''); + var toRemove = (target.removeClass || '') + ' ' + (newOptions.removeClass || ''); + var classes = resolveElementClasses(element.attr('class'), toAdd, toRemove); + + extend(target, newOptions); + + if (classes.addClass) { + target.addClass = classes.addClass; + } else { + target.addClass = null; + } + + if (classes.removeClass) { + target.removeClass = classes.removeClass; + } else { + target.removeClass = null; + } + + return target; +} + +function resolveElementClasses(existing, toAdd, toRemove) { + var ADD_CLASS = 1; + var REMOVE_CLASS = -1; + + var flags = {}; + existing = splitClassesToLookup(existing); + + toAdd = splitClassesToLookup(toAdd); + forEach(toAdd, function(value, key) { + flags[key] = ADD_CLASS; + }); + + toRemove = splitClassesToLookup(toRemove); + forEach(toRemove, function(value, key) { + flags[key] = flags[key] === ADD_CLASS ? null : REMOVE_CLASS; + }); + + var classes = { + addClass: '', + removeClass: '' + }; + + forEach(flags, function(val, klass) { + var prop, allow; + if (val === ADD_CLASS) { + prop = 'addClass'; + allow = !existing[klass]; + } else if (val === REMOVE_CLASS) { + prop = 'removeClass'; + allow = existing[klass]; + } + if (allow) { + if (classes[prop].length) { + classes[prop] += ' '; + } + classes[prop] += klass; + } + }); + + function splitClassesToLookup(classes) { + if (isString(classes)) { + classes = classes.split(' '); + } + + var obj = {}; + forEach(classes, function(klass) { + // sometimes the split leaves empty string values + // incase extra spaces were applied to the options + if (klass.length) { + obj[klass] = true; + } + }); + return obj; + } + + return classes; +} + +function getDomNode(element) { + return (element instanceof angular.element) ? element[0] : element; +} + +var $$rAFSchedulerFactory = ['$$rAF', function($$rAF) { + var tickQueue = []; + var cancelFn; + + function scheduler(tasks) { + // we make a copy since RAFScheduler mutates the state + // of the passed in array variable and this would be difficult + // to track down on the outside code + tickQueue.push([].concat(tasks)); + nextTick(); + } + + /* waitUntilQuiet does two things: + * 1. It will run the FINAL `fn` value only when an uncancelled RAF has passed through + * 2. It will delay the next wave of tasks from running until the quiet `fn` has run. + * + * The motivation here is that animation code can request more time from the scheduler + * before the next wave runs. This allows for certain DOM properties such as classes to + * be resolved in time for the next animation to run. + */ + scheduler.waitUntilQuiet = function(fn) { + if (cancelFn) cancelFn(); + + cancelFn = $$rAF(function() { + cancelFn = null; + fn(); + nextTick(); + }); + }; + + return scheduler; + + function nextTick() { + if (!tickQueue.length) return; + + var updatedQueue = []; + for (var i = 0; i < tickQueue.length; i++) { + var innerQueue = tickQueue[i]; + runNextTask(innerQueue); + if (innerQueue.length) { + updatedQueue.push(innerQueue); + } + } + tickQueue = updatedQueue; + + if (!cancelFn) { + $$rAF(function() { + if (!cancelFn) nextTick(); + }); + } + } + + function runNextTask(tasks) { + var nextTask = tasks.shift(); + nextTask(); + } +}]; + +var $$AnimateChildrenDirective = [function() { + return function(scope, element, attrs) { + var val = attrs.ngAnimateChildren; + if (angular.isString(val) && val.length === 0) { //empty attribute + element.data(NG_ANIMATE_CHILDREN_DATA, true); + } else { + attrs.$observe('ngAnimateChildren', function(value) { + value = value === 'on' || value === 'true'; + element.data(NG_ANIMATE_CHILDREN_DATA, value); + }); + } + }; +}]; + +/** + * @ngdoc service + * @name $animateCss + * @kind object + * + * @description + * The `$animateCss` service is a useful utility to trigger customized CSS-based transitions/keyframes + * from a JavaScript-based animation or directly from a directive. The purpose of `$animateCss` is NOT + * to side-step how `$animate` and ngAnimate work, but the goal is to allow pre-existing animations or + * directives to create more complex animations that can be purely driven using CSS code. + * + * Note that only browsers that support CSS transitions and/or keyframe animations are capable of + * rendering animations triggered via `$animateCss` (bad news for IE9 and lower). + * + * ## Usage + * Once again, `$animateCss` is designed to be used inside of a registered JavaScript animation that + * is powered by ngAnimate. It is possible to use `$animateCss` directly inside of a directive, however, + * any automatic control over cancelling animations and/or preventing animations from being run on + * child elements will not be handled by Angular. For this to work as expected, please use `$animate` to + * trigger the animation and then setup a JavaScript animation that injects `$animateCss` to trigger + * the CSS animation. + * + * The example below shows how we can create a folding animation on an element using `ng-if`: + * + * ```html + * + *
+ *
+ *
+ *
+ *
+ * ```
+ *
+ * Now, when the view changes (once the link is clicked), ngAnimate will examine the
+ * HTML contents to see if there is a match reference between any components in the view
+ * that is leaving and the view that is entering. It will scan both the view which is being
+ * removed (leave) and inserted (enter) to see if there are any paired DOM elements that
+ * contain a matching ref value.
+ *
+ * The two images match since they share the same ref value. ngAnimate will now create a
+ * transport element (which is a clone of the first image element) and it will then attempt
+ * to animate to the position of the second image element in the next view. For the animation to
+ * work a special CSS class called `ng-anchor` will be added to the transported element.
+ *
+ * We can now attach a transition onto the `.banner.ng-anchor` CSS class and then
+ * ngAnimate will handle the entire transition for us as well as the addition and removal of
+ * any changes of CSS classes between the elements:
+ *
+ * ```css
+ * .banner.ng-anchor {
+ * /* this animation will last for 1 second since there are
+ * two phases to the animation (an `in` and an `out` phase) */
+ * transition:0.5s linear all;
+ * }
+ * ```
+ *
+ * We also **must** include animations for the views that are being entered and removed
+ * (otherwise anchoring wouldn't be possible since the new view would be inserted right away).
+ *
+ * ```css
+ * .view-animation.ng-enter, .view-animation.ng-leave {
+ * transition:0.5s linear all;
+ * position:fixed;
+ * left:0;
+ * top:0;
+ * width:100%;
+ * }
+ * .view-animation.ng-enter {
+ * transform:translateX(100%);
+ * }
+ * .view-animation.ng-leave,
+ * .view-animation.ng-enter.ng-enter-active {
+ * transform:translateX(0%);
+ * }
+ * .view-animation.ng-leave.ng-leave-active {
+ * transform:translateX(-100%);
+ * }
+ * ```
+ *
+ * Now we can jump back to the anchor animation. When the animation happens, there are two stages that occur:
+ * an `out` and an `in` stage. The `out` stage happens first and that is when the element is animated away
+ * from its origin. Once that animation is over then the `in` stage occurs which animates the
+ * element to its destination. The reason why there are two animations is to give enough time
+ * for the enter animation on the new element to be ready.
+ *
+ * The example above sets up a transition for both the in and out phases, but we can also target the out or
+ * in phases directly via `ng-anchor-out` and `ng-anchor-in`.
+ *
+ * ```css
+ * .banner.ng-anchor-out {
+ * transition: 0.5s linear all;
+ *
+ * /* the scale will be applied during the out animation,
+ * but will be animated away when the in animation runs */
+ * transform: scale(1.2);
+ * }
+ *
+ * .banner.ng-anchor-in {
+ * transition: 1s linear all;
+ * }
+ * ```
+ *
+ *
+ *
+ *
+ * ### Anchoring Demo
+ *
+ Please click on an element
+ + {{ record.title }} + ++ * An InfoBox behaves like a google.maps.InfoWindow, but it supports several + * additional properties for advanced styling. An InfoBox can also be used as a map label. + *
+ * An InfoBox also fires the same events as a google.maps.InfoWindow.
+ */
+
+/*jslint browser:true */
+/*global google */
+
+/**
+ * @name InfoBoxOptions
+ * @class This class represents the optional parameter passed to the {@link InfoBox} constructor.
+ * @property {string|Node} content The content of the InfoBox (plain text or an HTML DOM node).
+ * @property {boolean} [disableAutoPan=false] Disable auto-pan on open.
+ * @property {number} maxWidth The maximum width (in pixels) of the InfoBox. Set to 0 if no maximum.
+ * @property {Size} pixelOffset The offset (in pixels) from the top left corner of the InfoBox
+ * (or the bottom left corner if the alignBottom property is true)
+ * to the map pixel corresponding to position.
+ * @property {LatLng} position The geographic location at which to display the InfoBox.
+ * @property {number} zIndex The CSS z-index style value for the InfoBox.
+ * Note: This value overrides a zIndex setting specified in the boxStyle property.
+ * @property {string} [boxClass="infoBox"] The name of the CSS class defining the styles for the InfoBox container.
+ * @property {Object} [boxStyle] An object literal whose properties define specific CSS
+ * style values to be applied to the InfoBox. Style values defined here override those that may
+ * be defined in the boxClass style sheet. If this property is changed after the
+ * InfoBox has been created, all previously set styles (except those defined in the style sheet)
+ * are removed from the InfoBox before the new style values are applied.
+ * @property {string} closeBoxMargin The CSS margin style value for the close box.
+ * The default is "2px" (a 2-pixel margin on all sides).
+ * @property {string} closeBoxURL The URL of the image representing the close box.
+ * Note: The default is the URL for Google's standard close box.
+ * Set this property to "" if no close box is required.
+ * @property {Size} infoBoxClearance Minimum offset (in pixels) from the InfoBox to the
+ * map edge after an auto-pan.
+ * @property {boolean} [isHidden=false] Hide the InfoBox on open.
+ * [Deprecated in favor of the visible property.]
+ * @property {boolean} [visible=true] Show the InfoBox on open.
+ * @property {boolean} alignBottom Align the bottom left corner of the InfoBox to the position
+ * location (default is false which means that the top left corner of the InfoBox is aligned).
+ * @property {string} pane The pane where the InfoBox is to appear (default is "floatPane").
+ * Set the pane to "mapPane" if the InfoBox is being used as a map label.
+ * Valid pane names are the property names for the google.maps.MapPanes object.
+ * @property {boolean} enableEventPropagation Propagate mousedown, mousemove, mouseover, mouseout,
+ * mouseup, click, dblclick, touchstart, touchend, touchmove, and contextmenu events in the InfoBox
+ * (default is false to mimic the behavior of a google.maps.InfoWindow). Set
+ * this property to true if the InfoBox is being used as a map label.
+ */
+
+/**
+ * Creates an InfoBox with the options specified in {@link InfoBoxOptions}.
+ * Call InfoBox.open to add the box to the map.
+ * @constructor
+ * @param {InfoBoxOptions} [opt_opts]
+ */
+function InfoBox(opt_opts) {
+
+ opt_opts = opt_opts || {};
+
+ google.maps.OverlayView.apply(this, arguments);
+
+ // Standard options (in common with google.maps.InfoWindow):
+ //
+ this.content_ = opt_opts.content || "";
+ this.disableAutoPan_ = opt_opts.disableAutoPan || false;
+ this.maxWidth_ = opt_opts.maxWidth || 0;
+ this.pixelOffset_ = opt_opts.pixelOffset || new google.maps.Size(0, 0);
+ this.position_ = opt_opts.position || new google.maps.LatLng(0, 0);
+ this.zIndex_ = opt_opts.zIndex || null;
+
+ // Additional options (unique to InfoBox):
+ //
+ this.boxClass_ = opt_opts.boxClass || "infoBox";
+ this.boxStyle_ = opt_opts.boxStyle || {};
+ this.closeBoxMargin_ = opt_opts.closeBoxMargin || "2px";
+ this.closeBoxURL_ = opt_opts.closeBoxURL || "http://www.google.com/intl/en_us/mapfiles/close.gif";
+ if (opt_opts.closeBoxURL === "") {
+ this.closeBoxURL_ = "";
+ }
+ this.infoBoxClearance_ = opt_opts.infoBoxClearance || new google.maps.Size(1, 1);
+
+ if (typeof opt_opts.visible === "undefined") {
+ if (typeof opt_opts.isHidden === "undefined") {
+ opt_opts.visible = true;
+ } else {
+ opt_opts.visible = !opt_opts.isHidden;
+ }
+ }
+ this.isHidden_ = !opt_opts.visible;
+
+ this.alignBottom_ = opt_opts.alignBottom || false;
+ this.pane_ = opt_opts.pane || "floatPane";
+ this.enableEventPropagation_ = opt_opts.enableEventPropagation || false;
+
+ this.div_ = null;
+ this.closeListener_ = null;
+ this.moveListener_ = null;
+ this.contextListener_ = null;
+ this.eventListeners_ = null;
+ this.fixedWidthSet_ = null;
+}
+
+/* InfoBox extends OverlayView in the Google Maps API v3.
+ */
+InfoBox.prototype = new google.maps.OverlayView();
+
+/**
+ * Creates the DIV representing the InfoBox.
+ * @private
+ */
+InfoBox.prototype.createInfoBoxDiv_ = function () {
+
+ var i;
+ var events;
+ var bw;
+ var me = this;
+
+ // This handler prevents an event in the InfoBox from being passed on to the map.
+ //
+ var cancelHandler = function (e) {
+ e.cancelBubble = true;
+ if (e.stopPropagation) {
+ e.stopPropagation();
+ }
+ };
+
+ // This handler ignores the current event in the InfoBox and conditionally prevents
+ // the event from being passed on to the map. It is used for the contextmenu event.
+ //
+ var ignoreHandler = function (e) {
+
+ e.returnValue = false;
+
+ if (e.preventDefault) {
+
+ e.preventDefault();
+ }
+
+ if (!me.enableEventPropagation_) {
+
+ cancelHandler(e);
+ }
+ };
+
+ if (!this.div_) {
+
+ this.div_ = document.createElement("div");
+
+ this.setBoxStyle_();
+
+ if (typeof this.content_.nodeType === "undefined") {
+ this.div_.innerHTML = this.getCloseBoxImg_() + this.content_;
+ } else {
+ this.div_.innerHTML = this.getCloseBoxImg_();
+ this.div_.appendChild(this.content_);
+ }
+
+ // Add the InfoBox DIV to the DOM
+ this.getPanes()[this.pane_].appendChild(this.div_);
+
+ this.addClickHandler_();
+
+ if (this.div_.style.width) {
+
+ this.fixedWidthSet_ = true;
+
+ } else {
+
+ if (this.maxWidth_ !== 0 && this.div_.offsetWidth > this.maxWidth_) {
+
+ this.div_.style.width = this.maxWidth_;
+ this.div_.style.overflow = "auto";
+ this.fixedWidthSet_ = true;
+
+ } else { // The following code is needed to overcome problems with MSIE
+
+ bw = this.getBoxWidths_();
+
+ this.div_.style.width = (this.div_.offsetWidth - bw.left - bw.right) + "px";
+ this.fixedWidthSet_ = false;
+ }
+ }
+
+ this.panBox_(this.disableAutoPan_);
+
+ if (!this.enableEventPropagation_) {
+
+ this.eventListeners_ = [];
+
+ // Cancel event propagation.
+ //
+ // Note: mousemove not included (to resolve Issue 152)
+ events = ["mousedown", "mouseover", "mouseout", "mouseup",
+ "click", "dblclick", "touchstart", "touchend", "touchmove"];
+
+ for (i = 0; i < events.length; i++) {
+
+ this.eventListeners_.push(google.maps.event.addDomListener(this.div_, events[i], cancelHandler));
+ }
+
+ // Workaround for Google bug that causes the cursor to change to a pointer
+ // when the mouse moves over a marker underneath InfoBox.
+ this.eventListeners_.push(google.maps.event.addDomListener(this.div_, "mouseover", function (e) {
+ this.style.cursor = "default";
+ }));
+ }
+
+ this.contextListener_ = google.maps.event.addDomListener(this.div_, "contextmenu", ignoreHandler);
+
+ /**
+ * This event is fired when the DIV containing the InfoBox's content is attached to the DOM.
+ * @name InfoBox#domready
+ * @event
+ */
+ google.maps.event.trigger(this, "domready");
+ }
+};
+
+/**
+ * Returns the HTML tag for the close box.
+ * @private
+ */
+InfoBox.prototype.getCloseBoxImg_ = function () {
+
+ var img = "";
+
+ if (this.closeBoxURL_ !== "") {
+
+ img = "
";
+ }
+
+ return img;
+};
+
+/**
+ * Adds the click handler to the InfoBox close box.
+ * @private
+ */
+InfoBox.prototype.addClickHandler_ = function () {
+
+ var closeBox;
+
+ if (this.closeBoxURL_ !== "") {
+
+ closeBox = this.div_.firstChild;
+ this.closeListener_ = google.maps.event.addDomListener(closeBox, "click", this.getCloseClickHandler_());
+
+ } else {
+
+ this.closeListener_ = null;
+ }
+};
+
+/**
+ * Returns the function to call when the user clicks the close box of an InfoBox.
+ * @private
+ */
+InfoBox.prototype.getCloseClickHandler_ = function () {
+
+ var me = this;
+
+ return function (e) {
+
+ // 1.0.3 fix: Always prevent propagation of a close box click to the map:
+ e.cancelBubble = true;
+
+ if (e.stopPropagation) {
+
+ e.stopPropagation();
+ }
+
+ /**
+ * This event is fired when the InfoBox's close box is clicked.
+ * @name InfoBox#closeclick
+ * @event
+ */
+ google.maps.event.trigger(me, "closeclick");
+
+ me.close();
+ };
+};
+
+/**
+ * Pans the map so that the InfoBox appears entirely within the map's visible area.
+ * @private
+ */
+InfoBox.prototype.panBox_ = function (disablePan) {
+
+ var map;
+ var bounds;
+ var xOffset = 0, yOffset = 0;
+
+ if (!disablePan) {
+
+ map = this.getMap();
+
+ if (map instanceof google.maps.Map) { // Only pan if attached to map, not panorama
+
+ if (!map.getBounds().contains(this.position_)) {
+ // Marker not in visible area of map, so set center
+ // of map to the marker position first.
+ map.setCenter(this.position_);
+ }
+
+ bounds = map.getBounds();
+
+ var mapDiv = map.getDiv();
+ var mapWidth = mapDiv.offsetWidth;
+ var mapHeight = mapDiv.offsetHeight;
+ var iwOffsetX = this.pixelOffset_.width;
+ var iwOffsetY = this.pixelOffset_.height;
+ var iwWidth = this.div_.offsetWidth;
+ var iwHeight = this.div_.offsetHeight;
+ var padX = this.infoBoxClearance_.width;
+ var padY = this.infoBoxClearance_.height;
+ var pixPosition = this.getProjection().fromLatLngToContainerPixel(this.position_);
+
+ if (pixPosition.x < (-iwOffsetX + padX)) {
+ xOffset = pixPosition.x + iwOffsetX - padX;
+ } else if ((pixPosition.x + iwWidth + iwOffsetX + padX) > mapWidth) {
+ xOffset = pixPosition.x + iwWidth + iwOffsetX + padX - mapWidth;
+ }
+ if (this.alignBottom_) {
+ if (pixPosition.y < (-iwOffsetY + padY + iwHeight)) {
+ yOffset = pixPosition.y + iwOffsetY - padY - iwHeight;
+ } else if ((pixPosition.y + iwOffsetY + padY) > mapHeight) {
+ yOffset = pixPosition.y + iwOffsetY + padY - mapHeight;
+ }
+ } else {
+ if (pixPosition.y < (-iwOffsetY + padY)) {
+ yOffset = pixPosition.y + iwOffsetY - padY;
+ } else if ((pixPosition.y + iwHeight + iwOffsetY + padY) > mapHeight) {
+ yOffset = pixPosition.y + iwHeight + iwOffsetY + padY - mapHeight;
+ }
+ }
+
+ if (!(xOffset === 0 && yOffset === 0)) {
+
+ // Move the map to the shifted center.
+ //
+ var c = map.getCenter();
+ map.panBy(xOffset, yOffset);
+ }
+ }
+ }
+};
+
+/**
+ * Sets the style of the InfoBox by setting the style sheet and applying
+ * other specific styles requested.
+ * @private
+ */
+InfoBox.prototype.setBoxStyle_ = function () {
+
+ var i, boxStyle;
+
+ if (this.div_) {
+
+ // Apply style values from the style sheet defined in the boxClass parameter:
+ this.div_.className = this.boxClass_;
+
+ // Clear existing inline style values:
+ this.div_.style.cssText = "";
+
+ // Apply style values defined in the boxStyle parameter:
+ boxStyle = this.boxStyle_;
+ for (i in boxStyle) {
+
+ if (boxStyle.hasOwnProperty(i)) {
+
+ this.div_.style[i] = boxStyle[i];
+ }
+ }
+
+ // Fix for iOS disappearing InfoBox problem.
+ // See http://stackoverflow.com/questions/9229535/google-maps-markers-disappear-at-certain-zoom-level-only-on-iphone-ipad
+ this.div_.style.WebkitTransform = "translateZ(0)";
+
+ // Fix up opacity style for benefit of MSIE:
+ //
+ if (typeof this.div_.style.opacity !== "undefined" && this.div_.style.opacity !== "") {
+ // See http://www.quirksmode.org/css/opacity.html
+ this.div_.style.MsFilter = "\"progid:DXImageTransform.Microsoft.Alpha(Opacity=" + (this.div_.style.opacity * 100) + ")\"";
+ this.div_.style.filter = "alpha(opacity=" + (this.div_.style.opacity * 100) + ")";
+ }
+
+ // Apply required styles:
+ //
+ this.div_.style.position = "absolute";
+ this.div_.style.visibility = 'hidden';
+ if (this.zIndex_ !== null) {
+
+ this.div_.style.zIndex = this.zIndex_;
+ }
+ }
+};
+
+/**
+ * Get the widths of the borders of the InfoBox.
+ * @private
+ * @return {Object} widths object (top, bottom left, right)
+ */
+InfoBox.prototype.getBoxWidths_ = function () {
+
+ var computedStyle;
+ var bw = {top: 0, bottom: 0, left: 0, right: 0};
+ var box = this.div_;
+
+ if (document.defaultView && document.defaultView.getComputedStyle) {
+
+ computedStyle = box.ownerDocument.defaultView.getComputedStyle(box, "");
+
+ if (computedStyle) {
+
+ // The computed styles are always in pixel units (good!)
+ bw.top = parseInt(computedStyle.borderTopWidth, 10) || 0;
+ bw.bottom = parseInt(computedStyle.borderBottomWidth, 10) || 0;
+ bw.left = parseInt(computedStyle.borderLeftWidth, 10) || 0;
+ bw.right = parseInt(computedStyle.borderRightWidth, 10) || 0;
+ }
+
+ } else if (document.documentElement.currentStyle) { // MSIE
+
+ if (box.currentStyle) {
+
+ // The current styles may not be in pixel units, but assume they are (bad!)
+ bw.top = parseInt(box.currentStyle.borderTopWidth, 10) || 0;
+ bw.bottom = parseInt(box.currentStyle.borderBottomWidth, 10) || 0;
+ bw.left = parseInt(box.currentStyle.borderLeftWidth, 10) || 0;
+ bw.right = parseInt(box.currentStyle.borderRightWidth, 10) || 0;
+ }
+ }
+
+ return bw;
+};
+
+/**
+ * Invoked when close is called. Do not call it directly.
+ */
+InfoBox.prototype.onRemove = function () {
+
+ if (this.div_) {
+
+ this.div_.parentNode.removeChild(this.div_);
+ this.div_ = null;
+ }
+};
+
+/**
+ * Draws the InfoBox based on the current map projection and zoom level.
+ */
+InfoBox.prototype.draw = function () {
+
+ this.createInfoBoxDiv_();
+
+ var pixPosition = this.getProjection().fromLatLngToDivPixel(this.position_);
+
+ this.div_.style.left = (pixPosition.x + this.pixelOffset_.width) + "px";
+
+ if (this.alignBottom_) {
+ this.div_.style.bottom = -(pixPosition.y + this.pixelOffset_.height) + "px";
+ } else {
+ this.div_.style.top = (pixPosition.y + this.pixelOffset_.height) + "px";
+ }
+
+ if (this.isHidden_) {
+
+ this.div_.style.visibility = "hidden";
+
+ } else {
+
+ this.div_.style.visibility = "visible";
+ }
+};
+
+/**
+ * Sets the options for the InfoBox. Note that changes to the maxWidth,
+ * closeBoxMargin, closeBoxURL, and enableEventPropagation
+ * properties have no affect until the current InfoBox is closed and a new one
+ * is opened.
+ * @param {InfoBoxOptions} opt_opts
+ */
+InfoBox.prototype.setOptions = function (opt_opts) {
+ if (typeof opt_opts.boxClass !== "undefined") { // Must be first
+
+ this.boxClass_ = opt_opts.boxClass;
+ this.setBoxStyle_();
+ }
+ if (typeof opt_opts.boxStyle !== "undefined") { // Must be second
+
+ this.boxStyle_ = opt_opts.boxStyle;
+ this.setBoxStyle_();
+ }
+ if (typeof opt_opts.content !== "undefined") {
+
+ this.setContent(opt_opts.content);
+ }
+ if (typeof opt_opts.disableAutoPan !== "undefined") {
+
+ this.disableAutoPan_ = opt_opts.disableAutoPan;
+ }
+ if (typeof opt_opts.maxWidth !== "undefined") {
+
+ this.maxWidth_ = opt_opts.maxWidth;
+ }
+ if (typeof opt_opts.pixelOffset !== "undefined") {
+
+ this.pixelOffset_ = opt_opts.pixelOffset;
+ }
+ if (typeof opt_opts.alignBottom !== "undefined") {
+
+ this.alignBottom_ = opt_opts.alignBottom;
+ }
+ if (typeof opt_opts.position !== "undefined") {
+
+ this.setPosition(opt_opts.position);
+ }
+ if (typeof opt_opts.zIndex !== "undefined") {
+
+ this.setZIndex(opt_opts.zIndex);
+ }
+ if (typeof opt_opts.closeBoxMargin !== "undefined") {
+
+ this.closeBoxMargin_ = opt_opts.closeBoxMargin;
+ }
+ if (typeof opt_opts.closeBoxURL !== "undefined") {
+
+ this.closeBoxURL_ = opt_opts.closeBoxURL;
+ }
+ if (typeof opt_opts.infoBoxClearance !== "undefined") {
+
+ this.infoBoxClearance_ = opt_opts.infoBoxClearance;
+ }
+ if (typeof opt_opts.isHidden !== "undefined") {
+
+ this.isHidden_ = opt_opts.isHidden;
+ }
+ if (typeof opt_opts.visible !== "undefined") {
+
+ this.isHidden_ = !opt_opts.visible;
+ }
+ if (typeof opt_opts.enableEventPropagation !== "undefined") {
+
+ this.enableEventPropagation_ = opt_opts.enableEventPropagation;
+ }
+
+ if (this.div_) {
+
+ this.draw();
+ }
+};
+
+/**
+ * Sets the content of the InfoBox.
+ * The content can be plain text or an HTML DOM node.
+ * @param {string|Node} content
+ */
+InfoBox.prototype.setContent = function (content) {
+ this.content_ = content;
+
+ if (this.div_) {
+
+ if (this.closeListener_) {
+
+ google.maps.event.removeListener(this.closeListener_);
+ this.closeListener_ = null;
+ }
+
+ // Odd code required to make things work with MSIE.
+ //
+ if (!this.fixedWidthSet_) {
+
+ this.div_.style.width = "";
+ }
+
+ if (typeof content.nodeType === "undefined") {
+ this.div_.innerHTML = this.getCloseBoxImg_() + content;
+ } else {
+ this.div_.innerHTML = this.getCloseBoxImg_();
+ this.div_.appendChild(content);
+ }
+
+ // Perverse code required to make things work with MSIE.
+ // (Ensures the close box does, in fact, float to the right.)
+ //
+ if (!this.fixedWidthSet_) {
+ this.div_.style.width = this.div_.offsetWidth + "px";
+ if (typeof content.nodeType === "undefined") {
+ this.div_.innerHTML = this.getCloseBoxImg_() + content;
+ } else {
+ this.div_.innerHTML = this.getCloseBoxImg_();
+ this.div_.appendChild(content);
+ }
+ }
+
+ this.addClickHandler_();
+ }
+
+ /**
+ * This event is fired when the content of the InfoBox changes.
+ * @name InfoBox#content_changed
+ * @event
+ */
+ google.maps.event.trigger(this, "content_changed");
+};
+
+/**
+ * Sets the geographic location of the InfoBox.
+ * @param {LatLng} latlng
+ */
+InfoBox.prototype.setPosition = function (latlng) {
+
+ this.position_ = latlng;
+
+ if (this.div_) {
+
+ this.draw();
+ }
+
+ /**
+ * This event is fired when the position of the InfoBox changes.
+ * @name InfoBox#position_changed
+ * @event
+ */
+ google.maps.event.trigger(this, "position_changed");
+};
+
+/**
+ * Sets the zIndex style for the InfoBox.
+ * @param {number} index
+ */
+InfoBox.prototype.setZIndex = function (index) {
+
+ this.zIndex_ = index;
+
+ if (this.div_) {
+
+ this.div_.style.zIndex = index;
+ }
+
+ /**
+ * This event is fired when the zIndex of the InfoBox changes.
+ * @name InfoBox#zindex_changed
+ * @event
+ */
+ google.maps.event.trigger(this, "zindex_changed");
+};
+
+/**
+ * Sets the visibility of the InfoBox.
+ * @param {boolean} isVisible
+ */
+InfoBox.prototype.setVisible = function (isVisible) {
+
+ this.isHidden_ = !isVisible;
+ if (this.div_) {
+ this.div_.style.visibility = (this.isHidden_ ? "hidden" : "visible");
+ }
+};
+
+/**
+ * Returns the content of the InfoBox.
+ * @returns {string}
+ */
+InfoBox.prototype.getContent = function () {
+
+ return this.content_;
+};
+
+/**
+ * Returns the geographic location of the InfoBox.
+ * @returns {LatLng}
+ */
+InfoBox.prototype.getPosition = function () {
+
+ return this.position_;
+};
+
+/**
+ * Returns the zIndex for the InfoBox.
+ * @returns {number}
+ */
+InfoBox.prototype.getZIndex = function () {
+
+ return this.zIndex_;
+};
+
+/**
+ * Returns a flag indicating whether the InfoBox is visible.
+ * @returns {boolean}
+ */
+InfoBox.prototype.getVisible = function () {
+
+ var isVisible;
+
+ if ((typeof this.getMap() === "undefined") || (this.getMap() === null)) {
+ isVisible = false;
+ } else {
+ isVisible = !this.isHidden_;
+ }
+ return isVisible;
+};
+
+/**
+ * Shows the InfoBox. [Deprecated; use setVisible instead.]
+ */
+InfoBox.prototype.show = function () {
+
+ this.isHidden_ = false;
+ if (this.div_) {
+ this.div_.style.visibility = "visible";
+ }
+};
+
+/**
+ * Hides the InfoBox. [Deprecated; use setVisible instead.]
+ */
+InfoBox.prototype.hide = function () {
+
+ this.isHidden_ = true;
+ if (this.div_) {
+ this.div_.style.visibility = "hidden";
+ }
+};
+
+/**
+ * Adds the InfoBox to the specified map or Street View panorama. If anchor
+ * (usually a google.maps.Marker) is specified, the position
+ * of the InfoBox is set to the position of the anchor. If the
+ * anchor is dragged to a new location, the InfoBox moves as well.
+ * @param {Map|StreetViewPanorama} map
+ * @param {MVCObject} [anchor]
+ */
+InfoBox.prototype.open = function (map, anchor) {
+
+ var me = this;
+
+ if (anchor) {
+
+ this.position_ = anchor.getPosition();
+ this.moveListener_ = google.maps.event.addListener(anchor, "position_changed", function () {
+ me.setPosition(this.getPosition());
+ });
+ }
+
+ this.setMap(map);
+
+ if (this.div_) {
+
+ this.panBox_();
+ }
+};
+
+/**
+ * Removes the InfoBox from the map.
+ */
+InfoBox.prototype.close = function () {
+
+ var i;
+
+ if (this.closeListener_) {
+
+ google.maps.event.removeListener(this.closeListener_);
+ this.closeListener_ = null;
+ }
+
+ if (this.eventListeners_) {
+
+ for (i = 0; i < this.eventListeners_.length; i++) {
+
+ google.maps.event.removeListener(this.eventListeners_[i]);
+ }
+ this.eventListeners_ = null;
+ }
+
+ if (this.moveListener_) {
+
+ google.maps.event.removeListener(this.moveListener_);
+ this.moveListener_ = null;
+ }
+
+ if (this.contextListener_) {
+
+ google.maps.event.removeListener(this.contextListener_);
+ this.contextListener_ = null;
+ }
+
+ this.setMap(null);
+};
+
+/**
+ * google-maps-utility-library-v3-keydragzoom
+ *
+ * @version: 2.0.9
+ * @author: Nianwei Liu [nianwei at gmail dot com] & Gary Little [gary at luxcentral dot com]
+ * @contributors: undefined
+ * @date: Fri May 13 2016 13:45:18 GMT-0400 (EDT)
+ * @license: Apache License 2.0
+ */
+/**
+ * @fileoverview This library adds a drag zoom capability to a V3 Google map.
+ * When drag zoom is enabled, holding down a designated hot key
(shift | ctrl | alt)
+ * while dragging a box around an area of interest will zoom the map in to that area when
+ * the mouse button is released. Optionally, a visual control can also be supplied for turning
+ * a drag zoom operation on and off.
+ * Only one line of code is needed: google.maps.Map.enableKeyDragZoom();
+ *
+ * NOTE: Do not use Ctrl as the hot key with Google Maps JavaScript API V3 since, unlike with V2, + * it causes a context menu to appear when running on the Macintosh. + *
+ * Note that if the map's container has a border around it, the border widths must be specified + * in pixel units (or as thin, medium, or thick). This is required because of an MSIE limitation. + *
NL: 2009-05-28: initial port to core API V3.
+ *
NL: 2009-11-02: added a temp fix for -moz-transform for FF3.5.x using code from Paul Kulchenko (http://notebook.kulchenko.com/maps/gridmove).
+ *
NL: 2010-02-02: added a fix for IE flickering on divs onmousemove, caused by scroll value when get mouse position.
+ *
GL: 2010-06-15: added a visual control option.
+ */
+(function () {
+ /*jslint browser:true */
+ /*global window,google */
+ /* Utility functions use "var funName=function()" syntax to allow use of the */
+ /* Dean Edwards Packer compression tool (with Shrink variables, without Base62 encode). */
+
+ /**
+ * Converts "thin", "medium", and "thick" to pixel widths
+ * in an MSIE environment. Not called for other browsers
+ * because getComputedStyle() returns pixel widths automatically.
+ * @param {string} widthValue The value of the border width parameter.
+ */
+ var toPixels = function (widthValue) {
+ var px;
+ switch (widthValue) {
+ case "thin":
+ px = "2px";
+ break;
+ case "medium":
+ px = "4px";
+ break;
+ case "thick":
+ px = "6px";
+ break;
+ default:
+ px = widthValue;
+ }
+ return px;
+ };
+ /**
+ * Get the widths of the borders of an HTML element.
+ *
+ * @param {Node} h The HTML element.
+ * @return {Object} The width object {top, bottom left, right}.
+ */
+ var getBorderWidths = function (h) {
+ var computedStyle;
+ var bw = {};
+ if (document.defaultView && document.defaultView.getComputedStyle) {
+ computedStyle = h.ownerDocument.defaultView.getComputedStyle(h, "");
+ if (computedStyle) {
+ // The computed styles are always in pixel units (good!)
+ bw.top = parseInt(computedStyle.borderTopWidth, 10) || 0;
+ bw.bottom = parseInt(computedStyle.borderBottomWidth, 10) || 0;
+ bw.left = parseInt(computedStyle.borderLeftWidth, 10) || 0;
+ bw.right = parseInt(computedStyle.borderRightWidth, 10) || 0;
+ return bw;
+ }
+ } else if (document.documentElement.currentStyle) { // MSIE
+ if (h.currentStyle) {
+ // The current styles may not be in pixel units so try to convert (bad!)
+ bw.top = parseInt(toPixels(h.currentStyle.borderTopWidth), 10) || 0;
+ bw.bottom = parseInt(toPixels(h.currentStyle.borderBottomWidth), 10) || 0;
+ bw.left = parseInt(toPixels(h.currentStyle.borderLeftWidth), 10) || 0;
+ bw.right = parseInt(toPixels(h.currentStyle.borderRightWidth), 10) || 0;
+ return bw;
+ }
+ }
+ // Shouldn't get this far for any modern browser
+ bw.top = parseInt(h.style["border-top-width"], 10) || 0;
+ bw.bottom = parseInt(h.style["border-bottom-width"], 10) || 0;
+ bw.left = parseInt(h.style["border-left-width"], 10) || 0;
+ bw.right = parseInt(h.style["border-right-width"], 10) || 0;
+ return bw;
+ };
+
+ // Page scroll values for use by getMousePosition. To prevent flickering on MSIE
+ // they are calculated only when the document actually scrolls, not every time the
+ // mouse moves (as they would be if they were calculated inside getMousePosition).
+ var scroll = {
+ x: 0,
+ y: 0
+ };
+ var getScrollValue = function (e) {
+ scroll.x = (typeof document.documentElement.scrollLeft !== "undefined" ? document.documentElement.scrollLeft : document.body.scrollLeft);
+ scroll.y = (typeof document.documentElement.scrollTop !== "undefined" ? document.documentElement.scrollTop : document.body.scrollTop);
+ };
+ getScrollValue();
+
+ /**
+ * Get the position of the mouse relative to the document.
+ * @param {Event} e The mouse event.
+ * @return {Object} The position object {left, top}.
+ */
+ var getMousePosition = function (e) {
+ var posX = 0, posY = 0;
+ e = e || window.event;
+ if (typeof e.pageX !== "undefined") {
+ posX = e.pageX;
+ posY = e.pageY;
+ } else if (typeof e.clientX !== "undefined") { // MSIE
+ posX = e.clientX + scroll.x;
+ posY = e.clientY + scroll.y;
+ }
+ return {
+ left: posX,
+ top: posY
+ };
+ };
+ /**
+ * Get the position of an HTML element relative to the document.
+ * @param {Node} h The HTML element.
+ * @return {Object} The position object {left, top}.
+ */
+ var getElementPosition = function (h) {
+ var posX = h.offsetLeft;
+ var posY = h.offsetTop;
+ var parent = h.offsetParent;
+ // Add offsets for all ancestors in the hierarchy
+ while (parent !== null) {
+ // Adjust for scrolling elements which may affect the map position.
+ //
+ // See http://www.howtocreate.co.uk/tutorials/javascript/browserspecific
+ //
+ // "...make sure that every element [on a Web page] with an overflow
+ // of anything other than visible also has a position style set to
+ // something other than the default static..."
+ if (parent !== document.body && parent !== document.documentElement) {
+ posX -= parent.scrollLeft;
+ posY -= parent.scrollTop;
+ }
+ // See http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/4cb86c0c1037a5e5
+ // Example: http://notebook.kulchenko.com/maps/gridmove
+ var m = parent;
+ // This is the "normal" way to get offset information:
+ var moffx = m.offsetLeft;
+ var moffy = m.offsetTop;
+ // This covers those cases where a transform is used:
+ if (!moffx && !moffy && window.getComputedStyle) {
+ var matrix = document.defaultView.getComputedStyle(m, null).MozTransform ||
+ document.defaultView.getComputedStyle(m, null).WebkitTransform;
+ if (matrix) {
+ if (typeof matrix === "string") {
+ var parms = matrix.split(",");
+ moffx += parseInt(parms[4], 10) || 0;
+ moffy += parseInt(parms[5], 10) || 0;
+ }
+ }
+ }
+ posX += moffx;
+ posY += moffy;
+ parent = parent.offsetParent;
+ }
+ return {
+ left: posX,
+ top: posY
+ };
+ };
+ /**
+ * Set the properties of an object to those from another object.
+ * @param {Object} obj The target object.
+ * @param {Object} vals The source object.
+ */
+ var setVals = function (obj, vals) {
+ if (obj && vals) {
+ for (var x in vals) {
+ if (vals.hasOwnProperty(x)) {
+ obj[x] = vals[x];
+ }
+ }
+ }
+ return obj;
+ };
+ /**
+ * Set the opacity. If op is not passed in, this function just performs an MSIE fix.
+ * @param {Node} h The HTML element.
+ * @param {number} op The opacity value (0-1).
+ */
+ var setOpacity = function (h, op) {
+ if (typeof op !== "undefined") {
+ h.style.opacity = op;
+ }
+ if (typeof h.style.opacity !== "undefined" && h.style.opacity !== "") {
+ h.style.filter = "alpha(opacity=" + (h.style.opacity * 100) + ")";
+ }
+ };
+ /**
+ * @name KeyDragZoomOptions
+ * @class This class represents the optional parameter passed into google.maps.Map.enableKeyDragZoom.
+ * @property {string} [key="shift"] The hot key to hold down to activate a drag zoom, shift | ctrl | alt.
+ * NOTE: Do not use Ctrl as the hot key with Google Maps JavaScript API V3 since, unlike with V2,
+ * it causes a context menu to appear when running on the Macintosh. Also note that the
+ * alt hot key refers to the Option key on a Macintosh.
+ * @property {Object} [boxStyle={border: "4px solid #736AFF"}]
+ * An object literal defining the CSS styles of the zoom box.
+ * Border widths must be specified in pixel units (or as thin, medium, or thick).
+ * @property {Object} [veilStyle={backgroundColor: "gray", opacity: 0.25, cursor: "crosshair"}]
+ * An object literal defining the CSS styles of the veil pane which covers the map when a drag
+ * zoom is activated. The previous name for this property was paneStyle but the use
+ * of this name is now deprecated.
+ * @property {boolean} [noZoom=false] A flag indicating whether to disable zooming after an area is
+ * selected. Set this to true to allow KeyDragZoom to be used as a simple area
+ * selection tool.
+ * @property {boolean} [visualEnabled=false] A flag indicating whether a visual control is to be used.
+ * @property {string} [visualClass=""] The name of the CSS class defining the styles for the visual
+ * control. To prevent the visual control from being printed, set this property to the name of
+ * a class, defined inside a @media print rule, which sets the CSS
+ * display style to none.
+ * @property {ControlPosition} [visualPosition=google.maps.ControlPosition.LEFT_TOP]
+ * The position of the visual control.
+ * @property {Size} [visualPositionOffset=google.maps.Size(35, 0)] The width and height values
+ * provided by this property are the offsets (in pixels) from the location at which the control
+ * would normally be drawn to the desired drawing location.
+ * @property {number} [visualPositionIndex=null] The index of the visual control.
+ * The index is for controlling the placement of the control relative to other controls at the
+ * position given by visualPosition; controls with a lower index are placed first.
+ * Use a negative value to place the control before any default controls. No index is
+ * generally required.
+ * @property {String} [visualSprite="http://maps.gstatic.com/mapfiles/ftr/controls/dragzoom_btn.png"]
+ * The URL of the sprite image used for showing the visual control in the on, off, and hot
+ * (i.e., when the mouse is over the control) states. The three images within the sprite must
+ * be the same size and arranged in on-hot-off order in a single row with no spaces between images.
+ * @property {Size} [visualSize=google.maps.Size(20, 20)] The width and height values provided by
+ * this property are the size (in pixels) of each of the images within visualSprite.
+ * @property {Object} [visualTips={off: "Turn on drag zoom mode", on: "Turn off drag zoom mode"}]
+ * An object literal defining the help tips that appear when
+ * the mouse moves over the visual control. The off property is the tip to be shown
+ * when the control is off and the on property is the tip to be shown when the
+ * control is on.
+ */
+ /**
+ * @name DragZoom
+ * @class This class represents a drag zoom object for a map. The object is activated by holding down the hot key
+ * or by turning on the visual control.
+ * This object is created when google.maps.Map.enableKeyDragZoom is called; it cannot be created directly.
+ * Use google.maps.Map.getDragZoomObject to gain access to this object in order to attach event listeners.
+ * @param {Map} map The map to which the DragZoom object is to be attached.
+ * @param {KeyDragZoomOptions} [opt_zoomOpts] The optional parameters.
+ */
+ function DragZoom(map, opt_zoomOpts) {
+ var me = this;
+ var ov = new google.maps.OverlayView();
+ ov.onAdd = function () {
+ me.init_(map, opt_zoomOpts);
+ };
+ ov.draw = function () {
+ };
+ ov.onRemove = function () {
+ };
+ ov.setMap(map);
+ this.prjov_ = ov;
+ }
+ /**
+ * Initialize the tool.
+ * @param {Map} map The map to which the DragZoom object is to be attached.
+ * @param {KeyDragZoomOptions} [opt_zoomOpts] The optional parameters.
+ */
+ DragZoom.prototype.init_ = function (map, opt_zoomOpts) {
+ var i;
+ var me = this;
+ this.map_ = map;
+ opt_zoomOpts = opt_zoomOpts || {};
+ this.key_ = opt_zoomOpts.key || "shift";
+ this.key_ = this.key_.toLowerCase();
+ this.borderWidths_ = getBorderWidths(this.map_.getDiv());
+ this.veilDiv_ = [];
+ for (i = 0; i < 4; i++) {
+ this.veilDiv_[i] = document.createElement("div");
+ // Prevents selection of other elements on the webpage
+ // when a drag zoom operation is in progress:
+ this.veilDiv_[i].onselectstart = function () {
+ return false;
+ };
+ // Apply default style values for the veil:
+ setVals(this.veilDiv_[i].style, {
+ backgroundColor: "gray",
+ opacity: 0.25,
+ cursor: "crosshair"
+ });
+ // Apply style values specified in veilStyle parameter:
+ setVals(this.veilDiv_[i].style, opt_zoomOpts.paneStyle); // Old option name was "paneStyle"
+ setVals(this.veilDiv_[i].style, opt_zoomOpts.veilStyle); // New name is "veilStyle"
+ // Apply mandatory style values:
+ setVals(this.veilDiv_[i].style, {
+ position: "absolute",
+ overflow: "hidden",
+ display: "none"
+ });
+ // Workaround for Firefox Shift-Click problem:
+ if (this.key_ === "shift") {
+ this.veilDiv_[i].style.MozUserSelect = "none";
+ }
+ setOpacity(this.veilDiv_[i]);
+ // An IE fix: If the background is transparent it cannot capture mousedown
+ // events, so if it is, change the background to white with 0 opacity.
+ if (this.veilDiv_[i].style.backgroundColor === "transparent") {
+ this.veilDiv_[i].style.backgroundColor = "white";
+ setOpacity(this.veilDiv_[i], 0);
+ }
+ this.map_.getDiv().appendChild(this.veilDiv_[i]);
+ }
+
+ this.noZoom_ = opt_zoomOpts.noZoom || false;
+ this.visualEnabled_ = opt_zoomOpts.visualEnabled || false;
+ this.visualClass_ = opt_zoomOpts.visualClass || "";
+ this.visualPosition_ = opt_zoomOpts.visualPosition || google.maps.ControlPosition.LEFT_TOP;
+ this.visualPositionOffset_ = opt_zoomOpts.visualPositionOffset || new google.maps.Size(35, 0);
+ this.visualPositionIndex_ = opt_zoomOpts.visualPositionIndex || null;
+ this.visualSprite_ = opt_zoomOpts.visualSprite || "http" + (document.location.protocol === "https:" ? "s" : "") + "://maps.gstatic.com/mapfiles/ftr/controls/dragzoom_btn.png";
+ this.visualSize_ = opt_zoomOpts.visualSize || new google.maps.Size(20, 20);
+ this.visualTips_ = opt_zoomOpts.visualTips || {};
+ this.visualTips_.off = this.visualTips_.off || "Turn on drag zoom mode";
+ this.visualTips_.on = this.visualTips_.on || "Turn off drag zoom mode";
+
+ this.boxDiv_ = document.createElement("div");
+ // Apply default style values for the zoom box:
+ setVals(this.boxDiv_.style, {
+ border: "4px solid #736AFF"
+ });
+ // Apply style values specified in boxStyle parameter:
+ setVals(this.boxDiv_.style, opt_zoomOpts.boxStyle);
+ // Apply mandatory style values:
+ setVals(this.boxDiv_.style, {
+ position: "absolute",
+ display: "none"
+ });
+ setOpacity(this.boxDiv_);
+ this.map_.getDiv().appendChild(this.boxDiv_);
+ this.boxBorderWidths_ = getBorderWidths(this.boxDiv_);
+
+ this.listeners_ = [
+ google.maps.event.addDomListener(document, "keydown", function (e) {
+ me.onKeyDown_(e);
+ }),
+ google.maps.event.addDomListener(document, "keyup", function (e) {
+ me.onKeyUp_(e);
+ }),
+ google.maps.event.addDomListener(this.veilDiv_[0], "mousedown", function (e) {
+ me.onMouseDown_(e);
+ }),
+ google.maps.event.addDomListener(this.veilDiv_[1], "mousedown", function (e) {
+ me.onMouseDown_(e);
+ }),
+ google.maps.event.addDomListener(this.veilDiv_[2], "mousedown", function (e) {
+ me.onMouseDown_(e);
+ }),
+ google.maps.event.addDomListener(this.veilDiv_[3], "mousedown", function (e) {
+ me.onMouseDown_(e);
+ }),
+ google.maps.event.addDomListener(document, "mousedown", function (e) {
+ me.onMouseDownDocument_(e);
+ }),
+ google.maps.event.addDomListener(document, "mousemove", function (e) {
+ me.onMouseMove_(e);
+ }),
+ google.maps.event.addDomListener(document, "mouseup", function (e) {
+ me.onMouseUp_(e);
+ }),
+ google.maps.event.addDomListener(window, "scroll", getScrollValue)
+ ];
+
+ this.hotKeyDown_ = false;
+ this.mouseDown_ = false;
+ this.dragging_ = false;
+ this.startPt_ = null;
+ this.endPt_ = null;
+ this.mapWidth_ = null;
+ this.mapHeight_ = null;
+ this.mousePosn_ = null;
+ this.mapPosn_ = null;
+
+ if (this.visualEnabled_) {
+ this.buttonDiv_ = this.initControl_(this.visualPositionOffset_);
+ if (this.visualPositionIndex_ !== null) {
+ this.buttonDiv_.index = this.visualPositionIndex_;
+ }
+ this.map_.controls[this.visualPosition_].push(this.buttonDiv_);
+ this.controlIndex_ = this.map_.controls[this.visualPosition_].length - 1;
+ }
+ };
+ /**
+ * Initializes the visual control and returns its DOM element.
+ * @param {Size} offset The offset of the control from its normal position.
+ * @return {Node} The DOM element containing the visual control.
+ */
+ DragZoom.prototype.initControl_ = function (offset) {
+ var control;
+ var image;
+ var me = this;
+
+ control = document.createElement("div");
+ control.className = this.visualClass_;
+ control.style.position = "relative";
+ control.style.overflow = "hidden";
+ control.style.height = this.visualSize_.height + "px";
+ control.style.width = this.visualSize_.width + "px";
+ control.title = this.visualTips_.off;
+ image = document.createElement("img");
+ image.src = this.visualSprite_;
+ image.style.position = "absolute";
+ image.style.left = -(this.visualSize_.width * 2) + "px";
+ image.style.top = 0 + "px";
+ control.appendChild(image);
+ control.onclick = function (e) {
+ me.hotKeyDown_ = !me.hotKeyDown_;
+ if (me.hotKeyDown_) {
+ me.buttonDiv_.firstChild.style.left = -(me.visualSize_.width * 0) + "px";
+ me.buttonDiv_.title = me.visualTips_.on;
+ me.activatedByControl_ = true;
+ google.maps.event.trigger(me, "activate");
+ } else {
+ me.buttonDiv_.firstChild.style.left = -(me.visualSize_.width * 2) + "px";
+ me.buttonDiv_.title = me.visualTips_.off;
+ google.maps.event.trigger(me, "deactivate");
+ }
+ me.onMouseMove_(e); // Updates the veil
+ };
+ control.onmouseover = function () {
+ me.buttonDiv_.firstChild.style.left = -(me.visualSize_.width * 1) + "px";
+ };
+ control.onmouseout = function () {
+ if (me.hotKeyDown_) {
+ me.buttonDiv_.firstChild.style.left = -(me.visualSize_.width * 0) + "px";
+ me.buttonDiv_.title = me.visualTips_.on;
+ } else {
+ me.buttonDiv_.firstChild.style.left = -(me.visualSize_.width * 2) + "px";
+ me.buttonDiv_.title = me.visualTips_.off;
+ }
+ };
+ control.ondragstart = function () {
+ return false;
+ };
+ setVals(control.style, {
+ cursor: "pointer",
+ marginTop: offset.height + "px",
+ marginLeft: offset.width + "px"
+ });
+ return control;
+ };
+ /**
+ * Returns true if the hot key is being pressed when an event occurs.
+ * @param {Event} e The keyboard event.
+ * @return {boolean} Flag indicating whether the hot key is down.
+ */
+ DragZoom.prototype.isHotKeyDown_ = function (e) {
+ var isHot;
+ e = e || window.event;
+ isHot = (e.shiftKey && this.key_ === "shift") || (e.altKey && this.key_ === "alt") || (e.ctrlKey && this.key_ === "ctrl");
+ if (!isHot) {
+ // Need to look at keyCode for Opera because it
+ // doesn't set the shiftKey, altKey, ctrlKey properties
+ // unless a non-modifier event is being reported.
+ //
+ // See http://cross-browser.com/x/examples/shift_mode.php
+ // Also see http://unixpapa.com/js/key.html
+ switch (e.keyCode) {
+ case 16:
+ if (this.key_ === "shift") {
+ isHot = true;
+ }
+ break;
+ case 17:
+ if (this.key_ === "ctrl") {
+ isHot = true;
+ }
+ break;
+ case 18:
+ if (this.key_ === "alt") {
+ isHot = true;
+ }
+ break;
+ }
+ }
+ return isHot;
+ };
+ /**
+ * Returns true if the mouse is on top of the map div.
+ * The position is captured in onMouseMove_.
+ * @return {boolean}
+ */
+ DragZoom.prototype.isMouseOnMap_ = function () {
+ var mousePosn = this.mousePosn_;
+ if (mousePosn) {
+ var mapPosn = this.mapPosn_;
+ var mapDiv = this.map_.getDiv();
+ return mousePosn.left > mapPosn.left && mousePosn.left < (mapPosn.left + mapDiv.offsetWidth) &&
+ mousePosn.top > mapPosn.top && mousePosn.top < (mapPosn.top + mapDiv.offsetHeight);
+ } else {
+ // if user never moved mouse
+ return false;
+ }
+ };
+ /**
+ * Show the veil if the hot key is down and the mouse is over the map,
+ * otherwise hide the veil.
+ */
+ DragZoom.prototype.setVeilVisibility_ = function () {
+ var i;
+ if (this.map_ && this.hotKeyDown_ && this.isMouseOnMap_()) {
+ var mapDiv = this.map_.getDiv();
+ this.mapWidth_ = mapDiv.offsetWidth - (this.borderWidths_.left + this.borderWidths_.right);
+ this.mapHeight_ = mapDiv.offsetHeight - (this.borderWidths_.top + this.borderWidths_.bottom);
+ if (this.activatedByControl_) { // Veil covers entire map (except control)
+ var left = parseInt(this.buttonDiv_.style.left, 10) + this.visualPositionOffset_.width;
+ var top = parseInt(this.buttonDiv_.style.top, 10) + this.visualPositionOffset_.height;
+ var width = this.visualSize_.width;
+ var height = this.visualSize_.height;
+ // Left veil rectangle:
+ this.veilDiv_[0].style.top = "0px";
+ this.veilDiv_[0].style.left = "0px";
+ this.veilDiv_[0].style.width = left + "px";
+ this.veilDiv_[0].style.height = this.mapHeight_ + "px";
+ // Right veil rectangle:
+ this.veilDiv_[1].style.top = "0px";
+ this.veilDiv_[1].style.left = (left + width) + "px";
+ this.veilDiv_[1].style.width = (this.mapWidth_ - (left + width)) + "px";
+ this.veilDiv_[1].style.height = this.mapHeight_ + "px";
+ // Top veil rectangle:
+ this.veilDiv_[2].style.top = "0px";
+ this.veilDiv_[2].style.left = left + "px";
+ this.veilDiv_[2].style.width = width + "px";
+ this.veilDiv_[2].style.height = top + "px";
+ // Bottom veil rectangle:
+ this.veilDiv_[3].style.top = (top + height) + "px";
+ this.veilDiv_[3].style.left = left + "px";
+ this.veilDiv_[3].style.width = width + "px";
+ this.veilDiv_[3].style.height = (this.mapHeight_ - (top + height)) + "px";
+ for (i = 0; i < this.veilDiv_.length; i++) {
+ this.veilDiv_[i].style.display = "block";
+ }
+ } else {
+ this.veilDiv_[0].style.left = "0px";
+ this.veilDiv_[0].style.top = "0px";
+ this.veilDiv_[0].style.width = this.mapWidth_ + "px";
+ this.veilDiv_[0].style.height = this.mapHeight_ + "px";
+ for (i = 1; i < this.veilDiv_.length; i++) {
+ this.veilDiv_[i].style.width = "0px";
+ this.veilDiv_[i].style.height = "0px";
+ }
+ for (i = 0; i < this.veilDiv_.length; i++) {
+ this.veilDiv_[i].style.display = "block";
+ }
+ }
+ } else {
+ for (i = 0; i < this.veilDiv_.length; i++) {
+ this.veilDiv_[i].style.display = "none";
+ }
+ }
+ };
+ /**
+ * Handle key down. Show the veil if the hot key has been pressed.
+ * @param {Event} e The keyboard event.
+ */
+ DragZoom.prototype.onKeyDown_ = function (e) {
+ if (this.map_ && !this.hotKeyDown_ && this.isHotKeyDown_(e)) {
+ this.mapPosn_ = getElementPosition(this.map_.getDiv());
+ this.hotKeyDown_ = true;
+ this.activatedByControl_ = false;
+ this.setVeilVisibility_();
+ /**
+ * This event is fired when the hot key is pressed.
+ * @name DragZoom#activate
+ * @event
+ */
+ google.maps.event.trigger(this, "activate");
+ }
+ };
+ /**
+ * Get the google.maps.Point of the mouse position.
+ * @param {Event} e The mouse event.
+ * @return {Point} The mouse position.
+ */
+ DragZoom.prototype.getMousePoint_ = function (e) {
+ var mousePosn = getMousePosition(e);
+ var p = new google.maps.Point();
+ p.x = mousePosn.left - this.mapPosn_.left - this.borderWidths_.left;
+ p.y = mousePosn.top - this.mapPosn_.top - this.borderWidths_.top;
+ p.x = Math.min(p.x, this.mapWidth_);
+ p.y = Math.min(p.y, this.mapHeight_);
+ p.x = Math.max(p.x, 0);
+ p.y = Math.max(p.y, 0);
+ return p;
+ };
+ /**
+ * Handle mouse down.
+ * @param {Event} e The mouse event.
+ */
+ DragZoom.prototype.onMouseDown_ = function (e) {
+ if (this.map_ && this.hotKeyDown_) {
+ this.mapPosn_ = getElementPosition(this.map_.getDiv());
+ this.dragging_ = true;
+ this.startPt_ = this.endPt_ = this.getMousePoint_(e);
+ this.boxDiv_.style.width = this.boxDiv_.style.height = "0px";
+ var prj = this.prjov_.getProjection();
+ var latlng = prj.fromContainerPixelToLatLng(this.startPt_);
+ /**
+ * This event is fired when the drag operation begins.
+ * The parameter passed is the geographic position of the starting point.
+ * @name DragZoom#dragstart
+ * @param {LatLng} latlng The geographic position of the starting point.
+ * @event
+ */
+ google.maps.event.trigger(this, "dragstart", latlng);
+ }
+ };
+ /**
+ * Handle mouse down at the document level.
+ * @param {Event} e The mouse event.
+ */
+ DragZoom.prototype.onMouseDownDocument_ = function (e) {
+ this.mouseDown_ = true;
+ };
+ /**
+ * Handle mouse move.
+ * @param {Event} e The mouse event.
+ */
+ DragZoom.prototype.onMouseMove_ = function (e) {
+ this.mousePosn_ = getMousePosition(e);
+ if (this.dragging_) {
+ this.endPt_ = this.getMousePoint_(e);
+ var left = Math.min(this.startPt_.x, this.endPt_.x);
+ var top = Math.min(this.startPt_.y, this.endPt_.y);
+ var width = Math.abs(this.startPt_.x - this.endPt_.x);
+ var height = Math.abs(this.startPt_.y - this.endPt_.y);
+ // For benefit of MSIE 7/8 ensure following values are not negative:
+ var boxWidth = Math.max(0, width - (this.boxBorderWidths_.left + this.boxBorderWidths_.right));
+ var boxHeight = Math.max(0, height - (this.boxBorderWidths_.top + this.boxBorderWidths_.bottom));
+ // Left veil rectangle:
+ this.veilDiv_[0].style.top = "0px";
+ this.veilDiv_[0].style.left = "0px";
+ this.veilDiv_[0].style.width = left + "px";
+ this.veilDiv_[0].style.height = this.mapHeight_ + "px";
+ // Right veil rectangle:
+ this.veilDiv_[1].style.top = "0px";
+ this.veilDiv_[1].style.left = (left + width) + "px";
+ this.veilDiv_[1].style.width = (this.mapWidth_ - (left + width)) + "px";
+ this.veilDiv_[1].style.height = this.mapHeight_ + "px";
+ // Top veil rectangle:
+ this.veilDiv_[2].style.top = "0px";
+ this.veilDiv_[2].style.left = left + "px";
+ this.veilDiv_[2].style.width = width + "px";
+ this.veilDiv_[2].style.height = top + "px";
+ // Bottom veil rectangle:
+ this.veilDiv_[3].style.top = (top + height) + "px";
+ this.veilDiv_[3].style.left = left + "px";
+ this.veilDiv_[3].style.width = width + "px";
+ this.veilDiv_[3].style.height = (this.mapHeight_ - (top + height)) + "px";
+ // Selection rectangle:
+ this.boxDiv_.style.top = top + "px";
+ this.boxDiv_.style.left = left + "px";
+ this.boxDiv_.style.width = boxWidth + "px";
+ this.boxDiv_.style.height = boxHeight + "px";
+ this.boxDiv_.style.display = "block";
+ /**
+ * This event is fired repeatedly while the user drags a box across the area of interest.
+ * The southwest and northeast point are passed as parameters of type google.maps.Point
+ * (for performance reasons), relative to the map container. Also passed is the projection object
+ * so that the event listener, if necessary, can convert the pixel positions to geographic
+ * coordinates using google.maps.MapCanvasProjection.fromContainerPixelToLatLng.
+ * @name DragZoom#drag
+ * @param {Point} southwestPixel The southwest point of the selection area.
+ * @param {Point} northeastPixel The northeast point of the selection area.
+ * @param {MapCanvasProjection} prj The projection object.
+ * @event
+ */
+ google.maps.event.trigger(this, "drag", new google.maps.Point(left, top + height), new google.maps.Point(left + width, top), this.prjov_.getProjection());
+ } else if (!this.mouseDown_) {
+ this.mapPosn_ = getElementPosition(this.map_.getDiv());
+ this.setVeilVisibility_();
+ }
+ };
+ /**
+ * Handle mouse up.
+ * @param {Event} e The mouse event.
+ */
+ DragZoom.prototype.onMouseUp_ = function (e) {
+ var z;
+ var me = this;
+ this.mouseDown_ = false;
+ if (this.dragging_) {
+ if ((this.getMousePoint_(e).x === this.startPt_.x) && (this.getMousePoint_(e).y === this.startPt_.y)) {
+ this.onKeyUp_(e); // Cancel event
+ return;
+ }
+ var left = Math.min(this.startPt_.x, this.endPt_.x);
+ var top = Math.min(this.startPt_.y, this.endPt_.y);
+ var width = Math.abs(this.startPt_.x - this.endPt_.x);
+ var height = Math.abs(this.startPt_.y - this.endPt_.y);
+ // Google Maps API bug: setCenter() doesn't work as expected if the map has a
+ // border on the left or top. The code here includes a workaround for this problem.
+ var kGoogleCenteringBug = true;
+ if (kGoogleCenteringBug) {
+ left += this.borderWidths_.left;
+ top += this.borderWidths_.top;
+ }
+
+ var prj = this.prjov_.getProjection();
+ var sw = prj.fromContainerPixelToLatLng(new google.maps.Point(left, top + height));
+ var ne = prj.fromContainerPixelToLatLng(new google.maps.Point(left + width, top));
+ var bnds = new google.maps.LatLngBounds(sw, ne);
+
+ if (this.noZoom_) {
+ this.boxDiv_.style.display = "none";
+ } else {
+ // Sometimes fitBounds causes a zoom OUT, so restore original zoom level if this happens.
+ z = this.map_.getZoom();
+ this.map_.fitBounds(bnds);
+ if (this.map_.getZoom() < z) {
+ this.map_.setZoom(z);
+ }
+
+ // Redraw box after zoom:
+ var swPt = prj.fromLatLngToContainerPixel(sw);
+ var nePt = prj.fromLatLngToContainerPixel(ne);
+ if (kGoogleCenteringBug) {
+ swPt.x -= this.borderWidths_.left;
+ swPt.y -= this.borderWidths_.top;
+ nePt.x -= this.borderWidths_.left;
+ nePt.y -= this.borderWidths_.top;
+ }
+ this.boxDiv_.style.left = swPt.x + "px";
+ this.boxDiv_.style.top = nePt.y + "px";
+ this.boxDiv_.style.width = (Math.abs(nePt.x - swPt.x) - (this.boxBorderWidths_.left + this.boxBorderWidths_.right)) + "px";
+ this.boxDiv_.style.height = (Math.abs(nePt.y - swPt.y) - (this.boxBorderWidths_.top + this.boxBorderWidths_.bottom)) + "px";
+ // Hide box asynchronously after 1 second:
+ setTimeout(function () {
+ me.boxDiv_.style.display = "none";
+ }, 1000);
+ }
+ this.dragging_ = false;
+ this.onMouseMove_(e); // Updates the veil
+ /**
+ * This event is fired when the drag operation ends.
+ * The parameter passed is the geographic bounds of the selected area.
+ * Note that this event is not fired if the hot key is released before the drag operation ends.
+ * @name DragZoom#dragend
+ * @param {LatLngBounds} bnds The geographic bounds of the selected area.
+ * @event
+ */
+ google.maps.event.trigger(this, "dragend", bnds);
+ // if the hot key isn't down, the drag zoom must have been activated by turning
+ // on the visual control. In this case, finish up by simulating a key up event.
+ if (!this.isHotKeyDown_(e)) {
+ this.onKeyUp_(e);
+ }
+ }
+ };
+ /**
+ * Handle key up.
+ * @param {Event} e The keyboard event.
+ */
+ DragZoom.prototype.onKeyUp_ = function (e) {
+ var i;
+ var left, top, width, height, prj, sw, ne;
+ var bnds = null;
+ if (this.map_ && this.hotKeyDown_) {
+ this.hotKeyDown_ = false;
+ if (this.dragging_) {
+ this.boxDiv_.style.display = "none";
+ this.dragging_ = false;
+ // Calculate the bounds when drag zoom was cancelled
+ left = Math.min(this.startPt_.x, this.endPt_.x);
+ top = Math.min(this.startPt_.y, this.endPt_.y);
+ width = Math.abs(this.startPt_.x - this.endPt_.x);
+ height = Math.abs(this.startPt_.y - this.endPt_.y);
+ prj = this.prjov_.getProjection();
+ sw = prj.fromContainerPixelToLatLng(new google.maps.Point(left, top + height));
+ ne = prj.fromContainerPixelToLatLng(new google.maps.Point(left + width, top));
+ bnds = new google.maps.LatLngBounds(sw, ne);
+ }
+ for (i = 0; i < this.veilDiv_.length; i++) {
+ this.veilDiv_[i].style.display = "none";
+ }
+ if (this.visualEnabled_) {
+ this.buttonDiv_.firstChild.style.left = -(this.visualSize_.width * 2) + "px";
+ this.buttonDiv_.title = this.visualTips_.off;
+ this.buttonDiv_.style.display = "";
+ }
+ /**
+ * This event is fired when the hot key is released.
+ * The parameter passed is the geographic bounds of the selected area immediately
+ * before the hot key was released.
+ * @name DragZoom#deactivate
+ * @param {LatLngBounds} bnds The geographic bounds of the selected area immediately
+ * before the hot key was released.
+ * @event
+ */
+ google.maps.event.trigger(this, "deactivate", bnds);
+ }
+ };
+ /**
+ * @name google.maps.Map
+ * @class These are new methods added to the Google Maps JavaScript API V3's
+ * Map
+ * class.
+ */
+ /**
+ * Enables drag zoom. The user can zoom to an area of interest by holding down the hot key
+ * (shift | ctrl | alt ) while dragging a box around the area or by turning
+ * on the visual control then dragging a box around the area.
+ * @param {KeyDragZoomOptions} opt_zoomOpts The optional parameters.
+ */
+ google.maps.Map.prototype.enableKeyDragZoom = function (opt_zoomOpts) {
+ this.dragZoom_ = new DragZoom(this, opt_zoomOpts);
+ };
+ /**
+ * Disables drag zoom.
+ */
+ google.maps.Map.prototype.disableKeyDragZoom = function () {
+ var i;
+ var d = this.dragZoom_;
+ if (d) {
+ for (i = 0; i < d.listeners_.length; ++i) {
+ google.maps.event.removeListener(d.listeners_[i]);
+ }
+ this.getDiv().removeChild(d.boxDiv_);
+ for (i = 0; i < d.veilDiv_.length; i++) {
+ this.getDiv().removeChild(d.veilDiv_[i]);
+ }
+ if (d.visualEnabled_) {
+ // Remove the custom control:
+ this.controls[d.visualPosition_].removeAt(d.controlIndex_);
+ }
+ d.prjov_.setMap(null);
+ this.dragZoom_ = null;
+ }
+ };
+ /**
+ * Returns true if the drag zoom feature has been enabled.
+ * @return {boolean}
+ */
+ google.maps.Map.prototype.keyDragZoomEnabled = function () {
+ return this.dragZoom_ !== null;
+ };
+ /**
+ * Returns the DragZoom object which is created when google.maps.Map.enableKeyDragZoom is called.
+ * With this object you can use google.maps.event.addListener to attach event listeners
+ * for the "activate", "deactivate", "dragstart", "drag", and "dragend" events.
+ * @return {DragZoom}
+ */
+ google.maps.Map.prototype.getDragZoomObject = function () {
+ return this.dragZoom_;
+ };
+})();
+
+/**
+ * google-maps-utility-library-v3-markerwithlabel
+ *
+ * @version: 1.1.10
+ * @author: Gary Little (inspired by code from Marc Ridey of Google).
+ * @contributors: Nicholas McCready
+ * @date: Fri May 13 2016 16:29:58 GMT-0400 (EDT)
+ * @license: Apache License 2.0
+ */
+/**
+ * MarkerWithLabel allows you to define markers with associated labels. As you would expect,
+ * if the marker is draggable, so too will be the label. In addition, a marker with a label
+ * responds to all mouse events in the same manner as a regular marker. It also fires mouse
+ * events and "property changed" events just as a regular marker would. Version 1.1 adds
+ * support for the raiseOnDrag feature introduced in API V3.3.
+ *
+ * If you drag a marker by its label, you can cancel the drag and return the marker to its
+ * original position by pressing the Esc key. This doesn't work if you drag the marker
+ * itself because this feature is not (yet) supported in the google.maps.Marker class.
+ */
+
+/*jslint browser:true */
+/*global document,google */
+
+/**
+ * @param {Function} childCtor Child class.
+ * @param {Function} parentCtor Parent class.
+ * @private
+ */
+function inherits(childCtor, parentCtor) {
+ /* @constructor */
+ function tempCtor() {}
+ tempCtor.prototype = parentCtor.prototype;
+ childCtor.superClass_ = parentCtor.prototype;
+ childCtor.prototype = new tempCtor();
+ /* @override */
+ childCtor.prototype.constructor = childCtor;
+}
+
+/**
+ * This constructor creates a label and associates it with a marker.
+ * It is for the private use of the MarkerWithLabel class.
+ * @constructor
+ * @param {Marker} marker The marker with which the label is to be associated.
+ * @param {string} crossURL The URL of the cross image =.
+ * @param {string} handCursor The URL of the hand cursor.
+ * @private
+ */
+function MarkerLabel_(marker, crossURL, handCursorURL) {
+ this.marker_ = marker;
+ this.handCursorURL_ = marker.handCursorURL;
+
+ this.labelDiv_ = document.createElement("div");
+ this.labelDiv_.style.cssText = "position: absolute; overflow: hidden;";
+
+ // Set up the DIV for handling mouse events in the label. This DIV forms a transparent veil
+ // in the "overlayMouseTarget" pane, a veil that covers just the label. This is done so that
+ // events can be captured even if the label is in the shadow of a google.maps.InfoWindow.
+ // Code is included here to ensure the veil is always exactly the same size as the label.
+ this.eventDiv_ = document.createElement("div");
+ this.eventDiv_.style.cssText = this.labelDiv_.style.cssText;
+
+ // This is needed for proper behavior on MSIE:
+ this.eventDiv_.setAttribute("onselectstart", "return false;");
+ this.eventDiv_.setAttribute("ondragstart", "return false;");
+
+ // Get the DIV for the "X" to be displayed when the marker is raised.
+ this.crossDiv_ = MarkerLabel_.getSharedCross(crossURL);
+}
+
+inherits(MarkerLabel_, google.maps.OverlayView);
+
+/**
+ * Returns the DIV for the cross used when dragging a marker when the
+ * raiseOnDrag parameter set to true. One cross is shared with all markers.
+ * @param {string} crossURL The URL of the cross image =.
+ * @private
+ */
+MarkerLabel_.getSharedCross = function (crossURL) {
+ var div;
+ if (typeof MarkerLabel_.getSharedCross.crossDiv === "undefined") {
+ div = document.createElement("img");
+ div.style.cssText = "position: absolute; z-index: 1000002; display: none;";
+ // Hopefully Google never changes the standard "X" attributes:
+ div.style.marginLeft = "-8px";
+ div.style.marginTop = "-9px";
+ div.src = crossURL;
+ MarkerLabel_.getSharedCross.crossDiv = div;
+ }
+ return MarkerLabel_.getSharedCross.crossDiv;
+};
+
+/**
+ * Adds the DIV representing the label to the DOM. This method is called
+ * automatically when the marker's setMap method is called.
+ * @private
+ */
+MarkerLabel_.prototype.onAdd = function () {
+ var me = this;
+ var cMouseIsDown = false;
+ var cDraggingLabel = false;
+ var cSavedZIndex;
+ var cLatOffset, cLngOffset;
+ var cIgnoreClick;
+ var cRaiseEnabled;
+ var cStartPosition;
+ var cStartCenter;
+ // Constants:
+ var cRaiseOffset = 20;
+ var cDraggingCursor = "url(" + this.handCursorURL_ + ")";
+
+ // Stops all processing of an event.
+ //
+ var cAbortEvent = function (e) {
+ if (e.preventDefault) {
+ e.preventDefault();
+ }
+ e.cancelBubble = true;
+ if (e.stopPropagation) {
+ e.stopPropagation();
+ }
+ };
+
+ var cStopBounce = function () {
+ me.marker_.setAnimation(null);
+ };
+
+ this.getPanes().overlayImage.appendChild(this.labelDiv_);
+ this.getPanes().overlayMouseTarget.appendChild(this.eventDiv_);
+ // One cross is shared with all markers, so only add it once:
+ if (typeof MarkerLabel_.getSharedCross.processed === "undefined") {
+ this.getPanes().overlayImage.appendChild(this.crossDiv_);
+ MarkerLabel_.getSharedCross.processed = true;
+ }
+
+ this.listeners_ = [
+ google.maps.event.addDomListener(this.eventDiv_, "mouseover", function (e) {
+ if (me.marker_.getDraggable() || me.marker_.getClickable()) {
+ this.style.cursor = "pointer";
+ google.maps.event.trigger(me.marker_, "mouseover", e);
+ }
+ }),
+ google.maps.event.addDomListener(this.eventDiv_, "mouseout", function (e) {
+ if ((me.marker_.getDraggable() || me.marker_.getClickable()) && !cDraggingLabel) {
+ this.style.cursor = me.marker_.getCursor();
+ google.maps.event.trigger(me.marker_, "mouseout", e);
+ }
+ }),
+ google.maps.event.addDomListener(this.eventDiv_, "mousedown", function (e) {
+ cDraggingLabel = false;
+ if (me.marker_.getDraggable()) {
+ cMouseIsDown = true;
+ this.style.cursor = cDraggingCursor;
+ }
+ if (me.marker_.getDraggable() || me.marker_.getClickable()) {
+ google.maps.event.trigger(me.marker_, "mousedown", e);
+ cAbortEvent(e); // Prevent map pan when starting a drag on a label
+ }
+ }),
+ google.maps.event.addDomListener(document, "mouseup", function (mEvent) {
+ var position;
+ if (cMouseIsDown) {
+ cMouseIsDown = false;
+ me.eventDiv_.style.cursor = "pointer";
+ google.maps.event.trigger(me.marker_, "mouseup", mEvent);
+ }
+ if (cDraggingLabel) {
+ if (cRaiseEnabled) { // Lower the marker & label
+ position = me.getProjection().fromLatLngToDivPixel(me.marker_.getPosition());
+ position.y += cRaiseOffset;
+ me.marker_.setPosition(me.getProjection().fromDivPixelToLatLng(position));
+ // This is not the same bouncing style as when the marker portion is dragged,
+ // but it will have to do:
+ try { // Will fail if running Google Maps API earlier than V3.3
+ me.marker_.setAnimation(google.maps.Animation.BOUNCE);
+ setTimeout(cStopBounce, 1406);
+ } catch (e) {}
+ }
+ me.crossDiv_.style.display = "none";
+ me.marker_.setZIndex(cSavedZIndex);
+ cIgnoreClick = true; // Set flag to ignore the click event reported after a label drag
+ cDraggingLabel = false;
+ mEvent.latLng = me.marker_.getPosition();
+ google.maps.event.trigger(me.marker_, "dragend", mEvent);
+ }
+ }),
+ google.maps.event.addListener(me.marker_.getMap(), "mousemove", function (mEvent) {
+ var position;
+ if (cMouseIsDown) {
+ if (cDraggingLabel) {
+ // Change the reported location from the mouse position to the marker position:
+ mEvent.latLng = new google.maps.LatLng(mEvent.latLng.lat() - cLatOffset, mEvent.latLng.lng() - cLngOffset);
+ position = me.getProjection().fromLatLngToDivPixel(mEvent.latLng);
+ if (cRaiseEnabled) {
+ me.crossDiv_.style.left = position.x + "px";
+ me.crossDiv_.style.top = position.y + "px";
+ me.crossDiv_.style.display = "";
+ position.y -= cRaiseOffset;
+ }
+ me.marker_.setPosition(me.getProjection().fromDivPixelToLatLng(position));
+ if (cRaiseEnabled) { // Don't raise the veil; this hack needed to make MSIE act properly
+ me.eventDiv_.style.top = (position.y + cRaiseOffset) + "px";
+ }
+ google.maps.event.trigger(me.marker_, "drag", mEvent);
+ } else {
+ // Calculate offsets from the click point to the marker position:
+ cLatOffset = mEvent.latLng.lat() - me.marker_.getPosition().lat();
+ cLngOffset = mEvent.latLng.lng() - me.marker_.getPosition().lng();
+ cSavedZIndex = me.marker_.getZIndex();
+ cStartPosition = me.marker_.getPosition();
+ cStartCenter = me.marker_.getMap().getCenter();
+ cRaiseEnabled = me.marker_.get("raiseOnDrag");
+ cDraggingLabel = true;
+ me.marker_.setZIndex(1000000); // Moves the marker & label to the foreground during a drag
+ mEvent.latLng = me.marker_.getPosition();
+ google.maps.event.trigger(me.marker_, "dragstart", mEvent);
+ }
+ }
+ }),
+ google.maps.event.addDomListener(document, "keydown", function (e) {
+ if (cDraggingLabel) {
+ if (e.keyCode === 27) { // Esc key
+ cRaiseEnabled = false;
+ me.marker_.setPosition(cStartPosition);
+ me.marker_.getMap().setCenter(cStartCenter);
+ google.maps.event.trigger(document, "mouseup", e);
+ }
+ }
+ }),
+ google.maps.event.addDomListener(this.eventDiv_, "click", function (e) {
+ if (me.marker_.getDraggable() || me.marker_.getClickable()) {
+ if (cIgnoreClick) { // Ignore the click reported when a label drag ends
+ cIgnoreClick = false;
+ } else {
+ google.maps.event.trigger(me.marker_, "click", e);
+ cAbortEvent(e); // Prevent click from being passed on to map
+ }
+ }
+ }),
+ google.maps.event.addDomListener(this.eventDiv_, "dblclick", function (e) {
+ if (me.marker_.getDraggable() || me.marker_.getClickable()) {
+ google.maps.event.trigger(me.marker_, "dblclick", e);
+ cAbortEvent(e); // Prevent map zoom when double-clicking on a label
+ }
+ }),
+ google.maps.event.addListener(this.marker_, "dragstart", function (mEvent) {
+ if (!cDraggingLabel) {
+ cRaiseEnabled = this.get("raiseOnDrag");
+ }
+ }),
+ google.maps.event.addListener(this.marker_, "drag", function (mEvent) {
+ if (!cDraggingLabel) {
+ if (cRaiseEnabled) {
+ me.setPosition(cRaiseOffset);
+ // During a drag, the marker's z-index is temporarily set to 1000000 to
+ // ensure it appears above all other markers. Also set the label's z-index
+ // to 1000000 (plus or minus 1 depending on whether the label is supposed
+ // to be above or below the marker).
+ me.labelDiv_.style.zIndex = 1000000 + (this.get("labelInBackground") ? -1 : +1);
+ }
+ }
+ }),
+ google.maps.event.addListener(this.marker_, "dragend", function (mEvent) {
+ if (!cDraggingLabel) {
+ if (cRaiseEnabled) {
+ me.setPosition(0); // Also restores z-index of label
+ }
+ }
+ }),
+ google.maps.event.addListener(this.marker_, "position_changed", function () {
+ me.setPosition();
+ }),
+ google.maps.event.addListener(this.marker_, "zindex_changed", function () {
+ me.setZIndex();
+ }),
+ google.maps.event.addListener(this.marker_, "visible_changed", function () {
+ me.setVisible();
+ }),
+ google.maps.event.addListener(this.marker_, "labelvisible_changed", function () {
+ me.setVisible();
+ }),
+ google.maps.event.addListener(this.marker_, "title_changed", function () {
+ me.setTitle();
+ }),
+ google.maps.event.addListener(this.marker_, "labelcontent_changed", function () {
+ me.setContent();
+ }),
+ google.maps.event.addListener(this.marker_, "labelanchor_changed", function () {
+ me.setAnchor();
+ }),
+ google.maps.event.addListener(this.marker_, "labelclass_changed", function () {
+ me.setStyles();
+ }),
+ google.maps.event.addListener(this.marker_, "labelstyle_changed", function () {
+ me.setStyles();
+ })
+ ];
+};
+
+/**
+ * Removes the DIV for the label from the DOM. It also removes all event handlers.
+ * This method is called automatically when the marker's setMap(null)
+ * method is called.
+ * @private
+ */
+MarkerLabel_.prototype.onRemove = function () {
+ var i;
+ this.labelDiv_.parentNode.removeChild(this.labelDiv_);
+ this.eventDiv_.parentNode.removeChild(this.eventDiv_);
+
+ // Remove event listeners:
+ for (i = 0; i < this.listeners_.length; i++) {
+ google.maps.event.removeListener(this.listeners_[i]);
+ }
+};
+
+/**
+ * Draws the label on the map.
+ * @private
+ */
+MarkerLabel_.prototype.draw = function () {
+ this.setContent();
+ this.setTitle();
+ this.setStyles();
+};
+
+/**
+ * Sets the content of the label.
+ * The content can be plain text or an HTML DOM node.
+ * @private
+ */
+MarkerLabel_.prototype.setContent = function () {
+ var content = this.marker_.get("labelContent");
+ if (typeof content.nodeType === "undefined") {
+ this.labelDiv_.innerHTML = content;
+ this.eventDiv_.innerHTML = this.labelDiv_.innerHTML;
+ } else {
+ this.labelDiv_.innerHTML = ""; // Remove current content
+ this.labelDiv_.appendChild(content);
+ content = content.cloneNode(true);
+ this.eventDiv_.innerHTML = ""; // Remove current content
+ this.eventDiv_.appendChild(content);
+ }
+};
+
+/**
+ * Sets the content of the tool tip for the label. It is
+ * always set to be the same as for the marker itself.
+ * @private
+ */
+MarkerLabel_.prototype.setTitle = function () {
+ this.eventDiv_.title = this.marker_.getTitle() || "";
+};
+
+/**
+ * Sets the style of the label by setting the style sheet and applying
+ * other specific styles requested.
+ * @private
+ */
+MarkerLabel_.prototype.setStyles = function () {
+ var i, labelStyle;
+
+ // Apply style values from the style sheet defined in the labelClass parameter:
+ this.labelDiv_.className = this.marker_.get("labelClass");
+ this.eventDiv_.className = this.labelDiv_.className;
+
+ // Clear existing inline style values:
+ this.labelDiv_.style.cssText = "";
+ this.eventDiv_.style.cssText = "";
+ // Apply style values defined in the labelStyle parameter:
+ labelStyle = this.marker_.get("labelStyle");
+ for (i in labelStyle) {
+ if (labelStyle.hasOwnProperty(i)) {
+ this.labelDiv_.style[i] = labelStyle[i];
+ this.eventDiv_.style[i] = labelStyle[i];
+ }
+ }
+ this.setMandatoryStyles();
+};
+
+/**
+ * Sets the mandatory styles to the DIV representing the label as well as to the
+ * associated event DIV. This includes setting the DIV position, z-index, and visibility.
+ * @private
+ */
+MarkerLabel_.prototype.setMandatoryStyles = function () {
+ this.labelDiv_.style.position = "absolute";
+ this.labelDiv_.style.overflow = "hidden";
+ // Make sure the opacity setting causes the desired effect on MSIE:
+ if (typeof this.labelDiv_.style.opacity !== "undefined" && this.labelDiv_.style.opacity !== "") {
+ this.labelDiv_.style.MsFilter = "\"progid:DXImageTransform.Microsoft.Alpha(opacity=" + (this.labelDiv_.style.opacity * 100) + ")\"";
+ this.labelDiv_.style.filter = "alpha(opacity=" + (this.labelDiv_.style.opacity * 100) + ")";
+ }
+
+ this.eventDiv_.style.position = this.labelDiv_.style.position;
+ this.eventDiv_.style.overflow = this.labelDiv_.style.overflow;
+ this.eventDiv_.style.opacity = 0.01; // Don't use 0; DIV won't be clickable on MSIE
+ this.eventDiv_.style.MsFilter = "\"progid:DXImageTransform.Microsoft.Alpha(opacity=1)\"";
+ this.eventDiv_.style.filter = "alpha(opacity=1)"; // For MSIE
+
+ this.setAnchor();
+ this.setPosition(); // This also updates z-index, if necessary.
+ this.setVisible();
+};
+
+/**
+ * Sets the anchor point of the label.
+ * @private
+ */
+MarkerLabel_.prototype.setAnchor = function () {
+ var anchor = this.marker_.get("labelAnchor");
+ this.labelDiv_.style.marginLeft = -anchor.x + "px";
+ this.labelDiv_.style.marginTop = -anchor.y + "px";
+ this.eventDiv_.style.marginLeft = -anchor.x + "px";
+ this.eventDiv_.style.marginTop = -anchor.y + "px";
+};
+
+/**
+ * Sets the position of the label. The z-index is also updated, if necessary.
+ * @private
+ */
+MarkerLabel_.prototype.setPosition = function (yOffset) {
+ var position = this.getProjection().fromLatLngToDivPixel(this.marker_.getPosition());
+ if (typeof yOffset === "undefined") {
+ yOffset = 0;
+ }
+ this.labelDiv_.style.left = Math.round(position.x) + "px";
+ this.labelDiv_.style.top = Math.round(position.y - yOffset) + "px";
+ this.eventDiv_.style.left = this.labelDiv_.style.left;
+ this.eventDiv_.style.top = this.labelDiv_.style.top;
+
+ this.setZIndex();
+};
+
+/**
+ * Sets the z-index of the label. If the marker's z-index property has not been defined, the z-index
+ * of the label is set to the vertical coordinate of the label. This is in keeping with the default
+ * stacking order for Google Maps: markers to the south are in front of markers to the north.
+ * @private
+ */
+MarkerLabel_.prototype.setZIndex = function () {
+ var zAdjust = (this.marker_.get("labelInBackground") ? -1 : +1);
+ if (typeof this.marker_.getZIndex() === "undefined") {
+ this.labelDiv_.style.zIndex = parseInt(this.labelDiv_.style.top, 10) + zAdjust;
+ this.eventDiv_.style.zIndex = this.labelDiv_.style.zIndex;
+ } else {
+ this.labelDiv_.style.zIndex = this.marker_.getZIndex() + zAdjust;
+ this.eventDiv_.style.zIndex = this.labelDiv_.style.zIndex;
+ }
+};
+
+/**
+ * Sets the visibility of the label. The label is visible only if the marker itself is
+ * visible (i.e., its visible property is true) and the labelVisible property is true.
+ * @private
+ */
+MarkerLabel_.prototype.setVisible = function () {
+ if (this.marker_.get("labelVisible")) {
+ this.labelDiv_.style.display = this.marker_.getVisible() ? "block" : "none";
+ } else {
+ this.labelDiv_.style.display = "none";
+ }
+ this.eventDiv_.style.display = this.labelDiv_.style.display;
+};
+
+/**
+ * @name MarkerWithLabelOptions
+ * @class This class represents the optional parameter passed to the {@link MarkerWithLabel} constructor.
+ * The properties available are the same as for google.maps.Marker with the addition
+ * of the properties listed below. To change any of these additional properties after the labeled
+ * marker has been created, call google.maps.Marker.set(propertyName, propertyValue).
+ *
+ * When any of these properties changes, a property changed event is fired. The names of these
+ * events are derived from the name of the property and are of the form propertyname_changed.
+ * For example, if the content of the label changes, a labelcontent_changed event
+ * is fired.
+ *
+ * @property {string|Node} [labelContent] The content of the label (plain text or an HTML DOM node).
+ * @property {Point} [labelAnchor] By default, a label is drawn with its anchor point at (0,0) so
+ * that its top left corner is positioned at the anchor point of the associated marker. Use this
+ * property to change the anchor point of the label. For example, to center a 50px-wide label
+ * beneath a marker, specify a c&&(e=k[c],!(e!==a&&null!=e.map&&e.getVisible()&&(f=this.llToPt(null!=(l=null!=(m=e._omsData)?m.usualPosition:void 0)?l:e.position),this.ptDistanceSq(f,g) q;a=++q)h=t[a],m[a].willSpiderfy&&u.push(h);return u},l.makeHighlightListenerFuncs=function(a){return{highlight:function(b){return function(){return a._omsData.leg.setOptions({strokeColor:b.legColors.highlighted[b.map.mapTypeId],zIndex:b.highlightedLegZIndex})}}(this),unhighlight:function(b){return function(){return a._omsData.leg.setOptions({strokeColor:b.legColors.usual[b.map.mapTypeId],zIndex:b.usualLegZIndex})}}(this)}},l.spiderfy=function(a,b){var c,d,g,h,i,j,k,l,m,n,o;return this.minZoomLevel&&this.map.getZoom()
+ * An InfoBox behaves like a google.maps.InfoWindow, but it supports several
+ * additional properties for advanced styling. An InfoBox can also be used as a map label.
+ *
+ * An InfoBox also fires the same events as a google.maps.InfoWindow.
+ */
+
+/*jslint browser:true */
+/*global google */
+
+/**
+ * @name InfoBoxOptions
+ * @class This class represents the optional parameter passed to the {@link InfoBox} constructor.
+ * @property {string|Node} content The content of the InfoBox (plain text or an HTML DOM node).
+ * @property {boolean} [disableAutoPan=false] Disable auto-pan on open.
+ * @property {number} maxWidth The maximum width (in pixels) of the InfoBox. Set to 0 if no maximum.
+ * @property {Size} pixelOffset The offset (in pixels) from the top left corner of the InfoBox
+ * (or the bottom left corner if the
+ * NOTE: Do not use Ctrl as the hot key with Google Maps JavaScript API V3 since, unlike with V2,
+ * it causes a context menu to appear when running on the Macintosh.
+ *
+ * Note that if the map's container has a border around it, the border widths must be specified
+ * in pixel units (or as thin, medium, or thick). This is required because of an MSIE limitation.
+ * NL: 2009-05-28: initial port to core API V3.
+ *
+ * If you drag a marker by its label, you can cancel the drag and return the marker to its
+ * original position by pressing the
+ * When any of these properties changes, a property changed event is fired. The names of these
+ * events are derived from the name of the property and are of the form
+ * @property {string|Node} [labelContent] The content of the label (plain text or an HTML DOM node).
+ * @property {Point} [labelAnchor] By default, a label is drawn with its anchor point at (0,0) so
+ * that its top left corner is positioned at the anchor point of the associated marker. Use this
+ * property to change the anchor point of the label. For example, to center a 50px-wide label
+ * beneath a marker, specify a \n * An InfoBox behaves like a google.maps.InfoWindow, but it supports several\n * additional properties for advanced styling. An InfoBox can also be used as a map label.\n * \n * An InfoBox also fires the same events as a google.maps.InfoWindow.\n */\n\n/*jslint browser:true */\n/*global google */\n\n/**\n * @name InfoBoxOptions\n * @class This class represents the optional parameter passed to the {@link InfoBox} constructor.\n * @property {string|Node} content The content of the InfoBox (plain text or an HTML DOM node).\n * @property {boolean} [disableAutoPan=false] Disable auto-pan on open.\n * @property {number} maxWidth The maximum width (in pixels) of the InfoBox. Set to 0 if no maximum.\n * @property {Size} pixelOffset The offset (in pixels) from the top left corner of the InfoBox\n * (or the bottom left corner if the \n * NOTE: Do not use Ctrl as the hot key with Google Maps JavaScript API V3 since, unlike with V2,\n * it causes a context menu to appear when running on the Macintosh.\n * \n * Note that if the map's container has a border around it, the border widths must be specified\n * in pixel units (or as thin, medium, or thick). This is required because of an MSIE limitation.\n * NL: 2009-05-28: initial port to core API V3.\n * \n * If you drag a marker by its label, you can cancel the drag and return the marker to its\n * original position by pressing the \n * When any of these properties changes, a property changed event is fired. The names of these\n * events are derived from the name of the property and are of the form \n * @property {string|Node} [labelContent] The content of the label (plain text or an HTML DOM node).\n * @property {Point} [labelAnchor] By default, a label is drawn with its anchor point at (0,0) so\n * that its top left corner is positioned at the anchor point of the associated marker. Use this\n * property to change the anchor point of the label. For example, to center a 50px-wide label\n * beneath a marker, specify a c&&(e=k[c],!(e!==a&&null!=e.map&&e.getVisible()&&(f=this.llToPt(null!=(l=null!=(m=e._omsData)?m.usualPosition:void 0)?l:e.position),this.ptDistanceSq(f,g) q;a=++q)h=t[a],m[a].willSpiderfy&&u.push(h);return u},l.makeHighlightListenerFuncs=function(a){return{highlight:function(b){return function(){return a._omsData.leg.setOptions({strokeColor:b.legColors.highlighted[b.map.mapTypeId],zIndex:b.highlightedLegZIndex})}}(this),unhighlight:function(b){return function(){return a._omsData.leg.setOptions({strokeColor:b.legColors.usual[b.map.mapTypeId],zIndex:b.usualLegZIndex})}}(this)}},l.spiderfy=function(a,b){var c,d,g,h,i,j,k,l,m,n,o;return this.minZoomLevel&&this.map.getZoom() an html\nclick here\nsnippet an html\n" +
+ "click here\n" +
+ "snippet This renders because the controller does not fail to
+ instantiate, by using explicit annotation style (see
+ script.js for details)
+ This renders because the controller does not fail to
+ instantiate, by using explicit annotation style
+ (see script.js for details)
+ The controller could not be instantiated, due to relying
+ on automatic function annotations (which are disabled in
+ strict mode). As such, the content of this section is not
+ interpolated, and there should be an error in your web console.
+ Cached Values Cache InfolabelAnchor of google.maps.Point(25, 0).
+ * (Note: x-values increase to the right and y-values increase to the top.)
+ * @property {string} [labelClass] The name of the CSS class defining the styles for the label.
+ * Note that style values for position, overflow, top,
+ * left, zIndex, display, marginLeft, and
+ * marginTop are ignored; these styles are for internal use only.
+ * @property {Object} [labelStyle] An object literal whose properties define specific CSS
+ * style values to be applied to the label. Style values defined here override those that may
+ * be defined in the labelClass style sheet. If this property is changed after the
+ * label has been created, all previously set styles (except those defined in the style sheet)
+ * are removed from the label before the new style values are applied.
+ * Note that style values for position, overflow, top,
+ * left, zIndex, display, marginLeft, and
+ * marginTop are ignored; these styles are for internal use only.
+ * @property {boolean} [labelInBackground] A flag indicating whether a label that overlaps its
+ * associated marker should appear in the background (i.e., in a plane below the marker).
+ * The default is false, which causes the label to appear in the foreground.
+ * @property {boolean} [labelVisible] A flag indicating whether the label is to be visible.
+ * The default is true. Note that even if labelVisible is
+ * true, the label will not be visible unless the associated marker is also
+ * visible (i.e., unless the marker's visible property is true).
+ * @property {boolean} [raiseOnDrag] A flag indicating whether the label and marker are to be
+ * raised when the marker is dragged. The default is true. If a draggable marker is
+ * being created and a version of Google Maps API earlier than V3.3 is being used, this property
+ * must be set to false.
+ * @property {boolean} [optimized] A flag indicating whether rendering is to be optimized for the
+ * marker. Important: The optimized rendering technique is not supported by MarkerWithLabel,
+ * so the value of this parameter is always forced to false.
+ * @property {string} [crossImage="http://maps.gstatic.com/intl/en_us/mapfiles/drag_cross_67_16.png"]
+ * The URL of the cross image to be displayed while dragging a marker.
+ * @property {string} [handCursor="http://maps.gstatic.com/intl/en_us/mapfiles/closedhand_8_8.cur"]
+ * The URL of the cursor to be displayed while dragging a marker.
+ */
+/**
+ * Creates a MarkerWithLabel with the options specified in {@link MarkerWithLabelOptions}.
+ * @constructor
+ * @param {MarkerWithLabelOptions} [opt_options] The optional parameters.
+ */
+function MarkerWithLabel(opt_options) {
+ opt_options = opt_options || {};
+ opt_options.labelContent = opt_options.labelContent || "";
+ opt_options.labelAnchor = opt_options.labelAnchor || new google.maps.Point(0, 0);
+ opt_options.labelClass = opt_options.labelClass || "markerLabels";
+ opt_options.labelStyle = opt_options.labelStyle || {};
+ opt_options.labelInBackground = opt_options.labelInBackground || false;
+ if (typeof opt_options.labelVisible === "undefined") {
+ opt_options.labelVisible = true;
+ }
+ if (typeof opt_options.raiseOnDrag === "undefined") {
+ opt_options.raiseOnDrag = true;
+ }
+ if (typeof opt_options.clickable === "undefined") {
+ opt_options.clickable = true;
+ }
+ if (typeof opt_options.draggable === "undefined") {
+ opt_options.draggable = false;
+ }
+ if (typeof opt_options.optimized === "undefined") {
+ opt_options.optimized = false;
+ }
+ opt_options.crossImage = opt_options.crossImage || "http" + (document.location.protocol === "https:" ? "s" : "") + "://maps.gstatic.com/intl/en_us/mapfiles/drag_cross_67_16.png";
+ opt_options.handCursor = opt_options.handCursor || "http" + (document.location.protocol === "https:" ? "s" : "") + "://maps.gstatic.com/intl/en_us/mapfiles/closedhand_8_8.cur";
+ opt_options.optimized = false; // Optimized rendering is not supported
+
+ this.label = new MarkerLabel_(this, opt_options.crossImage, opt_options.handCursor); // Bind the label to the marker
+
+ // Call the parent constructor. It calls Marker.setValues to initialize, so all
+ // the new parameters are conveniently saved and can be accessed with get/set.
+ // Marker.set triggers a property changed event (called "propertyname_changed")
+ // that the marker label listens for in order to react to state changes.
+ google.maps.Marker.apply(this, arguments);
+}
+
+inherits(MarkerWithLabel, google.maps.Marker);
+
+/**
+ * Overrides the standard Marker setMap function.
+ * @param {Map} theMap The map to which the marker is to be added.
+ * @private
+ */
+MarkerWithLabel.prototype.setMap = function (theMap) {
+
+ // Call the inherited function...
+ google.maps.Marker.prototype.setMap.apply(this, arguments);
+
+ // ... then deal with the label:
+ this.label.setMap(theMap);
+};
+
+// ==ClosureCompiler==
+// @compilation_level ADVANCED_OPTIMIZATIONS
+// @externs_url http://closure-compiler.googlecode.com/svn/trunk/contrib/externs/maps/google_maps_api_v3.js
+// @output_wrapper (function() {%output%})();
+// ==/ClosureCompiler==
+
+/**
+ * @license
+ * Copyright 2013 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * A RichMarker that allows any HTML/DOM to be added to a map and be draggable.
+ *
+ * @param {Object.MarkerClusterer begins
+ * clustering markers.
+ * @name MarkerClusterer#clusteringbegin
+ * @param {MarkerClusterer} mc The MarkerClusterer whose markers are being clustered.
+ * @event
+ */
+ google.maps.event.trigger(this, 'clusteringbegin', this);
+
+ if (typeof this.timerRefStatic !== 'undefined') {
+ clearTimeout(this.timerRefStatic);
+ delete this.timerRefStatic;
+ }
+ }
+
+ // Get our current map view bounds.
+ // Create a new bounds object so we don't affect the map.
+ //
+ // See Comments 9 & 11 on Issue 3651 relating to this workaround for a Google Maps bug:
+ if (this.getMap().getZoom() > 3) {
+ mapBounds = new google.maps.LatLngBounds(this.getMap().getBounds().getSouthWest(),
+ this.getMap().getBounds().getNorthEast());
+ } else {
+ mapBounds = new google.maps.LatLngBounds(new google.maps.LatLng(85.02070771743472, -178.48388434375), new google.maps.LatLng(-85.08136444384544, 178.00048865625));
+ }
+ var bounds = this.getExtendedBounds(mapBounds);
+
+ var iLast = Math.min(iFirst + this.batchSize_, this.markers_.length);
+
+ var _ms = this.markers_.values();
+ for (i = iFirst; i < iLast; i++) {
+ marker = _ms[i];
+ if (!marker.isAdded && this.isMarkerInBounds_(marker, bounds)) {
+ if (!this.ignoreHidden_ || (this.ignoreHidden_ && marker.getVisible())) {
+ this.addToClosestCluster_(marker);
+ }
+ }
+ }
+
+ if (iLast < this.markers_.length) {
+ this.timerRefStatic = setTimeout(function () {
+ cMarkerClusterer.createClusters_(iLast);
+ }, 0);
+ } else {
+ // custom addition by ui-gmap
+ // update icon for all clusters
+ for (i = 0; i < this.clusters_.length; i++) {
+ this.clusters_[i].updateIcon_();
+ }
+
+ delete this.timerRefStatic;
+
+ /**
+ * This event is fired when the MarkerClusterer stops
+ * clustering markers.
+ * @name MarkerClusterer#clusteringend
+ * @param {MarkerClusterer} mc The MarkerClusterer whose markers are being clustered.
+ * @event
+ */
+ google.maps.event.trigger(this, 'clusteringend', this);
+ }
+ };
+
+ /**
+ * Adds a marker to a cluster, or creates a new cluster.
+ *
+ * @param {google.maps.Marker} marker The marker to add.
+ */
+ NgMapMarkerClusterer.prototype.addToClosestCluster_ = function (marker) {
+ var i, d, cluster, center;
+ var distance = 40000; // Some large number
+ var clusterToAddTo = null;
+ for (i = 0; i < this.clusters_.length; i++) {
+ cluster = this.clusters_[i];
+ center = cluster.getCenter();
+ if (center) {
+ d = this.distanceBetweenPoints_(center, marker.getPosition());
+ if (d < distance) {
+ distance = d;
+ clusterToAddTo = cluster;
+ }
+ }
+ }
+
+ if (clusterToAddTo && clusterToAddTo.isMarkerInClusterBounds(marker)) {
+ clusterToAddTo.addMarker(marker);
+ } else {
+ cluster = new NgMapCluster(this);
+ cluster.addMarker(marker);
+ this.clusters_.push(cluster);
+ }
+ };
+
+ /**
+ * Redraws all the clusters.
+ */
+ NgMapMarkerClusterer.prototype.redraw_ = function () {
+ this.createClusters_(0);
+ };
+
+
+ /**
+ * Removes all clusters from the map. The markers are also removed from the map
+ * if opt_hide is set to true.
+ *
+ * @param {boolean} [opt_hide] Set to true to also remove the markers
+ * from the map.
+ */
+ NgMapMarkerClusterer.prototype.resetViewport_ = function (opt_hide) {
+ var i, marker;
+ // Remove all the clusters
+ for (i = 0; i < this.clusters_.length; i++) {
+ this.clusters_[i].remove();
+ }
+ this.clusters_ = [];
+
+ // Reset the markers to not be added and to be removed from the map.
+ this.markers_.each(function (marker) {
+ marker.isAdded = false;
+ if (opt_hide) {
+ marker.setMap(null);
+ }
+ });
+ };
+
+ /**
+ * Extends an object's prototype by another's.
+ *
+ * @param {Object} obj1 The object to be extended.
+ * @param {Object} obj2 The object to extend with.
+ * @return {Object} The new extended object.
+ * @ignore
+ */
+ NgMapMarkerClusterer.prototype.extend = function (obj1, obj2) {
+ return (function (object) {
+ var property;
+ for (property in object.prototype) {
+ if (property !== 'constructor')
+ this.prototype[property] = object.prototype[property];
+ }
+ return this;
+ }).apply(obj1, [obj2]);
+ };
+ ////////////////////////////////////////////////////////////////////////////////
+ /*
+ Other overrides relevant to MarkerClusterPlus
+ */
+ ////////////////////////////////////////////////////////////////////////////////
+ /**
+ * Positions and shows the icon.
+ */
+ ClusterIcon.prototype.show = function () {
+ if (this.div_) {
+ var img = "";
+ // NOTE: values must be specified in px units
+ var bp = this.backgroundPosition_.split(" ");
+ var spriteH = parseInt(bp[0].trim(), 10);
+ var spriteV = parseInt(bp[1].trim(), 10);
+ var pos = this.getPosFromLatLng_(this.center_);
+ this.div_.style.cssText = this.createCss(pos);
+ img = "";
+ this.div_.innerHTML = img + "
"),a},e}(a.InfoBox),a.uiGmapInfoBox=b),a.MarkerLabel_?a.MarkerLabel_.prototype.setContent=function(){var a;a=this.marker_.get("labelContent"),a&&!_.isEqual(this.oldContent,a)&&("undefined"==typeof(null!=a?a.nodeType:void 0)?(this.labelDiv_.innerHTML=a,this.eventDiv_.innerHTML=this.labelDiv_.innerHTML,this.oldContent=a):(this.labelDiv_.innerHTML="",this.labelDiv_.appendChild(a),a=a.cloneNode(!0),this.labelDiv_.innerHTML="",this.eventDiv_.appendChild(a),this.oldContent=a))}:void 0})}})}.call(this),function(){b.module("uiGmapgoogle-maps.extensions").service("uiGmapLodash",function(){var a,b,c,d,e,f,g,h;return f=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g,e=/\\(\\)?/g,c=function(a){var b,c,d;return c=a.missingName,d=a.swapName,b=a.isProto,null==_[c]&&(_[c]=_[d],b)?_.prototype[c]=_[d]:void 0},[{missingName:"contains",swapName:"includes",isProto:!0},{missingName:"includes",swapName:"contains",isProto:!0},{missingName:"object",swapName:"zipObject"},{missingName:"zipObject",swapName:"object"},{missingName:"all",swapName:"every"},{missingName:"every",swapName:"all"},{missingName:"any",swapName:"some"},{missingName:"some",swapName:"any"},{missingName:"first",swapName:"head"},{missingName:"head",swapName:"first"}].forEach(function(a){return c(a)}),null==_.get&&(g=function(a){return _.isObject(a)?a:Object(a)},b=function(a){return null===a?"":a+""},h=function(a){var c;return _.isArray(a)?a:(c=[],b(a).replace(f,function(a,b,d,f){c.push(d?f.replace(e,"$1"):b||a)}),c)},a=function(a,b,c){var d,e;if(null!==a){void 0!==c&&c in g(a)&&(b=[c]),d=0,e=b.length;for(;!_.isUndefined(a)&&e>d;)a=a[b[d++]];return d&&d===e?a:void 0}},d=function(b,c,d){var e;return e=null===b?void 0:a(b,h(c),c+""),void 0===e?d:e},_.get=d),this.intersectionObjects=function(a,b,c){var d;return null==c&&(c=void 0),d=_.map(a,function(a){return _.find(b,function(b){return null!=c?c(a,b):_.isEqual(a,b)})}),_.filter(d,function(a){return null!=a})},this.containsObject=_.includeObject=function(a,b,c){return null==c&&(c=void 0),null===a?!1:_.some(a,function(a){return null!=c?c(a,b):_.isEqual(a,b)})},this.differenceObjects=function(a,b,c){return null==c&&(c=void 0),_.filter(a,function(a){return function(d){return!a.containsObject(b,d,c)}}(this))},this.withoutObjects=this.differenceObjects,this.indexOfObject=function(a,b,c,d){var e,f;if(null==a)return-1;if(e=0,f=a.length,d){if("number"!=typeof d)return e=_.sortedIndex(a,b),a[e]===b?e:-1;e=0>d?Math.max(0,f+d):d}for(;f>e;){if(null!=c){if(c(a[e],b))return e}else if(_.isEqual(a[e],b))return e;e++}return-1},this.isNullOrUndefined=function(a){return _.isNull(a||_.isUndefined(a))},this})}.call(this),function(){b.module("uiGmapgoogle-maps.extensions").factory("uiGmapString",function(){return function(a){return this.contains=function(b,c){return-1!==a.indexOf(b,c)},this}})}.call(this),function(){b.module("uiGmapgoogle-maps.directives.api.utils").service("uiGmap_sync",[function(){return{fakePromise:function(){var a;return a=void 0,{then:function(b){return a=b},resolve:function(){return a.apply(void 0,arguments)}}}}}]).service("uiGmap_async",["$timeout","uiGmapPromise","uiGmapLogger","$q","uiGmapDataStructures","uiGmapGmapUtil",function(a,c,d,e,f,g){var h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A;return z=c.promiseTypes,s=c.isInProgress,y=c.promiseStatus,h=c.ExposedPromise,j=c.SniffedPromise,t=function(a,b){var c;return c=a.promise(),c.promiseType=a.promiseType,c.$$state&&d.debug("promiseType: "+c.promiseType+", state: "+y(c.$$state.status)),c.cancelCb=b,c},o=function(a,b){return a.promiseType===z.create&&b.promiseType!==z["delete"]&&b.promiseType!==z.init?(d.debug("lastPromise.promiseType "+b.promiseType+", newPromiseType: "+a.promiseType+", SKIPPED MUST COME AFTER DELETE ONLY"),!0):!1},x=function(a,b,c){var e;return b.promiseType===z["delete"]&&c.promiseType!==z["delete"]&&null!=c.cancelCb&&_.isFunction(c.cancelCb)&&s(c)&&(d.debug("promiseType: "+b.promiseType+", CANCELING LAST PROMISE type: "+c.promiseType),c.cancelCb("cancel safe"),e=a.peek(),null!=e&&s(e))?e.hasOwnProperty("cancelCb")&&_.isFunction(e.cancelCb)?(d.debug("promiseType: "+e.promiseType+", CANCELING FIRST PROMISE type: "+e.promiseType),e.cancelCb("cancel safe")):d.warn("first promise was not cancelable"):void 0},i=function(a,b,c){var d,e;if(a.existingPieces){if(d=_.last(a.existingPieces._content),o(b,d))return;return x(a.existingPieces,b,d),e=h(d["finally"](function(){return t(b,c)})),e.cancelCb=c,e.promiseType=b.promiseType,a.existingPieces.enqueue(e),d["finally"](function(){return a.existingPieces.dequeue()})}return a.existingPieces=new f.Queue,a.existingPieces.enqueue(t(b,c))},v=function(a,b,c,e,f){var g;return null==c&&(c=""),g=function(a){return d.debug(a+": "+a),null!=e&&_.isFunction(e)?e(a):void 0},i(a,j(f,b),g)},m=80,q={value:null},A=function(a,b,c){var d,e;try{return a.apply(b,c)}catch(e){return d=e,q.value=d,q}},u=function(a,b,c,e){var f,g;return g=A(a,b,e),g===q&&(f="error within chunking iterator: "+q.value,d.error(f),c.reject(f)),"cancel safe"!==g},k=function(a,b,c){var d,e;return d=a===b,e=b[c],d?e:a[e]},l=["length","forEach","map"],r=function(a,c,d,e){var f,g,h;if(b.isArray(a))f=a;else if(c)f=c;else{f=[];for(g in a)h=a[g],a.hasOwnProperty(g)&&!_.includes(l,g)&&f.push(g)}return null==e&&(e=d),b.isArray(f)&&!(null!=f?f.length:void 0)&&e!==d?d():e(f,c)},n=function(c,d,e,f,g,h,i,j){return r(c,j,function(j,l){var m,o,p,q;for(m=d&&d
",this.div_.innerHTML=a+"
";
+ }
+ return img;
+ };
+
+ return uiGmapInfoBox;
+
+ })(window.InfoBox);
+ window.uiGmapInfoBox = uiGmapInfoBox;
+ }
+ if (window.MarkerLabel_) {
+ return window.MarkerLabel_.prototype.setContent = function() {
+ var content;
+ content = this.marker_.get('labelContent');
+ if (!content || _.isEqual(this.oldContent, content)) {
+ return;
+ }
+ if (typeof (content != null ? content.nodeType : void 0) === 'undefined') {
+ this.labelDiv_.innerHTML = content;
+ this.eventDiv_.innerHTML = this.labelDiv_.innerHTML;
+ this.oldContent = content;
+ } else {
+ this.labelDiv_.innerHTML = '';
+ this.labelDiv_.appendChild(content);
+ content = content.cloneNode(true);
+ this.labelDiv_.innerHTML = '';
+ this.eventDiv_.appendChild(content);
+ this.oldContent = content;
+ }
+ };
+ }
+ })
+ };
+ });
+
+}).call(this);
+;
+/*global _:true, angular:true */
+
+(function() {
+ angular.module('uiGmapgoogle-maps.extensions').service('uiGmapLodash', function() {
+ var baseGet, baseToString, fixLodash, get, reEscapeChar, rePropName, toObject, toPath;
+ rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g;
+ reEscapeChar = /\\(\\)?/g;
+
+ /*
+ For Lodash 4 compatibility (some aliases are removed)
+ */
+ fixLodash = function(arg) {
+ var isProto, missingName, swapName;
+ missingName = arg.missingName, swapName = arg.swapName, isProto = arg.isProto;
+ if (_[missingName] == null) {
+ _[missingName] = _[swapName];
+ if (isProto) {
+ return _.prototype[missingName] = _[swapName];
+ }
+ }
+ };
+ [
+ {
+ missingName: 'contains',
+ swapName: 'includes',
+ isProto: true
+ }, {
+ missingName: 'includes',
+ swapName: 'contains',
+ isProto: true
+ }, {
+ missingName: 'object',
+ swapName: 'zipObject'
+ }, {
+ missingName: 'zipObject',
+ swapName: 'object'
+ }, {
+ missingName: 'all',
+ swapName: 'every'
+ }, {
+ missingName: 'every',
+ swapName: 'all'
+ }, {
+ missingName: 'any',
+ swapName: 'some'
+ }, {
+ missingName: 'some',
+ swapName: 'any'
+ }, {
+ missingName: 'first',
+ swapName: 'head'
+ }, {
+ missingName: 'head',
+ swapName: 'first'
+ }
+ ].forEach(function(toMonkeyPatch) {
+ return fixLodash(toMonkeyPatch);
+ });
+ if (_.get == null) {
+
+ /**
+ * Converts `value` to an object if it's not one.
+ *
+ * @private
+ * @param {*} value The value to process.
+ * @returns {Object} Returns the object.
+ */
+ toObject = function(value) {
+ if (_.isObject(value)) {
+ return value;
+ } else {
+ return Object(value);
+ }
+ };
+
+ /**
+ * Converts `value` to a string if it's not one. An empty string is returned
+ * for `null` or `undefined` values.
+ *
+ * @private
+ * @param {*} value The value to process.
+ * @returns {string} Returns the string.
+ */
+ baseToString = function(value) {
+ if (value === null) {
+ return '';
+ } else {
+ return value + '';
+ }
+ };
+
+ /**
+ * Converts `value` to property path array if it's not one.
+ *
+ * @private
+ * @param {*} value The value to process.
+ * @returns {Array} Returns the property path array.
+ */
+ toPath = function(value) {
+ var result;
+ if (_.isArray(value)) {
+ return value;
+ }
+ result = [];
+ baseToString(value).replace(rePropName, function(match, number, quote, string) {
+ result.push(quote ? string.replace(reEscapeChar, '$1') : number || match);
+ });
+ return result;
+ };
+
+ /**
+ * The base implementation of `get` without support for string paths
+ * and default values.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @param {Array} path The path of the property to get.
+ * @param {string} [pathKey] The key representation of path.
+ * @returns {*} Returns the resolved value.
+ */
+ baseGet = function(object, path, pathKey) {
+ var index, length;
+ if (object === null) {
+ return;
+ }
+ if (pathKey !== void 0 && pathKey in toObject(object)) {
+ path = [pathKey];
+ }
+ index = 0;
+ length = path.length;
+ while (!_.isUndefined(object) && index < length) {
+ object = object[path[index++]];
+ }
+ if (index && index === length) {
+ return object;
+ } else {
+ return void 0;
+ }
+ };
+
+ /**
+ * Gets the property value at `path` of `object`. If the resolved value is
+ * `undefined` the `defaultValue` is used in its place.
+ *
+ * @static
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The object to query.
+ * @param {Array|string} path The path of the property to get.
+ * @param {*} [defaultValue] The value returned if the resolved value is `undefined`.
+ * @returns {*} Returns the resolved value.
+ * @example
+ *
+ * var object = { 'a': [{ 'b': { 'c': 3 } }] };
+ *
+ * _.get(object, 'a[0].b.c');
+ * // => 3
+ *
+ * _.get(object, ['a', '0', 'b', 'c']);
+ * // => 3
+ *
+ * _.get(object, 'a.b.c', 'default');
+ * // => 'default'
+ */
+ get = function(object, path, defaultValue) {
+ var result;
+ result = object === null ? void 0 : baseGet(object, toPath(path), path + '');
+ if (result === void 0) {
+ return defaultValue;
+ } else {
+ return result;
+ }
+ };
+ _.get = get;
+ }
+
+ /*
+ Author Nick McCready
+ Intersection of Objects if the arrays have something in common each intersecting object will be returned
+ in an new array.
+ */
+ this.intersectionObjects = function(array1, array2, comparison) {
+ var res;
+ if (comparison == null) {
+ comparison = void 0;
+ }
+ res = _.map(array1, function(obj1) {
+ return _.find(array2, function(obj2) {
+ if (comparison != null) {
+ return comparison(obj1, obj2);
+ } else {
+ return _.isEqual(obj1, obj2);
+ }
+ });
+ });
+ return _.filter(res, function(o) {
+ return o != null;
+ });
+ };
+ this.containsObject = _.includeObject = function(obj, target, comparison) {
+ if (comparison == null) {
+ comparison = void 0;
+ }
+ if (obj === null) {
+ return false;
+ }
+ return _.some(obj, function(value) {
+ if (comparison != null) {
+ return comparison(value, target);
+ } else {
+ return _.isEqual(value, target);
+ }
+ });
+ };
+ this.differenceObjects = function(array1, array2, comparison) {
+ if (comparison == null) {
+ comparison = void 0;
+ }
+ return _.filter(array1, (function(_this) {
+ return function(value) {
+ return !_this.containsObject(array2, value, comparison);
+ };
+ })(this));
+ };
+ this.withoutObjects = this.differenceObjects;
+ this.indexOfObject = function(array, item, comparison, isSorted) {
+ var i, length;
+ if (array == null) {
+ return -1;
+ }
+ i = 0;
+ length = array.length;
+ if (isSorted) {
+ if (typeof isSorted === "number") {
+ i = (isSorted < 0 ? Math.max(0, length + isSorted) : isSorted);
+ } else {
+ i = _.sortedIndex(array, item);
+ return (array[i] === item ? i : -1);
+ }
+ }
+ while (i < length) {
+ if (comparison != null) {
+ if (comparison(array[i], item)) {
+ return i;
+ }
+ } else {
+ if (_.isEqual(array[i], item)) {
+ return i;
+ }
+ }
+ i++;
+ }
+ return -1;
+ };
+ this.isNullOrUndefined = function(thing) {
+ return _.isNull(thing || _.isUndefined(thing));
+ };
+ return this;
+ });
+
+}).call(this);
+;(function() {
+ angular.module('uiGmapgoogle-maps.extensions').factory('uiGmapString', function() {
+ return function(str) {
+ this.contains = function(value, fromIndex) {
+ return str.indexOf(value, fromIndex) !== -1;
+ };
+ return this;
+ };
+ });
+
+}).call(this);
+;
+/*global _:true,angular:true, */
+
+(function() {
+ angular.module('uiGmapgoogle-maps.directives.api.utils').service('uiGmap_sync', [
+ function() {
+ return {
+ fakePromise: function() {
+ var _cb;
+ _cb = void 0;
+ return {
+ then: function(cb) {
+ return _cb = cb;
+ },
+ resolve: function() {
+ return _cb.apply(void 0, arguments);
+ }
+ };
+ }
+ };
+ }
+ ]).service('uiGmap_async', [
+ '$timeout', 'uiGmapPromise', 'uiGmapLogger', '$q', 'uiGmapDataStructures', 'uiGmapGmapUtil', function($timeout, uiGmapPromise, $log, $q, uiGmapDataStructures, uiGmapGmapUtil) {
+ var ExposedPromise, PromiseQueueManager, SniffedPromise, _getIterateeValue, _ignoreFields, defaultChunkSize, doChunk, doSkippPromise, each, errorObject, getArrayAndKeys, isInProgress, kickPromise, logTryCatch, managePromiseQueue, map, maybeCancelPromises, promiseStatus, promiseTypes, tryCatch;
+ promiseTypes = uiGmapPromise.promiseTypes;
+ isInProgress = uiGmapPromise.isInProgress;
+ promiseStatus = uiGmapPromise.promiseStatus;
+ ExposedPromise = uiGmapPromise.ExposedPromise;
+ SniffedPromise = uiGmapPromise.SniffedPromise;
+ kickPromise = function(sniffedPromise, cancelCb) {
+ var promise;
+ promise = sniffedPromise.promise();
+ promise.promiseType = sniffedPromise.promiseType;
+ if (promise.$$state) {
+ $log.debug("promiseType: " + promise.promiseType + ", state: " + (promiseStatus(promise.$$state.status)));
+ }
+ promise.cancelCb = cancelCb;
+ return promise;
+ };
+ doSkippPromise = function(sniffedPromise, lastPromise) {
+ if (sniffedPromise.promiseType === promiseTypes.create && lastPromise.promiseType !== promiseTypes["delete"] && lastPromise.promiseType !== promiseTypes.init) {
+ $log.debug("lastPromise.promiseType " + lastPromise.promiseType + ", newPromiseType: " + sniffedPromise.promiseType + ", SKIPPED MUST COME AFTER DELETE ONLY");
+ return true;
+ }
+ return false;
+ };
+ maybeCancelPromises = function(queue, sniffedPromise, lastPromise) {
+ var first;
+ if (sniffedPromise.promiseType === promiseTypes["delete"] && lastPromise.promiseType !== promiseTypes["delete"]) {
+ if ((lastPromise.cancelCb != null) && _.isFunction(lastPromise.cancelCb) && isInProgress(lastPromise)) {
+ $log.debug("promiseType: " + sniffedPromise.promiseType + ", CANCELING LAST PROMISE type: " + lastPromise.promiseType);
+ lastPromise.cancelCb('cancel safe');
+ first = queue.peek();
+ if ((first != null) && isInProgress(first)) {
+ if (first.hasOwnProperty("cancelCb") && _.isFunction(first.cancelCb)) {
+ $log.debug("promiseType: " + first.promiseType + ", CANCELING FIRST PROMISE type: " + first.promiseType);
+ return first.cancelCb('cancel safe');
+ } else {
+ return $log.warn('first promise was not cancelable');
+ }
+ }
+ }
+ }
+ };
+
+ /*
+ From a High Level:
+ This is a SniffedPromiseQueueManager (looking to rename) where the queue is existingPiecesObj.existingPieces.
+ This is a function and should not be considered a class.
+ So it is run to manage the state (cancel, skip, link) as needed.
+ Purpose:
+ The whole point is to check if there is existing async work going on. If so we wait on it.
+
+ arguments:
+ - existingPiecesObj = Queue
",this.div_.innerHTML=img+"
alignBottom property is true)
+ * to the map pixel corresponding to position.
+ * @property {LatLng} position The geographic location at which to display the InfoBox.
+ * @property {number} zIndex The CSS z-index style value for the InfoBox.
+ * Note: This value overrides a zIndex setting specified in the boxStyle property.
+ * @property {string} [boxClass="infoBox"] The name of the CSS class defining the styles for the InfoBox container.
+ * @property {Object} [boxStyle] An object literal whose properties define specific CSS
+ * style values to be applied to the InfoBox. Style values defined here override those that may
+ * be defined in the boxClass style sheet. If this property is changed after the
+ * InfoBox has been created, all previously set styles (except those defined in the style sheet)
+ * are removed from the InfoBox before the new style values are applied.
+ * @property {string} closeBoxMargin The CSS margin style value for the close box.
+ * The default is "2px" (a 2-pixel margin on all sides).
+ * @property {string} closeBoxURL The URL of the image representing the close box.
+ * Note: The default is the URL for Google's standard close box.
+ * Set this property to "" if no close box is required.
+ * @property {Size} infoBoxClearance Minimum offset (in pixels) from the InfoBox to the
+ * map edge after an auto-pan.
+ * @property {boolean} [isHidden=false] Hide the InfoBox on open.
+ * [Deprecated in favor of the visible property.]
+ * @property {boolean} [visible=true] Show the InfoBox on open.
+ * @property {boolean} alignBottom Align the bottom left corner of the InfoBox to the position
+ * location (default is false which means that the top left corner of the InfoBox is aligned).
+ * @property {string} pane The pane where the InfoBox is to appear (default is "floatPane").
+ * Set the pane to "mapPane" if the InfoBox is being used as a map label.
+ * Valid pane names are the property names for the google.maps.MapPanes object.
+ * @property {boolean} enableEventPropagation Propagate mousedown, mousemove, mouseover, mouseout,
+ * mouseup, click, dblclick, touchstart, touchend, touchmove, and contextmenu events in the InfoBox
+ * (default is false to mimic the behavior of a google.maps.InfoWindow). Set
+ * this property to true if the InfoBox is being used as a map label.
+ */
+
+/**
+ * Creates an InfoBox with the options specified in {@link InfoBoxOptions}.
+ * Call InfoBox.open to add the box to the map.
+ * @constructor
+ * @param {InfoBoxOptions} [opt_opts]
+ */
+function InfoBox(opt_opts) {
+
+ opt_opts = opt_opts || {};
+
+ google.maps.OverlayView.apply(this, arguments);
+
+ // Standard options (in common with google.maps.InfoWindow):
+ //
+ this.content_ = opt_opts.content || "";
+ this.disableAutoPan_ = opt_opts.disableAutoPan || false;
+ this.maxWidth_ = opt_opts.maxWidth || 0;
+ this.pixelOffset_ = opt_opts.pixelOffset || new google.maps.Size(0, 0);
+ this.position_ = opt_opts.position || new google.maps.LatLng(0, 0);
+ this.zIndex_ = opt_opts.zIndex || null;
+
+ // Additional options (unique to InfoBox):
+ //
+ this.boxClass_ = opt_opts.boxClass || "infoBox";
+ this.boxStyle_ = opt_opts.boxStyle || {};
+ this.closeBoxMargin_ = opt_opts.closeBoxMargin || "2px";
+ this.closeBoxURL_ = opt_opts.closeBoxURL || "http://www.google.com/intl/en_us/mapfiles/close.gif";
+ if (opt_opts.closeBoxURL === "") {
+ this.closeBoxURL_ = "";
+ }
+ this.infoBoxClearance_ = opt_opts.infoBoxClearance || new google.maps.Size(1, 1);
+
+ if (typeof opt_opts.visible === "undefined") {
+ if (typeof opt_opts.isHidden === "undefined") {
+ opt_opts.visible = true;
+ } else {
+ opt_opts.visible = !opt_opts.isHidden;
+ }
+ }
+ this.isHidden_ = !opt_opts.visible;
+
+ this.alignBottom_ = opt_opts.alignBottom || false;
+ this.pane_ = opt_opts.pane || "floatPane";
+ this.enableEventPropagation_ = opt_opts.enableEventPropagation || false;
+
+ this.div_ = null;
+ this.closeListener_ = null;
+ this.moveListener_ = null;
+ this.contextListener_ = null;
+ this.eventListeners_ = null;
+ this.fixedWidthSet_ = null;
+}
+
+/* InfoBox extends OverlayView in the Google Maps API v3.
+ */
+InfoBox.prototype = new google.maps.OverlayView();
+
+/**
+ * Creates the DIV representing the InfoBox.
+ * @private
+ */
+InfoBox.prototype.createInfoBoxDiv_ = function () {
+
+ var i;
+ var events;
+ var bw;
+ var me = this;
+
+ // This handler prevents an event in the InfoBox from being passed on to the map.
+ //
+ var cancelHandler = function (e) {
+ e.cancelBubble = true;
+ if (e.stopPropagation) {
+ e.stopPropagation();
+ }
+ };
+
+ // This handler ignores the current event in the InfoBox and conditionally prevents
+ // the event from being passed on to the map. It is used for the contextmenu event.
+ //
+ var ignoreHandler = function (e) {
+
+ e.returnValue = false;
+
+ if (e.preventDefault) {
+
+ e.preventDefault();
+ }
+
+ if (!me.enableEventPropagation_) {
+
+ cancelHandler(e);
+ }
+ };
+
+ if (!this.div_) {
+
+ this.div_ = document.createElement("div");
+
+ this.setBoxStyle_();
+
+ if (typeof this.content_.nodeType === "undefined") {
+ this.div_.innerHTML = this.getCloseBoxImg_() + this.content_;
+ } else {
+ this.div_.innerHTML = this.getCloseBoxImg_();
+ this.div_.appendChild(this.content_);
+ }
+
+ // Add the InfoBox DIV to the DOM
+ this.getPanes()[this.pane_].appendChild(this.div_);
+
+ this.addClickHandler_();
+
+ if (this.div_.style.width) {
+
+ this.fixedWidthSet_ = true;
+
+ } else {
+
+ if (this.maxWidth_ !== 0 && this.div_.offsetWidth > this.maxWidth_) {
+
+ this.div_.style.width = this.maxWidth_;
+ this.div_.style.overflow = "auto";
+ this.fixedWidthSet_ = true;
+
+ } else { // The following code is needed to overcome problems with MSIE
+
+ bw = this.getBoxWidths_();
+
+ this.div_.style.width = (this.div_.offsetWidth - bw.left - bw.right) + "px";
+ this.fixedWidthSet_ = false;
+ }
+ }
+
+ this.panBox_(this.disableAutoPan_);
+
+ if (!this.enableEventPropagation_) {
+
+ this.eventListeners_ = [];
+
+ // Cancel event propagation.
+ //
+ // Note: mousemove not included (to resolve Issue 152)
+ events = ["mousedown", "mouseover", "mouseout", "mouseup",
+ "click", "dblclick", "touchstart", "touchend", "touchmove"];
+
+ for (i = 0; i < events.length; i++) {
+
+ this.eventListeners_.push(google.maps.event.addDomListener(this.div_, events[i], cancelHandler));
+ }
+
+ // Workaround for Google bug that causes the cursor to change to a pointer
+ // when the mouse moves over a marker underneath InfoBox.
+ this.eventListeners_.push(google.maps.event.addDomListener(this.div_, "mouseover", function (e) {
+ this.style.cursor = "default";
+ }));
+ }
+
+ this.contextListener_ = google.maps.event.addDomListener(this.div_, "contextmenu", ignoreHandler);
+
+ /**
+ * This event is fired when the DIV containing the InfoBox's content is attached to the DOM.
+ * @name InfoBox#domready
+ * @event
+ */
+ google.maps.event.trigger(this, "domready");
+ }
+};
+
+/**
+ * Returns the HTML tag for the close box.
+ * @private
+ */
+InfoBox.prototype.getCloseBoxImg_ = function () {
+
+ var img = "";
+
+ if (this.closeBoxURL_ !== "") {
+
+ img = "
";
+ }
+
+ return img;
+};
+
+/**
+ * Adds the click handler to the InfoBox close box.
+ * @private
+ */
+InfoBox.prototype.addClickHandler_ = function () {
+
+ var closeBox;
+
+ if (this.closeBoxURL_ !== "") {
+
+ closeBox = this.div_.firstChild;
+ this.closeListener_ = google.maps.event.addDomListener(closeBox, "click", this.getCloseClickHandler_());
+
+ } else {
+
+ this.closeListener_ = null;
+ }
+};
+
+/**
+ * Returns the function to call when the user clicks the close box of an InfoBox.
+ * @private
+ */
+InfoBox.prototype.getCloseClickHandler_ = function () {
+
+ var me = this;
+
+ return function (e) {
+
+ // 1.0.3 fix: Always prevent propagation of a close box click to the map:
+ e.cancelBubble = true;
+
+ if (e.stopPropagation) {
+
+ e.stopPropagation();
+ }
+
+ /**
+ * This event is fired when the InfoBox's close box is clicked.
+ * @name InfoBox#closeclick
+ * @event
+ */
+ google.maps.event.trigger(me, "closeclick");
+
+ me.close();
+ };
+};
+
+/**
+ * Pans the map so that the InfoBox appears entirely within the map's visible area.
+ * @private
+ */
+InfoBox.prototype.panBox_ = function (disablePan) {
+
+ var map;
+ var bounds;
+ var xOffset = 0, yOffset = 0;
+
+ if (!disablePan) {
+
+ map = this.getMap();
+
+ if (map instanceof google.maps.Map) { // Only pan if attached to map, not panorama
+
+ if (!map.getBounds().contains(this.position_)) {
+ // Marker not in visible area of map, so set center
+ // of map to the marker position first.
+ map.setCenter(this.position_);
+ }
+
+ bounds = map.getBounds();
+
+ var mapDiv = map.getDiv();
+ var mapWidth = mapDiv.offsetWidth;
+ var mapHeight = mapDiv.offsetHeight;
+ var iwOffsetX = this.pixelOffset_.width;
+ var iwOffsetY = this.pixelOffset_.height;
+ var iwWidth = this.div_.offsetWidth;
+ var iwHeight = this.div_.offsetHeight;
+ var padX = this.infoBoxClearance_.width;
+ var padY = this.infoBoxClearance_.height;
+ var pixPosition = this.getProjection().fromLatLngToContainerPixel(this.position_);
+
+ if (pixPosition.x < (-iwOffsetX + padX)) {
+ xOffset = pixPosition.x + iwOffsetX - padX;
+ } else if ((pixPosition.x + iwWidth + iwOffsetX + padX) > mapWidth) {
+ xOffset = pixPosition.x + iwWidth + iwOffsetX + padX - mapWidth;
+ }
+ if (this.alignBottom_) {
+ if (pixPosition.y < (-iwOffsetY + padY + iwHeight)) {
+ yOffset = pixPosition.y + iwOffsetY - padY - iwHeight;
+ } else if ((pixPosition.y + iwOffsetY + padY) > mapHeight) {
+ yOffset = pixPosition.y + iwOffsetY + padY - mapHeight;
+ }
+ } else {
+ if (pixPosition.y < (-iwOffsetY + padY)) {
+ yOffset = pixPosition.y + iwOffsetY - padY;
+ } else if ((pixPosition.y + iwHeight + iwOffsetY + padY) > mapHeight) {
+ yOffset = pixPosition.y + iwHeight + iwOffsetY + padY - mapHeight;
+ }
+ }
+
+ if (!(xOffset === 0 && yOffset === 0)) {
+
+ // Move the map to the shifted center.
+ //
+ var c = map.getCenter();
+ map.panBy(xOffset, yOffset);
+ }
+ }
+ }
+};
+
+/**
+ * Sets the style of the InfoBox by setting the style sheet and applying
+ * other specific styles requested.
+ * @private
+ */
+InfoBox.prototype.setBoxStyle_ = function () {
+
+ var i, boxStyle;
+
+ if (this.div_) {
+
+ // Apply style values from the style sheet defined in the boxClass parameter:
+ this.div_.className = this.boxClass_;
+
+ // Clear existing inline style values:
+ this.div_.style.cssText = "";
+
+ // Apply style values defined in the boxStyle parameter:
+ boxStyle = this.boxStyle_;
+ for (i in boxStyle) {
+
+ if (boxStyle.hasOwnProperty(i)) {
+
+ this.div_.style[i] = boxStyle[i];
+ }
+ }
+
+ // Fix for iOS disappearing InfoBox problem.
+ // See http://stackoverflow.com/questions/9229535/google-maps-markers-disappear-at-certain-zoom-level-only-on-iphone-ipad
+ this.div_.style.WebkitTransform = "translateZ(0)";
+
+ // Fix up opacity style for benefit of MSIE:
+ //
+ if (typeof this.div_.style.opacity !== "undefined" && this.div_.style.opacity !== "") {
+ // See http://www.quirksmode.org/css/opacity.html
+ this.div_.style.MsFilter = "\"progid:DXImageTransform.Microsoft.Alpha(Opacity=" + (this.div_.style.opacity * 100) + ")\"";
+ this.div_.style.filter = "alpha(opacity=" + (this.div_.style.opacity * 100) + ")";
+ }
+
+ // Apply required styles:
+ //
+ this.div_.style.position = "absolute";
+ this.div_.style.visibility = 'hidden';
+ if (this.zIndex_ !== null) {
+
+ this.div_.style.zIndex = this.zIndex_;
+ }
+ }
+};
+
+/**
+ * Get the widths of the borders of the InfoBox.
+ * @private
+ * @return {Object} widths object (top, bottom left, right)
+ */
+InfoBox.prototype.getBoxWidths_ = function () {
+
+ var computedStyle;
+ var bw = {top: 0, bottom: 0, left: 0, right: 0};
+ var box = this.div_;
+
+ if (document.defaultView && document.defaultView.getComputedStyle) {
+
+ computedStyle = box.ownerDocument.defaultView.getComputedStyle(box, "");
+
+ if (computedStyle) {
+
+ // The computed styles are always in pixel units (good!)
+ bw.top = parseInt(computedStyle.borderTopWidth, 10) || 0;
+ bw.bottom = parseInt(computedStyle.borderBottomWidth, 10) || 0;
+ bw.left = parseInt(computedStyle.borderLeftWidth, 10) || 0;
+ bw.right = parseInt(computedStyle.borderRightWidth, 10) || 0;
+ }
+
+ } else if (document.documentElement.currentStyle) { // MSIE
+
+ if (box.currentStyle) {
+
+ // The current styles may not be in pixel units, but assume they are (bad!)
+ bw.top = parseInt(box.currentStyle.borderTopWidth, 10) || 0;
+ bw.bottom = parseInt(box.currentStyle.borderBottomWidth, 10) || 0;
+ bw.left = parseInt(box.currentStyle.borderLeftWidth, 10) || 0;
+ bw.right = parseInt(box.currentStyle.borderRightWidth, 10) || 0;
+ }
+ }
+
+ return bw;
+};
+
+/**
+ * Invoked when close is called. Do not call it directly.
+ */
+InfoBox.prototype.onRemove = function () {
+
+ if (this.div_) {
+
+ this.div_.parentNode.removeChild(this.div_);
+ this.div_ = null;
+ }
+};
+
+/**
+ * Draws the InfoBox based on the current map projection and zoom level.
+ */
+InfoBox.prototype.draw = function () {
+
+ this.createInfoBoxDiv_();
+
+ var pixPosition = this.getProjection().fromLatLngToDivPixel(this.position_);
+
+ this.div_.style.left = (pixPosition.x + this.pixelOffset_.width) + "px";
+
+ if (this.alignBottom_) {
+ this.div_.style.bottom = -(pixPosition.y + this.pixelOffset_.height) + "px";
+ } else {
+ this.div_.style.top = (pixPosition.y + this.pixelOffset_.height) + "px";
+ }
+
+ if (this.isHidden_) {
+
+ this.div_.style.visibility = "hidden";
+
+ } else {
+
+ this.div_.style.visibility = "visible";
+ }
+};
+
+/**
+ * Sets the options for the InfoBox. Note that changes to the maxWidth,
+ * closeBoxMargin, closeBoxURL, and enableEventPropagation
+ * properties have no affect until the current InfoBox is closed and a new one
+ * is opened.
+ * @param {InfoBoxOptions} opt_opts
+ */
+InfoBox.prototype.setOptions = function (opt_opts) {
+ if (typeof opt_opts.boxClass !== "undefined") { // Must be first
+
+ this.boxClass_ = opt_opts.boxClass;
+ this.setBoxStyle_();
+ }
+ if (typeof opt_opts.boxStyle !== "undefined") { // Must be second
+
+ this.boxStyle_ = opt_opts.boxStyle;
+ this.setBoxStyle_();
+ }
+ if (typeof opt_opts.content !== "undefined") {
+
+ this.setContent(opt_opts.content);
+ }
+ if (typeof opt_opts.disableAutoPan !== "undefined") {
+
+ this.disableAutoPan_ = opt_opts.disableAutoPan;
+ }
+ if (typeof opt_opts.maxWidth !== "undefined") {
+
+ this.maxWidth_ = opt_opts.maxWidth;
+ }
+ if (typeof opt_opts.pixelOffset !== "undefined") {
+
+ this.pixelOffset_ = opt_opts.pixelOffset;
+ }
+ if (typeof opt_opts.alignBottom !== "undefined") {
+
+ this.alignBottom_ = opt_opts.alignBottom;
+ }
+ if (typeof opt_opts.position !== "undefined") {
+
+ this.setPosition(opt_opts.position);
+ }
+ if (typeof opt_opts.zIndex !== "undefined") {
+
+ this.setZIndex(opt_opts.zIndex);
+ }
+ if (typeof opt_opts.closeBoxMargin !== "undefined") {
+
+ this.closeBoxMargin_ = opt_opts.closeBoxMargin;
+ }
+ if (typeof opt_opts.closeBoxURL !== "undefined") {
+
+ this.closeBoxURL_ = opt_opts.closeBoxURL;
+ }
+ if (typeof opt_opts.infoBoxClearance !== "undefined") {
+
+ this.infoBoxClearance_ = opt_opts.infoBoxClearance;
+ }
+ if (typeof opt_opts.isHidden !== "undefined") {
+
+ this.isHidden_ = opt_opts.isHidden;
+ }
+ if (typeof opt_opts.visible !== "undefined") {
+
+ this.isHidden_ = !opt_opts.visible;
+ }
+ if (typeof opt_opts.enableEventPropagation !== "undefined") {
+
+ this.enableEventPropagation_ = opt_opts.enableEventPropagation;
+ }
+
+ if (this.div_) {
+
+ this.draw();
+ }
+};
+
+/**
+ * Sets the content of the InfoBox.
+ * The content can be plain text or an HTML DOM node.
+ * @param {string|Node} content
+ */
+InfoBox.prototype.setContent = function (content) {
+ this.content_ = content;
+
+ if (this.div_) {
+
+ if (this.closeListener_) {
+
+ google.maps.event.removeListener(this.closeListener_);
+ this.closeListener_ = null;
+ }
+
+ // Odd code required to make things work with MSIE.
+ //
+ if (!this.fixedWidthSet_) {
+
+ this.div_.style.width = "";
+ }
+
+ if (typeof content.nodeType === "undefined") {
+ this.div_.innerHTML = this.getCloseBoxImg_() + content;
+ } else {
+ this.div_.innerHTML = this.getCloseBoxImg_();
+ this.div_.appendChild(content);
+ }
+
+ // Perverse code required to make things work with MSIE.
+ // (Ensures the close box does, in fact, float to the right.)
+ //
+ if (!this.fixedWidthSet_) {
+ this.div_.style.width = this.div_.offsetWidth + "px";
+ if (typeof content.nodeType === "undefined") {
+ this.div_.innerHTML = this.getCloseBoxImg_() + content;
+ } else {
+ this.div_.innerHTML = this.getCloseBoxImg_();
+ this.div_.appendChild(content);
+ }
+ }
+
+ this.addClickHandler_();
+ }
+
+ /**
+ * This event is fired when the content of the InfoBox changes.
+ * @name InfoBox#content_changed
+ * @event
+ */
+ google.maps.event.trigger(this, "content_changed");
+};
+
+/**
+ * Sets the geographic location of the InfoBox.
+ * @param {LatLng} latlng
+ */
+InfoBox.prototype.setPosition = function (latlng) {
+
+ this.position_ = latlng;
+
+ if (this.div_) {
+
+ this.draw();
+ }
+
+ /**
+ * This event is fired when the position of the InfoBox changes.
+ * @name InfoBox#position_changed
+ * @event
+ */
+ google.maps.event.trigger(this, "position_changed");
+};
+
+/**
+ * Sets the zIndex style for the InfoBox.
+ * @param {number} index
+ */
+InfoBox.prototype.setZIndex = function (index) {
+
+ this.zIndex_ = index;
+
+ if (this.div_) {
+
+ this.div_.style.zIndex = index;
+ }
+
+ /**
+ * This event is fired when the zIndex of the InfoBox changes.
+ * @name InfoBox#zindex_changed
+ * @event
+ */
+ google.maps.event.trigger(this, "zindex_changed");
+};
+
+/**
+ * Sets the visibility of the InfoBox.
+ * @param {boolean} isVisible
+ */
+InfoBox.prototype.setVisible = function (isVisible) {
+
+ this.isHidden_ = !isVisible;
+ if (this.div_) {
+ this.div_.style.visibility = (this.isHidden_ ? "hidden" : "visible");
+ }
+};
+
+/**
+ * Returns the content of the InfoBox.
+ * @returns {string}
+ */
+InfoBox.prototype.getContent = function () {
+
+ return this.content_;
+};
+
+/**
+ * Returns the geographic location of the InfoBox.
+ * @returns {LatLng}
+ */
+InfoBox.prototype.getPosition = function () {
+
+ return this.position_;
+};
+
+/**
+ * Returns the zIndex for the InfoBox.
+ * @returns {number}
+ */
+InfoBox.prototype.getZIndex = function () {
+
+ return this.zIndex_;
+};
+
+/**
+ * Returns a flag indicating whether the InfoBox is visible.
+ * @returns {boolean}
+ */
+InfoBox.prototype.getVisible = function () {
+
+ var isVisible;
+
+ if ((typeof this.getMap() === "undefined") || (this.getMap() === null)) {
+ isVisible = false;
+ } else {
+ isVisible = !this.isHidden_;
+ }
+ return isVisible;
+};
+
+/**
+ * Shows the InfoBox. [Deprecated; use setVisible instead.]
+ */
+InfoBox.prototype.show = function () {
+
+ this.isHidden_ = false;
+ if (this.div_) {
+ this.div_.style.visibility = "visible";
+ }
+};
+
+/**
+ * Hides the InfoBox. [Deprecated; use setVisible instead.]
+ */
+InfoBox.prototype.hide = function () {
+
+ this.isHidden_ = true;
+ if (this.div_) {
+ this.div_.style.visibility = "hidden";
+ }
+};
+
+/**
+ * Adds the InfoBox to the specified map or Street View panorama. If anchor
+ * (usually a google.maps.Marker) is specified, the position
+ * of the InfoBox is set to the position of the anchor. If the
+ * anchor is dragged to a new location, the InfoBox moves as well.
+ * @param {Map|StreetViewPanorama} map
+ * @param {MVCObject} [anchor]
+ */
+InfoBox.prototype.open = function (map, anchor) {
+
+ var me = this;
+
+ if (anchor) {
+
+ this.position_ = anchor.getPosition();
+ this.moveListener_ = google.maps.event.addListener(anchor, "position_changed", function () {
+ me.setPosition(this.getPosition());
+ });
+ }
+
+ this.setMap(map);
+
+ if (this.div_) {
+
+ this.panBox_();
+ }
+};
+
+/**
+ * Removes the InfoBox from the map.
+ */
+InfoBox.prototype.close = function () {
+
+ var i;
+
+ if (this.closeListener_) {
+
+ google.maps.event.removeListener(this.closeListener_);
+ this.closeListener_ = null;
+ }
+
+ if (this.eventListeners_) {
+
+ for (i = 0; i < this.eventListeners_.length; i++) {
+
+ google.maps.event.removeListener(this.eventListeners_[i]);
+ }
+ this.eventListeners_ = null;
+ }
+
+ if (this.moveListener_) {
+
+ google.maps.event.removeListener(this.moveListener_);
+ this.moveListener_ = null;
+ }
+
+ if (this.contextListener_) {
+
+ google.maps.event.removeListener(this.contextListener_);
+ this.contextListener_ = null;
+ }
+
+ this.setMap(null);
+};
+
+/**
+ * google-maps-utility-library-v3-keydragzoom
+ *
+ * @version: 2.0.9
+ * @author: Nianwei Liu [nianwei at gmail dot com] & Gary Little [gary at luxcentral dot com]
+ * @contributors: undefined
+ * @date: Fri May 13 2016 13:45:18 GMT-0400 (EDT)
+ * @license: Apache License 2.0
+ */
+/**
+ * @fileoverview This library adds a drag zoom capability to a V3 Google map.
+ * When drag zoom is enabled, holding down a designated hot key
(shift | ctrl | alt)
+ * while dragging a box around an area of interest will zoom the map in to that area when
+ * the mouse button is released. Optionally, a visual control can also be supplied for turning
+ * a drag zoom operation on and off.
+ * Only one line of code is needed: google.maps.Map.enableKeyDragZoom();
+ *
NL: 2009-11-02: added a temp fix for -moz-transform for FF3.5.x using code from Paul Kulchenko (http://notebook.kulchenko.com/maps/gridmove).
+ *
NL: 2010-02-02: added a fix for IE flickering on divs onmousemove, caused by scroll value when get mouse position.
+ *
GL: 2010-06-15: added a visual control option.
+ */
+(function () {
+ /*jslint browser:true */
+ /*global window,google */
+ /* Utility functions use "var funName=function()" syntax to allow use of the */
+ /* Dean Edwards Packer compression tool (with Shrink variables, without Base62 encode). */
+
+ /**
+ * Converts "thin", "medium", and "thick" to pixel widths
+ * in an MSIE environment. Not called for other browsers
+ * because getComputedStyle() returns pixel widths automatically.
+ * @param {string} widthValue The value of the border width parameter.
+ */
+ var toPixels = function (widthValue) {
+ var px;
+ switch (widthValue) {
+ case "thin":
+ px = "2px";
+ break;
+ case "medium":
+ px = "4px";
+ break;
+ case "thick":
+ px = "6px";
+ break;
+ default:
+ px = widthValue;
+ }
+ return px;
+ };
+ /**
+ * Get the widths of the borders of an HTML element.
+ *
+ * @param {Node} h The HTML element.
+ * @return {Object} The width object {top, bottom left, right}.
+ */
+ var getBorderWidths = function (h) {
+ var computedStyle;
+ var bw = {};
+ if (document.defaultView && document.defaultView.getComputedStyle) {
+ computedStyle = h.ownerDocument.defaultView.getComputedStyle(h, "");
+ if (computedStyle) {
+ // The computed styles are always in pixel units (good!)
+ bw.top = parseInt(computedStyle.borderTopWidth, 10) || 0;
+ bw.bottom = parseInt(computedStyle.borderBottomWidth, 10) || 0;
+ bw.left = parseInt(computedStyle.borderLeftWidth, 10) || 0;
+ bw.right = parseInt(computedStyle.borderRightWidth, 10) || 0;
+ return bw;
+ }
+ } else if (document.documentElement.currentStyle) { // MSIE
+ if (h.currentStyle) {
+ // The current styles may not be in pixel units so try to convert (bad!)
+ bw.top = parseInt(toPixels(h.currentStyle.borderTopWidth), 10) || 0;
+ bw.bottom = parseInt(toPixels(h.currentStyle.borderBottomWidth), 10) || 0;
+ bw.left = parseInt(toPixels(h.currentStyle.borderLeftWidth), 10) || 0;
+ bw.right = parseInt(toPixels(h.currentStyle.borderRightWidth), 10) || 0;
+ return bw;
+ }
+ }
+ // Shouldn't get this far for any modern browser
+ bw.top = parseInt(h.style["border-top-width"], 10) || 0;
+ bw.bottom = parseInt(h.style["border-bottom-width"], 10) || 0;
+ bw.left = parseInt(h.style["border-left-width"], 10) || 0;
+ bw.right = parseInt(h.style["border-right-width"], 10) || 0;
+ return bw;
+ };
+
+ // Page scroll values for use by getMousePosition. To prevent flickering on MSIE
+ // they are calculated only when the document actually scrolls, not every time the
+ // mouse moves (as they would be if they were calculated inside getMousePosition).
+ var scroll = {
+ x: 0,
+ y: 0
+ };
+ var getScrollValue = function (e) {
+ scroll.x = (typeof document.documentElement.scrollLeft !== "undefined" ? document.documentElement.scrollLeft : document.body.scrollLeft);
+ scroll.y = (typeof document.documentElement.scrollTop !== "undefined" ? document.documentElement.scrollTop : document.body.scrollTop);
+ };
+ getScrollValue();
+
+ /**
+ * Get the position of the mouse relative to the document.
+ * @param {Event} e The mouse event.
+ * @return {Object} The position object {left, top}.
+ */
+ var getMousePosition = function (e) {
+ var posX = 0, posY = 0;
+ e = e || window.event;
+ if (typeof e.pageX !== "undefined") {
+ posX = e.pageX;
+ posY = e.pageY;
+ } else if (typeof e.clientX !== "undefined") { // MSIE
+ posX = e.clientX + scroll.x;
+ posY = e.clientY + scroll.y;
+ }
+ return {
+ left: posX,
+ top: posY
+ };
+ };
+ /**
+ * Get the position of an HTML element relative to the document.
+ * @param {Node} h The HTML element.
+ * @return {Object} The position object {left, top}.
+ */
+ var getElementPosition = function (h) {
+ var posX = h.offsetLeft;
+ var posY = h.offsetTop;
+ var parent = h.offsetParent;
+ // Add offsets for all ancestors in the hierarchy
+ while (parent !== null) {
+ // Adjust for scrolling elements which may affect the map position.
+ //
+ // See http://www.howtocreate.co.uk/tutorials/javascript/browserspecific
+ //
+ // "...make sure that every element [on a Web page] with an overflow
+ // of anything other than visible also has a position style set to
+ // something other than the default static..."
+ if (parent !== document.body && parent !== document.documentElement) {
+ posX -= parent.scrollLeft;
+ posY -= parent.scrollTop;
+ }
+ // See http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/4cb86c0c1037a5e5
+ // Example: http://notebook.kulchenko.com/maps/gridmove
+ var m = parent;
+ // This is the "normal" way to get offset information:
+ var moffx = m.offsetLeft;
+ var moffy = m.offsetTop;
+ // This covers those cases where a transform is used:
+ if (!moffx && !moffy && window.getComputedStyle) {
+ var matrix = document.defaultView.getComputedStyle(m, null).MozTransform ||
+ document.defaultView.getComputedStyle(m, null).WebkitTransform;
+ if (matrix) {
+ if (typeof matrix === "string") {
+ var parms = matrix.split(",");
+ moffx += parseInt(parms[4], 10) || 0;
+ moffy += parseInt(parms[5], 10) || 0;
+ }
+ }
+ }
+ posX += moffx;
+ posY += moffy;
+ parent = parent.offsetParent;
+ }
+ return {
+ left: posX,
+ top: posY
+ };
+ };
+ /**
+ * Set the properties of an object to those from another object.
+ * @param {Object} obj The target object.
+ * @param {Object} vals The source object.
+ */
+ var setVals = function (obj, vals) {
+ if (obj && vals) {
+ for (var x in vals) {
+ if (vals.hasOwnProperty(x)) {
+ obj[x] = vals[x];
+ }
+ }
+ }
+ return obj;
+ };
+ /**
+ * Set the opacity. If op is not passed in, this function just performs an MSIE fix.
+ * @param {Node} h The HTML element.
+ * @param {number} op The opacity value (0-1).
+ */
+ var setOpacity = function (h, op) {
+ if (typeof op !== "undefined") {
+ h.style.opacity = op;
+ }
+ if (typeof h.style.opacity !== "undefined" && h.style.opacity !== "") {
+ h.style.filter = "alpha(opacity=" + (h.style.opacity * 100) + ")";
+ }
+ };
+ /**
+ * @name KeyDragZoomOptions
+ * @class This class represents the optional parameter passed into google.maps.Map.enableKeyDragZoom.
+ * @property {string} [key="shift"] The hot key to hold down to activate a drag zoom, shift | ctrl | alt.
+ * NOTE: Do not use Ctrl as the hot key with Google Maps JavaScript API V3 since, unlike with V2,
+ * it causes a context menu to appear when running on the Macintosh. Also note that the
+ * alt hot key refers to the Option key on a Macintosh.
+ * @property {Object} [boxStyle={border: "4px solid #736AFF"}]
+ * An object literal defining the CSS styles of the zoom box.
+ * Border widths must be specified in pixel units (or as thin, medium, or thick).
+ * @property {Object} [veilStyle={backgroundColor: "gray", opacity: 0.25, cursor: "crosshair"}]
+ * An object literal defining the CSS styles of the veil pane which covers the map when a drag
+ * zoom is activated. The previous name for this property was paneStyle but the use
+ * of this name is now deprecated.
+ * @property {boolean} [noZoom=false] A flag indicating whether to disable zooming after an area is
+ * selected. Set this to true to allow KeyDragZoom to be used as a simple area
+ * selection tool.
+ * @property {boolean} [visualEnabled=false] A flag indicating whether a visual control is to be used.
+ * @property {string} [visualClass=""] The name of the CSS class defining the styles for the visual
+ * control. To prevent the visual control from being printed, set this property to the name of
+ * a class, defined inside a @media print rule, which sets the CSS
+ * display style to none.
+ * @property {ControlPosition} [visualPosition=google.maps.ControlPosition.LEFT_TOP]
+ * The position of the visual control.
+ * @property {Size} [visualPositionOffset=google.maps.Size(35, 0)] The width and height values
+ * provided by this property are the offsets (in pixels) from the location at which the control
+ * would normally be drawn to the desired drawing location.
+ * @property {number} [visualPositionIndex=null] The index of the visual control.
+ * The index is for controlling the placement of the control relative to other controls at the
+ * position given by visualPosition; controls with a lower index are placed first.
+ * Use a negative value to place the control before any default controls. No index is
+ * generally required.
+ * @property {String} [visualSprite="http://maps.gstatic.com/mapfiles/ftr/controls/dragzoom_btn.png"]
+ * The URL of the sprite image used for showing the visual control in the on, off, and hot
+ * (i.e., when the mouse is over the control) states. The three images within the sprite must
+ * be the same size and arranged in on-hot-off order in a single row with no spaces between images.
+ * @property {Size} [visualSize=google.maps.Size(20, 20)] The width and height values provided by
+ * this property are the size (in pixels) of each of the images within visualSprite.
+ * @property {Object} [visualTips={off: "Turn on drag zoom mode", on: "Turn off drag zoom mode"}]
+ * An object literal defining the help tips that appear when
+ * the mouse moves over the visual control. The off property is the tip to be shown
+ * when the control is off and the on property is the tip to be shown when the
+ * control is on.
+ */
+ /**
+ * @name DragZoom
+ * @class This class represents a drag zoom object for a map. The object is activated by holding down the hot key
+ * or by turning on the visual control.
+ * This object is created when google.maps.Map.enableKeyDragZoom is called; it cannot be created directly.
+ * Use google.maps.Map.getDragZoomObject to gain access to this object in order to attach event listeners.
+ * @param {Map} map The map to which the DragZoom object is to be attached.
+ * @param {KeyDragZoomOptions} [opt_zoomOpts] The optional parameters.
+ */
+ function DragZoom(map, opt_zoomOpts) {
+ var me = this;
+ var ov = new google.maps.OverlayView();
+ ov.onAdd = function () {
+ me.init_(map, opt_zoomOpts);
+ };
+ ov.draw = function () {
+ };
+ ov.onRemove = function () {
+ };
+ ov.setMap(map);
+ this.prjov_ = ov;
+ }
+ /**
+ * Initialize the tool.
+ * @param {Map} map The map to which the DragZoom object is to be attached.
+ * @param {KeyDragZoomOptions} [opt_zoomOpts] The optional parameters.
+ */
+ DragZoom.prototype.init_ = function (map, opt_zoomOpts) {
+ var i;
+ var me = this;
+ this.map_ = map;
+ opt_zoomOpts = opt_zoomOpts || {};
+ this.key_ = opt_zoomOpts.key || "shift";
+ this.key_ = this.key_.toLowerCase();
+ this.borderWidths_ = getBorderWidths(this.map_.getDiv());
+ this.veilDiv_ = [];
+ for (i = 0; i < 4; i++) {
+ this.veilDiv_[i] = document.createElement("div");
+ // Prevents selection of other elements on the webpage
+ // when a drag zoom operation is in progress:
+ this.veilDiv_[i].onselectstart = function () {
+ return false;
+ };
+ // Apply default style values for the veil:
+ setVals(this.veilDiv_[i].style, {
+ backgroundColor: "gray",
+ opacity: 0.25,
+ cursor: "crosshair"
+ });
+ // Apply style values specified in veilStyle parameter:
+ setVals(this.veilDiv_[i].style, opt_zoomOpts.paneStyle); // Old option name was "paneStyle"
+ setVals(this.veilDiv_[i].style, opt_zoomOpts.veilStyle); // New name is "veilStyle"
+ // Apply mandatory style values:
+ setVals(this.veilDiv_[i].style, {
+ position: "absolute",
+ overflow: "hidden",
+ display: "none"
+ });
+ // Workaround for Firefox Shift-Click problem:
+ if (this.key_ === "shift") {
+ this.veilDiv_[i].style.MozUserSelect = "none";
+ }
+ setOpacity(this.veilDiv_[i]);
+ // An IE fix: If the background is transparent it cannot capture mousedown
+ // events, so if it is, change the background to white with 0 opacity.
+ if (this.veilDiv_[i].style.backgroundColor === "transparent") {
+ this.veilDiv_[i].style.backgroundColor = "white";
+ setOpacity(this.veilDiv_[i], 0);
+ }
+ this.map_.getDiv().appendChild(this.veilDiv_[i]);
+ }
+
+ this.noZoom_ = opt_zoomOpts.noZoom || false;
+ this.visualEnabled_ = opt_zoomOpts.visualEnabled || false;
+ this.visualClass_ = opt_zoomOpts.visualClass || "";
+ this.visualPosition_ = opt_zoomOpts.visualPosition || google.maps.ControlPosition.LEFT_TOP;
+ this.visualPositionOffset_ = opt_zoomOpts.visualPositionOffset || new google.maps.Size(35, 0);
+ this.visualPositionIndex_ = opt_zoomOpts.visualPositionIndex || null;
+ this.visualSprite_ = opt_zoomOpts.visualSprite || "http" + (document.location.protocol === "https:" ? "s" : "") + "://maps.gstatic.com/mapfiles/ftr/controls/dragzoom_btn.png";
+ this.visualSize_ = opt_zoomOpts.visualSize || new google.maps.Size(20, 20);
+ this.visualTips_ = opt_zoomOpts.visualTips || {};
+ this.visualTips_.off = this.visualTips_.off || "Turn on drag zoom mode";
+ this.visualTips_.on = this.visualTips_.on || "Turn off drag zoom mode";
+
+ this.boxDiv_ = document.createElement("div");
+ // Apply default style values for the zoom box:
+ setVals(this.boxDiv_.style, {
+ border: "4px solid #736AFF"
+ });
+ // Apply style values specified in boxStyle parameter:
+ setVals(this.boxDiv_.style, opt_zoomOpts.boxStyle);
+ // Apply mandatory style values:
+ setVals(this.boxDiv_.style, {
+ position: "absolute",
+ display: "none"
+ });
+ setOpacity(this.boxDiv_);
+ this.map_.getDiv().appendChild(this.boxDiv_);
+ this.boxBorderWidths_ = getBorderWidths(this.boxDiv_);
+
+ this.listeners_ = [
+ google.maps.event.addDomListener(document, "keydown", function (e) {
+ me.onKeyDown_(e);
+ }),
+ google.maps.event.addDomListener(document, "keyup", function (e) {
+ me.onKeyUp_(e);
+ }),
+ google.maps.event.addDomListener(this.veilDiv_[0], "mousedown", function (e) {
+ me.onMouseDown_(e);
+ }),
+ google.maps.event.addDomListener(this.veilDiv_[1], "mousedown", function (e) {
+ me.onMouseDown_(e);
+ }),
+ google.maps.event.addDomListener(this.veilDiv_[2], "mousedown", function (e) {
+ me.onMouseDown_(e);
+ }),
+ google.maps.event.addDomListener(this.veilDiv_[3], "mousedown", function (e) {
+ me.onMouseDown_(e);
+ }),
+ google.maps.event.addDomListener(document, "mousedown", function (e) {
+ me.onMouseDownDocument_(e);
+ }),
+ google.maps.event.addDomListener(document, "mousemove", function (e) {
+ me.onMouseMove_(e);
+ }),
+ google.maps.event.addDomListener(document, "mouseup", function (e) {
+ me.onMouseUp_(e);
+ }),
+ google.maps.event.addDomListener(window, "scroll", getScrollValue)
+ ];
+
+ this.hotKeyDown_ = false;
+ this.mouseDown_ = false;
+ this.dragging_ = false;
+ this.startPt_ = null;
+ this.endPt_ = null;
+ this.mapWidth_ = null;
+ this.mapHeight_ = null;
+ this.mousePosn_ = null;
+ this.mapPosn_ = null;
+
+ if (this.visualEnabled_) {
+ this.buttonDiv_ = this.initControl_(this.visualPositionOffset_);
+ if (this.visualPositionIndex_ !== null) {
+ this.buttonDiv_.index = this.visualPositionIndex_;
+ }
+ this.map_.controls[this.visualPosition_].push(this.buttonDiv_);
+ this.controlIndex_ = this.map_.controls[this.visualPosition_].length - 1;
+ }
+ };
+ /**
+ * Initializes the visual control and returns its DOM element.
+ * @param {Size} offset The offset of the control from its normal position.
+ * @return {Node} The DOM element containing the visual control.
+ */
+ DragZoom.prototype.initControl_ = function (offset) {
+ var control;
+ var image;
+ var me = this;
+
+ control = document.createElement("div");
+ control.className = this.visualClass_;
+ control.style.position = "relative";
+ control.style.overflow = "hidden";
+ control.style.height = this.visualSize_.height + "px";
+ control.style.width = this.visualSize_.width + "px";
+ control.title = this.visualTips_.off;
+ image = document.createElement("img");
+ image.src = this.visualSprite_;
+ image.style.position = "absolute";
+ image.style.left = -(this.visualSize_.width * 2) + "px";
+ image.style.top = 0 + "px";
+ control.appendChild(image);
+ control.onclick = function (e) {
+ me.hotKeyDown_ = !me.hotKeyDown_;
+ if (me.hotKeyDown_) {
+ me.buttonDiv_.firstChild.style.left = -(me.visualSize_.width * 0) + "px";
+ me.buttonDiv_.title = me.visualTips_.on;
+ me.activatedByControl_ = true;
+ google.maps.event.trigger(me, "activate");
+ } else {
+ me.buttonDiv_.firstChild.style.left = -(me.visualSize_.width * 2) + "px";
+ me.buttonDiv_.title = me.visualTips_.off;
+ google.maps.event.trigger(me, "deactivate");
+ }
+ me.onMouseMove_(e); // Updates the veil
+ };
+ control.onmouseover = function () {
+ me.buttonDiv_.firstChild.style.left = -(me.visualSize_.width * 1) + "px";
+ };
+ control.onmouseout = function () {
+ if (me.hotKeyDown_) {
+ me.buttonDiv_.firstChild.style.left = -(me.visualSize_.width * 0) + "px";
+ me.buttonDiv_.title = me.visualTips_.on;
+ } else {
+ me.buttonDiv_.firstChild.style.left = -(me.visualSize_.width * 2) + "px";
+ me.buttonDiv_.title = me.visualTips_.off;
+ }
+ };
+ control.ondragstart = function () {
+ return false;
+ };
+ setVals(control.style, {
+ cursor: "pointer",
+ marginTop: offset.height + "px",
+ marginLeft: offset.width + "px"
+ });
+ return control;
+ };
+ /**
+ * Returns true if the hot key is being pressed when an event occurs.
+ * @param {Event} e The keyboard event.
+ * @return {boolean} Flag indicating whether the hot key is down.
+ */
+ DragZoom.prototype.isHotKeyDown_ = function (e) {
+ var isHot;
+ e = e || window.event;
+ isHot = (e.shiftKey && this.key_ === "shift") || (e.altKey && this.key_ === "alt") || (e.ctrlKey && this.key_ === "ctrl");
+ if (!isHot) {
+ // Need to look at keyCode for Opera because it
+ // doesn't set the shiftKey, altKey, ctrlKey properties
+ // unless a non-modifier event is being reported.
+ //
+ // See http://cross-browser.com/x/examples/shift_mode.php
+ // Also see http://unixpapa.com/js/key.html
+ switch (e.keyCode) {
+ case 16:
+ if (this.key_ === "shift") {
+ isHot = true;
+ }
+ break;
+ case 17:
+ if (this.key_ === "ctrl") {
+ isHot = true;
+ }
+ break;
+ case 18:
+ if (this.key_ === "alt") {
+ isHot = true;
+ }
+ break;
+ }
+ }
+ return isHot;
+ };
+ /**
+ * Returns true if the mouse is on top of the map div.
+ * The position is captured in onMouseMove_.
+ * @return {boolean}
+ */
+ DragZoom.prototype.isMouseOnMap_ = function () {
+ var mousePosn = this.mousePosn_;
+ if (mousePosn) {
+ var mapPosn = this.mapPosn_;
+ var mapDiv = this.map_.getDiv();
+ return mousePosn.left > mapPosn.left && mousePosn.left < (mapPosn.left + mapDiv.offsetWidth) &&
+ mousePosn.top > mapPosn.top && mousePosn.top < (mapPosn.top + mapDiv.offsetHeight);
+ } else {
+ // if user never moved mouse
+ return false;
+ }
+ };
+ /**
+ * Show the veil if the hot key is down and the mouse is over the map,
+ * otherwise hide the veil.
+ */
+ DragZoom.prototype.setVeilVisibility_ = function () {
+ var i;
+ if (this.map_ && this.hotKeyDown_ && this.isMouseOnMap_()) {
+ var mapDiv = this.map_.getDiv();
+ this.mapWidth_ = mapDiv.offsetWidth - (this.borderWidths_.left + this.borderWidths_.right);
+ this.mapHeight_ = mapDiv.offsetHeight - (this.borderWidths_.top + this.borderWidths_.bottom);
+ if (this.activatedByControl_) { // Veil covers entire map (except control)
+ var left = parseInt(this.buttonDiv_.style.left, 10) + this.visualPositionOffset_.width;
+ var top = parseInt(this.buttonDiv_.style.top, 10) + this.visualPositionOffset_.height;
+ var width = this.visualSize_.width;
+ var height = this.visualSize_.height;
+ // Left veil rectangle:
+ this.veilDiv_[0].style.top = "0px";
+ this.veilDiv_[0].style.left = "0px";
+ this.veilDiv_[0].style.width = left + "px";
+ this.veilDiv_[0].style.height = this.mapHeight_ + "px";
+ // Right veil rectangle:
+ this.veilDiv_[1].style.top = "0px";
+ this.veilDiv_[1].style.left = (left + width) + "px";
+ this.veilDiv_[1].style.width = (this.mapWidth_ - (left + width)) + "px";
+ this.veilDiv_[1].style.height = this.mapHeight_ + "px";
+ // Top veil rectangle:
+ this.veilDiv_[2].style.top = "0px";
+ this.veilDiv_[2].style.left = left + "px";
+ this.veilDiv_[2].style.width = width + "px";
+ this.veilDiv_[2].style.height = top + "px";
+ // Bottom veil rectangle:
+ this.veilDiv_[3].style.top = (top + height) + "px";
+ this.veilDiv_[3].style.left = left + "px";
+ this.veilDiv_[3].style.width = width + "px";
+ this.veilDiv_[3].style.height = (this.mapHeight_ - (top + height)) + "px";
+ for (i = 0; i < this.veilDiv_.length; i++) {
+ this.veilDiv_[i].style.display = "block";
+ }
+ } else {
+ this.veilDiv_[0].style.left = "0px";
+ this.veilDiv_[0].style.top = "0px";
+ this.veilDiv_[0].style.width = this.mapWidth_ + "px";
+ this.veilDiv_[0].style.height = this.mapHeight_ + "px";
+ for (i = 1; i < this.veilDiv_.length; i++) {
+ this.veilDiv_[i].style.width = "0px";
+ this.veilDiv_[i].style.height = "0px";
+ }
+ for (i = 0; i < this.veilDiv_.length; i++) {
+ this.veilDiv_[i].style.display = "block";
+ }
+ }
+ } else {
+ for (i = 0; i < this.veilDiv_.length; i++) {
+ this.veilDiv_[i].style.display = "none";
+ }
+ }
+ };
+ /**
+ * Handle key down. Show the veil if the hot key has been pressed.
+ * @param {Event} e The keyboard event.
+ */
+ DragZoom.prototype.onKeyDown_ = function (e) {
+ if (this.map_ && !this.hotKeyDown_ && this.isHotKeyDown_(e)) {
+ this.mapPosn_ = getElementPosition(this.map_.getDiv());
+ this.hotKeyDown_ = true;
+ this.activatedByControl_ = false;
+ this.setVeilVisibility_();
+ /**
+ * This event is fired when the hot key is pressed.
+ * @name DragZoom#activate
+ * @event
+ */
+ google.maps.event.trigger(this, "activate");
+ }
+ };
+ /**
+ * Get the google.maps.Point of the mouse position.
+ * @param {Event} e The mouse event.
+ * @return {Point} The mouse position.
+ */
+ DragZoom.prototype.getMousePoint_ = function (e) {
+ var mousePosn = getMousePosition(e);
+ var p = new google.maps.Point();
+ p.x = mousePosn.left - this.mapPosn_.left - this.borderWidths_.left;
+ p.y = mousePosn.top - this.mapPosn_.top - this.borderWidths_.top;
+ p.x = Math.min(p.x, this.mapWidth_);
+ p.y = Math.min(p.y, this.mapHeight_);
+ p.x = Math.max(p.x, 0);
+ p.y = Math.max(p.y, 0);
+ return p;
+ };
+ /**
+ * Handle mouse down.
+ * @param {Event} e The mouse event.
+ */
+ DragZoom.prototype.onMouseDown_ = function (e) {
+ if (this.map_ && this.hotKeyDown_) {
+ this.mapPosn_ = getElementPosition(this.map_.getDiv());
+ this.dragging_ = true;
+ this.startPt_ = this.endPt_ = this.getMousePoint_(e);
+ this.boxDiv_.style.width = this.boxDiv_.style.height = "0px";
+ var prj = this.prjov_.getProjection();
+ var latlng = prj.fromContainerPixelToLatLng(this.startPt_);
+ /**
+ * This event is fired when the drag operation begins.
+ * The parameter passed is the geographic position of the starting point.
+ * @name DragZoom#dragstart
+ * @param {LatLng} latlng The geographic position of the starting point.
+ * @event
+ */
+ google.maps.event.trigger(this, "dragstart", latlng);
+ }
+ };
+ /**
+ * Handle mouse down at the document level.
+ * @param {Event} e The mouse event.
+ */
+ DragZoom.prototype.onMouseDownDocument_ = function (e) {
+ this.mouseDown_ = true;
+ };
+ /**
+ * Handle mouse move.
+ * @param {Event} e The mouse event.
+ */
+ DragZoom.prototype.onMouseMove_ = function (e) {
+ this.mousePosn_ = getMousePosition(e);
+ if (this.dragging_) {
+ this.endPt_ = this.getMousePoint_(e);
+ var left = Math.min(this.startPt_.x, this.endPt_.x);
+ var top = Math.min(this.startPt_.y, this.endPt_.y);
+ var width = Math.abs(this.startPt_.x - this.endPt_.x);
+ var height = Math.abs(this.startPt_.y - this.endPt_.y);
+ // For benefit of MSIE 7/8 ensure following values are not negative:
+ var boxWidth = Math.max(0, width - (this.boxBorderWidths_.left + this.boxBorderWidths_.right));
+ var boxHeight = Math.max(0, height - (this.boxBorderWidths_.top + this.boxBorderWidths_.bottom));
+ // Left veil rectangle:
+ this.veilDiv_[0].style.top = "0px";
+ this.veilDiv_[0].style.left = "0px";
+ this.veilDiv_[0].style.width = left + "px";
+ this.veilDiv_[0].style.height = this.mapHeight_ + "px";
+ // Right veil rectangle:
+ this.veilDiv_[1].style.top = "0px";
+ this.veilDiv_[1].style.left = (left + width) + "px";
+ this.veilDiv_[1].style.width = (this.mapWidth_ - (left + width)) + "px";
+ this.veilDiv_[1].style.height = this.mapHeight_ + "px";
+ // Top veil rectangle:
+ this.veilDiv_[2].style.top = "0px";
+ this.veilDiv_[2].style.left = left + "px";
+ this.veilDiv_[2].style.width = width + "px";
+ this.veilDiv_[2].style.height = top + "px";
+ // Bottom veil rectangle:
+ this.veilDiv_[3].style.top = (top + height) + "px";
+ this.veilDiv_[3].style.left = left + "px";
+ this.veilDiv_[3].style.width = width + "px";
+ this.veilDiv_[3].style.height = (this.mapHeight_ - (top + height)) + "px";
+ // Selection rectangle:
+ this.boxDiv_.style.top = top + "px";
+ this.boxDiv_.style.left = left + "px";
+ this.boxDiv_.style.width = boxWidth + "px";
+ this.boxDiv_.style.height = boxHeight + "px";
+ this.boxDiv_.style.display = "block";
+ /**
+ * This event is fired repeatedly while the user drags a box across the area of interest.
+ * The southwest and northeast point are passed as parameters of type google.maps.Point
+ * (for performance reasons), relative to the map container. Also passed is the projection object
+ * so that the event listener, if necessary, can convert the pixel positions to geographic
+ * coordinates using google.maps.MapCanvasProjection.fromContainerPixelToLatLng.
+ * @name DragZoom#drag
+ * @param {Point} southwestPixel The southwest point of the selection area.
+ * @param {Point} northeastPixel The northeast point of the selection area.
+ * @param {MapCanvasProjection} prj The projection object.
+ * @event
+ */
+ google.maps.event.trigger(this, "drag", new google.maps.Point(left, top + height), new google.maps.Point(left + width, top), this.prjov_.getProjection());
+ } else if (!this.mouseDown_) {
+ this.mapPosn_ = getElementPosition(this.map_.getDiv());
+ this.setVeilVisibility_();
+ }
+ };
+ /**
+ * Handle mouse up.
+ * @param {Event} e The mouse event.
+ */
+ DragZoom.prototype.onMouseUp_ = function (e) {
+ var z;
+ var me = this;
+ this.mouseDown_ = false;
+ if (this.dragging_) {
+ if ((this.getMousePoint_(e).x === this.startPt_.x) && (this.getMousePoint_(e).y === this.startPt_.y)) {
+ this.onKeyUp_(e); // Cancel event
+ return;
+ }
+ var left = Math.min(this.startPt_.x, this.endPt_.x);
+ var top = Math.min(this.startPt_.y, this.endPt_.y);
+ var width = Math.abs(this.startPt_.x - this.endPt_.x);
+ var height = Math.abs(this.startPt_.y - this.endPt_.y);
+ // Google Maps API bug: setCenter() doesn't work as expected if the map has a
+ // border on the left or top. The code here includes a workaround for this problem.
+ var kGoogleCenteringBug = true;
+ if (kGoogleCenteringBug) {
+ left += this.borderWidths_.left;
+ top += this.borderWidths_.top;
+ }
+
+ var prj = this.prjov_.getProjection();
+ var sw = prj.fromContainerPixelToLatLng(new google.maps.Point(left, top + height));
+ var ne = prj.fromContainerPixelToLatLng(new google.maps.Point(left + width, top));
+ var bnds = new google.maps.LatLngBounds(sw, ne);
+
+ if (this.noZoom_) {
+ this.boxDiv_.style.display = "none";
+ } else {
+ // Sometimes fitBounds causes a zoom OUT, so restore original zoom level if this happens.
+ z = this.map_.getZoom();
+ this.map_.fitBounds(bnds);
+ if (this.map_.getZoom() < z) {
+ this.map_.setZoom(z);
+ }
+
+ // Redraw box after zoom:
+ var swPt = prj.fromLatLngToContainerPixel(sw);
+ var nePt = prj.fromLatLngToContainerPixel(ne);
+ if (kGoogleCenteringBug) {
+ swPt.x -= this.borderWidths_.left;
+ swPt.y -= this.borderWidths_.top;
+ nePt.x -= this.borderWidths_.left;
+ nePt.y -= this.borderWidths_.top;
+ }
+ this.boxDiv_.style.left = swPt.x + "px";
+ this.boxDiv_.style.top = nePt.y + "px";
+ this.boxDiv_.style.width = (Math.abs(nePt.x - swPt.x) - (this.boxBorderWidths_.left + this.boxBorderWidths_.right)) + "px";
+ this.boxDiv_.style.height = (Math.abs(nePt.y - swPt.y) - (this.boxBorderWidths_.top + this.boxBorderWidths_.bottom)) + "px";
+ // Hide box asynchronously after 1 second:
+ setTimeout(function () {
+ me.boxDiv_.style.display = "none";
+ }, 1000);
+ }
+ this.dragging_ = false;
+ this.onMouseMove_(e); // Updates the veil
+ /**
+ * This event is fired when the drag operation ends.
+ * The parameter passed is the geographic bounds of the selected area.
+ * Note that this event is not fired if the hot key is released before the drag operation ends.
+ * @name DragZoom#dragend
+ * @param {LatLngBounds} bnds The geographic bounds of the selected area.
+ * @event
+ */
+ google.maps.event.trigger(this, "dragend", bnds);
+ // if the hot key isn't down, the drag zoom must have been activated by turning
+ // on the visual control. In this case, finish up by simulating a key up event.
+ if (!this.isHotKeyDown_(e)) {
+ this.onKeyUp_(e);
+ }
+ }
+ };
+ /**
+ * Handle key up.
+ * @param {Event} e The keyboard event.
+ */
+ DragZoom.prototype.onKeyUp_ = function (e) {
+ var i;
+ var left, top, width, height, prj, sw, ne;
+ var bnds = null;
+ if (this.map_ && this.hotKeyDown_) {
+ this.hotKeyDown_ = false;
+ if (this.dragging_) {
+ this.boxDiv_.style.display = "none";
+ this.dragging_ = false;
+ // Calculate the bounds when drag zoom was cancelled
+ left = Math.min(this.startPt_.x, this.endPt_.x);
+ top = Math.min(this.startPt_.y, this.endPt_.y);
+ width = Math.abs(this.startPt_.x - this.endPt_.x);
+ height = Math.abs(this.startPt_.y - this.endPt_.y);
+ prj = this.prjov_.getProjection();
+ sw = prj.fromContainerPixelToLatLng(new google.maps.Point(left, top + height));
+ ne = prj.fromContainerPixelToLatLng(new google.maps.Point(left + width, top));
+ bnds = new google.maps.LatLngBounds(sw, ne);
+ }
+ for (i = 0; i < this.veilDiv_.length; i++) {
+ this.veilDiv_[i].style.display = "none";
+ }
+ if (this.visualEnabled_) {
+ this.buttonDiv_.firstChild.style.left = -(this.visualSize_.width * 2) + "px";
+ this.buttonDiv_.title = this.visualTips_.off;
+ this.buttonDiv_.style.display = "";
+ }
+ /**
+ * This event is fired when the hot key is released.
+ * The parameter passed is the geographic bounds of the selected area immediately
+ * before the hot key was released.
+ * @name DragZoom#deactivate
+ * @param {LatLngBounds} bnds The geographic bounds of the selected area immediately
+ * before the hot key was released.
+ * @event
+ */
+ google.maps.event.trigger(this, "deactivate", bnds);
+ }
+ };
+ /**
+ * @name google.maps.Map
+ * @class These are new methods added to the Google Maps JavaScript API V3's
+ * Map
+ * class.
+ */
+ /**
+ * Enables drag zoom. The user can zoom to an area of interest by holding down the hot key
+ * (shift | ctrl | alt ) while dragging a box around the area or by turning
+ * on the visual control then dragging a box around the area.
+ * @param {KeyDragZoomOptions} opt_zoomOpts The optional parameters.
+ */
+ google.maps.Map.prototype.enableKeyDragZoom = function (opt_zoomOpts) {
+ this.dragZoom_ = new DragZoom(this, opt_zoomOpts);
+ };
+ /**
+ * Disables drag zoom.
+ */
+ google.maps.Map.prototype.disableKeyDragZoom = function () {
+ var i;
+ var d = this.dragZoom_;
+ if (d) {
+ for (i = 0; i < d.listeners_.length; ++i) {
+ google.maps.event.removeListener(d.listeners_[i]);
+ }
+ this.getDiv().removeChild(d.boxDiv_);
+ for (i = 0; i < d.veilDiv_.length; i++) {
+ this.getDiv().removeChild(d.veilDiv_[i]);
+ }
+ if (d.visualEnabled_) {
+ // Remove the custom control:
+ this.controls[d.visualPosition_].removeAt(d.controlIndex_);
+ }
+ d.prjov_.setMap(null);
+ this.dragZoom_ = null;
+ }
+ };
+ /**
+ * Returns true if the drag zoom feature has been enabled.
+ * @return {boolean}
+ */
+ google.maps.Map.prototype.keyDragZoomEnabled = function () {
+ return this.dragZoom_ !== null;
+ };
+ /**
+ * Returns the DragZoom object which is created when google.maps.Map.enableKeyDragZoom is called.
+ * With this object you can use google.maps.event.addListener to attach event listeners
+ * for the "activate", "deactivate", "dragstart", "drag", and "dragend" events.
+ * @return {DragZoom}
+ */
+ google.maps.Map.prototype.getDragZoomObject = function () {
+ return this.dragZoom_;
+ };
+})();
+
+/**
+ * google-maps-utility-library-v3-markerwithlabel
+ *
+ * @version: 1.1.10
+ * @author: Gary Little (inspired by code from Marc Ridey of Google).
+ * @contributors: Nicholas McCready
+ * @date: Fri May 13 2016 16:29:58 GMT-0400 (EDT)
+ * @license: Apache License 2.0
+ */
+/**
+ * MarkerWithLabel allows you to define markers with associated labels. As you would expect,
+ * if the marker is draggable, so too will be the label. In addition, a marker with a label
+ * responds to all mouse events in the same manner as a regular marker. It also fires mouse
+ * events and "property changed" events just as a regular marker would. Version 1.1 adds
+ * support for the raiseOnDrag feature introduced in API V3.3.
+ * Esc key. This doesn't work if you drag the marker
+ * itself because this feature is not (yet) supported in the google.maps.Marker class.
+ */
+
+/*jslint browser:true */
+/*global document,google */
+
+/**
+ * @param {Function} childCtor Child class.
+ * @param {Function} parentCtor Parent class.
+ * @private
+ */
+function inherits(childCtor, parentCtor) {
+ /* @constructor */
+ function tempCtor() {}
+ tempCtor.prototype = parentCtor.prototype;
+ childCtor.superClass_ = parentCtor.prototype;
+ childCtor.prototype = new tempCtor();
+ /* @override */
+ childCtor.prototype.constructor = childCtor;
+}
+
+/**
+ * This constructor creates a label and associates it with a marker.
+ * It is for the private use of the MarkerWithLabel class.
+ * @constructor
+ * @param {Marker} marker The marker with which the label is to be associated.
+ * @param {string} crossURL The URL of the cross image =.
+ * @param {string} handCursor The URL of the hand cursor.
+ * @private
+ */
+function MarkerLabel_(marker, crossURL, handCursorURL) {
+ this.marker_ = marker;
+ this.handCursorURL_ = marker.handCursorURL;
+
+ this.labelDiv_ = document.createElement("div");
+ this.labelDiv_.style.cssText = "position: absolute; overflow: hidden;";
+
+ // Set up the DIV for handling mouse events in the label. This DIV forms a transparent veil
+ // in the "overlayMouseTarget" pane, a veil that covers just the label. This is done so that
+ // events can be captured even if the label is in the shadow of a google.maps.InfoWindow.
+ // Code is included here to ensure the veil is always exactly the same size as the label.
+ this.eventDiv_ = document.createElement("div");
+ this.eventDiv_.style.cssText = this.labelDiv_.style.cssText;
+
+ // This is needed for proper behavior on MSIE:
+ this.eventDiv_.setAttribute("onselectstart", "return false;");
+ this.eventDiv_.setAttribute("ondragstart", "return false;");
+
+ // Get the DIV for the "X" to be displayed when the marker is raised.
+ this.crossDiv_ = MarkerLabel_.getSharedCross(crossURL);
+}
+
+inherits(MarkerLabel_, google.maps.OverlayView);
+
+/**
+ * Returns the DIV for the cross used when dragging a marker when the
+ * raiseOnDrag parameter set to true. One cross is shared with all markers.
+ * @param {string} crossURL The URL of the cross image =.
+ * @private
+ */
+MarkerLabel_.getSharedCross = function (crossURL) {
+ var div;
+ if (typeof MarkerLabel_.getSharedCross.crossDiv === "undefined") {
+ div = document.createElement("img");
+ div.style.cssText = "position: absolute; z-index: 1000002; display: none;";
+ // Hopefully Google never changes the standard "X" attributes:
+ div.style.marginLeft = "-8px";
+ div.style.marginTop = "-9px";
+ div.src = crossURL;
+ MarkerLabel_.getSharedCross.crossDiv = div;
+ }
+ return MarkerLabel_.getSharedCross.crossDiv;
+};
+
+/**
+ * Adds the DIV representing the label to the DOM. This method is called
+ * automatically when the marker's setMap method is called.
+ * @private
+ */
+MarkerLabel_.prototype.onAdd = function () {
+ var me = this;
+ var cMouseIsDown = false;
+ var cDraggingLabel = false;
+ var cSavedZIndex;
+ var cLatOffset, cLngOffset;
+ var cIgnoreClick;
+ var cRaiseEnabled;
+ var cStartPosition;
+ var cStartCenter;
+ // Constants:
+ var cRaiseOffset = 20;
+ var cDraggingCursor = "url(" + this.handCursorURL_ + ")";
+
+ // Stops all processing of an event.
+ //
+ var cAbortEvent = function (e) {
+ if (e.preventDefault) {
+ e.preventDefault();
+ }
+ e.cancelBubble = true;
+ if (e.stopPropagation) {
+ e.stopPropagation();
+ }
+ };
+
+ var cStopBounce = function () {
+ me.marker_.setAnimation(null);
+ };
+
+ this.getPanes().overlayImage.appendChild(this.labelDiv_);
+ this.getPanes().overlayMouseTarget.appendChild(this.eventDiv_);
+ // One cross is shared with all markers, so only add it once:
+ if (typeof MarkerLabel_.getSharedCross.processed === "undefined") {
+ this.getPanes().overlayImage.appendChild(this.crossDiv_);
+ MarkerLabel_.getSharedCross.processed = true;
+ }
+
+ this.listeners_ = [
+ google.maps.event.addDomListener(this.eventDiv_, "mouseover", function (e) {
+ if (me.marker_.getDraggable() || me.marker_.getClickable()) {
+ this.style.cursor = "pointer";
+ google.maps.event.trigger(me.marker_, "mouseover", e);
+ }
+ }),
+ google.maps.event.addDomListener(this.eventDiv_, "mouseout", function (e) {
+ if ((me.marker_.getDraggable() || me.marker_.getClickable()) && !cDraggingLabel) {
+ this.style.cursor = me.marker_.getCursor();
+ google.maps.event.trigger(me.marker_, "mouseout", e);
+ }
+ }),
+ google.maps.event.addDomListener(this.eventDiv_, "mousedown", function (e) {
+ cDraggingLabel = false;
+ if (me.marker_.getDraggable()) {
+ cMouseIsDown = true;
+ this.style.cursor = cDraggingCursor;
+ }
+ if (me.marker_.getDraggable() || me.marker_.getClickable()) {
+ google.maps.event.trigger(me.marker_, "mousedown", e);
+ cAbortEvent(e); // Prevent map pan when starting a drag on a label
+ }
+ }),
+ google.maps.event.addDomListener(document, "mouseup", function (mEvent) {
+ var position;
+ if (cMouseIsDown) {
+ cMouseIsDown = false;
+ me.eventDiv_.style.cursor = "pointer";
+ google.maps.event.trigger(me.marker_, "mouseup", mEvent);
+ }
+ if (cDraggingLabel) {
+ if (cRaiseEnabled) { // Lower the marker & label
+ position = me.getProjection().fromLatLngToDivPixel(me.marker_.getPosition());
+ position.y += cRaiseOffset;
+ me.marker_.setPosition(me.getProjection().fromDivPixelToLatLng(position));
+ // This is not the same bouncing style as when the marker portion is dragged,
+ // but it will have to do:
+ try { // Will fail if running Google Maps API earlier than V3.3
+ me.marker_.setAnimation(google.maps.Animation.BOUNCE);
+ setTimeout(cStopBounce, 1406);
+ } catch (e) {}
+ }
+ me.crossDiv_.style.display = "none";
+ me.marker_.setZIndex(cSavedZIndex);
+ cIgnoreClick = true; // Set flag to ignore the click event reported after a label drag
+ cDraggingLabel = false;
+ mEvent.latLng = me.marker_.getPosition();
+ google.maps.event.trigger(me.marker_, "dragend", mEvent);
+ }
+ }),
+ google.maps.event.addListener(me.marker_.getMap(), "mousemove", function (mEvent) {
+ var position;
+ if (cMouseIsDown) {
+ if (cDraggingLabel) {
+ // Change the reported location from the mouse position to the marker position:
+ mEvent.latLng = new google.maps.LatLng(mEvent.latLng.lat() - cLatOffset, mEvent.latLng.lng() - cLngOffset);
+ position = me.getProjection().fromLatLngToDivPixel(mEvent.latLng);
+ if (cRaiseEnabled) {
+ me.crossDiv_.style.left = position.x + "px";
+ me.crossDiv_.style.top = position.y + "px";
+ me.crossDiv_.style.display = "";
+ position.y -= cRaiseOffset;
+ }
+ me.marker_.setPosition(me.getProjection().fromDivPixelToLatLng(position));
+ if (cRaiseEnabled) { // Don't raise the veil; this hack needed to make MSIE act properly
+ me.eventDiv_.style.top = (position.y + cRaiseOffset) + "px";
+ }
+ google.maps.event.trigger(me.marker_, "drag", mEvent);
+ } else {
+ // Calculate offsets from the click point to the marker position:
+ cLatOffset = mEvent.latLng.lat() - me.marker_.getPosition().lat();
+ cLngOffset = mEvent.latLng.lng() - me.marker_.getPosition().lng();
+ cSavedZIndex = me.marker_.getZIndex();
+ cStartPosition = me.marker_.getPosition();
+ cStartCenter = me.marker_.getMap().getCenter();
+ cRaiseEnabled = me.marker_.get("raiseOnDrag");
+ cDraggingLabel = true;
+ me.marker_.setZIndex(1000000); // Moves the marker & label to the foreground during a drag
+ mEvent.latLng = me.marker_.getPosition();
+ google.maps.event.trigger(me.marker_, "dragstart", mEvent);
+ }
+ }
+ }),
+ google.maps.event.addDomListener(document, "keydown", function (e) {
+ if (cDraggingLabel) {
+ if (e.keyCode === 27) { // Esc key
+ cRaiseEnabled = false;
+ me.marker_.setPosition(cStartPosition);
+ me.marker_.getMap().setCenter(cStartCenter);
+ google.maps.event.trigger(document, "mouseup", e);
+ }
+ }
+ }),
+ google.maps.event.addDomListener(this.eventDiv_, "click", function (e) {
+ if (me.marker_.getDraggable() || me.marker_.getClickable()) {
+ if (cIgnoreClick) { // Ignore the click reported when a label drag ends
+ cIgnoreClick = false;
+ } else {
+ google.maps.event.trigger(me.marker_, "click", e);
+ cAbortEvent(e); // Prevent click from being passed on to map
+ }
+ }
+ }),
+ google.maps.event.addDomListener(this.eventDiv_, "dblclick", function (e) {
+ if (me.marker_.getDraggable() || me.marker_.getClickable()) {
+ google.maps.event.trigger(me.marker_, "dblclick", e);
+ cAbortEvent(e); // Prevent map zoom when double-clicking on a label
+ }
+ }),
+ google.maps.event.addListener(this.marker_, "dragstart", function (mEvent) {
+ if (!cDraggingLabel) {
+ cRaiseEnabled = this.get("raiseOnDrag");
+ }
+ }),
+ google.maps.event.addListener(this.marker_, "drag", function (mEvent) {
+ if (!cDraggingLabel) {
+ if (cRaiseEnabled) {
+ me.setPosition(cRaiseOffset);
+ // During a drag, the marker's z-index is temporarily set to 1000000 to
+ // ensure it appears above all other markers. Also set the label's z-index
+ // to 1000000 (plus or minus 1 depending on whether the label is supposed
+ // to be above or below the marker).
+ me.labelDiv_.style.zIndex = 1000000 + (this.get("labelInBackground") ? -1 : +1);
+ }
+ }
+ }),
+ google.maps.event.addListener(this.marker_, "dragend", function (mEvent) {
+ if (!cDraggingLabel) {
+ if (cRaiseEnabled) {
+ me.setPosition(0); // Also restores z-index of label
+ }
+ }
+ }),
+ google.maps.event.addListener(this.marker_, "position_changed", function () {
+ me.setPosition();
+ }),
+ google.maps.event.addListener(this.marker_, "zindex_changed", function () {
+ me.setZIndex();
+ }),
+ google.maps.event.addListener(this.marker_, "visible_changed", function () {
+ me.setVisible();
+ }),
+ google.maps.event.addListener(this.marker_, "labelvisible_changed", function () {
+ me.setVisible();
+ }),
+ google.maps.event.addListener(this.marker_, "title_changed", function () {
+ me.setTitle();
+ }),
+ google.maps.event.addListener(this.marker_, "labelcontent_changed", function () {
+ me.setContent();
+ }),
+ google.maps.event.addListener(this.marker_, "labelanchor_changed", function () {
+ me.setAnchor();
+ }),
+ google.maps.event.addListener(this.marker_, "labelclass_changed", function () {
+ me.setStyles();
+ }),
+ google.maps.event.addListener(this.marker_, "labelstyle_changed", function () {
+ me.setStyles();
+ })
+ ];
+};
+
+/**
+ * Removes the DIV for the label from the DOM. It also removes all event handlers.
+ * This method is called automatically when the marker's setMap(null)
+ * method is called.
+ * @private
+ */
+MarkerLabel_.prototype.onRemove = function () {
+ var i;
+ this.labelDiv_.parentNode.removeChild(this.labelDiv_);
+ this.eventDiv_.parentNode.removeChild(this.eventDiv_);
+
+ // Remove event listeners:
+ for (i = 0; i < this.listeners_.length; i++) {
+ google.maps.event.removeListener(this.listeners_[i]);
+ }
+};
+
+/**
+ * Draws the label on the map.
+ * @private
+ */
+MarkerLabel_.prototype.draw = function () {
+ this.setContent();
+ this.setTitle();
+ this.setStyles();
+};
+
+/**
+ * Sets the content of the label.
+ * The content can be plain text or an HTML DOM node.
+ * @private
+ */
+MarkerLabel_.prototype.setContent = function () {
+ var content = this.marker_.get("labelContent");
+ if (typeof content.nodeType === "undefined") {
+ this.labelDiv_.innerHTML = content;
+ this.eventDiv_.innerHTML = this.labelDiv_.innerHTML;
+ } else {
+ this.labelDiv_.innerHTML = ""; // Remove current content
+ this.labelDiv_.appendChild(content);
+ content = content.cloneNode(true);
+ this.eventDiv_.innerHTML = ""; // Remove current content
+ this.eventDiv_.appendChild(content);
+ }
+};
+
+/**
+ * Sets the content of the tool tip for the label. It is
+ * always set to be the same as for the marker itself.
+ * @private
+ */
+MarkerLabel_.prototype.setTitle = function () {
+ this.eventDiv_.title = this.marker_.getTitle() || "";
+};
+
+/**
+ * Sets the style of the label by setting the style sheet and applying
+ * other specific styles requested.
+ * @private
+ */
+MarkerLabel_.prototype.setStyles = function () {
+ var i, labelStyle;
+
+ // Apply style values from the style sheet defined in the labelClass parameter:
+ this.labelDiv_.className = this.marker_.get("labelClass");
+ this.eventDiv_.className = this.labelDiv_.className;
+
+ // Clear existing inline style values:
+ this.labelDiv_.style.cssText = "";
+ this.eventDiv_.style.cssText = "";
+ // Apply style values defined in the labelStyle parameter:
+ labelStyle = this.marker_.get("labelStyle");
+ for (i in labelStyle) {
+ if (labelStyle.hasOwnProperty(i)) {
+ this.labelDiv_.style[i] = labelStyle[i];
+ this.eventDiv_.style[i] = labelStyle[i];
+ }
+ }
+ this.setMandatoryStyles();
+};
+
+/**
+ * Sets the mandatory styles to the DIV representing the label as well as to the
+ * associated event DIV. This includes setting the DIV position, z-index, and visibility.
+ * @private
+ */
+MarkerLabel_.prototype.setMandatoryStyles = function () {
+ this.labelDiv_.style.position = "absolute";
+ this.labelDiv_.style.overflow = "hidden";
+ // Make sure the opacity setting causes the desired effect on MSIE:
+ if (typeof this.labelDiv_.style.opacity !== "undefined" && this.labelDiv_.style.opacity !== "") {
+ this.labelDiv_.style.MsFilter = "\"progid:DXImageTransform.Microsoft.Alpha(opacity=" + (this.labelDiv_.style.opacity * 100) + ")\"";
+ this.labelDiv_.style.filter = "alpha(opacity=" + (this.labelDiv_.style.opacity * 100) + ")";
+ }
+
+ this.eventDiv_.style.position = this.labelDiv_.style.position;
+ this.eventDiv_.style.overflow = this.labelDiv_.style.overflow;
+ this.eventDiv_.style.opacity = 0.01; // Don't use 0; DIV won't be clickable on MSIE
+ this.eventDiv_.style.MsFilter = "\"progid:DXImageTransform.Microsoft.Alpha(opacity=1)\"";
+ this.eventDiv_.style.filter = "alpha(opacity=1)"; // For MSIE
+
+ this.setAnchor();
+ this.setPosition(); // This also updates z-index, if necessary.
+ this.setVisible();
+};
+
+/**
+ * Sets the anchor point of the label.
+ * @private
+ */
+MarkerLabel_.prototype.setAnchor = function () {
+ var anchor = this.marker_.get("labelAnchor");
+ this.labelDiv_.style.marginLeft = -anchor.x + "px";
+ this.labelDiv_.style.marginTop = -anchor.y + "px";
+ this.eventDiv_.style.marginLeft = -anchor.x + "px";
+ this.eventDiv_.style.marginTop = -anchor.y + "px";
+};
+
+/**
+ * Sets the position of the label. The z-index is also updated, if necessary.
+ * @private
+ */
+MarkerLabel_.prototype.setPosition = function (yOffset) {
+ var position = this.getProjection().fromLatLngToDivPixel(this.marker_.getPosition());
+ if (typeof yOffset === "undefined") {
+ yOffset = 0;
+ }
+ this.labelDiv_.style.left = Math.round(position.x) + "px";
+ this.labelDiv_.style.top = Math.round(position.y - yOffset) + "px";
+ this.eventDiv_.style.left = this.labelDiv_.style.left;
+ this.eventDiv_.style.top = this.labelDiv_.style.top;
+
+ this.setZIndex();
+};
+
+/**
+ * Sets the z-index of the label. If the marker's z-index property has not been defined, the z-index
+ * of the label is set to the vertical coordinate of the label. This is in keeping with the default
+ * stacking order for Google Maps: markers to the south are in front of markers to the north.
+ * @private
+ */
+MarkerLabel_.prototype.setZIndex = function () {
+ var zAdjust = (this.marker_.get("labelInBackground") ? -1 : +1);
+ if (typeof this.marker_.getZIndex() === "undefined") {
+ this.labelDiv_.style.zIndex = parseInt(this.labelDiv_.style.top, 10) + zAdjust;
+ this.eventDiv_.style.zIndex = this.labelDiv_.style.zIndex;
+ } else {
+ this.labelDiv_.style.zIndex = this.marker_.getZIndex() + zAdjust;
+ this.eventDiv_.style.zIndex = this.labelDiv_.style.zIndex;
+ }
+};
+
+/**
+ * Sets the visibility of the label. The label is visible only if the marker itself is
+ * visible (i.e., its visible property is true) and the labelVisible property is true.
+ * @private
+ */
+MarkerLabel_.prototype.setVisible = function () {
+ if (this.marker_.get("labelVisible")) {
+ this.labelDiv_.style.display = this.marker_.getVisible() ? "block" : "none";
+ } else {
+ this.labelDiv_.style.display = "none";
+ }
+ this.eventDiv_.style.display = this.labelDiv_.style.display;
+};
+
+/**
+ * @name MarkerWithLabelOptions
+ * @class This class represents the optional parameter passed to the {@link MarkerWithLabel} constructor.
+ * The properties available are the same as for google.maps.Marker with the addition
+ * of the properties listed below. To change any of these additional properties after the labeled
+ * marker has been created, call google.maps.Marker.set(propertyName, propertyValue).
+ * propertyname_changed.
+ * For example, if the content of the label changes, a labelcontent_changed event
+ * is fired.
+ * labelAnchor of google.maps.Point(25, 0).
+ * (Note: x-values increase to the right and y-values increase to the top.)
+ * @property {string} [labelClass] The name of the CSS class defining the styles for the label.
+ * Note that style values for position, overflow, top,
+ * left, zIndex, display, marginLeft, and
+ * marginTop are ignored; these styles are for internal use only.
+ * @property {Object} [labelStyle] An object literal whose properties define specific CSS
+ * style values to be applied to the label. Style values defined here override those that may
+ * be defined in the labelClass style sheet. If this property is changed after the
+ * label has been created, all previously set styles (except those defined in the style sheet)
+ * are removed from the label before the new style values are applied.
+ * Note that style values for position, overflow, top,
+ * left, zIndex, display, marginLeft, and
+ * marginTop are ignored; these styles are for internal use only.
+ * @property {boolean} [labelInBackground] A flag indicating whether a label that overlaps its
+ * associated marker should appear in the background (i.e., in a plane below the marker).
+ * The default is false, which causes the label to appear in the foreground.
+ * @property {boolean} [labelVisible] A flag indicating whether the label is to be visible.
+ * The default is true. Note that even if labelVisible is
+ * true, the label will not be visible unless the associated marker is also
+ * visible (i.e., unless the marker's visible property is true).
+ * @property {boolean} [raiseOnDrag] A flag indicating whether the label and marker are to be
+ * raised when the marker is dragged. The default is true. If a draggable marker is
+ * being created and a version of Google Maps API earlier than V3.3 is being used, this property
+ * must be set to false.
+ * @property {boolean} [optimized] A flag indicating whether rendering is to be optimized for the
+ * marker. Important: The optimized rendering technique is not supported by MarkerWithLabel,
+ * so the value of this parameter is always forced to false.
+ * @property {string} [crossImage="http://maps.gstatic.com/intl/en_us/mapfiles/drag_cross_67_16.png"]
+ * The URL of the cross image to be displayed while dragging a marker.
+ * @property {string} [handCursor="http://maps.gstatic.com/intl/en_us/mapfiles/closedhand_8_8.cur"]
+ * The URL of the cursor to be displayed while dragging a marker.
+ */
+/**
+ * Creates a MarkerWithLabel with the options specified in {@link MarkerWithLabelOptions}.
+ * @constructor
+ * @param {MarkerWithLabelOptions} [opt_options] The optional parameters.
+ */
+function MarkerWithLabel(opt_options) {
+ opt_options = opt_options || {};
+ opt_options.labelContent = opt_options.labelContent || "";
+ opt_options.labelAnchor = opt_options.labelAnchor || new google.maps.Point(0, 0);
+ opt_options.labelClass = opt_options.labelClass || "markerLabels";
+ opt_options.labelStyle = opt_options.labelStyle || {};
+ opt_options.labelInBackground = opt_options.labelInBackground || false;
+ if (typeof opt_options.labelVisible === "undefined") {
+ opt_options.labelVisible = true;
+ }
+ if (typeof opt_options.raiseOnDrag === "undefined") {
+ opt_options.raiseOnDrag = true;
+ }
+ if (typeof opt_options.clickable === "undefined") {
+ opt_options.clickable = true;
+ }
+ if (typeof opt_options.draggable === "undefined") {
+ opt_options.draggable = false;
+ }
+ if (typeof opt_options.optimized === "undefined") {
+ opt_options.optimized = false;
+ }
+ opt_options.crossImage = opt_options.crossImage || "http" + (document.location.protocol === "https:" ? "s" : "") + "://maps.gstatic.com/intl/en_us/mapfiles/drag_cross_67_16.png";
+ opt_options.handCursor = opt_options.handCursor || "http" + (document.location.protocol === "https:" ? "s" : "") + "://maps.gstatic.com/intl/en_us/mapfiles/closedhand_8_8.cur";
+ opt_options.optimized = false; // Optimized rendering is not supported
+
+ this.label = new MarkerLabel_(this, opt_options.crossImage, opt_options.handCursor); // Bind the label to the marker
+
+ // Call the parent constructor. It calls Marker.setValues to initialize, so all
+ // the new parameters are conveniently saved and can be accessed with get/set.
+ // Marker.set triggers a property changed event (called "propertyname_changed")
+ // that the marker label listens for in order to react to state changes.
+ google.maps.Marker.apply(this, arguments);
+}
+
+inherits(MarkerWithLabel, google.maps.Marker);
+
+/**
+ * Overrides the standard Marker setMap function.
+ * @param {Map} theMap The map to which the marker is to be added.
+ * @private
+ */
+MarkerWithLabel.prototype.setMap = function (theMap) {
+
+ // Call the inherited function...
+ google.maps.Marker.prototype.setMap.apply(this, arguments);
+
+ // ... then deal with the label:
+ this.label.setMap(theMap);
+};
+
+// ==ClosureCompiler==
+// @compilation_level ADVANCED_OPTIMIZATIONS
+// @externs_url http://closure-compiler.googlecode.com/svn/trunk/contrib/externs/maps/google_maps_api_v3.js
+// @output_wrapper (function() {%output%})();
+// ==/ClosureCompiler==
+
+/**
+ * @license
+ * Copyright 2013 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * A RichMarker that allows any HTML/DOM to be added to a map and be draggable.
+ *
+ * @param {Object.MarkerClusterer begins
+ * clustering markers.
+ * @name MarkerClusterer#clusteringbegin
+ * @param {MarkerClusterer} mc The MarkerClusterer whose markers are being clustered.
+ * @event
+ */
+ google.maps.event.trigger(this, 'clusteringbegin', this);
+
+ if (typeof this.timerRefStatic !== 'undefined') {
+ clearTimeout(this.timerRefStatic);
+ delete this.timerRefStatic;
+ }
+ }
+
+ // Get our current map view bounds.
+ // Create a new bounds object so we don't affect the map.
+ //
+ // See Comments 9 & 11 on Issue 3651 relating to this workaround for a Google Maps bug:
+ if (this.getMap().getZoom() > 3) {
+ mapBounds = new google.maps.LatLngBounds(this.getMap().getBounds().getSouthWest(),
+ this.getMap().getBounds().getNorthEast());
+ } else {
+ mapBounds = new google.maps.LatLngBounds(new google.maps.LatLng(85.02070771743472, -178.48388434375), new google.maps.LatLng(-85.08136444384544, 178.00048865625));
+ }
+ var bounds = this.getExtendedBounds(mapBounds);
+
+ var iLast = Math.min(iFirst + this.batchSize_, this.markers_.length);
+
+ var _ms = this.markers_.values();
+ for (i = iFirst; i < iLast; i++) {
+ marker = _ms[i];
+ if (!marker.isAdded && this.isMarkerInBounds_(marker, bounds)) {
+ if (!this.ignoreHidden_ || (this.ignoreHidden_ && marker.getVisible())) {
+ this.addToClosestCluster_(marker);
+ }
+ }
+ }
+
+ if (iLast < this.markers_.length) {
+ this.timerRefStatic = setTimeout(function () {
+ cMarkerClusterer.createClusters_(iLast);
+ }, 0);
+ } else {
+ // custom addition by ui-gmap
+ // update icon for all clusters
+ for (i = 0; i < this.clusters_.length; i++) {
+ this.clusters_[i].updateIcon_();
+ }
+
+ delete this.timerRefStatic;
+
+ /**
+ * This event is fired when the MarkerClusterer stops
+ * clustering markers.
+ * @name MarkerClusterer#clusteringend
+ * @param {MarkerClusterer} mc The MarkerClusterer whose markers are being clustered.
+ * @event
+ */
+ google.maps.event.trigger(this, 'clusteringend', this);
+ }
+ };
+
+ /**
+ * Adds a marker to a cluster, or creates a new cluster.
+ *
+ * @param {google.maps.Marker} marker The marker to add.
+ */
+ NgMapMarkerClusterer.prototype.addToClosestCluster_ = function (marker) {
+ var i, d, cluster, center;
+ var distance = 40000; // Some large number
+ var clusterToAddTo = null;
+ for (i = 0; i < this.clusters_.length; i++) {
+ cluster = this.clusters_[i];
+ center = cluster.getCenter();
+ if (center) {
+ d = this.distanceBetweenPoints_(center, marker.getPosition());
+ if (d < distance) {
+ distance = d;
+ clusterToAddTo = cluster;
+ }
+ }
+ }
+
+ if (clusterToAddTo && clusterToAddTo.isMarkerInClusterBounds(marker)) {
+ clusterToAddTo.addMarker(marker);
+ } else {
+ cluster = new NgMapCluster(this);
+ cluster.addMarker(marker);
+ this.clusters_.push(cluster);
+ }
+ };
+
+ /**
+ * Redraws all the clusters.
+ */
+ NgMapMarkerClusterer.prototype.redraw_ = function () {
+ this.createClusters_(0);
+ };
+
+
+ /**
+ * Removes all clusters from the map. The markers are also removed from the map
+ * if opt_hide is set to true.
+ *
+ * @param {boolean} [opt_hide] Set to true to also remove the markers
+ * from the map.
+ */
+ NgMapMarkerClusterer.prototype.resetViewport_ = function (opt_hide) {
+ var i, marker;
+ // Remove all the clusters
+ for (i = 0; i < this.clusters_.length; i++) {
+ this.clusters_[i].remove();
+ }
+ this.clusters_ = [];
+
+ // Reset the markers to not be added and to be removed from the map.
+ this.markers_.each(function (marker) {
+ marker.isAdded = false;
+ if (opt_hide) {
+ marker.setMap(null);
+ }
+ });
+ };
+
+ /**
+ * Extends an object's prototype by another's.
+ *
+ * @param {Object} obj1 The object to be extended.
+ * @param {Object} obj2 The object to extend with.
+ * @return {Object} The new extended object.
+ * @ignore
+ */
+ NgMapMarkerClusterer.prototype.extend = function (obj1, obj2) {
+ return (function (object) {
+ var property;
+ for (property in object.prototype) {
+ if (property !== 'constructor')
+ this.prototype[property] = object.prototype[property];
+ }
+ return this;
+ }).apply(obj1, [obj2]);
+ };
+ ////////////////////////////////////////////////////////////////////////////////
+ /*
+ Other overrides relevant to MarkerClusterPlus
+ */
+ ////////////////////////////////////////////////////////////////////////////////
+ /**
+ * Positions and shows the icon.
+ */
+ ClusterIcon.prototype.show = function () {
+ if (this.div_) {
+ var img = "";
+ // NOTE: values must be specified in px units
+ var bp = this.backgroundPosition_.split(" ");
+ var spriteH = parseInt(bp[0].trim(), 10);
+ var spriteV = parseInt(bp[1].trim(), 10);
+ var pos = this.getPosFromLatLng_(this.center_);
+ this.div_.style.cssText = this.createCss(pos);
+ img = "";
+ this.div_.innerHTML = img + "
\";\n }\n return img;\n };\n\n return uiGmapInfoBox;\n\n })(window.InfoBox);\n window.uiGmapInfoBox = uiGmapInfoBox;\n }\n if (window.MarkerLabel_) {\n return window.MarkerLabel_.prototype.setContent = function() {\n var content;\n content = this.marker_.get('labelContent');\n if (!content || _.isEqual(this.oldContent, content)) {\n return;\n }\n if (typeof (content != null ? content.nodeType : void 0) === 'undefined') {\n this.labelDiv_.innerHTML = content;\n this.eventDiv_.innerHTML = this.labelDiv_.innerHTML;\n this.oldContent = content;\n } else {\n this.labelDiv_.innerHTML = '';\n this.labelDiv_.appendChild(content);\n content = content.cloneNode(true);\n this.labelDiv_.innerHTML = '';\n this.eventDiv_.appendChild(content);\n this.oldContent = content;\n }\n };\n }\n })\n };\n });\n\n}).call(this);\n","\n/*global _:true, angular:true */\n\n(function() {\n angular.module('uiGmapgoogle-maps.extensions').service('uiGmapLodash', function() {\n var baseGet, baseToString, fixLodash, get, reEscapeChar, rePropName, toObject, toPath;\n rePropName = /[^.[\\]]+|\\[(?:(-?\\d+(?:\\.\\d+)?)|([\"'])((?:(?!\\2)[^\\n\\\\]|\\\\.)*?)\\2)\\]/g;\n reEscapeChar = /\\\\(\\\\)?/g;\n\n /*\n For Lodash 4 compatibility (some aliases are removed)\n */\n fixLodash = function(arg) {\n var isProto, missingName, swapName;\n missingName = arg.missingName, swapName = arg.swapName, isProto = arg.isProto;\n if (_[missingName] == null) {\n _[missingName] = _[swapName];\n if (isProto) {\n return _.prototype[missingName] = _[swapName];\n }\n }\n };\n [\n {\n missingName: 'contains',\n swapName: 'includes',\n isProto: true\n }, {\n missingName: 'includes',\n swapName: 'contains',\n isProto: true\n }, {\n missingName: 'object',\n swapName: 'zipObject'\n }, {\n missingName: 'zipObject',\n swapName: 'object'\n }, {\n missingName: 'all',\n swapName: 'every'\n }, {\n missingName: 'every',\n swapName: 'all'\n }, {\n missingName: 'any',\n swapName: 'some'\n }, {\n missingName: 'some',\n swapName: 'any'\n }, {\n missingName: 'first',\n swapName: 'head'\n }, {\n missingName: 'head',\n swapName: 'first'\n }\n ].forEach(function(toMonkeyPatch) {\n return fixLodash(toMonkeyPatch);\n });\n if (_.get == null) {\n\n /**\n * Converts `value` to an object if it's not one.\n *\n * @private\n * @param {*} value The value to process.\n * @returns {Object} Returns the object.\n */\n toObject = function(value) {\n if (_.isObject(value)) {\n return value;\n } else {\n return Object(value);\n }\n };\n\n /**\n * Converts `value` to a string if it's not one. An empty string is returned\n * for `null` or `undefined` values.\n *\n * @private\n * @param {*} value The value to process.\n * @returns {string} Returns the string.\n */\n baseToString = function(value) {\n if (value === null) {\n return '';\n } else {\n return value + '';\n }\n };\n\n /**\n * Converts `value` to property path array if it's not one.\n *\n * @private\n * @param {*} value The value to process.\n * @returns {Array} Returns the property path array.\n */\n toPath = function(value) {\n var result;\n if (_.isArray(value)) {\n return value;\n }\n result = [];\n baseToString(value).replace(rePropName, function(match, number, quote, string) {\n result.push(quote ? string.replace(reEscapeChar, '$1') : number || match);\n });\n return result;\n };\n\n /**\n * The base implementation of `get` without support for string paths\n * and default values.\n *\n * @private\n * @param {Object} object The object to query.\n * @param {Array} path The path of the property to get.\n * @param {string} [pathKey] The key representation of path.\n * @returns {*} Returns the resolved value.\n */\n baseGet = function(object, path, pathKey) {\n var index, length;\n if (object === null) {\n return;\n }\n if (pathKey !== void 0 && pathKey in toObject(object)) {\n path = [pathKey];\n }\n index = 0;\n length = path.length;\n while (!_.isUndefined(object) && index < length) {\n object = object[path[index++]];\n }\n if (index && index === length) {\n return object;\n } else {\n return void 0;\n }\n };\n\n /**\n * Gets the property value at `path` of `object`. If the resolved value is\n * `undefined` the `defaultValue` is used in its place.\n *\n * @static\n * @memberOf _\n * @category Object\n * @param {Object} object The object to query.\n * @param {Array|string} path The path of the property to get.\n * @param {*} [defaultValue] The value returned if the resolved value is `undefined`.\n * @returns {*} Returns the resolved value.\n * @example\n *\n * var object = { 'a': [{ 'b': { 'c': 3 } }] };\n *\n * _.get(object, 'a[0].b.c');\n * // => 3\n *\n * _.get(object, ['a', '0', 'b', 'c']);\n * // => 3\n *\n * _.get(object, 'a.b.c', 'default');\n * // => 'default'\n */\n get = function(object, path, defaultValue) {\n var result;\n result = object === null ? void 0 : baseGet(object, toPath(path), path + '');\n if (result === void 0) {\n return defaultValue;\n } else {\n return result;\n }\n };\n _.get = get;\n }\n\n /*\n Author Nick McCready\n Intersection of Objects if the arrays have something in common each intersecting object will be returned\n in an new array.\n */\n this.intersectionObjects = function(array1, array2, comparison) {\n var res;\n if (comparison == null) {\n comparison = void 0;\n }\n res = _.map(array1, function(obj1) {\n return _.find(array2, function(obj2) {\n if (comparison != null) {\n return comparison(obj1, obj2);\n } else {\n return _.isEqual(obj1, obj2);\n }\n });\n });\n return _.filter(res, function(o) {\n return o != null;\n });\n };\n this.containsObject = _.includeObject = function(obj, target, comparison) {\n if (comparison == null) {\n comparison = void 0;\n }\n if (obj === null) {\n return false;\n }\n return _.some(obj, function(value) {\n if (comparison != null) {\n return comparison(value, target);\n } else {\n return _.isEqual(value, target);\n }\n });\n };\n this.differenceObjects = function(array1, array2, comparison) {\n if (comparison == null) {\n comparison = void 0;\n }\n return _.filter(array1, (function(_this) {\n return function(value) {\n return !_this.containsObject(array2, value, comparison);\n };\n })(this));\n };\n this.withoutObjects = this.differenceObjects;\n this.indexOfObject = function(array, item, comparison, isSorted) {\n var i, length;\n if (array == null) {\n return -1;\n }\n i = 0;\n length = array.length;\n if (isSorted) {\n if (typeof isSorted === \"number\") {\n i = (isSorted < 0 ? Math.max(0, length + isSorted) : isSorted);\n } else {\n i = _.sortedIndex(array, item);\n return (array[i] === item ? i : -1);\n }\n }\n while (i < length) {\n if (comparison != null) {\n if (comparison(array[i], item)) {\n return i;\n }\n } else {\n if (_.isEqual(array[i], item)) {\n return i;\n }\n }\n i++;\n }\n return -1;\n };\n this.isNullOrUndefined = function(thing) {\n return _.isNull(thing || _.isUndefined(thing));\n };\n return this;\n });\n\n}).call(this);\n","(function() {\n angular.module('uiGmapgoogle-maps.extensions').factory('uiGmapString', function() {\n return function(str) {\n this.contains = function(value, fromIndex) {\n return str.indexOf(value, fromIndex) !== -1;\n };\n return this;\n };\n });\n\n}).call(this);\n","\n/*global _:true,angular:true, */\n\n(function() {\n angular.module('uiGmapgoogle-maps.directives.api.utils').service('uiGmap_sync', [\n function() {\n return {\n fakePromise: function() {\n var _cb;\n _cb = void 0;\n return {\n then: function(cb) {\n return _cb = cb;\n },\n resolve: function() {\n return _cb.apply(void 0, arguments);\n }\n };\n }\n };\n }\n ]).service('uiGmap_async', [\n '$timeout', 'uiGmapPromise', 'uiGmapLogger', '$q', 'uiGmapDataStructures', 'uiGmapGmapUtil', function($timeout, uiGmapPromise, $log, $q, uiGmapDataStructures, uiGmapGmapUtil) {\n var ExposedPromise, PromiseQueueManager, SniffedPromise, _getIterateeValue, _ignoreFields, defaultChunkSize, doChunk, doSkippPromise, each, errorObject, getArrayAndKeys, isInProgress, kickPromise, logTryCatch, managePromiseQueue, map, maybeCancelPromises, promiseStatus, promiseTypes, tryCatch;\n promiseTypes = uiGmapPromise.promiseTypes;\n isInProgress = uiGmapPromise.isInProgress;\n promiseStatus = uiGmapPromise.promiseStatus;\n ExposedPromise = uiGmapPromise.ExposedPromise;\n SniffedPromise = uiGmapPromise.SniffedPromise;\n kickPromise = function(sniffedPromise, cancelCb) {\n var promise;\n promise = sniffedPromise.promise();\n promise.promiseType = sniffedPromise.promiseType;\n if (promise.$$state) {\n $log.debug(\"promiseType: \" + promise.promiseType + \", state: \" + (promiseStatus(promise.$$state.status)));\n }\n promise.cancelCb = cancelCb;\n return promise;\n };\n doSkippPromise = function(sniffedPromise, lastPromise) {\n if (sniffedPromise.promiseType === promiseTypes.create && lastPromise.promiseType !== promiseTypes[\"delete\"] && lastPromise.promiseType !== promiseTypes.init) {\n $log.debug(\"lastPromise.promiseType \" + lastPromise.promiseType + \", newPromiseType: \" + sniffedPromise.promiseType + \", SKIPPED MUST COME AFTER DELETE ONLY\");\n return true;\n }\n return false;\n };\n maybeCancelPromises = function(queue, sniffedPromise, lastPromise) {\n var first;\n if (sniffedPromise.promiseType === promiseTypes[\"delete\"] && lastPromise.promiseType !== promiseTypes[\"delete\"]) {\n if ((lastPromise.cancelCb != null) && _.isFunction(lastPromise.cancelCb) && isInProgress(lastPromise)) {\n $log.debug(\"promiseType: \" + sniffedPromise.promiseType + \", CANCELING LAST PROMISE type: \" + lastPromise.promiseType);\n lastPromise.cancelCb('cancel safe');\n first = queue.peek();\n if ((first != null) && isInProgress(first)) {\n if (first.hasOwnProperty(\"cancelCb\") && _.isFunction(first.cancelCb)) {\n $log.debug(\"promiseType: \" + first.promiseType + \", CANCELING FIRST PROMISE type: \" + first.promiseType);\n return first.cancelCb('cancel safe');\n } else {\n return $log.warn('first promise was not cancelable');\n }\n }\n }\n }\n };\n\n /*\n From a High Level:\n This is a SniffedPromiseQueueManager (looking to rename) where the queue is existingPiecesObj.existingPieces.\n This is a function and should not be considered a class.\n So it is run to manage the state (cancel, skip, link) as needed.\n Purpose:\n The whole point is to check if there is existing async work going on. If so we wait on it.\n \n arguments:\n - existingPiecesObj = Queue
\",this.div_.innerHTML=img+\"
alignBottom property is true)\n * to the map pixel corresponding to position.\n * @property {LatLng} position The geographic location at which to display the InfoBox.\n * @property {number} zIndex The CSS z-index style value for the InfoBox.\n * Note: This value overrides a zIndex setting specified in the boxStyle property.\n * @property {string} [boxClass=\"infoBox\"] The name of the CSS class defining the styles for the InfoBox container.\n * @property {Object} [boxStyle] An object literal whose properties define specific CSS\n * style values to be applied to the InfoBox. Style values defined here override those that may\n * be defined in the boxClass style sheet. If this property is changed after the\n * InfoBox has been created, all previously set styles (except those defined in the style sheet)\n * are removed from the InfoBox before the new style values are applied.\n * @property {string} closeBoxMargin The CSS margin style value for the close box.\n * The default is \"2px\" (a 2-pixel margin on all sides).\n * @property {string} closeBoxURL The URL of the image representing the close box.\n * Note: The default is the URL for Google's standard close box.\n * Set this property to \"\" if no close box is required.\n * @property {Size} infoBoxClearance Minimum offset (in pixels) from the InfoBox to the\n * map edge after an auto-pan.\n * @property {boolean} [isHidden=false] Hide the InfoBox on open.\n * [Deprecated in favor of the visible property.]\n * @property {boolean} [visible=true] Show the InfoBox on open.\n * @property {boolean} alignBottom Align the bottom left corner of the InfoBox to the position\n * location (default is false which means that the top left corner of the InfoBox is aligned).\n * @property {string} pane The pane where the InfoBox is to appear (default is \"floatPane\").\n * Set the pane to \"mapPane\" if the InfoBox is being used as a map label.\n * Valid pane names are the property names for the google.maps.MapPanes object.\n * @property {boolean} enableEventPropagation Propagate mousedown, mousemove, mouseover, mouseout,\n * mouseup, click, dblclick, touchstart, touchend, touchmove, and contextmenu events in the InfoBox\n * (default is false to mimic the behavior of a google.maps.InfoWindow). Set\n * this property to true if the InfoBox is being used as a map label.\n */\n\n/**\n * Creates an InfoBox with the options specified in {@link InfoBoxOptions}.\n * Call InfoBox.open to add the box to the map.\n * @constructor\n * @param {InfoBoxOptions} [opt_opts]\n */\nfunction InfoBox(opt_opts) {\n\n opt_opts = opt_opts || {};\n\n google.maps.OverlayView.apply(this, arguments);\n\n // Standard options (in common with google.maps.InfoWindow):\n //\n this.content_ = opt_opts.content || \"\";\n this.disableAutoPan_ = opt_opts.disableAutoPan || false;\n this.maxWidth_ = opt_opts.maxWidth || 0;\n this.pixelOffset_ = opt_opts.pixelOffset || new google.maps.Size(0, 0);\n this.position_ = opt_opts.position || new google.maps.LatLng(0, 0);\n this.zIndex_ = opt_opts.zIndex || null;\n\n // Additional options (unique to InfoBox):\n //\n this.boxClass_ = opt_opts.boxClass || \"infoBox\";\n this.boxStyle_ = opt_opts.boxStyle || {};\n this.closeBoxMargin_ = opt_opts.closeBoxMargin || \"2px\";\n this.closeBoxURL_ = opt_opts.closeBoxURL || \"http://www.google.com/intl/en_us/mapfiles/close.gif\";\n if (opt_opts.closeBoxURL === \"\") {\n this.closeBoxURL_ = \"\";\n }\n this.infoBoxClearance_ = opt_opts.infoBoxClearance || new google.maps.Size(1, 1);\n\n if (typeof opt_opts.visible === \"undefined\") {\n if (typeof opt_opts.isHidden === \"undefined\") {\n opt_opts.visible = true;\n } else {\n opt_opts.visible = !opt_opts.isHidden;\n }\n }\n this.isHidden_ = !opt_opts.visible;\n\n this.alignBottom_ = opt_opts.alignBottom || false;\n this.pane_ = opt_opts.pane || \"floatPane\";\n this.enableEventPropagation_ = opt_opts.enableEventPropagation || false;\n\n this.div_ = null;\n this.closeListener_ = null;\n this.moveListener_ = null;\n this.contextListener_ = null;\n this.eventListeners_ = null;\n this.fixedWidthSet_ = null;\n}\n\n/* InfoBox extends OverlayView in the Google Maps API v3.\n */\nInfoBox.prototype = new google.maps.OverlayView();\n\n/**\n * Creates the DIV representing the InfoBox.\n * @private\n */\nInfoBox.prototype.createInfoBoxDiv_ = function () {\n\n var i;\n var events;\n var bw;\n var me = this;\n\n // This handler prevents an event in the InfoBox from being passed on to the map.\n //\n var cancelHandler = function (e) {\n e.cancelBubble = true;\n if (e.stopPropagation) {\n e.stopPropagation();\n }\n };\n\n // This handler ignores the current event in the InfoBox and conditionally prevents\n // the event from being passed on to the map. It is used for the contextmenu event.\n //\n var ignoreHandler = function (e) {\n\n e.returnValue = false;\n\n if (e.preventDefault) {\n\n e.preventDefault();\n }\n\n if (!me.enableEventPropagation_) {\n\n cancelHandler(e);\n }\n };\n\n if (!this.div_) {\n\n this.div_ = document.createElement(\"div\");\n\n this.setBoxStyle_();\n\n if (typeof this.content_.nodeType === \"undefined\") {\n this.div_.innerHTML = this.getCloseBoxImg_() + this.content_;\n } else {\n this.div_.innerHTML = this.getCloseBoxImg_();\n this.div_.appendChild(this.content_);\n }\n\n // Add the InfoBox DIV to the DOM\n this.getPanes()[this.pane_].appendChild(this.div_);\n\n this.addClickHandler_();\n\n if (this.div_.style.width) {\n\n this.fixedWidthSet_ = true;\n\n } else {\n\n if (this.maxWidth_ !== 0 && this.div_.offsetWidth > this.maxWidth_) {\n\n this.div_.style.width = this.maxWidth_;\n this.div_.style.overflow = \"auto\";\n this.fixedWidthSet_ = true;\n\n } else { // The following code is needed to overcome problems with MSIE\n\n bw = this.getBoxWidths_();\n\n this.div_.style.width = (this.div_.offsetWidth - bw.left - bw.right) + \"px\";\n this.fixedWidthSet_ = false;\n }\n }\n\n this.panBox_(this.disableAutoPan_);\n\n if (!this.enableEventPropagation_) {\n\n this.eventListeners_ = [];\n\n // Cancel event propagation.\n //\n // Note: mousemove not included (to resolve Issue 152)\n events = [\"mousedown\", \"mouseover\", \"mouseout\", \"mouseup\",\n \"click\", \"dblclick\", \"touchstart\", \"touchend\", \"touchmove\"];\n\n for (i = 0; i < events.length; i++) {\n\n this.eventListeners_.push(google.maps.event.addDomListener(this.div_, events[i], cancelHandler));\n }\n\n // Workaround for Google bug that causes the cursor to change to a pointer\n // when the mouse moves over a marker underneath InfoBox.\n this.eventListeners_.push(google.maps.event.addDomListener(this.div_, \"mouseover\", function (e) {\n this.style.cursor = \"default\";\n }));\n }\n\n this.contextListener_ = google.maps.event.addDomListener(this.div_, \"contextmenu\", ignoreHandler);\n\n /**\n * This event is fired when the DIV containing the InfoBox's content is attached to the DOM.\n * @name InfoBox#domready\n * @event\n */\n google.maps.event.trigger(this, \"domready\");\n }\n};\n\n/**\n * Returns the HTML tag for the close box.\n * @private\n */\nInfoBox.prototype.getCloseBoxImg_ = function () {\n\n var img = \"\";\n\n if (this.closeBoxURL_ !== \"\") {\n\n img = \"
\";\n }\n\n return img;\n};\n\n/**\n * Adds the click handler to the InfoBox close box.\n * @private\n */\nInfoBox.prototype.addClickHandler_ = function () {\n\n var closeBox;\n\n if (this.closeBoxURL_ !== \"\") {\n\n closeBox = this.div_.firstChild;\n this.closeListener_ = google.maps.event.addDomListener(closeBox, \"click\", this.getCloseClickHandler_());\n\n } else {\n\n this.closeListener_ = null;\n }\n};\n\n/**\n * Returns the function to call when the user clicks the close box of an InfoBox.\n * @private\n */\nInfoBox.prototype.getCloseClickHandler_ = function () {\n\n var me = this;\n\n return function (e) {\n\n // 1.0.3 fix: Always prevent propagation of a close box click to the map:\n e.cancelBubble = true;\n\n if (e.stopPropagation) {\n\n e.stopPropagation();\n }\n\n /**\n * This event is fired when the InfoBox's close box is clicked.\n * @name InfoBox#closeclick\n * @event\n */\n google.maps.event.trigger(me, \"closeclick\");\n\n me.close();\n };\n};\n\n/**\n * Pans the map so that the InfoBox appears entirely within the map's visible area.\n * @private\n */\nInfoBox.prototype.panBox_ = function (disablePan) {\n\n var map;\n var bounds;\n var xOffset = 0, yOffset = 0;\n\n if (!disablePan) {\n\n map = this.getMap();\n\n if (map instanceof google.maps.Map) { // Only pan if attached to map, not panorama\n\n if (!map.getBounds().contains(this.position_)) {\n // Marker not in visible area of map, so set center\n // of map to the marker position first.\n map.setCenter(this.position_);\n }\n\n bounds = map.getBounds();\n\n var mapDiv = map.getDiv();\n var mapWidth = mapDiv.offsetWidth;\n var mapHeight = mapDiv.offsetHeight;\n var iwOffsetX = this.pixelOffset_.width;\n var iwOffsetY = this.pixelOffset_.height;\n var iwWidth = this.div_.offsetWidth;\n var iwHeight = this.div_.offsetHeight;\n var padX = this.infoBoxClearance_.width;\n var padY = this.infoBoxClearance_.height;\n var pixPosition = this.getProjection().fromLatLngToContainerPixel(this.position_);\n\n if (pixPosition.x < (-iwOffsetX + padX)) {\n xOffset = pixPosition.x + iwOffsetX - padX;\n } else if ((pixPosition.x + iwWidth + iwOffsetX + padX) > mapWidth) {\n xOffset = pixPosition.x + iwWidth + iwOffsetX + padX - mapWidth;\n }\n if (this.alignBottom_) {\n if (pixPosition.y < (-iwOffsetY + padY + iwHeight)) {\n yOffset = pixPosition.y + iwOffsetY - padY - iwHeight;\n } else if ((pixPosition.y + iwOffsetY + padY) > mapHeight) {\n yOffset = pixPosition.y + iwOffsetY + padY - mapHeight;\n }\n } else {\n if (pixPosition.y < (-iwOffsetY + padY)) {\n yOffset = pixPosition.y + iwOffsetY - padY;\n } else if ((pixPosition.y + iwHeight + iwOffsetY + padY) > mapHeight) {\n yOffset = pixPosition.y + iwHeight + iwOffsetY + padY - mapHeight;\n }\n }\n\n if (!(xOffset === 0 && yOffset === 0)) {\n\n // Move the map to the shifted center.\n //\n var c = map.getCenter();\n map.panBy(xOffset, yOffset);\n }\n }\n }\n};\n\n/**\n * Sets the style of the InfoBox by setting the style sheet and applying\n * other specific styles requested.\n * @private\n */\nInfoBox.prototype.setBoxStyle_ = function () {\n\n var i, boxStyle;\n\n if (this.div_) {\n\n // Apply style values from the style sheet defined in the boxClass parameter:\n this.div_.className = this.boxClass_;\n\n // Clear existing inline style values:\n this.div_.style.cssText = \"\";\n\n // Apply style values defined in the boxStyle parameter:\n boxStyle = this.boxStyle_;\n for (i in boxStyle) {\n\n if (boxStyle.hasOwnProperty(i)) {\n\n this.div_.style[i] = boxStyle[i];\n }\n }\n\n // Fix for iOS disappearing InfoBox problem.\n // See http://stackoverflow.com/questions/9229535/google-maps-markers-disappear-at-certain-zoom-level-only-on-iphone-ipad\n this.div_.style.WebkitTransform = \"translateZ(0)\";\n\n // Fix up opacity style for benefit of MSIE:\n //\n if (typeof this.div_.style.opacity !== \"undefined\" && this.div_.style.opacity !== \"\") {\n // See http://www.quirksmode.org/css/opacity.html\n this.div_.style.MsFilter = \"\\\"progid:DXImageTransform.Microsoft.Alpha(Opacity=\" + (this.div_.style.opacity * 100) + \")\\\"\";\n this.div_.style.filter = \"alpha(opacity=\" + (this.div_.style.opacity * 100) + \")\";\n }\n\n // Apply required styles:\n //\n this.div_.style.position = \"absolute\";\n this.div_.style.visibility = 'hidden';\n if (this.zIndex_ !== null) {\n\n this.div_.style.zIndex = this.zIndex_;\n }\n }\n};\n\n/**\n * Get the widths of the borders of the InfoBox.\n * @private\n * @return {Object} widths object (top, bottom left, right)\n */\nInfoBox.prototype.getBoxWidths_ = function () {\n\n var computedStyle;\n var bw = {top: 0, bottom: 0, left: 0, right: 0};\n var box = this.div_;\n\n if (document.defaultView && document.defaultView.getComputedStyle) {\n\n computedStyle = box.ownerDocument.defaultView.getComputedStyle(box, \"\");\n\n if (computedStyle) {\n\n // The computed styles are always in pixel units (good!)\n bw.top = parseInt(computedStyle.borderTopWidth, 10) || 0;\n bw.bottom = parseInt(computedStyle.borderBottomWidth, 10) || 0;\n bw.left = parseInt(computedStyle.borderLeftWidth, 10) || 0;\n bw.right = parseInt(computedStyle.borderRightWidth, 10) || 0;\n }\n\n } else if (document.documentElement.currentStyle) { // MSIE\n\n if (box.currentStyle) {\n\n // The current styles may not be in pixel units, but assume they are (bad!)\n bw.top = parseInt(box.currentStyle.borderTopWidth, 10) || 0;\n bw.bottom = parseInt(box.currentStyle.borderBottomWidth, 10) || 0;\n bw.left = parseInt(box.currentStyle.borderLeftWidth, 10) || 0;\n bw.right = parseInt(box.currentStyle.borderRightWidth, 10) || 0;\n }\n }\n\n return bw;\n};\n\n/**\n * Invoked when close is called. Do not call it directly.\n */\nInfoBox.prototype.onRemove = function () {\n\n if (this.div_) {\n\n this.div_.parentNode.removeChild(this.div_);\n this.div_ = null;\n }\n};\n\n/**\n * Draws the InfoBox based on the current map projection and zoom level.\n */\nInfoBox.prototype.draw = function () {\n\n this.createInfoBoxDiv_();\n\n var pixPosition = this.getProjection().fromLatLngToDivPixel(this.position_);\n\n this.div_.style.left = (pixPosition.x + this.pixelOffset_.width) + \"px\";\n\n if (this.alignBottom_) {\n this.div_.style.bottom = -(pixPosition.y + this.pixelOffset_.height) + \"px\";\n } else {\n this.div_.style.top = (pixPosition.y + this.pixelOffset_.height) + \"px\";\n }\n\n if (this.isHidden_) {\n\n this.div_.style.visibility = \"hidden\";\n\n } else {\n\n this.div_.style.visibility = \"visible\";\n }\n};\n\n/**\n * Sets the options for the InfoBox. Note that changes to the maxWidth,\n * closeBoxMargin, closeBoxURL, and enableEventPropagation\n * properties have no affect until the current InfoBox is closed and a new one\n * is opened.\n * @param {InfoBoxOptions} opt_opts\n */\nInfoBox.prototype.setOptions = function (opt_opts) {\n if (typeof opt_opts.boxClass !== \"undefined\") { // Must be first\n\n this.boxClass_ = opt_opts.boxClass;\n this.setBoxStyle_();\n }\n if (typeof opt_opts.boxStyle !== \"undefined\") { // Must be second\n\n this.boxStyle_ = opt_opts.boxStyle;\n this.setBoxStyle_();\n }\n if (typeof opt_opts.content !== \"undefined\") {\n\n this.setContent(opt_opts.content);\n }\n if (typeof opt_opts.disableAutoPan !== \"undefined\") {\n\n this.disableAutoPan_ = opt_opts.disableAutoPan;\n }\n if (typeof opt_opts.maxWidth !== \"undefined\") {\n\n this.maxWidth_ = opt_opts.maxWidth;\n }\n if (typeof opt_opts.pixelOffset !== \"undefined\") {\n\n this.pixelOffset_ = opt_opts.pixelOffset;\n }\n if (typeof opt_opts.alignBottom !== \"undefined\") {\n\n this.alignBottom_ = opt_opts.alignBottom;\n }\n if (typeof opt_opts.position !== \"undefined\") {\n\n this.setPosition(opt_opts.position);\n }\n if (typeof opt_opts.zIndex !== \"undefined\") {\n\n this.setZIndex(opt_opts.zIndex);\n }\n if (typeof opt_opts.closeBoxMargin !== \"undefined\") {\n\n this.closeBoxMargin_ = opt_opts.closeBoxMargin;\n }\n if (typeof opt_opts.closeBoxURL !== \"undefined\") {\n\n this.closeBoxURL_ = opt_opts.closeBoxURL;\n }\n if (typeof opt_opts.infoBoxClearance !== \"undefined\") {\n\n this.infoBoxClearance_ = opt_opts.infoBoxClearance;\n }\n if (typeof opt_opts.isHidden !== \"undefined\") {\n\n this.isHidden_ = opt_opts.isHidden;\n }\n if (typeof opt_opts.visible !== \"undefined\") {\n\n this.isHidden_ = !opt_opts.visible;\n }\n if (typeof opt_opts.enableEventPropagation !== \"undefined\") {\n\n this.enableEventPropagation_ = opt_opts.enableEventPropagation;\n }\n\n if (this.div_) {\n\n this.draw();\n }\n};\n\n/**\n * Sets the content of the InfoBox.\n * The content can be plain text or an HTML DOM node.\n * @param {string|Node} content\n */\nInfoBox.prototype.setContent = function (content) {\n this.content_ = content;\n\n if (this.div_) {\n\n if (this.closeListener_) {\n\n google.maps.event.removeListener(this.closeListener_);\n this.closeListener_ = null;\n }\n\n // Odd code required to make things work with MSIE.\n //\n if (!this.fixedWidthSet_) {\n\n this.div_.style.width = \"\";\n }\n\n if (typeof content.nodeType === \"undefined\") {\n this.div_.innerHTML = this.getCloseBoxImg_() + content;\n } else {\n this.div_.innerHTML = this.getCloseBoxImg_();\n this.div_.appendChild(content);\n }\n\n // Perverse code required to make things work with MSIE.\n // (Ensures the close box does, in fact, float to the right.)\n //\n if (!this.fixedWidthSet_) {\n this.div_.style.width = this.div_.offsetWidth + \"px\";\n if (typeof content.nodeType === \"undefined\") {\n this.div_.innerHTML = this.getCloseBoxImg_() + content;\n } else {\n this.div_.innerHTML = this.getCloseBoxImg_();\n this.div_.appendChild(content);\n }\n }\n\n this.addClickHandler_();\n }\n\n /**\n * This event is fired when the content of the InfoBox changes.\n * @name InfoBox#content_changed\n * @event\n */\n google.maps.event.trigger(this, \"content_changed\");\n};\n\n/**\n * Sets the geographic location of the InfoBox.\n * @param {LatLng} latlng\n */\nInfoBox.prototype.setPosition = function (latlng) {\n\n this.position_ = latlng;\n\n if (this.div_) {\n\n this.draw();\n }\n\n /**\n * This event is fired when the position of the InfoBox changes.\n * @name InfoBox#position_changed\n * @event\n */\n google.maps.event.trigger(this, \"position_changed\");\n};\n\n/**\n * Sets the zIndex style for the InfoBox.\n * @param {number} index\n */\nInfoBox.prototype.setZIndex = function (index) {\n\n this.zIndex_ = index;\n\n if (this.div_) {\n\n this.div_.style.zIndex = index;\n }\n\n /**\n * This event is fired when the zIndex of the InfoBox changes.\n * @name InfoBox#zindex_changed\n * @event\n */\n google.maps.event.trigger(this, \"zindex_changed\");\n};\n\n/**\n * Sets the visibility of the InfoBox.\n * @param {boolean} isVisible\n */\nInfoBox.prototype.setVisible = function (isVisible) {\n\n this.isHidden_ = !isVisible;\n if (this.div_) {\n this.div_.style.visibility = (this.isHidden_ ? \"hidden\" : \"visible\");\n }\n};\n\n/**\n * Returns the content of the InfoBox.\n * @returns {string}\n */\nInfoBox.prototype.getContent = function () {\n\n return this.content_;\n};\n\n/**\n * Returns the geographic location of the InfoBox.\n * @returns {LatLng}\n */\nInfoBox.prototype.getPosition = function () {\n\n return this.position_;\n};\n\n/**\n * Returns the zIndex for the InfoBox.\n * @returns {number}\n */\nInfoBox.prototype.getZIndex = function () {\n\n return this.zIndex_;\n};\n\n/**\n * Returns a flag indicating whether the InfoBox is visible.\n * @returns {boolean}\n */\nInfoBox.prototype.getVisible = function () {\n\n var isVisible;\n\n if ((typeof this.getMap() === \"undefined\") || (this.getMap() === null)) {\n isVisible = false;\n } else {\n isVisible = !this.isHidden_;\n }\n return isVisible;\n};\n\n/**\n * Shows the InfoBox. [Deprecated; use setVisible instead.]\n */\nInfoBox.prototype.show = function () {\n\n this.isHidden_ = false;\n if (this.div_) {\n this.div_.style.visibility = \"visible\";\n }\n};\n\n/**\n * Hides the InfoBox. [Deprecated; use setVisible instead.]\n */\nInfoBox.prototype.hide = function () {\n\n this.isHidden_ = true;\n if (this.div_) {\n this.div_.style.visibility = \"hidden\";\n }\n};\n\n/**\n * Adds the InfoBox to the specified map or Street View panorama. If anchor\n * (usually a google.maps.Marker) is specified, the position\n * of the InfoBox is set to the position of the anchor. If the\n * anchor is dragged to a new location, the InfoBox moves as well.\n * @param {Map|StreetViewPanorama} map\n * @param {MVCObject} [anchor]\n */\nInfoBox.prototype.open = function (map, anchor) {\n\n var me = this;\n\n if (anchor) {\n\n this.position_ = anchor.getPosition();\n this.moveListener_ = google.maps.event.addListener(anchor, \"position_changed\", function () {\n me.setPosition(this.getPosition());\n });\n }\n\n this.setMap(map);\n\n if (this.div_) {\n\n this.panBox_();\n }\n};\n\n/**\n * Removes the InfoBox from the map.\n */\nInfoBox.prototype.close = function () {\n\n var i;\n\n if (this.closeListener_) {\n\n google.maps.event.removeListener(this.closeListener_);\n this.closeListener_ = null;\n }\n\n if (this.eventListeners_) {\n\n for (i = 0; i < this.eventListeners_.length; i++) {\n\n google.maps.event.removeListener(this.eventListeners_[i]);\n }\n this.eventListeners_ = null;\n }\n\n if (this.moveListener_) {\n\n google.maps.event.removeListener(this.moveListener_);\n this.moveListener_ = null;\n }\n\n if (this.contextListener_) {\n\n google.maps.event.removeListener(this.contextListener_);\n this.contextListener_ = null;\n }\n\n this.setMap(null);\n};\n\n/**\n * google-maps-utility-library-v3-keydragzoom\n *\n * @version: 2.0.9\n * @author: Nianwei Liu [nianwei at gmail dot com] & Gary Little [gary at luxcentral dot com]\n * @contributors: undefined\n * @date: Fri May 13 2016 13:45:18 GMT-0400 (EDT)\n * @license: Apache License 2.0\n */\n/**\n * @fileoverview This library adds a drag zoom capability to a V3 Google map.\n * When drag zoom is enabled, holding down a designated hot key
(shift | ctrl | alt)\n * while dragging a box around an area of interest will zoom the map in to that area when\n * the mouse button is released. Optionally, a visual control can also be supplied for turning\n * a drag zoom operation on and off.\n * Only one line of code is needed: google.maps.Map.enableKeyDragZoom();\n *
NL: 2009-11-02: added a temp fix for -moz-transform for FF3.5.x using code from Paul Kulchenko (http://notebook.kulchenko.com/maps/gridmove).\n *
NL: 2010-02-02: added a fix for IE flickering on divs onmousemove, caused by scroll value when get mouse position.\n *
GL: 2010-06-15: added a visual control option.\n */\n(function () {\n /*jslint browser:true */\n /*global window,google */\n /* Utility functions use \"var funName=function()\" syntax to allow use of the */\n /* Dean Edwards Packer compression tool (with Shrink variables, without Base62 encode). */\n\n /**\n * Converts \"thin\", \"medium\", and \"thick\" to pixel widths\n * in an MSIE environment. Not called for other browsers\n * because getComputedStyle() returns pixel widths automatically.\n * @param {string} widthValue The value of the border width parameter.\n */\n var toPixels = function (widthValue) {\n var px;\n switch (widthValue) {\n case \"thin\":\n px = \"2px\";\n break;\n case \"medium\":\n px = \"4px\";\n break;\n case \"thick\":\n px = \"6px\";\n break;\n default:\n px = widthValue;\n }\n return px;\n };\n /**\n * Get the widths of the borders of an HTML element.\n *\n * @param {Node} h The HTML element.\n * @return {Object} The width object {top, bottom left, right}.\n */\n var getBorderWidths = function (h) {\n var computedStyle;\n var bw = {};\n if (document.defaultView && document.defaultView.getComputedStyle) {\n computedStyle = h.ownerDocument.defaultView.getComputedStyle(h, \"\");\n if (computedStyle) {\n // The computed styles are always in pixel units (good!)\n bw.top = parseInt(computedStyle.borderTopWidth, 10) || 0;\n bw.bottom = parseInt(computedStyle.borderBottomWidth, 10) || 0;\n bw.left = parseInt(computedStyle.borderLeftWidth, 10) || 0;\n bw.right = parseInt(computedStyle.borderRightWidth, 10) || 0;\n return bw;\n }\n } else if (document.documentElement.currentStyle) { // MSIE\n if (h.currentStyle) {\n // The current styles may not be in pixel units so try to convert (bad!)\n bw.top = parseInt(toPixels(h.currentStyle.borderTopWidth), 10) || 0;\n bw.bottom = parseInt(toPixels(h.currentStyle.borderBottomWidth), 10) || 0;\n bw.left = parseInt(toPixels(h.currentStyle.borderLeftWidth), 10) || 0;\n bw.right = parseInt(toPixels(h.currentStyle.borderRightWidth), 10) || 0;\n return bw;\n }\n }\n // Shouldn't get this far for any modern browser\n bw.top = parseInt(h.style[\"border-top-width\"], 10) || 0;\n bw.bottom = parseInt(h.style[\"border-bottom-width\"], 10) || 0;\n bw.left = parseInt(h.style[\"border-left-width\"], 10) || 0;\n bw.right = parseInt(h.style[\"border-right-width\"], 10) || 0;\n return bw;\n };\n\n // Page scroll values for use by getMousePosition. To prevent flickering on MSIE\n // they are calculated only when the document actually scrolls, not every time the\n // mouse moves (as they would be if they were calculated inside getMousePosition).\n var scroll = {\n x: 0,\n y: 0\n };\n var getScrollValue = function (e) {\n scroll.x = (typeof document.documentElement.scrollLeft !== \"undefined\" ? document.documentElement.scrollLeft : document.body.scrollLeft);\n scroll.y = (typeof document.documentElement.scrollTop !== \"undefined\" ? document.documentElement.scrollTop : document.body.scrollTop);\n };\n getScrollValue();\n\n /**\n * Get the position of the mouse relative to the document.\n * @param {Event} e The mouse event.\n * @return {Object} The position object {left, top}.\n */\n var getMousePosition = function (e) {\n var posX = 0, posY = 0;\n e = e || window.event;\n if (typeof e.pageX !== \"undefined\") {\n posX = e.pageX;\n posY = e.pageY;\n } else if (typeof e.clientX !== \"undefined\") { // MSIE\n posX = e.clientX + scroll.x;\n posY = e.clientY + scroll.y;\n }\n return {\n left: posX,\n top: posY\n };\n };\n /**\n * Get the position of an HTML element relative to the document.\n * @param {Node} h The HTML element.\n * @return {Object} The position object {left, top}.\n */\n var getElementPosition = function (h) {\n var posX = h.offsetLeft;\n var posY = h.offsetTop;\n var parent = h.offsetParent;\n // Add offsets for all ancestors in the hierarchy\n while (parent !== null) {\n // Adjust for scrolling elements which may affect the map position.\n //\n // See http://www.howtocreate.co.uk/tutorials/javascript/browserspecific\n //\n // \"...make sure that every element [on a Web page] with an overflow\n // of anything other than visible also has a position style set to\n // something other than the default static...\"\n if (parent !== document.body && parent !== document.documentElement) {\n posX -= parent.scrollLeft;\n posY -= parent.scrollTop;\n }\n // See http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/4cb86c0c1037a5e5\n // Example: http://notebook.kulchenko.com/maps/gridmove\n var m = parent;\n // This is the \"normal\" way to get offset information:\n var moffx = m.offsetLeft;\n var moffy = m.offsetTop;\n // This covers those cases where a transform is used:\n if (!moffx && !moffy && window.getComputedStyle) {\n var matrix = document.defaultView.getComputedStyle(m, null).MozTransform ||\n document.defaultView.getComputedStyle(m, null).WebkitTransform;\n if (matrix) {\n if (typeof matrix === \"string\") {\n var parms = matrix.split(\",\");\n moffx += parseInt(parms[4], 10) || 0;\n moffy += parseInt(parms[5], 10) || 0;\n }\n }\n }\n posX += moffx;\n posY += moffy;\n parent = parent.offsetParent;\n }\n return {\n left: posX,\n top: posY\n };\n };\n /**\n * Set the properties of an object to those from another object.\n * @param {Object} obj The target object.\n * @param {Object} vals The source object.\n */\n var setVals = function (obj, vals) {\n if (obj && vals) {\n for (var x in vals) {\n if (vals.hasOwnProperty(x)) {\n obj[x] = vals[x];\n }\n }\n }\n return obj;\n };\n /**\n * Set the opacity. If op is not passed in, this function just performs an MSIE fix.\n * @param {Node} h The HTML element.\n * @param {number} op The opacity value (0-1).\n */\n var setOpacity = function (h, op) {\n if (typeof op !== \"undefined\") {\n h.style.opacity = op;\n }\n if (typeof h.style.opacity !== \"undefined\" && h.style.opacity !== \"\") {\n h.style.filter = \"alpha(opacity=\" + (h.style.opacity * 100) + \")\";\n }\n };\n /**\n * @name KeyDragZoomOptions\n * @class This class represents the optional parameter passed into google.maps.Map.enableKeyDragZoom.\n * @property {string} [key=\"shift\"] The hot key to hold down to activate a drag zoom, shift | ctrl | alt.\n * NOTE: Do not use Ctrl as the hot key with Google Maps JavaScript API V3 since, unlike with V2,\n * it causes a context menu to appear when running on the Macintosh. Also note that the\n * alt hot key refers to the Option key on a Macintosh.\n * @property {Object} [boxStyle={border: \"4px solid #736AFF\"}]\n * An object literal defining the CSS styles of the zoom box.\n * Border widths must be specified in pixel units (or as thin, medium, or thick).\n * @property {Object} [veilStyle={backgroundColor: \"gray\", opacity: 0.25, cursor: \"crosshair\"}]\n * An object literal defining the CSS styles of the veil pane which covers the map when a drag\n * zoom is activated. The previous name for this property was paneStyle but the use\n * of this name is now deprecated.\n * @property {boolean} [noZoom=false] A flag indicating whether to disable zooming after an area is\n * selected. Set this to true to allow KeyDragZoom to be used as a simple area\n * selection tool.\n * @property {boolean} [visualEnabled=false] A flag indicating whether a visual control is to be used.\n * @property {string} [visualClass=\"\"] The name of the CSS class defining the styles for the visual\n * control. To prevent the visual control from being printed, set this property to the name of\n * a class, defined inside a @media print rule, which sets the CSS\n * display style to none.\n * @property {ControlPosition} [visualPosition=google.maps.ControlPosition.LEFT_TOP]\n * The position of the visual control.\n * @property {Size} [visualPositionOffset=google.maps.Size(35, 0)] The width and height values\n * provided by this property are the offsets (in pixels) from the location at which the control\n * would normally be drawn to the desired drawing location.\n * @property {number} [visualPositionIndex=null] The index of the visual control.\n * The index is for controlling the placement of the control relative to other controls at the\n * position given by visualPosition; controls with a lower index are placed first.\n * Use a negative value to place the control before any default controls. No index is\n * generally required.\n * @property {String} [visualSprite=\"http://maps.gstatic.com/mapfiles/ftr/controls/dragzoom_btn.png\"]\n * The URL of the sprite image used for showing the visual control in the on, off, and hot\n * (i.e., when the mouse is over the control) states. The three images within the sprite must\n * be the same size and arranged in on-hot-off order in a single row with no spaces between images.\n * @property {Size} [visualSize=google.maps.Size(20, 20)] The width and height values provided by\n * this property are the size (in pixels) of each of the images within visualSprite.\n * @property {Object} [visualTips={off: \"Turn on drag zoom mode\", on: \"Turn off drag zoom mode\"}]\n * An object literal defining the help tips that appear when\n * the mouse moves over the visual control. The off property is the tip to be shown\n * when the control is off and the on property is the tip to be shown when the\n * control is on.\n */\n /**\n * @name DragZoom\n * @class This class represents a drag zoom object for a map. The object is activated by holding down the hot key\n * or by turning on the visual control.\n * This object is created when google.maps.Map.enableKeyDragZoom is called; it cannot be created directly.\n * Use google.maps.Map.getDragZoomObject to gain access to this object in order to attach event listeners.\n * @param {Map} map The map to which the DragZoom object is to be attached.\n * @param {KeyDragZoomOptions} [opt_zoomOpts] The optional parameters.\n */\n function DragZoom(map, opt_zoomOpts) {\n var me = this;\n var ov = new google.maps.OverlayView();\n ov.onAdd = function () {\n me.init_(map, opt_zoomOpts);\n };\n ov.draw = function () {\n };\n ov.onRemove = function () {\n };\n ov.setMap(map);\n this.prjov_ = ov;\n }\n /**\n * Initialize the tool.\n * @param {Map} map The map to which the DragZoom object is to be attached.\n * @param {KeyDragZoomOptions} [opt_zoomOpts] The optional parameters.\n */\n DragZoom.prototype.init_ = function (map, opt_zoomOpts) {\n var i;\n var me = this;\n this.map_ = map;\n opt_zoomOpts = opt_zoomOpts || {};\n this.key_ = opt_zoomOpts.key || \"shift\";\n this.key_ = this.key_.toLowerCase();\n this.borderWidths_ = getBorderWidths(this.map_.getDiv());\n this.veilDiv_ = [];\n for (i = 0; i < 4; i++) {\n this.veilDiv_[i] = document.createElement(\"div\");\n // Prevents selection of other elements on the webpage\n // when a drag zoom operation is in progress:\n this.veilDiv_[i].onselectstart = function () {\n return false;\n };\n // Apply default style values for the veil:\n setVals(this.veilDiv_[i].style, {\n backgroundColor: \"gray\",\n opacity: 0.25,\n cursor: \"crosshair\"\n });\n // Apply style values specified in veilStyle parameter:\n setVals(this.veilDiv_[i].style, opt_zoomOpts.paneStyle); // Old option name was \"paneStyle\"\n setVals(this.veilDiv_[i].style, opt_zoomOpts.veilStyle); // New name is \"veilStyle\"\n // Apply mandatory style values:\n setVals(this.veilDiv_[i].style, {\n position: \"absolute\",\n overflow: \"hidden\",\n display: \"none\"\n });\n // Workaround for Firefox Shift-Click problem:\n if (this.key_ === \"shift\") {\n this.veilDiv_[i].style.MozUserSelect = \"none\";\n }\n setOpacity(this.veilDiv_[i]);\n // An IE fix: If the background is transparent it cannot capture mousedown\n // events, so if it is, change the background to white with 0 opacity.\n if (this.veilDiv_[i].style.backgroundColor === \"transparent\") {\n this.veilDiv_[i].style.backgroundColor = \"white\";\n setOpacity(this.veilDiv_[i], 0);\n }\n this.map_.getDiv().appendChild(this.veilDiv_[i]);\n }\n\n this.noZoom_ = opt_zoomOpts.noZoom || false;\n this.visualEnabled_ = opt_zoomOpts.visualEnabled || false;\n this.visualClass_ = opt_zoomOpts.visualClass || \"\";\n this.visualPosition_ = opt_zoomOpts.visualPosition || google.maps.ControlPosition.LEFT_TOP;\n this.visualPositionOffset_ = opt_zoomOpts.visualPositionOffset || new google.maps.Size(35, 0);\n this.visualPositionIndex_ = opt_zoomOpts.visualPositionIndex || null;\n this.visualSprite_ = opt_zoomOpts.visualSprite || \"http\" + (document.location.protocol === \"https:\" ? \"s\" : \"\") + \"://maps.gstatic.com/mapfiles/ftr/controls/dragzoom_btn.png\";\n this.visualSize_ = opt_zoomOpts.visualSize || new google.maps.Size(20, 20);\n this.visualTips_ = opt_zoomOpts.visualTips || {};\n this.visualTips_.off = this.visualTips_.off || \"Turn on drag zoom mode\";\n this.visualTips_.on = this.visualTips_.on || \"Turn off drag zoom mode\";\n\n this.boxDiv_ = document.createElement(\"div\");\n // Apply default style values for the zoom box:\n setVals(this.boxDiv_.style, {\n border: \"4px solid #736AFF\"\n });\n // Apply style values specified in boxStyle parameter:\n setVals(this.boxDiv_.style, opt_zoomOpts.boxStyle);\n // Apply mandatory style values:\n setVals(this.boxDiv_.style, {\n position: \"absolute\",\n display: \"none\"\n });\n setOpacity(this.boxDiv_);\n this.map_.getDiv().appendChild(this.boxDiv_);\n this.boxBorderWidths_ = getBorderWidths(this.boxDiv_);\n\n this.listeners_ = [\n google.maps.event.addDomListener(document, \"keydown\", function (e) {\n me.onKeyDown_(e);\n }),\n google.maps.event.addDomListener(document, \"keyup\", function (e) {\n me.onKeyUp_(e);\n }),\n google.maps.event.addDomListener(this.veilDiv_[0], \"mousedown\", function (e) {\n me.onMouseDown_(e);\n }),\n google.maps.event.addDomListener(this.veilDiv_[1], \"mousedown\", function (e) {\n me.onMouseDown_(e);\n }),\n google.maps.event.addDomListener(this.veilDiv_[2], \"mousedown\", function (e) {\n me.onMouseDown_(e);\n }),\n google.maps.event.addDomListener(this.veilDiv_[3], \"mousedown\", function (e) {\n me.onMouseDown_(e);\n }),\n google.maps.event.addDomListener(document, \"mousedown\", function (e) {\n me.onMouseDownDocument_(e);\n }),\n google.maps.event.addDomListener(document, \"mousemove\", function (e) {\n me.onMouseMove_(e);\n }),\n google.maps.event.addDomListener(document, \"mouseup\", function (e) {\n me.onMouseUp_(e);\n }),\n google.maps.event.addDomListener(window, \"scroll\", getScrollValue)\n ];\n\n this.hotKeyDown_ = false;\n this.mouseDown_ = false;\n this.dragging_ = false;\n this.startPt_ = null;\n this.endPt_ = null;\n this.mapWidth_ = null;\n this.mapHeight_ = null;\n this.mousePosn_ = null;\n this.mapPosn_ = null;\n\n if (this.visualEnabled_) {\n this.buttonDiv_ = this.initControl_(this.visualPositionOffset_);\n if (this.visualPositionIndex_ !== null) {\n this.buttonDiv_.index = this.visualPositionIndex_;\n }\n this.map_.controls[this.visualPosition_].push(this.buttonDiv_);\n this.controlIndex_ = this.map_.controls[this.visualPosition_].length - 1;\n }\n };\n /**\n * Initializes the visual control and returns its DOM element.\n * @param {Size} offset The offset of the control from its normal position.\n * @return {Node} The DOM element containing the visual control.\n */\n DragZoom.prototype.initControl_ = function (offset) {\n var control;\n var image;\n var me = this;\n\n control = document.createElement(\"div\");\n control.className = this.visualClass_;\n control.style.position = \"relative\";\n control.style.overflow = \"hidden\";\n control.style.height = this.visualSize_.height + \"px\";\n control.style.width = this.visualSize_.width + \"px\";\n control.title = this.visualTips_.off;\n image = document.createElement(\"img\");\n image.src = this.visualSprite_;\n image.style.position = \"absolute\";\n image.style.left = -(this.visualSize_.width * 2) + \"px\";\n image.style.top = 0 + \"px\";\n control.appendChild(image);\n control.onclick = function (e) {\n me.hotKeyDown_ = !me.hotKeyDown_;\n if (me.hotKeyDown_) {\n me.buttonDiv_.firstChild.style.left = -(me.visualSize_.width * 0) + \"px\";\n me.buttonDiv_.title = me.visualTips_.on;\n me.activatedByControl_ = true;\n google.maps.event.trigger(me, \"activate\");\n } else {\n me.buttonDiv_.firstChild.style.left = -(me.visualSize_.width * 2) + \"px\";\n me.buttonDiv_.title = me.visualTips_.off;\n google.maps.event.trigger(me, \"deactivate\");\n }\n me.onMouseMove_(e); // Updates the veil\n };\n control.onmouseover = function () {\n me.buttonDiv_.firstChild.style.left = -(me.visualSize_.width * 1) + \"px\";\n };\n control.onmouseout = function () {\n if (me.hotKeyDown_) {\n me.buttonDiv_.firstChild.style.left = -(me.visualSize_.width * 0) + \"px\";\n me.buttonDiv_.title = me.visualTips_.on;\n } else {\n me.buttonDiv_.firstChild.style.left = -(me.visualSize_.width * 2) + \"px\";\n me.buttonDiv_.title = me.visualTips_.off;\n }\n };\n control.ondragstart = function () {\n return false;\n };\n setVals(control.style, {\n cursor: \"pointer\",\n marginTop: offset.height + \"px\",\n marginLeft: offset.width + \"px\"\n });\n return control;\n };\n /**\n * Returns true if the hot key is being pressed when an event occurs.\n * @param {Event} e The keyboard event.\n * @return {boolean} Flag indicating whether the hot key is down.\n */\n DragZoom.prototype.isHotKeyDown_ = function (e) {\n var isHot;\n e = e || window.event;\n isHot = (e.shiftKey && this.key_ === \"shift\") || (e.altKey && this.key_ === \"alt\") || (e.ctrlKey && this.key_ === \"ctrl\");\n if (!isHot) {\n // Need to look at keyCode for Opera because it\n // doesn't set the shiftKey, altKey, ctrlKey properties\n // unless a non-modifier event is being reported.\n //\n // See http://cross-browser.com/x/examples/shift_mode.php\n // Also see http://unixpapa.com/js/key.html\n switch (e.keyCode) {\n case 16:\n if (this.key_ === \"shift\") {\n isHot = true;\n }\n break;\n case 17:\n if (this.key_ === \"ctrl\") {\n isHot = true;\n }\n break;\n case 18:\n if (this.key_ === \"alt\") {\n isHot = true;\n }\n break;\n }\n }\n return isHot;\n };\n /**\n * Returns true if the mouse is on top of the map div.\n * The position is captured in onMouseMove_.\n * @return {boolean}\n */\n DragZoom.prototype.isMouseOnMap_ = function () {\n var mousePosn = this.mousePosn_;\n if (mousePosn) {\n var mapPosn = this.mapPosn_;\n var mapDiv = this.map_.getDiv();\n return mousePosn.left > mapPosn.left && mousePosn.left < (mapPosn.left + mapDiv.offsetWidth) &&\n mousePosn.top > mapPosn.top && mousePosn.top < (mapPosn.top + mapDiv.offsetHeight);\n } else {\n // if user never moved mouse\n return false;\n }\n };\n /**\n * Show the veil if the hot key is down and the mouse is over the map,\n * otherwise hide the veil.\n */\n DragZoom.prototype.setVeilVisibility_ = function () {\n var i;\n if (this.map_ && this.hotKeyDown_ && this.isMouseOnMap_()) {\n var mapDiv = this.map_.getDiv();\n this.mapWidth_ = mapDiv.offsetWidth - (this.borderWidths_.left + this.borderWidths_.right);\n this.mapHeight_ = mapDiv.offsetHeight - (this.borderWidths_.top + this.borderWidths_.bottom);\n if (this.activatedByControl_) { // Veil covers entire map (except control)\n var left = parseInt(this.buttonDiv_.style.left, 10) + this.visualPositionOffset_.width;\n var top = parseInt(this.buttonDiv_.style.top, 10) + this.visualPositionOffset_.height;\n var width = this.visualSize_.width;\n var height = this.visualSize_.height;\n // Left veil rectangle:\n this.veilDiv_[0].style.top = \"0px\";\n this.veilDiv_[0].style.left = \"0px\";\n this.veilDiv_[0].style.width = left + \"px\";\n this.veilDiv_[0].style.height = this.mapHeight_ + \"px\";\n // Right veil rectangle:\n this.veilDiv_[1].style.top = \"0px\";\n this.veilDiv_[1].style.left = (left + width) + \"px\";\n this.veilDiv_[1].style.width = (this.mapWidth_ - (left + width)) + \"px\";\n this.veilDiv_[1].style.height = this.mapHeight_ + \"px\";\n // Top veil rectangle:\n this.veilDiv_[2].style.top = \"0px\";\n this.veilDiv_[2].style.left = left + \"px\";\n this.veilDiv_[2].style.width = width + \"px\";\n this.veilDiv_[2].style.height = top + \"px\";\n // Bottom veil rectangle:\n this.veilDiv_[3].style.top = (top + height) + \"px\";\n this.veilDiv_[3].style.left = left + \"px\";\n this.veilDiv_[3].style.width = width + \"px\";\n this.veilDiv_[3].style.height = (this.mapHeight_ - (top + height)) + \"px\";\n for (i = 0; i < this.veilDiv_.length; i++) {\n this.veilDiv_[i].style.display = \"block\";\n }\n } else {\n this.veilDiv_[0].style.left = \"0px\";\n this.veilDiv_[0].style.top = \"0px\";\n this.veilDiv_[0].style.width = this.mapWidth_ + \"px\";\n this.veilDiv_[0].style.height = this.mapHeight_ + \"px\";\n for (i = 1; i < this.veilDiv_.length; i++) {\n this.veilDiv_[i].style.width = \"0px\";\n this.veilDiv_[i].style.height = \"0px\";\n }\n for (i = 0; i < this.veilDiv_.length; i++) {\n this.veilDiv_[i].style.display = \"block\";\n }\n }\n } else {\n for (i = 0; i < this.veilDiv_.length; i++) {\n this.veilDiv_[i].style.display = \"none\";\n }\n }\n };\n /**\n * Handle key down. Show the veil if the hot key has been pressed.\n * @param {Event} e The keyboard event.\n */\n DragZoom.prototype.onKeyDown_ = function (e) {\n if (this.map_ && !this.hotKeyDown_ && this.isHotKeyDown_(e)) {\n this.mapPosn_ = getElementPosition(this.map_.getDiv());\n this.hotKeyDown_ = true;\n this.activatedByControl_ = false;\n this.setVeilVisibility_();\n /**\n * This event is fired when the hot key is pressed.\n * @name DragZoom#activate\n * @event\n */\n google.maps.event.trigger(this, \"activate\");\n }\n };\n /**\n * Get the google.maps.Point of the mouse position.\n * @param {Event} e The mouse event.\n * @return {Point} The mouse position.\n */\n DragZoom.prototype.getMousePoint_ = function (e) {\n var mousePosn = getMousePosition(e);\n var p = new google.maps.Point();\n p.x = mousePosn.left - this.mapPosn_.left - this.borderWidths_.left;\n p.y = mousePosn.top - this.mapPosn_.top - this.borderWidths_.top;\n p.x = Math.min(p.x, this.mapWidth_);\n p.y = Math.min(p.y, this.mapHeight_);\n p.x = Math.max(p.x, 0);\n p.y = Math.max(p.y, 0);\n return p;\n };\n /**\n * Handle mouse down.\n * @param {Event} e The mouse event.\n */\n DragZoom.prototype.onMouseDown_ = function (e) {\n if (this.map_ && this.hotKeyDown_) {\n this.mapPosn_ = getElementPosition(this.map_.getDiv());\n this.dragging_ = true;\n this.startPt_ = this.endPt_ = this.getMousePoint_(e);\n this.boxDiv_.style.width = this.boxDiv_.style.height = \"0px\";\n var prj = this.prjov_.getProjection();\n var latlng = prj.fromContainerPixelToLatLng(this.startPt_);\n /**\n * This event is fired when the drag operation begins.\n * The parameter passed is the geographic position of the starting point.\n * @name DragZoom#dragstart\n * @param {LatLng} latlng The geographic position of the starting point.\n * @event\n */\n google.maps.event.trigger(this, \"dragstart\", latlng);\n }\n };\n /**\n * Handle mouse down at the document level.\n * @param {Event} e The mouse event.\n */\n DragZoom.prototype.onMouseDownDocument_ = function (e) {\n this.mouseDown_ = true;\n };\n /**\n * Handle mouse move.\n * @param {Event} e The mouse event.\n */\n DragZoom.prototype.onMouseMove_ = function (e) {\n this.mousePosn_ = getMousePosition(e);\n if (this.dragging_) {\n this.endPt_ = this.getMousePoint_(e);\n var left = Math.min(this.startPt_.x, this.endPt_.x);\n var top = Math.min(this.startPt_.y, this.endPt_.y);\n var width = Math.abs(this.startPt_.x - this.endPt_.x);\n var height = Math.abs(this.startPt_.y - this.endPt_.y);\n // For benefit of MSIE 7/8 ensure following values are not negative:\n var boxWidth = Math.max(0, width - (this.boxBorderWidths_.left + this.boxBorderWidths_.right));\n var boxHeight = Math.max(0, height - (this.boxBorderWidths_.top + this.boxBorderWidths_.bottom));\n // Left veil rectangle:\n this.veilDiv_[0].style.top = \"0px\";\n this.veilDiv_[0].style.left = \"0px\";\n this.veilDiv_[0].style.width = left + \"px\";\n this.veilDiv_[0].style.height = this.mapHeight_ + \"px\";\n // Right veil rectangle:\n this.veilDiv_[1].style.top = \"0px\";\n this.veilDiv_[1].style.left = (left + width) + \"px\";\n this.veilDiv_[1].style.width = (this.mapWidth_ - (left + width)) + \"px\";\n this.veilDiv_[1].style.height = this.mapHeight_ + \"px\";\n // Top veil rectangle:\n this.veilDiv_[2].style.top = \"0px\";\n this.veilDiv_[2].style.left = left + \"px\";\n this.veilDiv_[2].style.width = width + \"px\";\n this.veilDiv_[2].style.height = top + \"px\";\n // Bottom veil rectangle:\n this.veilDiv_[3].style.top = (top + height) + \"px\";\n this.veilDiv_[3].style.left = left + \"px\";\n this.veilDiv_[3].style.width = width + \"px\";\n this.veilDiv_[3].style.height = (this.mapHeight_ - (top + height)) + \"px\";\n // Selection rectangle:\n this.boxDiv_.style.top = top + \"px\";\n this.boxDiv_.style.left = left + \"px\";\n this.boxDiv_.style.width = boxWidth + \"px\";\n this.boxDiv_.style.height = boxHeight + \"px\";\n this.boxDiv_.style.display = \"block\";\n /**\n * This event is fired repeatedly while the user drags a box across the area of interest.\n * The southwest and northeast point are passed as parameters of type google.maps.Point\n * (for performance reasons), relative to the map container. Also passed is the projection object\n * so that the event listener, if necessary, can convert the pixel positions to geographic\n * coordinates using google.maps.MapCanvasProjection.fromContainerPixelToLatLng.\n * @name DragZoom#drag\n * @param {Point} southwestPixel The southwest point of the selection area.\n * @param {Point} northeastPixel The northeast point of the selection area.\n * @param {MapCanvasProjection} prj The projection object.\n * @event\n */\n google.maps.event.trigger(this, \"drag\", new google.maps.Point(left, top + height), new google.maps.Point(left + width, top), this.prjov_.getProjection());\n } else if (!this.mouseDown_) {\n this.mapPosn_ = getElementPosition(this.map_.getDiv());\n this.setVeilVisibility_();\n }\n };\n /**\n * Handle mouse up.\n * @param {Event} e The mouse event.\n */\n DragZoom.prototype.onMouseUp_ = function (e) {\n var z;\n var me = this;\n this.mouseDown_ = false;\n if (this.dragging_) {\n if ((this.getMousePoint_(e).x === this.startPt_.x) && (this.getMousePoint_(e).y === this.startPt_.y)) {\n this.onKeyUp_(e); // Cancel event\n return;\n }\n var left = Math.min(this.startPt_.x, this.endPt_.x);\n var top = Math.min(this.startPt_.y, this.endPt_.y);\n var width = Math.abs(this.startPt_.x - this.endPt_.x);\n var height = Math.abs(this.startPt_.y - this.endPt_.y);\n // Google Maps API bug: setCenter() doesn't work as expected if the map has a\n // border on the left or top. The code here includes a workaround for this problem.\n var kGoogleCenteringBug = true;\n if (kGoogleCenteringBug) {\n left += this.borderWidths_.left;\n top += this.borderWidths_.top;\n }\n\n var prj = this.prjov_.getProjection();\n var sw = prj.fromContainerPixelToLatLng(new google.maps.Point(left, top + height));\n var ne = prj.fromContainerPixelToLatLng(new google.maps.Point(left + width, top));\n var bnds = new google.maps.LatLngBounds(sw, ne);\n\n if (this.noZoom_) {\n this.boxDiv_.style.display = \"none\";\n } else {\n // Sometimes fitBounds causes a zoom OUT, so restore original zoom level if this happens.\n z = this.map_.getZoom();\n this.map_.fitBounds(bnds);\n if (this.map_.getZoom() < z) {\n this.map_.setZoom(z);\n }\n\n // Redraw box after zoom:\n var swPt = prj.fromLatLngToContainerPixel(sw);\n var nePt = prj.fromLatLngToContainerPixel(ne);\n if (kGoogleCenteringBug) {\n swPt.x -= this.borderWidths_.left;\n swPt.y -= this.borderWidths_.top;\n nePt.x -= this.borderWidths_.left;\n nePt.y -= this.borderWidths_.top;\n }\n this.boxDiv_.style.left = swPt.x + \"px\";\n this.boxDiv_.style.top = nePt.y + \"px\";\n this.boxDiv_.style.width = (Math.abs(nePt.x - swPt.x) - (this.boxBorderWidths_.left + this.boxBorderWidths_.right)) + \"px\";\n this.boxDiv_.style.height = (Math.abs(nePt.y - swPt.y) - (this.boxBorderWidths_.top + this.boxBorderWidths_.bottom)) + \"px\";\n // Hide box asynchronously after 1 second:\n setTimeout(function () {\n me.boxDiv_.style.display = \"none\";\n }, 1000);\n }\n this.dragging_ = false;\n this.onMouseMove_(e); // Updates the veil\n /**\n * This event is fired when the drag operation ends.\n * The parameter passed is the geographic bounds of the selected area.\n * Note that this event is not fired if the hot key is released before the drag operation ends.\n * @name DragZoom#dragend\n * @param {LatLngBounds} bnds The geographic bounds of the selected area.\n * @event\n */\n google.maps.event.trigger(this, \"dragend\", bnds);\n // if the hot key isn't down, the drag zoom must have been activated by turning\n // on the visual control. In this case, finish up by simulating a key up event.\n if (!this.isHotKeyDown_(e)) {\n this.onKeyUp_(e);\n }\n }\n };\n /**\n * Handle key up.\n * @param {Event} e The keyboard event.\n */\n DragZoom.prototype.onKeyUp_ = function (e) {\n var i;\n var left, top, width, height, prj, sw, ne;\n var bnds = null;\n if (this.map_ && this.hotKeyDown_) {\n this.hotKeyDown_ = false;\n if (this.dragging_) {\n this.boxDiv_.style.display = \"none\";\n this.dragging_ = false;\n // Calculate the bounds when drag zoom was cancelled\n left = Math.min(this.startPt_.x, this.endPt_.x);\n top = Math.min(this.startPt_.y, this.endPt_.y);\n width = Math.abs(this.startPt_.x - this.endPt_.x);\n height = Math.abs(this.startPt_.y - this.endPt_.y);\n prj = this.prjov_.getProjection();\n sw = prj.fromContainerPixelToLatLng(new google.maps.Point(left, top + height));\n ne = prj.fromContainerPixelToLatLng(new google.maps.Point(left + width, top));\n bnds = new google.maps.LatLngBounds(sw, ne);\n }\n for (i = 0; i < this.veilDiv_.length; i++) {\n this.veilDiv_[i].style.display = \"none\";\n }\n if (this.visualEnabled_) {\n this.buttonDiv_.firstChild.style.left = -(this.visualSize_.width * 2) + \"px\";\n this.buttonDiv_.title = this.visualTips_.off;\n this.buttonDiv_.style.display = \"\";\n }\n /**\n * This event is fired when the hot key is released.\n * The parameter passed is the geographic bounds of the selected area immediately\n * before the hot key was released.\n * @name DragZoom#deactivate\n * @param {LatLngBounds} bnds The geographic bounds of the selected area immediately\n * before the hot key was released.\n * @event\n */\n google.maps.event.trigger(this, \"deactivate\", bnds);\n }\n };\n /**\n * @name google.maps.Map\n * @class These are new methods added to the Google Maps JavaScript API V3's\n * Map\n * class.\n */\n /**\n * Enables drag zoom. The user can zoom to an area of interest by holding down the hot key\n * (shift | ctrl | alt ) while dragging a box around the area or by turning\n * on the visual control then dragging a box around the area.\n * @param {KeyDragZoomOptions} opt_zoomOpts The optional parameters.\n */\n google.maps.Map.prototype.enableKeyDragZoom = function (opt_zoomOpts) {\n this.dragZoom_ = new DragZoom(this, opt_zoomOpts);\n };\n /**\n * Disables drag zoom.\n */\n google.maps.Map.prototype.disableKeyDragZoom = function () {\n var i;\n var d = this.dragZoom_;\n if (d) {\n for (i = 0; i < d.listeners_.length; ++i) {\n google.maps.event.removeListener(d.listeners_[i]);\n }\n this.getDiv().removeChild(d.boxDiv_);\n for (i = 0; i < d.veilDiv_.length; i++) {\n this.getDiv().removeChild(d.veilDiv_[i]);\n }\n if (d.visualEnabled_) {\n // Remove the custom control:\n this.controls[d.visualPosition_].removeAt(d.controlIndex_);\n }\n d.prjov_.setMap(null);\n this.dragZoom_ = null;\n }\n };\n /**\n * Returns true if the drag zoom feature has been enabled.\n * @return {boolean}\n */\n google.maps.Map.prototype.keyDragZoomEnabled = function () {\n return this.dragZoom_ !== null;\n };\n /**\n * Returns the DragZoom object which is created when google.maps.Map.enableKeyDragZoom is called.\n * With this object you can use google.maps.event.addListener to attach event listeners\n * for the \"activate\", \"deactivate\", \"dragstart\", \"drag\", and \"dragend\" events.\n * @return {DragZoom}\n */\n google.maps.Map.prototype.getDragZoomObject = function () {\n return this.dragZoom_;\n };\n})();\n\n/**\n * google-maps-utility-library-v3-markerwithlabel\n *\n * @version: 1.1.10\n * @author: Gary Little (inspired by code from Marc Ridey of Google).\n * @contributors: Nicholas McCready\n * @date: Fri May 13 2016 16:29:58 GMT-0400 (EDT)\n * @license: Apache License 2.0\n */\n/**\n * MarkerWithLabel allows you to define markers with associated labels. As you would expect,\n * if the marker is draggable, so too will be the label. In addition, a marker with a label\n * responds to all mouse events in the same manner as a regular marker. It also fires mouse\n * events and \"property changed\" events just as a regular marker would. Version 1.1 adds\n * support for the raiseOnDrag feature introduced in API V3.3.\n * Esc key. This doesn't work if you drag the marker\n * itself because this feature is not (yet) supported in the google.maps.Marker class.\n */\n\n/*jslint browser:true */\n/*global document,google */\n\n/**\n * @param {Function} childCtor Child class.\n * @param {Function} parentCtor Parent class.\n * @private\n */\nfunction inherits(childCtor, parentCtor) {\n /* @constructor */\n function tempCtor() {}\n tempCtor.prototype = parentCtor.prototype;\n childCtor.superClass_ = parentCtor.prototype;\n childCtor.prototype = new tempCtor();\n /* @override */\n childCtor.prototype.constructor = childCtor;\n}\n\n/**\n * This constructor creates a label and associates it with a marker.\n * It is for the private use of the MarkerWithLabel class.\n * @constructor\n * @param {Marker} marker The marker with which the label is to be associated.\n * @param {string} crossURL The URL of the cross image =.\n * @param {string} handCursor The URL of the hand cursor.\n * @private\n */\nfunction MarkerLabel_(marker, crossURL, handCursorURL) {\n this.marker_ = marker;\n this.handCursorURL_ = marker.handCursorURL;\n\n this.labelDiv_ = document.createElement(\"div\");\n this.labelDiv_.style.cssText = \"position: absolute; overflow: hidden;\";\n\n // Set up the DIV for handling mouse events in the label. This DIV forms a transparent veil\n // in the \"overlayMouseTarget\" pane, a veil that covers just the label. This is done so that\n // events can be captured even if the label is in the shadow of a google.maps.InfoWindow.\n // Code is included here to ensure the veil is always exactly the same size as the label.\n this.eventDiv_ = document.createElement(\"div\");\n this.eventDiv_.style.cssText = this.labelDiv_.style.cssText;\n\n // This is needed for proper behavior on MSIE:\n this.eventDiv_.setAttribute(\"onselectstart\", \"return false;\");\n this.eventDiv_.setAttribute(\"ondragstart\", \"return false;\");\n\n // Get the DIV for the \"X\" to be displayed when the marker is raised.\n this.crossDiv_ = MarkerLabel_.getSharedCross(crossURL);\n}\n\ninherits(MarkerLabel_, google.maps.OverlayView);\n\n/**\n * Returns the DIV for the cross used when dragging a marker when the\n * raiseOnDrag parameter set to true. One cross is shared with all markers.\n * @param {string} crossURL The URL of the cross image =.\n * @private\n */\nMarkerLabel_.getSharedCross = function (crossURL) {\n var div;\n if (typeof MarkerLabel_.getSharedCross.crossDiv === \"undefined\") {\n div = document.createElement(\"img\");\n div.style.cssText = \"position: absolute; z-index: 1000002; display: none;\";\n // Hopefully Google never changes the standard \"X\" attributes:\n div.style.marginLeft = \"-8px\";\n div.style.marginTop = \"-9px\";\n div.src = crossURL;\n MarkerLabel_.getSharedCross.crossDiv = div;\n }\n return MarkerLabel_.getSharedCross.crossDiv;\n};\n\n/**\n * Adds the DIV representing the label to the DOM. This method is called\n * automatically when the marker's setMap method is called.\n * @private\n */\nMarkerLabel_.prototype.onAdd = function () {\n var me = this;\n var cMouseIsDown = false;\n var cDraggingLabel = false;\n var cSavedZIndex;\n var cLatOffset, cLngOffset;\n var cIgnoreClick;\n var cRaiseEnabled;\n var cStartPosition;\n var cStartCenter;\n // Constants:\n var cRaiseOffset = 20;\n var cDraggingCursor = \"url(\" + this.handCursorURL_ + \")\";\n\n // Stops all processing of an event.\n //\n var cAbortEvent = function (e) {\n if (e.preventDefault) {\n e.preventDefault();\n }\n e.cancelBubble = true;\n if (e.stopPropagation) {\n e.stopPropagation();\n }\n };\n\n var cStopBounce = function () {\n me.marker_.setAnimation(null);\n };\n\n this.getPanes().overlayImage.appendChild(this.labelDiv_);\n this.getPanes().overlayMouseTarget.appendChild(this.eventDiv_);\n // One cross is shared with all markers, so only add it once:\n if (typeof MarkerLabel_.getSharedCross.processed === \"undefined\") {\n this.getPanes().overlayImage.appendChild(this.crossDiv_);\n MarkerLabel_.getSharedCross.processed = true;\n }\n\n this.listeners_ = [\n google.maps.event.addDomListener(this.eventDiv_, \"mouseover\", function (e) {\n if (me.marker_.getDraggable() || me.marker_.getClickable()) {\n this.style.cursor = \"pointer\";\n google.maps.event.trigger(me.marker_, \"mouseover\", e);\n }\n }),\n google.maps.event.addDomListener(this.eventDiv_, \"mouseout\", function (e) {\n if ((me.marker_.getDraggable() || me.marker_.getClickable()) && !cDraggingLabel) {\n this.style.cursor = me.marker_.getCursor();\n google.maps.event.trigger(me.marker_, \"mouseout\", e);\n }\n }),\n google.maps.event.addDomListener(this.eventDiv_, \"mousedown\", function (e) {\n cDraggingLabel = false;\n if (me.marker_.getDraggable()) {\n cMouseIsDown = true;\n this.style.cursor = cDraggingCursor;\n }\n if (me.marker_.getDraggable() || me.marker_.getClickable()) {\n google.maps.event.trigger(me.marker_, \"mousedown\", e);\n cAbortEvent(e); // Prevent map pan when starting a drag on a label\n }\n }),\n google.maps.event.addDomListener(document, \"mouseup\", function (mEvent) {\n var position;\n if (cMouseIsDown) {\n cMouseIsDown = false;\n me.eventDiv_.style.cursor = \"pointer\";\n google.maps.event.trigger(me.marker_, \"mouseup\", mEvent);\n }\n if (cDraggingLabel) {\n if (cRaiseEnabled) { // Lower the marker & label\n position = me.getProjection().fromLatLngToDivPixel(me.marker_.getPosition());\n position.y += cRaiseOffset;\n me.marker_.setPosition(me.getProjection().fromDivPixelToLatLng(position));\n // This is not the same bouncing style as when the marker portion is dragged,\n // but it will have to do:\n try { // Will fail if running Google Maps API earlier than V3.3\n me.marker_.setAnimation(google.maps.Animation.BOUNCE);\n setTimeout(cStopBounce, 1406);\n } catch (e) {}\n }\n me.crossDiv_.style.display = \"none\";\n me.marker_.setZIndex(cSavedZIndex);\n cIgnoreClick = true; // Set flag to ignore the click event reported after a label drag\n cDraggingLabel = false;\n mEvent.latLng = me.marker_.getPosition();\n google.maps.event.trigger(me.marker_, \"dragend\", mEvent);\n }\n }),\n google.maps.event.addListener(me.marker_.getMap(), \"mousemove\", function (mEvent) {\n var position;\n if (cMouseIsDown) {\n if (cDraggingLabel) {\n // Change the reported location from the mouse position to the marker position:\n mEvent.latLng = new google.maps.LatLng(mEvent.latLng.lat() - cLatOffset, mEvent.latLng.lng() - cLngOffset);\n position = me.getProjection().fromLatLngToDivPixel(mEvent.latLng);\n if (cRaiseEnabled) {\n me.crossDiv_.style.left = position.x + \"px\";\n me.crossDiv_.style.top = position.y + \"px\";\n me.crossDiv_.style.display = \"\";\n position.y -= cRaiseOffset;\n }\n me.marker_.setPosition(me.getProjection().fromDivPixelToLatLng(position));\n if (cRaiseEnabled) { // Don't raise the veil; this hack needed to make MSIE act properly\n me.eventDiv_.style.top = (position.y + cRaiseOffset) + \"px\";\n }\n google.maps.event.trigger(me.marker_, \"drag\", mEvent);\n } else {\n // Calculate offsets from the click point to the marker position:\n cLatOffset = mEvent.latLng.lat() - me.marker_.getPosition().lat();\n cLngOffset = mEvent.latLng.lng() - me.marker_.getPosition().lng();\n cSavedZIndex = me.marker_.getZIndex();\n cStartPosition = me.marker_.getPosition();\n cStartCenter = me.marker_.getMap().getCenter();\n cRaiseEnabled = me.marker_.get(\"raiseOnDrag\");\n cDraggingLabel = true;\n me.marker_.setZIndex(1000000); // Moves the marker & label to the foreground during a drag\n mEvent.latLng = me.marker_.getPosition();\n google.maps.event.trigger(me.marker_, \"dragstart\", mEvent);\n }\n }\n }),\n google.maps.event.addDomListener(document, \"keydown\", function (e) {\n if (cDraggingLabel) {\n if (e.keyCode === 27) { // Esc key\n cRaiseEnabled = false;\n me.marker_.setPosition(cStartPosition);\n me.marker_.getMap().setCenter(cStartCenter);\n google.maps.event.trigger(document, \"mouseup\", e);\n }\n }\n }),\n google.maps.event.addDomListener(this.eventDiv_, \"click\", function (e) {\n if (me.marker_.getDraggable() || me.marker_.getClickable()) {\n if (cIgnoreClick) { // Ignore the click reported when a label drag ends\n cIgnoreClick = false;\n } else {\n google.maps.event.trigger(me.marker_, \"click\", e);\n cAbortEvent(e); // Prevent click from being passed on to map\n }\n }\n }),\n google.maps.event.addDomListener(this.eventDiv_, \"dblclick\", function (e) {\n if (me.marker_.getDraggable() || me.marker_.getClickable()) {\n google.maps.event.trigger(me.marker_, \"dblclick\", e);\n cAbortEvent(e); // Prevent map zoom when double-clicking on a label\n }\n }),\n google.maps.event.addListener(this.marker_, \"dragstart\", function (mEvent) {\n if (!cDraggingLabel) {\n cRaiseEnabled = this.get(\"raiseOnDrag\");\n }\n }),\n google.maps.event.addListener(this.marker_, \"drag\", function (mEvent) {\n if (!cDraggingLabel) {\n if (cRaiseEnabled) {\n me.setPosition(cRaiseOffset);\n // During a drag, the marker's z-index is temporarily set to 1000000 to\n // ensure it appears above all other markers. Also set the label's z-index\n // to 1000000 (plus or minus 1 depending on whether the label is supposed\n // to be above or below the marker).\n me.labelDiv_.style.zIndex = 1000000 + (this.get(\"labelInBackground\") ? -1 : +1);\n }\n }\n }),\n google.maps.event.addListener(this.marker_, \"dragend\", function (mEvent) {\n if (!cDraggingLabel) {\n if (cRaiseEnabled) {\n me.setPosition(0); // Also restores z-index of label\n }\n }\n }),\n google.maps.event.addListener(this.marker_, \"position_changed\", function () {\n me.setPosition();\n }),\n google.maps.event.addListener(this.marker_, \"zindex_changed\", function () {\n me.setZIndex();\n }),\n google.maps.event.addListener(this.marker_, \"visible_changed\", function () {\n me.setVisible();\n }),\n google.maps.event.addListener(this.marker_, \"labelvisible_changed\", function () {\n me.setVisible();\n }),\n google.maps.event.addListener(this.marker_, \"title_changed\", function () {\n me.setTitle();\n }),\n google.maps.event.addListener(this.marker_, \"labelcontent_changed\", function () {\n me.setContent();\n }),\n google.maps.event.addListener(this.marker_, \"labelanchor_changed\", function () {\n me.setAnchor();\n }),\n google.maps.event.addListener(this.marker_, \"labelclass_changed\", function () {\n me.setStyles();\n }),\n google.maps.event.addListener(this.marker_, \"labelstyle_changed\", function () {\n me.setStyles();\n })\n ];\n};\n\n/**\n * Removes the DIV for the label from the DOM. It also removes all event handlers.\n * This method is called automatically when the marker's setMap(null)\n * method is called.\n * @private\n */\nMarkerLabel_.prototype.onRemove = function () {\n var i;\n this.labelDiv_.parentNode.removeChild(this.labelDiv_);\n this.eventDiv_.parentNode.removeChild(this.eventDiv_);\n\n // Remove event listeners:\n for (i = 0; i < this.listeners_.length; i++) {\n google.maps.event.removeListener(this.listeners_[i]);\n }\n};\n\n/**\n * Draws the label on the map.\n * @private\n */\nMarkerLabel_.prototype.draw = function () {\n this.setContent();\n this.setTitle();\n this.setStyles();\n};\n\n/**\n * Sets the content of the label.\n * The content can be plain text or an HTML DOM node.\n * @private\n */\nMarkerLabel_.prototype.setContent = function () {\n var content = this.marker_.get(\"labelContent\");\n if (typeof content.nodeType === \"undefined\") {\n this.labelDiv_.innerHTML = content;\n this.eventDiv_.innerHTML = this.labelDiv_.innerHTML;\n } else {\n this.labelDiv_.innerHTML = \"\"; // Remove current content\n this.labelDiv_.appendChild(content);\n content = content.cloneNode(true);\n this.eventDiv_.innerHTML = \"\"; // Remove current content\n this.eventDiv_.appendChild(content);\n }\n};\n\n/**\n * Sets the content of the tool tip for the label. It is\n * always set to be the same as for the marker itself.\n * @private\n */\nMarkerLabel_.prototype.setTitle = function () {\n this.eventDiv_.title = this.marker_.getTitle() || \"\";\n};\n\n/**\n * Sets the style of the label by setting the style sheet and applying\n * other specific styles requested.\n * @private\n */\nMarkerLabel_.prototype.setStyles = function () {\n var i, labelStyle;\n\n // Apply style values from the style sheet defined in the labelClass parameter:\n this.labelDiv_.className = this.marker_.get(\"labelClass\");\n this.eventDiv_.className = this.labelDiv_.className;\n\n // Clear existing inline style values:\n this.labelDiv_.style.cssText = \"\";\n this.eventDiv_.style.cssText = \"\";\n // Apply style values defined in the labelStyle parameter:\n labelStyle = this.marker_.get(\"labelStyle\");\n for (i in labelStyle) {\n if (labelStyle.hasOwnProperty(i)) {\n this.labelDiv_.style[i] = labelStyle[i];\n this.eventDiv_.style[i] = labelStyle[i];\n }\n }\n this.setMandatoryStyles();\n};\n\n/**\n * Sets the mandatory styles to the DIV representing the label as well as to the\n * associated event DIV. This includes setting the DIV position, z-index, and visibility.\n * @private\n */\nMarkerLabel_.prototype.setMandatoryStyles = function () {\n this.labelDiv_.style.position = \"absolute\";\n this.labelDiv_.style.overflow = \"hidden\";\n // Make sure the opacity setting causes the desired effect on MSIE:\n if (typeof this.labelDiv_.style.opacity !== \"undefined\" && this.labelDiv_.style.opacity !== \"\") {\n this.labelDiv_.style.MsFilter = \"\\\"progid:DXImageTransform.Microsoft.Alpha(opacity=\" + (this.labelDiv_.style.opacity * 100) + \")\\\"\";\n this.labelDiv_.style.filter = \"alpha(opacity=\" + (this.labelDiv_.style.opacity * 100) + \")\";\n }\n\n this.eventDiv_.style.position = this.labelDiv_.style.position;\n this.eventDiv_.style.overflow = this.labelDiv_.style.overflow;\n this.eventDiv_.style.opacity = 0.01; // Don't use 0; DIV won't be clickable on MSIE\n this.eventDiv_.style.MsFilter = \"\\\"progid:DXImageTransform.Microsoft.Alpha(opacity=1)\\\"\";\n this.eventDiv_.style.filter = \"alpha(opacity=1)\"; // For MSIE\n\n this.setAnchor();\n this.setPosition(); // This also updates z-index, if necessary.\n this.setVisible();\n};\n\n/**\n * Sets the anchor point of the label.\n * @private\n */\nMarkerLabel_.prototype.setAnchor = function () {\n var anchor = this.marker_.get(\"labelAnchor\");\n this.labelDiv_.style.marginLeft = -anchor.x + \"px\";\n this.labelDiv_.style.marginTop = -anchor.y + \"px\";\n this.eventDiv_.style.marginLeft = -anchor.x + \"px\";\n this.eventDiv_.style.marginTop = -anchor.y + \"px\";\n};\n\n/**\n * Sets the position of the label. The z-index is also updated, if necessary.\n * @private\n */\nMarkerLabel_.prototype.setPosition = function (yOffset) {\n var position = this.getProjection().fromLatLngToDivPixel(this.marker_.getPosition());\n if (typeof yOffset === \"undefined\") {\n yOffset = 0;\n }\n this.labelDiv_.style.left = Math.round(position.x) + \"px\";\n this.labelDiv_.style.top = Math.round(position.y - yOffset) + \"px\";\n this.eventDiv_.style.left = this.labelDiv_.style.left;\n this.eventDiv_.style.top = this.labelDiv_.style.top;\n\n this.setZIndex();\n};\n\n/**\n * Sets the z-index of the label. If the marker's z-index property has not been defined, the z-index\n * of the label is set to the vertical coordinate of the label. This is in keeping with the default\n * stacking order for Google Maps: markers to the south are in front of markers to the north.\n * @private\n */\nMarkerLabel_.prototype.setZIndex = function () {\n var zAdjust = (this.marker_.get(\"labelInBackground\") ? -1 : +1);\n if (typeof this.marker_.getZIndex() === \"undefined\") {\n this.labelDiv_.style.zIndex = parseInt(this.labelDiv_.style.top, 10) + zAdjust;\n this.eventDiv_.style.zIndex = this.labelDiv_.style.zIndex;\n } else {\n this.labelDiv_.style.zIndex = this.marker_.getZIndex() + zAdjust;\n this.eventDiv_.style.zIndex = this.labelDiv_.style.zIndex;\n }\n};\n\n/**\n * Sets the visibility of the label. The label is visible only if the marker itself is\n * visible (i.e., its visible property is true) and the labelVisible property is true.\n * @private\n */\nMarkerLabel_.prototype.setVisible = function () {\n if (this.marker_.get(\"labelVisible\")) {\n this.labelDiv_.style.display = this.marker_.getVisible() ? \"block\" : \"none\";\n } else {\n this.labelDiv_.style.display = \"none\";\n }\n this.eventDiv_.style.display = this.labelDiv_.style.display;\n};\n\n/**\n * @name MarkerWithLabelOptions\n * @class This class represents the optional parameter passed to the {@link MarkerWithLabel} constructor.\n * The properties available are the same as for google.maps.Marker with the addition\n * of the properties listed below. To change any of these additional properties after the labeled\n * marker has been created, call google.maps.Marker.set(propertyName, propertyValue).\n * propertyname_changed.\n * For example, if the content of the label changes, a labelcontent_changed event\n * is fired.\n * labelAnchor of google.maps.Point(25, 0).\n * (Note: x-values increase to the right and y-values increase to the top.)\n * @property {string} [labelClass] The name of the CSS class defining the styles for the label.\n * Note that style values for position, overflow, top,\n * left, zIndex, display, marginLeft, and\n * marginTop are ignored; these styles are for internal use only.\n * @property {Object} [labelStyle] An object literal whose properties define specific CSS\n * style values to be applied to the label. Style values defined here override those that may\n * be defined in the labelClass style sheet. If this property is changed after the\n * label has been created, all previously set styles (except those defined in the style sheet)\n * are removed from the label before the new style values are applied.\n * Note that style values for position, overflow, top,\n * left, zIndex, display, marginLeft, and\n * marginTop are ignored; these styles are for internal use only.\n * @property {boolean} [labelInBackground] A flag indicating whether a label that overlaps its\n * associated marker should appear in the background (i.e., in a plane below the marker).\n * The default is false, which causes the label to appear in the foreground.\n * @property {boolean} [labelVisible] A flag indicating whether the label is to be visible.\n * The default is true. Note that even if labelVisible is\n * true, the label will not be visible unless the associated marker is also\n * visible (i.e., unless the marker's visible property is true).\n * @property {boolean} [raiseOnDrag] A flag indicating whether the label and marker are to be\n * raised when the marker is dragged. The default is true. If a draggable marker is\n * being created and a version of Google Maps API earlier than V3.3 is being used, this property\n * must be set to false.\n * @property {boolean} [optimized] A flag indicating whether rendering is to be optimized for the\n * marker. Important: The optimized rendering technique is not supported by MarkerWithLabel,\n * so the value of this parameter is always forced to false.\n * @property {string} [crossImage=\"http://maps.gstatic.com/intl/en_us/mapfiles/drag_cross_67_16.png\"]\n * The URL of the cross image to be displayed while dragging a marker.\n * @property {string} [handCursor=\"http://maps.gstatic.com/intl/en_us/mapfiles/closedhand_8_8.cur\"]\n * The URL of the cursor to be displayed while dragging a marker.\n */\n/**\n * Creates a MarkerWithLabel with the options specified in {@link MarkerWithLabelOptions}.\n * @constructor\n * @param {MarkerWithLabelOptions} [opt_options] The optional parameters.\n */\nfunction MarkerWithLabel(opt_options) {\n opt_options = opt_options || {};\n opt_options.labelContent = opt_options.labelContent || \"\";\n opt_options.labelAnchor = opt_options.labelAnchor || new google.maps.Point(0, 0);\n opt_options.labelClass = opt_options.labelClass || \"markerLabels\";\n opt_options.labelStyle = opt_options.labelStyle || {};\n opt_options.labelInBackground = opt_options.labelInBackground || false;\n if (typeof opt_options.labelVisible === \"undefined\") {\n opt_options.labelVisible = true;\n }\n if (typeof opt_options.raiseOnDrag === \"undefined\") {\n opt_options.raiseOnDrag = true;\n }\n if (typeof opt_options.clickable === \"undefined\") {\n opt_options.clickable = true;\n }\n if (typeof opt_options.draggable === \"undefined\") {\n opt_options.draggable = false;\n }\n if (typeof opt_options.optimized === \"undefined\") {\n opt_options.optimized = false;\n }\n opt_options.crossImage = opt_options.crossImage || \"http\" + (document.location.protocol === \"https:\" ? \"s\" : \"\") + \"://maps.gstatic.com/intl/en_us/mapfiles/drag_cross_67_16.png\";\n opt_options.handCursor = opt_options.handCursor || \"http\" + (document.location.protocol === \"https:\" ? \"s\" : \"\") + \"://maps.gstatic.com/intl/en_us/mapfiles/closedhand_8_8.cur\";\n opt_options.optimized = false; // Optimized rendering is not supported\n\n this.label = new MarkerLabel_(this, opt_options.crossImage, opt_options.handCursor); // Bind the label to the marker\n\n // Call the parent constructor. It calls Marker.setValues to initialize, so all\n // the new parameters are conveniently saved and can be accessed with get/set.\n // Marker.set triggers a property changed event (called \"propertyname_changed\")\n // that the marker label listens for in order to react to state changes.\n google.maps.Marker.apply(this, arguments);\n}\n\ninherits(MarkerWithLabel, google.maps.Marker);\n\n/**\n * Overrides the standard Marker setMap function.\n * @param {Map} theMap The map to which the marker is to be added.\n * @private\n */\nMarkerWithLabel.prototype.setMap = function (theMap) {\n\n // Call the inherited function...\n google.maps.Marker.prototype.setMap.apply(this, arguments);\n\n // ... then deal with the label:\n this.label.setMap(theMap);\n};\n\n// ==ClosureCompiler==\n// @compilation_level ADVANCED_OPTIMIZATIONS\n// @externs_url http://closure-compiler.googlecode.com/svn/trunk/contrib/externs/maps/google_maps_api_v3.js\n// @output_wrapper (function() {%output%})();\n// ==/ClosureCompiler==\n\n/**\n * @license\n * Copyright 2013 Google Inc. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A RichMarker that allows any HTML/DOM to be added to a map and be draggable.\n *\n * @param {Object.MarkerClusterer begins\n * clustering markers.\n * @name MarkerClusterer#clusteringbegin\n * @param {MarkerClusterer} mc The MarkerClusterer whose markers are being clustered.\n * @event\n */\n google.maps.event.trigger(this, 'clusteringbegin', this);\n\n if (typeof this.timerRefStatic !== 'undefined') {\n clearTimeout(this.timerRefStatic);\n delete this.timerRefStatic;\n }\n }\n\n // Get our current map view bounds.\n // Create a new bounds object so we don't affect the map.\n //\n // See Comments 9 & 11 on Issue 3651 relating to this workaround for a Google Maps bug:\n if (this.getMap().getZoom() > 3) {\n mapBounds = new google.maps.LatLngBounds(this.getMap().getBounds().getSouthWest(),\n this.getMap().getBounds().getNorthEast());\n } else {\n mapBounds = new google.maps.LatLngBounds(new google.maps.LatLng(85.02070771743472, -178.48388434375), new google.maps.LatLng(-85.08136444384544, 178.00048865625));\n }\n var bounds = this.getExtendedBounds(mapBounds);\n\n var iLast = Math.min(iFirst + this.batchSize_, this.markers_.length);\n\n var _ms = this.markers_.values();\n for (i = iFirst; i < iLast; i++) {\n marker = _ms[i];\n if (!marker.isAdded && this.isMarkerInBounds_(marker, bounds)) {\n if (!this.ignoreHidden_ || (this.ignoreHidden_ && marker.getVisible())) {\n this.addToClosestCluster_(marker);\n }\n }\n }\n\n if (iLast < this.markers_.length) {\n this.timerRefStatic = setTimeout(function () {\n cMarkerClusterer.createClusters_(iLast);\n }, 0);\n } else {\n // custom addition by ui-gmap\n // update icon for all clusters\n for (i = 0; i < this.clusters_.length; i++) {\n this.clusters_[i].updateIcon_();\n }\n\n delete this.timerRefStatic;\n\n /**\n * This event is fired when the MarkerClusterer stops\n * clustering markers.\n * @name MarkerClusterer#clusteringend\n * @param {MarkerClusterer} mc The MarkerClusterer whose markers are being clustered.\n * @event\n */\n google.maps.event.trigger(this, 'clusteringend', this);\n }\n };\n\n /**\n * Adds a marker to a cluster, or creates a new cluster.\n *\n * @param {google.maps.Marker} marker The marker to add.\n */\n NgMapMarkerClusterer.prototype.addToClosestCluster_ = function (marker) {\n var i, d, cluster, center;\n var distance = 40000; // Some large number\n var clusterToAddTo = null;\n for (i = 0; i < this.clusters_.length; i++) {\n cluster = this.clusters_[i];\n center = cluster.getCenter();\n if (center) {\n d = this.distanceBetweenPoints_(center, marker.getPosition());\n if (d < distance) {\n distance = d;\n clusterToAddTo = cluster;\n }\n }\n }\n\n if (clusterToAddTo && clusterToAddTo.isMarkerInClusterBounds(marker)) {\n clusterToAddTo.addMarker(marker);\n } else {\n cluster = new NgMapCluster(this);\n cluster.addMarker(marker);\n this.clusters_.push(cluster);\n }\n };\n\n /**\n * Redraws all the clusters.\n */\n NgMapMarkerClusterer.prototype.redraw_ = function () {\n this.createClusters_(0);\n };\n\n\n /**\n * Removes all clusters from the map. The markers are also removed from the map\n * if opt_hide is set to true.\n *\n * @param {boolean} [opt_hide] Set to true to also remove the markers\n * from the map.\n */\n NgMapMarkerClusterer.prototype.resetViewport_ = function (opt_hide) {\n var i, marker;\n // Remove all the clusters\n for (i = 0; i < this.clusters_.length; i++) {\n this.clusters_[i].remove();\n }\n this.clusters_ = [];\n\n // Reset the markers to not be added and to be removed from the map.\n this.markers_.each(function (marker) {\n marker.isAdded = false;\n if (opt_hide) {\n marker.setMap(null);\n }\n });\n };\n\n /**\n * Extends an object's prototype by another's.\n *\n * @param {Object} obj1 The object to be extended.\n * @param {Object} obj2 The object to extend with.\n * @return {Object} The new extended object.\n * @ignore\n */\n NgMapMarkerClusterer.prototype.extend = function (obj1, obj2) {\n return (function (object) {\n var property;\n for (property in object.prototype) {\n if (property !== 'constructor')\n this.prototype[property] = object.prototype[property];\n }\n return this;\n }).apply(obj1, [obj2]);\n };\n ////////////////////////////////////////////////////////////////////////////////\n /*\n Other overrides relevant to MarkerClusterPlus\n */\n ////////////////////////////////////////////////////////////////////////////////\n /**\n * Positions and shows the icon.\n */\n ClusterIcon.prototype.show = function () {\n if (this.div_) {\n var img = \"\";\n // NOTE: values must be specified in px units\n var bp = this.backgroundPosition_.split(\" \");\n var spriteH = parseInt(bp[0].trim(), 10);\n var spriteV = parseInt(bp[1].trim(), 10);\n var pos = this.getPosFromLatLng_(this.center_);\n this.div_.style.cssText = this.createCss(pos);\n img = \"\";\n this.div_.innerHTML = img + \"
"),a},e}(a.InfoBox),a.uiGmapInfoBox=b),a.MarkerLabel_?a.MarkerLabel_.prototype.setContent=function(){var a;a=this.marker_.get("labelContent"),a&&!_.isEqual(this.oldContent,a)&&("undefined"==typeof(null!=a?a.nodeType:void 0)?(this.labelDiv_.innerHTML=a,this.eventDiv_.innerHTML=this.labelDiv_.innerHTML,this.oldContent=a):(this.labelDiv_.innerHTML="",this.labelDiv_.appendChild(a),a=a.cloneNode(!0),this.labelDiv_.innerHTML="",this.eventDiv_.appendChild(a),this.oldContent=a))}:void 0})}})}.call(this),function(){b.module("uiGmapgoogle-maps.extensions").service("uiGmapLodash",function(){var a,b,c,d,e,f,g,h;return f=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g,e=/\\(\\)?/g,c=function(a){var b,c,d;return c=a.missingName,d=a.swapName,b=a.isProto,null==_[c]&&(_[c]=_[d],b)?_.prototype[c]=_[d]:void 0},[{missingName:"contains",swapName:"includes",isProto:!0},{missingName:"includes",swapName:"contains",isProto:!0},{missingName:"object",swapName:"zipObject"},{missingName:"zipObject",swapName:"object"},{missingName:"all",swapName:"every"},{missingName:"every",swapName:"all"},{missingName:"any",swapName:"some"},{missingName:"some",swapName:"any"},{missingName:"first",swapName:"head"},{missingName:"head",swapName:"first"}].forEach(function(a){return c(a)}),null==_.get&&(g=function(a){return _.isObject(a)?a:Object(a)},b=function(a){return null===a?"":a+""},h=function(a){var c;return _.isArray(a)?a:(c=[],b(a).replace(f,function(a,b,d,f){c.push(d?f.replace(e,"$1"):b||a)}),c)},a=function(a,b,c){var d,e;if(null!==a){void 0!==c&&c in g(a)&&(b=[c]),d=0,e=b.length;for(;!_.isUndefined(a)&&e>d;)a=a[b[d++]];return d&&d===e?a:void 0}},d=function(b,c,d){var e;return e=null===b?void 0:a(b,h(c),c+""),void 0===e?d:e},_.get=d),this.intersectionObjects=function(a,b,c){var d;return null==c&&(c=void 0),d=_.map(a,function(a){return _.find(b,function(b){return null!=c?c(a,b):_.isEqual(a,b)})}),_.filter(d,function(a){return null!=a})},this.containsObject=_.includeObject=function(a,b,c){return null==c&&(c=void 0),null===a?!1:_.some(a,function(a){return null!=c?c(a,b):_.isEqual(a,b)})},this.differenceObjects=function(a,b,c){return null==c&&(c=void 0),_.filter(a,function(a){return function(d){return!a.containsObject(b,d,c)}}(this))},this.withoutObjects=this.differenceObjects,this.indexOfObject=function(a,b,c,d){var e,f;if(null==a)return-1;if(e=0,f=a.length,d){if("number"!=typeof d)return e=_.sortedIndex(a,b),a[e]===b?e:-1;e=0>d?Math.max(0,f+d):d}for(;f>e;){if(null!=c){if(c(a[e],b))return e}else if(_.isEqual(a[e],b))return e;e++}return-1},this.isNullOrUndefined=function(a){return _.isNull(a||_.isUndefined(a))},this})}.call(this),function(){b.module("uiGmapgoogle-maps.extensions").factory("uiGmapString",function(){return function(a){return this.contains=function(b,c){return-1!==a.indexOf(b,c)},this}})}.call(this),function(){b.module("uiGmapgoogle-maps.directives.api.utils").service("uiGmap_sync",[function(){return{fakePromise:function(){var a;return a=void 0,{then:function(b){return a=b},resolve:function(){return a.apply(void 0,arguments)}}}}}]).service("uiGmap_async",["$timeout","uiGmapPromise","uiGmapLogger","$q","uiGmapDataStructures","uiGmapGmapUtil",function(a,c,d,e,f,g){var h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A;return z=c.promiseTypes,s=c.isInProgress,y=c.promiseStatus,h=c.ExposedPromise,j=c.SniffedPromise,t=function(a,b){var c;return c=a.promise(),c.promiseType=a.promiseType,c.$$state&&d.debug("promiseType: "+c.promiseType+", state: "+y(c.$$state.status)),c.cancelCb=b,c},o=function(a,b){return a.promiseType===z.create&&b.promiseType!==z["delete"]&&b.promiseType!==z.init?(d.debug("lastPromise.promiseType "+b.promiseType+", newPromiseType: "+a.promiseType+", SKIPPED MUST COME AFTER DELETE ONLY"),!0):!1},x=function(a,b,c){var e;return b.promiseType===z["delete"]&&c.promiseType!==z["delete"]&&null!=c.cancelCb&&_.isFunction(c.cancelCb)&&s(c)&&(d.debug("promiseType: "+b.promiseType+", CANCELING LAST PROMISE type: "+c.promiseType),c.cancelCb("cancel safe"),e=a.peek(),null!=e&&s(e))?e.hasOwnProperty("cancelCb")&&_.isFunction(e.cancelCb)?(d.debug("promiseType: "+e.promiseType+", CANCELING FIRST PROMISE type: "+e.promiseType),e.cancelCb("cancel safe")):d.warn("first promise was not cancelable"):void 0},i=function(a,b,c){var d,e;if(a.existingPieces){if(d=_.last(a.existingPieces._content),o(b,d))return;return x(a.existingPieces,b,d),e=h(d["finally"](function(){return t(b,c)})),e.cancelCb=c,e.promiseType=b.promiseType,a.existingPieces.enqueue(e),d["finally"](function(){return a.existingPieces.dequeue()})}return a.existingPieces=new f.Queue,a.existingPieces.enqueue(t(b,c))},v=function(a,b,c,e,f){var g;return null==c&&(c=""),g=function(a){return d.debug(a+": "+a),null!=e&&_.isFunction(e)?e(a):void 0},i(a,j(f,b),g)},m=80,q={value:null},A=function(a,b,c){var d,e;try{return a.apply(b,c)}catch(e){return d=e,q.value=d,q}},u=function(a,b,c,e){var f,g;return g=A(a,b,e),g===q&&(f="error within chunking iterator: "+q.value,d.error(f),c.reject(f)),"cancel safe"!==g},k=function(a,b,c){var d,e;return d=a===b,e=b[c],d?e:a[e]},l=["length","forEach","map"],r=function(a,c,d,e){var f,g,h;if(b.isArray(a))f=a;else if(c)f=c;else{f=[];for(g in a)h=a[g],a.hasOwnProperty(g)&&!_.includes(l,g)&&f.push(g)}return null==e&&(e=d),b.isArray(f)&&!(null!=f?f.length:void 0)&&e!==d?d():e(f,c)},n=function(c,d,e,f,g,h,i,j){return r(c,j,function(j,l){var m,o,p,q;for(m=d&&d
",this.div_.innerHTML=a+"
+ *
+ *
+ * In cases where both backend definitions and request expectations are specified during unit
+ * testing, the request expectations are evaluated first.
+ *
+ * If a request expectation has no response specified, the algorithm will search your backend
+ * definitions for an appropriate response.
+ *
+ * If a request didn't match any expectation or if the expectation doesn't have the response
+ * defined, the backend definitions are evaluated in sequential order to see if any of them match
+ * the request. The response from the first matched definition is returned.
+ *
+ *
+ * # Flushing HTTP requests
+ *
+ * The $httpBackend used in production always responds to requests asynchronously. If we preserved
+ * this behavior in unit testing, we'd have to create async unit tests, which are hard to write,
+ * to follow and to maintain. But neither can the testing mock respond synchronously; that would
+ * change the execution of the code under test. For this reason, the mock $httpBackend has a
+ * `flush()` method, which allows the test to explicitly flush pending requests. This preserves
+ * the async api of the backend, while allowing the test to execute synchronously.
+ *
+ *
+ * # Unit testing with mock $httpBackend
+ * The following code shows how to setup and use the mock backend when unit testing a controller.
+ * First we create the controller under test:
+ *
+ ```js
+ // The module code
+ angular
+ .module('MyApp', [])
+ .controller('MyController', MyController);
+
+ // The controller code
+ function MyController($scope, $http) {
+ var authToken;
+
+ $http.get('/auth.py').success(function(data, status, headers) {
+ authToken = headers('A-Token');
+ $scope.user = data;
+ });
+
+ $scope.saveMessage = function(message) {
+ var headers = { 'Authorization': authToken };
+ $scope.status = 'Saving...';
+
+ $http.post('/add-msg.py', message, { headers: headers } ).success(function(response) {
+ $scope.status = '';
+ }).error(function() {
+ $scope.status = 'ERROR!';
+ });
+ };
+ }
+ ```
+ *
+ * Now we setup the mock backend and create the test specs:
+ *
+ ```js
+ // testing controller
+ describe('MyController', function() {
+ var $httpBackend, $rootScope, createController, authRequestHandler;
+
+ // Set up the module
+ beforeEach(module('MyApp'));
+
+ beforeEach(inject(function($injector) {
+ // Set up the mock http service responses
+ $httpBackend = $injector.get('$httpBackend');
+ // backend definition common for all tests
+ authRequestHandler = $httpBackend.when('GET', '/auth.py')
+ .respond({userId: 'userX'}, {'A-Token': 'xxx'});
+
+ // Get hold of a scope (i.e. the root scope)
+ $rootScope = $injector.get('$rootScope');
+ // The $controller service is used to create instances of controllers
+ var $controller = $injector.get('$controller');
+
+ createController = function() {
+ return $controller('MyController', {'$scope' : $rootScope });
+ };
+ }));
+
+
+ afterEach(function() {
+ $httpBackend.verifyNoOutstandingExpectation();
+ $httpBackend.verifyNoOutstandingRequest();
+ });
+
+
+ it('should fetch authentication token', function() {
+ $httpBackend.expectGET('/auth.py');
+ var controller = createController();
+ $httpBackend.flush();
+ });
+
+
+ it('should fail authentication', function() {
+
+ // Notice how you can change the response even after it was set
+ authRequestHandler.respond(401, '');
+
+ $httpBackend.expectGET('/auth.py');
+ var controller = createController();
+ $httpBackend.flush();
+ expect($rootScope.status).toBe('Failed...');
+ });
+
+
+ it('should send msg to server', function() {
+ var controller = createController();
+ $httpBackend.flush();
+
+ // now you don’t care about the authentication, but
+ // the controller will still send the request and
+ // $httpBackend will respond without you having to
+ // specify the expectation and response for this request
+
+ $httpBackend.expectPOST('/add-msg.py', 'message content').respond(201, '');
+ $rootScope.saveMessage('message content');
+ expect($rootScope.status).toBe('Saving...');
+ $httpBackend.flush();
+ expect($rootScope.status).toBe('');
+ });
+
+
+ it('should send auth header', function() {
+ var controller = createController();
+ $httpBackend.flush();
+
+ $httpBackend.expectPOST('/add-msg.py', undefined, function(headers) {
+ // check if the header was send, if it wasn't the expectation won't
+ // match the request and the test will fail
+ return headers['Authorization'] == 'xxx';
+ }).respond(201, '');
+
+ $rootScope.saveMessage('whatever');
+ $httpBackend.flush();
+ });
+ });
+ ```
+ */
+angular.mock.$HttpBackendProvider = function() {
+ this.$get = ['$rootScope', '$timeout', createHttpBackendMock];
+};
+
+/**
+ * General factory function for $httpBackend mock.
+ * Returns instance for unit testing (when no arguments specified):
+ * - passing through is disabled
+ * - auto flushing is disabled
+ *
+ * Returns instance for e2e testing (when `$delegate` and `$browser` specified):
+ * - passing through (delegating request to real backend) is enabled
+ * - auto flushing is enabled
+ *
+ * @param {Object=} $delegate Real $httpBackend instance (allow passing through if specified)
+ * @param {Object=} $browser Auto-flushing enabled if specified
+ * @return {Object} Instance of $httpBackend mock
+ */
+function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
+ var definitions = [],
+ expectations = [],
+ responses = [],
+ responsesPush = angular.bind(responses, responses.push),
+ copy = angular.copy;
+
+ function createResponse(status, data, headers, statusText) {
+ if (angular.isFunction(status)) return status;
+
+ return function() {
+ return angular.isNumber(status)
+ ? [status, data, headers, statusText]
+ : [200, status, data, headers];
+ };
+ }
+
+ // TODO(vojta): change params to: method, url, data, headers, callback
+ function $httpBackend(method, url, data, callback, headers, timeout, withCredentials) {
+ var xhr = new MockXhr(),
+ expectation = expectations[0],
+ wasExpected = false;
+
+ function prettyPrint(data) {
+ return (angular.isString(data) || angular.isFunction(data) || data instanceof RegExp)
+ ? data
+ : angular.toJson(data);
+ }
+
+ function wrapResponse(wrapped) {
+ if (!$browser && timeout) {
+ timeout.then ? timeout.then(handleTimeout) : $timeout(handleTimeout, timeout);
+ }
+
+ return handleResponse;
+
+ function handleResponse() {
+ var response = wrapped.response(method, url, data, headers);
+ xhr.$$respHeaders = response[2];
+ callback(copy(response[0]), copy(response[1]), xhr.getAllResponseHeaders(),
+ copy(response[3] || ''));
+ }
+
+ function handleTimeout() {
+ for (var i = 0, ii = responses.length; i < ii; i++) {
+ if (responses[i] === handleResponse) {
+ responses.splice(i, 1);
+ callback(-1, undefined, '');
+ break;
+ }
+ }
+ }
+ }
+
+ if (expectation && expectation.match(method, url)) {
+ if (!expectation.matchData(data))
+ throw new Error('Expected ' + expectation + ' with different data\n' +
+ 'EXPECTED: ' + prettyPrint(expectation.data) + '\nGOT: ' + data);
+
+ if (!expectation.matchHeaders(headers))
+ throw new Error('Expected ' + expectation + ' with different headers\n' +
+ 'EXPECTED: ' + prettyPrint(expectation.headers) + '\nGOT: ' +
+ prettyPrint(headers));
+
+ expectations.shift();
+
+ if (expectation.response) {
+ responses.push(wrapResponse(expectation));
+ return;
+ }
+ wasExpected = true;
+ }
+
+ var i = -1, definition;
+ while ((definition = definitions[++i])) {
+ if (definition.match(method, url, data, headers || {})) {
+ if (definition.response) {
+ // if $browser specified, we do auto flush all requests
+ ($browser ? $browser.defer : responsesPush)(wrapResponse(definition));
+ } else if (definition.passThrough) {
+ $delegate(method, url, data, callback, headers, timeout, withCredentials);
+ } else throw new Error('No response defined !');
+ return;
+ }
+ }
+ throw wasExpected ?
+ new Error('No response defined !') :
+ new Error('Unexpected request: ' + method + ' ' + url + '\n' +
+ (expectation ? 'Expected ' + expectation : 'No more request expected'));
+ }
+
+ /**
+ * @ngdoc method
+ * @name $httpBackend#when
+ * @description
+ * Creates a new backend definition.
+ *
+ * @param {string} method HTTP method.
+ * @param {string|RegExp|function(string)} url HTTP url or function that receives the url
+ * and returns true if the url match the current definition.
+ * @param {(string|RegExp|function(string))=} data HTTP request body or function that receives
+ * data string and returns true if the data is as expected.
+ * @param {(Object|function(Object))=} headers HTTP headers or function that receives http header
+ * object and returns true if the headers match the current definition.
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
+ * request is handled. You can save this object for later use and invoke `respond` again in
+ * order to change how a matched request is handled.
+ *
+ * - respond –
+ * `{function([status,] data[, headers, statusText])
+ * | function(function(method, url, data, headers)}`
+ * – The respond method takes a set of static data to be returned or a function that can
+ * return an array containing response status (number), response data (string), response
+ * headers (Object), and the text for the status (string). The respond method returns the
+ * `requestHandler` object for possible overrides.
+ */
+ $httpBackend.when = function(method, url, data, headers) {
+ var definition = new MockHttpExpectation(method, url, data, headers),
+ chain = {
+ respond: function(status, data, headers, statusText) {
+ definition.passThrough = undefined;
+ definition.response = createResponse(status, data, headers, statusText);
+ return chain;
+ }
+ };
+
+ if ($browser) {
+ chain.passThrough = function() {
+ definition.response = undefined;
+ definition.passThrough = true;
+ return chain;
+ };
+ }
+
+ definitions.push(definition);
+ return chain;
+ };
+
+ /**
+ * @ngdoc method
+ * @name $httpBackend#whenGET
+ * @description
+ * Creates a new backend definition for GET requests. For more info see `when()`.
+ *
+ * @param {string|RegExp|function(string)} url HTTP url or function that receives the url
+ * and returns true if the url match the current definition.
+ * @param {(Object|function(Object))=} headers HTTP headers.
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
+ * request is handled. You can save this object for later use and invoke `respond` again in
+ * order to change how a matched request is handled.
+ */
+
+ /**
+ * @ngdoc method
+ * @name $httpBackend#whenHEAD
+ * @description
+ * Creates a new backend definition for HEAD requests. For more info see `when()`.
+ *
+ * @param {string|RegExp|function(string)} url HTTP url or function that receives the url
+ * and returns true if the url match the current definition.
+ * @param {(Object|function(Object))=} headers HTTP headers.
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
+ * request is handled. You can save this object for later use and invoke `respond` again in
+ * order to change how a matched request is handled.
+ */
+
+ /**
+ * @ngdoc method
+ * @name $httpBackend#whenDELETE
+ * @description
+ * Creates a new backend definition for DELETE requests. For more info see `when()`.
+ *
+ * @param {string|RegExp|function(string)} url HTTP url or function that receives the url
+ * and returns true if the url match the current definition.
+ * @param {(Object|function(Object))=} headers HTTP headers.
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
+ * request is handled. You can save this object for later use and invoke `respond` again in
+ * order to change how a matched request is handled.
+ */
+
+ /**
+ * @ngdoc method
+ * @name $httpBackend#whenPOST
+ * @description
+ * Creates a new backend definition for POST requests. For more info see `when()`.
+ *
+ * @param {string|RegExp|function(string)} url HTTP url or function that receives the url
+ * and returns true if the url match the current definition.
+ * @param {(string|RegExp|function(string))=} data HTTP request body or function that receives
+ * data string and returns true if the data is as expected.
+ * @param {(Object|function(Object))=} headers HTTP headers.
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
+ * request is handled. You can save this object for later use and invoke `respond` again in
+ * order to change how a matched request is handled.
+ */
+
+ /**
+ * @ngdoc method
+ * @name $httpBackend#whenPUT
+ * @description
+ * Creates a new backend definition for PUT requests. For more info see `when()`.
+ *
+ * @param {string|RegExp|function(string)} url HTTP url or function that receives the url
+ * and returns true if the url match the current definition.
+ * @param {(string|RegExp|function(string))=} data HTTP request body or function that receives
+ * data string and returns true if the data is as expected.
+ * @param {(Object|function(Object))=} headers HTTP headers.
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
+ * request is handled. You can save this object for later use and invoke `respond` again in
+ * order to change how a matched request is handled.
+ */
+
+ /**
+ * @ngdoc method
+ * @name $httpBackend#whenJSONP
+ * @description
+ * Creates a new backend definition for JSONP requests. For more info see `when()`.
+ *
+ * @param {string|RegExp|function(string)} url HTTP url or function that receives the url
+ * and returns true if the url match the current definition.
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
+ * request is handled. You can save this object for later use and invoke `respond` again in
+ * order to change how a matched request is handled.
+ */
+ createShortMethods('when');
+
+
+ /**
+ * @ngdoc method
+ * @name $httpBackend#expect
+ * @description
+ * Creates a new request expectation.
+ *
+ * @param {string} method HTTP method.
+ * @param {string|RegExp|function(string)} url HTTP url or function that receives the url
+ * and returns true if the url match the current definition.
+ * @param {(string|RegExp|function(string)|Object)=} data HTTP request body or function that
+ * receives data string and returns true if the data is as expected, or Object if request body
+ * is in JSON format.
+ * @param {(Object|function(Object))=} headers HTTP headers or function that receives http header
+ * object and returns true if the headers match the current expectation.
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
+ * request is handled. You can save this object for later use and invoke `respond` again in
+ * order to change how a matched request is handled.
+ *
+ * - respond –
+ * `{function([status,] data[, headers, statusText])
+ * | function(function(method, url, data, headers)}`
+ * – The respond method takes a set of static data to be returned or a function that can
+ * return an array containing response status (number), response data (string), response
+ * headers (Object), and the text for the status (string). The respond method returns the
+ * `requestHandler` object for possible overrides.
+ */
+ $httpBackend.expect = function(method, url, data, headers) {
+ var expectation = new MockHttpExpectation(method, url, data, headers),
+ chain = {
+ respond: function(status, data, headers, statusText) {
+ expectation.response = createResponse(status, data, headers, statusText);
+ return chain;
+ }
+ };
+
+ expectations.push(expectation);
+ return chain;
+ };
+
+
+ /**
+ * @ngdoc method
+ * @name $httpBackend#expectGET
+ * @description
+ * Creates a new request expectation for GET requests. For more info see `expect()`.
+ *
+ * @param {string|RegExp|function(string)} url HTTP url or function that receives the url
+ * and returns true if the url match the current definition.
+ * @param {Object=} headers HTTP headers.
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
+ * request is handled. You can save this object for later use and invoke `respond` again in
+ * order to change how a matched request is handled. See #expect for more info.
+ */
+
+ /**
+ * @ngdoc method
+ * @name $httpBackend#expectHEAD
+ * @description
+ * Creates a new request expectation for HEAD requests. For more info see `expect()`.
+ *
+ * @param {string|RegExp|function(string)} url HTTP url or function that receives the url
+ * and returns true if the url match the current definition.
+ * @param {Object=} headers HTTP headers.
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
+ * request is handled. You can save this object for later use and invoke `respond` again in
+ * order to change how a matched request is handled.
+ */
+
+ /**
+ * @ngdoc method
+ * @name $httpBackend#expectDELETE
+ * @description
+ * Creates a new request expectation for DELETE requests. For more info see `expect()`.
+ *
+ * @param {string|RegExp|function(string)} url HTTP url or function that receives the url
+ * and returns true if the url match the current definition.
+ * @param {Object=} headers HTTP headers.
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
+ * request is handled. You can save this object for later use and invoke `respond` again in
+ * order to change how a matched request is handled.
+ */
+
+ /**
+ * @ngdoc method
+ * @name $httpBackend#expectPOST
+ * @description
+ * Creates a new request expectation for POST requests. For more info see `expect()`.
+ *
+ * @param {string|RegExp|function(string)} url HTTP url or function that receives the url
+ * and returns true if the url match the current definition.
+ * @param {(string|RegExp|function(string)|Object)=} data HTTP request body or function that
+ * receives data string and returns true if the data is as expected, or Object if request body
+ * is in JSON format.
+ * @param {Object=} headers HTTP headers.
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
+ * request is handled. You can save this object for later use and invoke `respond` again in
+ * order to change how a matched request is handled.
+ */
+
+ /**
+ * @ngdoc method
+ * @name $httpBackend#expectPUT
+ * @description
+ * Creates a new request expectation for PUT requests. For more info see `expect()`.
+ *
+ * @param {string|RegExp|function(string)} url HTTP url or function that receives the url
+ * and returns true if the url match the current definition.
+ * @param {(string|RegExp|function(string)|Object)=} data HTTP request body or function that
+ * receives data string and returns true if the data is as expected, or Object if request body
+ * is in JSON format.
+ * @param {Object=} headers HTTP headers.
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
+ * request is handled. You can save this object for later use and invoke `respond` again in
+ * order to change how a matched request is handled.
+ */
+
+ /**
+ * @ngdoc method
+ * @name $httpBackend#expectPATCH
+ * @description
+ * Creates a new request expectation for PATCH requests. For more info see `expect()`.
+ *
+ * @param {string|RegExp|function(string)} url HTTP url or function that receives the url
+ * and returns true if the url match the current definition.
+ * @param {(string|RegExp|function(string)|Object)=} data HTTP request body or function that
+ * receives data string and returns true if the data is as expected, or Object if request body
+ * is in JSON format.
+ * @param {Object=} headers HTTP headers.
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
+ * request is handled. You can save this object for later use and invoke `respond` again in
+ * order to change how a matched request is handled.
+ */
+
+ /**
+ * @ngdoc method
+ * @name $httpBackend#expectJSONP
+ * @description
+ * Creates a new request expectation for JSONP requests. For more info see `expect()`.
+ *
+ * @param {string|RegExp|function(string)} url HTTP url or function that receives the url
+ * and returns true if the url match the current definition.
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
+ * request is handled. You can save this object for later use and invoke `respond` again in
+ * order to change how a matched request is handled.
+ */
+ createShortMethods('expect');
+
+
+ /**
+ * @ngdoc method
+ * @name $httpBackend#flush
+ * @description
+ * Flushes all pending requests using the trained responses.
+ *
+ * @param {number=} count Number of responses to flush (in the order they arrived). If undefined,
+ * all pending requests will be flushed. If there are no pending requests when the flush method
+ * is called an exception is thrown (as this typically a sign of programming error).
+ */
+ $httpBackend.flush = function(count, digest) {
+ if (digest !== false) $rootScope.$digest();
+ if (!responses.length) throw new Error('No pending request to flush !');
+
+ if (angular.isDefined(count) && count !== null) {
+ while (count--) {
+ if (!responses.length) throw new Error('No more pending request to flush !');
+ responses.shift()();
+ }
+ } else {
+ while (responses.length) {
+ responses.shift()();
+ }
+ }
+ $httpBackend.verifyNoOutstandingExpectation(digest);
+ };
+
+
+ /**
+ * @ngdoc method
+ * @name $httpBackend#verifyNoOutstandingExpectation
+ * @description
+ * Verifies that all of the requests defined via the `expect` api were made. If any of the
+ * requests were not made, verifyNoOutstandingExpectation throws an exception.
+ *
+ * Typically, you would call this method following each test case that asserts requests using an
+ * "afterEach" clause.
+ *
+ * ```js
+ * afterEach($httpBackend.verifyNoOutstandingExpectation);
+ * ```
+ */
+ $httpBackend.verifyNoOutstandingExpectation = function(digest) {
+ if (digest !== false) $rootScope.$digest();
+ if (expectations.length) {
+ throw new Error('Unsatisfied requests: ' + expectations.join(', '));
+ }
+ };
+
+
+ /**
+ * @ngdoc method
+ * @name $httpBackend#verifyNoOutstandingRequest
+ * @description
+ * Verifies that there are no outstanding requests that need to be flushed.
+ *
+ * Typically, you would call this method following each test case that asserts requests using an
+ * "afterEach" clause.
+ *
+ * ```js
+ * afterEach($httpBackend.verifyNoOutstandingRequest);
+ * ```
+ */
+ $httpBackend.verifyNoOutstandingRequest = function() {
+ if (responses.length) {
+ throw new Error('Unflushed requests: ' + responses.length);
+ }
+ };
+
+
+ /**
+ * @ngdoc method
+ * @name $httpBackend#resetExpectations
+ * @description
+ * Resets all request expectations, but preserves all backend definitions. Typically, you would
+ * call resetExpectations during a multiple-phase test when you want to reuse the same instance of
+ * $httpBackend mock.
+ */
+ $httpBackend.resetExpectations = function() {
+ expectations.length = 0;
+ responses.length = 0;
+ };
+
+ return $httpBackend;
+
+
+ function createShortMethods(prefix) {
+ angular.forEach(['GET', 'DELETE', 'JSONP', 'HEAD'], function(method) {
+ $httpBackend[prefix + method] = function(url, headers) {
+ return $httpBackend[prefix](method, url, undefined, headers);
+ };
+ });
+
+ angular.forEach(['PUT', 'POST', 'PATCH'], function(method) {
+ $httpBackend[prefix + method] = function(url, data, headers) {
+ return $httpBackend[prefix](method, url, data, headers);
+ };
+ });
+ }
+}
+
+function MockHttpExpectation(method, url, data, headers) {
+
+ this.data = data;
+ this.headers = headers;
+
+ this.match = function(m, u, d, h) {
+ if (method != m) return false;
+ if (!this.matchUrl(u)) return false;
+ if (angular.isDefined(d) && !this.matchData(d)) return false;
+ if (angular.isDefined(h) && !this.matchHeaders(h)) return false;
+ return true;
+ };
+
+ this.matchUrl = function(u) {
+ if (!url) return true;
+ if (angular.isFunction(url.test)) return url.test(u);
+ if (angular.isFunction(url)) return url(u);
+ return url == u;
+ };
+
+ this.matchHeaders = function(h) {
+ if (angular.isUndefined(headers)) return true;
+ if (angular.isFunction(headers)) return headers(h);
+ return angular.equals(headers, h);
+ };
+
+ this.matchData = function(d) {
+ if (angular.isUndefined(data)) return true;
+ if (data && angular.isFunction(data.test)) return data.test(d);
+ if (data && angular.isFunction(data)) return data(d);
+ if (data && !angular.isString(data)) {
+ return angular.equals(angular.fromJson(angular.toJson(data)), angular.fromJson(d));
+ }
+ return data == d;
+ };
+
+ this.toString = function() {
+ return method + ' ' + url;
+ };
+}
+
+function createMockXhr() {
+ return new MockXhr();
+}
+
+function MockXhr() {
+
+ // hack for testing $http, $httpBackend
+ MockXhr.$$lastInstance = this;
+
+ this.open = function(method, url, async) {
+ this.$$method = method;
+ this.$$url = url;
+ this.$$async = async;
+ this.$$reqHeaders = {};
+ this.$$respHeaders = {};
+ };
+
+ this.send = function(data) {
+ this.$$data = data;
+ };
+
+ this.setRequestHeader = function(key, value) {
+ this.$$reqHeaders[key] = value;
+ };
+
+ this.getResponseHeader = function(name) {
+ // the lookup must be case insensitive,
+ // that's why we try two quick lookups first and full scan last
+ var header = this.$$respHeaders[name];
+ if (header) return header;
+
+ name = angular.lowercase(name);
+ header = this.$$respHeaders[name];
+ if (header) return header;
+
+ header = undefined;
+ angular.forEach(this.$$respHeaders, function(headerVal, headerName) {
+ if (!header && angular.lowercase(headerName) == name) header = headerVal;
+ });
+ return header;
+ };
+
+ this.getAllResponseHeaders = function() {
+ var lines = [];
+
+ angular.forEach(this.$$respHeaders, function(value, key) {
+ lines.push(key + ': ' + value);
+ });
+ return lines.join('\n');
+ };
+
+ this.abort = angular.noop;
+}
+
+
+/**
+ * @ngdoc service
+ * @name $timeout
+ * @description
+ *
+ * This service is just a simple decorator for {@link ng.$timeout $timeout} service
+ * that adds a "flush" and "verifyNoPendingTasks" methods.
+ */
+
+angular.mock.$TimeoutDecorator = ['$delegate', '$browser', function($delegate, $browser) {
+
+ /**
+ * @ngdoc method
+ * @name $timeout#flush
+ * @description
+ *
+ * Flushes the queue of pending tasks.
+ *
+ * @param {number=} delay maximum timeout amount to flush up until
+ */
+ $delegate.flush = function(delay) {
+ $browser.defer.flush(delay);
+ };
+
+ /**
+ * @ngdoc method
+ * @name $timeout#verifyNoPendingTasks
+ * @description
+ *
+ * Verifies that there are no pending tasks that need to be flushed.
+ */
+ $delegate.verifyNoPendingTasks = function() {
+ if ($browser.deferredFns.length) {
+ throw new Error('Deferred tasks to flush (' + $browser.deferredFns.length + '): ' +
+ formatPendingTasksAsString($browser.deferredFns));
+ }
+ };
+
+ function formatPendingTasksAsString(tasks) {
+ var result = [];
+ angular.forEach(tasks, function(task) {
+ result.push('{id: ' + task.id + ', ' + 'time: ' + task.time + '}');
+ });
+
+ return result.join(', ');
+ }
+
+ return $delegate;
+}];
+
+angular.mock.$RAFDecorator = ['$delegate', function($delegate) {
+ var queue = [];
+ var rafFn = function(fn) {
+ var index = queue.length;
+ queue.push(fn);
+ return function() {
+ queue.splice(index, 1);
+ };
+ };
+
+ rafFn.supported = $delegate.supported;
+
+ rafFn.flush = function() {
+ if (queue.length === 0) {
+ throw new Error('No rAF callbacks present');
+ }
+
+ var length = queue.length;
+ for (var i = 0; i < length; i++) {
+ queue[i]();
+ }
+
+ queue = [];
+ };
+
+ return rafFn;
+}];
+
+angular.mock.$AsyncCallbackDecorator = ['$delegate', function($delegate) {
+ var callbacks = [];
+ var addFn = function(fn) {
+ callbacks.push(fn);
+ };
+ addFn.flush = function() {
+ angular.forEach(callbacks, function(fn) {
+ fn();
+ });
+ callbacks = [];
+ };
+ return addFn;
+}];
+
+/**
+ *
+ */
+angular.mock.$RootElementProvider = function() {
+ this.$get = function() {
+ return angular.element('');
+ };
+};
+
+/**
+ * @ngdoc module
+ * @name ngMock
+ * @packageName angular-mocks
+ * @description
+ *
+ * # ngMock
+ *
+ * The `ngMock` module provides support to inject and mock Angular services into unit tests.
+ * In addition, ngMock also extends various core ng services such that they can be
+ * inspected and controlled in a synchronous manner within test code.
+ *
+ *
+ *
+ *
+ */
+angular.module('ngMock', ['ng']).provider({
+ $browser: angular.mock.$BrowserProvider,
+ $exceptionHandler: angular.mock.$ExceptionHandlerProvider,
+ $log: angular.mock.$LogProvider,
+ $interval: angular.mock.$IntervalProvider,
+ $httpBackend: angular.mock.$HttpBackendProvider,
+ $rootElement: angular.mock.$RootElementProvider
+}).config(['$provide', function($provide) {
+ $provide.decorator('$timeout', angular.mock.$TimeoutDecorator);
+ $provide.decorator('$$rAF', angular.mock.$RAFDecorator);
+ $provide.decorator('$$asyncCallback', angular.mock.$AsyncCallbackDecorator);
+ $provide.decorator('$rootScope', angular.mock.$RootScopeDecorator);
+}]);
+
+/**
+ * @ngdoc module
+ * @name ngMockE2E
+ * @module ngMockE2E
+ * @packageName angular-mocks
+ * @description
+ *
+ * The `ngMockE2E` is an angular module which contains mocks suitable for end-to-end testing.
+ * Currently there is only one mock present in this module -
+ * the {@link ngMockE2E.$httpBackend e2e $httpBackend} mock.
+ */
+angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
+ $provide.decorator('$httpBackend', angular.mock.e2e.$httpBackendDecorator);
+}]);
+
+/**
+ * @ngdoc service
+ * @name $httpBackend
+ * @module ngMockE2E
+ * @description
+ * Fake HTTP backend implementation suitable for end-to-end testing or backend-less development of
+ * applications that use the {@link ng.$http $http service}.
+ *
+ * *Note*: For fake http backend implementation suitable for unit testing please see
+ * {@link ngMock.$httpBackend unit-testing $httpBackend mock}.
+ *
+ * This implementation can be used to respond with static or dynamic responses via the `when` api
+ * and its shortcuts (`whenGET`, `whenPOST`, etc) and optionally pass through requests to the
+ * real $httpBackend for specific requests (e.g. to interact with certain remote apis or to fetch
+ * templates from a webserver).
+ *
+ * As opposed to unit-testing, in an end-to-end testing scenario or in scenario when an application
+ * is being developed with the real backend api replaced with a mock, it is often desirable for
+ * certain category of requests to bypass the mock and issue a real http request (e.g. to fetch
+ * templates or static files from the webserver). To configure the backend with this behavior
+ * use the `passThrough` request handler of `when` instead of `respond`.
+ *
+ * Additionally, we don't want to manually have to flush mocked out requests like we do during unit
+ * testing. For this reason the e2e $httpBackend flushes mocked out requests
+ * automatically, closely simulating the behavior of the XMLHttpRequest object.
+ *
+ * To setup the application to run with this http backend, you have to create a module that depends
+ * on the `ngMockE2E` and your application modules and defines the fake backend:
+ *
+ * ```js
+ * myAppDev = angular.module('myAppDev', ['myApp', 'ngMockE2E']);
+ * myAppDev.run(function($httpBackend) {
+ * phones = [{name: 'phone1'}, {name: 'phone2'}];
+ *
+ * // returns the current list of phones
+ * $httpBackend.whenGET('/phones').respond(phones);
+ *
+ * // adds a new phone to the phones array
+ * $httpBackend.whenPOST('/phones').respond(function(method, url, data) {
+ * var phone = angular.fromJson(data);
+ * phones.push(phone);
+ * return [200, phone, {}];
+ * });
+ * $httpBackend.whenGET(/^\/templates\//).passThrough();
+ * //...
+ * });
+ * ```
+ *
+ * Afterwards, bootstrap your app with this new module.
+ */
+
+/**
+ * @ngdoc method
+ * @name $httpBackend#when
+ * @module ngMockE2E
+ * @description
+ * Creates a new backend definition.
+ *
+ * @param {string} method HTTP method.
+ * @param {string|RegExp|function(string)} url HTTP url or function that receives the url
+ * and returns true if the url match the current definition.
+ * @param {(string|RegExp)=} data HTTP request body.
+ * @param {(Object|function(Object))=} headers HTTP headers or function that receives http header
+ * object and returns true if the headers match the current definition.
+ * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that
+ * control how a matched request is handled. You can save this object for later use and invoke
+ * `respond` or `passThrough` again in order to change how a matched request is handled.
+ *
+ * - respond –
+ * `{function([status,] data[, headers, statusText])
+ * | function(function(method, url, data, headers)}`
+ * – The respond method takes a set of static data to be returned or a function that can return
+ * an array containing response status (number), response data (string), response headers
+ * (Object), and the text for the status (string).
+ * - passThrough – `{function()}` – Any request matching a backend definition with
+ * `passThrough` handler will be passed through to the real backend (an XHR request will be made
+ * to the server.)
+ * - Both methods return the `requestHandler` object for possible overrides.
+ */
+
+/**
+ * @ngdoc method
+ * @name $httpBackend#whenGET
+ * @module ngMockE2E
+ * @description
+ * Creates a new backend definition for GET requests. For more info see `when()`.
+ *
+ * @param {string|RegExp|function(string)} url HTTP url or function that receives the url
+ * and returns true if the url match the current definition.
+ * @param {(Object|function(Object))=} headers HTTP headers.
+ * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that
+ * control how a matched request is handled. You can save this object for later use and invoke
+ * `respond` or `passThrough` again in order to change how a matched request is handled.
+ */
+
+/**
+ * @ngdoc method
+ * @name $httpBackend#whenHEAD
+ * @module ngMockE2E
+ * @description
+ * Creates a new backend definition for HEAD requests. For more info see `when()`.
+ *
+ * @param {string|RegExp|function(string)} url HTTP url or function that receives the url
+ * and returns true if the url match the current definition.
+ * @param {(Object|function(Object))=} headers HTTP headers.
+ * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that
+ * control how a matched request is handled. You can save this object for later use and invoke
+ * `respond` or `passThrough` again in order to change how a matched request is handled.
+ */
+
+/**
+ * @ngdoc method
+ * @name $httpBackend#whenDELETE
+ * @module ngMockE2E
+ * @description
+ * Creates a new backend definition for DELETE requests. For more info see `when()`.
+ *
+ * @param {string|RegExp|function(string)} url HTTP url or function that receives the url
+ * and returns true if the url match the current definition.
+ * @param {(Object|function(Object))=} headers HTTP headers.
+ * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that
+ * control how a matched request is handled. You can save this object for later use and invoke
+ * `respond` or `passThrough` again in order to change how a matched request is handled.
+ */
+
+/**
+ * @ngdoc method
+ * @name $httpBackend#whenPOST
+ * @module ngMockE2E
+ * @description
+ * Creates a new backend definition for POST requests. For more info see `when()`.
+ *
+ * @param {string|RegExp|function(string)} url HTTP url or function that receives the url
+ * and returns true if the url match the current definition.
+ * @param {(string|RegExp)=} data HTTP request body.
+ * @param {(Object|function(Object))=} headers HTTP headers.
+ * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that
+ * control how a matched request is handled. You can save this object for later use and invoke
+ * `respond` or `passThrough` again in order to change how a matched request is handled.
+ */
+
+/**
+ * @ngdoc method
+ * @name $httpBackend#whenPUT
+ * @module ngMockE2E
+ * @description
+ * Creates a new backend definition for PUT requests. For more info see `when()`.
+ *
+ * @param {string|RegExp|function(string)} url HTTP url or function that receives the url
+ * and returns true if the url match the current definition.
+ * @param {(string|RegExp)=} data HTTP request body.
+ * @param {(Object|function(Object))=} headers HTTP headers.
+ * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that
+ * control how a matched request is handled. You can save this object for later use and invoke
+ * `respond` or `passThrough` again in order to change how a matched request is handled.
+ */
+
+/**
+ * @ngdoc method
+ * @name $httpBackend#whenPATCH
+ * @module ngMockE2E
+ * @description
+ * Creates a new backend definition for PATCH requests. For more info see `when()`.
+ *
+ * @param {string|RegExp|function(string)} url HTTP url or function that receives the url
+ * and returns true if the url match the current definition.
+ * @param {(string|RegExp)=} data HTTP request body.
+ * @param {(Object|function(Object))=} headers HTTP headers.
+ * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that
+ * control how a matched request is handled. You can save this object for later use and invoke
+ * `respond` or `passThrough` again in order to change how a matched request is handled.
+ */
+
+/**
+ * @ngdoc method
+ * @name $httpBackend#whenJSONP
+ * @module ngMockE2E
+ * @description
+ * Creates a new backend definition for JSONP requests. For more info see `when()`.
+ *
+ * @param {string|RegExp|function(string)} url HTTP url or function that receives the url
+ * and returns true if the url match the current definition.
+ * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that
+ * control how a matched request is handled. You can save this object for later use and invoke
+ * `respond` or `passThrough` again in order to change how a matched request is handled.
+ */
+angular.mock.e2e = {};
+angular.mock.e2e.$httpBackendDecorator =
+ ['$rootScope', '$timeout', '$delegate', '$browser', createHttpBackendMock];
+
+
+/**
+ * @ngdoc type
+ * @name $rootScope.Scope
+ * @module ngMock
+ * @description
+ * {@link ng.$rootScope.Scope Scope} type decorated with helper methods useful for testing. These
+ * methods are automatically available on any {@link ng.$rootScope.Scope Scope} instance when
+ * `ngMock` module is loaded.
+ *
+ * In addition to all the regular `Scope` methods, the following helper methods are available:
+ */
+angular.mock.$RootScopeDecorator = ['$delegate', function($delegate) {
+
+ var $rootScopePrototype = Object.getPrototypeOf($delegate);
+
+ $rootScopePrototype.$countChildScopes = countChildScopes;
+ $rootScopePrototype.$countWatchers = countWatchers;
+
+ return $delegate;
+
+ // ------------------------------------------------------------------------------------------ //
+
+ /**
+ * @ngdoc method
+ * @name $rootScope.Scope#$countChildScopes
+ * @module ngMock
+ * @description
+ * Counts all the direct and indirect child scopes of the current scope.
+ *
+ * The current scope is excluded from the count. The count includes all isolate child scopes.
+ *
+ * @returns {number} Total number of child scopes.
+ */
+ function countChildScopes() {
+ // jshint validthis: true
+ var count = 0; // exclude the current scope
+ var pendingChildHeads = [this.$$childHead];
+ var currentScope;
+
+ while (pendingChildHeads.length) {
+ currentScope = pendingChildHeads.shift();
+
+ while (currentScope) {
+ count += 1;
+ pendingChildHeads.push(currentScope.$$childHead);
+ currentScope = currentScope.$$nextSibling;
+ }
+ }
+
+ return count;
+ }
+
+
+ /**
+ * @ngdoc method
+ * @name $rootScope.Scope#$countWatchers
+ * @module ngMock
+ * @description
+ * Counts all the watchers of direct and indirect child scopes of the current scope.
+ *
+ * The watchers of the current scope are included in the count and so are all the watchers of
+ * isolate child scopes.
+ *
+ * @returns {number} Total number of watchers.
+ */
+ function countWatchers() {
+ // jshint validthis: true
+ var count = this.$$watchers ? this.$$watchers.length : 0; // include the current scope
+ var pendingChildHeads = [this.$$childHead];
+ var currentScope;
+
+ while (pendingChildHeads.length) {
+ currentScope = pendingChildHeads.shift();
+
+ while (currentScope) {
+ count += currentScope.$$watchers ? currentScope.$$watchers.length : 0;
+ pendingChildHeads.push(currentScope.$$childHead);
+ currentScope = currentScope.$$nextSibling;
+ }
+ }
+
+ return count;
+ }
+}];
+
+
+if (window.jasmine || window.mocha) {
+
+ var currentSpec = null,
+ annotatedFunctions = [],
+ isSpecRunning = function() {
+ return !!currentSpec;
+ };
+
+ angular.mock.$$annotate = angular.injector.$$annotate;
+ angular.injector.$$annotate = function(fn) {
+ if (typeof fn === 'function' && !fn.$inject) {
+ annotatedFunctions.push(fn);
+ }
+ return angular.mock.$$annotate.apply(this, arguments);
+ };
+
+
+ (window.beforeEach || window.setup)(function() {
+ annotatedFunctions = [];
+ currentSpec = this;
+ });
+
+ (window.afterEach || window.teardown)(function() {
+ var injector = currentSpec.$injector;
+
+ annotatedFunctions.forEach(function(fn) {
+ delete fn.$inject;
+ });
+
+ angular.forEach(currentSpec.$modules, function(module) {
+ if (module && module.$$hashKey) {
+ module.$$hashKey = undefined;
+ }
+ });
+
+ currentSpec.$injector = null;
+ currentSpec.$modules = null;
+ currentSpec = null;
+
+ if (injector) {
+ injector.get('$rootElement').off();
+ injector.get('$browser').pollFns.length = 0;
+ }
+
+ // clean up jquery's fragment cache
+ angular.forEach(angular.element.fragments, function(val, key) {
+ delete angular.element.fragments[key];
+ });
+
+ MockXhr.$$lastInstance = null;
+
+ angular.forEach(angular.callbacks, function(val, key) {
+ delete angular.callbacks[key];
+ });
+ angular.callbacks.counter = 0;
+ });
+
+ /**
+ * @ngdoc function
+ * @name angular.mock.module
+ * @description
+ *
+ * *NOTE*: This function is also published on window for easy access.
+ * Request expectations Backend definitions
+ *
+ * Syntax
+ * .expect(...).respond(...)
+ * .when(...).respond(...)
+ *
+ *
+ * Typical usage
+ * strict unit tests
+ * loose (black-box) unit testing
+ *
+ *
+ * Fulfills multiple requests
+ * NO
+ * YES
+ *
+ *
+ * Order of requests matters
+ * YES
+ * NO
+ *
+ *
+ * Request required
+ * YES
+ * NO
+ *
+ *
+ * Response required
+ * optional (see below)
+ * YES
+ *
+ * *NOTE*: This function is declared ONLY WHEN running tests with jasmine or mocha
+ *
+ * This function registers a module configuration code. It collects the configuration information
+ * which will be used when the injector is created by {@link angular.mock.inject inject}.
+ *
+ * See {@link angular.mock.inject inject} for usage example
+ *
+ * @param {...(string|Function|Object)} fns any number of modules which are represented as string
+ * aliases or as anonymous module initialization functions. The modules are used to
+ * configure the injector. The 'ng' and 'ngMock' modules are automatically loaded. If an
+ * object literal is passed they will be registered as values in the module, the key being
+ * the module name and the value being what is returned.
+ */
+ window.module = angular.mock.module = function() {
+ var moduleFns = Array.prototype.slice.call(arguments, 0);
+ return isSpecRunning() ? workFn() : workFn;
+ /////////////////////
+ function workFn() {
+ if (currentSpec.$injector) {
+ throw new Error('Injector already created, can not register a module!');
+ } else {
+ var modules = currentSpec.$modules || (currentSpec.$modules = []);
+ angular.forEach(moduleFns, function(module) {
+ if (angular.isObject(module) && !angular.isArray(module)) {
+ modules.push(function($provide) {
+ angular.forEach(module, function(value, key) {
+ $provide.value(key, value);
+ });
+ });
+ } else {
+ modules.push(module);
+ }
+ });
+ }
+ }
+ };
+
+ /**
+ * @ngdoc function
+ * @name angular.mock.inject
+ * @description
+ *
+ * *NOTE*: This function is also published on window for easy access.
+ * *NOTE*: This function is declared ONLY WHEN running tests with jasmine or mocha
+ *
+ * The inject function wraps a function into an injectable function. The inject() creates new
+ * instance of {@link auto.$injector $injector} per test, which is then used for
+ * resolving references.
+ *
+ *
+ * ## Resolving References (Underscore Wrapping)
+ * Often, we would like to inject a reference once, in a `beforeEach()` block and reuse this
+ * in multiple `it()` clauses. To be able to do this we must assign the reference to a variable
+ * that is declared in the scope of the `describe()` block. Since we would, most likely, want
+ * the variable to have the same name of the reference we have a problem, since the parameter
+ * to the `inject()` function would hide the outer variable.
+ *
+ * To help with this, the injected parameters can, optionally, be enclosed with underscores.
+ * These are ignored by the injector when the reference name is resolved.
+ *
+ * For example, the parameter `_myService_` would be resolved as the reference `myService`.
+ * Since it is available in the function body as _myService_, we can then assign it to a variable
+ * defined in an outer scope.
+ *
+ * ```
+ * // Defined out reference variable outside
+ * var myService;
+ *
+ * // Wrap the parameter in underscores
+ * beforeEach( inject( function(_myService_){
+ * myService = _myService_;
+ * }));
+ *
+ * // Use myService in a series of tests.
+ * it('makes use of myService', function() {
+ * myService.doStuff();
+ * });
+ *
+ * ```
+ *
+ * See also {@link angular.mock.module angular.mock.module}
+ *
+ * ## Example
+ * Example of what a typical jasmine tests looks like with the inject method.
+ * ```js
+ *
+ * angular.module('myApplicationModule', [])
+ * .value('mode', 'app')
+ * .value('version', 'v1.0.1');
+ *
+ *
+ * describe('MyApp', function() {
+ *
+ * // You need to load modules that you want to test,
+ * // it loads only the "ng" module by default.
+ * beforeEach(module('myApplicationModule'));
+ *
+ *
+ * // inject() is used to inject arguments of all given functions
+ * it('should provide a version', inject(function(mode, version) {
+ * expect(version).toEqual('v1.0.1');
+ * expect(mode).toEqual('app');
+ * }));
+ *
+ *
+ * // The inject and module method can also be used inside of the it or beforeEach
+ * it('should override a version and test the new version is injected', function() {
+ * // module() takes functions or strings (module aliases)
+ * module(function($provide) {
+ * $provide.value('version', 'overridden'); // override version here
+ * });
+ *
+ * inject(function(version) {
+ * expect(version).toEqual('overridden');
+ * });
+ * });
+ * });
+ *
+ * ```
+ *
+ * @param {...Function} fns any number of functions which will be injected using the injector.
+ */
+
+
+
+ var ErrorAddingDeclarationLocationStack = function(e, errorForStack) {
+ this.message = e.message;
+ this.name = e.name;
+ if (e.line) this.line = e.line;
+ if (e.sourceId) this.sourceId = e.sourceId;
+ if (e.stack && errorForStack)
+ this.stack = e.stack + '\n' + errorForStack.stack;
+ if (e.stackArray) this.stackArray = e.stackArray;
+ };
+ ErrorAddingDeclarationLocationStack.prototype.toString = Error.prototype.toString;
+
+ window.inject = angular.mock.inject = function() {
+ var blockFns = Array.prototype.slice.call(arguments, 0);
+ var errorForStack = new Error('Declaration Location');
+ return isSpecRunning() ? workFn.call(currentSpec) : workFn;
+ /////////////////////
+ function workFn() {
+ var modules = currentSpec.$modules || [];
+ var strictDi = !!currentSpec.$injectorStrict;
+ modules.unshift('ngMock');
+ modules.unshift('ng');
+ var injector = currentSpec.$injector;
+ if (!injector) {
+ if (strictDi) {
+ // If strictDi is enabled, annotate the providerInjector blocks
+ angular.forEach(modules, function(moduleFn) {
+ if (typeof moduleFn === "function") {
+ angular.injector.$$annotate(moduleFn);
+ }
+ });
+ }
+ injector = currentSpec.$injector = angular.injector(modules, strictDi);
+ currentSpec.$injectorStrict = strictDi;
+ }
+ for (var i = 0, ii = blockFns.length; i < ii; i++) {
+ if (currentSpec.$injectorStrict) {
+ // If the injector is strict / strictDi, and the spec wants to inject using automatic
+ // annotation, then annotate the function here.
+ injector.annotate(blockFns[i]);
+ }
+ try {
+ /* jshint -W040 *//* Jasmine explicitly provides a `this` object when calling functions */
+ injector.invoke(blockFns[i] || angular.noop, this);
+ /* jshint +W040 */
+ } catch (e) {
+ if (e.stack && errorForStack) {
+ throw new ErrorAddingDeclarationLocationStack(e, errorForStack);
+ }
+ throw e;
+ } finally {
+ errorForStack = null;
+ }
+ }
+ }
+ };
+
+
+ angular.mock.inject.strictDi = function(value) {
+ value = arguments.length ? !!value : true;
+ return isSpecRunning() ? workFn() : workFn;
+
+ function workFn() {
+ if (value !== currentSpec.$injectorStrict) {
+ if (currentSpec.$injector) {
+ throw new Error('Injector already created, can not modify strict annotations');
+ } else {
+ currentSpec.$injectorStrict = value;
+ }
+ }
+ }
+ };
+}
+
+
+})(window, window.angular);
diff --git a/client/www/lib/angular-mocks/bower.json b/client/www/lib/angular-mocks/bower.json
new file mode 100644
index 0000000..953ed68
--- /dev/null
+++ b/client/www/lib/angular-mocks/bower.json
@@ -0,0 +1,9 @@
+{
+ "name": "angular-mocks",
+ "version": "1.3.13",
+ "main": "./angular-mocks.js",
+ "ignore": [],
+ "dependencies": {
+ "angular": "1.3.13"
+ }
+}
diff --git a/client/www/lib/angular-mocks/package.json b/client/www/lib/angular-mocks/package.json
new file mode 100644
index 0000000..19207e3
--- /dev/null
+++ b/client/www/lib/angular-mocks/package.json
@@ -0,0 +1,27 @@
+{
+ "name": "angular-mocks",
+ "version": "1.3.13",
+ "description": "AngularJS mocks for testing",
+ "main": "angular-mocks.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/angular/angular.js.git"
+ },
+ "keywords": [
+ "angular",
+ "framework",
+ "browser",
+ "mocks",
+ "testing",
+ "client-side"
+ ],
+ "author": "Angular Core Team
+
+
+
+ Directive
+ How
+ Source
+ Rendered
+
+
+ ng-bind-html
+ Automatically uses $sanitize
+
+ <div ng-bind-html="snippet">
</div>
+
+
+ ng-bind-html
+ Bypass $sanitize by explicitly trusting the dangerous value
+
+
+ <div ng-bind-html="deliberatelyTrustDangerousSnippet()">
+</div>
+
+
+
+ ng-bind
+ Automatically escapes
+
+ <div ng-bind="snippet">
</div>
+
+
+
+
+
+ Filter
+ Source
+ Rendered
+
+
+ linky filter
+
+
+ <div ng-bind-html="snippet | linky">
+
</div>
+
+
+
+
+ linky target
+
+
+ <div ng-bind-html="snippetWithTarget | linky:'_blank'">
+
</div>
+
+
+
+
+ no filter
+
+ <div ng-bind="snippet">
</div>
+ grunt >= 0.4.x. Make sure to upgrade your environment and read the
+[Migration Guide](http://gruntjs.com/upgrading-from-0.3-to-0.4).
+
+Dependencies for building from source and running tests:
+
+* [grunt-cli](https://github.com/gruntjs/grunt-cli) - run: `$ npm install -g grunt-cli`
+* Then, install the development dependencies by running `$ npm install` from the project directory
+
+There are a number of targets in the gruntfile that are used to generating different builds:
+
+* `grunt`: Perform a normal build, runs jshint and karma tests
+* `grunt build`: Perform a normal build
+* `grunt dist`: Perform a clean build and generate documentation
+* `grunt dev`: Run dev server (sample app) and watch for changes, builds and runs karma tests on changes.
diff --git a/client/www/lib/angular-ui-router/LICENSE b/client/www/lib/angular-ui-router/LICENSE
new file mode 100644
index 0000000..939f8f8
--- /dev/null
+++ b/client/www/lib/angular-ui-router/LICENSE
@@ -0,0 +1,21 @@
+The MIT License
+
+Copyright (c) 2014 The AngularUI Team, Karsten Sperling
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/client/www/lib/angular-ui-router/README.md b/client/www/lib/angular-ui-router/README.md
new file mode 100644
index 0000000..f02d83b
--- /dev/null
+++ b/client/www/lib/angular-ui-router/README.md
@@ -0,0 +1,243 @@
+# AngularUI Router [](https://travis-ci.org/angular-ui/ui-router)
+
+#### The de-facto solution to flexible routing with nested views
+---
+**[Download 0.2.11](http://angular-ui.github.io/ui-router/release/angular-ui-router.js)** (or **[Minified](http://angular-ui.github.io/ui-router/release/angular-ui-router.min.js)**) **|**
+**[Guide](https://github.com/angular-ui/ui-router/wiki) |**
+**[API](http://angular-ui.github.io/ui-router/site) |**
+**[Sample](http://angular-ui.github.com/ui-router/sample/) ([Src](https://github.com/angular-ui/ui-router/tree/gh-pages/sample)) |**
+**[FAQ](https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions) |**
+**[Resources](#resources) |**
+**[Report an Issue](https://github.com/angular-ui/ui-router/blob/master/CONTRIBUTING.md#report-an-issue) |**
+**[Contribute](https://github.com/angular-ui/ui-router/blob/master/CONTRIBUTING.md#contribute) |**
+**[Help!](http://stackoverflow.com/questions/ask?tags=angularjs,angular-ui-router) |**
+**[Discuss](https://groups.google.com/forum/#!categories/angular-ui/router)**
+
+---
+
+AngularUI Router is a routing framework for [AngularJS](http://angularjs.org), which allows you to organize the
+parts of your interface into a [*state machine*](https://en.wikipedia.org/wiki/Finite-state_machine). Unlike the
+[`$route` service](http://docs.angularjs.org/api/ngRoute.$route) in the Angular ngRoute module, which is organized around URL
+routes, UI-Router is organized around [*states*](https://github.com/angular-ui/ui-router/wiki),
+which may optionally have routes, as well as other behavior, attached.
+
+States are bound to *named*, *nested* and *parallel views*, allowing you to powerfully manage your application's interface.
+
+Check out the sample app: http://angular-ui.github.io/ui-router/sample/
+
+-
+**Note:** *UI-Router is under active development. As such, while this library is well-tested, the API may change. Consider using it in production applications only if you're comfortable following a changelog and updating your usage accordingly.*
+
+
+## Get Started
+
+**(1)** Get UI-Router in one of the following ways:
+ - clone & [build](CONTRIBUTING.md#developing) this repository
+ - [download the release](http://angular-ui.github.io/ui-router/release/angular-ui-router.js) (or [minified](http://angular-ui.github.io/ui-router/release/angular-ui-router.min.js))
+ - via **[Bower](http://bower.io/)**: by running `$ bower install angular-ui-router` from your console
+ - or via **[npm](https://www.npmjs.org/)**: by running `$ npm install angular-ui-router` from your console
+ - or via **[Component](https://github.com/component/component)**: by running `$ component install angular-ui/ui-router` from your console
+
+**(2)** Include `angular-ui-router.js` (or `angular-ui-router.min.js`) in your `index.html`, after including Angular itself (For Component users: ignore this step)
+
+**(3)** Add `'ui.router'` to your main module's list of dependencies (For Component users: replace `'ui.router'` with `require('angular-ui-router')`)
+
+When you're done, your setup should look similar to the following:
+
+>
+```html
+
+
+
+
+
+
+ ...
+
+
+ ...
+
+
+```
+
+### [Nested States & Views](http://plnkr.co/edit/u18KQc?p=preview)
+
+The majority of UI-Router's power is in its ability to nest states & views.
+
+**(1)** First, follow the [setup](#get-started) instructions detailed above.
+
+**(2)** Then, add a [`ui-view` directive](https://github.com/angular-ui/ui-router/wiki/Quick-Reference#ui-view) to the `State 1
+
+Show List
+
+```
+```html
+
+State 2
+
+Show List
+
+```
+
+**(4)** Next, we'll add some child templates. *These* will get plugged into the `ui-view` of their parent state templates.
+
+>
+```html
+
+List of State 1 Items
+
+
+```
+
+>
+```html
+
+List of State 2 Things
+
+
+```
+
+**(5)** Finally, we'll wire it all up with `$stateProvider`. Set up your states in the module config, as in the following:
+
+
+>
+```javascript
+myApp.config(function($stateProvider, $urlRouterProvider) {
+ //
+ // For any unmatched url, redirect to /state1
+ $urlRouterProvider.otherwise("/state1");
+ //
+ // Now set up the states
+ $stateProvider
+ .state('state1', {
+ url: "/state1",
+ templateUrl: "partials/state1.html"
+ })
+ .state('state1.list', {
+ url: "/list",
+ templateUrl: "partials/state1.list.html",
+ controller: function($scope) {
+ $scope.items = ["A", "List", "Of", "Items"];
+ }
+ })
+ .state('state2', {
+ url: "/state2",
+ templateUrl: "partials/state2.html"
+ })
+ .state('state2.list', {
+ url: "/list",
+ templateUrl: "partials/state2.list.html",
+ controller: function($scope) {
+ $scope.things = ["A", "Set", "Of", "Things"];
+ }
+ });
+});
+```
+
+**(6)** See this quick start example in action.
+>**[Go to Quick Start Plunker for Nested States & Views](http://plnkr.co/edit/u18KQc?p=preview)**
+
+**(7)** This only scratches the surface
+>**[Dive Deeper!](https://github.com/angular-ui/ui-router/wiki)**
+
+
+### [Multiple & Named Views](http://plnkr.co/edit/SDOcGS?p=preview)
+
+Another great feature is the ability to have multiple `ui-view`s view per template.
+
+**Pro Tip:** *While multiple parallel views are a powerful feature, you'll often be able to manage your
+interfaces more effectively by nesting your views, and pairing those views with nested states.*
+
+**(1)** Follow the [setup](#get-started) instructions detailed above.
+
+**(2)** Add one or more `ui-view` to your app, give them names.
+>
+```html
+
+
+
+
+
+ Route 1
+ Route 2
+
+```
+
+**(3)** Set up your states in the module config:
+>
+```javascript
+myApp.config(function($stateProvider) {
+ $stateProvider
+ .state('index', {
+ url: "",
+ views: {
+ "viewA": { template: "index.viewA" },
+ "viewB": { template: "index.viewB" }
+ }
+ })
+ .state('route1', {
+ url: "/route1",
+ views: {
+ "viewA": { template: "route1.viewA" },
+ "viewB": { template: "route1.viewB" }
+ }
+ })
+ .state('route2', {
+ url: "/route2",
+ views: {
+ "viewA": { template: "route2.viewA" },
+ "viewB": { template: "route2.viewB" }
+ }
+ })
+});
+```
+
+**(4)** See this quick start example in action.
+>**[Go to Quick Start Plunker for Multiple & Named Views](http://plnkr.co/edit/SDOcGS?p=preview)**
+
+
+## Resources
+
+* [In-Depth Guide](https://github.com/angular-ui/ui-router/wiki)
+* [API Reference](http://angular-ui.github.io/ui-router/site)
+* [Sample App](http://angular-ui.github.com/ui-router/sample/) ([Source](https://github.com/angular-ui/ui-router/tree/gh-pages/sample))
+* [FAQ](https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions)
+* [Slides comparing ngRoute to ui-router](http://slid.es/timkindberg/ui-router#/)
+* [UI-Router Extras / Addons](http://christopherthielen.github.io/ui-router-extras/#/home) (@christopherthielen)
+
+### Videos
+
+* [Introduction Video](https://egghead.io/lessons/angularjs-introduction-ui-router) (egghead.io)
+* [Tim Kindberg on Angular UI-Router](https://www.youtube.com/watch?v=lBqiZSemrqg)
+* [Activating States](https://egghead.io/lessons/angularjs-ui-router-activating-states) (egghead.io)
+* [Learn Angular.js using UI-Router](http://youtu.be/QETUuZ27N0w) (LearnCode.academy)
+
+
+
+## Reporting issues and Contributing
+
+Please read our [Contributor guidelines](CONTRIBUTING.md) before reporting an issue or creating a pull request.
diff --git a/client/www/lib/angular-ui-router/api/angular-ui-router.d.ts b/client/www/lib/angular-ui-router/api/angular-ui-router.d.ts
new file mode 100644
index 0000000..55c5d5e
--- /dev/null
+++ b/client/www/lib/angular-ui-router/api/angular-ui-router.d.ts
@@ -0,0 +1,126 @@
+// Type definitions for Angular JS 1.1.5+ (ui.router module)
+// Project: https://github.com/angular-ui/ui-router
+// Definitions by: Michel Salib
+ * $resolve.study(invocables)(locals, parent, self)
+ *
+ * is equivalent to
+ *
+ * $resolve.resolve(invocables, locals, parent, self)
+ *
+ * but the former is more efficient (in fact `resolve` just calls `study`
+ * internally).
+ *
+ * @param {object} invocables Invocable objects
+ * @return {function} a function to pass in locals, parent and self
+ */
+ this.study = function (invocables) {
+ if (!isObject(invocables)) throw new Error("'invocables' must be an object");
+ var invocableKeys = objectKeys(invocables || {});
+
+ // Perform a topological sort of invocables to build an ordered plan
+ var plan = [], cycle = [], visited = {};
+ function visit(value, key) {
+ if (visited[key] === VISIT_DONE) return;
+
+ cycle.push(key);
+ if (visited[key] === VISIT_IN_PROGRESS) {
+ cycle.splice(0, indexOf(cycle, key));
+ throw new Error("Cyclic dependency: " + cycle.join(" -> "));
+ }
+ visited[key] = VISIT_IN_PROGRESS;
+
+ if (isString(value)) {
+ plan.push(key, [ function() { return $injector.get(value); }], NO_DEPENDENCIES);
+ } else {
+ var params = $injector.annotate(value);
+ forEach(params, function (param) {
+ if (param !== key && invocables.hasOwnProperty(param)) visit(invocables[param], param);
+ });
+ plan.push(key, value, params);
+ }
+
+ cycle.pop();
+ visited[key] = VISIT_DONE;
+ }
+ forEach(invocables, visit);
+ invocables = cycle = visited = null; // plan is all that's required
+
+ function isResolve(value) {
+ return isObject(value) && value.then && value.$$promises;
+ }
+
+ return function (locals, parent, self) {
+ if (isResolve(locals) && self === undefined) {
+ self = parent; parent = locals; locals = null;
+ }
+ if (!locals) locals = NO_LOCALS;
+ else if (!isObject(locals)) {
+ throw new Error("'locals' must be an object");
+ }
+ if (!parent) parent = NO_PARENT;
+ else if (!isResolve(parent)) {
+ throw new Error("'parent' must be a promise returned by $resolve.resolve()");
+ }
+
+ // To complete the overall resolution, we have to wait for the parent
+ // promise and for the promise for each invokable in our plan.
+ var resolution = $q.defer(),
+ result = resolution.promise,
+ promises = result.$$promises = {},
+ values = extend({}, locals),
+ wait = 1 + plan.length/3,
+ merged = false;
+
+ function done() {
+ // Merge parent values we haven't got yet and publish our own $$values
+ if (!--wait) {
+ if (!merged) merge(values, parent.$$values);
+ result.$$values = values;
+ result.$$promises = result.$$promises || true; // keep for isResolve()
+ delete result.$$inheritedValues;
+ resolution.resolve(values);
+ }
+ }
+
+ function fail(reason) {
+ result.$$failure = reason;
+ resolution.reject(reason);
+ }
+
+ // Short-circuit if parent has already failed
+ if (isDefined(parent.$$failure)) {
+ fail(parent.$$failure);
+ return result;
+ }
+
+ if (parent.$$inheritedValues) {
+ merge(values, omit(parent.$$inheritedValues, invocableKeys));
+ }
+
+ // Merge parent values if the parent has already resolved, or merge
+ // parent promises and wait if the parent resolve is still in progress.
+ extend(promises, parent.$$promises);
+ if (parent.$$values) {
+ merged = merge(values, omit(parent.$$values, invocableKeys));
+ result.$$inheritedValues = omit(parent.$$values, invocableKeys);
+ done();
+ } else {
+ if (parent.$$inheritedValues) {
+ result.$$inheritedValues = omit(parent.$$inheritedValues, invocableKeys);
+ }
+ parent.then(done, fail);
+ }
+
+ // Process each invocable in the plan, but ignore any where a local of the same name exists.
+ for (var i=0, ii=plan.length; i
+ * new UrlMatcher('/user/{id}?q').concat('/details?date');
+ * new UrlMatcher('/user/{id}/details?q&date');
+ *
+ *
+ * @param {string} pattern The pattern to append.
+ * @param {Object} config An object hash of the configuration for the matcher.
+ * @returns {UrlMatcher} A matcher for the concatenated pattern.
+ */
+UrlMatcher.prototype.concat = function (pattern, config) {
+ // Because order of search parameters is irrelevant, we can add our own search
+ // parameters to the end of the new pattern. Parse the new pattern by itself
+ // and then join the bits together, but it's much easier to do this on a string level.
+ var defaultConfig = {
+ caseInsensitive: $$UMFP.caseInsensitive(),
+ strict: $$UMFP.strictMode(),
+ squash: $$UMFP.defaultSquashPolicy()
+ };
+ return new UrlMatcher(this.sourcePath + pattern + this.sourceSearch, extend(defaultConfig, config), this);
+};
+
+UrlMatcher.prototype.toString = function () {
+ return this.source;
+};
+
+/**
+ * @ngdoc function
+ * @name ui.router.util.type:UrlMatcher#exec
+ * @methodOf ui.router.util.type:UrlMatcher
+ *
+ * @description
+ * Tests the specified path against this matcher, and returns an object containing the captured
+ * parameter values, or null if the path does not match. The returned object contains the values
+ * of any search parameters that are mentioned in the pattern, but their value may be null if
+ * they are not present in `searchParams`. This means that search parameters are always treated
+ * as optional.
+ *
+ * @example
+ *
+ * new UrlMatcher('/user/{id}?q&r').exec('/user/bob', {
+ * x: '1', q: 'hello'
+ * });
+ * // returns { id: 'bob', q: 'hello', r: null }
+ *
+ *
+ * @param {string} path The URL path to match, e.g. `$location.path()`.
+ * @param {Object} searchParams URL search parameters, e.g. `$location.search()`.
+ * @returns {Object} The captured parameter values.
+ */
+UrlMatcher.prototype.exec = function (path, searchParams) {
+ var m = this.regexp.exec(path);
+ if (!m) return null;
+ searchParams = searchParams || {};
+
+ var paramNames = this.parameters(), nTotal = paramNames.length,
+ nPath = this.segments.length - 1,
+ values = {}, i, j, cfg, paramName;
+
+ if (nPath !== m.length - 1) throw new Error("Unbalanced capture group in route '" + this.source + "'");
+
+ function decodePathArray(string) {
+ function reverseString(str) { return str.split("").reverse().join(""); }
+ function unquoteDashes(str) { return str.replace(/\\-/, "-"); }
+
+ var split = reverseString(string).split(/-(?!\\)/);
+ var allReversed = map(split, reverseString);
+ return map(allReversed, unquoteDashes).reverse();
+ }
+
+ for (i = 0; i < nPath; i++) {
+ paramName = paramNames[i];
+ var param = this.params[paramName];
+ var paramVal = m[i+1];
+ // if the param value matches a pre-replace pair, replace the value before decoding.
+ for (j = 0; j < param.replace; j++) {
+ if (param.replace[j].from === paramVal) paramVal = param.replace[j].to;
+ }
+ if (paramVal && param.array === true) paramVal = decodePathArray(paramVal);
+ values[paramName] = param.value(paramVal);
+ }
+ for (/**/; i < nTotal; i++) {
+ paramName = paramNames[i];
+ values[paramName] = this.params[paramName].value(searchParams[paramName]);
+ }
+
+ return values;
+};
+
+/**
+ * @ngdoc function
+ * @name ui.router.util.type:UrlMatcher#parameters
+ * @methodOf ui.router.util.type:UrlMatcher
+ *
+ * @description
+ * Returns the names of all path and search parameters of this pattern in an unspecified order.
+ *
+ * @returns {Array.
+ * new UrlMatcher('/user/{id}?q').format({ id:'bob', q:'yes' });
+ * // returns '/user/bob?q=yes'
+ *
+ *
+ * @param {Object} values the values to substitute for the parameters in this pattern.
+ * @returns {string} the formatted URL (path and optionally search part).
+ */
+UrlMatcher.prototype.format = function (values) {
+ values = values || {};
+ var segments = this.segments, params = this.parameters(), paramset = this.params;
+ if (!this.validates(values)) return null;
+
+ var i, search = false, nPath = segments.length - 1, nTotal = params.length, result = segments[0];
+
+ function encodeDashes(str) { // Replace dashes with encoded "\-"
+ return encodeURIComponent(str).replace(/-/g, function(c) { return '%5C%' + c.charCodeAt(0).toString(16).toUpperCase(); });
+ }
+
+ for (i = 0; i < nTotal; i++) {
+ var isPathParam = i < nPath;
+ var name = params[i], param = paramset[name], value = param.value(values[name]);
+ var isDefaultValue = param.isOptional && param.type.equals(param.value(), value);
+ var squash = isDefaultValue ? param.squash : false;
+ var encoded = param.type.encode(value);
+
+ if (isPathParam) {
+ var nextSegment = segments[i + 1];
+ if (squash === false) {
+ if (encoded != null) {
+ if (isArray(encoded)) {
+ result += map(encoded, encodeDashes).join("-");
+ } else {
+ result += encodeURIComponent(encoded);
+ }
+ }
+ result += nextSegment;
+ } else if (squash === true) {
+ var capture = result.match(/\/$/) ? /\/?(.*)/ : /(.*)/;
+ result += nextSegment.match(capture)[1];
+ } else if (isString(squash)) {
+ result += squash + nextSegment;
+ }
+ } else {
+ if (encoded == null || (isDefaultValue && squash !== false)) continue;
+ if (!isArray(encoded)) encoded = [ encoded ];
+ encoded = map(encoded, encodeURIComponent).join('&' + name + '=');
+ result += (search ? '&' : '?') + (name + '=' + encoded);
+ search = true;
+ }
+ }
+
+ return result;
+};
+
+/**
+ * @ngdoc object
+ * @name ui.router.util.type:Type
+ *
+ * @description
+ * Implements an interface to define custom parameter types that can be decoded from and encoded to
+ * string parameters matched in a URL. Used by {@link ui.router.util.type:UrlMatcher `UrlMatcher`}
+ * objects when matching or formatting URLs, or comparing or validating parameter values.
+ *
+ * See {@link ui.router.util.$urlMatcherFactory#methods_type `$urlMatcherFactory#type()`} for more
+ * information on registering custom types.
+ *
+ * @param {Object} config A configuration object which contains the custom type definition. The object's
+ * properties will override the default methods and/or pattern in `Type`'s public interface.
+ * @example
+ *
+ * {
+ * decode: function(val) { return parseInt(val, 10); },
+ * encode: function(val) { return val && val.toString(); },
+ * equals: function(a, b) { return this.is(a) && a === b; },
+ * is: function(val) { return angular.isNumber(val) isFinite(val) && val % 1 === 0; },
+ * pattern: /\d+/
+ * }
+ *
+ *
+ * @property {RegExp} pattern The regular expression pattern used to match values of this type when
+ * coming from a substring of a URL.
+ *
+ * @returns {Object} Returns a new `Type` object.
+ */
+function Type(config) {
+ extend(this, config);
+}
+
+/**
+ * @ngdoc function
+ * @name ui.router.util.type:Type#is
+ * @methodOf ui.router.util.type:Type
+ *
+ * @description
+ * Detects whether a value is of a particular type. Accepts a native (decoded) value
+ * and determines whether it matches the current `Type` object.
+ *
+ * @param {*} val The value to check.
+ * @param {string} key Optional. If the type check is happening in the context of a specific
+ * {@link ui.router.util.type:UrlMatcher `UrlMatcher`} object, this is the name of the
+ * parameter in which `val` is stored. Can be used for meta-programming of `Type` objects.
+ * @returns {Boolean} Returns `true` if the value matches the type, otherwise `false`.
+ */
+Type.prototype.is = function(val, key) {
+ return true;
+};
+
+/**
+ * @ngdoc function
+ * @name ui.router.util.type:Type#encode
+ * @methodOf ui.router.util.type:Type
+ *
+ * @description
+ * Encodes a custom/native type value to a string that can be embedded in a URL. Note that the
+ * return value does *not* need to be URL-safe (i.e. passed through `encodeURIComponent()`), it
+ * only needs to be a representation of `val` that has been coerced to a string.
+ *
+ * @param {*} val The value to encode.
+ * @param {string} key The name of the parameter in which `val` is stored. Can be used for
+ * meta-programming of `Type` objects.
+ * @returns {string} Returns a string representation of `val` that can be encoded in a URL.
+ */
+Type.prototype.encode = function(val, key) {
+ return val;
+};
+
+/**
+ * @ngdoc function
+ * @name ui.router.util.type:Type#decode
+ * @methodOf ui.router.util.type:Type
+ *
+ * @description
+ * Converts a parameter value (from URL string or transition param) to a custom/native value.
+ *
+ * @param {string} val The URL parameter value to decode.
+ * @param {string} key The name of the parameter in which `val` is stored. Can be used for
+ * meta-programming of `Type` objects.
+ * @returns {*} Returns a custom representation of the URL parameter value.
+ */
+Type.prototype.decode = function(val, key) {
+ return val;
+};
+
+/**
+ * @ngdoc function
+ * @name ui.router.util.type:Type#equals
+ * @methodOf ui.router.util.type:Type
+ *
+ * @description
+ * Determines whether two decoded values are equivalent.
+ *
+ * @param {*} a A value to compare against.
+ * @param {*} b A value to compare against.
+ * @returns {Boolean} Returns `true` if the values are equivalent/equal, otherwise `false`.
+ */
+Type.prototype.equals = function(a, b) {
+ return a == b;
+};
+
+Type.prototype.$subPattern = function() {
+ var sub = this.pattern.toString();
+ return sub.substr(1, sub.length - 2);
+};
+
+Type.prototype.pattern = /.*/;
+
+Type.prototype.toString = function() { return "{Type:" + this.name + "}"; };
+
+/*
+ * Wraps an existing custom Type as an array of Type, depending on 'mode'.
+ * e.g.:
+ * - urlmatcher pattern "/path?{queryParam[]:int}"
+ * - url: "/path?queryParam=1&queryParam=2
+ * - $stateParams.queryParam will be [1, 2]
+ * if `mode` is "auto", then
+ * - url: "/path?queryParam=1 will create $stateParams.queryParam: 1
+ * - url: "/path?queryParam=1&queryParam=2 will create $stateParams.queryParam: [1, 2]
+ */
+Type.prototype.$asArray = function(mode, isSearch) {
+ if (!mode) return this;
+ if (mode === "auto" && !isSearch) throw new Error("'auto' array mode is for query parameters only");
+ return new ArrayType(this, mode);
+
+ function ArrayType(type, mode) {
+ function bindTo(type, callbackName) {
+ return function() {
+ return type[callbackName].apply(type, arguments);
+ };
+ }
+
+ // Wrap non-array value as array
+ function arrayWrap(val) { return isArray(val) ? val : (isDefined(val) ? [ val ] : []); }
+ // Unwrap array value for "auto" mode. Return undefined for empty array.
+ function arrayUnwrap(val) {
+ switch(val.length) {
+ case 0: return undefined;
+ case 1: return mode === "auto" ? val[0] : val;
+ default: return val;
+ }
+ }
+ function falsey(val) { return !val; }
+
+ // Wraps type (.is/.encode/.decode) functions to operate on each value of an array
+ function arrayHandler(callback, allTruthyMode) {
+ return function handleArray(val) {
+ val = arrayWrap(val);
+ var result = map(val, callback);
+ if (allTruthyMode === true)
+ return filter(result, falsey).length === 0;
+ return arrayUnwrap(result);
+ };
+ }
+
+ // Wraps type (.equals) functions to operate on each value of an array
+ function arrayEqualsHandler(callback) {
+ return function handleArray(val1, val2) {
+ var left = arrayWrap(val1), right = arrayWrap(val2);
+ if (left.length !== right.length) return false;
+ for (var i = 0; i < left.length; i++) {
+ if (!callback(left[i], right[i])) return false;
+ }
+ return true;
+ };
+ }
+
+ this.encode = arrayHandler(bindTo(type, 'encode'));
+ this.decode = arrayHandler(bindTo(type, 'decode'));
+ this.is = arrayHandler(bindTo(type, 'is'), true);
+ this.equals = arrayEqualsHandler(bindTo(type, 'equals'));
+ this.pattern = type.pattern;
+ this.$arrayMode = mode;
+ }
+};
+
+
+
+/**
+ * @ngdoc object
+ * @name ui.router.util.$urlMatcherFactory
+ *
+ * @description
+ * Factory for {@link ui.router.util.type:UrlMatcher `UrlMatcher`} instances. The factory
+ * is also available to providers under the name `$urlMatcherFactoryProvider`.
+ */
+function $UrlMatcherFactory() {
+ $$UMFP = this;
+
+ var isCaseInsensitive = false, isStrictMode = true, defaultSquashPolicy = false;
+
+ function valToString(val) { return val != null ? val.toString().replace(/\//g, "%2F") : val; }
+ function valFromString(val) { return val != null ? val.toString().replace(/%2F/g, "/") : val; }
+// TODO: in 1.0, make string .is() return false if value is undefined by default.
+// function regexpMatches(val) { /*jshint validthis:true */ return isDefined(val) && this.pattern.test(val); }
+ function regexpMatches(val) { /*jshint validthis:true */ return this.pattern.test(val); }
+
+ var $types = {}, enqueue = true, typeQueue = [], injector, defaultTypes = {
+ string: {
+ encode: valToString,
+ decode: valFromString,
+ is: regexpMatches,
+ pattern: /[^/]*/
+ },
+ int: {
+ encode: valToString,
+ decode: function(val) { return parseInt(val, 10); },
+ is: function(val) { return isDefined(val) && this.decode(val.toString()) === val; },
+ pattern: /\d+/
+ },
+ bool: {
+ encode: function(val) { return val ? 1 : 0; },
+ decode: function(val) { return parseInt(val, 10) !== 0; },
+ is: function(val) { return val === true || val === false; },
+ pattern: /0|1/
+ },
+ date: {
+ encode: function (val) {
+ if (!this.is(val))
+ return undefined;
+ return [ val.getFullYear(),
+ ('0' + (val.getMonth() + 1)).slice(-2),
+ ('0' + val.getDate()).slice(-2)
+ ].join("-");
+ },
+ decode: function (val) {
+ if (this.is(val)) return val;
+ var match = this.capture.exec(val);
+ return match ? new Date(match[1], match[2] - 1, match[3]) : undefined;
+ },
+ is: function(val) { return val instanceof Date && !isNaN(val.valueOf()); },
+ equals: function (a, b) { return this.is(a) && this.is(b) && a.toISOString() === b.toISOString(); },
+ pattern: /[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])/,
+ capture: /([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/
+ },
+ json: {
+ encode: angular.toJson,
+ decode: angular.fromJson,
+ is: angular.isObject,
+ equals: angular.equals,
+ pattern: /[^/]*/
+ },
+ any: { // does not encode/decode
+ encode: angular.identity,
+ decode: angular.identity,
+ is: angular.identity,
+ equals: angular.equals,
+ pattern: /.*/
+ }
+ };
+
+ function getDefaultConfig() {
+ return {
+ strict: isStrictMode,
+ caseInsensitive: isCaseInsensitive
+ };
+ }
+
+ function isInjectable(value) {
+ return (isFunction(value) || (isArray(value) && isFunction(value[value.length - 1])));
+ }
+
+ /**
+ * [Internal] Get the default value of a parameter, which may be an injectable function.
+ */
+ $UrlMatcherFactory.$$getDefaultValue = function(config) {
+ if (!isInjectable(config.value)) return config.value;
+ if (!injector) throw new Error("Injectable functions cannot be called at configuration time");
+ return injector.invoke(config.value);
+ };
+
+ /**
+ * @ngdoc function
+ * @name ui.router.util.$urlMatcherFactory#caseInsensitive
+ * @methodOf ui.router.util.$urlMatcherFactory
+ *
+ * @description
+ * Defines whether URL matching should be case sensitive (the default behavior), or not.
+ *
+ * @param {boolean} value `false` to match URL in a case sensitive manner; otherwise `true`;
+ * @returns {boolean} the current value of caseInsensitive
+ */
+ this.caseInsensitive = function(value) {
+ if (isDefined(value))
+ isCaseInsensitive = value;
+ return isCaseInsensitive;
+ };
+
+ /**
+ * @ngdoc function
+ * @name ui.router.util.$urlMatcherFactory#strictMode
+ * @methodOf ui.router.util.$urlMatcherFactory
+ *
+ * @description
+ * Defines whether URLs should match trailing slashes, or not (the default behavior).
+ *
+ * @param {boolean=} value `false` to match trailing slashes in URLs, otherwise `true`.
+ * @returns {boolean} the current value of strictMode
+ */
+ this.strictMode = function(value) {
+ if (isDefined(value))
+ isStrictMode = value;
+ return isStrictMode;
+ };
+
+ /**
+ * @ngdoc function
+ * @name ui.router.util.$urlMatcherFactory#defaultSquashPolicy
+ * @methodOf ui.router.util.$urlMatcherFactory
+ *
+ * @description
+ * Sets the default behavior when generating or matching URLs with default parameter values.
+ *
+ * @param {string} value A string that defines the default parameter URL squashing behavior.
+ * `nosquash`: When generating an href with a default parameter value, do not squash the parameter value from the URL
+ * `slash`: When generating an href with a default parameter value, squash (remove) the parameter value, and, if the
+ * parameter is surrounded by slashes, squash (remove) one slash from the URL
+ * any other string, e.g. "~": When generating an href with a default parameter value, squash (remove)
+ * the parameter value from the URL and replace it with this string.
+ */
+ this.defaultSquashPolicy = function(value) {
+ if (!isDefined(value)) return defaultSquashPolicy;
+ if (value !== true && value !== false && !isString(value))
+ throw new Error("Invalid squash policy: " + value + ". Valid policies: false, true, arbitrary-string");
+ defaultSquashPolicy = value;
+ return value;
+ };
+
+ /**
+ * @ngdoc function
+ * @name ui.router.util.$urlMatcherFactory#compile
+ * @methodOf ui.router.util.$urlMatcherFactory
+ *
+ * @description
+ * Creates a {@link ui.router.util.type:UrlMatcher `UrlMatcher`} for the specified pattern.
+ *
+ * @param {string} pattern The URL pattern.
+ * @param {Object} config The config object hash.
+ * @returns {UrlMatcher} The UrlMatcher.
+ */
+ this.compile = function (pattern, config) {
+ return new UrlMatcher(pattern, extend(getDefaultConfig(), config));
+ };
+
+ /**
+ * @ngdoc function
+ * @name ui.router.util.$urlMatcherFactory#isMatcher
+ * @methodOf ui.router.util.$urlMatcherFactory
+ *
+ * @description
+ * Returns true if the specified object is a `UrlMatcher`, or false otherwise.
+ *
+ * @param {Object} object The object to perform the type check against.
+ * @returns {Boolean} Returns `true` if the object matches the `UrlMatcher` interface, by
+ * implementing all the same methods.
+ */
+ this.isMatcher = function (o) {
+ if (!isObject(o)) return false;
+ var result = true;
+
+ forEach(UrlMatcher.prototype, function(val, name) {
+ if (isFunction(val)) {
+ result = result && (isDefined(o[name]) && isFunction(o[name]));
+ }
+ });
+ return result;
+ };
+
+ /**
+ * @ngdoc function
+ * @name ui.router.util.$urlMatcherFactory#type
+ * @methodOf ui.router.util.$urlMatcherFactory
+ *
+ * @description
+ * Registers a custom {@link ui.router.util.type:Type `Type`} object that can be used to
+ * generate URLs with typed parameters.
+ *
+ * @param {string} name The type name.
+ * @param {Object|Function} definition The type definition. See
+ * {@link ui.router.util.type:Type `Type`} for information on the values accepted.
+ * @param {Object|Function} definitionFn (optional) A function that is injected before the app
+ * runtime starts. The result of this function is merged into the existing `definition`.
+ * See {@link ui.router.util.type:Type `Type`} for information on the values accepted.
+ *
+ * @returns {Object} Returns `$urlMatcherFactoryProvider`.
+ *
+ * @example
+ * This is a simple example of a custom type that encodes and decodes items from an
+ * array, using the array index as the URL-encoded value:
+ *
+ *
+ * var list = ['John', 'Paul', 'George', 'Ringo'];
+ *
+ * $urlMatcherFactoryProvider.type('listItem', {
+ * encode: function(item) {
+ * // Represent the list item in the URL using its corresponding index
+ * return list.indexOf(item);
+ * },
+ * decode: function(item) {
+ * // Look up the list item by index
+ * return list[parseInt(item, 10)];
+ * },
+ * is: function(item) {
+ * // Ensure the item is valid by checking to see that it appears
+ * // in the list
+ * return list.indexOf(item) > -1;
+ * }
+ * });
+ *
+ * $stateProvider.state('list', {
+ * url: "/list/{item:listItem}",
+ * controller: function($scope, $stateParams) {
+ * console.log($stateParams.item);
+ * }
+ * });
+ *
+ * // ...
+ *
+ * // Changes URL to '/list/3', logs "Ringo" to the console
+ * $state.go('list', { item: "Ringo" });
+ *
+ *
+ * This is a more complex example of a type that relies on dependency injection to
+ * interact with services, and uses the parameter name from the URL to infer how to
+ * handle encoding and decoding parameter values:
+ *
+ *
+ * // Defines a custom type that gets a value from a service,
+ * // where each service gets different types of values from
+ * // a backend API:
+ * $urlMatcherFactoryProvider.type('dbObject', {}, function(Users, Posts) {
+ *
+ * // Matches up services to URL parameter names
+ * var services = {
+ * user: Users,
+ * post: Posts
+ * };
+ *
+ * return {
+ * encode: function(object) {
+ * // Represent the object in the URL using its unique ID
+ * return object.id;
+ * },
+ * decode: function(value, key) {
+ * // Look up the object by ID, using the parameter
+ * // name (key) to call the correct service
+ * return services[key].findById(value);
+ * },
+ * is: function(object, key) {
+ * // Check that object is a valid dbObject
+ * return angular.isObject(object) && object.id && services[key];
+ * }
+ * equals: function(a, b) {
+ * // Check the equality of decoded objects by comparing
+ * // their unique IDs
+ * return a.id === b.id;
+ * }
+ * };
+ * });
+ *
+ * // In a config() block, you can then attach URLs with
+ * // type-annotated parameters:
+ * $stateProvider.state('users', {
+ * url: "/users",
+ * // ...
+ * }).state('users.item', {
+ * url: "/{user:dbObject}",
+ * controller: function($scope, $stateParams) {
+ * // $stateParams.user will now be an object returned from
+ * // the Users service
+ * },
+ * // ...
+ * });
+ *
+ */
+ this.type = function (name, definition, definitionFn) {
+ if (!isDefined(definition)) return $types[name];
+ if ($types.hasOwnProperty(name)) throw new Error("A type named '" + name + "' has already been defined.");
+
+ $types[name] = new Type(extend({ name: name }, definition));
+ if (definitionFn) {
+ typeQueue.push({ name: name, def: definitionFn });
+ if (!enqueue) flushTypeQueue();
+ }
+ return this;
+ };
+
+ // `flushTypeQueue()` waits until `$urlMatcherFactory` is injected before invoking the queued `definitionFn`s
+ function flushTypeQueue() {
+ while(typeQueue.length) {
+ var type = typeQueue.shift();
+ if (type.pattern) throw new Error("You cannot override a type's .pattern at runtime.");
+ angular.extend($types[type.name], injector.invoke(type.def));
+ }
+ }
+
+ // Register default types. Store them in the prototype of $types.
+ forEach(defaultTypes, function(type, name) { $types[name] = new Type(extend({name: name}, type)); });
+ $types = inherit($types, {});
+
+ /* No need to document $get, since it returns this */
+ this.$get = ['$injector', function ($injector) {
+ injector = $injector;
+ enqueue = false;
+ flushTypeQueue();
+
+ forEach(defaultTypes, function(type, name) {
+ if (!$types[name]) $types[name] = new Type(type);
+ });
+ return this;
+ }];
+
+ this.Param = function Param(id, type, config, location) {
+ var self = this;
+ config = unwrapShorthand(config);
+ type = getType(config, type, location);
+ var arrayMode = getArrayMode();
+ type = arrayMode ? type.$asArray(arrayMode, location === "search") : type;
+ if (type.name === "string" && !arrayMode && location === "path" && config.value === undefined)
+ config.value = ""; // for 0.2.x; in 0.3.0+ do not automatically default to ""
+ var isOptional = config.value !== undefined;
+ var squash = getSquashPolicy(config, isOptional);
+ var replace = getReplace(config, arrayMode, isOptional, squash);
+
+ function unwrapShorthand(config) {
+ var keys = isObject(config) ? objectKeys(config) : [];
+ var isShorthand = indexOf(keys, "value") === -1 && indexOf(keys, "type") === -1 &&
+ indexOf(keys, "squash") === -1 && indexOf(keys, "array") === -1;
+ if (isShorthand) config = { value: config };
+ config.$$fn = isInjectable(config.value) ? config.value : function () { return config.value; };
+ return config;
+ }
+
+ function getType(config, urlType, location) {
+ if (config.type && urlType) throw new Error("Param '"+id+"' has two type configurations.");
+ if (urlType) return urlType;
+ if (!config.type) return (location === "config" ? $types.any : $types.string);
+ return config.type instanceof Type ? config.type : new Type(config.type);
+ }
+
+ // array config: param name (param[]) overrides default settings. explicit config overrides param name.
+ function getArrayMode() {
+ var arrayDefaults = { array: (location === "search" ? "auto" : false) };
+ var arrayParamNomenclature = id.match(/\[\]$/) ? { array: true } : {};
+ return extend(arrayDefaults, arrayParamNomenclature, config).array;
+ }
+
+ /**
+ * returns false, true, or the squash value to indicate the "default parameter url squash policy".
+ */
+ function getSquashPolicy(config, isOptional) {
+ var squash = config.squash;
+ if (!isOptional || squash === false) return false;
+ if (!isDefined(squash) || squash == null) return defaultSquashPolicy;
+ if (squash === true || isString(squash)) return squash;
+ throw new Error("Invalid squash policy: '" + squash + "'. Valid policies: false, true, or arbitrary string");
+ }
+
+ function getReplace(config, arrayMode, isOptional, squash) {
+ var replace, configuredKeys, defaultPolicy = [
+ { from: "", to: (isOptional || arrayMode ? undefined : "") },
+ { from: null, to: (isOptional || arrayMode ? undefined : "") }
+ ];
+ replace = isArray(config.replace) ? config.replace : [];
+ if (isString(squash))
+ replace.push({ from: squash, to: undefined });
+ configuredKeys = map(replace, function(item) { return item.from; } );
+ return filter(defaultPolicy, function(item) { return indexOf(configuredKeys, item.from) === -1; }).concat(replace);
+ }
+
+ /**
+ * [Internal] Get the default value of a parameter, which may be an injectable function.
+ */
+ function $$getDefaultValue() {
+ if (!injector) throw new Error("Injectable functions cannot be called at configuration time");
+ return injector.invoke(config.$$fn);
+ }
+
+ /**
+ * [Internal] Gets the decoded representation of a value if the value is defined, otherwise, returns the
+ * default value, which may be the result of an injectable function.
+ */
+ function $value(value) {
+ function hasReplaceVal(val) { return function(obj) { return obj.from === val; }; }
+ function $replace(value) {
+ var replacement = map(filter(self.replace, hasReplaceVal(value)), function(obj) { return obj.to; });
+ return replacement.length ? replacement[0] : value;
+ }
+ value = $replace(value);
+ return isDefined(value) ? self.type.decode(value) : $$getDefaultValue();
+ }
+
+ function toString() { return "{Param:" + id + " " + type + " squash: '" + squash + "' optional: " + isOptional + "}"; }
+
+ extend(this, {
+ id: id,
+ type: type,
+ location: location,
+ array: arrayMode,
+ squash: squash,
+ replace: replace,
+ isOptional: isOptional,
+ value: $value,
+ dynamic: undefined,
+ config: config,
+ toString: toString
+ });
+ };
+
+ function ParamSet(params) {
+ extend(this, params || {});
+ }
+
+ ParamSet.prototype = {
+ $$new: function() {
+ return inherit(this, extend(new ParamSet(), { $$parent: this}));
+ },
+ $$keys: function () {
+ var keys = [], chain = [], parent = this,
+ ignore = objectKeys(ParamSet.prototype);
+ while (parent) { chain.push(parent); parent = parent.$$parent; }
+ chain.reverse();
+ forEach(chain, function(paramset) {
+ forEach(objectKeys(paramset), function(key) {
+ if (indexOf(keys, key) === -1 && indexOf(ignore, key) === -1) keys.push(key);
+ });
+ });
+ return keys;
+ },
+ $$values: function(paramValues) {
+ var values = {}, self = this;
+ forEach(self.$$keys(), function(key) {
+ values[key] = self[key].value(paramValues && paramValues[key]);
+ });
+ return values;
+ },
+ $$equals: function(paramValues1, paramValues2) {
+ var equal = true, self = this;
+ forEach(self.$$keys(), function(key) {
+ var left = paramValues1 && paramValues1[key], right = paramValues2 && paramValues2[key];
+ if (!self[key].type.equals(left, right)) equal = false;
+ });
+ return equal;
+ },
+ $$validates: function $$validate(paramValues) {
+ var result = true, isOptional, val, param, self = this;
+
+ forEach(this.$$keys(), function(key) {
+ param = self[key];
+ val = paramValues[key];
+ isOptional = !val && param.isOptional;
+ result = result && (isOptional || !!param.type.is(val));
+ });
+ return result;
+ },
+ $$parent: undefined
+ };
+
+ this.ParamSet = ParamSet;
+}
+
+// Register as a provider so it's available to other providers
+angular.module('ui.router.util').provider('$urlMatcherFactory', $UrlMatcherFactory);
+angular.module('ui.router.util').run(['$urlMatcherFactory', function($urlMatcherFactory) { }]);
+
+/**
+ * @ngdoc object
+ * @name ui.router.router.$urlRouterProvider
+ *
+ * @requires ui.router.util.$urlMatcherFactoryProvider
+ * @requires $locationProvider
+ *
+ * @description
+ * `$urlRouterProvider` has the responsibility of watching `$location`.
+ * When `$location` changes it runs through a list of rules one by one until a
+ * match is found. `$urlRouterProvider` is used behind the scenes anytime you specify
+ * a url in a state configuration. All urls are compiled into a UrlMatcher object.
+ *
+ * There are several methods on `$urlRouterProvider` that make it useful to use directly
+ * in your module config.
+ */
+$UrlRouterProvider.$inject = ['$locationProvider', '$urlMatcherFactoryProvider'];
+function $UrlRouterProvider( $locationProvider, $urlMatcherFactory) {
+ var rules = [], otherwise = null, interceptDeferred = false, listener;
+
+ // Returns a string that is a prefix of all strings matching the RegExp
+ function regExpPrefix(re) {
+ var prefix = /^\^((?:\\[^a-zA-Z0-9]|[^\\\[\]\^$*+?.()|{}]+)*)/.exec(re.source);
+ return (prefix != null) ? prefix[1].replace(/\\(.)/g, "$1") : '';
+ }
+
+ // Interpolates matched values into a String.replace()-style pattern
+ function interpolate(pattern, match) {
+ return pattern.replace(/\$(\$|\d{1,2})/, function (m, what) {
+ return match[what === '$' ? 0 : Number(what)];
+ });
+ }
+
+ /**
+ * @ngdoc function
+ * @name ui.router.router.$urlRouterProvider#rule
+ * @methodOf ui.router.router.$urlRouterProvider
+ *
+ * @description
+ * Defines rules that are used by `$urlRouterProvider` to find matches for
+ * specific URLs.
+ *
+ * @example
+ *
+ * var app = angular.module('app', ['ui.router.router']);
+ *
+ * app.config(function ($urlRouterProvider) {
+ * // Here's an example of how you might allow case insensitive urls
+ * $urlRouterProvider.rule(function ($injector, $location) {
+ * var path = $location.path(),
+ * normalized = path.toLowerCase();
+ *
+ * if (path !== normalized) {
+ * return normalized;
+ * }
+ * });
+ * });
+ *
+ *
+ * @param {object} rule Handler function that takes `$injector` and `$location`
+ * services as arguments. You can use them to return a valid path as a string.
+ *
+ * @return {object} `$urlRouterProvider` - `$urlRouterProvider` instance
+ */
+ this.rule = function (rule) {
+ if (!isFunction(rule)) throw new Error("'rule' must be a function");
+ rules.push(rule);
+ return this;
+ };
+
+ /**
+ * @ngdoc object
+ * @name ui.router.router.$urlRouterProvider#otherwise
+ * @methodOf ui.router.router.$urlRouterProvider
+ *
+ * @description
+ * Defines a path that is used when an invalid route is requested.
+ *
+ * @example
+ *
+ * var app = angular.module('app', ['ui.router.router']);
+ *
+ * app.config(function ($urlRouterProvider) {
+ * // if the path doesn't match any of the urls you configured
+ * // otherwise will take care of routing the user to the
+ * // specified url
+ * $urlRouterProvider.otherwise('/index');
+ *
+ * // Example of using function rule as param
+ * $urlRouterProvider.otherwise(function ($injector, $location) {
+ * return '/a/valid/url';
+ * });
+ * });
+ *
+ *
+ * @param {string|object} rule The url path you want to redirect to or a function
+ * rule that returns the url path. The function version is passed two params:
+ * `$injector` and `$location` services, and must return a url string.
+ *
+ * @return {object} `$urlRouterProvider` - `$urlRouterProvider` instance
+ */
+ this.otherwise = function (rule) {
+ if (isString(rule)) {
+ var redirect = rule;
+ rule = function () { return redirect; };
+ }
+ else if (!isFunction(rule)) throw new Error("'rule' must be a function");
+ otherwise = rule;
+ return this;
+ };
+
+
+ function handleIfMatch($injector, handler, match) {
+ if (!match) return false;
+ var result = $injector.invoke(handler, handler, { $match: match });
+ return isDefined(result) ? result : true;
+ }
+
+ /**
+ * @ngdoc function
+ * @name ui.router.router.$urlRouterProvider#when
+ * @methodOf ui.router.router.$urlRouterProvider
+ *
+ * @description
+ * Registers a handler for a given url matching. if handle is a string, it is
+ * treated as a redirect, and is interpolated according to the syntax of match
+ * (i.e. like `String.replace()` for `RegExp`, or like a `UrlMatcher` pattern otherwise).
+ *
+ * If the handler is a function, it is injectable. It gets invoked if `$location`
+ * matches. You have the option of inject the match object as `$match`.
+ *
+ * The handler can return
+ *
+ * - **falsy** to indicate that the rule didn't match after all, then `$urlRouter`
+ * will continue trying to find another one that matches.
+ * - **string** which is treated as a redirect and passed to `$location.url()`
+ * - **void** or any **truthy** value tells `$urlRouter` that the url was handled.
+ *
+ * @example
+ *
+ * var app = angular.module('app', ['ui.router.router']);
+ *
+ * app.config(function ($urlRouterProvider) {
+ * $urlRouterProvider.when($state.url, function ($match, $stateParams) {
+ * if ($state.$current.navigable !== state ||
+ * !equalForKeys($match, $stateParams) {
+ * $state.transitionTo(state, $match, false);
+ * }
+ * });
+ * });
+ *
+ *
+ * @param {string|object} what The incoming path that you want to redirect.
+ * @param {string|object} handler The path you want to redirect your user to.
+ */
+ this.when = function (what, handler) {
+ var redirect, handlerIsString = isString(handler);
+ if (isString(what)) what = $urlMatcherFactory.compile(what);
+
+ if (!handlerIsString && !isFunction(handler) && !isArray(handler))
+ throw new Error("invalid 'handler' in when()");
+
+ var strategies = {
+ matcher: function (what, handler) {
+ if (handlerIsString) {
+ redirect = $urlMatcherFactory.compile(handler);
+ handler = ['$match', function ($match) { return redirect.format($match); }];
+ }
+ return extend(function ($injector, $location) {
+ return handleIfMatch($injector, handler, what.exec($location.path(), $location.search()));
+ }, {
+ prefix: isString(what.prefix) ? what.prefix : ''
+ });
+ },
+ regex: function (what, handler) {
+ if (what.global || what.sticky) throw new Error("when() RegExp must not be global or sticky");
+
+ if (handlerIsString) {
+ redirect = handler;
+ handler = ['$match', function ($match) { return interpolate(redirect, $match); }];
+ }
+ return extend(function ($injector, $location) {
+ return handleIfMatch($injector, handler, what.exec($location.path()));
+ }, {
+ prefix: regExpPrefix(what)
+ });
+ }
+ };
+
+ var check = { matcher: $urlMatcherFactory.isMatcher(what), regex: what instanceof RegExp };
+
+ for (var n in check) {
+ if (check[n]) return this.rule(strategies[n](what, handler));
+ }
+
+ throw new Error("invalid 'what' in when()");
+ };
+
+ /**
+ * @ngdoc function
+ * @name ui.router.router.$urlRouterProvider#deferIntercept
+ * @methodOf ui.router.router.$urlRouterProvider
+ *
+ * @description
+ * Disables (or enables) deferring location change interception.
+ *
+ * If you wish to customize the behavior of syncing the URL (for example, if you wish to
+ * defer a transition but maintain the current URL), call this method at configuration time.
+ * Then, at run time, call `$urlRouter.listen()` after you have configured your own
+ * `$locationChangeSuccess` event handler.
+ *
+ * @example
+ *
+ * var app = angular.module('app', ['ui.router.router']);
+ *
+ * app.config(function ($urlRouterProvider) {
+ *
+ * // Prevent $urlRouter from automatically intercepting URL changes;
+ * // this allows you to configure custom behavior in between
+ * // location changes and route synchronization:
+ * $urlRouterProvider.deferIntercept();
+ *
+ * }).run(function ($rootScope, $urlRouter, UserService) {
+ *
+ * $rootScope.$on('$locationChangeSuccess', function(e) {
+ * // UserService is an example service for managing user state
+ * if (UserService.isLoggedIn()) return;
+ *
+ * // Prevent $urlRouter's default handler from firing
+ * e.preventDefault();
+ *
+ * UserService.handleLogin().then(function() {
+ * // Once the user has logged in, sync the current URL
+ * // to the router:
+ * $urlRouter.sync();
+ * });
+ * });
+ *
+ * // Configures $urlRouter's listener *after* your custom listener
+ * $urlRouter.listen();
+ * });
+ *
+ *
+ * @param {boolean} defer Indicates whether to defer location change interception. Passing
+ no parameter is equivalent to `true`.
+ */
+ this.deferIntercept = function (defer) {
+ if (defer === undefined) defer = true;
+ interceptDeferred = defer;
+ };
+
+ /**
+ * @ngdoc object
+ * @name ui.router.router.$urlRouter
+ *
+ * @requires $location
+ * @requires $rootScope
+ * @requires $injector
+ * @requires $browser
+ *
+ * @description
+ *
+ */
+ this.$get = $get;
+ $get.$inject = ['$location', '$rootScope', '$injector', '$browser'];
+ function $get( $location, $rootScope, $injector, $browser) {
+
+ var baseHref = $browser.baseHref(), location = $location.url(), lastPushedUrl;
+
+ function appendBasePath(url, isHtml5, absolute) {
+ if (baseHref === '/') return url;
+ if (isHtml5) return baseHref.slice(0, -1) + url;
+ if (absolute) return baseHref.slice(1) + url;
+ return url;
+ }
+
+ // TODO: Optimize groups of rules with non-empty prefix into some sort of decision tree
+ function update(evt) {
+ if (evt && evt.defaultPrevented) return;
+ var ignoreUpdate = lastPushedUrl && $location.url() === lastPushedUrl;
+ lastPushedUrl = undefined;
+ if (ignoreUpdate) return true;
+
+ function check(rule) {
+ var handled = rule($injector, $location);
+
+ if (!handled) return false;
+ if (isString(handled)) $location.replace().url(handled);
+ return true;
+ }
+ var n = rules.length, i;
+
+ for (i = 0; i < n; i++) {
+ if (check(rules[i])) return;
+ }
+ // always check otherwise last to allow dynamic updates to the set of rules
+ if (otherwise) check(otherwise);
+ }
+
+ function listen() {
+ listener = listener || $rootScope.$on('$locationChangeSuccess', update);
+ return listener;
+ }
+
+ if (!interceptDeferred) listen();
+
+ return {
+ /**
+ * @ngdoc function
+ * @name ui.router.router.$urlRouter#sync
+ * @methodOf ui.router.router.$urlRouter
+ *
+ * @description
+ * Triggers an update; the same update that happens when the address bar url changes, aka `$locationChangeSuccess`.
+ * This method is useful when you need to use `preventDefault()` on the `$locationChangeSuccess` event,
+ * perform some custom logic (route protection, auth, config, redirection, etc) and then finally proceed
+ * with the transition by calling `$urlRouter.sync()`.
+ *
+ * @example
+ *
+ * angular.module('app', ['ui.router'])
+ * .run(function($rootScope, $urlRouter) {
+ * $rootScope.$on('$locationChangeSuccess', function(evt) {
+ * // Halt state change from even starting
+ * evt.preventDefault();
+ * // Perform custom logic
+ * var meetsRequirement = ...
+ * // Continue with the update and state transition if logic allows
+ * if (meetsRequirement) $urlRouter.sync();
+ * });
+ * });
+ *
+ */
+ sync: function() {
+ update();
+ },
+
+ listen: function() {
+ return listen();
+ },
+
+ update: function(read) {
+ if (read) {
+ location = $location.url();
+ return;
+ }
+ if ($location.url() === location) return;
+
+ $location.url(location);
+ $location.replace();
+ },
+
+ push: function(urlMatcher, params, options) {
+ $location.url(urlMatcher.format(params || {}));
+ lastPushedUrl = options && options.$$avoidResync ? $location.url() : undefined;
+ if (options && options.replace) $location.replace();
+ },
+
+ /**
+ * @ngdoc function
+ * @name ui.router.router.$urlRouter#href
+ * @methodOf ui.router.router.$urlRouter
+ *
+ * @description
+ * A URL generation method that returns the compiled URL for a given
+ * {@link ui.router.util.type:UrlMatcher `UrlMatcher`}, populated with the provided parameters.
+ *
+ * @example
+ *
+ * $bob = $urlRouter.href(new UrlMatcher("/about/:person"), {
+ * person: "bob"
+ * });
+ * // $bob == "/about/bob";
+ *
+ *
+ * @param {UrlMatcher} urlMatcher The `UrlMatcher` object which is used as the template of the URL to generate.
+ * @param {object=} params An object of parameter values to fill the matcher's required parameters.
+ * @param {object=} options Options object. The options are:
+ *
+ * - **`absolute`** - {boolean=false}, If true will generate an absolute url, e.g. "http://www.example.com/fullurl".
+ *
+ * @returns {string} Returns the fully compiled URL, or `null` if `params` fail validation against `urlMatcher`
+ */
+ href: function(urlMatcher, params, options) {
+ if (!urlMatcher.validates(params)) return null;
+
+ var isHtml5 = $locationProvider.html5Mode();
+ if (angular.isObject(isHtml5)) {
+ isHtml5 = isHtml5.enabled;
+ }
+
+ var url = urlMatcher.format(params);
+ options = options || {};
+
+ if (!isHtml5 && url !== null) {
+ url = "#" + $locationProvider.hashPrefix() + url;
+ }
+ url = appendBasePath(url, isHtml5, options.absolute);
+
+ if (!options.absolute || !url) {
+ return url;
+ }
+
+ var slash = (!isHtml5 && url ? '/' : ''), port = $location.port();
+ port = (port === 80 || port === 443 ? '' : ':' + port);
+
+ return [$location.protocol(), '://', $location.host(), port, slash, url].join('');
+ }
+ };
+ }
+}
+
+angular.module('ui.router.router').provider('$urlRouter', $UrlRouterProvider);
+
+/**
+ * @ngdoc object
+ * @name ui.router.state.$stateProvider
+ *
+ * @requires ui.router.router.$urlRouterProvider
+ * @requires ui.router.util.$urlMatcherFactoryProvider
+ *
+ * @description
+ * The new `$stateProvider` works similar to Angular's v1 router, but it focuses purely
+ * on state.
+ *
+ * A state corresponds to a "place" in the application in terms of the overall UI and
+ * navigation. A state describes (via the controller / template / view properties) what
+ * the UI looks like and does at that place.
+ *
+ * States often have things in common, and the primary way of factoring out these
+ * commonalities in this model is via the state hierarchy, i.e. parent/child states aka
+ * nested states.
+ *
+ * The `$stateProvider` provides interfaces to declare these states for your app.
+ */
+$StateProvider.$inject = ['$urlRouterProvider', '$urlMatcherFactoryProvider'];
+function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
+
+ var root, states = {}, $state, queue = {}, abstractKey = 'abstract';
+
+ // Builds state properties from definition passed to registerState()
+ var stateBuilder = {
+
+ // Derive parent state from a hierarchical name only if 'parent' is not explicitly defined.
+ // state.children = [];
+ // if (parent) parent.children.push(state);
+ parent: function(state) {
+ if (isDefined(state.parent) && state.parent) return findState(state.parent);
+ // regex matches any valid composite state name
+ // would match "contact.list" but not "contacts"
+ var compositeName = /^(.+)\.[^.]+$/.exec(state.name);
+ return compositeName ? findState(compositeName[1]) : root;
+ },
+
+ // inherit 'data' from parent and override by own values (if any)
+ data: function(state) {
+ if (state.parent && state.parent.data) {
+ state.data = state.self.data = extend({}, state.parent.data, state.data);
+ }
+ return state.data;
+ },
+
+ // Build a URLMatcher if necessary, either via a relative or absolute URL
+ url: function(state) {
+ var url = state.url, config = { params: state.params || {} };
+
+ if (isString(url)) {
+ if (url.charAt(0) == '^') return $urlMatcherFactory.compile(url.substring(1), config);
+ return (state.parent.navigable || root).url.concat(url, config);
+ }
+
+ if (!url || $urlMatcherFactory.isMatcher(url)) return url;
+ throw new Error("Invalid url '" + url + "' in state '" + state + "'");
+ },
+
+ // Keep track of the closest ancestor state that has a URL (i.e. is navigable)
+ navigable: function(state) {
+ return state.url ? state : (state.parent ? state.parent.navigable : null);
+ },
+
+ // Own parameters for this state. state.url.params is already built at this point. Create and add non-url params
+ ownParams: function(state) {
+ var params = state.url && state.url.params || new $$UMFP.ParamSet();
+ forEach(state.params || {}, function(config, id) {
+ if (!params[id]) params[id] = new $$UMFP.Param(id, null, config, "config");
+ });
+ return params;
+ },
+
+ // Derive parameters for this state and ensure they're a super-set of parent's parameters
+ params: function(state) {
+ return state.parent && state.parent.params ? extend(state.parent.params.$$new(), state.ownParams) : new $$UMFP.ParamSet();
+ },
+
+ // If there is no explicit multi-view configuration, make one up so we don't have
+ // to handle both cases in the view directive later. Note that having an explicit
+ // 'views' property will mean the default unnamed view properties are ignored. This
+ // is also a good time to resolve view names to absolute names, so everything is a
+ // straight lookup at link time.
+ views: function(state) {
+ var views = {};
+
+ forEach(isDefined(state.views) ? state.views : { '': state }, function (view, name) {
+ if (name.indexOf('@') < 0) name += '@' + state.parent.name;
+ views[name] = view;
+ });
+ return views;
+ },
+
+ // Keep a full path from the root down to this state as this is needed for state activation.
+ path: function(state) {
+ return state.parent ? state.parent.path.concat(state) : []; // exclude root from path
+ },
+
+ // Speed up $state.contains() as it's used a lot
+ includes: function(state) {
+ var includes = state.parent ? extend({}, state.parent.includes) : {};
+ includes[state.name] = true;
+ return includes;
+ },
+
+ $delegates: {}
+ };
+
+ function isRelative(stateName) {
+ return stateName.indexOf(".") === 0 || stateName.indexOf("^") === 0;
+ }
+
+ function findState(stateOrName, base) {
+ if (!stateOrName) return undefined;
+
+ var isStr = isString(stateOrName),
+ name = isStr ? stateOrName : stateOrName.name,
+ path = isRelative(name);
+
+ if (path) {
+ if (!base) throw new Error("No reference point given for path '" + name + "'");
+ base = findState(base);
+
+ var rel = name.split("."), i = 0, pathLength = rel.length, current = base;
+
+ for (; i < pathLength; i++) {
+ if (rel[i] === "" && i === 0) {
+ current = base;
+ continue;
+ }
+ if (rel[i] === "^") {
+ if (!current.parent) throw new Error("Path '" + name + "' not valid for state '" + base.name + "'");
+ current = current.parent;
+ continue;
+ }
+ break;
+ }
+ rel = rel.slice(i).join(".");
+ name = current.name + (current.name && rel ? "." : "") + rel;
+ }
+ var state = states[name];
+
+ if (state && (isStr || (!isStr && (state === stateOrName || state.self === stateOrName)))) {
+ return state;
+ }
+ return undefined;
+ }
+
+ function queueState(parentName, state) {
+ if (!queue[parentName]) {
+ queue[parentName] = [];
+ }
+ queue[parentName].push(state);
+ }
+
+ function flushQueuedChildren(parentName) {
+ var queued = queue[parentName] || [];
+ while(queued.length) {
+ registerState(queued.shift());
+ }
+ }
+
+ function registerState(state) {
+ // Wrap a new object around the state so we can store our private details easily.
+ state = inherit(state, {
+ self: state,
+ resolve: state.resolve || {},
+ toString: function() { return this.name; }
+ });
+
+ var name = state.name;
+ if (!isString(name) || name.indexOf('@') >= 0) throw new Error("State must have a valid name");
+ if (states.hasOwnProperty(name)) throw new Error("State '" + name + "'' is already defined");
+
+ // Get parent name
+ var parentName = (name.indexOf('.') !== -1) ? name.substring(0, name.lastIndexOf('.'))
+ : (isString(state.parent)) ? state.parent
+ : (isObject(state.parent) && isString(state.parent.name)) ? state.parent.name
+ : '';
+
+ // If parent is not registered yet, add state to queue and register later
+ if (parentName && !states[parentName]) {
+ return queueState(parentName, state.self);
+ }
+
+ for (var key in stateBuilder) {
+ if (isFunction(stateBuilder[key])) state[key] = stateBuilder[key](state, stateBuilder.$delegates[key]);
+ }
+ states[name] = state;
+
+ // Register the state in the global state list and with $urlRouter if necessary.
+ if (!state[abstractKey] && state.url) {
+ $urlRouterProvider.when(state.url, ['$match', '$stateParams', function ($match, $stateParams) {
+ if ($state.$current.navigable != state || !equalForKeys($match, $stateParams)) {
+ $state.transitionTo(state, $match, { inherit: true, location: false });
+ }
+ }]);
+ }
+
+ // Register any queued children
+ flushQueuedChildren(name);
+
+ return state;
+ }
+
+ // Checks text to see if it looks like a glob.
+ function isGlob (text) {
+ return text.indexOf('*') > -1;
+ }
+
+ // Returns true if glob matches current $state name.
+ function doesStateMatchGlob (glob) {
+ var globSegments = glob.split('.'),
+ segments = $state.$current.name.split('.');
+
+ //match greedy starts
+ if (globSegments[0] === '**') {
+ segments = segments.slice(indexOf(segments, globSegments[1]));
+ segments.unshift('**');
+ }
+ //match greedy ends
+ if (globSegments[globSegments.length - 1] === '**') {
+ segments.splice(indexOf(segments, globSegments[globSegments.length - 2]) + 1, Number.MAX_VALUE);
+ segments.push('**');
+ }
+
+ if (globSegments.length != segments.length) {
+ return false;
+ }
+
+ //match single stars
+ for (var i = 0, l = globSegments.length; i < l; i++) {
+ if (globSegments[i] === '*') {
+ segments[i] = '*';
+ }
+ }
+
+ return segments.join('') === globSegments.join('');
+ }
+
+
+ // Implicit root state that is always active
+ root = registerState({
+ name: '',
+ url: '^',
+ views: null,
+ 'abstract': true
+ });
+ root.navigable = null;
+
+
+ /**
+ * @ngdoc function
+ * @name ui.router.state.$stateProvider#decorator
+ * @methodOf ui.router.state.$stateProvider
+ *
+ * @description
+ * Allows you to extend (carefully) or override (at your own peril) the
+ * `stateBuilder` object used internally by `$stateProvider`. This can be used
+ * to add custom functionality to ui-router, for example inferring templateUrl
+ * based on the state name.
+ *
+ * When passing only a name, it returns the current (original or decorated) builder
+ * function that matches `name`.
+ *
+ * The builder functions that can be decorated are listed below. Though not all
+ * necessarily have a good use case for decoration, that is up to you to decide.
+ *
+ * In addition, users can attach custom decorators, which will generate new
+ * properties within the state's internal definition. There is currently no clear
+ * use-case for this beyond accessing internal states (i.e. $state.$current),
+ * however, expect this to become increasingly relevant as we introduce additional
+ * meta-programming features.
+ *
+ * **Warning**: Decorators should not be interdependent because the order of
+ * execution of the builder functions in non-deterministic. Builder functions
+ * should only be dependent on the state definition object and super function.
+ *
+ *
+ * Existing builder functions and current return values:
+ *
+ * - **parent** `{object}` - returns the parent state object.
+ * - **data** `{object}` - returns state data, including any inherited data that is not
+ * overridden by own values (if any).
+ * - **url** `{object}` - returns a {@link ui.router.util.type:UrlMatcher UrlMatcher}
+ * or `null`.
+ * - **navigable** `{object}` - returns closest ancestor state that has a URL (aka is
+ * navigable).
+ * - **params** `{object}` - returns an array of state params that are ensured to
+ * be a super-set of parent's params.
+ * - **views** `{object}` - returns a views object where each key is an absolute view
+ * name (i.e. "viewName@stateName") and each value is the config object
+ * (template, controller) for the view. Even when you don't use the views object
+ * explicitly on a state config, one is still created for you internally.
+ * So by decorating this builder function you have access to decorating template
+ * and controller properties.
+ * - **ownParams** `{object}` - returns an array of params that belong to the state,
+ * not including any params defined by ancestor states.
+ * - **path** `{string}` - returns the full path from the root down to this state.
+ * Needed for state activation.
+ * - **includes** `{object}` - returns an object that includes every state that
+ * would pass a `$state.includes()` test.
+ *
+ * @example
+ *
+ * // Override the internal 'views' builder with a function that takes the state
+ * // definition, and a reference to the internal function being overridden:
+ * $stateProvider.decorator('views', function (state, parent) {
+ * var result = {},
+ * views = parent(state);
+ *
+ * angular.forEach(views, function (config, name) {
+ * var autoName = (state.name + '.' + name).replace('.', '/');
+ * config.templateUrl = config.templateUrl || '/partials/' + autoName + '.html';
+ * result[name] = config;
+ * });
+ * return result;
+ * });
+ *
+ * $stateProvider.state('home', {
+ * views: {
+ * 'contact.list': { controller: 'ListController' },
+ * 'contact.item': { controller: 'ItemController' }
+ * }
+ * });
+ *
+ * // ...
+ *
+ * $state.go('home');
+ * // Auto-populates list and item views with /partials/home/contact/list.html,
+ * // and /partials/home/contact/item.html, respectively.
+ *
+ *
+ * @param {string} name The name of the builder function to decorate.
+ * @param {object} func A function that is responsible for decorating the original
+ * builder function. The function receives two parameters:
+ *
+ * - `{object}` - state - The state config object.
+ * - `{object}` - super - The original builder function.
+ *
+ * @return {object} $stateProvider - $stateProvider instance
+ */
+ this.decorator = decorator;
+ function decorator(name, func) {
+ /*jshint validthis: true */
+ if (isString(name) && !isDefined(func)) {
+ return stateBuilder[name];
+ }
+ if (!isFunction(func) || !isString(name)) {
+ return this;
+ }
+ if (stateBuilder[name] && !stateBuilder.$delegates[name]) {
+ stateBuilder.$delegates[name] = stateBuilder[name];
+ }
+ stateBuilder[name] = func;
+ return this;
+ }
+
+ /**
+ * @ngdoc function
+ * @name ui.router.state.$stateProvider#state
+ * @methodOf ui.router.state.$stateProvider
+ *
+ * @description
+ * Registers a state configuration under a given state name. The stateConfig object
+ * has the following acceptable properties.
+ *
+ * @param {string} name A unique state name, e.g. "home", "about", "contacts".
+ * To create a parent/child state use a dot, e.g. "about.sales", "home.newest".
+ * @param {object} stateConfig State configuration object.
+ * @param {string|function=} stateConfig.template
+ *
+ * html template as a string or a function that returns
+ * an html template as a string which should be used by the uiView directives. This property
+ * takes precedence over templateUrl.
+ *
+ * If `template` is a function, it will be called with the following parameters:
+ *
+ * - {array.<object>} - state parameters extracted from the current $location.path() by
+ * applying the current state
+ *
+ * template:
+ * "
+ * inline template definition
" +
+ * ""template: function(params) {
+ * return "
+ * generated template
"; }templateUrl: "home.html"
+ * templateUrl: function(params) {
+ * return myTemplates[params.pageId]; }
+ *
+ * @param {function=} stateConfig.templateProvider
+ *
+ * Provider function that returns HTML content string.
+ * templateProvider:
+ * function(MyTemplateService, params) {
+ * return MyTemplateService.getTemplate(params.pageId);
+ * }
+ *
+ * @param {string|function=} stateConfig.controller
+ *
+ *
+ * Controller fn that should be associated with newly
+ * related scope or the name of a registered controller if passed as a string.
+ * Optionally, the ControllerAs may be declared here.
+ * controller: "MyRegisteredController"
+ * controller:
+ * "MyRegisteredController as fooCtrl"}
+ * controller: function($scope, MyService) {
+ * $scope.data = MyService.getData(); }
+ *
+ * @param {function=} stateConfig.controllerProvider
+ *
+ *
+ * Injectable provider function that returns the actual controller or string.
+ * controllerProvider:
+ * function(MyResolveData) {
+ * if (MyResolveData.foo)
+ * return "FooCtrl"
+ * else if (MyResolveData.bar)
+ * return "BarCtrl";
+ * else return function($scope) {
+ * $scope.baz = "Qux";
+ * }
+ * }
+ *
+ * @param {string=} stateConfig.controllerAs
+ *
+ *
+ * A controller alias name. If present the controller will be
+ * published to scope under the controllerAs name.
+ * controllerAs: "myCtrl"
+ *
+ * @param {object=} stateConfig.resolve
+ *
+ *
+ * An optional map<string, function> of dependencies which
+ * should be injected into the controller. If any of these dependencies are promises,
+ * the router will wait for them all to be resolved before the controller is instantiated.
+ * If all the promises are resolved successfully, the $stateChangeSuccess event is fired
+ * and the values of the resolved promises are injected into any controllers that reference them.
+ * If any of the promises are rejected the $stateChangeError event is fired.
+ *
+ * The map object is:
+ *
+ * - key - {string}: name of dependency to be injected into controller
+ * - factory - {string|function}: If string then it is alias for service. Otherwise if function,
+ * it is injected and return value it treated as dependency. If result is a promise, it is
+ * resolved before its value is injected into controller.
+ *
+ * resolve: {
+ * myResolve1:
+ * function($http, $stateParams) {
+ * return $http.get("/api/foos/"+stateParams.fooID);
+ * }
+ * }
+ *
+ * @param {string=} stateConfig.url
+ *
+ *
+ * A url fragment with optional parameters. When a state is navigated or
+ * transitioned to, the `$stateParams` service will be populated with any
+ * parameters that were passed.
+ *
+ * examples:
+ * url: "/home"
+ * url: "/users/:userid"
+ * url: "/books/{bookid:[a-zA-Z_-]}"
+ * url: "/books/{categoryid:int}"
+ * url: "/books/{publishername:string}/{categoryid:int}"
+ * url: "/messages?before&after"
+ * url: "/messages?{before:date}&{after:date}"
+ * url: "/messages/:mailboxid?{before:date}&{after:date}"
+ *
+ * @param {object=} stateConfig.views
+ *
+ * an optional map<string, object> which defined multiple views, or targets views
+ * manually/explicitly.
+ *
+ * Examples:
+ *
+ * Targets three named `ui-view`s in the parent state's template
+ * views: {
+ * header: {
+ * controller: "headerCtrl",
+ * templateUrl: "header.html"
+ * }, body: {
+ * controller: "bodyCtrl",
+ * templateUrl: "body.html"
+ * }, footer: {
+ * controller: "footCtrl",
+ * templateUrl: "footer.html"
+ * }
+ * }
+ *
+ * Targets named `ui-view="header"` from grandparent state 'top''s template, and named `ui-view="body" from parent state's template.
+ * views: {
+ * 'header@top': {
+ * controller: "msgHeaderCtrl",
+ * templateUrl: "msgHeader.html"
+ * }, 'body': {
+ * controller: "messagesCtrl",
+ * templateUrl: "messages.html"
+ * }
+ * }
+ *
+ * @param {boolean=} [stateConfig.abstract=false]
+ *
+ * An abstract state will never be directly activated,
+ * but can provide inherited properties to its common children states.
+ * abstract: true
+ *
+ * @param {function=} stateConfig.onEnter
+ *
+ *
+ * Callback function for when a state is entered. Good way
+ * to trigger an action or dispatch an event, such as opening a dialog.
+ * If minifying your scripts, make sure to explictly annotate this function,
+ * because it won't be automatically annotated by your build tools.
+ *
+ * onEnter: function(MyService, $stateParams) {
+ * MyService.foo($stateParams.myParam);
+ * }
+ *
+ * @param {function=} stateConfig.onExit
+ *
+ *
+ * Callback function for when a state is exited. Good way to
+ * trigger an action or dispatch an event, such as opening a dialog.
+ * If minifying your scripts, make sure to explictly annotate this function,
+ * because it won't be automatically annotated by your build tools.
+ *
+ * onExit: function(MyService, $stateParams) {
+ * MyService.cleanup($stateParams.myParam);
+ * }
+ *
+ * @param {boolean=} [stateConfig.reloadOnSearch=true]
+ *
+ *
+ * If `false`, will not retrigger the same state
+ * just because a search/query parameter has changed (via $location.search() or $location.hash()).
+ * Useful for when you'd like to modify $location.search() without triggering a reload.
+ * reloadOnSearch: false
+ *
+ * @param {object=} stateConfig.data
+ *
+ *
+ * Arbitrary data object, useful for custom configuration. The parent state's `data` is
+ * prototypally inherited. In other words, adding a data property to a state adds it to
+ * the entire subtree via prototypal inheritance.
+ *
+ * data: {
+ * requiredRole: 'foo'
+ * }
+ *
+ * @param {object=} stateConfig.params
+ *
+ *
+ * A map which optionally configures parameters declared in the `url`, or
+ * defines additional non-url parameters. For each parameter being
+ * configured, add a configuration object keyed to the name of the parameter.
+ *
+ * Each parameter configuration object may contain the following properties:
+ *
+ * - ** value ** - {object|function=}: specifies the default value for this
+ * parameter. This implicitly sets this parameter as optional.
+ *
+ * When UI-Router routes to a state and no value is
+ * specified for this parameter in the URL or transition, the
+ * default value will be used instead. If `value` is a function,
+ * it will be injected and invoked, and the return value used.
+ *
+ * *Note*: `undefined` is treated as "no default value" while `null`
+ * is treated as "the default value is `null`".
+ *
+ * *Shorthand*: If you only need to configure the default value of the
+ * parameter, you may use a shorthand syntax. In the **`params`**
+ * map, instead mapping the param name to a full parameter configuration
+ * object, simply set map it to the default parameter value, e.g.:
+ *
+ * // define a parameter's default value
+ * params: {
+ * param1: { value: "defaultValue" }
+ * }
+ * // shorthand default values
+ * params: {
+ * param1: "defaultValue",
+ * param2: "param2Default"
+ * }
+ *
+ * - ** array ** - {boolean=}: *(default: false)* If true, the param value will be
+ * treated as an array of values. If you specified a Type, the value will be
+ * treated as an array of the specified Type. Note: query parameter values
+ * default to a special `"auto"` mode.
+ *
+ * For query parameters in `"auto"` mode, if multiple values for a single parameter
+ * are present in the URL (e.g.: `/foo?bar=1&bar=2&bar=3`) then the values
+ * are mapped to an array (e.g.: `{ foo: [ '1', '2', '3' ] }`). However, if
+ * only one value is present (e.g.: `/foo?bar=1`) then the value is treated as single
+ * value (e.g.: `{ foo: '1' }`).
+ *
+ * params: {
+ * param1: { array: true }
+ * }
+ *
+ * - ** squash ** - {bool|string=}: `squash` configures how a default parameter value is represented in the URL when
+ * the current parameter value is the same as the default value. If `squash` is not set, it uses the
+ * configured default squash policy.
+ * (See {@link ui.router.util.$urlMatcherFactory#methods_defaultSquashPolicy `defaultSquashPolicy()`})
+ *
+ * There are three squash settings:
+ *
+ * - false: The parameter's default value is not squashed. It is encoded and included in the URL
+ * - true: The parameter's default value is omitted from the URL. If the parameter is preceeded and followed
+ * by slashes in the state's `url` declaration, then one of those slashes are omitted.
+ * This can allow for cleaner looking URLs.
+ * - `"params: {
+ * param1: {
+ * value: "defaultId",
+ * squash: true
+ * } }
+ * // squash "defaultValue" to "~"
+ * params: {
+ * param1: {
+ * value: "defaultValue",
+ * squash: "~"
+ * } }
+ *
+ *
+ *
+ * @example
+ *
+ * // Some state name examples
+ *
+ * // stateName can be a single top-level name (must be unique).
+ * $stateProvider.state("home", {});
+ *
+ * // Or it can be a nested state name. This state is a child of the
+ * // above "home" state.
+ * $stateProvider.state("home.newest", {});
+ *
+ * // Nest states as deeply as needed.
+ * $stateProvider.state("home.newest.abc.xyz.inception", {});
+ *
+ * // state() returns $stateProvider, so you can chain state declarations.
+ * $stateProvider
+ * .state("home", {})
+ * .state("about", {})
+ * .state("contacts", {});
+ *
+ *
+ */
+ this.state = state;
+ function state(name, definition) {
+ /*jshint validthis: true */
+ if (isObject(name)) definition = name;
+ else definition.name = name;
+ registerState(definition);
+ return this;
+ }
+
+ /**
+ * @ngdoc object
+ * @name ui.router.state.$state
+ *
+ * @requires $rootScope
+ * @requires $q
+ * @requires ui.router.state.$view
+ * @requires $injector
+ * @requires ui.router.util.$resolve
+ * @requires ui.router.state.$stateParams
+ * @requires ui.router.router.$urlRouter
+ *
+ * @property {object} params A param object, e.g. {sectionId: section.id)}, that
+ * you'd like to test against the current active state.
+ * @property {object} current A reference to the state's config object. However
+ * you passed it in. Useful for accessing custom data.
+ * @property {object} transition Currently pending transition. A promise that'll
+ * resolve or reject.
+ *
+ * @description
+ * `$state` service is responsible for representing states as well as transitioning
+ * between them. It also provides interfaces to ask for current state or even states
+ * you're coming from.
+ */
+ this.$get = $get;
+ $get.$inject = ['$rootScope', '$q', '$view', '$injector', '$resolve', '$stateParams', '$urlRouter', '$location', '$urlMatcherFactory'];
+ function $get( $rootScope, $q, $view, $injector, $resolve, $stateParams, $urlRouter, $location, $urlMatcherFactory) {
+
+ var TransitionSuperseded = $q.reject(new Error('transition superseded'));
+ var TransitionPrevented = $q.reject(new Error('transition prevented'));
+ var TransitionAborted = $q.reject(new Error('transition aborted'));
+ var TransitionFailed = $q.reject(new Error('transition failed'));
+
+ // Handles the case where a state which is the target of a transition is not found, and the user
+ // can optionally retry or defer the transition
+ function handleRedirect(redirect, state, params, options) {
+ /**
+ * @ngdoc event
+ * @name ui.router.state.$state#$stateNotFound
+ * @eventOf ui.router.state.$state
+ * @eventType broadcast on root scope
+ * @description
+ * Fired when a requested state **cannot be found** using the provided state name during transition.
+ * The event is broadcast allowing any handlers a single chance to deal with the error (usually by
+ * lazy-loading the unfound state). A special `unfoundState` object is passed to the listener handler,
+ * you can see its three properties in the example. You can use `event.preventDefault()` to abort the
+ * transition and the promise returned from `go` will be rejected with a `'transition aborted'` value.
+ *
+ * @param {Object} event Event object.
+ * @param {Object} unfoundState Unfound State information. Contains: `to, toParams, options` properties.
+ * @param {State} fromState Current state object.
+ * @param {Object} fromParams Current state params.
+ *
+ * @example
+ *
+ *
+ * // somewhere, assume lazy.state has not been defined
+ * $state.go("lazy.state", {a:1, b:2}, {inherit:false});
+ *
+ * // somewhere else
+ * $scope.$on('$stateNotFound',
+ * function(event, unfoundState, fromState, fromParams){
+ * console.log(unfoundState.to); // "lazy.state"
+ * console.log(unfoundState.toParams); // {a:1, b:2}
+ * console.log(unfoundState.options); // {inherit:false} + default options
+ * })
+ *
+ */
+ var evt = $rootScope.$broadcast('$stateNotFound', redirect, state, params);
+
+ if (evt.defaultPrevented) {
+ $urlRouter.update();
+ return TransitionAborted;
+ }
+
+ if (!evt.retry) {
+ return null;
+ }
+
+ // Allow the handler to return a promise to defer state lookup retry
+ if (options.$retry) {
+ $urlRouter.update();
+ return TransitionFailed;
+ }
+ var retryTransition = $state.transition = $q.when(evt.retry);
+
+ retryTransition.then(function() {
+ if (retryTransition !== $state.transition) return TransitionSuperseded;
+ redirect.options.$retry = true;
+ return $state.transitionTo(redirect.to, redirect.toParams, redirect.options);
+ }, function() {
+ return TransitionAborted;
+ });
+ $urlRouter.update();
+
+ return retryTransition;
+ }
+
+ root.locals = { resolve: null, globals: { $stateParams: {} } };
+
+ $state = {
+ params: {},
+ current: root.self,
+ $current: root,
+ transition: null
+ };
+
+ /**
+ * @ngdoc function
+ * @name ui.router.state.$state#reload
+ * @methodOf ui.router.state.$state
+ *
+ * @description
+ * A method that force reloads the current state. All resolves are re-resolved, events are not re-fired,
+ * and controllers reinstantiated (bug with controllers reinstantiating right now, fixing soon).
+ *
+ * @example
+ *
+ * var app angular.module('app', ['ui.router']);
+ *
+ * app.controller('ctrl', function ($scope, $state) {
+ * $scope.reload = function(){
+ * $state.reload();
+ * }
+ * });
+ *
+ *
+ * `reload()` is just an alias for:
+ *
+ * $state.transitionTo($state.current, $stateParams, {
+ * reload: true, inherit: false, notify: true
+ * });
+ *
+ *
+ * @returns {promise} A promise representing the state of the new transition. See
+ * {@link ui.router.state.$state#methods_go $state.go}.
+ */
+ $state.reload = function reload() {
+ return $state.transitionTo($state.current, $stateParams, { reload: true, inherit: false, notify: true });
+ };
+
+ /**
+ * @ngdoc function
+ * @name ui.router.state.$state#go
+ * @methodOf ui.router.state.$state
+ *
+ * @description
+ * Convenience method for transitioning to a new state. `$state.go` calls
+ * `$state.transitionTo` internally but automatically sets options to
+ * `{ location: true, inherit: true, relative: $state.$current, notify: true }`.
+ * This allows you to easily use an absolute or relative to path and specify
+ * only the parameters you'd like to update (while letting unspecified parameters
+ * inherit from the currently active ancestor states).
+ *
+ * @example
+ *
+ * var app = angular.module('app', ['ui.router']);
+ *
+ * app.controller('ctrl', function ($scope, $state) {
+ * $scope.changeState = function () {
+ * $state.go('contact.detail');
+ * };
+ * });
+ *
+ *
+ *
+ * @param {string} to Absolute state name or relative state path. Some examples:
+ *
+ * - `$state.go('contact.detail')` - will go to the `contact.detail` state
+ * - `$state.go('^')` - will go to a parent state
+ * - `$state.go('^.sibling')` - will go to a sibling state
+ * - `$state.go('.child.grandchild')` - will go to grandchild state
+ *
+ * @param {object=} params A map of the parameters that will be sent to the state,
+ * will populate $stateParams. Any parameters that are not specified will be inherited from currently
+ * defined parameters. This allows, for example, going to a sibling state that shares parameters
+ * specified in a parent state. Parameter inheritance only works between common ancestor states, I.e.
+ * transitioning to a sibling will get you the parameters for all parents, transitioning to a child
+ * will get you all current parameters, etc.
+ * @param {object=} options Options object. The options are:
+ *
+ * - **`location`** - {boolean=true|string=} - If `true` will update the url in the location bar, if `false`
+ * will not. If string, must be `"replace"`, which will update url and also replace last history record.
+ * - **`inherit`** - {boolean=true}, If `true` will inherit url parameters from current url.
+ * - **`relative`** - {object=$state.$current}, When transitioning with relative path (e.g '^'),
+ * defines which state to be relative from.
+ * - **`notify`** - {boolean=true}, If `true` will broadcast $stateChangeStart and $stateChangeSuccess events.
+ * - **`reload`** (v0.2.5) - {boolean=false}, If `true` will force transition even if the state or params
+ * have not changed, aka a reload of the same state. It differs from reloadOnSearch because you'd
+ * use this when you want to force a reload when *everything* is the same, including search params.
+ *
+ * @returns {promise} A promise representing the state of the new transition.
+ *
+ * Possible success values:
+ *
+ * - $state.current
+ *
+ *
Possible rejection values:
+ *
+ * - 'transition superseded' - when a newer transition has been started after this one
+ * - 'transition prevented' - when `event.preventDefault()` has been called in a `$stateChangeStart` listener
+ * - 'transition aborted' - when `event.preventDefault()` has been called in a `$stateNotFound` listener or
+ * when a `$stateNotFound` `event.retry` promise errors.
+ * - 'transition failed' - when a state has been unsuccessfully found after 2 tries.
+ * - *resolve error* - when an error has occurred with a `resolve`
+ *
+ */
+ $state.go = function go(to, params, options) {
+ return $state.transitionTo(to, params, extend({ inherit: true, relative: $state.$current }, options));
+ };
+
+ /**
+ * @ngdoc function
+ * @name ui.router.state.$state#transitionTo
+ * @methodOf ui.router.state.$state
+ *
+ * @description
+ * Low-level method for transitioning to a new state. {@link ui.router.state.$state#methods_go $state.go}
+ * uses `transitionTo` internally. `$state.go` is recommended in most situations.
+ *
+ * @example
+ *
+ * var app = angular.module('app', ['ui.router']);
+ *
+ * app.controller('ctrl', function ($scope, $state) {
+ * $scope.changeState = function () {
+ * $state.transitionTo('contact.detail');
+ * };
+ * });
+ *
+ *
+ * @param {string} to State name.
+ * @param {object=} toParams A map of the parameters that will be sent to the state,
+ * will populate $stateParams.
+ * @param {object=} options Options object. The options are:
+ *
+ * - **`location`** - {boolean=true|string=} - If `true` will update the url in the location bar, if `false`
+ * will not. If string, must be `"replace"`, which will update url and also replace last history record.
+ * - **`inherit`** - {boolean=false}, If `true` will inherit url parameters from current url.
+ * - **`relative`** - {object=}, When transitioning with relative path (e.g '^'),
+ * defines which state to be relative from.
+ * - **`notify`** - {boolean=true}, If `true` will broadcast $stateChangeStart and $stateChangeSuccess events.
+ * - **`reload`** (v0.2.5) - {boolean=false}, If `true` will force transition even if the state or params
+ * have not changed, aka a reload of the same state. It differs from reloadOnSearch because you'd
+ * use this when you want to force a reload when *everything* is the same, including search params.
+ *
+ * @returns {promise} A promise representing the state of the new transition. See
+ * {@link ui.router.state.$state#methods_go $state.go}.
+ */
+ $state.transitionTo = function transitionTo(to, toParams, options) {
+ toParams = toParams || {};
+ options = extend({
+ location: true, inherit: false, relative: null, notify: true, reload: false, $retry: false
+ }, options || {});
+
+ var from = $state.$current, fromParams = $state.params, fromPath = from.path;
+ var evt, toState = findState(to, options.relative);
+
+ if (!isDefined(toState)) {
+ var redirect = { to: to, toParams: toParams, options: options };
+ var redirectResult = handleRedirect(redirect, from.self, fromParams, options);
+
+ if (redirectResult) {
+ return redirectResult;
+ }
+
+ // Always retry once if the $stateNotFound was not prevented
+ // (handles either redirect changed or state lazy-definition)
+ to = redirect.to;
+ toParams = redirect.toParams;
+ options = redirect.options;
+ toState = findState(to, options.relative);
+
+ if (!isDefined(toState)) {
+ if (!options.relative) throw new Error("No such state '" + to + "'");
+ throw new Error("Could not resolve '" + to + "' from state '" + options.relative + "'");
+ }
+ }
+ if (toState[abstractKey]) throw new Error("Cannot transition to abstract state '" + to + "'");
+ if (options.inherit) toParams = inheritParams($stateParams, toParams || {}, $state.$current, toState);
+ if (!toState.params.$$validates(toParams)) return TransitionFailed;
+
+ toParams = toState.params.$$values(toParams);
+ to = toState;
+
+ var toPath = to.path;
+
+ // Starting from the root of the path, keep all levels that haven't changed
+ var keep = 0, state = toPath[keep], locals = root.locals, toLocals = [];
+
+ if (!options.reload) {
+ while (state && state === fromPath[keep] && state.ownParams.$$equals(toParams, fromParams)) {
+ locals = toLocals[keep] = state.locals;
+ keep++;
+ state = toPath[keep];
+ }
+ }
+
+ // If we're going to the same state and all locals are kept, we've got nothing to do.
+ // But clear 'transition', as we still want to cancel any other pending transitions.
+ // TODO: We may not want to bump 'transition' if we're called from a location change
+ // that we've initiated ourselves, because we might accidentally abort a legitimate
+ // transition initiated from code?
+ if (shouldTriggerReload(to, from, locals, options)) {
+ if (to.self.reloadOnSearch !== false) $urlRouter.update();
+ $state.transition = null;
+ return $q.when($state.current);
+ }
+
+ // Filter parameters before we pass them to event handlers etc.
+ toParams = filterByKeys(to.params.$$keys(), toParams || {});
+
+ // Broadcast start event and cancel the transition if requested
+ if (options.notify) {
+ /**
+ * @ngdoc event
+ * @name ui.router.state.$state#$stateChangeStart
+ * @eventOf ui.router.state.$state
+ * @eventType broadcast on root scope
+ * @description
+ * Fired when the state transition **begins**. You can use `event.preventDefault()`
+ * to prevent the transition from happening and then the transition promise will be
+ * rejected with a `'transition prevented'` value.
+ *
+ * @param {Object} event Event object.
+ * @param {State} toState The state being transitioned to.
+ * @param {Object} toParams The params supplied to the `toState`.
+ * @param {State} fromState The current state, pre-transition.
+ * @param {Object} fromParams The params supplied to the `fromState`.
+ *
+ * @example
+ *
+ *
+ * $rootScope.$on('$stateChangeStart',
+ * function(event, toState, toParams, fromState, fromParams){
+ * event.preventDefault();
+ * // transitionTo() promise will be rejected with
+ * // a 'transition prevented' error
+ * })
+ *
+ */
+ if ($rootScope.$broadcast('$stateChangeStart', to.self, toParams, from.self, fromParams).defaultPrevented) {
+ $urlRouter.update();
+ return TransitionPrevented;
+ }
+ }
+
+ // Resolve locals for the remaining states, but don't update any global state just
+ // yet -- if anything fails to resolve the current state needs to remain untouched.
+ // We also set up an inheritance chain for the locals here. This allows the view directive
+ // to quickly look up the correct definition for each view in the current state. Even
+ // though we create the locals object itself outside resolveState(), it is initially
+ // empty and gets filled asynchronously. We need to keep track of the promise for the
+ // (fully resolved) current locals, and pass this down the chain.
+ var resolved = $q.when(locals);
+
+ for (var l = keep; l < toPath.length; l++, state = toPath[l]) {
+ locals = toLocals[l] = inherit(locals);
+ resolved = resolveState(state, toParams, state === to, resolved, locals, options);
+ }
+
+ // Once everything is resolved, we are ready to perform the actual transition
+ // and return a promise for the new state. We also keep track of what the
+ // current promise is, so that we can detect overlapping transitions and
+ // keep only the outcome of the last transition.
+ var transition = $state.transition = resolved.then(function () {
+ var l, entering, exiting;
+
+ if ($state.transition !== transition) return TransitionSuperseded;
+
+ // Exit 'from' states not kept
+ for (l = fromPath.length - 1; l >= keep; l--) {
+ exiting = fromPath[l];
+ if (exiting.self.onExit) {
+ $injector.invoke(exiting.self.onExit, exiting.self, exiting.locals.globals);
+ }
+ exiting.locals = null;
+ }
+
+ // Enter 'to' states not kept
+ for (l = keep; l < toPath.length; l++) {
+ entering = toPath[l];
+ entering.locals = toLocals[l];
+ if (entering.self.onEnter) {
+ $injector.invoke(entering.self.onEnter, entering.self, entering.locals.globals);
+ }
+ }
+
+ // Run it again, to catch any transitions in callbacks
+ if ($state.transition !== transition) return TransitionSuperseded;
+
+ // Update globals in $state
+ $state.$current = to;
+ $state.current = to.self;
+ $state.params = toParams;
+ copy($state.params, $stateParams);
+ $state.transition = null;
+
+ if (options.location && to.navigable) {
+ $urlRouter.push(to.navigable.url, to.navigable.locals.globals.$stateParams, {
+ $$avoidResync: true, replace: options.location === 'replace'
+ });
+ }
+
+ if (options.notify) {
+ /**
+ * @ngdoc event
+ * @name ui.router.state.$state#$stateChangeSuccess
+ * @eventOf ui.router.state.$state
+ * @eventType broadcast on root scope
+ * @description
+ * Fired once the state transition is **complete**.
+ *
+ * @param {Object} event Event object.
+ * @param {State} toState The state being transitioned to.
+ * @param {Object} toParams The params supplied to the `toState`.
+ * @param {State} fromState The current state, pre-transition.
+ * @param {Object} fromParams The params supplied to the `fromState`.
+ */
+ $rootScope.$broadcast('$stateChangeSuccess', to.self, toParams, from.self, fromParams);
+ }
+ $urlRouter.update(true);
+
+ return $state.current;
+ }, function (error) {
+ if ($state.transition !== transition) return TransitionSuperseded;
+
+ $state.transition = null;
+ /**
+ * @ngdoc event
+ * @name ui.router.state.$state#$stateChangeError
+ * @eventOf ui.router.state.$state
+ * @eventType broadcast on root scope
+ * @description
+ * Fired when an **error occurs** during transition. It's important to note that if you
+ * have any errors in your resolve functions (javascript errors, non-existent services, etc)
+ * they will not throw traditionally. You must listen for this $stateChangeError event to
+ * catch **ALL** errors.
+ *
+ * @param {Object} event Event object.
+ * @param {State} toState The state being transitioned to.
+ * @param {Object} toParams The params supplied to the `toState`.
+ * @param {State} fromState The current state, pre-transition.
+ * @param {Object} fromParams The params supplied to the `fromState`.
+ * @param {Error} error The resolve error object.
+ */
+ evt = $rootScope.$broadcast('$stateChangeError', to.self, toParams, from.self, fromParams, error);
+
+ if (!evt.defaultPrevented) {
+ $urlRouter.update();
+ }
+
+ return $q.reject(error);
+ });
+
+ return transition;
+ };
+
+ /**
+ * @ngdoc function
+ * @name ui.router.state.$state#is
+ * @methodOf ui.router.state.$state
+ *
+ * @description
+ * Similar to {@link ui.router.state.$state#methods_includes $state.includes},
+ * but only checks for the full state name. If params is supplied then it will be
+ * tested for strict equality against the current active params object, so all params
+ * must match with none missing and no extras.
+ *
+ * @example
+ *
+ * $state.$current.name = 'contacts.details.item';
+ *
+ * // absolute name
+ * $state.is('contact.details.item'); // returns true
+ * $state.is(contactDetailItemStateObject); // returns true
+ *
+ * // relative name (. and ^), typically from a template
+ * // E.g. from the 'contacts.details' template
+ *
+ *
+ * @param {string|object} stateOrName The state name (absolute or relative) or state object you'd like to check.
+ * @param {object=} params A param object, e.g. `{sectionId: section.id}`, that you'd like
+ * to test against the current active state.
+ * @param {object=} options An options object. The options are:
+ *
+ * - **`relative`** - {string|object} - If `stateOrName` is a relative state name and `options.relative` is set, .is will
+ * test relative to `options.relative` state (or name).
+ *
+ * @returns {boolean} Returns true if it is the state.
+ */
+ $state.is = function is(stateOrName, params, options) {
+ options = extend({ relative: $state.$current }, options || {});
+ var state = findState(stateOrName, options.relative);
+
+ if (!isDefined(state)) { return undefined; }
+ if ($state.$current !== state) { return false; }
+ return params ? equalForKeys(state.params.$$values(params), $stateParams) : true;
+ };
+
+ /**
+ * @ngdoc function
+ * @name ui.router.state.$state#includes
+ * @methodOf ui.router.state.$state
+ *
+ * @description
+ * A method to determine if the current active state is equal to or is the child of the
+ * state stateName. If any params are passed then they will be tested for a match as well.
+ * Not all the parameters need to be passed, just the ones you'd like to test for equality.
+ *
+ * @example
+ * Partial and relative names
+ *
+ * $state.$current.name = 'contacts.details.item';
+ *
+ * // Using partial names
+ * $state.includes("contacts"); // returns true
+ * $state.includes("contacts.details"); // returns true
+ * $state.includes("contacts.details.item"); // returns true
+ * $state.includes("contacts.list"); // returns false
+ * $state.includes("about"); // returns false
+ *
+ * // Using relative names (. and ^), typically from a template
+ * // E.g. from the 'contacts.details' template
+ *
+ *
+ * Basic globbing patterns
+ *
+ * $state.$current.name = 'contacts.details.item.url';
+ *
+ * $state.includes("*.details.*.*"); // returns true
+ * $state.includes("*.details.**"); // returns true
+ * $state.includes("**.item.**"); // returns true
+ * $state.includes("*.details.item.url"); // returns true
+ * $state.includes("*.details.*.url"); // returns true
+ * $state.includes("*.details.*"); // returns false
+ * $state.includes("item.**"); // returns false
+ *
+ *
+ * @param {string} stateOrName A partial name, relative name, or glob pattern
+ * to be searched for within the current state name.
+ * @param {object=} params A param object, e.g. `{sectionId: section.id}`,
+ * that you'd like to test against the current active state.
+ * @param {object=} options An options object. The options are:
+ *
+ * - **`relative`** - {string|object=} - If `stateOrName` is a relative state reference and `options.relative` is set,
+ * .includes will test relative to `options.relative` state (or name).
+ *
+ * @returns {boolean} Returns true if it does include the state
+ */
+ $state.includes = function includes(stateOrName, params, options) {
+ options = extend({ relative: $state.$current }, options || {});
+ if (isString(stateOrName) && isGlob(stateOrName)) {
+ if (!doesStateMatchGlob(stateOrName)) {
+ return false;
+ }
+ stateOrName = $state.$current.name;
+ }
+
+ var state = findState(stateOrName, options.relative);
+ if (!isDefined(state)) { return undefined; }
+ if (!isDefined($state.$current.includes[state.name])) { return false; }
+ return params ? equalForKeys(state.params.$$values(params), $stateParams, objectKeys(params)) : true;
+ };
+
+
+ /**
+ * @ngdoc function
+ * @name ui.router.state.$state#href
+ * @methodOf ui.router.state.$state
+ *
+ * @description
+ * A url generation method that returns the compiled url for the given state populated with the given params.
+ *
+ * @example
+ *
+ * expect($state.href("about.person", { person: "bob" })).toEqual("/about/bob");
+ *
+ *
+ * @param {string|object} stateOrName The state name or state object you'd like to generate a url from.
+ * @param {object=} params An object of parameter values to fill the state's required parameters.
+ * @param {object=} options Options object. The options are:
+ *
+ * - **`lossy`** - {boolean=true} - If true, and if there is no url associated with the state provided in the
+ * first parameter, then the constructed href url will be built from the first navigable ancestor (aka
+ * ancestor with a valid url).
+ * - **`inherit`** - {boolean=true}, If `true` will inherit url parameters from current url.
+ * - **`relative`** - {object=$state.$current}, When transitioning with relative path (e.g '^'),
+ * defines which state to be relative from.
+ * - **`absolute`** - {boolean=false}, If true will generate an absolute url, e.g. "http://www.example.com/fullurl".
+ *
+ * @returns {string} compiled state url
+ */
+ $state.href = function href(stateOrName, params, options) {
+ options = extend({
+ lossy: true,
+ inherit: true,
+ absolute: false,
+ relative: $state.$current
+ }, options || {});
+
+ var state = findState(stateOrName, options.relative);
+
+ if (!isDefined(state)) return null;
+ if (options.inherit) params = inheritParams($stateParams, params || {}, $state.$current, state);
+
+ var nav = (state && options.lossy) ? state.navigable : state;
+
+ if (!nav || nav.url === undefined || nav.url === null) {
+ return null;
+ }
+ return $urlRouter.href(nav.url, filterByKeys(state.params.$$keys(), params || {}), {
+ absolute: options.absolute
+ });
+ };
+
+ /**
+ * @ngdoc function
+ * @name ui.router.state.$state#get
+ * @methodOf ui.router.state.$state
+ *
+ * @description
+ * Returns the state configuration object for any specific state or all states.
+ *
+ * @param {string|object=} stateOrName (absolute or relative) If provided, will only get the config for
+ * the requested state. If not provided, returns an array of ALL state configs.
+ * @param {string|object=} context When stateOrName is a relative state reference, the state will be retrieved relative to context.
+ * @returns {Object|Array} State configuration object or array of all objects.
+ */
+ $state.get = function (stateOrName, context) {
+ if (arguments.length === 0) return map(objectKeys(states), function(name) { return states[name].self; });
+ var state = findState(stateOrName, context || $state.$current);
+ return (state && state.self) ? state.self : null;
+ };
+
+ function resolveState(state, params, paramsAreFiltered, inherited, dst, options) {
+ // Make a restricted $stateParams with only the parameters that apply to this state if
+ // necessary. In addition to being available to the controller and onEnter/onExit callbacks,
+ // we also need $stateParams to be available for any $injector calls we make during the
+ // dependency resolution process.
+ var $stateParams = (paramsAreFiltered) ? params : filterByKeys(state.params.$$keys(), params);
+ var locals = { $stateParams: $stateParams };
+
+ // Resolve 'global' dependencies for the state, i.e. those not specific to a view.
+ // We're also including $stateParams in this; that way the parameters are restricted
+ // to the set that should be visible to the state, and are independent of when we update
+ // the global $state and $stateParams values.
+ dst.resolve = $resolve.resolve(state.resolve, locals, dst.resolve, state);
+ var promises = [dst.resolve.then(function (globals) {
+ dst.globals = globals;
+ })];
+ if (inherited) promises.push(inherited);
+
+ // Resolve template and dependencies for all views.
+ forEach(state.views, function (view, name) {
+ var injectables = (view.resolve && view.resolve !== state.resolve ? view.resolve : {});
+ injectables.$template = [ function () {
+ return $view.load(name, { view: view, locals: locals, params: $stateParams, notify: options.notify }) || '';
+ }];
+
+ promises.push($resolve.resolve(injectables, locals, dst.resolve, state).then(function (result) {
+ // References to the controller (only instantiated at link time)
+ if (isFunction(view.controllerProvider) || isArray(view.controllerProvider)) {
+ var injectLocals = angular.extend({}, injectables, locals);
+ result.$$controller = $injector.invoke(view.controllerProvider, null, injectLocals);
+ } else {
+ result.$$controller = view.controller;
+ }
+ // Provide access to the state itself for internal use
+ result.$$state = state;
+ result.$$controllerAs = view.controllerAs;
+ dst[name] = result;
+ }));
+ });
+
+ // Wait for all the promises and then return the activation object
+ return $q.all(promises).then(function (values) {
+ return dst;
+ });
+ }
+
+ return $state;
+ }
+
+ function shouldTriggerReload(to, from, locals, options) {
+ if (to === from && ((locals === from.locals && !options.reload) || (to.self.reloadOnSearch === false))) {
+ return true;
+ }
+ }
+}
+
+angular.module('ui.router.state')
+ .value('$stateParams', {})
+ .provider('$state', $StateProvider);
+
+
+$ViewProvider.$inject = [];
+function $ViewProvider() {
+
+ this.$get = $get;
+ /**
+ * @ngdoc object
+ * @name ui.router.state.$view
+ *
+ * @requires ui.router.util.$templateFactory
+ * @requires $rootScope
+ *
+ * @description
+ *
+ */
+ $get.$inject = ['$rootScope', '$templateFactory'];
+ function $get( $rootScope, $templateFactory) {
+ return {
+ // $view.load('full.viewName', { template: ..., controller: ..., resolve: ..., async: false, params: ... })
+ /**
+ * @ngdoc function
+ * @name ui.router.state.$view#load
+ * @methodOf ui.router.state.$view
+ *
+ * @description
+ *
+ * @param {string} name name
+ * @param {object} options option object.
+ */
+ load: function load(name, options) {
+ var result, defaults = {
+ template: null, controller: null, view: null, locals: null, notify: true, async: true, params: {}
+ };
+ options = extend(defaults, options);
+
+ if (options.view) {
+ result = $templateFactory.fromConfig(options.view, options.params, options.locals);
+ }
+ if (result && options.notify) {
+ /**
+ * @ngdoc event
+ * @name ui.router.state.$state#$viewContentLoading
+ * @eventOf ui.router.state.$view
+ * @eventType broadcast on root scope
+ * @description
+ *
+ * Fired once the view **begins loading**, *before* the DOM is rendered.
+ *
+ * @param {Object} event Event object.
+ * @param {Object} viewConfig The view config properties (template, controller, etc).
+ *
+ * @example
+ *
+ *
+ * $scope.$on('$viewContentLoading',
+ * function(event, viewConfig){
+ * // Access to all the view config properties.
+ * // and one special property 'targetView'
+ * // viewConfig.targetView
+ * });
+ *
+ */
+ $rootScope.$broadcast('$viewContentLoading', options);
+ }
+ return result;
+ }
+ };
+ }
+}
+
+angular.module('ui.router.state').provider('$view', $ViewProvider);
+
+/**
+ * @ngdoc object
+ * @name ui.router.state.$uiViewScrollProvider
+ *
+ * @description
+ * Provider that returns the {@link ui.router.state.$uiViewScroll} service function.
+ */
+function $ViewScrollProvider() {
+
+ var useAnchorScroll = false;
+
+ /**
+ * @ngdoc function
+ * @name ui.router.state.$uiViewScrollProvider#useAnchorScroll
+ * @methodOf ui.router.state.$uiViewScrollProvider
+ *
+ * @description
+ * Reverts back to using the core [`$anchorScroll`](http://docs.angularjs.org/api/ng.$anchorScroll) service for
+ * scrolling based on the url anchor.
+ */
+ this.useAnchorScroll = function () {
+ useAnchorScroll = true;
+ };
+
+ /**
+ * @ngdoc object
+ * @name ui.router.state.$uiViewScroll
+ *
+ * @requires $anchorScroll
+ * @requires $timeout
+ *
+ * @description
+ * When called with a jqLite element, it scrolls the element into view (after a
+ * `$timeout` so the DOM has time to refresh).
+ *
+ * If you prefer to rely on `$anchorScroll` to scroll the view to the anchor,
+ * this can be enabled by calling {@link ui.router.state.$uiViewScrollProvider#methods_useAnchorScroll `$uiViewScrollProvider.useAnchorScroll()`}.
+ */
+ this.$get = ['$anchorScroll', '$timeout', function ($anchorScroll, $timeout) {
+ if (useAnchorScroll) {
+ return $anchorScroll;
+ }
+
+ return function ($element) {
+ $timeout(function () {
+ $element[0].scrollIntoView();
+ }, 0, false);
+ };
+ }];
+}
+
+angular.module('ui.router.state').provider('$uiViewScroll', $ViewScrollProvider);
+
+/**
+ * @ngdoc directive
+ * @name ui.router.state.directive:ui-view
+ *
+ * @requires ui.router.state.$state
+ * @requires $compile
+ * @requires $controller
+ * @requires $injector
+ * @requires ui.router.state.$uiViewScroll
+ * @requires $document
+ *
+ * @restrict ECA
+ *
+ * @description
+ * The ui-view directive tells $state where to place your templates.
+ *
+ * @param {string=} name A view name. The name should be unique amongst the other views in the
+ * same state. You can have views of the same name that live in different states.
+ *
+ * @param {string=} autoscroll It allows you to set the scroll behavior of the browser window
+ * when a view is populated. By default, $anchorScroll is overridden by ui-router's custom scroll
+ * service, {@link ui.router.state.$uiViewScroll}. This custom service let's you
+ * scroll ui-view elements into view when they are populated during a state activation.
+ *
+ * *Note: To revert back to old [`$anchorScroll`](http://docs.angularjs.org/api/ng.$anchorScroll)
+ * functionality, call `$uiViewScrollProvider.useAnchorScroll()`.*
+ *
+ * @param {string=} onload Expression to evaluate whenever the view updates.
+ *
+ * @example
+ * A view can be unnamed or named.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * You can only have one unnamed view within any template (or root html). If you are only using a
+ * single view and it is unnamed then you can populate it like so:
+ *
+ *
+ * $stateProvider.state("home", {
+ * template: "
+ *
+ * The above is a convenient shortcut equivalent to specifying your view explicitly with the {@link ui.router.state.$stateProvider#views `views`}
+ * config property, by name, in this case an empty name:
+ * HELLO!
"
+ * })
+ *
+ * $stateProvider.state("home", {
+ * views: {
+ * "": {
+ * template: "
+ *
+ * But typically you'll only use the views property if you name your view or have more than one view
+ * in the same template. There's not really a compelling reason to name a view if its the only one,
+ * but you could if you wanted, like so:
+ * HELLO!
"
+ * }
+ * }
+ * })
+ *
+ *
+ *
+ *
+ * $stateProvider.state("home", {
+ * views: {
+ * "main": {
+ * template: "
+ *
+ * Really though, you'll use views to set up multiple views:
+ * HELLO!
"
+ * }
+ * }
+ * })
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * $stateProvider.state("home", {
+ * views: {
+ * "": {
+ * template: "
+ *
+ * Examples for `autoscroll`:
+ *
+ * HELLO!
"
+ * },
+ * "chart": {
+ * template: "
+ *
+ *
+ */
+$ViewDirective.$inject = ['$state', '$injector', '$uiViewScroll', '$interpolate'];
+function $ViewDirective( $state, $injector, $uiViewScroll, $interpolate) {
+
+ function getService() {
+ return ($injector.has) ? function(service) {
+ return $injector.has(service) ? $injector.get(service) : null;
+ } : function(service) {
+ try {
+ return $injector.get(service);
+ } catch (e) {
+ return null;
+ }
+ };
+ }
+
+ var service = getService(),
+ $animator = service('$animator'),
+ $animate = service('$animate');
+
+ // Returns a set of DOM manipulation functions based on which Angular version
+ // it should use
+ function getRenderer(attrs, scope) {
+ var statics = function() {
+ return {
+ enter: function (element, target, cb) { target.after(element); cb(); },
+ leave: function (element, cb) { element.remove(); cb(); }
+ };
+ };
+
+ if ($animate) {
+ return {
+ enter: function(element, target, cb) {
+ var promise = $animate.enter(element, null, target, cb);
+ if (promise && promise.then) promise.then(cb);
+ },
+ leave: function(element, cb) {
+ var promise = $animate.leave(element, cb);
+ if (promise && promise.then) promise.then(cb);
+ }
+ };
+ }
+
+ if ($animator) {
+ var animate = $animator && $animator(scope, attrs);
+
+ return {
+ enter: function(element, target, cb) {animate.enter(element, null, target); cb(); },
+ leave: function(element, cb) { animate.leave(element); cb(); }
+ };
+ }
+
+ return statics();
+ }
+
+ var directive = {
+ restrict: 'ECA',
+ terminal: true,
+ priority: 400,
+ transclude: 'element',
+ compile: function (tElement, tAttrs, $transclude) {
+ return function (scope, $element, attrs) {
+ var previousEl, currentEl, currentScope, latestLocals,
+ onloadExp = attrs.onload || '',
+ autoScrollExp = attrs.autoscroll,
+ renderer = getRenderer(attrs, scope);
+
+ scope.$on('$stateChangeSuccess', function() {
+ updateView(false);
+ });
+ scope.$on('$viewContentLoading', function() {
+ updateView(false);
+ });
+
+ updateView(true);
+
+ function cleanupLastView() {
+ if (previousEl) {
+ previousEl.remove();
+ previousEl = null;
+ }
+
+ if (currentScope) {
+ currentScope.$destroy();
+ currentScope = null;
+ }
+
+ if (currentEl) {
+ renderer.leave(currentEl, function() {
+ previousEl = null;
+ });
+
+ previousEl = currentEl;
+ currentEl = null;
+ }
+ }
+
+ function updateView(firstTime) {
+ var newScope,
+ name = getUiViewName(scope, attrs, $element, $interpolate),
+ previousLocals = name && $state.$current && $state.$current.locals[name];
+
+ if (!firstTime && previousLocals === latestLocals) return; // nothing to do
+ newScope = scope.$new();
+ latestLocals = $state.$current.locals[name];
+
+ var clone = $transclude(newScope, function(clone) {
+ renderer.enter(clone, $element, function onUiViewEnter() {
+ if(currentScope) {
+ currentScope.$emit('$viewContentAnimationEnded');
+ }
+
+ if (angular.isDefined(autoScrollExp) && !autoScrollExp || scope.$eval(autoScrollExp)) {
+ $uiViewScroll(clone);
+ }
+ });
+ cleanupLastView();
+ });
+
+ currentEl = clone;
+ currentScope = newScope;
+ /**
+ * @ngdoc event
+ * @name ui.router.state.directive:ui-view#$viewContentLoaded
+ * @eventOf ui.router.state.directive:ui-view
+ * @eventType emits on ui-view directive scope
+ * @description *
+ * Fired once the view is **loaded**, *after* the DOM is rendered.
+ *
+ * @param {Object} event Event object.
+ */
+ currentScope.$emit('$viewContentLoaded');
+ currentScope.$eval(onloadExp);
+ }
+ };
+ }
+ };
+
+ return directive;
+}
+
+$ViewDirectiveFill.$inject = ['$compile', '$controller', '$state', '$interpolate'];
+function $ViewDirectiveFill ( $compile, $controller, $state, $interpolate) {
+ return {
+ restrict: 'ECA',
+ priority: -400,
+ compile: function (tElement) {
+ var initial = tElement.html();
+ return function (scope, $element, attrs) {
+ var current = $state.$current,
+ name = getUiViewName(scope, attrs, $element, $interpolate),
+ locals = current && current.locals[name];
+
+ if (! locals) {
+ return;
+ }
+
+ $element.data('$uiView', { name: name, state: locals.$$state });
+ $element.html(locals.$template ? locals.$template : initial);
+
+ var link = $compile($element.contents());
+
+ if (locals.$$controller) {
+ locals.$scope = scope;
+ var controller = $controller(locals.$$controller, locals);
+ if (locals.$$controllerAs) {
+ scope[locals.$$controllerAs] = controller;
+ }
+ $element.data('$ngControllerController', controller);
+ $element.children().data('$ngControllerController', controller);
+ }
+
+ link(scope);
+ };
+ }
+ };
+}
+
+/**
+ * Shared ui-view code for both directives:
+ * Given scope, element, and its attributes, return the view's name
+ */
+function getUiViewName(scope, attrs, element, $interpolate) {
+ var name = $interpolate(attrs.uiView || attrs.name || '')(scope);
+ var inherited = element.inheritedData('$uiView');
+ return name.indexOf('@') >= 0 ? name : (name + '@' + (inherited ? inherited.state.name : ''));
+}
+
+angular.module('ui.router.state').directive('uiView', $ViewDirective);
+angular.module('ui.router.state').directive('uiView', $ViewDirectiveFill);
+
+function parseStateRef(ref, current) {
+ var preparsed = ref.match(/^\s*({[^}]*})\s*$/), parsed;
+ if (preparsed) ref = current + '(' + preparsed[1] + ')';
+ parsed = ref.replace(/\n/g, " ").match(/^([^(]+?)\s*(\((.*)\))?$/);
+ if (!parsed || parsed.length !== 4) throw new Error("Invalid state ref '" + ref + "'");
+ return { state: parsed[1], paramExpr: parsed[3] || null };
+}
+
+function stateContext(el) {
+ var stateData = el.parent().inheritedData('$uiView');
+
+ if (stateData && stateData.state && stateData.state.name) {
+ return stateData.state;
+ }
+}
+
+/**
+ * @ngdoc directive
+ * @name ui.router.state.directive:ui-sref
+ *
+ * @requires ui.router.state.$state
+ * @requires $timeout
+ *
+ * @restrict A
+ *
+ * @description
+ * A directive that binds a link (`` tag) to a state. If the state has an associated
+ * URL, the directive will automatically generate & update the `href` attribute via
+ * the {@link ui.router.state.$state#methods_href $state.href()} method. Clicking
+ * the link will trigger a state transition with optional parameters.
+ *
+ * Also middle-clicking, right-clicking, and ctrl-clicking on the link will be
+ * handled natively by the browser.
+ *
+ * You can also use relative state paths within ui-sref, just like the relative
+ * paths passed to `$state.go()`. You just need to be aware that the path is relative
+ * to the state that the link lives in, in other words the state that loaded the
+ * template containing the link.
+ *
+ * You can specify options to pass to {@link ui.router.state.$state#go $state.go()}
+ * using the `ui-sref-opts` attribute. Options are restricted to `location`, `inherit`,
+ * and `reload`.
+ *
+ * @example
+ * Here's an example of how you'd use ui-sref and how it would compile. If you have the
+ * following template:
+ *
+ * Home | About | Next page
+ *
+ *
+ *
+ *
+ *
+ * Then the compiled html would be (assuming Html5Mode is off and current state is contacts):
+ *
+ * Home | About | Next page
+ *
+ *
+ *
+ * Home
+ *
+ *
+ * @param {string} ui-sref 'stateName' can be any valid absolute or relative state
+ * @param {Object} ui-sref-opts options to pass to {@link ui.router.state.$state#go $state.go()}
+ */
+$StateRefDirective.$inject = ['$state', '$timeout'];
+function $StateRefDirective($state, $timeout) {
+ var allowedOptions = ['location', 'inherit', 'reload'];
+
+ return {
+ restrict: 'A',
+ require: ['?^uiSrefActive', '?^uiSrefActiveEq'],
+ link: function(scope, element, attrs, uiSrefActive) {
+ var ref = parseStateRef(attrs.uiSref, $state.current.name);
+ var params = null, url = null, base = stateContext(element) || $state.$current;
+ var newHref = null, isAnchor = element.prop("tagName") === "A";
+ var isForm = element[0].nodeName === "FORM";
+ var attr = isForm ? "action" : "href", nav = true;
+
+ var options = { relative: base, inherit: true };
+ var optionsOverride = scope.$eval(attrs.uiSrefOpts) || {};
+
+ angular.forEach(allowedOptions, function(option) {
+ if (option in optionsOverride) {
+ options[option] = optionsOverride[option];
+ }
+ });
+
+ var update = function(newVal) {
+ if (newVal) params = angular.copy(newVal);
+ if (!nav) return;
+
+ newHref = $state.href(ref.state, params, options);
+
+ var activeDirective = uiSrefActive[1] || uiSrefActive[0];
+ if (activeDirective) {
+ activeDirective.$$setStateInfo(ref.state, params);
+ }
+ if (newHref === null) {
+ nav = false;
+ return false;
+ }
+ attrs.$set(attr, newHref);
+ };
+
+ if (ref.paramExpr) {
+ scope.$watch(ref.paramExpr, function(newVal, oldVal) {
+ if (newVal !== params) update(newVal);
+ }, true);
+ params = angular.copy(scope.$eval(ref.paramExpr));
+ }
+ update();
+
+ if (isForm) return;
+
+ element.bind("click", function(e) {
+ var button = e.which || e.button;
+ if ( !(button > 1 || e.ctrlKey || e.metaKey || e.shiftKey || element.attr('target')) ) {
+ // HACK: This is to allow ng-clicks to be processed before the transition is initiated:
+ var transition = $timeout(function() {
+ $state.go(ref.state, params, options);
+ });
+ e.preventDefault();
+
+ // if the state has no URL, ignore one preventDefault from the directive.
+ var ignorePreventDefaultCount = isAnchor && !newHref ? 1: 0;
+ e.preventDefault = function() {
+ if (ignorePreventDefaultCount-- <= 0)
+ $timeout.cancel(transition);
+ };
+ }
+ });
+ }
+ };
+}
+
+/**
+ * @ngdoc directive
+ * @name ui.router.state.directive:ui-sref-active
+ *
+ * @requires ui.router.state.$state
+ * @requires ui.router.state.$stateParams
+ * @requires $interpolate
+ *
+ * @restrict A
+ *
+ * @description
+ * A directive working alongside ui-sref to add classes to an element when the
+ * related ui-sref directive's state is active, and removing them when it is inactive.
+ * The primary use-case is to simplify the special appearance of navigation menus
+ * relying on `ui-sref`, by having the "active" state's menu button appear different,
+ * distinguishing it from the inactive menu items.
+ *
+ * ui-sref-active can live on the same element as ui-sref or on a parent element. The first
+ * ui-sref-active found at the same level or above the ui-sref will be used.
+ *
+ * Will activate when the ui-sref's target state or any child state is active. If you
+ * need to activate only when the ui-sref target state is active and *not* any of
+ * it's children, then you will use
+ * {@link ui.router.state.directive:ui-sref-active-eq ui-sref-active-eq}
+ *
+ * @example
+ * Given the following template:
+ *
+ *
+ *
+ *
+ *
+ *
+ * When the app state is "app.user" (or any children states), and contains the state parameter "user" with value "bilbobaggins",
+ * the resulting HTML will appear as (note the 'active' class):
+ *
+ *
+ *
+ *
+ *
+ * The class name is interpolated **once** during the directives link time (any further changes to the
+ * interpolated value are ignored).
+ *
+ * Multiple classes may be specified in a space-separated format:
+ *
+ *
+ *
+ *
+ */
+
+/**
+ * @ngdoc directive
+ * @name ui.router.state.directive:ui-sref-active-eq
+ *
+ * @requires ui.router.state.$state
+ * @requires ui.router.state.$stateParams
+ * @requires $interpolate
+ *
+ * @restrict A
+ *
+ * @description
+ * The same as {@link ui.router.state.directive:ui-sref-active ui-sref-active} but will only activate
+ * when the exact target state used in the `ui-sref` is active; no child states.
+ *
+ */
+$StateRefActiveDirective.$inject = ['$state', '$stateParams', '$interpolate'];
+function $StateRefActiveDirective($state, $stateParams, $interpolate) {
+ return {
+ restrict: "A",
+ controller: ['$scope', '$element', '$attrs', function ($scope, $element, $attrs) {
+ var state, params, activeClass;
+
+ // There probably isn't much point in $observing this
+ // uiSrefActive and uiSrefActiveEq share the same directive object with some
+ // slight difference in logic routing
+ activeClass = $interpolate($attrs.uiSrefActiveEq || $attrs.uiSrefActive || '', false)($scope);
+
+ // Allow uiSref to communicate with uiSrefActive[Equals]
+ this.$$setStateInfo = function (newState, newParams) {
+ state = $state.get(newState, stateContext($element));
+ params = newParams;
+ update();
+ };
+
+ $scope.$on('$stateChangeSuccess', update);
+
+ // Update route state
+ function update() {
+ if (isMatch()) {
+ $element.addClass(activeClass);
+ } else {
+ $element.removeClass(activeClass);
+ }
+ }
+
+ function isMatch() {
+ if (typeof $attrs.uiSrefActiveEq !== 'undefined') {
+ return state && $state.is(state.name, params);
+ } else {
+ return state && $state.includes(state.name, params);
+ }
+ }
+ }]
+ };
+}
+
+angular.module('ui.router.state')
+ .directive('uiSref', $StateRefDirective)
+ .directive('uiSrefActive', $StateRefActiveDirective)
+ .directive('uiSrefActiveEq', $StateRefActiveDirective);
+
+/**
+ * @ngdoc filter
+ * @name ui.router.state.filter:isState
+ *
+ * @requires ui.router.state.$state
+ *
+ * @description
+ * Translates to {@link ui.router.state.$state#methods_is $state.is("stateName")}.
+ */
+$IsStateFilter.$inject = ['$state'];
+function $IsStateFilter($state) {
+ var isFilter = function (state) {
+ return $state.is(state);
+ };
+ isFilter.$stateful = true;
+ return isFilter;
+}
+
+/**
+ * @ngdoc filter
+ * @name ui.router.state.filter:includedByState
+ *
+ * @requires ui.router.state.$state
+ *
+ * @description
+ * Translates to {@link ui.router.state.$state#methods_includes $state.includes('fullOrPartialStateName')}.
+ */
+$IncludedByStateFilter.$inject = ['$state'];
+function $IncludedByStateFilter($state) {
+ var includesFilter = function (state) {
+ return $state.includes(state);
+ };
+ includesFilter.$stateful = true;
+ return includesFilter;
+}
+
+angular.module('ui.router.state')
+ .filter('isState', $IsStateFilter)
+ .filter('includedByState', $IncludedByStateFilter);
+})(window, window.angular);
\ No newline at end of file
diff --git a/client/www/lib/angular-ui-router/release/angular-ui-router.min.js b/client/www/lib/angular-ui-router/release/angular-ui-router.min.js
new file mode 100644
index 0000000..be06fb5
--- /dev/null
+++ b/client/www/lib/angular-ui-router/release/angular-ui-router.min.js
@@ -0,0 +1,7 @@
+/**
+ * State-based routing for AngularJS
+ * @version v0.2.13
+ * @link http://angular-ui.github.com/
+ * @license MIT License, http://www.opensource.org/licenses/MIT
+ */
+"undefined"!=typeof module&&"undefined"!=typeof exports&&module.exports===exports&&(module.exports="ui.router"),function(a,b,c){"use strict";function d(a,b){return M(new(M(function(){},{prototype:a})),b)}function e(a){return L(arguments,function(b){b!==a&&L(b,function(b,c){a.hasOwnProperty(c)||(a[c]=b)})}),a}function f(a,b){var c=[];for(var d in a.path){if(a.path[d]!==b.path[d])break;c.push(a.path[d])}return c}function g(a){if(Object.keys)return Object.keys(a);var c=[];return b.forEach(a,function(a,b){c.push(b)}),c}function h(a,b){if(Array.prototype.indexOf)return a.indexOf(b,Number(arguments[2])||0);var c=a.length>>>0,d=Number(arguments[2])||0;for(d=0>d?Math.ceil(d):Math.floor(d),0>d&&(d+=c);c>d;d++)if(d in a&&a[d]===b)return d;return-1}function i(a,b,c,d){var e,i=f(c,d),j={},k=[];for(var l in i)if(i[l].params&&(e=g(i[l].params),e.length))for(var m in e)h(k,e[m])>=0||(k.push(e[m]),j[e[m]]=a[e[m]]);return M({},j,b)}function j(a,b,c){if(!c){c=[];for(var d in a)c.push(d)}for(var e=0;e
+ * $resolve.study(invocables)(locals, parent, self)
+ *
+ * is equivalent to
+ *
+ * $resolve.resolve(invocables, locals, parent, self)
+ *
+ * but the former is more efficient (in fact `resolve` just calls `study`
+ * internally).
+ *
+ * @param {object} invocables Invocable objects
+ * @return {function} a function to pass in locals, parent and self
+ */
+ this.study = function (invocables) {
+ if (!isObject(invocables)) throw new Error("'invocables' must be an object");
+ var invocableKeys = objectKeys(invocables || {});
+
+ // Perform a topological sort of invocables to build an ordered plan
+ var plan = [], cycle = [], visited = {};
+ function visit(value, key) {
+ if (visited[key] === VISIT_DONE) return;
+
+ cycle.push(key);
+ if (visited[key] === VISIT_IN_PROGRESS) {
+ cycle.splice(0, indexOf(cycle, key));
+ throw new Error("Cyclic dependency: " + cycle.join(" -> "));
+ }
+ visited[key] = VISIT_IN_PROGRESS;
+
+ if (isString(value)) {
+ plan.push(key, [ function() { return $injector.get(value); }], NO_DEPENDENCIES);
+ } else {
+ var params = $injector.annotate(value);
+ forEach(params, function (param) {
+ if (param !== key && invocables.hasOwnProperty(param)) visit(invocables[param], param);
+ });
+ plan.push(key, value, params);
+ }
+
+ cycle.pop();
+ visited[key] = VISIT_DONE;
+ }
+ forEach(invocables, visit);
+ invocables = cycle = visited = null; // plan is all that's required
+
+ function isResolve(value) {
+ return isObject(value) && value.then && value.$$promises;
+ }
+
+ return function (locals, parent, self) {
+ if (isResolve(locals) && self === undefined) {
+ self = parent; parent = locals; locals = null;
+ }
+ if (!locals) locals = NO_LOCALS;
+ else if (!isObject(locals)) {
+ throw new Error("'locals' must be an object");
+ }
+ if (!parent) parent = NO_PARENT;
+ else if (!isResolve(parent)) {
+ throw new Error("'parent' must be a promise returned by $resolve.resolve()");
+ }
+
+ // To complete the overall resolution, we have to wait for the parent
+ // promise and for the promise for each invokable in our plan.
+ var resolution = $q.defer(),
+ result = resolution.promise,
+ promises = result.$$promises = {},
+ values = extend({}, locals),
+ wait = 1 + plan.length/3,
+ merged = false;
+
+ function done() {
+ // Merge parent values we haven't got yet and publish our own $$values
+ if (!--wait) {
+ if (!merged) merge(values, parent.$$values);
+ result.$$values = values;
+ result.$$promises = result.$$promises || true; // keep for isResolve()
+ delete result.$$inheritedValues;
+ resolution.resolve(values);
+ }
+ }
+
+ function fail(reason) {
+ result.$$failure = reason;
+ resolution.reject(reason);
+ }
+
+ // Short-circuit if parent has already failed
+ if (isDefined(parent.$$failure)) {
+ fail(parent.$$failure);
+ return result;
+ }
+
+ if (parent.$$inheritedValues) {
+ merge(values, omit(parent.$$inheritedValues, invocableKeys));
+ }
+
+ // Merge parent values if the parent has already resolved, or merge
+ // parent promises and wait if the parent resolve is still in progress.
+ extend(promises, parent.$$promises);
+ if (parent.$$values) {
+ merged = merge(values, omit(parent.$$values, invocableKeys));
+ result.$$inheritedValues = omit(parent.$$values, invocableKeys);
+ done();
+ } else {
+ if (parent.$$inheritedValues) {
+ result.$$inheritedValues = omit(parent.$$inheritedValues, invocableKeys);
+ }
+ parent.then(done, fail);
+ }
+
+ // Process each invocable in the plan, but ignore any where a local of the same name exists.
+ for (var i=0, ii=plan.length; i
+ * // Override the internal 'views' builder with a function that takes the state
+ * // definition, and a reference to the internal function being overridden:
+ * $stateProvider.decorator('views', function (state, parent) {
+ * var result = {},
+ * views = parent(state);
+ *
+ * angular.forEach(views, function (config, name) {
+ * var autoName = (state.name + '.' + name).replace('.', '/');
+ * config.templateUrl = config.templateUrl || '/partials/' + autoName + '.html';
+ * result[name] = config;
+ * });
+ * return result;
+ * });
+ *
+ * $stateProvider.state('home', {
+ * views: {
+ * 'contact.list': { controller: 'ListController' },
+ * 'contact.item': { controller: 'ItemController' }
+ * }
+ * });
+ *
+ * // ...
+ *
+ * $state.go('home');
+ * // Auto-populates list and item views with /partials/home/contact/list.html,
+ * // and /partials/home/contact/item.html, respectively.
+ *
+ *
+ * @param {string} name The name of the builder function to decorate.
+ * @param {object} func A function that is responsible for decorating the original
+ * builder function. The function receives two parameters:
+ *
+ * - `{object}` - state - The state config object.
+ * - `{object}` - super - The original builder function.
+ *
+ * @return {object} $stateProvider - $stateProvider instance
+ */
+ this.decorator = decorator;
+ function decorator(name, func) {
+ /*jshint validthis: true */
+ if (isString(name) && !isDefined(func)) {
+ return stateBuilder[name];
+ }
+ if (!isFunction(func) || !isString(name)) {
+ return this;
+ }
+ if (stateBuilder[name] && !stateBuilder.$delegates[name]) {
+ stateBuilder.$delegates[name] = stateBuilder[name];
+ }
+ stateBuilder[name] = func;
+ return this;
+ }
+
+ /**
+ * @ngdoc function
+ * @name ui.router.state.$stateProvider#state
+ * @methodOf ui.router.state.$stateProvider
+ *
+ * @description
+ * Registers a state configuration under a given state name. The stateConfig object
+ * has the following acceptable properties.
+ *
+ * @param {string} name A unique state name, e.g. "home", "about", "contacts".
+ * To create a parent/child state use a dot, e.g. "about.sales", "home.newest".
+ * @param {object} stateConfig State configuration object.
+ * @param {string|function=} stateConfig.template
+ *
+ * html template as a string or a function that returns
+ * an html template as a string which should be used by the uiView directives. This property
+ * takes precedence over templateUrl.
+ *
+ * If `template` is a function, it will be called with the following parameters:
+ *
+ * - {array.<object>} - state parameters extracted from the current $location.path() by
+ * applying the current state
+ *
+ * template:
+ * "
+ * inline template definition
" +
+ * ""template: function(params) {
+ * return "
+ *
+ *
+ * @param {string|function=} stateConfig.templateUrl
+ *
+ *
+ * path or function that returns a path to an html
+ * template that should be used by uiView.
+ *
+ * If `templateUrl` is a function, it will be called with the following parameters:
+ *
+ * - {array.<object>} - state parameters extracted from the current $location.path() by
+ * applying the current state
+ *
+ * generated template
"; }templateUrl: "home.html"
+ * templateUrl: function(params) {
+ * return myTemplates[params.pageId]; }
+ *
+ * @param {function=} stateConfig.templateProvider
+ *
+ * Provider function that returns HTML content string.
+ * templateProvider:
+ * function(MyTemplateService, params) {
+ * return MyTemplateService.getTemplate(params.pageId);
+ * }
+ *
+ * @param {string|function=} stateConfig.controller
+ *
+ *
+ * Controller fn that should be associated with newly
+ * related scope or the name of a registered controller if passed as a string.
+ * Optionally, the ControllerAs may be declared here.
+ * controller: "MyRegisteredController"
+ * controller:
+ * "MyRegisteredController as fooCtrl"}
+ * controller: function($scope, MyService) {
+ * $scope.data = MyService.getData(); }
+ *
+ * @param {function=} stateConfig.controllerProvider
+ *
+ *
+ * Injectable provider function that returns the actual controller or string.
+ * controllerProvider:
+ * function(MyResolveData) {
+ * if (MyResolveData.foo)
+ * return "FooCtrl"
+ * else if (MyResolveData.bar)
+ * return "BarCtrl";
+ * else return function($scope) {
+ * $scope.baz = "Qux";
+ * }
+ * }
+ *
+ * @param {string=} stateConfig.controllerAs
+ *
+ *
+ * A controller alias name. If present the controller will be
+ * published to scope under the controllerAs name.
+ * controllerAs: "myCtrl"
+ *
+ * @param {object=} stateConfig.resolve
+ *
+ *
+ * An optional map<string, function> of dependencies which
+ * should be injected into the controller. If any of these dependencies are promises,
+ * the router will wait for them all to be resolved before the controller is instantiated.
+ * If all the promises are resolved successfully, the $stateChangeSuccess event is fired
+ * and the values of the resolved promises are injected into any controllers that reference them.
+ * If any of the promises are rejected the $stateChangeError event is fired.
+ *
+ * The map object is:
+ *
+ * - key - {string}: name of dependency to be injected into controller
+ * - factory - {string|function}: If string then it is alias for service. Otherwise if function,
+ * it is injected and return value it treated as dependency. If result is a promise, it is
+ * resolved before its value is injected into controller.
+ *
+ * resolve: {
+ * myResolve1:
+ * function($http, $stateParams) {
+ * return $http.get("/api/foos/"+stateParams.fooID);
+ * }
+ * }
+ *
+ * @param {string=} stateConfig.url
+ *
+ *
+ * A url fragment with optional parameters. When a state is navigated or
+ * transitioned to, the `$stateParams` service will be populated with any
+ * parameters that were passed.
+ *
+ * examples:
+ * url: "/home"
+ * url: "/users/:userid"
+ * url: "/books/{bookid:[a-zA-Z_-]}"
+ * url: "/books/{categoryid:int}"
+ * url: "/books/{publishername:string}/{categoryid:int}"
+ * url: "/messages?before&after"
+ * url: "/messages?{before:date}&{after:date}"
+ * url: "/messages/:mailboxid?{before:date}&{after:date}"
+ *
+ * @param {object=} stateConfig.views
+ *
+ * an optional map<string, object> which defined multiple views, or targets views
+ * manually/explicitly.
+ *
+ * Examples:
+ *
+ * Targets three named `ui-view`s in the parent state's template
+ * views: {
+ * header: {
+ * controller: "headerCtrl",
+ * templateUrl: "header.html"
+ * }, body: {
+ * controller: "bodyCtrl",
+ * templateUrl: "body.html"
+ * }, footer: {
+ * controller: "footCtrl",
+ * templateUrl: "footer.html"
+ * }
+ * }
+ *
+ * Targets named `ui-view="header"` from grandparent state 'top''s template, and named `ui-view="body" from parent state's template.
+ * views: {
+ * 'header@top': {
+ * controller: "msgHeaderCtrl",
+ * templateUrl: "msgHeader.html"
+ * }, 'body': {
+ * controller: "messagesCtrl",
+ * templateUrl: "messages.html"
+ * }
+ * }
+ *
+ * @param {boolean=} [stateConfig.abstract=false]
+ *
+ * An abstract state will never be directly activated,
+ * but can provide inherited properties to its common children states.
+ * abstract: true
+ *
+ * @param {function=} stateConfig.onEnter
+ *
+ *
+ * Callback function for when a state is entered. Good way
+ * to trigger an action or dispatch an event, such as opening a dialog.
+ * If minifying your scripts, make sure to explictly annotate this function,
+ * because it won't be automatically annotated by your build tools.
+ *
+ * onEnter: function(MyService, $stateParams) {
+ * MyService.foo($stateParams.myParam);
+ * }
+ *
+ * @param {function=} stateConfig.onExit
+ *
+ *
+ * Callback function for when a state is exited. Good way to
+ * trigger an action or dispatch an event, such as opening a dialog.
+ * If minifying your scripts, make sure to explictly annotate this function,
+ * because it won't be automatically annotated by your build tools.
+ *
+ * onExit: function(MyService, $stateParams) {
+ * MyService.cleanup($stateParams.myParam);
+ * }
+ *
+ * @param {boolean=} [stateConfig.reloadOnSearch=true]
+ *
+ *
+ * If `false`, will not retrigger the same state
+ * just because a search/query parameter has changed (via $location.search() or $location.hash()).
+ * Useful for when you'd like to modify $location.search() without triggering a reload.
+ * reloadOnSearch: false
+ *
+ * @param {object=} stateConfig.data
+ *
+ *
+ * Arbitrary data object, useful for custom configuration. The parent state's `data` is
+ * prototypally inherited. In other words, adding a data property to a state adds it to
+ * the entire subtree via prototypal inheritance.
+ *
+ * data: {
+ * requiredRole: 'foo'
+ * }
+ *
+ * @param {object=} stateConfig.params
+ *
+ *
+ * A map which optionally configures parameters declared in the `url`, or
+ * defines additional non-url parameters. For each parameter being
+ * configured, add a configuration object keyed to the name of the parameter.
+ *
+ * Each parameter configuration object may contain the following properties:
+ *
+ * - ** value ** - {object|function=}: specifies the default value for this
+ * parameter. This implicitly sets this parameter as optional.
+ *
+ * When UI-Router routes to a state and no value is
+ * specified for this parameter in the URL or transition, the
+ * default value will be used instead. If `value` is a function,
+ * it will be injected and invoked, and the return value used.
+ *
+ * *Note*: `undefined` is treated as "no default value" while `null`
+ * is treated as "the default value is `null`".
+ *
+ * *Shorthand*: If you only need to configure the default value of the
+ * parameter, you may use a shorthand syntax. In the **`params`**
+ * map, instead mapping the param name to a full parameter configuration
+ * object, simply set map it to the default parameter value, e.g.:
+ *
+ * // define a parameter's default value
+ * params: {
+ * param1: { value: "defaultValue" }
+ * }
+ * // shorthand default values
+ * params: {
+ * param1: "defaultValue",
+ * param2: "param2Default"
+ * }
+ *
+ * - ** array ** - {boolean=}: *(default: false)* If true, the param value will be
+ * treated as an array of values. If you specified a Type, the value will be
+ * treated as an array of the specified Type. Note: query parameter values
+ * default to a special `"auto"` mode.
+ *
+ * For query parameters in `"auto"` mode, if multiple values for a single parameter
+ * are present in the URL (e.g.: `/foo?bar=1&bar=2&bar=3`) then the values
+ * are mapped to an array (e.g.: `{ foo: [ '1', '2', '3' ] }`). However, if
+ * only one value is present (e.g.: `/foo?bar=1`) then the value is treated as single
+ * value (e.g.: `{ foo: '1' }`).
+ *
+ * params: {
+ * param1: { array: true }
+ * }
+ *
+ * - ** squash ** - {bool|string=}: `squash` configures how a default parameter value is represented in the URL when
+ * the current parameter value is the same as the default value. If `squash` is not set, it uses the
+ * configured default squash policy.
+ * (See {@link ui.router.util.$urlMatcherFactory#methods_defaultSquashPolicy `defaultSquashPolicy()`})
+ *
+ * There are three squash settings:
+ *
+ * - false: The parameter's default value is not squashed. It is encoded and included in the URL
+ * - true: The parameter's default value is omitted from the URL. If the parameter is preceeded and followed
+ * by slashes in the state's `url` declaration, then one of those slashes are omitted.
+ * This can allow for cleaner looking URLs.
+ * - `"params: {
+ * param1: {
+ * value: "defaultId",
+ * squash: true
+ * } }
+ * // squash "defaultValue" to "~"
+ * params: {
+ * param1: {
+ * value: "defaultValue",
+ * squash: "~"
+ * } }
+ *
+ *
+ *
+ * @example
+ *
+ * // Some state name examples
+ *
+ * // stateName can be a single top-level name (must be unique).
+ * $stateProvider.state("home", {});
+ *
+ * // Or it can be a nested state name. This state is a child of the
+ * // above "home" state.
+ * $stateProvider.state("home.newest", {});
+ *
+ * // Nest states as deeply as needed.
+ * $stateProvider.state("home.newest.abc.xyz.inception", {});
+ *
+ * // state() returns $stateProvider, so you can chain state declarations.
+ * $stateProvider
+ * .state("home", {})
+ * .state("about", {})
+ * .state("contacts", {});
+ *
+ *
+ */
+ this.state = state;
+ function state(name, definition) {
+ /*jshint validthis: true */
+ if (isObject(name)) definition = name;
+ else definition.name = name;
+ registerState(definition);
+ return this;
+ }
+
+ /**
+ * @ngdoc object
+ * @name ui.router.state.$state
+ *
+ * @requires $rootScope
+ * @requires $q
+ * @requires ui.router.state.$view
+ * @requires $injector
+ * @requires ui.router.util.$resolve
+ * @requires ui.router.state.$stateParams
+ * @requires ui.router.router.$urlRouter
+ *
+ * @property {object} params A param object, e.g. {sectionId: section.id)}, that
+ * you'd like to test against the current active state.
+ * @property {object} current A reference to the state's config object. However
+ * you passed it in. Useful for accessing custom data.
+ * @property {object} transition Currently pending transition. A promise that'll
+ * resolve or reject.
+ *
+ * @description
+ * `$state` service is responsible for representing states as well as transitioning
+ * between them. It also provides interfaces to ask for current state or even states
+ * you're coming from.
+ */
+ this.$get = $get;
+ $get.$inject = ['$rootScope', '$q', '$view', '$injector', '$resolve', '$stateParams', '$urlRouter', '$location', '$urlMatcherFactory'];
+ function $get( $rootScope, $q, $view, $injector, $resolve, $stateParams, $urlRouter, $location, $urlMatcherFactory) {
+
+ var TransitionSuperseded = $q.reject(new Error('transition superseded'));
+ var TransitionPrevented = $q.reject(new Error('transition prevented'));
+ var TransitionAborted = $q.reject(new Error('transition aborted'));
+ var TransitionFailed = $q.reject(new Error('transition failed'));
+
+ // Handles the case where a state which is the target of a transition is not found, and the user
+ // can optionally retry or defer the transition
+ function handleRedirect(redirect, state, params, options) {
+ /**
+ * @ngdoc event
+ * @name ui.router.state.$state#$stateNotFound
+ * @eventOf ui.router.state.$state
+ * @eventType broadcast on root scope
+ * @description
+ * Fired when a requested state **cannot be found** using the provided state name during transition.
+ * The event is broadcast allowing any handlers a single chance to deal with the error (usually by
+ * lazy-loading the unfound state). A special `unfoundState` object is passed to the listener handler,
+ * you can see its three properties in the example. You can use `event.preventDefault()` to abort the
+ * transition and the promise returned from `go` will be rejected with a `'transition aborted'` value.
+ *
+ * @param {Object} event Event object.
+ * @param {Object} unfoundState Unfound State information. Contains: `to, toParams, options` properties.
+ * @param {State} fromState Current state object.
+ * @param {Object} fromParams Current state params.
+ *
+ * @example
+ *
+ *
+ * // somewhere, assume lazy.state has not been defined
+ * $state.go("lazy.state", {a:1, b:2}, {inherit:false});
+ *
+ * // somewhere else
+ * $scope.$on('$stateNotFound',
+ * function(event, unfoundState, fromState, fromParams){
+ * console.log(unfoundState.to); // "lazy.state"
+ * console.log(unfoundState.toParams); // {a:1, b:2}
+ * console.log(unfoundState.options); // {inherit:false} + default options
+ * })
+ *
+ */
+ var evt = $rootScope.$broadcast('$stateNotFound', redirect, state, params);
+
+ if (evt.defaultPrevented) {
+ $urlRouter.update();
+ return TransitionAborted;
+ }
+
+ if (!evt.retry) {
+ return null;
+ }
+
+ // Allow the handler to return a promise to defer state lookup retry
+ if (options.$retry) {
+ $urlRouter.update();
+ return TransitionFailed;
+ }
+ var retryTransition = $state.transition = $q.when(evt.retry);
+
+ retryTransition.then(function() {
+ if (retryTransition !== $state.transition) return TransitionSuperseded;
+ redirect.options.$retry = true;
+ return $state.transitionTo(redirect.to, redirect.toParams, redirect.options);
+ }, function() {
+ return TransitionAborted;
+ });
+ $urlRouter.update();
+
+ return retryTransition;
+ }
+
+ root.locals = { resolve: null, globals: { $stateParams: {} } };
+
+ $state = {
+ params: {},
+ current: root.self,
+ $current: root,
+ transition: null
+ };
+
+ /**
+ * @ngdoc function
+ * @name ui.router.state.$state#reload
+ * @methodOf ui.router.state.$state
+ *
+ * @description
+ * A method that force reloads the current state. All resolves are re-resolved, events are not re-fired,
+ * and controllers reinstantiated (bug with controllers reinstantiating right now, fixing soon).
+ *
+ * @example
+ *
+ * var app angular.module('app', ['ui.router']);
+ *
+ * app.controller('ctrl', function ($scope, $state) {
+ * $scope.reload = function(){
+ * $state.reload();
+ * }
+ * });
+ *
+ *
+ * `reload()` is just an alias for:
+ *
+ * $state.transitionTo($state.current, $stateParams, {
+ * reload: true, inherit: false, notify: true
+ * });
+ *
+ *
+ * @returns {promise} A promise representing the state of the new transition. See
+ * {@link ui.router.state.$state#methods_go $state.go}.
+ */
+ $state.reload = function reload() {
+ return $state.transitionTo($state.current, $stateParams, { reload: true, inherit: false, notify: true });
+ };
+
+ /**
+ * @ngdoc function
+ * @name ui.router.state.$state#go
+ * @methodOf ui.router.state.$state
+ *
+ * @description
+ * Convenience method for transitioning to a new state. `$state.go` calls
+ * `$state.transitionTo` internally but automatically sets options to
+ * `{ location: true, inherit: true, relative: $state.$current, notify: true }`.
+ * This allows you to easily use an absolute or relative to path and specify
+ * only the parameters you'd like to update (while letting unspecified parameters
+ * inherit from the currently active ancestor states).
+ *
+ * @example
+ *
+ * var app = angular.module('app', ['ui.router']);
+ *
+ * app.controller('ctrl', function ($scope, $state) {
+ * $scope.changeState = function () {
+ * $state.go('contact.detail');
+ * };
+ * });
+ *
+ *
+ *
+ * @param {string} to Absolute state name or relative state path. Some examples:
+ *
+ * - `$state.go('contact.detail')` - will go to the `contact.detail` state
+ * - `$state.go('^')` - will go to a parent state
+ * - `$state.go('^.sibling')` - will go to a sibling state
+ * - `$state.go('.child.grandchild')` - will go to grandchild state
+ *
+ * @param {object=} params A map of the parameters that will be sent to the state,
+ * will populate $stateParams. Any parameters that are not specified will be inherited from currently
+ * defined parameters. This allows, for example, going to a sibling state that shares parameters
+ * specified in a parent state. Parameter inheritance only works between common ancestor states, I.e.
+ * transitioning to a sibling will get you the parameters for all parents, transitioning to a child
+ * will get you all current parameters, etc.
+ * @param {object=} options Options object. The options are:
+ *
+ * - **`location`** - {boolean=true|string=} - If `true` will update the url in the location bar, if `false`
+ * will not. If string, must be `"replace"`, which will update url and also replace last history record.
+ * - **`inherit`** - {boolean=true}, If `true` will inherit url parameters from current url.
+ * - **`relative`** - {object=$state.$current}, When transitioning with relative path (e.g '^'),
+ * defines which state to be relative from.
+ * - **`notify`** - {boolean=true}, If `true` will broadcast $stateChangeStart and $stateChangeSuccess events.
+ * - **`reload`** (v0.2.5) - {boolean=false}, If `true` will force transition even if the state or params
+ * have not changed, aka a reload of the same state. It differs from reloadOnSearch because you'd
+ * use this when you want to force a reload when *everything* is the same, including search params.
+ *
+ * @returns {promise} A promise representing the state of the new transition.
+ *
+ * Possible success values:
+ *
+ * - $state.current
+ *
+ *
Possible rejection values:
+ *
+ * - 'transition superseded' - when a newer transition has been started after this one
+ * - 'transition prevented' - when `event.preventDefault()` has been called in a `$stateChangeStart` listener
+ * - 'transition aborted' - when `event.preventDefault()` has been called in a `$stateNotFound` listener or
+ * when a `$stateNotFound` `event.retry` promise errors.
+ * - 'transition failed' - when a state has been unsuccessfully found after 2 tries.
+ * - *resolve error* - when an error has occurred with a `resolve`
+ *
+ */
+ $state.go = function go(to, params, options) {
+ return $state.transitionTo(to, params, extend({ inherit: true, relative: $state.$current }, options));
+ };
+
+ /**
+ * @ngdoc function
+ * @name ui.router.state.$state#transitionTo
+ * @methodOf ui.router.state.$state
+ *
+ * @description
+ * Low-level method for transitioning to a new state. {@link ui.router.state.$state#methods_go $state.go}
+ * uses `transitionTo` internally. `$state.go` is recommended in most situations.
+ *
+ * @example
+ *
+ * var app = angular.module('app', ['ui.router']);
+ *
+ * app.controller('ctrl', function ($scope, $state) {
+ * $scope.changeState = function () {
+ * $state.transitionTo('contact.detail');
+ * };
+ * });
+ *
+ *
+ * @param {string} to State name.
+ * @param {object=} toParams A map of the parameters that will be sent to the state,
+ * will populate $stateParams.
+ * @param {object=} options Options object. The options are:
+ *
+ * - **`location`** - {boolean=true|string=} - If `true` will update the url in the location bar, if `false`
+ * will not. If string, must be `"replace"`, which will update url and also replace last history record.
+ * - **`inherit`** - {boolean=false}, If `true` will inherit url parameters from current url.
+ * - **`relative`** - {object=}, When transitioning with relative path (e.g '^'),
+ * defines which state to be relative from.
+ * - **`notify`** - {boolean=true}, If `true` will broadcast $stateChangeStart and $stateChangeSuccess events.
+ * - **`reload`** (v0.2.5) - {boolean=false}, If `true` will force transition even if the state or params
+ * have not changed, aka a reload of the same state. It differs from reloadOnSearch because you'd
+ * use this when you want to force a reload when *everything* is the same, including search params.
+ *
+ * @returns {promise} A promise representing the state of the new transition. See
+ * {@link ui.router.state.$state#methods_go $state.go}.
+ */
+ $state.transitionTo = function transitionTo(to, toParams, options) {
+ toParams = toParams || {};
+ options = extend({
+ location: true, inherit: false, relative: null, notify: true, reload: false, $retry: false
+ }, options || {});
+
+ var from = $state.$current, fromParams = $state.params, fromPath = from.path;
+ var evt, toState = findState(to, options.relative);
+
+ if (!isDefined(toState)) {
+ var redirect = { to: to, toParams: toParams, options: options };
+ var redirectResult = handleRedirect(redirect, from.self, fromParams, options);
+
+ if (redirectResult) {
+ return redirectResult;
+ }
+
+ // Always retry once if the $stateNotFound was not prevented
+ // (handles either redirect changed or state lazy-definition)
+ to = redirect.to;
+ toParams = redirect.toParams;
+ options = redirect.options;
+ toState = findState(to, options.relative);
+
+ if (!isDefined(toState)) {
+ if (!options.relative) throw new Error("No such state '" + to + "'");
+ throw new Error("Could not resolve '" + to + "' from state '" + options.relative + "'");
+ }
+ }
+ if (toState[abstractKey]) throw new Error("Cannot transition to abstract state '" + to + "'");
+ if (options.inherit) toParams = inheritParams($stateParams, toParams || {}, $state.$current, toState);
+ if (!toState.params.$$validates(toParams)) return TransitionFailed;
+
+ toParams = toState.params.$$values(toParams);
+ to = toState;
+
+ var toPath = to.path;
+
+ // Starting from the root of the path, keep all levels that haven't changed
+ var keep = 0, state = toPath[keep], locals = root.locals, toLocals = [];
+
+ if (!options.reload) {
+ while (state && state === fromPath[keep] && state.ownParams.$$equals(toParams, fromParams)) {
+ locals = toLocals[keep] = state.locals;
+ keep++;
+ state = toPath[keep];
+ }
+ }
+
+ // If we're going to the same state and all locals are kept, we've got nothing to do.
+ // But clear 'transition', as we still want to cancel any other pending transitions.
+ // TODO: We may not want to bump 'transition' if we're called from a location change
+ // that we've initiated ourselves, because we might accidentally abort a legitimate
+ // transition initiated from code?
+ if (shouldTriggerReload(to, from, locals, options)) {
+ if (to.self.reloadOnSearch !== false) $urlRouter.update();
+ $state.transition = null;
+ return $q.when($state.current);
+ }
+
+ // Filter parameters before we pass them to event handlers etc.
+ toParams = filterByKeys(to.params.$$keys(), toParams || {});
+
+ // Broadcast start event and cancel the transition if requested
+ if (options.notify) {
+ /**
+ * @ngdoc event
+ * @name ui.router.state.$state#$stateChangeStart
+ * @eventOf ui.router.state.$state
+ * @eventType broadcast on root scope
+ * @description
+ * Fired when the state transition **begins**. You can use `event.preventDefault()`
+ * to prevent the transition from happening and then the transition promise will be
+ * rejected with a `'transition prevented'` value.
+ *
+ * @param {Object} event Event object.
+ * @param {State} toState The state being transitioned to.
+ * @param {Object} toParams The params supplied to the `toState`.
+ * @param {State} fromState The current state, pre-transition.
+ * @param {Object} fromParams The params supplied to the `fromState`.
+ *
+ * @example
+ *
+ *
+ * $rootScope.$on('$stateChangeStart',
+ * function(event, toState, toParams, fromState, fromParams){
+ * event.preventDefault();
+ * // transitionTo() promise will be rejected with
+ * // a 'transition prevented' error
+ * })
+ *
+ */
+ if ($rootScope.$broadcast('$stateChangeStart', to.self, toParams, from.self, fromParams).defaultPrevented) {
+ $urlRouter.update();
+ return TransitionPrevented;
+ }
+ }
+
+ // Resolve locals for the remaining states, but don't update any global state just
+ // yet -- if anything fails to resolve the current state needs to remain untouched.
+ // We also set up an inheritance chain for the locals here. This allows the view directive
+ // to quickly look up the correct definition for each view in the current state. Even
+ // though we create the locals object itself outside resolveState(), it is initially
+ // empty and gets filled asynchronously. We need to keep track of the promise for the
+ // (fully resolved) current locals, and pass this down the chain.
+ var resolved = $q.when(locals);
+
+ for (var l = keep; l < toPath.length; l++, state = toPath[l]) {
+ locals = toLocals[l] = inherit(locals);
+ resolved = resolveState(state, toParams, state === to, resolved, locals, options);
+ }
+
+ // Once everything is resolved, we are ready to perform the actual transition
+ // and return a promise for the new state. We also keep track of what the
+ // current promise is, so that we can detect overlapping transitions and
+ // keep only the outcome of the last transition.
+ var transition = $state.transition = resolved.then(function () {
+ var l, entering, exiting;
+
+ if ($state.transition !== transition) return TransitionSuperseded;
+
+ // Exit 'from' states not kept
+ for (l = fromPath.length - 1; l >= keep; l--) {
+ exiting = fromPath[l];
+ if (exiting.self.onExit) {
+ $injector.invoke(exiting.self.onExit, exiting.self, exiting.locals.globals);
+ }
+ exiting.locals = null;
+ }
+
+ // Enter 'to' states not kept
+ for (l = keep; l < toPath.length; l++) {
+ entering = toPath[l];
+ entering.locals = toLocals[l];
+ if (entering.self.onEnter) {
+ $injector.invoke(entering.self.onEnter, entering.self, entering.locals.globals);
+ }
+ }
+
+ // Run it again, to catch any transitions in callbacks
+ if ($state.transition !== transition) return TransitionSuperseded;
+
+ // Update globals in $state
+ $state.$current = to;
+ $state.current = to.self;
+ $state.params = toParams;
+ copy($state.params, $stateParams);
+ $state.transition = null;
+
+ if (options.location && to.navigable) {
+ $urlRouter.push(to.navigable.url, to.navigable.locals.globals.$stateParams, {
+ $$avoidResync: true, replace: options.location === 'replace'
+ });
+ }
+
+ if (options.notify) {
+ /**
+ * @ngdoc event
+ * @name ui.router.state.$state#$stateChangeSuccess
+ * @eventOf ui.router.state.$state
+ * @eventType broadcast on root scope
+ * @description
+ * Fired once the state transition is **complete**.
+ *
+ * @param {Object} event Event object.
+ * @param {State} toState The state being transitioned to.
+ * @param {Object} toParams The params supplied to the `toState`.
+ * @param {State} fromState The current state, pre-transition.
+ * @param {Object} fromParams The params supplied to the `fromState`.
+ */
+ $rootScope.$broadcast('$stateChangeSuccess', to.self, toParams, from.self, fromParams);
+ }
+ $urlRouter.update(true);
+
+ return $state.current;
+ }, function (error) {
+ if ($state.transition !== transition) return TransitionSuperseded;
+
+ $state.transition = null;
+ /**
+ * @ngdoc event
+ * @name ui.router.state.$state#$stateChangeError
+ * @eventOf ui.router.state.$state
+ * @eventType broadcast on root scope
+ * @description
+ * Fired when an **error occurs** during transition. It's important to note that if you
+ * have any errors in your resolve functions (javascript errors, non-existent services, etc)
+ * they will not throw traditionally. You must listen for this $stateChangeError event to
+ * catch **ALL** errors.
+ *
+ * @param {Object} event Event object.
+ * @param {State} toState The state being transitioned to.
+ * @param {Object} toParams The params supplied to the `toState`.
+ * @param {State} fromState The current state, pre-transition.
+ * @param {Object} fromParams The params supplied to the `fromState`.
+ * @param {Error} error The resolve error object.
+ */
+ evt = $rootScope.$broadcast('$stateChangeError', to.self, toParams, from.self, fromParams, error);
+
+ if (!evt.defaultPrevented) {
+ $urlRouter.update();
+ }
+
+ return $q.reject(error);
+ });
+
+ return transition;
+ };
+
+ /**
+ * @ngdoc function
+ * @name ui.router.state.$state#is
+ * @methodOf ui.router.state.$state
+ *
+ * @description
+ * Similar to {@link ui.router.state.$state#methods_includes $state.includes},
+ * but only checks for the full state name. If params is supplied then it will be
+ * tested for strict equality against the current active params object, so all params
+ * must match with none missing and no extras.
+ *
+ * @example
+ *
+ * $state.$current.name = 'contacts.details.item';
+ *
+ * // absolute name
+ * $state.is('contact.details.item'); // returns true
+ * $state.is(contactDetailItemStateObject); // returns true
+ *
+ * // relative name (. and ^), typically from a template
+ * // E.g. from the 'contacts.details' template
+ *
+ *
+ * @param {string|object} stateOrName The state name (absolute or relative) or state object you'd like to check.
+ * @param {object=} params A param object, e.g. `{sectionId: section.id}`, that you'd like
+ * to test against the current active state.
+ * @param {object=} options An options object. The options are:
+ *
+ * - **`relative`** - {string|object} - If `stateOrName` is a relative state name and `options.relative` is set, .is will
+ * test relative to `options.relative` state (or name).
+ *
+ * @returns {boolean} Returns true if it is the state.
+ */
+ $state.is = function is(stateOrName, params, options) {
+ options = extend({ relative: $state.$current }, options || {});
+ var state = findState(stateOrName, options.relative);
+
+ if (!isDefined(state)) { return undefined; }
+ if ($state.$current !== state) { return false; }
+ return params ? equalForKeys(state.params.$$values(params), $stateParams) : true;
+ };
+
+ /**
+ * @ngdoc function
+ * @name ui.router.state.$state#includes
+ * @methodOf ui.router.state.$state
+ *
+ * @description
+ * A method to determine if the current active state is equal to or is the child of the
+ * state stateName. If any params are passed then they will be tested for a match as well.
+ * Not all the parameters need to be passed, just the ones you'd like to test for equality.
+ *
+ * @example
+ * Partial and relative names
+ *
+ * $state.$current.name = 'contacts.details.item';
+ *
+ * // Using partial names
+ * $state.includes("contacts"); // returns true
+ * $state.includes("contacts.details"); // returns true
+ * $state.includes("contacts.details.item"); // returns true
+ * $state.includes("contacts.list"); // returns false
+ * $state.includes("about"); // returns false
+ *
+ * // Using relative names (. and ^), typically from a template
+ * // E.g. from the 'contacts.details' template
+ *
+ *
+ * Basic globbing patterns
+ *
+ * $state.$current.name = 'contacts.details.item.url';
+ *
+ * $state.includes("*.details.*.*"); // returns true
+ * $state.includes("*.details.**"); // returns true
+ * $state.includes("**.item.**"); // returns true
+ * $state.includes("*.details.item.url"); // returns true
+ * $state.includes("*.details.*.url"); // returns true
+ * $state.includes("*.details.*"); // returns false
+ * $state.includes("item.**"); // returns false
+ *
+ *
+ * @param {string} stateOrName A partial name, relative name, or glob pattern
+ * to be searched for within the current state name.
+ * @param {object=} params A param object, e.g. `{sectionId: section.id}`,
+ * that you'd like to test against the current active state.
+ * @param {object=} options An options object. The options are:
+ *
+ * - **`relative`** - {string|object=} - If `stateOrName` is a relative state reference and `options.relative` is set,
+ * .includes will test relative to `options.relative` state (or name).
+ *
+ * @returns {boolean} Returns true if it does include the state
+ */
+ $state.includes = function includes(stateOrName, params, options) {
+ options = extend({ relative: $state.$current }, options || {});
+ if (isString(stateOrName) && isGlob(stateOrName)) {
+ if (!doesStateMatchGlob(stateOrName)) {
+ return false;
+ }
+ stateOrName = $state.$current.name;
+ }
+
+ var state = findState(stateOrName, options.relative);
+ if (!isDefined(state)) { return undefined; }
+ if (!isDefined($state.$current.includes[state.name])) { return false; }
+ return params ? equalForKeys(state.params.$$values(params), $stateParams, objectKeys(params)) : true;
+ };
+
+
+ /**
+ * @ngdoc function
+ * @name ui.router.state.$state#href
+ * @methodOf ui.router.state.$state
+ *
+ * @description
+ * A url generation method that returns the compiled url for the given state populated with the given params.
+ *
+ * @example
+ *
+ * expect($state.href("about.person", { person: "bob" })).toEqual("/about/bob");
+ *
+ *
+ * @param {string|object} stateOrName The state name or state object you'd like to generate a url from.
+ * @param {object=} params An object of parameter values to fill the state's required parameters.
+ * @param {object=} options Options object. The options are:
+ *
+ * - **`lossy`** - {boolean=true} - If true, and if there is no url associated with the state provided in the
+ * first parameter, then the constructed href url will be built from the first navigable ancestor (aka
+ * ancestor with a valid url).
+ * - **`inherit`** - {boolean=true}, If `true` will inherit url parameters from current url.
+ * - **`relative`** - {object=$state.$current}, When transitioning with relative path (e.g '^'),
+ * defines which state to be relative from.
+ * - **`absolute`** - {boolean=false}, If true will generate an absolute url, e.g. "http://www.example.com/fullurl".
+ *
+ * @returns {string} compiled state url
+ */
+ $state.href = function href(stateOrName, params, options) {
+ options = extend({
+ lossy: true,
+ inherit: true,
+ absolute: false,
+ relative: $state.$current
+ }, options || {});
+
+ var state = findState(stateOrName, options.relative);
+
+ if (!isDefined(state)) return null;
+ if (options.inherit) params = inheritParams($stateParams, params || {}, $state.$current, state);
+
+ var nav = (state && options.lossy) ? state.navigable : state;
+
+ if (!nav || nav.url === undefined || nav.url === null) {
+ return null;
+ }
+ return $urlRouter.href(nav.url, filterByKeys(state.params.$$keys(), params || {}), {
+ absolute: options.absolute
+ });
+ };
+
+ /**
+ * @ngdoc function
+ * @name ui.router.state.$state#get
+ * @methodOf ui.router.state.$state
+ *
+ * @description
+ * Returns the state configuration object for any specific state or all states.
+ *
+ * @param {string|object=} stateOrName (absolute or relative) If provided, will only get the config for
+ * the requested state. If not provided, returns an array of ALL state configs.
+ * @param {string|object=} context When stateOrName is a relative state reference, the state will be retrieved relative to context.
+ * @returns {Object|Array} State configuration object or array of all objects.
+ */
+ $state.get = function (stateOrName, context) {
+ if (arguments.length === 0) return map(objectKeys(states), function(name) { return states[name].self; });
+ var state = findState(stateOrName, context || $state.$current);
+ return (state && state.self) ? state.self : null;
+ };
+
+ function resolveState(state, params, paramsAreFiltered, inherited, dst, options) {
+ // Make a restricted $stateParams with only the parameters that apply to this state if
+ // necessary. In addition to being available to the controller and onEnter/onExit callbacks,
+ // we also need $stateParams to be available for any $injector calls we make during the
+ // dependency resolution process.
+ var $stateParams = (paramsAreFiltered) ? params : filterByKeys(state.params.$$keys(), params);
+ var locals = { $stateParams: $stateParams };
+
+ // Resolve 'global' dependencies for the state, i.e. those not specific to a view.
+ // We're also including $stateParams in this; that way the parameters are restricted
+ // to the set that should be visible to the state, and are independent of when we update
+ // the global $state and $stateParams values.
+ dst.resolve = $resolve.resolve(state.resolve, locals, dst.resolve, state);
+ var promises = [dst.resolve.then(function (globals) {
+ dst.globals = globals;
+ })];
+ if (inherited) promises.push(inherited);
+
+ // Resolve template and dependencies for all views.
+ forEach(state.views, function (view, name) {
+ var injectables = (view.resolve && view.resolve !== state.resolve ? view.resolve : {});
+ injectables.$template = [ function () {
+ return $view.load(name, { view: view, locals: locals, params: $stateParams, notify: options.notify }) || '';
+ }];
+
+ promises.push($resolve.resolve(injectables, locals, dst.resolve, state).then(function (result) {
+ // References to the controller (only instantiated at link time)
+ if (isFunction(view.controllerProvider) || isArray(view.controllerProvider)) {
+ var injectLocals = angular.extend({}, injectables, locals);
+ result.$$controller = $injector.invoke(view.controllerProvider, null, injectLocals);
+ } else {
+ result.$$controller = view.controller;
+ }
+ // Provide access to the state itself for internal use
+ result.$$state = state;
+ result.$$controllerAs = view.controllerAs;
+ dst[name] = result;
+ }));
+ });
+
+ // Wait for all the promises and then return the activation object
+ return $q.all(promises).then(function (values) {
+ return dst;
+ });
+ }
+
+ return $state;
+ }
+
+ function shouldTriggerReload(to, from, locals, options) {
+ if (to === from && ((locals === from.locals && !options.reload) || (to.self.reloadOnSearch === false))) {
+ return true;
+ }
+ }
+}
+
+angular.module('ui.router.state')
+ .value('$stateParams', {})
+ .provider('$state', $StateProvider);
diff --git a/client/www/lib/angular-ui-router/src/stateDirectives.js b/client/www/lib/angular-ui-router/src/stateDirectives.js
new file mode 100644
index 0000000..4d9d527
--- /dev/null
+++ b/client/www/lib/angular-ui-router/src/stateDirectives.js
@@ -0,0 +1,268 @@
+function parseStateRef(ref, current) {
+ var preparsed = ref.match(/^\s*({[^}]*})\s*$/), parsed;
+ if (preparsed) ref = current + '(' + preparsed[1] + ')';
+ parsed = ref.replace(/\n/g, " ").match(/^([^(]+?)\s*(\((.*)\))?$/);
+ if (!parsed || parsed.length !== 4) throw new Error("Invalid state ref '" + ref + "'");
+ return { state: parsed[1], paramExpr: parsed[3] || null };
+}
+
+function stateContext(el) {
+ var stateData = el.parent().inheritedData('$uiView');
+
+ if (stateData && stateData.state && stateData.state.name) {
+ return stateData.state;
+ }
+}
+
+/**
+ * @ngdoc directive
+ * @name ui.router.state.directive:ui-sref
+ *
+ * @requires ui.router.state.$state
+ * @requires $timeout
+ *
+ * @restrict A
+ *
+ * @description
+ * A directive that binds a link (`` tag) to a state. If the state has an associated
+ * URL, the directive will automatically generate & update the `href` attribute via
+ * the {@link ui.router.state.$state#methods_href $state.href()} method. Clicking
+ * the link will trigger a state transition with optional parameters.
+ *
+ * Also middle-clicking, right-clicking, and ctrl-clicking on the link will be
+ * handled natively by the browser.
+ *
+ * You can also use relative state paths within ui-sref, just like the relative
+ * paths passed to `$state.go()`. You just need to be aware that the path is relative
+ * to the state that the link lives in, in other words the state that loaded the
+ * template containing the link.
+ *
+ * You can specify options to pass to {@link ui.router.state.$state#go $state.go()}
+ * using the `ui-sref-opts` attribute. Options are restricted to `location`, `inherit`,
+ * and `reload`.
+ *
+ * @example
+ * Here's an example of how you'd use ui-sref and how it would compile. If you have the
+ * following template:
+ *
+ * Home | About | Next page
+ *
+ *
+ *
+ *
+ *
+ * Then the compiled html would be (assuming Html5Mode is off and current state is contacts):
+ *
+ * Home | About | Next page
+ *
+ *
+ *
+ * Home
+ *
+ *
+ * @param {string} ui-sref 'stateName' can be any valid absolute or relative state
+ * @param {Object} ui-sref-opts options to pass to {@link ui.router.state.$state#go $state.go()}
+ */
+$StateRefDirective.$inject = ['$state', '$timeout'];
+function $StateRefDirective($state, $timeout) {
+ var allowedOptions = ['location', 'inherit', 'reload'];
+
+ return {
+ restrict: 'A',
+ require: ['?^uiSrefActive', '?^uiSrefActiveEq'],
+ link: function(scope, element, attrs, uiSrefActive) {
+ var ref = parseStateRef(attrs.uiSref, $state.current.name);
+ var params = null, url = null, base = stateContext(element) || $state.$current;
+ var newHref = null, isAnchor = element.prop("tagName") === "A";
+ var isForm = element[0].nodeName === "FORM";
+ var attr = isForm ? "action" : "href", nav = true;
+
+ var options = { relative: base, inherit: true };
+ var optionsOverride = scope.$eval(attrs.uiSrefOpts) || {};
+
+ angular.forEach(allowedOptions, function(option) {
+ if (option in optionsOverride) {
+ options[option] = optionsOverride[option];
+ }
+ });
+
+ var update = function(newVal) {
+ if (newVal) params = angular.copy(newVal);
+ if (!nav) return;
+
+ newHref = $state.href(ref.state, params, options);
+
+ var activeDirective = uiSrefActive[1] || uiSrefActive[0];
+ if (activeDirective) {
+ activeDirective.$$setStateInfo(ref.state, params);
+ }
+ if (newHref === null) {
+ nav = false;
+ return false;
+ }
+ attrs.$set(attr, newHref);
+ };
+
+ if (ref.paramExpr) {
+ scope.$watch(ref.paramExpr, function(newVal, oldVal) {
+ if (newVal !== params) update(newVal);
+ }, true);
+ params = angular.copy(scope.$eval(ref.paramExpr));
+ }
+ update();
+
+ if (isForm) return;
+
+ element.bind("click", function(e) {
+ var button = e.which || e.button;
+ if ( !(button > 1 || e.ctrlKey || e.metaKey || e.shiftKey || element.attr('target')) ) {
+ // HACK: This is to allow ng-clicks to be processed before the transition is initiated:
+ var transition = $timeout(function() {
+ $state.go(ref.state, params, options);
+ });
+ e.preventDefault();
+
+ // if the state has no URL, ignore one preventDefault from the directive.
+ var ignorePreventDefaultCount = isAnchor && !newHref ? 1: 0;
+ e.preventDefault = function() {
+ if (ignorePreventDefaultCount-- <= 0)
+ $timeout.cancel(transition);
+ };
+ }
+ });
+ }
+ };
+}
+
+/**
+ * @ngdoc directive
+ * @name ui.router.state.directive:ui-sref-active
+ *
+ * @requires ui.router.state.$state
+ * @requires ui.router.state.$stateParams
+ * @requires $interpolate
+ *
+ * @restrict A
+ *
+ * @description
+ * A directive working alongside ui-sref to add classes to an element when the
+ * related ui-sref directive's state is active, and removing them when it is inactive.
+ * The primary use-case is to simplify the special appearance of navigation menus
+ * relying on `ui-sref`, by having the "active" state's menu button appear different,
+ * distinguishing it from the inactive menu items.
+ *
+ * ui-sref-active can live on the same element as ui-sref or on a parent element. The first
+ * ui-sref-active found at the same level or above the ui-sref will be used.
+ *
+ * Will activate when the ui-sref's target state or any child state is active. If you
+ * need to activate only when the ui-sref target state is active and *not* any of
+ * it's children, then you will use
+ * {@link ui.router.state.directive:ui-sref-active-eq ui-sref-active-eq}
+ *
+ * @example
+ * Given the following template:
+ *
+ *
+ *
+ *
+ *
+ *
+ * When the app state is "app.user" (or any children states), and contains the state parameter "user" with value "bilbobaggins",
+ * the resulting HTML will appear as (note the 'active' class):
+ *
+ *
+ *
+ *
+ *
+ * The class name is interpolated **once** during the directives link time (any further changes to the
+ * interpolated value are ignored).
+ *
+ * Multiple classes may be specified in a space-separated format:
+ *
+ *
+ *
+ *
+ */
+
+/**
+ * @ngdoc directive
+ * @name ui.router.state.directive:ui-sref-active-eq
+ *
+ * @requires ui.router.state.$state
+ * @requires ui.router.state.$stateParams
+ * @requires $interpolate
+ *
+ * @restrict A
+ *
+ * @description
+ * The same as {@link ui.router.state.directive:ui-sref-active ui-sref-active} but will only activate
+ * when the exact target state used in the `ui-sref` is active; no child states.
+ *
+ */
+$StateRefActiveDirective.$inject = ['$state', '$stateParams', '$interpolate'];
+function $StateRefActiveDirective($state, $stateParams, $interpolate) {
+ return {
+ restrict: "A",
+ controller: ['$scope', '$element', '$attrs', function ($scope, $element, $attrs) {
+ var state, params, activeClass;
+
+ // There probably isn't much point in $observing this
+ // uiSrefActive and uiSrefActiveEq share the same directive object with some
+ // slight difference in logic routing
+ activeClass = $interpolate($attrs.uiSrefActiveEq || $attrs.uiSrefActive || '', false)($scope);
+
+ // Allow uiSref to communicate with uiSrefActive[Equals]
+ this.$$setStateInfo = function (newState, newParams) {
+ state = $state.get(newState, stateContext($element));
+ params = newParams;
+ update();
+ };
+
+ $scope.$on('$stateChangeSuccess', update);
+
+ // Update route state
+ function update() {
+ if (isMatch()) {
+ $element.addClass(activeClass);
+ } else {
+ $element.removeClass(activeClass);
+ }
+ }
+
+ function isMatch() {
+ if (typeof $attrs.uiSrefActiveEq !== 'undefined') {
+ return state && $state.is(state.name, params);
+ } else {
+ return state && $state.includes(state.name, params);
+ }
+ }
+ }]
+ };
+}
+
+angular.module('ui.router.state')
+ .directive('uiSref', $StateRefDirective)
+ .directive('uiSrefActive', $StateRefActiveDirective)
+ .directive('uiSrefActiveEq', $StateRefActiveDirective);
diff --git a/client/www/lib/angular-ui-router/src/stateFilters.js b/client/www/lib/angular-ui-router/src/stateFilters.js
new file mode 100644
index 0000000..e0a1175
--- /dev/null
+++ b/client/www/lib/angular-ui-router/src/stateFilters.js
@@ -0,0 +1,39 @@
+/**
+ * @ngdoc filter
+ * @name ui.router.state.filter:isState
+ *
+ * @requires ui.router.state.$state
+ *
+ * @description
+ * Translates to {@link ui.router.state.$state#methods_is $state.is("stateName")}.
+ */
+$IsStateFilter.$inject = ['$state'];
+function $IsStateFilter($state) {
+ var isFilter = function (state) {
+ return $state.is(state);
+ };
+ isFilter.$stateful = true;
+ return isFilter;
+}
+
+/**
+ * @ngdoc filter
+ * @name ui.router.state.filter:includedByState
+ *
+ * @requires ui.router.state.$state
+ *
+ * @description
+ * Translates to {@link ui.router.state.$state#methods_includes $state.includes('fullOrPartialStateName')}.
+ */
+$IncludedByStateFilter.$inject = ['$state'];
+function $IncludedByStateFilter($state) {
+ var includesFilter = function (state) {
+ return $state.includes(state);
+ };
+ includesFilter.$stateful = true;
+ return includesFilter;
+}
+
+angular.module('ui.router.state')
+ .filter('isState', $IsStateFilter)
+ .filter('includedByState', $IncludedByStateFilter);
diff --git a/client/www/lib/angular-ui-router/src/templateFactory.js b/client/www/lib/angular-ui-router/src/templateFactory.js
new file mode 100644
index 0000000..ca491a9
--- /dev/null
+++ b/client/www/lib/angular-ui-router/src/templateFactory.js
@@ -0,0 +1,110 @@
+/**
+ * @ngdoc object
+ * @name ui.router.util.$templateFactory
+ *
+ * @requires $http
+ * @requires $templateCache
+ * @requires $injector
+ *
+ * @description
+ * Service. Manages loading of templates.
+ */
+$TemplateFactory.$inject = ['$http', '$templateCache', '$injector'];
+function $TemplateFactory( $http, $templateCache, $injector) {
+
+ /**
+ * @ngdoc function
+ * @name ui.router.util.$templateFactory#fromConfig
+ * @methodOf ui.router.util.$templateFactory
+ *
+ * @description
+ * Creates a template from a configuration object.
+ *
+ * @param {object} config Configuration object for which to load a template.
+ * The following properties are search in the specified order, and the first one
+ * that is defined is used to create the template:
+ *
+ * @param {string|object} config.template html string template or function to
+ * load via {@link ui.router.util.$templateFactory#fromString fromString}.
+ * @param {string|object} config.templateUrl url to load or a function returning
+ * the url to load via {@link ui.router.util.$templateFactory#fromUrl fromUrl}.
+ * @param {Function} config.templateProvider function to invoke via
+ * {@link ui.router.util.$templateFactory#fromProvider fromProvider}.
+ * @param {object} params Parameters to pass to the template function.
+ * @param {object} locals Locals to pass to `invoke` if the template is loaded
+ * via a `templateProvider`. Defaults to `{ params: params }`.
+ *
+ * @return {string|object} The template html as a string, or a promise for
+ * that string,or `null` if no template is configured.
+ */
+ this.fromConfig = function (config, params, locals) {
+ return (
+ isDefined(config.template) ? this.fromString(config.template, params) :
+ isDefined(config.templateUrl) ? this.fromUrl(config.templateUrl, params) :
+ isDefined(config.templateProvider) ? this.fromProvider(config.templateProvider, params, locals) :
+ null
+ );
+ };
+
+ /**
+ * @ngdoc function
+ * @name ui.router.util.$templateFactory#fromString
+ * @methodOf ui.router.util.$templateFactory
+ *
+ * @description
+ * Creates a template from a string or a function returning a string.
+ *
+ * @param {string|object} template html template as a string or function that
+ * returns an html template as a string.
+ * @param {object} params Parameters to pass to the template function.
+ *
+ * @return {string|object} The template html as a string, or a promise for that
+ * string.
+ */
+ this.fromString = function (template, params) {
+ return isFunction(template) ? template(params) : template;
+ };
+
+ /**
+ * @ngdoc function
+ * @name ui.router.util.$templateFactory#fromUrl
+ * @methodOf ui.router.util.$templateFactory
+ *
+ * @description
+ * Loads a template from the a URL via `$http` and `$templateCache`.
+ *
+ * @param {string|Function} url url of the template to load, or a function
+ * that returns a url.
+ * @param {Object} params Parameters to pass to the url function.
+ * @return {string|Promise.
+ * new UrlMatcher('/user/{id}?q').concat('/details?date');
+ * new UrlMatcher('/user/{id}/details?q&date');
+ *
+ *
+ * @param {string} pattern The pattern to append.
+ * @param {Object} config An object hash of the configuration for the matcher.
+ * @returns {UrlMatcher} A matcher for the concatenated pattern.
+ */
+UrlMatcher.prototype.concat = function (pattern, config) {
+ // Because order of search parameters is irrelevant, we can add our own search
+ // parameters to the end of the new pattern. Parse the new pattern by itself
+ // and then join the bits together, but it's much easier to do this on a string level.
+ var defaultConfig = {
+ caseInsensitive: $$UMFP.caseInsensitive(),
+ strict: $$UMFP.strictMode(),
+ squash: $$UMFP.defaultSquashPolicy()
+ };
+ return new UrlMatcher(this.sourcePath + pattern + this.sourceSearch, extend(defaultConfig, config), this);
+};
+
+UrlMatcher.prototype.toString = function () {
+ return this.source;
+};
+
+/**
+ * @ngdoc function
+ * @name ui.router.util.type:UrlMatcher#exec
+ * @methodOf ui.router.util.type:UrlMatcher
+ *
+ * @description
+ * Tests the specified path against this matcher, and returns an object containing the captured
+ * parameter values, or null if the path does not match. The returned object contains the values
+ * of any search parameters that are mentioned in the pattern, but their value may be null if
+ * they are not present in `searchParams`. This means that search parameters are always treated
+ * as optional.
+ *
+ * @example
+ *
+ * new UrlMatcher('/user/{id}?q&r').exec('/user/bob', {
+ * x: '1', q: 'hello'
+ * });
+ * // returns { id: 'bob', q: 'hello', r: null }
+ *
+ *
+ * @param {string} path The URL path to match, e.g. `$location.path()`.
+ * @param {Object} searchParams URL search parameters, e.g. `$location.search()`.
+ * @returns {Object} The captured parameter values.
+ */
+UrlMatcher.prototype.exec = function (path, searchParams) {
+ var m = this.regexp.exec(path);
+ if (!m) return null;
+ searchParams = searchParams || {};
+
+ var paramNames = this.parameters(), nTotal = paramNames.length,
+ nPath = this.segments.length - 1,
+ values = {}, i, j, cfg, paramName;
+
+ if (nPath !== m.length - 1) throw new Error("Unbalanced capture group in route '" + this.source + "'");
+
+ function decodePathArray(string) {
+ function reverseString(str) { return str.split("").reverse().join(""); }
+ function unquoteDashes(str) { return str.replace(/\\-/, "-"); }
+
+ var split = reverseString(string).split(/-(?!\\)/);
+ var allReversed = map(split, reverseString);
+ return map(allReversed, unquoteDashes).reverse();
+ }
+
+ for (i = 0; i < nPath; i++) {
+ paramName = paramNames[i];
+ var param = this.params[paramName];
+ var paramVal = m[i+1];
+ // if the param value matches a pre-replace pair, replace the value before decoding.
+ for (j = 0; j < param.replace; j++) {
+ if (param.replace[j].from === paramVal) paramVal = param.replace[j].to;
+ }
+ if (paramVal && param.array === true) paramVal = decodePathArray(paramVal);
+ values[paramName] = param.value(paramVal);
+ }
+ for (/**/; i < nTotal; i++) {
+ paramName = paramNames[i];
+ values[paramName] = this.params[paramName].value(searchParams[paramName]);
+ }
+
+ return values;
+};
+
+/**
+ * @ngdoc function
+ * @name ui.router.util.type:UrlMatcher#parameters
+ * @methodOf ui.router.util.type:UrlMatcher
+ *
+ * @description
+ * Returns the names of all path and search parameters of this pattern in an unspecified order.
+ *
+ * @returns {Array.
+ * new UrlMatcher('/user/{id}?q').format({ id:'bob', q:'yes' });
+ * // returns '/user/bob?q=yes'
+ *
+ *
+ * @param {Object} values the values to substitute for the parameters in this pattern.
+ * @returns {string} the formatted URL (path and optionally search part).
+ */
+UrlMatcher.prototype.format = function (values) {
+ values = values || {};
+ var segments = this.segments, params = this.parameters(), paramset = this.params;
+ if (!this.validates(values)) return null;
+
+ var i, search = false, nPath = segments.length - 1, nTotal = params.length, result = segments[0];
+
+ function encodeDashes(str) { // Replace dashes with encoded "\-"
+ return encodeURIComponent(str).replace(/-/g, function(c) { return '%5C%' + c.charCodeAt(0).toString(16).toUpperCase(); });
+ }
+
+ for (i = 0; i < nTotal; i++) {
+ var isPathParam = i < nPath;
+ var name = params[i], param = paramset[name], value = param.value(values[name]);
+ var isDefaultValue = param.isOptional && param.type.equals(param.value(), value);
+ var squash = isDefaultValue ? param.squash : false;
+ var encoded = param.type.encode(value);
+
+ if (isPathParam) {
+ var nextSegment = segments[i + 1];
+ if (squash === false) {
+ if (encoded != null) {
+ if (isArray(encoded)) {
+ result += map(encoded, encodeDashes).join("-");
+ } else {
+ result += encodeURIComponent(encoded);
+ }
+ }
+ result += nextSegment;
+ } else if (squash === true) {
+ var capture = result.match(/\/$/) ? /\/?(.*)/ : /(.*)/;
+ result += nextSegment.match(capture)[1];
+ } else if (isString(squash)) {
+ result += squash + nextSegment;
+ }
+ } else {
+ if (encoded == null || (isDefaultValue && squash !== false)) continue;
+ if (!isArray(encoded)) encoded = [ encoded ];
+ encoded = map(encoded, encodeURIComponent).join('&' + name + '=');
+ result += (search ? '&' : '?') + (name + '=' + encoded);
+ search = true;
+ }
+ }
+
+ return result;
+};
+
+/**
+ * @ngdoc object
+ * @name ui.router.util.type:Type
+ *
+ * @description
+ * Implements an interface to define custom parameter types that can be decoded from and encoded to
+ * string parameters matched in a URL. Used by {@link ui.router.util.type:UrlMatcher `UrlMatcher`}
+ * objects when matching or formatting URLs, or comparing or validating parameter values.
+ *
+ * See {@link ui.router.util.$urlMatcherFactory#methods_type `$urlMatcherFactory#type()`} for more
+ * information on registering custom types.
+ *
+ * @param {Object} config A configuration object which contains the custom type definition. The object's
+ * properties will override the default methods and/or pattern in `Type`'s public interface.
+ * @example
+ *
+ * {
+ * decode: function(val) { return parseInt(val, 10); },
+ * encode: function(val) { return val && val.toString(); },
+ * equals: function(a, b) { return this.is(a) && a === b; },
+ * is: function(val) { return angular.isNumber(val) isFinite(val) && val % 1 === 0; },
+ * pattern: /\d+/
+ * }
+ *
+ *
+ * @property {RegExp} pattern The regular expression pattern used to match values of this type when
+ * coming from a substring of a URL.
+ *
+ * @returns {Object} Returns a new `Type` object.
+ */
+function Type(config) {
+ extend(this, config);
+}
+
+/**
+ * @ngdoc function
+ * @name ui.router.util.type:Type#is
+ * @methodOf ui.router.util.type:Type
+ *
+ * @description
+ * Detects whether a value is of a particular type. Accepts a native (decoded) value
+ * and determines whether it matches the current `Type` object.
+ *
+ * @param {*} val The value to check.
+ * @param {string} key Optional. If the type check is happening in the context of a specific
+ * {@link ui.router.util.type:UrlMatcher `UrlMatcher`} object, this is the name of the
+ * parameter in which `val` is stored. Can be used for meta-programming of `Type` objects.
+ * @returns {Boolean} Returns `true` if the value matches the type, otherwise `false`.
+ */
+Type.prototype.is = function(val, key) {
+ return true;
+};
+
+/**
+ * @ngdoc function
+ * @name ui.router.util.type:Type#encode
+ * @methodOf ui.router.util.type:Type
+ *
+ * @description
+ * Encodes a custom/native type value to a string that can be embedded in a URL. Note that the
+ * return value does *not* need to be URL-safe (i.e. passed through `encodeURIComponent()`), it
+ * only needs to be a representation of `val` that has been coerced to a string.
+ *
+ * @param {*} val The value to encode.
+ * @param {string} key The name of the parameter in which `val` is stored. Can be used for
+ * meta-programming of `Type` objects.
+ * @returns {string} Returns a string representation of `val` that can be encoded in a URL.
+ */
+Type.prototype.encode = function(val, key) {
+ return val;
+};
+
+/**
+ * @ngdoc function
+ * @name ui.router.util.type:Type#decode
+ * @methodOf ui.router.util.type:Type
+ *
+ * @description
+ * Converts a parameter value (from URL string or transition param) to a custom/native value.
+ *
+ * @param {string} val The URL parameter value to decode.
+ * @param {string} key The name of the parameter in which `val` is stored. Can be used for
+ * meta-programming of `Type` objects.
+ * @returns {*} Returns a custom representation of the URL parameter value.
+ */
+Type.prototype.decode = function(val, key) {
+ return val;
+};
+
+/**
+ * @ngdoc function
+ * @name ui.router.util.type:Type#equals
+ * @methodOf ui.router.util.type:Type
+ *
+ * @description
+ * Determines whether two decoded values are equivalent.
+ *
+ * @param {*} a A value to compare against.
+ * @param {*} b A value to compare against.
+ * @returns {Boolean} Returns `true` if the values are equivalent/equal, otherwise `false`.
+ */
+Type.prototype.equals = function(a, b) {
+ return a == b;
+};
+
+Type.prototype.$subPattern = function() {
+ var sub = this.pattern.toString();
+ return sub.substr(1, sub.length - 2);
+};
+
+Type.prototype.pattern = /.*/;
+
+Type.prototype.toString = function() { return "{Type:" + this.name + "}"; };
+
+/*
+ * Wraps an existing custom Type as an array of Type, depending on 'mode'.
+ * e.g.:
+ * - urlmatcher pattern "/path?{queryParam[]:int}"
+ * - url: "/path?queryParam=1&queryParam=2
+ * - $stateParams.queryParam will be [1, 2]
+ * if `mode` is "auto", then
+ * - url: "/path?queryParam=1 will create $stateParams.queryParam: 1
+ * - url: "/path?queryParam=1&queryParam=2 will create $stateParams.queryParam: [1, 2]
+ */
+Type.prototype.$asArray = function(mode, isSearch) {
+ if (!mode) return this;
+ if (mode === "auto" && !isSearch) throw new Error("'auto' array mode is for query parameters only");
+ return new ArrayType(this, mode);
+
+ function ArrayType(type, mode) {
+ function bindTo(type, callbackName) {
+ return function() {
+ return type[callbackName].apply(type, arguments);
+ };
+ }
+
+ // Wrap non-array value as array
+ function arrayWrap(val) { return isArray(val) ? val : (isDefined(val) ? [ val ] : []); }
+ // Unwrap array value for "auto" mode. Return undefined for empty array.
+ function arrayUnwrap(val) {
+ switch(val.length) {
+ case 0: return undefined;
+ case 1: return mode === "auto" ? val[0] : val;
+ default: return val;
+ }
+ }
+ function falsey(val) { return !val; }
+
+ // Wraps type (.is/.encode/.decode) functions to operate on each value of an array
+ function arrayHandler(callback, allTruthyMode) {
+ return function handleArray(val) {
+ val = arrayWrap(val);
+ var result = map(val, callback);
+ if (allTruthyMode === true)
+ return filter(result, falsey).length === 0;
+ return arrayUnwrap(result);
+ };
+ }
+
+ // Wraps type (.equals) functions to operate on each value of an array
+ function arrayEqualsHandler(callback) {
+ return function handleArray(val1, val2) {
+ var left = arrayWrap(val1), right = arrayWrap(val2);
+ if (left.length !== right.length) return false;
+ for (var i = 0; i < left.length; i++) {
+ if (!callback(left[i], right[i])) return false;
+ }
+ return true;
+ };
+ }
+
+ this.encode = arrayHandler(bindTo(type, 'encode'));
+ this.decode = arrayHandler(bindTo(type, 'decode'));
+ this.is = arrayHandler(bindTo(type, 'is'), true);
+ this.equals = arrayEqualsHandler(bindTo(type, 'equals'));
+ this.pattern = type.pattern;
+ this.$arrayMode = mode;
+ }
+};
+
+
+
+/**
+ * @ngdoc object
+ * @name ui.router.util.$urlMatcherFactory
+ *
+ * @description
+ * Factory for {@link ui.router.util.type:UrlMatcher `UrlMatcher`} instances. The factory
+ * is also available to providers under the name `$urlMatcherFactoryProvider`.
+ */
+function $UrlMatcherFactory() {
+ $$UMFP = this;
+
+ var isCaseInsensitive = false, isStrictMode = true, defaultSquashPolicy = false;
+
+ function valToString(val) { return val != null ? val.toString().replace(/\//g, "%2F") : val; }
+ function valFromString(val) { return val != null ? val.toString().replace(/%2F/g, "/") : val; }
+// TODO: in 1.0, make string .is() return false if value is undefined by default.
+// function regexpMatches(val) { /*jshint validthis:true */ return isDefined(val) && this.pattern.test(val); }
+ function regexpMatches(val) { /*jshint validthis:true */ return this.pattern.test(val); }
+
+ var $types = {}, enqueue = true, typeQueue = [], injector, defaultTypes = {
+ string: {
+ encode: valToString,
+ decode: valFromString,
+ is: regexpMatches,
+ pattern: /[^/]*/
+ },
+ int: {
+ encode: valToString,
+ decode: function(val) { return parseInt(val, 10); },
+ is: function(val) { return isDefined(val) && this.decode(val.toString()) === val; },
+ pattern: /\d+/
+ },
+ bool: {
+ encode: function(val) { return val ? 1 : 0; },
+ decode: function(val) { return parseInt(val, 10) !== 0; },
+ is: function(val) { return val === true || val === false; },
+ pattern: /0|1/
+ },
+ date: {
+ encode: function (val) {
+ if (!this.is(val))
+ return undefined;
+ return [ val.getFullYear(),
+ ('0' + (val.getMonth() + 1)).slice(-2),
+ ('0' + val.getDate()).slice(-2)
+ ].join("-");
+ },
+ decode: function (val) {
+ if (this.is(val)) return val;
+ var match = this.capture.exec(val);
+ return match ? new Date(match[1], match[2] - 1, match[3]) : undefined;
+ },
+ is: function(val) { return val instanceof Date && !isNaN(val.valueOf()); },
+ equals: function (a, b) { return this.is(a) && this.is(b) && a.toISOString() === b.toISOString(); },
+ pattern: /[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])/,
+ capture: /([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/
+ },
+ json: {
+ encode: angular.toJson,
+ decode: angular.fromJson,
+ is: angular.isObject,
+ equals: angular.equals,
+ pattern: /[^/]*/
+ },
+ any: { // does not encode/decode
+ encode: angular.identity,
+ decode: angular.identity,
+ is: angular.identity,
+ equals: angular.equals,
+ pattern: /.*/
+ }
+ };
+
+ function getDefaultConfig() {
+ return {
+ strict: isStrictMode,
+ caseInsensitive: isCaseInsensitive
+ };
+ }
+
+ function isInjectable(value) {
+ return (isFunction(value) || (isArray(value) && isFunction(value[value.length - 1])));
+ }
+
+ /**
+ * [Internal] Get the default value of a parameter, which may be an injectable function.
+ */
+ $UrlMatcherFactory.$$getDefaultValue = function(config) {
+ if (!isInjectable(config.value)) return config.value;
+ if (!injector) throw new Error("Injectable functions cannot be called at configuration time");
+ return injector.invoke(config.value);
+ };
+
+ /**
+ * @ngdoc function
+ * @name ui.router.util.$urlMatcherFactory#caseInsensitive
+ * @methodOf ui.router.util.$urlMatcherFactory
+ *
+ * @description
+ * Defines whether URL matching should be case sensitive (the default behavior), or not.
+ *
+ * @param {boolean} value `false` to match URL in a case sensitive manner; otherwise `true`;
+ * @returns {boolean} the current value of caseInsensitive
+ */
+ this.caseInsensitive = function(value) {
+ if (isDefined(value))
+ isCaseInsensitive = value;
+ return isCaseInsensitive;
+ };
+
+ /**
+ * @ngdoc function
+ * @name ui.router.util.$urlMatcherFactory#strictMode
+ * @methodOf ui.router.util.$urlMatcherFactory
+ *
+ * @description
+ * Defines whether URLs should match trailing slashes, or not (the default behavior).
+ *
+ * @param {boolean=} value `false` to match trailing slashes in URLs, otherwise `true`.
+ * @returns {boolean} the current value of strictMode
+ */
+ this.strictMode = function(value) {
+ if (isDefined(value))
+ isStrictMode = value;
+ return isStrictMode;
+ };
+
+ /**
+ * @ngdoc function
+ * @name ui.router.util.$urlMatcherFactory#defaultSquashPolicy
+ * @methodOf ui.router.util.$urlMatcherFactory
+ *
+ * @description
+ * Sets the default behavior when generating or matching URLs with default parameter values.
+ *
+ * @param {string} value A string that defines the default parameter URL squashing behavior.
+ * `nosquash`: When generating an href with a default parameter value, do not squash the parameter value from the URL
+ * `slash`: When generating an href with a default parameter value, squash (remove) the parameter value, and, if the
+ * parameter is surrounded by slashes, squash (remove) one slash from the URL
+ * any other string, e.g. "~": When generating an href with a default parameter value, squash (remove)
+ * the parameter value from the URL and replace it with this string.
+ */
+ this.defaultSquashPolicy = function(value) {
+ if (!isDefined(value)) return defaultSquashPolicy;
+ if (value !== true && value !== false && !isString(value))
+ throw new Error("Invalid squash policy: " + value + ". Valid policies: false, true, arbitrary-string");
+ defaultSquashPolicy = value;
+ return value;
+ };
+
+ /**
+ * @ngdoc function
+ * @name ui.router.util.$urlMatcherFactory#compile
+ * @methodOf ui.router.util.$urlMatcherFactory
+ *
+ * @description
+ * Creates a {@link ui.router.util.type:UrlMatcher `UrlMatcher`} for the specified pattern.
+ *
+ * @param {string} pattern The URL pattern.
+ * @param {Object} config The config object hash.
+ * @returns {UrlMatcher} The UrlMatcher.
+ */
+ this.compile = function (pattern, config) {
+ return new UrlMatcher(pattern, extend(getDefaultConfig(), config));
+ };
+
+ /**
+ * @ngdoc function
+ * @name ui.router.util.$urlMatcherFactory#isMatcher
+ * @methodOf ui.router.util.$urlMatcherFactory
+ *
+ * @description
+ * Returns true if the specified object is a `UrlMatcher`, or false otherwise.
+ *
+ * @param {Object} object The object to perform the type check against.
+ * @returns {Boolean} Returns `true` if the object matches the `UrlMatcher` interface, by
+ * implementing all the same methods.
+ */
+ this.isMatcher = function (o) {
+ if (!isObject(o)) return false;
+ var result = true;
+
+ forEach(UrlMatcher.prototype, function(val, name) {
+ if (isFunction(val)) {
+ result = result && (isDefined(o[name]) && isFunction(o[name]));
+ }
+ });
+ return result;
+ };
+
+ /**
+ * @ngdoc function
+ * @name ui.router.util.$urlMatcherFactory#type
+ * @methodOf ui.router.util.$urlMatcherFactory
+ *
+ * @description
+ * Registers a custom {@link ui.router.util.type:Type `Type`} object that can be used to
+ * generate URLs with typed parameters.
+ *
+ * @param {string} name The type name.
+ * @param {Object|Function} definition The type definition. See
+ * {@link ui.router.util.type:Type `Type`} for information on the values accepted.
+ * @param {Object|Function} definitionFn (optional) A function that is injected before the app
+ * runtime starts. The result of this function is merged into the existing `definition`.
+ * See {@link ui.router.util.type:Type `Type`} for information on the values accepted.
+ *
+ * @returns {Object} Returns `$urlMatcherFactoryProvider`.
+ *
+ * @example
+ * This is a simple example of a custom type that encodes and decodes items from an
+ * array, using the array index as the URL-encoded value:
+ *
+ *
+ * var list = ['John', 'Paul', 'George', 'Ringo'];
+ *
+ * $urlMatcherFactoryProvider.type('listItem', {
+ * encode: function(item) {
+ * // Represent the list item in the URL using its corresponding index
+ * return list.indexOf(item);
+ * },
+ * decode: function(item) {
+ * // Look up the list item by index
+ * return list[parseInt(item, 10)];
+ * },
+ * is: function(item) {
+ * // Ensure the item is valid by checking to see that it appears
+ * // in the list
+ * return list.indexOf(item) > -1;
+ * }
+ * });
+ *
+ * $stateProvider.state('list', {
+ * url: "/list/{item:listItem}",
+ * controller: function($scope, $stateParams) {
+ * console.log($stateParams.item);
+ * }
+ * });
+ *
+ * // ...
+ *
+ * // Changes URL to '/list/3', logs "Ringo" to the console
+ * $state.go('list', { item: "Ringo" });
+ *
+ *
+ * This is a more complex example of a type that relies on dependency injection to
+ * interact with services, and uses the parameter name from the URL to infer how to
+ * handle encoding and decoding parameter values:
+ *
+ *
+ * // Defines a custom type that gets a value from a service,
+ * // where each service gets different types of values from
+ * // a backend API:
+ * $urlMatcherFactoryProvider.type('dbObject', {}, function(Users, Posts) {
+ *
+ * // Matches up services to URL parameter names
+ * var services = {
+ * user: Users,
+ * post: Posts
+ * };
+ *
+ * return {
+ * encode: function(object) {
+ * // Represent the object in the URL using its unique ID
+ * return object.id;
+ * },
+ * decode: function(value, key) {
+ * // Look up the object by ID, using the parameter
+ * // name (key) to call the correct service
+ * return services[key].findById(value);
+ * },
+ * is: function(object, key) {
+ * // Check that object is a valid dbObject
+ * return angular.isObject(object) && object.id && services[key];
+ * }
+ * equals: function(a, b) {
+ * // Check the equality of decoded objects by comparing
+ * // their unique IDs
+ * return a.id === b.id;
+ * }
+ * };
+ * });
+ *
+ * // In a config() block, you can then attach URLs with
+ * // type-annotated parameters:
+ * $stateProvider.state('users', {
+ * url: "/users",
+ * // ...
+ * }).state('users.item', {
+ * url: "/{user:dbObject}",
+ * controller: function($scope, $stateParams) {
+ * // $stateParams.user will now be an object returned from
+ * // the Users service
+ * },
+ * // ...
+ * });
+ *
+ */
+ this.type = function (name, definition, definitionFn) {
+ if (!isDefined(definition)) return $types[name];
+ if ($types.hasOwnProperty(name)) throw new Error("A type named '" + name + "' has already been defined.");
+
+ $types[name] = new Type(extend({ name: name }, definition));
+ if (definitionFn) {
+ typeQueue.push({ name: name, def: definitionFn });
+ if (!enqueue) flushTypeQueue();
+ }
+ return this;
+ };
+
+ // `flushTypeQueue()` waits until `$urlMatcherFactory` is injected before invoking the queued `definitionFn`s
+ function flushTypeQueue() {
+ while(typeQueue.length) {
+ var type = typeQueue.shift();
+ if (type.pattern) throw new Error("You cannot override a type's .pattern at runtime.");
+ angular.extend($types[type.name], injector.invoke(type.def));
+ }
+ }
+
+ // Register default types. Store them in the prototype of $types.
+ forEach(defaultTypes, function(type, name) { $types[name] = new Type(extend({name: name}, type)); });
+ $types = inherit($types, {});
+
+ /* No need to document $get, since it returns this */
+ this.$get = ['$injector', function ($injector) {
+ injector = $injector;
+ enqueue = false;
+ flushTypeQueue();
+
+ forEach(defaultTypes, function(type, name) {
+ if (!$types[name]) $types[name] = new Type(type);
+ });
+ return this;
+ }];
+
+ this.Param = function Param(id, type, config, location) {
+ var self = this;
+ config = unwrapShorthand(config);
+ type = getType(config, type, location);
+ var arrayMode = getArrayMode();
+ type = arrayMode ? type.$asArray(arrayMode, location === "search") : type;
+ if (type.name === "string" && !arrayMode && location === "path" && config.value === undefined)
+ config.value = ""; // for 0.2.x; in 0.3.0+ do not automatically default to ""
+ var isOptional = config.value !== undefined;
+ var squash = getSquashPolicy(config, isOptional);
+ var replace = getReplace(config, arrayMode, isOptional, squash);
+
+ function unwrapShorthand(config) {
+ var keys = isObject(config) ? objectKeys(config) : [];
+ var isShorthand = indexOf(keys, "value") === -1 && indexOf(keys, "type") === -1 &&
+ indexOf(keys, "squash") === -1 && indexOf(keys, "array") === -1;
+ if (isShorthand) config = { value: config };
+ config.$$fn = isInjectable(config.value) ? config.value : function () { return config.value; };
+ return config;
+ }
+
+ function getType(config, urlType, location) {
+ if (config.type && urlType) throw new Error("Param '"+id+"' has two type configurations.");
+ if (urlType) return urlType;
+ if (!config.type) return (location === "config" ? $types.any : $types.string);
+ return config.type instanceof Type ? config.type : new Type(config.type);
+ }
+
+ // array config: param name (param[]) overrides default settings. explicit config overrides param name.
+ function getArrayMode() {
+ var arrayDefaults = { array: (location === "search" ? "auto" : false) };
+ var arrayParamNomenclature = id.match(/\[\]$/) ? { array: true } : {};
+ return extend(arrayDefaults, arrayParamNomenclature, config).array;
+ }
+
+ /**
+ * returns false, true, or the squash value to indicate the "default parameter url squash policy".
+ */
+ function getSquashPolicy(config, isOptional) {
+ var squash = config.squash;
+ if (!isOptional || squash === false) return false;
+ if (!isDefined(squash) || squash == null) return defaultSquashPolicy;
+ if (squash === true || isString(squash)) return squash;
+ throw new Error("Invalid squash policy: '" + squash + "'. Valid policies: false, true, or arbitrary string");
+ }
+
+ function getReplace(config, arrayMode, isOptional, squash) {
+ var replace, configuredKeys, defaultPolicy = [
+ { from: "", to: (isOptional || arrayMode ? undefined : "") },
+ { from: null, to: (isOptional || arrayMode ? undefined : "") }
+ ];
+ replace = isArray(config.replace) ? config.replace : [];
+ if (isString(squash))
+ replace.push({ from: squash, to: undefined });
+ configuredKeys = map(replace, function(item) { return item.from; } );
+ return filter(defaultPolicy, function(item) { return indexOf(configuredKeys, item.from) === -1; }).concat(replace);
+ }
+
+ /**
+ * [Internal] Get the default value of a parameter, which may be an injectable function.
+ */
+ function $$getDefaultValue() {
+ if (!injector) throw new Error("Injectable functions cannot be called at configuration time");
+ return injector.invoke(config.$$fn);
+ }
+
+ /**
+ * [Internal] Gets the decoded representation of a value if the value is defined, otherwise, returns the
+ * default value, which may be the result of an injectable function.
+ */
+ function $value(value) {
+ function hasReplaceVal(val) { return function(obj) { return obj.from === val; }; }
+ function $replace(value) {
+ var replacement = map(filter(self.replace, hasReplaceVal(value)), function(obj) { return obj.to; });
+ return replacement.length ? replacement[0] : value;
+ }
+ value = $replace(value);
+ return isDefined(value) ? self.type.decode(value) : $$getDefaultValue();
+ }
+
+ function toString() { return "{Param:" + id + " " + type + " squash: '" + squash + "' optional: " + isOptional + "}"; }
+
+ extend(this, {
+ id: id,
+ type: type,
+ location: location,
+ array: arrayMode,
+ squash: squash,
+ replace: replace,
+ isOptional: isOptional,
+ value: $value,
+ dynamic: undefined,
+ config: config,
+ toString: toString
+ });
+ };
+
+ function ParamSet(params) {
+ extend(this, params || {});
+ }
+
+ ParamSet.prototype = {
+ $$new: function() {
+ return inherit(this, extend(new ParamSet(), { $$parent: this}));
+ },
+ $$keys: function () {
+ var keys = [], chain = [], parent = this,
+ ignore = objectKeys(ParamSet.prototype);
+ while (parent) { chain.push(parent); parent = parent.$$parent; }
+ chain.reverse();
+ forEach(chain, function(paramset) {
+ forEach(objectKeys(paramset), function(key) {
+ if (indexOf(keys, key) === -1 && indexOf(ignore, key) === -1) keys.push(key);
+ });
+ });
+ return keys;
+ },
+ $$values: function(paramValues) {
+ var values = {}, self = this;
+ forEach(self.$$keys(), function(key) {
+ values[key] = self[key].value(paramValues && paramValues[key]);
+ });
+ return values;
+ },
+ $$equals: function(paramValues1, paramValues2) {
+ var equal = true, self = this;
+ forEach(self.$$keys(), function(key) {
+ var left = paramValues1 && paramValues1[key], right = paramValues2 && paramValues2[key];
+ if (!self[key].type.equals(left, right)) equal = false;
+ });
+ return equal;
+ },
+ $$validates: function $$validate(paramValues) {
+ var result = true, isOptional, val, param, self = this;
+
+ forEach(this.$$keys(), function(key) {
+ param = self[key];
+ val = paramValues[key];
+ isOptional = !val && param.isOptional;
+ result = result && (isOptional || !!param.type.is(val));
+ });
+ return result;
+ },
+ $$parent: undefined
+ };
+
+ this.ParamSet = ParamSet;
+}
+
+// Register as a provider so it's available to other providers
+angular.module('ui.router.util').provider('$urlMatcherFactory', $UrlMatcherFactory);
+angular.module('ui.router.util').run(['$urlMatcherFactory', function($urlMatcherFactory) { }]);
diff --git a/client/www/lib/angular-ui-router/src/urlRouter.js b/client/www/lib/angular-ui-router/src/urlRouter.js
new file mode 100644
index 0000000..2b22937
--- /dev/null
+++ b/client/www/lib/angular-ui-router/src/urlRouter.js
@@ -0,0 +1,413 @@
+/**
+ * @ngdoc object
+ * @name ui.router.router.$urlRouterProvider
+ *
+ * @requires ui.router.util.$urlMatcherFactoryProvider
+ * @requires $locationProvider
+ *
+ * @description
+ * `$urlRouterProvider` has the responsibility of watching `$location`.
+ * When `$location` changes it runs through a list of rules one by one until a
+ * match is found. `$urlRouterProvider` is used behind the scenes anytime you specify
+ * a url in a state configuration. All urls are compiled into a UrlMatcher object.
+ *
+ * There are several methods on `$urlRouterProvider` that make it useful to use directly
+ * in your module config.
+ */
+$UrlRouterProvider.$inject = ['$locationProvider', '$urlMatcherFactoryProvider'];
+function $UrlRouterProvider( $locationProvider, $urlMatcherFactory) {
+ var rules = [], otherwise = null, interceptDeferred = false, listener;
+
+ // Returns a string that is a prefix of all strings matching the RegExp
+ function regExpPrefix(re) {
+ var prefix = /^\^((?:\\[^a-zA-Z0-9]|[^\\\[\]\^$*+?.()|{}]+)*)/.exec(re.source);
+ return (prefix != null) ? prefix[1].replace(/\\(.)/g, "$1") : '';
+ }
+
+ // Interpolates matched values into a String.replace()-style pattern
+ function interpolate(pattern, match) {
+ return pattern.replace(/\$(\$|\d{1,2})/, function (m, what) {
+ return match[what === '$' ? 0 : Number(what)];
+ });
+ }
+
+ /**
+ * @ngdoc function
+ * @name ui.router.router.$urlRouterProvider#rule
+ * @methodOf ui.router.router.$urlRouterProvider
+ *
+ * @description
+ * Defines rules that are used by `$urlRouterProvider` to find matches for
+ * specific URLs.
+ *
+ * @example
+ *
+ * var app = angular.module('app', ['ui.router.router']);
+ *
+ * app.config(function ($urlRouterProvider) {
+ * // Here's an example of how you might allow case insensitive urls
+ * $urlRouterProvider.rule(function ($injector, $location) {
+ * var path = $location.path(),
+ * normalized = path.toLowerCase();
+ *
+ * if (path !== normalized) {
+ * return normalized;
+ * }
+ * });
+ * });
+ *
+ *
+ * @param {object} rule Handler function that takes `$injector` and `$location`
+ * services as arguments. You can use them to return a valid path as a string.
+ *
+ * @return {object} `$urlRouterProvider` - `$urlRouterProvider` instance
+ */
+ this.rule = function (rule) {
+ if (!isFunction(rule)) throw new Error("'rule' must be a function");
+ rules.push(rule);
+ return this;
+ };
+
+ /**
+ * @ngdoc object
+ * @name ui.router.router.$urlRouterProvider#otherwise
+ * @methodOf ui.router.router.$urlRouterProvider
+ *
+ * @description
+ * Defines a path that is used when an invalid route is requested.
+ *
+ * @example
+ *
+ * var app = angular.module('app', ['ui.router.router']);
+ *
+ * app.config(function ($urlRouterProvider) {
+ * // if the path doesn't match any of the urls you configured
+ * // otherwise will take care of routing the user to the
+ * // specified url
+ * $urlRouterProvider.otherwise('/index');
+ *
+ * // Example of using function rule as param
+ * $urlRouterProvider.otherwise(function ($injector, $location) {
+ * return '/a/valid/url';
+ * });
+ * });
+ *
+ *
+ * @param {string|object} rule The url path you want to redirect to or a function
+ * rule that returns the url path. The function version is passed two params:
+ * `$injector` and `$location` services, and must return a url string.
+ *
+ * @return {object} `$urlRouterProvider` - `$urlRouterProvider` instance
+ */
+ this.otherwise = function (rule) {
+ if (isString(rule)) {
+ var redirect = rule;
+ rule = function () { return redirect; };
+ }
+ else if (!isFunction(rule)) throw new Error("'rule' must be a function");
+ otherwise = rule;
+ return this;
+ };
+
+
+ function handleIfMatch($injector, handler, match) {
+ if (!match) return false;
+ var result = $injector.invoke(handler, handler, { $match: match });
+ return isDefined(result) ? result : true;
+ }
+
+ /**
+ * @ngdoc function
+ * @name ui.router.router.$urlRouterProvider#when
+ * @methodOf ui.router.router.$urlRouterProvider
+ *
+ * @description
+ * Registers a handler for a given url matching. if handle is a string, it is
+ * treated as a redirect, and is interpolated according to the syntax of match
+ * (i.e. like `String.replace()` for `RegExp`, or like a `UrlMatcher` pattern otherwise).
+ *
+ * If the handler is a function, it is injectable. It gets invoked if `$location`
+ * matches. You have the option of inject the match object as `$match`.
+ *
+ * The handler can return
+ *
+ * - **falsy** to indicate that the rule didn't match after all, then `$urlRouter`
+ * will continue trying to find another one that matches.
+ * - **string** which is treated as a redirect and passed to `$location.url()`
+ * - **void** or any **truthy** value tells `$urlRouter` that the url was handled.
+ *
+ * @example
+ *
+ * var app = angular.module('app', ['ui.router.router']);
+ *
+ * app.config(function ($urlRouterProvider) {
+ * $urlRouterProvider.when($state.url, function ($match, $stateParams) {
+ * if ($state.$current.navigable !== state ||
+ * !equalForKeys($match, $stateParams) {
+ * $state.transitionTo(state, $match, false);
+ * }
+ * });
+ * });
+ *
+ *
+ * @param {string|object} what The incoming path that you want to redirect.
+ * @param {string|object} handler The path you want to redirect your user to.
+ */
+ this.when = function (what, handler) {
+ var redirect, handlerIsString = isString(handler);
+ if (isString(what)) what = $urlMatcherFactory.compile(what);
+
+ if (!handlerIsString && !isFunction(handler) && !isArray(handler))
+ throw new Error("invalid 'handler' in when()");
+
+ var strategies = {
+ matcher: function (what, handler) {
+ if (handlerIsString) {
+ redirect = $urlMatcherFactory.compile(handler);
+ handler = ['$match', function ($match) { return redirect.format($match); }];
+ }
+ return extend(function ($injector, $location) {
+ return handleIfMatch($injector, handler, what.exec($location.path(), $location.search()));
+ }, {
+ prefix: isString(what.prefix) ? what.prefix : ''
+ });
+ },
+ regex: function (what, handler) {
+ if (what.global || what.sticky) throw new Error("when() RegExp must not be global or sticky");
+
+ if (handlerIsString) {
+ redirect = handler;
+ handler = ['$match', function ($match) { return interpolate(redirect, $match); }];
+ }
+ return extend(function ($injector, $location) {
+ return handleIfMatch($injector, handler, what.exec($location.path()));
+ }, {
+ prefix: regExpPrefix(what)
+ });
+ }
+ };
+
+ var check = { matcher: $urlMatcherFactory.isMatcher(what), regex: what instanceof RegExp };
+
+ for (var n in check) {
+ if (check[n]) return this.rule(strategies[n](what, handler));
+ }
+
+ throw new Error("invalid 'what' in when()");
+ };
+
+ /**
+ * @ngdoc function
+ * @name ui.router.router.$urlRouterProvider#deferIntercept
+ * @methodOf ui.router.router.$urlRouterProvider
+ *
+ * @description
+ * Disables (or enables) deferring location change interception.
+ *
+ * If you wish to customize the behavior of syncing the URL (for example, if you wish to
+ * defer a transition but maintain the current URL), call this method at configuration time.
+ * Then, at run time, call `$urlRouter.listen()` after you have configured your own
+ * `$locationChangeSuccess` event handler.
+ *
+ * @example
+ *
+ * var app = angular.module('app', ['ui.router.router']);
+ *
+ * app.config(function ($urlRouterProvider) {
+ *
+ * // Prevent $urlRouter from automatically intercepting URL changes;
+ * // this allows you to configure custom behavior in between
+ * // location changes and route synchronization:
+ * $urlRouterProvider.deferIntercept();
+ *
+ * }).run(function ($rootScope, $urlRouter, UserService) {
+ *
+ * $rootScope.$on('$locationChangeSuccess', function(e) {
+ * // UserService is an example service for managing user state
+ * if (UserService.isLoggedIn()) return;
+ *
+ * // Prevent $urlRouter's default handler from firing
+ * e.preventDefault();
+ *
+ * UserService.handleLogin().then(function() {
+ * // Once the user has logged in, sync the current URL
+ * // to the router:
+ * $urlRouter.sync();
+ * });
+ * });
+ *
+ * // Configures $urlRouter's listener *after* your custom listener
+ * $urlRouter.listen();
+ * });
+ *
+ *
+ * @param {boolean} defer Indicates whether to defer location change interception. Passing
+ no parameter is equivalent to `true`.
+ */
+ this.deferIntercept = function (defer) {
+ if (defer === undefined) defer = true;
+ interceptDeferred = defer;
+ };
+
+ /**
+ * @ngdoc object
+ * @name ui.router.router.$urlRouter
+ *
+ * @requires $location
+ * @requires $rootScope
+ * @requires $injector
+ * @requires $browser
+ *
+ * @description
+ *
+ */
+ this.$get = $get;
+ $get.$inject = ['$location', '$rootScope', '$injector', '$browser'];
+ function $get( $location, $rootScope, $injector, $browser) {
+
+ var baseHref = $browser.baseHref(), location = $location.url(), lastPushedUrl;
+
+ function appendBasePath(url, isHtml5, absolute) {
+ if (baseHref === '/') return url;
+ if (isHtml5) return baseHref.slice(0, -1) + url;
+ if (absolute) return baseHref.slice(1) + url;
+ return url;
+ }
+
+ // TODO: Optimize groups of rules with non-empty prefix into some sort of decision tree
+ function update(evt) {
+ if (evt && evt.defaultPrevented) return;
+ var ignoreUpdate = lastPushedUrl && $location.url() === lastPushedUrl;
+ lastPushedUrl = undefined;
+ if (ignoreUpdate) return true;
+
+ function check(rule) {
+ var handled = rule($injector, $location);
+
+ if (!handled) return false;
+ if (isString(handled)) $location.replace().url(handled);
+ return true;
+ }
+ var n = rules.length, i;
+
+ for (i = 0; i < n; i++) {
+ if (check(rules[i])) return;
+ }
+ // always check otherwise last to allow dynamic updates to the set of rules
+ if (otherwise) check(otherwise);
+ }
+
+ function listen() {
+ listener = listener || $rootScope.$on('$locationChangeSuccess', update);
+ return listener;
+ }
+
+ if (!interceptDeferred) listen();
+
+ return {
+ /**
+ * @ngdoc function
+ * @name ui.router.router.$urlRouter#sync
+ * @methodOf ui.router.router.$urlRouter
+ *
+ * @description
+ * Triggers an update; the same update that happens when the address bar url changes, aka `$locationChangeSuccess`.
+ * This method is useful when you need to use `preventDefault()` on the `$locationChangeSuccess` event,
+ * perform some custom logic (route protection, auth, config, redirection, etc) and then finally proceed
+ * with the transition by calling `$urlRouter.sync()`.
+ *
+ * @example
+ *
+ * angular.module('app', ['ui.router'])
+ * .run(function($rootScope, $urlRouter) {
+ * $rootScope.$on('$locationChangeSuccess', function(evt) {
+ * // Halt state change from even starting
+ * evt.preventDefault();
+ * // Perform custom logic
+ * var meetsRequirement = ...
+ * // Continue with the update and state transition if logic allows
+ * if (meetsRequirement) $urlRouter.sync();
+ * });
+ * });
+ *
+ */
+ sync: function() {
+ update();
+ },
+
+ listen: function() {
+ return listen();
+ },
+
+ update: function(read) {
+ if (read) {
+ location = $location.url();
+ return;
+ }
+ if ($location.url() === location) return;
+
+ $location.url(location);
+ $location.replace();
+ },
+
+ push: function(urlMatcher, params, options) {
+ $location.url(urlMatcher.format(params || {}));
+ lastPushedUrl = options && options.$$avoidResync ? $location.url() : undefined;
+ if (options && options.replace) $location.replace();
+ },
+
+ /**
+ * @ngdoc function
+ * @name ui.router.router.$urlRouter#href
+ * @methodOf ui.router.router.$urlRouter
+ *
+ * @description
+ * A URL generation method that returns the compiled URL for a given
+ * {@link ui.router.util.type:UrlMatcher `UrlMatcher`}, populated with the provided parameters.
+ *
+ * @example
+ *
+ * $bob = $urlRouter.href(new UrlMatcher("/about/:person"), {
+ * person: "bob"
+ * });
+ * // $bob == "/about/bob";
+ *
+ *
+ * @param {UrlMatcher} urlMatcher The `UrlMatcher` object which is used as the template of the URL to generate.
+ * @param {object=} params An object of parameter values to fill the matcher's required parameters.
+ * @param {object=} options Options object. The options are:
+ *
+ * - **`absolute`** - {boolean=false}, If true will generate an absolute url, e.g. "http://www.example.com/fullurl".
+ *
+ * @returns {string} Returns the fully compiled URL, or `null` if `params` fail validation against `urlMatcher`
+ */
+ href: function(urlMatcher, params, options) {
+ if (!urlMatcher.validates(params)) return null;
+
+ var isHtml5 = $locationProvider.html5Mode();
+ if (angular.isObject(isHtml5)) {
+ isHtml5 = isHtml5.enabled;
+ }
+
+ var url = urlMatcher.format(params);
+ options = options || {};
+
+ if (!isHtml5 && url !== null) {
+ url = "#" + $locationProvider.hashPrefix() + url;
+ }
+ url = appendBasePath(url, isHtml5, options.absolute);
+
+ if (!options.absolute || !url) {
+ return url;
+ }
+
+ var slash = (!isHtml5 && url ? '/' : ''), port = $location.port();
+ port = (port === 80 || port === 443 ? '' : ':' + port);
+
+ return [$location.protocol(), '://', $location.host(), port, slash, url].join('');
+ }
+ };
+ }
+}
+
+angular.module('ui.router.router').provider('$urlRouter', $UrlRouterProvider);
diff --git a/client/www/lib/angular-ui-router/src/view.js b/client/www/lib/angular-ui-router/src/view.js
new file mode 100644
index 0000000..f19a3c5
--- /dev/null
+++ b/client/www/lib/angular-ui-router/src/view.js
@@ -0,0 +1,71 @@
+
+$ViewProvider.$inject = [];
+function $ViewProvider() {
+
+ this.$get = $get;
+ /**
+ * @ngdoc object
+ * @name ui.router.state.$view
+ *
+ * @requires ui.router.util.$templateFactory
+ * @requires $rootScope
+ *
+ * @description
+ *
+ */
+ $get.$inject = ['$rootScope', '$templateFactory'];
+ function $get( $rootScope, $templateFactory) {
+ return {
+ // $view.load('full.viewName', { template: ..., controller: ..., resolve: ..., async: false, params: ... })
+ /**
+ * @ngdoc function
+ * @name ui.router.state.$view#load
+ * @methodOf ui.router.state.$view
+ *
+ * @description
+ *
+ * @param {string} name name
+ * @param {object} options option object.
+ */
+ load: function load(name, options) {
+ var result, defaults = {
+ template: null, controller: null, view: null, locals: null, notify: true, async: true, params: {}
+ };
+ options = extend(defaults, options);
+
+ if (options.view) {
+ result = $templateFactory.fromConfig(options.view, options.params, options.locals);
+ }
+ if (result && options.notify) {
+ /**
+ * @ngdoc event
+ * @name ui.router.state.$state#$viewContentLoading
+ * @eventOf ui.router.state.$view
+ * @eventType broadcast on root scope
+ * @description
+ *
+ * Fired once the view **begins loading**, *before* the DOM is rendered.
+ *
+ * @param {Object} event Event object.
+ * @param {Object} viewConfig The view config properties (template, controller, etc).
+ *
+ * @example
+ *
+ *
+ * $scope.$on('$viewContentLoading',
+ * function(event, viewConfig){
+ * // Access to all the view config properties.
+ * // and one special property 'targetView'
+ * // viewConfig.targetView
+ * });
+ *
+ */
+ $rootScope.$broadcast('$viewContentLoading', options);
+ }
+ return result;
+ }
+ };
+ }
+}
+
+angular.module('ui.router.state').provider('$view', $ViewProvider);
diff --git a/client/www/lib/angular-ui-router/src/viewDirective.js b/client/www/lib/angular-ui-router/src/viewDirective.js
new file mode 100644
index 0000000..d3cf100
--- /dev/null
+++ b/client/www/lib/angular-ui-router/src/viewDirective.js
@@ -0,0 +1,302 @@
+/**
+ * @ngdoc directive
+ * @name ui.router.state.directive:ui-view
+ *
+ * @requires ui.router.state.$state
+ * @requires $compile
+ * @requires $controller
+ * @requires $injector
+ * @requires ui.router.state.$uiViewScroll
+ * @requires $document
+ *
+ * @restrict ECA
+ *
+ * @description
+ * The ui-view directive tells $state where to place your templates.
+ *
+ * @param {string=} name A view name. The name should be unique amongst the other views in the
+ * same state. You can have views of the same name that live in different states.
+ *
+ * @param {string=} autoscroll It allows you to set the scroll behavior of the browser window
+ * when a view is populated. By default, $anchorScroll is overridden by ui-router's custom scroll
+ * service, {@link ui.router.state.$uiViewScroll}. This custom service let's you
+ * scroll ui-view elements into view when they are populated during a state activation.
+ *
+ * *Note: To revert back to old [`$anchorScroll`](http://docs.angularjs.org/api/ng.$anchorScroll)
+ * functionality, call `$uiViewScrollProvider.useAnchorScroll()`.*
+ *
+ * @param {string=} onload Expression to evaluate whenever the view updates.
+ *
+ * @example
+ * A view can be unnamed or named.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * You can only have one unnamed view within any template (or root html). If you are only using a
+ * single view and it is unnamed then you can populate it like so:
+ *
+ *
+ * $stateProvider.state("home", {
+ * template: "
+ *
+ * The above is a convenient shortcut equivalent to specifying your view explicitly with the {@link ui.router.state.$stateProvider#views `views`}
+ * config property, by name, in this case an empty name:
+ * HELLO!
"
+ * })
+ *
+ * $stateProvider.state("home", {
+ * views: {
+ * "": {
+ * template: "
+ *
+ * But typically you'll only use the views property if you name your view or have more than one view
+ * in the same template. There's not really a compelling reason to name a view if its the only one,
+ * but you could if you wanted, like so:
+ * HELLO!
"
+ * }
+ * }
+ * })
+ *
+ *
+ *
+ *
+ * $stateProvider.state("home", {
+ * views: {
+ * "main": {
+ * template: "
+ *
+ * Really though, you'll use views to set up multiple views:
+ * HELLO!
"
+ * }
+ * }
+ * })
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * $stateProvider.state("home", {
+ * views: {
+ * "": {
+ * template: "
+ *
+ * Examples for `autoscroll`:
+ *
+ * HELLO!
"
+ * },
+ * "chart": {
+ * template: "
+ *
+ *
+ */
+$ViewDirective.$inject = ['$state', '$injector', '$uiViewScroll', '$interpolate'];
+function $ViewDirective( $state, $injector, $uiViewScroll, $interpolate) {
+
+ function getService() {
+ return ($injector.has) ? function(service) {
+ return $injector.has(service) ? $injector.get(service) : null;
+ } : function(service) {
+ try {
+ return $injector.get(service);
+ } catch (e) {
+ return null;
+ }
+ };
+ }
+
+ var service = getService(),
+ $animator = service('$animator'),
+ $animate = service('$animate');
+
+ // Returns a set of DOM manipulation functions based on which Angular version
+ // it should use
+ function getRenderer(attrs, scope) {
+ var statics = function() {
+ return {
+ enter: function (element, target, cb) { target.after(element); cb(); },
+ leave: function (element, cb) { element.remove(); cb(); }
+ };
+ };
+
+ if ($animate) {
+ return {
+ enter: function(element, target, cb) {
+ var promise = $animate.enter(element, null, target, cb);
+ if (promise && promise.then) promise.then(cb);
+ },
+ leave: function(element, cb) {
+ var promise = $animate.leave(element, cb);
+ if (promise && promise.then) promise.then(cb);
+ }
+ };
+ }
+
+ if ($animator) {
+ var animate = $animator && $animator(scope, attrs);
+
+ return {
+ enter: function(element, target, cb) {animate.enter(element, null, target); cb(); },
+ leave: function(element, cb) { animate.leave(element); cb(); }
+ };
+ }
+
+ return statics();
+ }
+
+ var directive = {
+ restrict: 'ECA',
+ terminal: true,
+ priority: 400,
+ transclude: 'element',
+ compile: function (tElement, tAttrs, $transclude) {
+ return function (scope, $element, attrs) {
+ var previousEl, currentEl, currentScope, latestLocals,
+ onloadExp = attrs.onload || '',
+ autoScrollExp = attrs.autoscroll,
+ renderer = getRenderer(attrs, scope);
+
+ scope.$on('$stateChangeSuccess', function() {
+ updateView(false);
+ });
+ scope.$on('$viewContentLoading', function() {
+ updateView(false);
+ });
+
+ updateView(true);
+
+ function cleanupLastView() {
+ if (previousEl) {
+ previousEl.remove();
+ previousEl = null;
+ }
+
+ if (currentScope) {
+ currentScope.$destroy();
+ currentScope = null;
+ }
+
+ if (currentEl) {
+ renderer.leave(currentEl, function() {
+ previousEl = null;
+ });
+
+ previousEl = currentEl;
+ currentEl = null;
+ }
+ }
+
+ function updateView(firstTime) {
+ var newScope,
+ name = getUiViewName(scope, attrs, $element, $interpolate),
+ previousLocals = name && $state.$current && $state.$current.locals[name];
+
+ if (!firstTime && previousLocals === latestLocals) return; // nothing to do
+ newScope = scope.$new();
+ latestLocals = $state.$current.locals[name];
+
+ var clone = $transclude(newScope, function(clone) {
+ renderer.enter(clone, $element, function onUiViewEnter() {
+ if(currentScope) {
+ currentScope.$emit('$viewContentAnimationEnded');
+ }
+
+ if (angular.isDefined(autoScrollExp) && !autoScrollExp || scope.$eval(autoScrollExp)) {
+ $uiViewScroll(clone);
+ }
+ });
+ cleanupLastView();
+ });
+
+ currentEl = clone;
+ currentScope = newScope;
+ /**
+ * @ngdoc event
+ * @name ui.router.state.directive:ui-view#$viewContentLoaded
+ * @eventOf ui.router.state.directive:ui-view
+ * @eventType emits on ui-view directive scope
+ * @description *
+ * Fired once the view is **loaded**, *after* the DOM is rendered.
+ *
+ * @param {Object} event Event object.
+ */
+ currentScope.$emit('$viewContentLoaded');
+ currentScope.$eval(onloadExp);
+ }
+ };
+ }
+ };
+
+ return directive;
+}
+
+$ViewDirectiveFill.$inject = ['$compile', '$controller', '$state', '$interpolate'];
+function $ViewDirectiveFill ( $compile, $controller, $state, $interpolate) {
+ return {
+ restrict: 'ECA',
+ priority: -400,
+ compile: function (tElement) {
+ var initial = tElement.html();
+ return function (scope, $element, attrs) {
+ var current = $state.$current,
+ name = getUiViewName(scope, attrs, $element, $interpolate),
+ locals = current && current.locals[name];
+
+ if (! locals) {
+ return;
+ }
+
+ $element.data('$uiView', { name: name, state: locals.$$state });
+ $element.html(locals.$template ? locals.$template : initial);
+
+ var link = $compile($element.contents());
+
+ if (locals.$$controller) {
+ locals.$scope = scope;
+ var controller = $controller(locals.$$controller, locals);
+ if (locals.$$controllerAs) {
+ scope[locals.$$controllerAs] = controller;
+ }
+ $element.data('$ngControllerController', controller);
+ $element.children().data('$ngControllerController', controller);
+ }
+
+ link(scope);
+ };
+ }
+ };
+}
+
+/**
+ * Shared ui-view code for both directives:
+ * Given scope, element, and its attributes, return the view's name
+ */
+function getUiViewName(scope, attrs, element, $interpolate) {
+ var name = $interpolate(attrs.uiView || attrs.name || '')(scope);
+ var inherited = element.inheritedData('$uiView');
+ return name.indexOf('@') >= 0 ? name : (name + '@' + (inherited ? inherited.state.name : ''));
+}
+
+angular.module('ui.router.state').directive('uiView', $ViewDirective);
+angular.module('ui.router.state').directive('uiView', $ViewDirectiveFill);
diff --git a/client/www/lib/angular-ui-router/src/viewScroll.js b/client/www/lib/angular-ui-router/src/viewScroll.js
new file mode 100644
index 0000000..dfe0a03
--- /dev/null
+++ b/client/www/lib/angular-ui-router/src/viewScroll.js
@@ -0,0 +1,52 @@
+/**
+ * @ngdoc object
+ * @name ui.router.state.$uiViewScrollProvider
+ *
+ * @description
+ * Provider that returns the {@link ui.router.state.$uiViewScroll} service function.
+ */
+function $ViewScrollProvider() {
+
+ var useAnchorScroll = false;
+
+ /**
+ * @ngdoc function
+ * @name ui.router.state.$uiViewScrollProvider#useAnchorScroll
+ * @methodOf ui.router.state.$uiViewScrollProvider
+ *
+ * @description
+ * Reverts back to using the core [`$anchorScroll`](http://docs.angularjs.org/api/ng.$anchorScroll) service for
+ * scrolling based on the url anchor.
+ */
+ this.useAnchorScroll = function () {
+ useAnchorScroll = true;
+ };
+
+ /**
+ * @ngdoc object
+ * @name ui.router.state.$uiViewScroll
+ *
+ * @requires $anchorScroll
+ * @requires $timeout
+ *
+ * @description
+ * When called with a jqLite element, it scrolls the element into view (after a
+ * `$timeout` so the DOM has time to refresh).
+ *
+ * If you prefer to rely on `$anchorScroll` to scroll the view to the anchor,
+ * this can be enabled by calling {@link ui.router.state.$uiViewScrollProvider#methods_useAnchorScroll `$uiViewScrollProvider.useAnchorScroll()`}.
+ */
+ this.$get = ['$anchorScroll', '$timeout', function ($anchorScroll, $timeout) {
+ if (useAnchorScroll) {
+ return $anchorScroll;
+ }
+
+ return function ($element) {
+ $timeout(function () {
+ $element[0].scrollIntoView();
+ }, 0, false);
+ };
+ }];
+}
+
+angular.module('ui.router.state').provider('$uiViewScroll', $ViewScrollProvider);
diff --git a/client/www/lib/angular/.bower.json b/client/www/lib/angular/.bower.json
new file mode 100644
index 0000000..1bc3863
--- /dev/null
+++ b/client/www/lib/angular/.bower.json
@@ -0,0 +1,17 @@
+{
+ "name": "angular",
+ "version": "1.4.3",
+ "main": "./angular.js",
+ "ignore": [],
+ "dependencies": {},
+ "homepage": "https://github.com/angular/bower-angular",
+ "_release": "1.4.3",
+ "_resolution": {
+ "type": "version",
+ "tag": "v1.4.3",
+ "commit": "dbd689e8103a6366e53e1f6786727f7c65ccfd75"
+ },
+ "_source": "https://github.com/angular/bower-angular.git",
+ "_target": "1.4.3",
+ "_originalSource": "angular"
+}
\ No newline at end of file
diff --git a/client/www/lib/angular/README.md b/client/www/lib/angular/README.md
new file mode 100644
index 0000000..d1bc0ed
--- /dev/null
+++ b/client/www/lib/angular/README.md
@@ -0,0 +1,64 @@
+# packaged angular
+
+This repo is for distribution on `npm` and `bower`. The source for this module is in the
+[main AngularJS repo](https://github.com/angular/angular.js).
+Please file issues and pull requests against that repo.
+
+## Install
+
+You can install this package either with `npm` or with `bower`.
+
+### npm
+
+```shell
+npm install angular
+```
+
+Then add a `
+```
+
+Or `require('angular')` from your code.
+
+### bower
+
+```shell
+bower install angular
+```
+
+Then add a `
+```
+
+## Documentation
+
+Documentation is available on the
+[AngularJS docs site](http://docs.angularjs.org/).
+
+## License
+
+The MIT License
+
+Copyright (c) 2010-2015 Google, Inc. http://angularjs.org
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/client/www/lib/angular/angular-csp.css b/client/www/lib/angular/angular-csp.css
new file mode 100644
index 0000000..f3cd926
--- /dev/null
+++ b/client/www/lib/angular/angular-csp.css
@@ -0,0 +1,21 @@
+/* Include this file in your html if you are using the CSP mode. */
+
+@charset "UTF-8";
+
+[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak],
+.ng-cloak, .x-ng-cloak,
+.ng-hide:not(.ng-hide-animate) {
+ display: none !important;
+}
+
+ng\:form {
+ display: block;
+}
+
+.ng-animate-shim {
+ visibility:hidden;
+}
+
+.ng-anchor {
+ position:absolute;
+}
diff --git a/client/www/lib/angular/angular.js b/client/www/lib/angular/angular.js
new file mode 100644
index 0000000..f7442c0
--- /dev/null
+++ b/client/www/lib/angular/angular.js
@@ -0,0 +1,28364 @@
+/**
+ * @license AngularJS v1.4.3
+ * (c) 2010-2015 Google, Inc. http://angularjs.org
+ * License: MIT
+ */
+(function(window, document, undefined) {'use strict';
+
+/**
+ * @description
+ *
+ * This object provides a utility for producing rich Error messages within
+ * Angular. It can be called as follows:
+ *
+ * var exampleMinErr = minErr('example');
+ * throw exampleMinErr('one', 'This {0} is {1}', foo, bar);
+ *
+ * The above creates an instance of minErr in the example namespace. The
+ * resulting error will have a namespaced error code of example.one. The
+ * resulting error will replace {0} with the value of foo, and {1} with the
+ * value of bar. The object is not restricted in the number of arguments it can
+ * take.
+ *
+ * If fewer arguments are specified than necessary for interpolation, the extra
+ * interpolation markers will be preserved in the final string.
+ *
+ * Since data will be parsed statically during a build step, some restrictions
+ * are applied with respect to how minErr instances are created and called.
+ * Instances should have names of the form namespaceMinErr for a minErr created
+ * using minErr('namespace') . Error codes, namespaces and template strings
+ * should all be static strings, not variables or general expressions.
+ *
+ * @param {string} module The namespace to use for the new minErr instance.
+ * @param {function} ErrorConstructor Custom error constructor to be instantiated when returning
+ * error from returned function, for cases when a particular type of error is useful.
+ * @returns {function(code:string, template:string, ...templateArgs): Error} minErr instance
+ */
+
+function minErr(module, ErrorConstructor) {
+ ErrorConstructor = ErrorConstructor || Error;
+ return function() {
+ var SKIP_INDEXES = 2;
+
+ var templateArgs = arguments,
+ code = templateArgs[0],
+ message = '[' + (module ? module + ':' : '') + code + '] ',
+ template = templateArgs[1],
+ paramPrefix, i;
+
+ message += template.replace(/\{\d+\}/g, function(match) {
+ var index = +match.slice(1, -1),
+ shiftedIndex = index + SKIP_INDEXES;
+
+ if (shiftedIndex < templateArgs.length) {
+ return toDebugString(templateArgs[shiftedIndex]);
+ }
+
+ return match;
+ });
+
+ message += '\nhttp://errors.angularjs.org/1.4.3/' +
+ (module ? module + '/' : '') + code;
+
+ for (i = SKIP_INDEXES, paramPrefix = '?'; i < templateArgs.length; i++, paramPrefix = '&') {
+ message += paramPrefix + 'p' + (i - SKIP_INDEXES) + '=' +
+ encodeURIComponent(toDebugString(templateArgs[i]));
+ }
+
+ return new ErrorConstructor(message);
+ };
+}
+
+/* We need to tell jshint what variables are being exported */
+/* global angular: true,
+ msie: true,
+ jqLite: true,
+ jQuery: true,
+ slice: true,
+ splice: true,
+ push: true,
+ toString: true,
+ ngMinErr: true,
+ angularModule: true,
+ uid: true,
+ REGEX_STRING_REGEXP: true,
+ VALIDITY_STATE_PROPERTY: true,
+
+ lowercase: true,
+ uppercase: true,
+ manualLowercase: true,
+ manualUppercase: true,
+ nodeName_: true,
+ isArrayLike: true,
+ forEach: true,
+ forEachSorted: true,
+ reverseParams: true,
+ nextUid: true,
+ setHashKey: true,
+ extend: true,
+ toInt: true,
+ inherit: true,
+ merge: true,
+ noop: true,
+ identity: true,
+ valueFn: true,
+ isUndefined: true,
+ isDefined: true,
+ isObject: true,
+ isBlankObject: true,
+ isString: true,
+ isNumber: true,
+ isDate: true,
+ isArray: true,
+ isFunction: true,
+ isRegExp: true,
+ isWindow: true,
+ isScope: true,
+ isFile: true,
+ isFormData: true,
+ isBlob: true,
+ isBoolean: true,
+ isPromiseLike: true,
+ trim: true,
+ escapeForRegexp: true,
+ isElement: true,
+ makeMap: true,
+ includes: true,
+ arrayRemove: true,
+ copy: true,
+ shallowCopy: true,
+ equals: true,
+ csp: true,
+ jq: true,
+ concat: true,
+ sliceArgs: true,
+ bind: true,
+ toJsonReplacer: true,
+ toJson: true,
+ fromJson: true,
+ convertTimezoneToLocal: true,
+ timezoneToOffset: true,
+ startingTag: true,
+ tryDecodeURIComponent: true,
+ parseKeyValue: true,
+ toKeyValue: true,
+ encodeUriSegment: true,
+ encodeUriQuery: true,
+ angularInit: true,
+ bootstrap: true,
+ getTestability: true,
+ snake_case: true,
+ bindJQuery: true,
+ assertArg: true,
+ assertArgFn: true,
+ assertNotHasOwnProperty: true,
+ getter: true,
+ getBlockNodes: true,
+ hasOwnProperty: true,
+ createMap: true,
+
+ NODE_TYPE_ELEMENT: true,
+ NODE_TYPE_ATTRIBUTE: true,
+ NODE_TYPE_TEXT: true,
+ NODE_TYPE_COMMENT: true,
+ NODE_TYPE_DOCUMENT: true,
+ NODE_TYPE_DOCUMENT_FRAGMENT: true,
+*/
+
+////////////////////////////////////
+
+/**
+ * @ngdoc module
+ * @name ng
+ * @module ng
+ * @description
+ *
+ * # ng (core module)
+ * The ng module is loaded by default when an AngularJS application is started. The module itself
+ * contains the essential components for an AngularJS application to function. The table below
+ * lists a high level breakdown of each of the services/factories, filters, directives and testing
+ * components available within this core module.
+ *
+ *
+ */
+
+var REGEX_STRING_REGEXP = /^\/(.+)\/([a-z]*)$/;
+
+// The name of a form control's ValidityState property.
+// This is used so that it's possible for internal tests to create mock ValidityStates.
+var VALIDITY_STATE_PROPERTY = 'validity';
+
+/**
+ * @ngdoc function
+ * @name angular.lowercase
+ * @module ng
+ * @kind function
+ *
+ * @description Converts the specified string to lowercase.
+ * @param {string} string String to be converted to lowercase.
+ * @returns {string} Lowercased string.
+ */
+var lowercase = function(string) {return isString(string) ? string.toLowerCase() : string;};
+var hasOwnProperty = Object.prototype.hasOwnProperty;
+
+/**
+ * @ngdoc function
+ * @name angular.uppercase
+ * @module ng
+ * @kind function
+ *
+ * @description Converts the specified string to uppercase.
+ * @param {string} string String to be converted to uppercase.
+ * @returns {string} Uppercased string.
+ */
+var uppercase = function(string) {return isString(string) ? string.toUpperCase() : string;};
+
+
+var manualLowercase = function(s) {
+ /* jshint bitwise: false */
+ return isString(s)
+ ? s.replace(/[A-Z]/g, function(ch) {return String.fromCharCode(ch.charCodeAt(0) | 32);})
+ : s;
+};
+var manualUppercase = function(s) {
+ /* jshint bitwise: false */
+ return isString(s)
+ ? s.replace(/[a-z]/g, function(ch) {return String.fromCharCode(ch.charCodeAt(0) & ~32);})
+ : s;
+};
+
+
+// String#toLowerCase and String#toUpperCase don't produce correct results in browsers with Turkish
+// locale, for this reason we need to detect this case and redefine lowercase/uppercase methods
+// with correct but slower alternatives.
+if ('i' !== 'I'.toLowerCase()) {
+ lowercase = manualLowercase;
+ uppercase = manualUppercase;
+}
+
+
+var
+ msie, // holds major version number for IE, or NaN if UA is not IE.
+ jqLite, // delay binding since jQuery could be loaded after us.
+ jQuery, // delay binding
+ slice = [].slice,
+ splice = [].splice,
+ push = [].push,
+ toString = Object.prototype.toString,
+ getPrototypeOf = Object.getPrototypeOf,
+ ngMinErr = minErr('ng'),
+
+ /** @name angular */
+ angular = window.angular || (window.angular = {}),
+ angularModule,
+ uid = 0;
+
+/**
+ * documentMode is an IE-only property
+ * http://msdn.microsoft.com/en-us/library/ie/cc196988(v=vs.85).aspx
+ */
+msie = document.documentMode;
+
+
+/**
+ * @private
+ * @param {*} obj
+ * @return {boolean} Returns true if `obj` is an array or array-like object (NodeList, Arguments,
+ * String ...)
+ */
+function isArrayLike(obj) {
+ if (obj == null || isWindow(obj)) {
+ return false;
+ }
+
+ // Support: iOS 8.2 (not reproducible in simulator)
+ // "length" in obj used to prevent JIT error (gh-11508)
+ var length = "length" in Object(obj) && obj.length;
+
+ if (obj.nodeType === NODE_TYPE_ELEMENT && length) {
+ return true;
+ }
+
+ return isString(obj) || isArray(obj) || length === 0 ||
+ typeof length === 'number' && length > 0 && (length - 1) in obj;
+}
+
+/**
+ * @ngdoc function
+ * @name angular.forEach
+ * @module ng
+ * @kind function
+ *
+ * @description
+ * Invokes the `iterator` function once for each item in `obj` collection, which can be either an
+ * object or an array. The `iterator` function is invoked with `iterator(value, key, obj)`, where `value`
+ * is the value of an object property or an array element, `key` is the object property key or
+ * array element index and obj is the `obj` itself. Specifying a `context` for the function is optional.
+ *
+ * It is worth noting that `.forEach` does not iterate over inherited properties because it filters
+ * using the `hasOwnProperty` method.
+ *
+ * Unlike ES262's
+ * [Array.prototype.forEach](http://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.18),
+ * Providing 'undefined' or 'null' values for `obj` will not throw a TypeError, but rather just
+ * return the value provided.
+ *
+ ```js
+ var values = {name: 'misko', gender: 'male'};
+ var log = [];
+ angular.forEach(values, function(value, key) {
+ this.push(key + ': ' + value);
+ }, log);
+ expect(log).toEqual(['name: misko', 'gender: male']);
+ ```
+ *
+ * @param {Object|Array} obj Object to iterate over.
+ * @param {Function} iterator Iterator function.
+ * @param {Object=} context Object to become context (`this`) for the iterator function.
+ * @returns {Object|Array} Reference to `obj`.
+ */
+
+function forEach(obj, iterator, context) {
+ var key, length;
+ if (obj) {
+ if (isFunction(obj)) {
+ for (key in obj) {
+ // Need to check if hasOwnProperty exists,
+ // as on IE8 the result of querySelectorAll is an object without a hasOwnProperty function
+ if (key != 'prototype' && key != 'length' && key != 'name' && (!obj.hasOwnProperty || obj.hasOwnProperty(key))) {
+ iterator.call(context, obj[key], key, obj);
+ }
+ }
+ } else if (isArray(obj) || isArrayLike(obj)) {
+ var isPrimitive = typeof obj !== 'object';
+ for (key = 0, length = obj.length; key < length; key++) {
+ if (isPrimitive || key in obj) {
+ iterator.call(context, obj[key], key, obj);
+ }
+ }
+ } else if (obj.forEach && obj.forEach !== forEach) {
+ obj.forEach(iterator, context, obj);
+ } else if (isBlankObject(obj)) {
+ // createMap() fast path --- Safe to avoid hasOwnProperty check because prototype chain is empty
+ for (key in obj) {
+ iterator.call(context, obj[key], key, obj);
+ }
+ } else if (typeof obj.hasOwnProperty === 'function') {
+ // Slow path for objects inheriting Object.prototype, hasOwnProperty check needed
+ for (key in obj) {
+ if (obj.hasOwnProperty(key)) {
+ iterator.call(context, obj[key], key, obj);
+ }
+ }
+ } else {
+ // Slow path for objects which do not have a method `hasOwnProperty`
+ for (key in obj) {
+ if (hasOwnProperty.call(obj, key)) {
+ iterator.call(context, obj[key], key, obj);
+ }
+ }
+ }
+ }
+ return obj;
+}
+
+function forEachSorted(obj, iterator, context) {
+ var keys = Object.keys(obj).sort();
+ for (var i = 0; i < keys.length; i++) {
+ iterator.call(context, obj[keys[i]], keys[i]);
+ }
+ return keys;
+}
+
+
+/**
+ * when using forEach the params are value, key, but it is often useful to have key, value.
+ * @param {function(string, *)} iteratorFn
+ * @returns {function(*, string)}
+ */
+function reverseParams(iteratorFn) {
+ return function(value, key) { iteratorFn(key, value); };
+}
+
+/**
+ * A consistent way of creating unique IDs in angular.
+ *
+ * Using simple numbers allows us to generate 28.6 million unique ids per second for 10 years before
+ * we hit number precision issues in JavaScript.
+ *
+ * Math.pow(2,53) / 60 / 60 / 24 / 365 / 10 = 28.6M
+ *
+ * @returns {number} an unique alpha-numeric string
+ */
+function nextUid() {
+ return ++uid;
+}
+
+
+/**
+ * Set or clear the hashkey for an object.
+ * @param obj object
+ * @param h the hashkey (!truthy to delete the hashkey)
+ */
+function setHashKey(obj, h) {
+ if (h) {
+ obj.$$hashKey = h;
+ } else {
+ delete obj.$$hashKey;
+ }
+}
+
+
+function baseExtend(dst, objs, deep) {
+ var h = dst.$$hashKey;
+
+ for (var i = 0, ii = objs.length; i < ii; ++i) {
+ var obj = objs[i];
+ if (!isObject(obj) && !isFunction(obj)) continue;
+ var keys = Object.keys(obj);
+ for (var j = 0, jj = keys.length; j < jj; j++) {
+ var key = keys[j];
+ var src = obj[key];
+
+ if (deep && isObject(src)) {
+ if (isDate(src)) {
+ dst[key] = new Date(src.valueOf());
+ } else {
+ if (!isObject(dst[key])) dst[key] = isArray(src) ? [] : {};
+ baseExtend(dst[key], [src], true);
+ }
+ } else {
+ dst[key] = src;
+ }
+ }
+ }
+
+ setHashKey(dst, h);
+ return dst;
+}
+
+/**
+ * @ngdoc function
+ * @name angular.extend
+ * @module ng
+ * @kind function
+ *
+ * @description
+ * Extends the destination object `dst` by copying own enumerable properties from the `src` object(s)
+ * to `dst`. You can specify multiple `src` objects. If you want to preserve original objects, you can do so
+ * by passing an empty object as the target: `var object = angular.extend({}, object1, object2)`.
+ *
+ * **Note:** Keep in mind that `angular.extend` does not support recursive merge (deep copy). Use
+ * {@link angular.merge} for this.
+ *
+ * @param {Object} dst Destination object.
+ * @param {...Object} src Source object(s).
+ * @returns {Object} Reference to `dst`.
+ */
+function extend(dst) {
+ return baseExtend(dst, slice.call(arguments, 1), false);
+}
+
+
+/**
+* @ngdoc function
+* @name angular.merge
+* @module ng
+* @kind function
+*
+* @description
+* Deeply extends the destination object `dst` by copying own enumerable properties from the `src` object(s)
+* to `dst`. You can specify multiple `src` objects. If you want to preserve original objects, you can do so
+* by passing an empty object as the target: `var object = angular.merge({}, object1, object2)`.
+*
+* Unlike {@link angular.extend extend()}, `merge()` recursively descends into object properties of source
+* objects, performing a deep copy.
+*
+* @param {Object} dst Destination object.
+* @param {...Object} src Source object(s).
+* @returns {Object} Reference to `dst`.
+*/
+function merge(dst) {
+ return baseExtend(dst, slice.call(arguments, 1), true);
+}
+
+
+
+function toInt(str) {
+ return parseInt(str, 10);
+}
+
+
+function inherit(parent, extra) {
+ return extend(Object.create(parent), extra);
+}
+
+/**
+ * @ngdoc function
+ * @name angular.noop
+ * @module ng
+ * @kind function
+ *
+ * @description
+ * A function that performs no operations. This function can be useful when writing code in the
+ * functional style.
+ ```js
+ function foo(callback) {
+ var result = calculateResult();
+ (callback || angular.noop)(result);
+ }
+ ```
+ */
+function noop() {}
+noop.$inject = [];
+
+
+/**
+ * @ngdoc function
+ * @name angular.identity
+ * @module ng
+ * @kind function
+ *
+ * @description
+ * A function that returns its first argument. This function is useful when writing code in the
+ * functional style.
+ *
+ ```js
+ function transformer(transformationFn, value) {
+ return (transformationFn || angular.identity)(value);
+ };
+ ```
+ * @param {*} value to be returned.
+ * @returns {*} the value passed in.
+ */
+function identity($) {return $;}
+identity.$inject = [];
+
+
+function valueFn(value) {return function() {return value;};}
+
+function hasCustomToString(obj) {
+ return isFunction(obj.toString) && obj.toString !== Object.prototype.toString;
+}
+
+
+/**
+ * @ngdoc function
+ * @name angular.isUndefined
+ * @module ng
+ * @kind function
+ *
+ * @description
+ * Determines if a reference is undefined.
+ *
+ * @param {*} value Reference to check.
+ * @returns {boolean} True if `value` is undefined.
+ */
+function isUndefined(value) {return typeof value === 'undefined';}
+
+
+/**
+ * @ngdoc function
+ * @name angular.isDefined
+ * @module ng
+ * @kind function
+ *
+ * @description
+ * Determines if a reference is defined.
+ *
+ * @param {*} value Reference to check.
+ * @returns {boolean} True if `value` is defined.
+ */
+function isDefined(value) {return typeof value !== 'undefined';}
+
+
+/**
+ * @ngdoc function
+ * @name angular.isObject
+ * @module ng
+ * @kind function
+ *
+ * @description
+ * Determines if a reference is an `Object`. Unlike `typeof` in JavaScript, `null`s are not
+ * considered to be objects. Note that JavaScript arrays are objects.
+ *
+ * @param {*} value Reference to check.
+ * @returns {boolean} True if `value` is an `Object` but not `null`.
+ */
+function isObject(value) {
+ // http://jsperf.com/isobject4
+ return value !== null && typeof value === 'object';
+}
+
+
+/**
+ * Determine if a value is an object with a null prototype
+ *
+ * @returns {boolean} True if `value` is an `Object` with a null prototype
+ */
+function isBlankObject(value) {
+ return value !== null && typeof value === 'object' && !getPrototypeOf(value);
+}
+
+
+/**
+ * @ngdoc function
+ * @name angular.isString
+ * @module ng
+ * @kind function
+ *
+ * @description
+ * Determines if a reference is a `String`.
+ *
+ * @param {*} value Reference to check.
+ * @returns {boolean} True if `value` is a `String`.
+ */
+function isString(value) {return typeof value === 'string';}
+
+
+/**
+ * @ngdoc function
+ * @name angular.isNumber
+ * @module ng
+ * @kind function
+ *
+ * @description
+ * Determines if a reference is a `Number`.
+ *
+ * This includes the "special" numbers `NaN`, `+Infinity` and `-Infinity`.
+ *
+ * If you wish to exclude these then you can use the native
+ * [`isFinite'](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isFinite)
+ * method.
+ *
+ * @param {*} value Reference to check.
+ * @returns {boolean} True if `value` is a `Number`.
+ */
+function isNumber(value) {return typeof value === 'number';}
+
+
+/**
+ * @ngdoc function
+ * @name angular.isDate
+ * @module ng
+ * @kind function
+ *
+ * @description
+ * Determines if a value is a date.
+ *
+ * @param {*} value Reference to check.
+ * @returns {boolean} True if `value` is a `Date`.
+ */
+function isDate(value) {
+ return toString.call(value) === '[object Date]';
+}
+
+
+/**
+ * @ngdoc function
+ * @name angular.isArray
+ * @module ng
+ * @kind function
+ *
+ * @description
+ * Determines if a reference is an `Array`.
+ *
+ * @param {*} value Reference to check.
+ * @returns {boolean} True if `value` is an `Array`.
+ */
+var isArray = Array.isArray;
+
+/**
+ * @ngdoc function
+ * @name angular.isFunction
+ * @module ng
+ * @kind function
+ *
+ * @description
+ * Determines if a reference is a `Function`.
+ *
+ * @param {*} value Reference to check.
+ * @returns {boolean} True if `value` is a `Function`.
+ */
+function isFunction(value) {return typeof value === 'function';}
+
+
+/**
+ * Determines if a value is a regular expression object.
+ *
+ * @private
+ * @param {*} value Reference to check.
+ * @returns {boolean} True if `value` is a `RegExp`.
+ */
+function isRegExp(value) {
+ return toString.call(value) === '[object RegExp]';
+}
+
+
+/**
+ * Checks if `obj` is a window object.
+ *
+ * @private
+ * @param {*} obj Object to check
+ * @returns {boolean} True if `obj` is a window obj.
+ */
+function isWindow(obj) {
+ return obj && obj.window === obj;
+}
+
+
+function isScope(obj) {
+ return obj && obj.$evalAsync && obj.$watch;
+}
+
+
+function isFile(obj) {
+ return toString.call(obj) === '[object File]';
+}
+
+
+function isFormData(obj) {
+ return toString.call(obj) === '[object FormData]';
+}
+
+
+function isBlob(obj) {
+ return toString.call(obj) === '[object Blob]';
+}
+
+
+function isBoolean(value) {
+ return typeof value === 'boolean';
+}
+
+
+function isPromiseLike(obj) {
+ return obj && isFunction(obj.then);
+}
+
+
+var TYPED_ARRAY_REGEXP = /^\[object (Uint8(Clamped)?)|(Uint16)|(Uint32)|(Int8)|(Int16)|(Int32)|(Float(32)|(64))Array\]$/;
+function isTypedArray(value) {
+ return TYPED_ARRAY_REGEXP.test(toString.call(value));
+}
+
+
+var trim = function(value) {
+ return isString(value) ? value.trim() : value;
+};
+
+// Copied from:
+// http://docs.closure-library.googlecode.com/git/local_closure_goog_string_string.js.source.html#line1021
+// Prereq: s is a string.
+var escapeForRegexp = function(s) {
+ return s.replace(/([-()\[\]{}+?*.$\^|,:#= 0) {
+ array.splice(index, 1);
+ }
+ return index;
+}
+
+/**
+ * @ngdoc function
+ * @name angular.copy
+ * @module ng
+ * @kind function
+ *
+ * @description
+ * Creates a deep copy of `source`, which should be an object or an array.
+ *
+ * * If no destination is supplied, a copy of the object or array is created.
+ * * If a destination is provided, all of its elements (for arrays) or properties (for objects)
+ * are deleted and then all elements/properties from the source are copied to it.
+ * * If `source` is not an object or array (inc. `null` and `undefined`), `source` is returned.
+ * * If `source` is identical to 'destination' an exception will be thrown.
+ *
+ * @param {*} source The source that will be used to make a copy.
+ * Can be any type, including primitives, `null`, and `undefined`.
+ * @param {(Object|Array)=} destination Destination into which the source is copied. If
+ * provided, must be of the same type as `source`.
+ * @returns {*} The copy or updated `destination`, if `destination` was specified.
+ *
+ * @example
+ form = {{user | json}}
+ master = {{master | json}}
+
+ Hello, {{name}}!
+
+ ', '
'],
+ 'col': [2, '
'],
+ 'tr': [2, '', '
'],
+ 'td': [3, '
'],
+ '_default': [0, "", ""]
+};
+
+wrapMap.optgroup = wrapMap.option;
+wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
+wrapMap.th = wrapMap.td;
+
+
+function jqLiteIsTextNode(html) {
+ return !HTML_REGEXP.test(html);
+}
+
+function jqLiteAcceptsData(node) {
+ // The window object can accept data but has no nodeType
+ // Otherwise we are only interested in elements (1) and documents (9)
+ var nodeType = node.nodeType;
+ return nodeType === NODE_TYPE_ELEMENT || !nodeType || nodeType === NODE_TYPE_DOCUMENT;
+}
+
+function jqLiteHasData(node) {
+ for (var key in jqCache[node.ng339]) {
+ return true;
+ }
+ return false;
+}
+
+function jqLiteBuildFragment(html, context) {
+ var tmp, tag, wrap,
+ fragment = context.createDocumentFragment(),
+ nodes = [], i;
+
+ if (jqLiteIsTextNode(html)) {
+ // Convert non-html into a text node
+ nodes.push(context.createTextNode(html));
+ } else {
+ // Convert html into DOM nodes
+ tmp = tmp || fragment.appendChild(context.createElement("div"));
+ tag = (TAG_NAME_REGEXP.exec(html) || ["", ""])[1].toLowerCase();
+ wrap = wrapMap[tag] || wrapMap._default;
+ tmp.innerHTML = wrap[1] + html.replace(XHTML_TAG_REGEXP, "<$1>$2>") + wrap[2];
+
+ // Descend through wrappers to the right content
+ i = wrap[0];
+ while (i--) {
+ tmp = tmp.lastChild;
+ }
+
+ nodes = concat(nodes, tmp.childNodes);
+
+ tmp = fragment.firstChild;
+ tmp.textContent = "";
+ }
+
+ // Remove wrapper from fragment
+ fragment.textContent = "";
+ fragment.innerHTML = ""; // Clear inner HTML
+ forEach(nodes, function(node) {
+ fragment.appendChild(node);
+ });
+
+ return fragment;
+}
+
+function jqLiteParseHTML(html, context) {
+ context = context || document;
+ var parsed;
+
+ if ((parsed = SINGLE_TAG_REGEXP.exec(html))) {
+ return [context.createElement(parsed[1])];
+ }
+
+ if ((parsed = jqLiteBuildFragment(html, context))) {
+ return parsed.childNodes;
+ }
+
+ return [];
+}
+
+/////////////////////////////////////////////
+function JQLite(element) {
+ if (element instanceof JQLite) {
+ return element;
+ }
+
+ var argIsString;
+
+ if (isString(element)) {
+ element = trim(element);
+ argIsString = true;
+ }
+ if (!(this instanceof JQLite)) {
+ if (argIsString && element.charAt(0) != '<') {
+ throw jqLiteMinErr('nosel', 'Looking up elements via selectors is not supported by jqLite! See: http://docs.angularjs.org/api/angular.element');
+ }
+ return new JQLite(element);
+ }
+
+ if (argIsString) {
+ jqLiteAddNodes(this, jqLiteParseHTML(element));
+ } else {
+ jqLiteAddNodes(this, element);
+ }
+}
+
+function jqLiteClone(element) {
+ return element.cloneNode(true);
+}
+
+function jqLiteDealoc(element, onlyDescendants) {
+ if (!onlyDescendants) jqLiteRemoveData(element);
+
+ if (element.querySelectorAll) {
+ var descendants = element.querySelectorAll('*');
+ for (var i = 0, l = descendants.length; i < l; i++) {
+ jqLiteRemoveData(descendants[i]);
+ }
+ }
+}
+
+function jqLiteOff(element, type, fn, unsupported) {
+ if (isDefined(unsupported)) throw jqLiteMinErr('offargs', 'jqLite#off() does not support the `selector` argument');
+
+ var expandoStore = jqLiteExpandoStore(element);
+ var events = expandoStore && expandoStore.events;
+ var handle = expandoStore && expandoStore.handle;
+
+ if (!handle) return; //no listeners registered
+
+ if (!type) {
+ for (type in events) {
+ if (type !== '$destroy') {
+ removeEventListenerFn(element, type, handle);
+ }
+ delete events[type];
+ }
+ } else {
+ forEach(type.split(' '), function(type) {
+ if (isDefined(fn)) {
+ var listenerFns = events[type];
+ arrayRemove(listenerFns || [], fn);
+ if (listenerFns && listenerFns.length > 0) {
+ return;
+ }
+ }
+
+ removeEventListenerFn(element, type, handle);
+ delete events[type];
+ });
+ }
+}
+
+function jqLiteRemoveData(element, name) {
+ var expandoId = element.ng339;
+ var expandoStore = expandoId && jqCache[expandoId];
+
+ if (expandoStore) {
+ if (name) {
+ delete expandoStore.data[name];
+ return;
+ }
+
+ if (expandoStore.handle) {
+ if (expandoStore.events.$destroy) {
+ expandoStore.handle({}, '$destroy');
+ }
+ jqLiteOff(element);
+ }
+ delete jqCache[expandoId];
+ element.ng339 = undefined; // don't delete DOM expandos. IE and Chrome don't like it
+ }
+}
+
+
+function jqLiteExpandoStore(element, createIfNecessary) {
+ var expandoId = element.ng339,
+ expandoStore = expandoId && jqCache[expandoId];
+
+ if (createIfNecessary && !expandoStore) {
+ element.ng339 = expandoId = jqNextId();
+ expandoStore = jqCache[expandoId] = {events: {}, data: {}, handle: undefined};
+ }
+
+ return expandoStore;
+}
+
+
+function jqLiteData(element, key, value) {
+ if (jqLiteAcceptsData(element)) {
+
+ var isSimpleSetter = isDefined(value);
+ var isSimpleGetter = !isSimpleSetter && key && !isObject(key);
+ var massGetter = !key;
+ var expandoStore = jqLiteExpandoStore(element, !isSimpleGetter);
+ var data = expandoStore && expandoStore.data;
+
+ if (isSimpleSetter) { // data('key', value)
+ data[key] = value;
+ } else {
+ if (massGetter) { // data()
+ return data;
+ } else {
+ if (isSimpleGetter) { // data('key')
+ // don't force creation of expandoStore if it doesn't exist yet
+ return data && data[key];
+ } else { // mass-setter: data({key1: val1, key2: val2})
+ extend(data, key);
+ }
+ }
+ }
+ }
+}
+
+function jqLiteHasClass(element, selector) {
+ if (!element.getAttribute) return false;
+ return ((" " + (element.getAttribute('class') || '') + " ").replace(/[\n\t]/g, " ").
+ indexOf(" " + selector + " ") > -1);
+}
+
+function jqLiteRemoveClass(element, cssClasses) {
+ if (cssClasses && element.setAttribute) {
+ forEach(cssClasses.split(' '), function(cssClass) {
+ element.setAttribute('class', trim(
+ (" " + (element.getAttribute('class') || '') + " ")
+ .replace(/[\n\t]/g, " ")
+ .replace(" " + trim(cssClass) + " ", " "))
+ );
+ });
+ }
+}
+
+function jqLiteAddClass(element, cssClasses) {
+ if (cssClasses && element.setAttribute) {
+ var existingClasses = (' ' + (element.getAttribute('class') || '') + ' ')
+ .replace(/[\n\t]/g, " ");
+
+ forEach(cssClasses.split(' '), function(cssClass) {
+ cssClass = trim(cssClass);
+ if (existingClasses.indexOf(' ' + cssClass + ' ') === -1) {
+ existingClasses += cssClass + ' ';
+ }
+ });
+
+ element.setAttribute('class', trim(existingClasses));
+ }
+}
+
+
+function jqLiteAddNodes(root, elements) {
+ // THIS CODE IS VERY HOT. Don't make changes without benchmarking.
+
+ if (elements) {
+
+ // if a Node (the most common case)
+ if (elements.nodeType) {
+ root[root.length++] = elements;
+ } else {
+ var length = elements.length;
+
+ // if an Array or NodeList and not a Window
+ if (typeof length === 'number' && elements.window !== elements) {
+ if (length) {
+ for (var i = 0; i < length; i++) {
+ root[root.length++] = elements[i];
+ }
+ }
+ } else {
+ root[root.length++] = elements;
+ }
+ }
+ }
+}
+
+
+function jqLiteController(element, name) {
+ return jqLiteInheritedData(element, '$' + (name || 'ngController') + 'Controller');
+}
+
+function jqLiteInheritedData(element, name, value) {
+ // if element is the document object work with the html element instead
+ // this makes $(document).scope() possible
+ if (element.nodeType == NODE_TYPE_DOCUMENT) {
+ element = element.documentElement;
+ }
+ var names = isArray(name) ? name : [name];
+
+ while (element) {
+ for (var i = 0, ii = names.length; i < ii; i++) {
+ if ((value = jqLite.data(element, names[i])) !== undefined) return value;
+ }
+
+ // If dealing with a document fragment node with a host element, and no parent, use the host
+ // element as the parent. This enables directives within a Shadow DOM or polyfilled Shadow DOM
+ // to lookup parent controllers.
+ element = element.parentNode || (element.nodeType === NODE_TYPE_DOCUMENT_FRAGMENT && element.host);
+ }
+}
+
+function jqLiteEmpty(element) {
+ jqLiteDealoc(element, true);
+ while (element.firstChild) {
+ element.removeChild(element.firstChild);
+ }
+}
+
+function jqLiteRemove(element, keepData) {
+ if (!keepData) jqLiteDealoc(element);
+ var parent = element.parentNode;
+ if (parent) parent.removeChild(element);
+}
+
+
+function jqLiteDocumentLoaded(action, win) {
+ win = win || window;
+ if (win.document.readyState === 'complete') {
+ // Force the action to be run async for consistent behaviour
+ // from the action's point of view
+ // i.e. it will definitely not be in a $apply
+ win.setTimeout(action);
+ } else {
+ // No need to unbind this handler as load is only ever called once
+ jqLite(win).on('load', action);
+ }
+}
+
+//////////////////////////////////////////
+// Functions which are declared directly.
+//////////////////////////////////////////
+var JQLitePrototype = JQLite.prototype = {
+ ready: function(fn) {
+ var fired = false;
+
+ function trigger() {
+ if (fired) return;
+ fired = true;
+ fn();
+ }
+
+ // check if document is already loaded
+ if (document.readyState === 'complete') {
+ setTimeout(trigger);
+ } else {
+ this.on('DOMContentLoaded', trigger); // works for modern browsers and IE9
+ // we can not use jqLite since we are not done loading and jQuery could be loaded later.
+ // jshint -W064
+ JQLite(window).on('load', trigger); // fallback to window.onload for others
+ // jshint +W064
+ }
+ },
+ toString: function() {
+ var value = [];
+ forEach(this, function(e) { value.push('' + e);});
+ return '[' + value.join(', ') + ']';
+ },
+
+ eq: function(index) {
+ return (index >= 0) ? jqLite(this[index]) : jqLite(this[this.length + index]);
+ },
+
+ length: 0,
+ push: push,
+ sort: [].sort,
+ splice: [].splice
+};
+
+//////////////////////////////////////////
+// Functions iterating getter/setters.
+// these functions return self on setter and
+// value on get.
+//////////////////////////////////////////
+var BOOLEAN_ATTR = {};
+forEach('multiple,selected,checked,disabled,readOnly,required,open'.split(','), function(value) {
+ BOOLEAN_ATTR[lowercase(value)] = value;
+});
+var BOOLEAN_ELEMENTS = {};
+forEach('input,select,option,textarea,button,form,details'.split(','), function(value) {
+ BOOLEAN_ELEMENTS[value] = true;
+});
+var ALIASED_ATTR = {
+ 'ngMinlength': 'minlength',
+ 'ngMaxlength': 'maxlength',
+ 'ngMin': 'min',
+ 'ngMax': 'max',
+ 'ngPattern': 'pattern'
+};
+
+function getBooleanAttrName(element, name) {
+ // check dom last since we will most likely fail on name
+ var booleanAttr = BOOLEAN_ATTR[name.toLowerCase()];
+
+ // booleanAttr is here twice to minimize DOM access
+ return booleanAttr && BOOLEAN_ELEMENTS[nodeName_(element)] && booleanAttr;
+}
+
+function getAliasedAttrName(element, name) {
+ var nodeName = element.nodeName;
+ return (nodeName === 'INPUT' || nodeName === 'TEXTAREA') && ALIASED_ATTR[name];
+}
+
+forEach({
+ data: jqLiteData,
+ removeData: jqLiteRemoveData,
+ hasData: jqLiteHasData
+}, function(fn, name) {
+ JQLite[name] = fn;
+});
+
+forEach({
+ data: jqLiteData,
+ inheritedData: jqLiteInheritedData,
+
+ scope: function(element) {
+ // Can't use jqLiteData here directly so we stay compatible with jQuery!
+ return jqLite.data(element, '$scope') || jqLiteInheritedData(element.parentNode || element, ['$isolateScope', '$scope']);
+ },
+
+ isolateScope: function(element) {
+ // Can't use jqLiteData here directly so we stay compatible with jQuery!
+ return jqLite.data(element, '$isolateScope') || jqLite.data(element, '$isolateScopeNoTemplate');
+ },
+
+ controller: jqLiteController,
+
+ injector: function(element) {
+ return jqLiteInheritedData(element, '$injector');
+ },
+
+ removeAttr: function(element, name) {
+ element.removeAttribute(name);
+ },
+
+ hasClass: jqLiteHasClass,
+
+ css: function(element, name, value) {
+ name = camelCase(name);
+
+ if (isDefined(value)) {
+ element.style[name] = value;
+ } else {
+ return element.style[name];
+ }
+ },
+
+ attr: function(element, name, value) {
+ var nodeType = element.nodeType;
+ if (nodeType === NODE_TYPE_TEXT || nodeType === NODE_TYPE_ATTRIBUTE || nodeType === NODE_TYPE_COMMENT) {
+ return;
+ }
+ var lowercasedName = lowercase(name);
+ if (BOOLEAN_ATTR[lowercasedName]) {
+ if (isDefined(value)) {
+ if (!!value) {
+ element[name] = true;
+ element.setAttribute(name, lowercasedName);
+ } else {
+ element[name] = false;
+ element.removeAttribute(lowercasedName);
+ }
+ } else {
+ return (element[name] ||
+ (element.attributes.getNamedItem(name) || noop).specified)
+ ? lowercasedName
+ : undefined;
+ }
+ } else if (isDefined(value)) {
+ element.setAttribute(name, value);
+ } else if (element.getAttribute) {
+ // the extra argument "2" is to get the right thing for a.href in IE, see jQuery code
+ // some elements (e.g. Document) don't have get attribute, so return undefined
+ var ret = element.getAttribute(name, 2);
+ // normalize non-existing attributes to undefined (as jQuery)
+ return ret === null ? undefined : ret;
+ }
+ },
+
+ prop: function(element, name, value) {
+ if (isDefined(value)) {
+ element[name] = value;
+ } else {
+ return element[name];
+ }
+ },
+
+ text: (function() {
+ getText.$dv = '';
+ return getText;
+
+ function getText(element, value) {
+ if (isUndefined(value)) {
+ var nodeType = element.nodeType;
+ return (nodeType === NODE_TYPE_ELEMENT || nodeType === NODE_TYPE_TEXT) ? element.textContent : '';
+ }
+ element.textContent = value;
+ }
+ })(),
+
+ val: function(element, value) {
+ if (isUndefined(value)) {
+ if (element.multiple && nodeName_(element) === 'select') {
+ var result = [];
+ forEach(element.options, function(option) {
+ if (option.selected) {
+ result.push(option.value || option.text);
+ }
+ });
+ return result.length === 0 ? null : result;
+ }
+ return element.value;
+ }
+ element.value = value;
+ },
+
+ html: function(element, value) {
+ if (isUndefined(value)) {
+ return element.innerHTML;
+ }
+ jqLiteDealoc(element, true);
+ element.innerHTML = value;
+ },
+
+ empty: jqLiteEmpty
+}, function(fn, name) {
+ /**
+ * Properties: writes return selection, reads return first value
+ */
+ JQLite.prototype[name] = function(arg1, arg2) {
+ var i, key;
+ var nodeCount = this.length;
+
+ // jqLiteHasClass has only two arguments, but is a getter-only fn, so we need to special-case it
+ // in a way that survives minification.
+ // jqLiteEmpty takes no arguments but is a setter.
+ if (fn !== jqLiteEmpty &&
+ (((fn.length == 2 && (fn !== jqLiteHasClass && fn !== jqLiteController)) ? arg1 : arg2) === undefined)) {
+ if (isObject(arg1)) {
+
+ // we are a write, but the object properties are the key/values
+ for (i = 0; i < nodeCount; i++) {
+ if (fn === jqLiteData) {
+ // data() takes the whole object in jQuery
+ fn(this[i], arg1);
+ } else {
+ for (key in arg1) {
+ fn(this[i], key, arg1[key]);
+ }
+ }
+ }
+ // return self for chaining
+ return this;
+ } else {
+ // we are a read, so read the first child.
+ // TODO: do we still need this?
+ var value = fn.$dv;
+ // Only if we have $dv do we iterate over all, otherwise it is just the first element.
+ var jj = (value === undefined) ? Math.min(nodeCount, 1) : nodeCount;
+ for (var j = 0; j < jj; j++) {
+ var nodeValue = fn(this[j], arg1, arg2);
+ value = value ? value + nodeValue : nodeValue;
+ }
+ return value;
+ }
+ } else {
+ // we are a write, so apply to all children
+ for (i = 0; i < nodeCount; i++) {
+ fn(this[i], arg1, arg2);
+ }
+ // return self for chaining
+ return this;
+ }
+ };
+});
+
+function createEventHandler(element, events) {
+ var eventHandler = function(event, type) {
+ // jQuery specific api
+ event.isDefaultPrevented = function() {
+ return event.defaultPrevented;
+ };
+
+ var eventFns = events[type || event.type];
+ var eventFnsLength = eventFns ? eventFns.length : 0;
+
+ if (!eventFnsLength) return;
+
+ if (isUndefined(event.immediatePropagationStopped)) {
+ var originalStopImmediatePropagation = event.stopImmediatePropagation;
+ event.stopImmediatePropagation = function() {
+ event.immediatePropagationStopped = true;
+
+ if (event.stopPropagation) {
+ event.stopPropagation();
+ }
+
+ if (originalStopImmediatePropagation) {
+ originalStopImmediatePropagation.call(event);
+ }
+ };
+ }
+
+ event.isImmediatePropagationStopped = function() {
+ return event.immediatePropagationStopped === true;
+ };
+
+ // Copy event handlers in case event handlers array is modified during execution.
+ if ((eventFnsLength > 1)) {
+ eventFns = shallowCopy(eventFns);
+ }
+
+ for (var i = 0; i < eventFnsLength; i++) {
+ if (!event.isImmediatePropagationStopped()) {
+ eventFns[i].call(element, event);
+ }
+ }
+ };
+
+ // TODO: this is a hack for angularMocks/clearDataCache that makes it possible to deregister all
+ // events on `element`
+ eventHandler.elem = element;
+ return eventHandler;
+}
+
+//////////////////////////////////////////
+// Functions iterating traversal.
+// These functions chain results into a single
+// selector.
+//////////////////////////////////////////
+forEach({
+ removeData: jqLiteRemoveData,
+
+ on: function jqLiteOn(element, type, fn, unsupported) {
+ if (isDefined(unsupported)) throw jqLiteMinErr('onargs', 'jqLite#on() does not support the `selector` or `eventData` parameters');
+
+ // Do not add event handlers to non-elements because they will not be cleaned up.
+ if (!jqLiteAcceptsData(element)) {
+ return;
+ }
+
+ var expandoStore = jqLiteExpandoStore(element, true);
+ var events = expandoStore.events;
+ var handle = expandoStore.handle;
+
+ if (!handle) {
+ handle = expandoStore.handle = createEventHandler(element, events);
+ }
+
+ // http://jsperf.com/string-indexof-vs-split
+ var types = type.indexOf(' ') >= 0 ? type.split(' ') : [type];
+ var i = types.length;
+
+ while (i--) {
+ type = types[i];
+ var eventFns = events[type];
+
+ if (!eventFns) {
+ events[type] = [];
+
+ if (type === 'mouseenter' || type === 'mouseleave') {
+ // Refer to jQuery's implementation of mouseenter & mouseleave
+ // Read about mouseenter and mouseleave:
+ // http://www.quirksmode.org/js/events_mouse.html#link8
+
+ jqLiteOn(element, MOUSE_EVENT_MAP[type], function(event) {
+ var target = this, related = event.relatedTarget;
+ // For mousenter/leave call the handler if related is outside the target.
+ // NB: No relatedTarget if the mouse left/entered the browser window
+ if (!related || (related !== target && !target.contains(related))) {
+ handle(event, type);
+ }
+ });
+
+ } else {
+ if (type !== '$destroy') {
+ addEventListenerFn(element, type, handle);
+ }
+ }
+ eventFns = events[type];
+ }
+ eventFns.push(fn);
+ }
+ },
+
+ off: jqLiteOff,
+
+ one: function(element, type, fn) {
+ element = jqLite(element);
+
+ //add the listener twice so that when it is called
+ //you can remove the original function and still be
+ //able to call element.off(ev, fn) normally
+ element.on(type, function onFn() {
+ element.off(type, fn);
+ element.off(type, onFn);
+ });
+ element.on(type, fn);
+ },
+
+ replaceWith: function(element, replaceNode) {
+ var index, parent = element.parentNode;
+ jqLiteDealoc(element);
+ forEach(new JQLite(replaceNode), function(node) {
+ if (index) {
+ parent.insertBefore(node, index.nextSibling);
+ } else {
+ parent.replaceChild(node, element);
+ }
+ index = node;
+ });
+ },
+
+ children: function(element) {
+ var children = [];
+ forEach(element.childNodes, function(element) {
+ if (element.nodeType === NODE_TYPE_ELEMENT) {
+ children.push(element);
+ }
+ });
+ return children;
+ },
+
+ contents: function(element) {
+ return element.contentDocument || element.childNodes || [];
+ },
+
+ append: function(element, node) {
+ var nodeType = element.nodeType;
+ if (nodeType !== NODE_TYPE_ELEMENT && nodeType !== NODE_TYPE_DOCUMENT_FRAGMENT) return;
+
+ node = new JQLite(node);
+
+ for (var i = 0, ii = node.length; i < ii; i++) {
+ var child = node[i];
+ element.appendChild(child);
+ }
+ },
+
+ prepend: function(element, node) {
+ if (element.nodeType === NODE_TYPE_ELEMENT) {
+ var index = element.firstChild;
+ forEach(new JQLite(node), function(child) {
+ element.insertBefore(child, index);
+ });
+ }
+ },
+
+ wrap: function(element, wrapNode) {
+ wrapNode = jqLite(wrapNode).eq(0).clone()[0];
+ var parent = element.parentNode;
+ if (parent) {
+ parent.replaceChild(wrapNode, element);
+ }
+ wrapNode.appendChild(element);
+ },
+
+ remove: jqLiteRemove,
+
+ detach: function(element) {
+ jqLiteRemove(element, true);
+ },
+
+ after: function(element, newElement) {
+ var index = element, parent = element.parentNode;
+ newElement = new JQLite(newElement);
+
+ for (var i = 0, ii = newElement.length; i < ii; i++) {
+ var node = newElement[i];
+ parent.insertBefore(node, index.nextSibling);
+ index = node;
+ }
+ },
+
+ addClass: jqLiteAddClass,
+ removeClass: jqLiteRemoveClass,
+
+ toggleClass: function(element, selector, condition) {
+ if (selector) {
+ forEach(selector.split(' '), function(className) {
+ var classCondition = condition;
+ if (isUndefined(classCondition)) {
+ classCondition = !jqLiteHasClass(element, className);
+ }
+ (classCondition ? jqLiteAddClass : jqLiteRemoveClass)(element, className);
+ });
+ }
+ },
+
+ parent: function(element) {
+ var parent = element.parentNode;
+ return parent && parent.nodeType !== NODE_TYPE_DOCUMENT_FRAGMENT ? parent : null;
+ },
+
+ next: function(element) {
+ return element.nextElementSibling;
+ },
+
+ find: function(element, selector) {
+ if (element.getElementsByTagName) {
+ return element.getElementsByTagName(selector);
+ } else {
+ return [];
+ }
+ },
+
+ clone: jqLiteClone,
+
+ triggerHandler: function(element, event, extraParameters) {
+
+ var dummyEvent, eventFnsCopy, handlerArgs;
+ var eventName = event.type || event;
+ var expandoStore = jqLiteExpandoStore(element);
+ var events = expandoStore && expandoStore.events;
+ var eventFns = events && events[eventName];
+
+ if (eventFns) {
+ // Create a dummy event to pass to the handlers
+ dummyEvent = {
+ preventDefault: function() { this.defaultPrevented = true; },
+ isDefaultPrevented: function() { return this.defaultPrevented === true; },
+ stopImmediatePropagation: function() { this.immediatePropagationStopped = true; },
+ isImmediatePropagationStopped: function() { return this.immediatePropagationStopped === true; },
+ stopPropagation: noop,
+ type: eventName,
+ target: element
+ };
+
+ // If a custom event was provided then extend our dummy event with it
+ if (event.type) {
+ dummyEvent = extend(dummyEvent, event);
+ }
+
+ // Copy event handlers in case event handlers array is modified during execution.
+ eventFnsCopy = shallowCopy(eventFns);
+ handlerArgs = extraParameters ? [dummyEvent].concat(extraParameters) : [dummyEvent];
+
+ forEach(eventFnsCopy, function(fn) {
+ if (!dummyEvent.isImmediatePropagationStopped()) {
+ fn.apply(element, handlerArgs);
+ }
+ });
+ }
+ }
+}, function(fn, name) {
+ /**
+ * chaining functions
+ */
+ JQLite.prototype[name] = function(arg1, arg2, arg3) {
+ var value;
+
+ for (var i = 0, ii = this.length; i < ii; i++) {
+ if (isUndefined(value)) {
+ value = fn(this[i], arg1, arg2, arg3);
+ if (isDefined(value)) {
+ // any function which returns a value needs to be wrapped
+ value = jqLite(value);
+ }
+ } else {
+ jqLiteAddNodes(value, fn(this[i], arg1, arg2, arg3));
+ }
+ }
+ return isDefined(value) ? value : this;
+ };
+
+ // bind legacy bind/unbind to on/off
+ JQLite.prototype.bind = JQLite.prototype.on;
+ JQLite.prototype.unbind = JQLite.prototype.off;
+});
+
+
+// Provider for private $$jqLite service
+function $$jqLiteProvider() {
+ this.$get = function $$jqLite() {
+ return extend(JQLite, {
+ hasClass: function(node, classes) {
+ if (node.attr) node = node[0];
+ return jqLiteHasClass(node, classes);
+ },
+ addClass: function(node, classes) {
+ if (node.attr) node = node[0];
+ return jqLiteAddClass(node, classes);
+ },
+ removeClass: function(node, classes) {
+ if (node.attr) node = node[0];
+ return jqLiteRemoveClass(node, classes);
+ }
+ });
+ };
+}
+
+/**
+ * Computes a hash of an 'obj'.
+ * Hash of a:
+ * string is string
+ * number is number as string
+ * object is either result of calling $$hashKey function on the object or uniquely generated id,
+ * that is also assigned to the $$hashKey property of the object.
+ *
+ * @param obj
+ * @returns {string} hash string such that the same input will have the same hash string.
+ * The resulting string key is in 'type:hashKey' format.
+ */
+function hashKey(obj, nextUidFn) {
+ var key = obj && obj.$$hashKey;
+
+ if (key) {
+ if (typeof key === 'function') {
+ key = obj.$$hashKey();
+ }
+ return key;
+ }
+
+ var objType = typeof obj;
+ if (objType == 'function' || (objType == 'object' && obj !== null)) {
+ key = obj.$$hashKey = objType + ':' + (nextUidFn || nextUid)();
+ } else {
+ key = objType + ':' + obj;
+ }
+
+ return key;
+}
+
+/**
+ * HashMap which can use objects as keys
+ */
+function HashMap(array, isolatedUid) {
+ if (isolatedUid) {
+ var uid = 0;
+ this.nextUid = function() {
+ return ++uid;
+ };
+ }
+ forEach(array, this.put, this);
+}
+HashMap.prototype = {
+ /**
+ * Store key value pair
+ * @param key key to store can be any type
+ * @param value value to store can be any type
+ */
+ put: function(key, value) {
+ this[hashKey(key, this.nextUid)] = value;
+ },
+
+ /**
+ * @param key
+ * @returns {Object} the value for the key
+ */
+ get: function(key) {
+ return this[hashKey(key, this.nextUid)];
+ },
+
+ /**
+ * Remove the key/value pair
+ * @param key
+ */
+ remove: function(key) {
+ var value = this[key = hashKey(key, this.nextUid)];
+ delete this[key];
+ return value;
+ }
+};
+
+var $$HashMapProvider = [function() {
+ this.$get = [function() {
+ return HashMap;
+ }];
+}];
+
+/**
+ * @ngdoc function
+ * @module ng
+ * @name angular.injector
+ * @kind function
+ *
+ * @description
+ * Creates an injector object that can be used for retrieving services as well as for
+ * dependency injection (see {@link guide/di dependency injection}).
+ *
+ * @param {Array.', '
+ * Use this method to disable automatic scrolling.
+ *
+ * If automatic scrolling is disabled, one must explicitly call
+ * {@link ng.$anchorScroll $anchorScroll()} in order to scroll to the element related to the
+ * current hash.
+ */
+ this.disableAutoScrolling = function() {
+ autoScrollingEnabled = false;
+ };
+
+ /**
+ * @ngdoc service
+ * @name $anchorScroll
+ * @kind function
+ * @requires $window
+ * @requires $location
+ * @requires $rootScope
+ *
+ * @description
+ * When called, it scrolls to the element related to the specified `hash` or (if omitted) to the
+ * current value of {@link ng.$location#hash $location.hash()}, according to the rules specified
+ * in the
+ * [HTML5 spec](http://dev.w3.org/html5/spec/Overview.html#the-indicated-part-of-the-document).
+ *
+ * It also watches the {@link ng.$location#hash $location.hash()} and automatically scrolls to
+ * match any anchor whenever it changes. This can be disabled by calling
+ * {@link ng.$anchorScrollProvider#disableAutoScrolling $anchorScrollProvider.disableAutoScrolling()}.
+ *
+ * Additionally, you can use its {@link ng.$anchorScroll#yOffset yOffset} property to specify a
+ * vertical scroll-offset (either fixed or dynamic).
+ *
+ * @param {string=} hash The hash specifying the element to scroll to. If omitted, the value of
+ * {@link ng.$location#hash $location.hash()} will be used.
+ *
+ * @property {(number|function|jqLite)} yOffset
+ * If set, specifies a vertical scroll-offset. This is often useful when there are fixed
+ * positioned elements at the top of the page, such as navbars, headers etc.
+ *
+ * `yOffset` can be specified in various ways:
+ * - **number**: A fixed number of pixels to be used as offset.
+ * - **function**: A getter function called everytime `$anchorScroll()` is executed. Must return
+ * a number representing the offset (in pixels).
+ * - **jqLite**: A jqLite/jQuery element to be used for specifying the offset. The distance from
+ * the top of the page to the element's bottom will be used as offset.
+ * **Note**: The element will be taken into account only as long as its `position` is set to
+ * `fixed`. This option is useful, when dealing with responsive navbars/headers that adjust
+ * their height and/or positioning according to the viewport's size.
+ *
+ *
+ *
+ * The example below illustrates the use of a vertical scroll-offset (specified as a fixed value).
+ * See {@link ng.$anchorScroll#yOffset $anchorScroll.yOffset} for more details.
+ *
+ * @example
+
+ *
+ */
+ info: function() {
+ return extend({}, stats, {size: size});
+ }
+ };
+
+
+ /**
+ * makes the `entry` the freshEnd of the LRU linked list
+ */
+ function refresh(entry) {
+ if (entry != freshEnd) {
+ if (!staleEnd) {
+ staleEnd = entry;
+ } else if (staleEnd == entry) {
+ staleEnd = entry.n;
+ }
+
+ link(entry.n, entry.p);
+ link(entry, freshEnd);
+ freshEnd = entry;
+ freshEnd.n = null;
+ }
+ }
+
+
+ /**
+ * bidirectionally links two entries of the LRU linked list
+ */
+ function link(nextEntry, prevEntry) {
+ if (nextEntry != prevEntry) {
+ if (nextEntry) nextEntry.p = prevEntry; //p stands for previous, 'prev' didn't minify
+ if (prevEntry) prevEntry.n = nextEntry; //n stands for next, 'next' didn't minify
+ }
+ }
+ }
+
+
+ /**
+ * @ngdoc method
+ * @name $cacheFactory#info
+ *
+ * @description
+ * Get information about all the caches that have been created
+ *
+ * @returns {Object} - key-value map of `cacheId` to the result of calling `cache#info`
+ */
+ cacheFactory.info = function() {
+ var info = {};
+ forEach(caches, function(cache, cacheId) {
+ info[cacheId] = cache.info();
+ });
+ return info;
+ };
+
+
+ /**
+ * @ngdoc method
+ * @name $cacheFactory#get
+ *
+ * @description
+ * Get access to a cache object by the `cacheId` used when it was created.
+ *
+ * @param {string} cacheId Name or id of a cache to access.
+ * @returns {object} Cache object identified by the cacheId or undefined if no such cache.
+ */
+ cacheFactory.get = function(cacheId) {
+ return caches[cacheId];
+ };
+
+
+ return cacheFactory;
+ };
+}
+
+/**
+ * @ngdoc service
+ * @name $templateCache
+ *
+ * @description
+ * The first time a template is used, it is loaded in the template cache for quick retrieval. You
+ * can load templates directly into the cache in a `script` tag, or by consuming the
+ * `$templateCache` service directly.
+ *
+ * Adding via the `script` tag:
+ *
+ * ```html
+ *
+ * ```
+ *
+ * **Note:** the `script` tag containing the template does not need to be included in the `head` of
+ * the document, but it must be a descendent of the {@link ng.$rootElement $rootElement} (IE,
+ * element with ng-app attribute), otherwise the template will be ignored.
+ *
+ * Adding via the `$templateCache` service:
+ *
+ * ```js
+ * var myApp = angular.module('myApp', []);
+ * myApp.run(function($templateCache) {
+ * $templateCache.put('templateId.html', 'This is the content of the template');
+ * });
+ * ```
+ *
+ * To retrieve the template later, simply use it in your HTML:
+ * ```html
+ *
+ * ```
+ *
+ * or get it via Javascript:
+ * ```js
+ * $templateCache.get('templateId.html')
+ * ```
+ *
+ * See {@link ng.$cacheFactory $cacheFactory}.
+ *
+ */
+function $TemplateCacheProvider() {
+ this.$get = ['$cacheFactory', function($cacheFactory) {
+ return $cacheFactory('templates');
+ }];
+}
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Any commits to this file should be reviewed with security in mind. *
+ * Changes to this file can potentially create security vulnerabilities. *
+ * An approval from 2 Core members with history of modifying *
+ * this file is required. *
+ * *
+ * Does the change somehow allow for arbitrary javascript to be executed? *
+ * Or allows for someone to change the prototype of built-in objects? *
+ * Or gives undesired access to variables likes document or window? *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/* ! VARIABLE/FUNCTION NAMING CONVENTIONS THAT APPLY TO THIS FILE!
+ *
+ * DOM-related variables:
+ *
+ * - "node" - DOM Node
+ * - "element" - DOM Element or Node
+ * - "$node" or "$element" - jqLite-wrapped node or element
+ *
+ *
+ * Compiler related stuff:
+ *
+ * - "linkFn" - linking fn of a single directive
+ * - "nodeLinkFn" - function that aggregates all linking fns for a particular node
+ * - "childLinkFn" - function that aggregates all linking fns for child nodes of a particular node
+ * - "compositeLinkFn" - function that aggregates all linking fns for a compilation root (nodeList)
+ */
+
+
+/**
+ * @ngdoc service
+ * @name $compile
+ * @kind function
+ *
+ * @description
+ * Compiles an HTML string or DOM into a template and produces a template function, which
+ * can then be used to link {@link ng.$rootScope.Scope `scope`} and the template together.
+ *
+ * The compilation is a process of walking the DOM tree and matching DOM elements to
+ * {@link ng.$compileProvider#directive directives}.
+ *
+ *