pyc-website
main website for pyc inc.
git clone https://9o.is/git/pyc-website.git
commit 3863887c8670275bb86d5bec3dab59f773f895ef parent 5ec5fdbf2ba07b810fcd6837d2d1ae2247af9cbd Author: Jul <jul@9o.is> Date: Sat, 5 Apr 2014 02:17:19 -0400 implemented Ng UI-Router and Ng Google Maps Diffstat:
28 files changed, 3532 insertions(+), 362 deletions(-)
diff --git a/build.config.js b/build.config.js @@ -58,6 +58,9 @@ module.exports = { js: [ "<%= dirs.vendor %>/angular1.3.0-beta.3.min.js", "<%= dirs.vendor %>/ui-bootstrap-custom-tpls-0.11.0-SNAPSHOT.js", + "<%= dirs.vendor %>/ui-router.js", + "<%= dirs.vendor %>/underscore.min.js", + "<%= dirs.vendor %>/angular-google-maps.min.js", "<%= dirs.vendor %>/ui-mask.js", "<%= dirs.vendor %>/liftAjax.js" ], diff --git a/src/main/scala/bootstrap/liftweb/Boot.scala b/src/main/scala/bootstrap/liftweb/Boot.scala @@ -53,6 +53,8 @@ class Boot extends Loggable { // Build SiteMap LiftRules.setSiteMap(Site.siteMap) + + Site.init() // Error handler ErrorHandler.init diff --git a/src/main/scala/com/pyd/config/Site.scala b/src/main/scala/com/pyd/config/Site.scala @@ -1,10 +1,12 @@ package com.pyd package config +import lib.NgUIRouterFactory import model.User + import net.liftweb._ import common._ -import http.{S, OkResponse, RedirectResponse} +import http.{S, OkResponse, RedirectResponse, RequestVar} import sitemap._ import sitemap.Loc._ import net.liftmodules.mongoauth.Locs @@ -26,11 +28,11 @@ object Site extends Locs { import MenuGroups._ // locations (for top group) - val home = MenuLoc(Menu.i("Home") / "index" >> EarlyResponse(() => Full(RedirectResponse(applyATM.url)))) - val applyATM = MenuLoc(Menu.i("Apply for Bitcoin ATM") / "apply-atm" >> TopBarGroup) + val home = MenuLoc(Menu.i("Home") / "index") + val applyATM = MenuLoc(Menu.i("Apply for Bitcoin ATM") / "apply-atm" >> TopBarGroup) val locations = MenuLoc(Menu.i("Locations") / "locations" >> TopBarGroup) val about = MenuLoc(Menu.i("About Us") / "about" >> TopBarGroup) - //val blog = MenuLoc(Menu.i("Blog") / "blog" >> TopBarGroup >> EarlyResponse(() => Full(RedirectResponse("http://blog."+S.hostName)))) + val blog = MenuLoc(Menu.i("Blog") / "blog" >> TopBarGroup >> RedirectBlog) val faqs = MenuLoc(Menu.i("FAQs") / "faqs" >> TopBarGroup) val loginToken = MenuLoc(buildLoginTokenMenu) @@ -51,8 +53,7 @@ object Site extends Locs { applyATM.menu, locations.menu, about.menu, - // blog under construction - //blog.menu, + blog.menu, faqs.menu, //Menu.i("Login") / "login" >> RequireNotLoggedIn, //register.menu, @@ -72,4 +73,17 @@ object Site extends Locs { * Return a SiteMap needed for Lift */ def siteMap: SiteMap = SiteMap(menus:_*) + + def init(): Unit = { + val routes = + applyATM.menu :: + locations.menu :: + about.menu :: + faqs.menu :: Nil + + NgUIRouterFactory.routes.default.set(routes) + NgUIRouterFactory.defaultRoute.default.set(Full(applyATM.menu)) + } + + private def RedirectBlog = EarlyResponse(() => Full(RedirectResponse("http://blog."+S.hostName))) } diff --git a/src/main/scala/com/pyd/lib/NgUIRouter.scala b/src/main/scala/com/pyd/lib/NgUIRouter.scala @@ -0,0 +1,148 @@ +package com.pyd +package lib + +import scala.xml._ +import net.liftweb._ +import sitemap._ +import common._ +import http._ +import util._ +import Helpers._ +import net.liftmodules.extras.SnippetHelper + +/** + * Configure these settings during boot. + */ +object NgUIRouterFactory extends Factory { + + /** + * Default route when page lands on index. + */ + val defaultRoute = new FactoryMaker[Box[Menu]](Empty) {} + + /** + * List of all the routes. + */ + val routes = new FactoryMaker[List[Menu]](Nil) {} +} + +trait NgUIRouterSnip extends SnippetHelper { + + /** + * Snippet to configures AngularJs module with all routes. + * + * Required attributes: + * - ngApp: Name of AngularJs module. + */ + def js: CssSel = + for{ + app <- S.attr("ngApp") ?~ "ngApp name is missing" + } yield "* *" #> { + import NgUIRouterFactory._ + + val otherwise = defaultRoute.vend map { + "$urlRouterProvider.otherwise('"+ + S.contextPath+_.loc.calcDefaultHref+"');" + } openOr "" + + app+".config(function($stateProvider, $urlRouterProvider) {"+ + otherwise+"$stateProvider"+ + routes.vend.map { menu => + val url: String = S.contextPath+menu.loc.calcDefaultHref + val state: String = url.replace('/', '.').tail + + ".state('"+state+"',{url:'"+url+"',views:"+ + "{'viewA':{templateUrl:'"+url+".html?ajax'}}})" + }.mkString+ + ";});" + } + + + /** + * Conditional Template Surround Snippet. Allows pages to be surrounded by a + * different template if it's accessed with ajax. + * + * Needed attributes are: + * - with: template name to surround page. + * - at: id of element in template to place the page. + * - withAjax: template name to surround page when accessed with ajax. + * + * When accessing with ajax, assure URL query parameter 'ajax' exists. + * + * NOTE: default.html in templates-hidden cannot exist + * (else Lift will auto-surround everything with default) + */ + def surround(ns: NodeSeq): NodeSeq = + for { + surroundWith <- S.attr("with") ?~ "Surround with not specified" + surroundWithAjax <- S.attr("withAjax") ?~ "Surround with ajax not specified" + at <- S.attr("at") ?~ "Surround at not specified" + } yield { + if(S.param("ajax").isDefined) + Templates("templates-hidden" :: surroundWithAjax :: Nil) map { + s"#$at" #> ns + } openOr Text("Template '"+surroundWithAjax+"' not found") + else + Templates("templates-hidden" :: surroundWith :: Nil) map { + s"#$at" #> ns + } openOr Text("Template '"+surroundWith+"' not found") + } +} + +/** + * Menu Group snippet. List of links grouped with LocGroup will + * have ui-sref attribute. If link points to /some/foo/bar, + * then ui-router state or ui-sref value will be some.foo.bar. + * + * Example snippet: data-lift="NgUIRouterMenu.group?group=topbar" + */ +trait NgUIRouterMenu extends SnippetHelper { + + private def buildUIRouterLink(name: String): NodeSeq = { + val options = for { + loc <- SiteMap.findAndTestLoc(name).toList + link <- loc.createDefaultLink + } yield { + val linkText = loc.linkText openOr Text(loc.name) + <a href={link} ui-sref={link.toString.replace('/', '.').tail}>{linkText}</a> + } + options.headOption getOrElse NodeSeq.Empty + } + + /** + * Produces a menu UL from a group, for use with Bootstrap. + */ + def group = { + val menus: NodeSeq = + for { + group <- S.attr("group") ?~ "Group not specified" + sitemap <- LiftRules.siteMap ?~ "Sitemap is empty" + request <- S.request ?~ "Request is empty" + curLoc <- request.location ?~ "Current location is empty" + } yield ({ + val currentClass = S.attr("current_class").openOr("active") + sitemap.locForGroup(group) flatMap { loc => + val nonHiddenKids = loc.menu.kids.filterNot(_.loc.hidden) + val styles = + if (curLoc.name == loc.name || loc.menu.kids.exists(_.loc.name == curLoc.name)) currentClass + else "" + + if (nonHiddenKids.length == 0) { + <li class={styles}>{buildUIRouterLink(loc.name)}</li> + } + else { + val dropdown: NodeSeq = nonHiddenKids.map { kid => + <li>{buildUIRouterLink(kid.loc.name)}</li> + } + + <li class={styles + " dropdown"}> + <a href="#" class="dropdown-toggle" data-toggle="dropdown">{loc.linkText.openOr(Text("Empty Name"))} <b class="caret"></b></a> + <ul class="dropdown-menu">{ dropdown }</ul> + </li> + } + } + }): NodeSeq + + "* *" #> menus + } +} +\ No newline at end of file diff --git a/src/main/scala/com/pyd/snippet/Alert.scala b/src/main/scala/com/pyd/snippet/Alert.scala @@ -1,35 +0,0 @@ -package com.pyd -package snippet - -import xml._ -import net.liftweb._ -import util._ -import common._ -import json.JsonAST._ - -object Alert extends Logger { - - private def msgBox(msgType: String, msg: NodeSeq): JValue = - JObject(List( - JField("msg_type", JString(msgType)), - JField("msg", JString(msg.toString)))) - - def success(msg: NodeSeq): JValue = msgBox("success", msg) - def success(msg: String): JValue = success(Text(msg)) - - def danger(msg: NodeSeq, errors: List[FieldError]): JValue = { - debug(errors) - - msgBox("danger", msg ++ - errors.foldLeft(<ul></ul>)((el,err) => el.copy(child = el.child :+ <li>{err.msg}</li>))) - } - - def danger(msg: String, errors: List[FieldError] = Nil): JValue = danger(Text(msg), errors) - - def info(msg: NodeSeq): JValue = msgBox("info", msg) - def info(msg: String): JValue = info(Text(msg)) - - def warning(msg: NodeSeq): JValue = msgBox("warning", msg) - def warning(msg: String): JValue = warning(Text(msg)) - -} -\ No newline at end of file diff --git a/src/main/scala/com/pyd/snippet/AtmApplicationSnip.scala b/src/main/scala/com/pyd/snippet/AtmApplicationSnip.scala @@ -23,13 +23,13 @@ class AtmApplicationSnip { rec.validate match { case Nil => rec.save - Alert.success( + NgAlert.success( <i class="fa-fw fa fa-thumbs-o-up"></i> ++ <strong>{ s"Your Bitcoin ATM application for ${rec.name.get} has been received." }</strong> ++ <span>{s" We will contact you when we are ready. Thank you for applying."}</span> ) case errors => - Alert.danger( + NgAlert.danger( <i class="fa-fw fa fa-thumbs-o-down"></i> ++ <strong>{ s"Your application could not be processed." }</strong>, errors diff --git a/src/main/scala/com/pyd/snippet/NearAtmNotifySnip.scala b/src/main/scala/com/pyd/snippet/NearAtmNotifySnip.scala @@ -23,7 +23,7 @@ class NearAtmNotifySnip { rec.validate match { case Nil => rec.save - Alert.success( + NgAlert.success( <div> <i class="fa-fw fa fa-thumbs-o-up"></i> <strong>{ s"Hi ${rec.fname.get}, your notification has been received." }</strong> @@ -31,7 +31,7 @@ class NearAtmNotifySnip { </div> ) case errors => - Alert.danger( + NgAlert.danger( <div> <i class="fa-fw fa fa-thumbs-o-down"></i> <strong>{ s"Hi ${rec.fname.get}, your notification was not submitted successfully." }</strong> diff --git a/src/main/scala/com/pyd/snippet/NgAlert.scala b/src/main/scala/com/pyd/snippet/NgAlert.scala @@ -0,0 +1,35 @@ +package com.pyd +package snippet + +import xml._ +import net.liftweb._ +import util._ +import common._ +import json.JsonAST._ + +object NgAlert extends Logger { + + private def msgBox(msgType: String, msg: NodeSeq): JValue = + JObject(List( + JField("msg_type", JString(msgType)), + JField("msg", JString(msg.toString)))) + + def success(msg: NodeSeq): JValue = msgBox("success", msg) + def success(msg: String): JValue = success(Text(msg)) + + def danger(msg: NodeSeq, errors: List[FieldError]): JValue = { + debug(errors) + + msgBox("danger", msg ++ + errors.foldLeft(<ul></ul>)((el,err) => el.copy(child = el.child :+ <li>{err.msg}</li>))) + } + + def danger(msg: String, errors: List[FieldError] = Nil): JValue = danger(Text(msg), errors) + + def info(msg: NodeSeq): JValue = msgBox("info", msg) + def info(msg: String): JValue = info(Text(msg)) + + def warning(msg: NodeSeq): JValue = msgBox("warning", msg) + def warning(msg: String): JValue = warning(Text(msg)) + +} +\ No newline at end of file diff --git a/src/main/scala/com/pyd/snippet/UtilSnips.scala b/src/main/scala/com/pyd/snippet/UtilSnips.scala @@ -5,10 +5,12 @@ import scala.xml.NodeSeq import net.liftweb._ import common._ import util._ +import Helpers._ import http._ import js._ import net.liftmodules.extras._ import snippet._ +import com.pyd.lib.{NgUIRouterMenu, NgUIRouterSnip} /* * Base all LiftScreens off this. Currently configured to use bootstrap 3. @@ -17,27 +19,11 @@ abstract class BaseScreen extends Bootstrap3Screen { override def defaultToAjax_? = true } -abstract class BaseSnippet[T] extends SnippetHelper { - val t: Box[T] - - protected def serve(snip: T => CssSel): CssSel = - (for { - t <- t ?~ "Data is empty" - } yield { - snip(t) - }): CssSel - - protected def serve(snip: T => JsCmd): JsCmd = - (for { - t <- t ?~ "Data is empty" - } yield { - snip(t) - }): JsCmd -} - object Assets extends AssetLoader -object Menus extends BsMenu +object NgUIRouter extends NgUIRouterSnip + +object Menus extends NgUIRouterMenu object ProductionOnly { def render(in: NodeSeq): NodeSeq = diff --git a/src/main/webapp/404.html b/src/main/webapp/404.html @@ -1,3 +1,3 @@ -<div data-lift="surround?with=default;at=content"> +<div data-lift="surround?with=base-default;at=content"> <p style="font-size: 1.2em;">We're sorry but the page you are trying to access does not exist.</p> </div> diff --git a/src/main/webapp/about.html b/src/main/webapp/about.html @@ -1,4 +1,4 @@ -<div data-lift="surround?with=default;at=content"> +<div data-lift="NgUIRouter.surround?withAjax=no-base-default&with=base-default&at=content"> <div class="row margin-top-10"> <div class="col-xs-12 multi-column"> diff --git a/src/main/webapp/app/App.js b/src/main/webapp/app/App.js @@ -1,8 +1,8 @@ -var app = angular.module("app", ['ui.bootstrap', 'ui.mask']); +var app = angular.module("app", ['ui.bootstrap', 'ui.router', 'google-maps', 'ui.mask']); var ZIP_CODE_REGEXP = /^(\d{5}(-\d{4})?|[A-Z]\d[A-Z] *\d[A-Z]\d)$/; var UNSAFE_URL_REGEXP = /[-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?/; - + app.directive('disabler', function($compile) { return { link: function(scope, elm, attrs) { @@ -75,4 +75,25 @@ app.controller('NearAtmNotifyCtrl', ['$scope', '$controller', '$rootScope', func app.controller('AtmApplicationCtrl', ['$scope', '$controller', '$rootScope', function($scope, $controller, $rootScope) { $controller('FormCtrl', {$scope: $scope, $rootScope: $rootScope}); $scope.url_regex = UNSAFE_URL_REGEXP; +}]); + +app.controller('GMapCtrl', ['$scope', function($scope) { + $scope.lat = 40.778202; + $scope.long = -74.122381; + $scope.zoom = 12; + + $scope.map = { + center: { + latitude: $scope.lat, + longitude: $scope.long + }, + zoom: $scope.zoom + }; + + $scope.formWindow = { + coord: { + latitude: $scope.lat - 0.038228, + longitude: $scope.long + 0.106745 + } + }; }]); \ No newline at end of file diff --git a/src/main/webapp/apply-atm.html b/src/main/webapp/apply-atm.html @@ -1,4 +1,4 @@ -<div data-lift="surround?with=with-footer;at=content"> +<div data-lift="NgUIRouter.surround?withAjax=no-base&with=base-wrap&at=content"> <div id="content-index" class="row no-gutter"> @@ -110,7 +110,7 @@ </div> </div> - <div id="atm-bitcoin-video" class="row"> + <div id="atm-bitcoin-video" class="row" ng-cloak> <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"> <div class="page-content"> <h1>What is Bitcoin?</h1> diff --git a/src/main/webapp/error.html b/src/main/webapp/error.html @@ -1,4 +1,4 @@ -<div data-lift="surround?with=default;at=content"> +<div data-lift="surround?with=base-default;at=content"> <p style="font-size: 1.2em;">We're sorry but an error has occurred. Our staff has been notified and is working on a solution.</p> </div> diff --git a/src/main/webapp/faqs.html b/src/main/webapp/faqs.html @@ -1,5 +1,4 @@ - -<div data-lift="surround?with=default;at=content"> +<div data-lift="NgUIRouter.surround?withAjax=no-base-default&with=base-default&at=content"> <div id="faqs" class="row"> <div class="col-xs-12 col-sm-8"> diff --git a/src/main/webapp/index.html b/src/main/webapp/index.html @@ -1,260 +1,6 @@ -<div data-lift="surround?with=base-wrap;at=content"> +<div data-lift="surround?with=with-footer;at=content"> <lift:head> - <title data-lift="Menu.title">PYD: The Easiest Way to Bitcoins</title> + <title data-lift="Menu.title">PYD: The Easiest Way to Bitcoin</title> </lift:head> - <div class="main-content"> - <div data-lift="Notices"></div> - - <div class="row"> - <div class="hidden-xs hidden-sm col-md-5 col-lg-4"></div> - <div id="big-tabs-outer" - class="col-xs-12 col-sm-12 col-md-7 col-lg-8 jarviswidget well"> - <ul id="big-tabs" class="nav nav-tabs bordered nav-justified"> - <li class="active"><a href="#find-atms" data-toggle="tab">Buy Bitcoin</a></li> - <li><a href="#sell-bitcoin" data-toggle="tab">Sell Bitcoin</a></li> - <li><a href="#merchant-deals" data-toggle="tab">Merchants</a></li> - - </ul> - </div> - </div> - - <div class="row"> - - <div id="big-pane-outer" - class="col-xs-12 col-sm-12 col-md-12 col-lg-12 no-padding"> - <div class="tab-content"> - - <div id="sell-bitcoin" class="tab-pane fade in"> - - </div> - - <div id="merchant-deals" class="tab-pane fade in"> - <div class="row"> - <div class="left-content col-xs-12 col-sm-12 col-md-6 col-lg-6"> - <h1>Bitcoin to Cash</h1> - <p> - <span class="fa-stack fa-lg"> <i - class="fa fa-circle fa-stack-2x"></i> <i - class="fa fa-btc fa-stack-1x fa-inverse"></i> - </span> <span class="fa-stack fa-lg"> <i - class="fa fa-circle fa-stack-2x"></i> <i - class="fa fa-btc fa-stack-1x fa-inverse"></i> - </span> <span class="fa-stack fa-lg"> <i - class="fa fa-circle fa-stack-2x"></i> <i - class="fa fa-btc fa-stack-1x fa-inverse"></i> - </span> <span class="fa-stack fa-lg"> <i - class="fa fa-circle fa-stack-2x"></i> <i - class="fa fa-btc fa-stack-1x fa-inverse"></i> - </span> <span class="fa-stack fa-lg"> <i - class="fa fa-circle fa-stack-2x"></i> <i - class="fa fa-btc fa-stack-1x fa-inverse"></i> - </span> <span class="fa-stack fa-lg"> <i - class="fa fa-circle fa-stack-2x"></i> <i - class="fa fa-btc fa-stack-1x fa-inverse"></i> - </span> <span class="fa-stack fa-lg"> <i - class="fa fa-circle fa-stack-2x"></i> <i - class="fa fa-btc fa-stack-1x fa-inverse"></i> - </span> <span class="fa-stack fa-lg"> <i - class="fa fa-circle fa-stack-2x"></i> <i - class="fa fa-btc fa-stack-1x fa-inverse"></i> - </span> <a href="/" class="btn btn-primary btn-xs">Host an ATM Now!</a> - </p> - <p class="message">Recieve up to $10,000 cash back on your - first $1,000,000 in sales when accepting Bitcoin at your business</p> - </div> - - <div id="merchant-signup" - class="right-content col-xs-12 col-sm-12 col-md-5 col-lg-4 col-lg-offset-1"> - <div class="no-padding"> - <form class="smart-form form-inline colored-form " role="form"> - <fieldset> - <section> - <label class="label">What is your E-mail address?</label> <label - class="input"> <i class="icon-append fa fa-envelope-o"></i> - <input type="email" name="email" placeholder="you@exeample.com"> - <b class="tooltip tooltip-top-right"><i - class="fa fa-user txt-color-blue"></i> Please enter email - address</b></label> - </section> - </fieldset> - <footer> - <a type="submit" class="btn btn-warning"> <i - class="fa fa-lock fa-fw"></i> Host a Bitcoin ATM - </a> - </footer> - </form> - - </div> - </div> - - <!-- <div - class="right-content col-xs-12 col-sm-12 col-md-5 col-lg-4 col-lg-offset-2"> - Bitcoin Vending Machine picture goes here</div> --> - </div> - </div> - - <div id="find-atms" class="tab-pane fade in active nj-map-pic"> - <div class="layer"></div> - - <div id="find-atms-coming-soon" - class="col-xs-12 col-sm-12 col-md-6 col-lg-5"> - <h1>Cash to Bitcoin</h1> - <p class="message">Fill the form on the right side to get - notified when an ATM comes to your home town.</p> - </div> - - <div id="notify-form-outer" - class="col-xs-12 col-sm-12 col-md-5 col-lg-4 col-lg-offset-2 content-right"> - - <form action="" id="notify-form" class="smart-form client-form"> - <header>Notify me when there is a nearby ATM</header> - <fieldset> - <div class="row"> - <section class="col col-6"> - <label class="input"> <i - class="icon-prepend fa fa-user"></i> <input name="fname" - placeholder="First name" type="text"> - </label> - </section> - <section class="col col-6"> - <label class="input"> <i - class="icon-prepend fa fa-user"></i> <input name="lname" - placeholder="Last name" type="text"> - </label> - </section> - </div> - - <div class="row"> - <section class="col col-6"> - <label class="input"> <i - class="icon-prepend fa fa-envelope-o"></i> <input - name="email" placeholder="E-mail" type="email"> - </label> - </section> - - <section class="col col-6"> - <label class="input"> <input name="code" - placeholder="Post code" type="text"> - </label> - </section> - </div> - <div class="row"> - <section class="col col-6"> - <label class="input"> <input name="city" - placeholder="City" type="text"> - </label> - </section> - <section class="col col-3"> - <label class="select"> <select name="state"> - <option value="0" selected="" disabled="ST"></option> - <option value="1">AL</option> - <option value="2">AK</option> - <option value="3">AZ</option> - <option value="4">AR</option> - <option value="5">CA</option> - <option value="6">CO</option> - <option value="7">CT</option> - <option value="8">DE</option> - <option value="9">FL</option> - <option value="10">GA</option> - <option value="11">HI</option> - <option value="12">ID</option> - <option value="13">IL</option> - <option value="14">IN</option> - <option value="15">IA</option> - <option value="16">KS</option> - <option value="17">KY</option> - <option value="18">LA</option> - <option value="19">ME</option> - <option value="20">MD</option> - <option value="21">MA</option> - <option value="22">MI</option> - <option value="23">MN</option> - <option value="24">MS</option> - <option value="25">MO</option> - <option value="26">MT</option> - <option value="27">NE</option> - <option value="28">NV</option> - <option value="29">NH</option> - <option value="30">NJ</option> - <option value="31">NM</option> - <option value="32">NY</option> - <option value="33">NC</option> - <option value="34">ND</option> - <option value="35">OH</option> - <option value="36">OK</option> - <option value="37">OR</option> - <option value="38">PA</option> - <option value="39">RI</option> - <option value="40">SC</option> - <option value="41">SD</option> - <option value="42">TN</option> - <option value="43">TX</option> - <option value="44">UT</option> - <option value="45">VT</option> - <option value="46">VA</option> - <option value="47">WA</option> - <option value="48">WV</option> - <option value="49">WI</option> - <option value="50">WY</option> - </select> - </label> - </section> - - - </div> - </fieldset> - - <footer> - <button type="submit" class="btn btn-primary">Notify - Me</button> - </footer> - </form> - </div> - </div> - </div> - </div> - <!-- end of big-pane-outer --> - </div> - <!-- end of row --> - - - <div class="row"> - <div class="sales-box col-xs-12 col-sm-4 col-md-4 col-lg-4"> - <h2>Secure, Reliable, Easy</h2> - <p>Bitcoins are kept offline and fully encrypted to keep - everyone safe.</p> - <p> - <a class="btn btn-default" href="#" role="button">View details - »</a> - </p> - </div> - <div class="sales-box col-xs-12 col-sm-4 col-md-4 col-lg-4"> - <h2>Merchant Deals</h2> - <p>1% cash back, zero fraud and chargebacks. Business the way it's meant to be.</p> - <p> - <a class="btn btn-default" href="#" role="button">View details - »</a> - </p> - </div> - <div class="sales-box col-xs-12 col-sm-4 col-md-4 col-lg-4"> - <h2>Low Fees</h2> - <p>Only 5% interest rate when buying Bitcoins from an ATM.</p> - <p> - <a class="btn btn-default" href="#" role="button">View details - »</a> - </p> - </div> - </div> - - <hr> - - </div> - - <div class="row"> - <div class="col-xs-12"> - <span data-lift="embed?what=/templates-hidden/parts/footer"></span> - </div> - </div> - + <div ui-view="viewA"></div> </div> diff --git a/src/main/webapp/less/pages/locations.less b/src/main/webapp/less/pages/locations.less @@ -1,7 +1,9 @@ #atm-locations { + position: relative; + // WARNING: Width is fixed because of layer-outer, but map-canvas can be 100% width // layer-outer is temporary :) - #map-canvas, .layer-overlay, layer-info { + .angular-google-map-container, .layer-overlay, layer-info { pointer-events: none; @media (max-width: @screen-lg) { @@ -11,12 +13,12 @@ @media (max-width: @screen-md-max) { width: 936px; - height: 500px; + height: 400px; } @media (max-width: @screen-sm-max) { width: 716px; - height: 600px; + height: 650px; } @media (max-width: @screen-xs-max) { @@ -50,6 +52,10 @@ @title-font-size: 50px; @message-font-size: 20px; + @media (max-width: @screen-sm-max) { + .text-center(); + } + h1 { @media (max-width: @screen-xs) { font-size: @title-font-size * 0.75; diff --git a/src/main/webapp/locations.html b/src/main/webapp/locations.html @@ -1,9 +1,9 @@ -<div data-lift="surround?with=base-wrap;at=content"> +<div data-lift="NgUIRouter.surround?withAjax=no-base&with=base-wrap&at=content"> <div id="atm-locations"> <div class="layer-info"> <div class="row margin-top-10"> - <div class="col-sm-10 col-md-6 col-lg-6"> + <div class="col-xs-12 col-md-6 col-lg-6"> <div id="coming-soon-msg"> <h1 class="text-white">ATMs Coming Soon</h1> <p class="message text-white"> @@ -11,10 +11,8 @@ </p> </div> </div> - <div class="col-xs-11 col-sm-10 col-md-4 col-lg-5"> - <div class="margin-left-10"> - <span data-lift="embed?what=/templates-hidden/parts/notify-atm-form"></span> - </div> + <div class="col-xs-10 col-md-5 col-lg-4 col-xs-offset-1 col-md-offset-0 col-lg-offset-1"> + <span data-lift="embed?what=/templates-hidden/parts/notify-atm-form"></span> </div> </div> </div> @@ -23,24 +21,9 @@ <div class="layer"></div> </div> - <div id="map-canvas"></div> + <div ng-controller="GMapCtrl"> + <google-map center="map.center" zoom="map.zoom" draggable="false" options="{disableDefaultUI:true}"></google-map> + </div> </div> - - - <script data-lift="tail" type="text/javascript" - src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAehyKUHOOWL_plRJCW8R1EdCIKCfR9jkg&sensor=true"> - </script> - <script data-lift="tail" type="text/javascript"> - function initialize() { - var mapOptions = { - zoom: 12, - center: new google.maps.LatLng(40.778202,-74.122381), - disableDefaultUI: true - } - var map = new google.maps.Map(document.getElementById("map-canvas"), - mapOptions); - } - google.maps.event.addDomListener(window, 'load', initialize); - </script> </div> \ No newline at end of file diff --git a/src/main/webapp/login.html b/src/main/webapp/login.html @@ -1,4 +1,4 @@ -<div data-lift="surround?with=default;at=content"> +<div data-lift="surround?with=base-default;at=content"> <div data-lift="Notices"></div> <div class="row"> <form data-lift="Form.ajax?class=form-horizontal"> diff --git a/src/main/webapp/register.html b/src/main/webapp/register.html @@ -1,4 +1,4 @@ -<div data-lift="surround?with=default;at=content"> +<div data-lift="surround?with=base-default;at=content"> <div data-lift="Notices"></div> <div data-lift="RegisterScreen"></div> </div> diff --git a/src/main/webapp/templates-hidden/default.html b/src/main/webapp/templates-hidden/base-default.html diff --git a/src/main/webapp/templates-hidden/base-wrap.html b/src/main/webapp/templates-hidden/base-wrap.html @@ -6,6 +6,7 @@ <meta name="description" content=""> <meta name="author" content="PYD"> <meta name="Copyright" content="Copyright PYD Inc 2014. All Rights Reserved."> +<meta name="fragment" content="!" /> <link data-lift="Assets.css" rel="stylesheet"> @@ -54,7 +55,9 @@ <div id="content"></div> </div> -<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script> +<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.0.min.js"></script> +<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAehyKUHOOWL_plRJCW8R1EdCIKCfR9jkg&sensor=true"></script> <script data-lift="Assets.js"></script> +<script data-lift="NgUIRouter.js?ngApp=app"></script> </body> </html> diff --git a/src/main/webapp/templates-hidden/no-base-default.html b/src/main/webapp/templates-hidden/no-base-default.html @@ -0,0 +1,17 @@ +<div data-lift="surround?with=no-base;at=content"> + <div class="row"> + <div class="col-xs-10 col-xs-offset-1"> + <div class="main-content"> + <div class="page-header"> + <h1> + <span data-lift="Menu.title"></span> + <div style="display:none; float:right;" id="ajax-spinner"> + <i class="fa fa-spinner fa-spin"></i> + </div> + </h1> + </div> + <div id="content"></div> + </div> + </div> + </div> +</div> +\ No newline at end of file diff --git a/src/main/webapp/templates-hidden/no-base.html b/src/main/webapp/templates-hidden/no-base.html @@ -0,0 +1 @@ +<div id="content"></div> +\ No newline at end of file diff --git a/src/main/webapp/templates-hidden/parts/notify-atm-form.html b/src/main/webapp/templates-hidden/parts/notify-atm-form.html @@ -1,4 +1,4 @@ -<div data-lift="NearAtmNotifySnip" ng-controller="NearAtmNotifyCtrl" ng-cloak> +<div data-lift="NearAtmNotifySnip" ng-controller="NearAtmNotifyCtrl"> <form name="form" class="smart-form client-form" ng-submit="save()" novalidate> <header>Notify me when there is a nearby ATM</header> <fieldset> diff --git a/src/main/webapp/vendor/angular-google-maps.min.js b/src/main/webapp/vendor/angular-google-maps.min.js @@ -0,0 +1,7 @@ +/*! angular-google-maps 1.0.18 2014-04-02 + * AngularJS directives for Google Maps + * git: https://github.com/nlaplante/angular-google-maps.git + */ +function InfoBox(a){a=a||{},google.maps.OverlayView.apply(this,arguments),this.content_=a.content||"",this.disableAutoPan_=a.disableAutoPan||!1,this.maxWidth_=a.maxWidth||0,this.pixelOffset_=a.pixelOffset||new google.maps.Size(0,0),this.position_=a.position||new google.maps.LatLng(0,0),this.zIndex_=a.zIndex||null,this.boxClass_=a.boxClass||"infoBox",this.boxStyle_=a.boxStyle||{},this.closeBoxMargin_=a.closeBoxMargin||"2px",this.closeBoxURL_=a.closeBoxURL||"http://www.google.com/intl/en_us/mapfiles/close.gif",""===a.closeBoxURL&&(this.closeBoxURL_=""),this.infoBoxClearance_=a.infoBoxClearance||new google.maps.Size(1,1),"undefined"==typeof a.visible&&(a.visible="undefined"==typeof a.isHidden?!0:!a.isHidden),this.isHidden_=!a.visible,this.alignBottom_=a.alignBottom||!1,this.pane_=a.pane||"floatPane",this.enableEventPropagation_=a.enableEventPropagation||!1,this.div_=null,this.closeListener_=null,this.moveListener_=null,this.contextListener_=null,this.eventListeners_=null,this.fixedWidthSet_=null}function ClusterIcon(a,b){a.getMarkerClusterer().extend(ClusterIcon,google.maps.OverlayView),this.cluster_=a,this.className_=a.getMarkerClusterer().getClusterClass(),this.styles_=b,this.center_=null,this.div_=null,this.sums_=null,this.visible_=!1,this.setMap(a.getMap())}function Cluster(a){this.markerClusterer_=a,this.map_=a.getMap(),this.gridSize_=a.getGridSize(),this.minClusterSize_=a.getMinimumClusterSize(),this.averageCenter_=a.getAverageCenter(),this.markers_=[],this.center_=null,this.bounds_=null,this.clusterIcon_=new ClusterIcon(this,a.getStyles())}function MarkerClusterer(a,b,c){this.extend(MarkerClusterer,google.maps.OverlayView),b=b||[],c=c||{},this.markers_=[],this.clusters_=[],this.listeners_=[],this.activeMap_=null,this.ready_=!1,this.gridSize_=c.gridSize||60,this.minClusterSize_=c.minimumClusterSize||2,this.maxZoom_=c.maxZoom||null,this.styles_=c.styles||[],this.title_=c.title||"",this.zoomOnClick_=!0,void 0!==c.zoomOnClick&&(this.zoomOnClick_=c.zoomOnClick),this.averageCenter_=!1,void 0!==c.averageCenter&&(this.averageCenter_=c.averageCenter),this.ignoreHidden_=!1,void 0!==c.ignoreHidden&&(this.ignoreHidden_=c.ignoreHidden),this.enableRetinaIcons_=!1,void 0!==c.enableRetinaIcons&&(this.enableRetinaIcons_=c.enableRetinaIcons),this.imagePath_=c.imagePath||MarkerClusterer.IMAGE_PATH,this.imageExtension_=c.imageExtension||MarkerClusterer.IMAGE_EXTENSION,this.imageSizes_=c.imageSizes||MarkerClusterer.IMAGE_SIZES,this.calculator_=c.calculator||MarkerClusterer.CALCULATOR,this.batchSize_=c.batchSize||MarkerClusterer.BATCH_SIZE,this.batchSizeIE_=c.batchSizeIE||MarkerClusterer.BATCH_SIZE_IE,this.clusterClass_=c.clusterClass||"cluster",-1!==navigator.userAgent.toLowerCase().indexOf("msie")&&(this.batchSize_=this.batchSizeIE_),this.setupStyles_(),this.addMarkers(b,!0),this.setMap(a)}function inherits(a,b){function c(){}c.prototype=b.prototype,a.superClass_=b.prototype,a.prototype=new c,a.prototype.constructor=a}function MarkerLabel_(a,b){this.marker_=a,this.handCursorURL_=a.handCursorURL,this.labelDiv_=document.createElement("div"),this.labelDiv_.style.cssText="position: absolute; overflow: hidden;",this.eventDiv_=document.createElement("div"),this.eventDiv_.style.cssText=this.labelDiv_.style.cssText,this.eventDiv_.setAttribute("onselectstart","return false;"),this.eventDiv_.setAttribute("ondragstart","return false;"),this.crossDiv_=MarkerLabel_.getSharedCross(b)}function MarkerWithLabel(a){a=a||{},a.labelContent=a.labelContent||"",a.labelAnchor=a.labelAnchor||new google.maps.Point(0,0),a.labelClass=a.labelClass||"markerLabels",a.labelStyle=a.labelStyle||{},a.labelInBackground=a.labelInBackground||!1,"undefined"==typeof a.labelVisible&&(a.labelVisible=!0),"undefined"==typeof a.raiseOnDrag&&(a.raiseOnDrag=!0),"undefined"==typeof a.clickable&&(a.clickable=!0),"undefined"==typeof a.draggable&&(a.draggable=!1),"undefined"==typeof a.optimized&&(a.optimized=!1),a.crossImage=a.crossImage||"http"+("https:"===document.location.protocol?"s":"")+"://maps.gstatic.com/intl/en_us/mapfiles/drag_cross_67_16.png",a.handCursor=a.handCursor||"http"+("https:"===document.location.protocol?"s":"")+"://maps.gstatic.com/intl/en_us/mapfiles/closedhand_8_8.cur",a.optimized=!1,this.label=new MarkerLabel_(this,a.crossImage,a.handCursor),google.maps.Marker.apply(this,arguments)}(function(){angular.element(document).ready(function(){return(google||("undefined"!=typeof google&&null!==google?google.maps:void 0)||null!=google.maps.InfoWindow)&&(google.maps.InfoWindow.prototype._open=google.maps.InfoWindow.prototype.open,google.maps.InfoWindow.prototype._close=google.maps.InfoWindow.prototype.close,google.maps.InfoWindow.prototype._isOpen=!1,google.maps.InfoWindow.prototype.open=function(a,b){this._isOpen=!0,this._open(a,b)},google.maps.InfoWindow.prototype.close=function(){this._isOpen=!1,this._close()},google.maps.InfoWindow.prototype.isOpen=function(a){return null==a&&(a=void 0),null==a?this._isOpen:this._isOpen=a},window.InfoBox)?(window.InfoBox.prototype._open=window.InfoBox.prototype.open,window.InfoBox.prototype._close=window.InfoBox.prototype.close,window.InfoBox.prototype._isOpen=!1,window.InfoBox.prototype.open=function(a,b){this._isOpen=!0,this._open(a,b)},window.InfoBox.prototype.close=function(){this._isOpen=!1,this._close()},window.InfoBox.prototype.isOpen=function(a){return null==a&&(a=void 0),null==a?this._isOpen:this._isOpen=a}):void 0})}).call(this),function(){_.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})}}.call(this),function(){!function(){var a;return a=angular.module("google-maps",[]),a.factory("debounce",["$timeout",function(a){return function(b){var c;return c=0,function(){var d,e,f;return f=this,d=arguments,c++,e=function(a){return function(){return a===c?b.apply(f,d):void 0}}(c),a(e,0,!0)}}}])}()}.call(this),function(){this.ngGmapModule=function(a,b){var c,d;return null==b&&(b=function(){}),"string"==typeof a&&(a=a.split(".")),c=this[d=a.shift()]||(this[d]={}),c.ngGmapModule||(c.ngGmapModule=this.ngGmapModule),a.length?c.ngGmapModule(a,b):b.call(c)}}.call(this),function(){angular.module("google-maps").factory("array-sync",["add-events",function(a){var b;return b=function(b,c,d){var e,f,g,h;return e=!1,g=c.$eval(d),f=a(b,{set_at:function(a){var c;if(!e&&(c=b.getAt(a),c&&c.lng&&c.lat))return g[a].latitude=c.lat(),g[a].longitude=c.lng()},insert_at:function(a){var c;if(!e&&(c=b.getAt(a),c&&c.lng&&c.lat))return g.splice(a,0,{latitude:c.lat(),longitude:c.lng()})},remove_at:function(a){return e?void 0:g.splice(a,1)}}),h=c.$watchCollection(d,function(a){var c,d,f,g,h,i,j;if(e=!0,h=b,a){for(c=0,i=h.getLength(),f=a.length,d=Math.min(i,f),g=void 0;d>c;)j=h.getAt(c),g=a[c],(j.lat()!==g.latitude||j.lng()!==g.longitude)&&h.setAt(c,new google.maps.LatLng(g.latitude,g.longitude)),c++;for(;f>c;)g=a[c],h.push(new google.maps.LatLng(g.latitude,g.longitude)),c++;for(;i>c;)h.pop(),c++}return e=!1}),function(){return f&&(f(),f=null),h?(h(),h=null):void 0}}}])}.call(this),function(){angular.module("google-maps").factory("add-events",["$timeout",function(a){var b,c;return b=function(b,c,d){return google.maps.event.addListener(b,c,function(){return d.apply(this,arguments),a(function(){},!0)})},c=function(a,c,d){var e;return d?b(a,c,d):(e=[],angular.forEach(c,function(c,d){return e.push(b(a,d,c))}),function(){return angular.forEach(e,function(a){return _.isFunction(a)&&a(),null!==a.e&&_.isFunction(a.e)?a.e():void 0}),e=null})}}])}.call(this),function(){var a=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};this.ngGmapModule("oo",function(){var b;return b=["extended","included"],this.BaseObject=function(){function c(){}return c.extend=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this[d]=e);return null!=(f=c.extended)&&f.apply(0),this},c.include=function(c){var d,e,f;for(d in c)e=c[d],a.call(b,d)<0&&(this.prototype[d]=e);return null!=(f=c.included)&&f.apply(0),this},c}()})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api.managers",function(){return this.ClustererMarkerManager=function(b){function d(b,c,e){this.clear=a(this.clear,this),this.draw=a(this.draw,this),this.removeMany=a(this.removeMany,this),this.remove=a(this.remove,this),this.addMany=a(this.addMany,this),this.add=a(this.add,this);var f;d.__super__.constructor.call(this),f=this,this.opt_options=e,this.clusterer=null!=e&&void 0===c?new MarkerClusterer(b,void 0,e):null!=e&&null!=c?new MarkerClusterer(b,c,e):new MarkerClusterer(b),this.clusterer.setIgnoreHidden(!0),this.$log=directives.api.utils.Logger,this.noDrawOnSingleAddRemoves=!0,this.$log.info(this)}return c(d,b),d.prototype.add=function(a){return this.clusterer.addMarker(a,this.noDrawOnSingleAddRemoves)},d.prototype.addMany=function(a){return this.clusterer.addMarkers(a)},d.prototype.remove=function(a){return this.clusterer.removeMarker(a,this.noDrawOnSingleAddRemoves)},d.prototype.removeMany=function(a){return this.clusterer.addMarkers(a)},d.prototype.draw=function(){return this.clusterer.repaint()},d.prototype.clear=function(){return this.clusterer.clearMarkers(),this.clusterer.repaint()},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api.managers",function(){return this.MarkerManager=function(b){function d(b){this.handleOptDraw=a(this.handleOptDraw,this),this.clear=a(this.clear,this),this.draw=a(this.draw,this),this.removeMany=a(this.removeMany,this),this.remove=a(this.remove,this),this.addMany=a(this.addMany,this),this.add=a(this.add,this);var c;d.__super__.constructor.call(this),c=this,this.gMap=b,this.gMarkers=[],this.$log=directives.api.utils.Logger,this.$log.info(this)}return c(d,b),d.prototype.add=function(a,b){return this.handleOptDraw(a,b,!0),this.gMarkers.push(a)},d.prototype.addMany=function(a){var b,c,d,e;for(e=[],c=0,d=a.length;d>c;c++)b=a[c],e.push(this.add(b));return e},d.prototype.remove=function(a,b){var c,d;return this.handleOptDraw(a,b,!1),b?(c=void 0,null!=this.gMarkers.indexOf?c=this.gMarkers.indexOf(a):(d=0,_.find(this.gMarkers,function(b){d+=1,b===a&&(c=d)})),null!=c?this.gMarkers.splice(c,1):void 0):void 0},d.prototype.removeMany=function(){var a,b,c,d,e;for(d=this.gMarkers,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(this.remove(a));return e},d.prototype.draw=function(){var a,b,c,d,e,f,g,h,i,j=this;for(a=[],h=this.gMarkers,c=function(b){return b.isDrawn?void 0:b.doAdd?b.setMap(j.gMap):a.push(b)},d=0,f=h.length;f>d;d++)b=h[d],c(b);for(i=[],e=0,g=a.length;g>e;e++)b=a[e],i.push(this.remove(b,!0));return i},d.prototype.clear=function(){var a,b,c,d;for(d=this.gMarkers,b=0,c=d.length;c>b;b++)a=d[b],a.setMap(null);return delete this.gMarkers,this.gMarkers=[]},d.prototype.handleOptDraw=function(a,b,c){return b===!0?(a.setMap(c?this.gMap:null),a.isDrawn=!0):(a.isDrawn=!1,a.doAdd=c)},d}(oo.BaseObject)})}.call(this),function(){this.ngGmapModule("directives.api.utils",function(){return this.AsyncProcessor={handleLargeArray:function(a,b,c,d,e,f){var g;return null==e&&(e=100),null==f&&(f=0),void 0===a||a.length<=0?void d():(g=function(){var h,i;for(h=e,i=f;h--&&i<a.length;)b(a[i]),++i;return i<a.length?(f=i,null!=c&&c(),setTimeout(g,1)):d()})()}}})}.call(this),function(){this.ngGmapModule("directives.api.utils",function(){return this.ChildEvents={onChildCreation:function(){}}})}.call(this),function(){this.ngGmapModule("directives.api.utils",function(){return this.GmapUtil={getLabelPositionPoint:function(a){var b,c;return void 0===a?void 0:(a=/^([\d\.]+)\s([\d\.]+)$/.exec(a),b=a[1],c=a[2],b&&c?new google.maps.Point(b,c):void 0)},createMarkerOptions:function(a,b,c,d){var e;return null==d&&(d=void 0),null==c&&(c={}),e=angular.extend({},c,{position:null!=c.position?c.position:new google.maps.LatLng(a.latitude,a.longitude),icon:null!=c.icon?c.icon:b,visible:null!=c.visible?c.visible:null!=a.latitude&&null!=a.longitude}),null!=d&&(e.map=d),e},createWindowOptions:function(a,b,c,d){return null!=c&&null!=d?angular.extend({},d,{content:null!=d.content?d.content:c,position:null!=d.position?d.position:angular.isObject(a)?a.getPosition():new google.maps.LatLng(b.coords.latitude,b.coords.longitude)}):d?d:void 0},defaultDelay:50}})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.ngGmapModule("directives.api.utils",function(){return this.Linked=function(a){function c(a,b,c,d){this.scope=a,this.element=b,this.attrs=c,this.ctrls=d}return b(c,a),c}(oo.BaseObject)})}.call(this),function(){this.ngGmapModule("directives.api.utils",function(){var a;return this.Logger={logger:void 0,doLog:!1,info:function(b){return a.doLog?null!=a.logger?a.logger.info(b):console.info(b):void 0},error:function(b){return a.doLog?null!=a.logger?a.logger.error(b):console.error(b):void 0}},a=this.Logger})}.call(this),function(){this.ngGmapModule("directives.api.utils",function(){return this.ModelsWatcher={didModelsChange:function(a,b){var c,d;return _.isArray(a)?a===b?!1:(d=_.intersectionObjects(a,b).length!==b.length,c=!0,d||(c=a.length!==b.length),c):(directives.api.utils.Logger.error("models property must be an array newValue of: "+a.toString()+" is not!!"),!1)}}})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api.models.child",function(){return this.MarkerLabelChildModel=function(b){function d(b,c){this.destroy=a(this.destroy,this),this.draw=a(this.draw,this),this.setPosition=a(this.setPosition,this),this.setZIndex=a(this.setZIndex,this),this.setVisible=a(this.setVisible,this),this.setAnchor=a(this.setAnchor,this),this.setMandatoryStyles=a(this.setMandatoryStyles,this),this.setStyles=a(this.setStyles,this),this.setContent=a(this.setContent,this),this.setTitle=a(this.setTitle,this),this.getSharedCross=a(this.getSharedCross,this);var e,f,g;d.__super__.constructor.call(this),e=this,this.marker=b,this.marker.set("labelContent",c.labelContent),this.marker.set("labelAnchor",this.getLabelPositionPoint(c.labelAnchor)),this.marker.set("labelClass",c.labelClass||"labels"),this.marker.set("labelStyle",c.labelStyle||{opacity:100}),this.marker.set("labelInBackground",c.labelInBackground||!1),c.labelVisible||this.marker.set("labelVisible",!0),c.raiseOnDrag||this.marker.set("raiseOnDrag",!0),c.clickable||this.marker.set("clickable",!0),c.draggable||this.marker.set("draggable",!1),c.optimized||this.marker.set("optimized",!1),c.crossImage=null!=(f=c.crossImage)?f:document.location.protocol+"//maps.gstatic.com/intl/en_us/mapfiles/drag_cross_67_16.png",c.handCursor=null!=(g=c.handCursor)?g:document.location.protocol+"//maps.gstatic.com/intl/en_us/mapfiles/closedhand_8_8.cur",this.markerLabel=new MarkerLabel_(this.marker,c.crossImage,c.handCursor),this.marker.set("setMap",function(a){return google.maps.Marker.prototype.setMap.apply(this,arguments),e.markerLabel.setMap(a)}),this.marker.setMap(this.marker.getMap())}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.getSharedCross=function(a){return this.markerLabel.getSharedCross(a)},d.prototype.setTitle=function(){return this.markerLabel.setTitle()},d.prototype.setContent=function(){return this.markerLabel.setContent()},d.prototype.setStyles=function(){return this.markerLabel.setStyles()},d.prototype.setMandatoryStyles=function(){return this.markerLabel.setMandatoryStyles()},d.prototype.setAnchor=function(){return this.markerLabel.setAnchor()},d.prototype.setVisible=function(){return this.markerLabel.setVisible()},d.prototype.setZIndex=function(){return this.markerLabel.setZIndex()},d.prototype.setPosition=function(){return this.markerLabel.setPosition()},d.prototype.draw=function(){return this.markerLabel.draw()},d.prototype.destroy=function(){return null!=this.markerLabel.labelDiv_.parentNode&&null!=this.markerLabel.eventDiv_.parentNode?this.markerLabel.onRemove():void 0},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api.models.child",function(){return this.MarkerChildModel=function(b){function d(b,c,d,e,f,g,h,i,j){var k,l=this;this.index=b,this.model=c,this.parentScope=d,this.gMap=e,this.defaults=g,this.doClick=h,this.gMarkerManager=i,this.watchDestroy=a(this.watchDestroy,this),this.setLabelOptions=a(this.setLabelOptions,this),this.isLabelDefined=a(this.isLabelDefined,this),this.setOptions=a(this.setOptions,this),this.setIcon=a(this.setIcon,this),this.setCoords=a(this.setCoords,this),this.destroy=a(this.destroy,this),this.maybeSetScopeValue=a(this.maybeSetScopeValue,this),this.createMarker=a(this.createMarker,this),this.setMyScope=a(this.setMyScope,this),k=this,this.iconKey=this.parentScope.icon,this.coordsKey=this.parentScope.coords,this.clickKey=this.parentScope.click(),this.labelContentKey=this.parentScope.labelContent,this.optionsKey=this.parentScope.options,this.labelOptionsKey=this.parentScope.labelOptions,this.myScope=this.parentScope.$new(!1),this.$injector=j,this.myScope.model=this.model,this.setMyScope(this.model,void 0,!0),this.createMarker(this.model),this.myScope.$watch("model",function(a,b){return a!==b?l.setMyScope(a,b):void 0},!0),this.$log=directives.api.utils.Logger,this.$log.info(k),this.watchDestroy(this.myScope)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.setMyScope=function(a,b,c){var d=this;return null==b&&(b=void 0),null==c&&(c=!1),this.maybeSetScopeValue("icon",a,b,this.iconKey,this.evalModelHandle,c,this.setIcon),this.maybeSetScopeValue("coords",a,b,this.coordsKey,this.evalModelHandle,c,this.setCoords),this.maybeSetScopeValue("labelContent",a,b,this.labelContentKey,this.evalModelHandle,c),_.isFunction(this.clickKey)&&this.$injector?this.myScope.click=function(){return d.$injector.invoke(d.clickKey,void 0,{$markerModel:a})}:this.maybeSetScopeValue("click",a,b,this.clickKey,this.evalModelHandle,c),this.createMarker(a,b,c)},d.prototype.createMarker=function(a,b,c){var d=this;return null==b&&(b=void 0),null==c&&(c=!1),this.maybeSetScopeValue("options",a,b,this.optionsKey,function(a,b){var c;return void 0===a?void 0:(c="self"===b?a:a[b],void 0===c?c=void 0===b?d.defaults:d.myScope.options:c)},c,this.setOptions)},d.prototype.evalModelHandle=function(a,b){return void 0===a?void 0:"self"===b?a:a[b]},d.prototype.maybeSetScopeValue=function(a,b,c,d,e,f,g){var h,i;return null==g&&(g=void 0),void 0===c?(this.myScope[a]=e(b,d),void(f||null!=g&&g(this.myScope))):(i=e(c,d),h=e(b,d),h===i||this.myScope[a]===h||(this.myScope[a]=h,f)?void 0:(null!=g&&g(this.myScope),this.gMarkerManager.draw()))},d.prototype.destroy=function(){return this.myScope.$destroy()},d.prototype.setCoords=function(a){return a.$id===this.myScope.$id&&void 0!==this.gMarker?null!=a.coords?null==this.scope.coords.latitude||null==this.scope.coords.longitude?void this.$log.error("MarkerChildMarker cannot render marker as scope.coords as no position on marker: "+JSON.stringify(this.model)):(this.gMarker.setPosition(new google.maps.LatLng(a.coords.latitude,a.coords.longitude)),this.gMarker.setVisible(null!=a.coords.latitude&&null!=a.coords.longitude),this.gMarkerManager.remove(this.gMarker),this.gMarkerManager.add(this.gMarker)):this.gMarkerManager.remove(this.gMarker):void 0},d.prototype.setIcon=function(a){return a.$id===this.myScope.$id&&void 0!==this.gMarker?(this.gMarkerManager.remove(this.gMarker),this.gMarker.setIcon(a.icon),this.gMarkerManager.add(this.gMarker),this.gMarker.setPosition(new google.maps.LatLng(a.coords.latitude,a.coords.longitude)),this.gMarker.setVisible(a.coords.latitude&&null!=a.coords.longitude)):void 0},d.prototype.setOptions=function(a){var b,c=this;if(a.$id===this.myScope.$id&&(null!=this.gMarker&&(this.gMarkerManager.remove(this.gMarker),delete this.gMarker),null!=(b=a.coords)?b:"function"==typeof a.icon?a.icon(null!=a.options):void 0))return this.opts=this.createMarkerOptions(a.coords,a.icon,a.options),delete this.gMarker,this.gMarker=this.isLabelDefined(a)?new MarkerWithLabel(this.setLabelOptions(this.opts,a)):new google.maps.Marker(this.opts),this.gMarkerManager.add(this.gMarker),google.maps.event.addListener(this.gMarker,"click",function(){return c.doClick&&null!=c.myScope.click?c.myScope.click():void 0})},d.prototype.isLabelDefined=function(a){return null!=a.labelContent},d.prototype.setLabelOptions=function(a,b){return a.labelAnchor=this.getLabelPositionPoint(b.labelAnchor),a.labelClass=b.labelClass,a.labelContent=b.labelContent,a},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){var a;return null!=b.gMarker&&(b.gMarkerManager.remove(b.gMarker),delete b.gMarker),a=void 0})},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api.models.child",function(){return this.WindowChildModel=function(b){function d(b,c,d,e,f,g,h,i,j,k){this.element=j,null==k&&(k=!1),this.destroy=a(this.destroy,this),this.hideWindow=a(this.hideWindow,this),this.getLatestPosition=a(this.getLatestPosition,this),this.showWindow=a(this.showWindow,this),this.handleClick=a(this.handleClick,this),this.watchCoords=a(this.watchCoords,this),this.watchShow=a(this.watchShow,this),this.createGWin=a(this.createGWin,this),this.scope=b,this.googleMapsHandles=[],this.opts=c,this.mapCtrl=e,this.markerCtrl=f,this.isIconVisibleOnClick=d,this.initialMarkerVisibility=null!=this.markerCtrl?this.markerCtrl.getVisible():!1,this.$log=directives.api.utils.Logger,this.$http=g,this.$templateCache=h,this.$compile=i,this.createGWin(),null!=this.markerCtrl&&this.markerCtrl.setClickable(!0),this.handleClick(),this.watchShow(),this.watchCoords(),this.needToManualDestroy=k,this.$log.info(this)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.createGWin=function(){var a,b,c=this;return null==this.gWin&&null!=this.markerCtrl&&(a=null!=this.opts?this.opts:{},b=null!=this.element&&_.isFunction(this.element.html)?this.element.html():this.element,this.opts=null!=this.markerCtrl?this.createWindowOptions(this.markerCtrl,this.scope,b,a):{}),null!=this.opts&&void 0===this.gWin?(this.gWin=this.opts.boxClass&&window.InfoBox&&"function"==typeof window.InfoBox?new window.InfoBox(this.opts):new google.maps.InfoWindow(this.opts),this.googleMapsHandles.push(google.maps.event.addListener(this.gWin,"closeclick",function(){return null!=c.markerCtrl&&c.markerCtrl.setVisible(c.initialMarkerVisibility),c.gWin.isOpen(!1),null!=c.scope.closeClick?c.scope.closeClick():void 0}))):void 0},d.prototype.watchShow=function(){var a=this;return this.scope.$watch("show",function(b){return b?a.showWindow():a.hideWindow()})},d.prototype.watchCoords=function(){var a,b=this;return a=null!=this.markerCtrl?this.scope.$parent:this.scope,a.$watch("coords",function(a,c){return a!==c?null==a?b.hideWindow():null==a.latitude||null==a.longitude?void b.$log.error("WindowChildMarker cannot render marker as scope.coords as no position on marker: "+JSON.stringify(b.model)):b.gWin.setPosition(new google.maps.LatLng(a.latitude,a.longitude)):void 0},!0)},d.prototype.handleClick=function(){var a=this;return null!=this.markerCtrl?this.googleMapsHandles.push(google.maps.event.addListener(this.markerCtrl,"click",function(){var b;return null==a.gWin&&a.createGWin(),b=a.markerCtrl.getPosition(),null!=a.gWin&&(a.gWin.setPosition(b),a.showWindow()),a.initialMarkerVisibility=a.markerCtrl.getVisible(),a.markerCtrl.setVisible(a.isIconVisibleOnClick)})):void 0},d.prototype.showWindow=function(){var a,b=this;return a=function(){return!b.gWin||!b.scope.show&&null!=b.scope.show||b.gWin.isOpen()?void 0:b.gWin.open(b.mapCtrl)},this.scope.templateUrl?this.gWin?this.$http.get(this.scope.templateUrl,{cache:this.$templateCache}).then(function(c){var d,e;return e=b.scope.$new(),angular.isDefined(b.scope.templateParameter)&&(e.parameter=b.scope.templateParameter),d=b.$compile(c.data)(e),b.gWin.setContent(d[0]),a()}):void 0:a()},d.prototype.getLatestPosition=function(){return null!=this.gWin&&null!=this.markerCtrl?this.gWin.setPosition(this.markerCtrl.getPosition()):void 0},d.prototype.hideWindow=function(){return null!=this.gWin&&this.gWin.isOpen()?this.gWin.close():void 0},d.prototype.destroy=function(){var a;return this.hideWindow(),_.each(this.googleMapsHandles,function(a){return google.maps.event.removeListener(a)}),this.googleMapsHandles.length=0,null!=this.scope&&this.needToManualDestroy&&this.scope.$destroy(),delete this.gWin,a=void 0},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api.models.parent",function(){return this.IMarkerParentModel=function(b){function d(b,c,d,e,f){var g,h=this;this.scope=b,this.element=c,this.attrs=d,this.mapCtrl=e,this.$timeout=f,this.linkInit=a(this.linkInit,this),this.onDestroy=a(this.onDestroy,this),this.onWatch=a(this.onWatch,this),this.watch=a(this.watch,this),this.validateScope=a(this.validateScope,this),this.onTimeOut=a(this.onTimeOut,this),g=this,this.$log=directives.api.utils.Logger,this.validateScope(b)&&(this.doClick=angular.isDefined(d.click),null!=b.options&&(this.DEFAULTS=b.options),this.$timeout(function(){return h.watch("coords",b),h.watch("icon",b),h.watch("options",b),h.onTimeOut(b),b.$on("$destroy",function(){return h.onDestroy(b)})}))}return c(d,b),d.prototype.DEFAULTS={},d.prototype.isFalse=function(a){return-1!==["false","FALSE",0,"n","N","no","NO"].indexOf(a)},d.prototype.onTimeOut=function(){},d.prototype.validateScope=function(a){var b;return null==a?!1:(b=null!=a.coords,b||this.$log.error(this.constructor.name+": no valid coords attribute found"),b)},d.prototype.watch=function(a,b){var c=this;return b.$watch(a,function(d,e){return d!==e?c.onWatch(a,b,d,e):void 0},!0)},d.prototype.onWatch=function(){throw new Exception("Not Implemented!!")},d.prototype.onDestroy=function(){throw new Exception("Not Implemented!!")},d.prototype.linkInit=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a={}.hasOwnProperty,b=function(b,c){function d(){this.constructor=b}for(var e in c)a.call(c,e)&&(b[e]=c[e]);return d.prototype=c.prototype,b.prototype=new d,b.__super__=c.prototype,b};this.ngGmapModule("directives.api.models.parent",function(){return this.IWindowParentModel=function(a){function c(a,b,c,d,e,f,g,h){var i;i=this,this.$log=directives.api.utils.Logger,this.$timeout=e,this.$compile=f,this.$http=g,this.$templateCache=h,null!=a.options&&(this.DEFAULTS=a.options)}return b(c,a),c.include(directives.api.utils.GmapUtil),c.prototype.DEFAULTS={},c}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api.models.parent",function(){return this.LayerParentModel=function(b){function d(b,c,d,e,f,g,h){var i=this;return this.scope=b,this.element=c,this.attrs=d,this.mapCtrl=e,this.$timeout=f,this.onLayerCreated=null!=g?g:void 0,this.$log=null!=h?h:directives.api.utils.Logger,this.createGoogleLayer=a(this.createGoogleLayer,this),null==this.attrs.type?void this.$log.info("type attribute for the layer directive is mandatory. Layer creation aborted!!"):(this.createGoogleLayer(),this.gMap=void 0,this.doShow=!0,void this.$timeout(function(){return i.gMap=e.getMap(),angular.isDefined(i.attrs.show)&&(i.doShow=i.scope.show),null!==i.doShow&&i.doShow&&null!==i.gMap&&i.layer.setMap(i.gMap),i.scope.$watch("show",function(a,b){return a!==b?(i.doShow=a,i.layer.setMap(a?i.gMap:null)):void 0},!0),i.scope.$watch("options",function(a,b){return a!==b?(i.layer.setMap(null),i.layer=null,i.createGoogleLayer()):void 0},!0),i.scope.$on("$destroy",function(){return i.layer.setMap(null)})}))}return c(d,b),d.prototype.createGoogleLayer=function(){var a=this;return this.layer=null==this.attrs.options?void 0===this.attrs.namespace?new google.maps[this.attrs.type]:new google.maps[this.attrs.namespace][this.attrs.type]:void 0===this.attrs.namespace?new google.maps[this.attrs.type](this.scope.options):new google.maps[this.attrs.namespace][this.attrs.type](this.scope.options),this.$timeout(function(){var b;return null!=a.layer&&null!=a.onLayerCreated&&(b=a.onLayerCreated(a.scope,a.layer))?b(a.layer):void 0})},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api.models.parent",function(){return this.MarkerParentModel=function(b){function d(b,c,e,f,g){this.onDestroy=a(this.onDestroy,this),this.onWatch=a(this.onWatch,this),this.onTimeOut=a(this.onTimeOut,this);var h;d.__super__.constructor.call(this,b,c,e,f,g),h=this}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.onTimeOut=function(a){var b,c=this;return b=this.createMarkerOptions(a.coords,a.icon,a.options,this.mapCtrl.getMap()),this.scope.gMarker=new google.maps.Marker(b),google.maps.event.addListener(this.scope.gMarker,"click",function(){return c.doClick&&null!=a.click?c.$timeout(function(){return c.scope.click()}):void 0}),this.setEvents(this.scope.gMarker,a),this.$log.info(this)},d.prototype.onWatch=function(a,b){switch(a){case"coords":return null!=b.coords&&null!=this.scope.gMarker?(this.scope.gMarker.setMap(this.mapCtrl.getMap()),this.scope.gMarker.setPosition(new google.maps.LatLng(b.coords.latitude,b.coords.longitude)),this.scope.gMarker.setVisible(null!=b.coords.latitude&&null!=b.coords.longitude),this.scope.gMarker.setOptions(b.options)):this.scope.gMarker.setMap(null);case"icon":if(null!=b.icon&&null!=b.coords&&null!=this.scope.gMarker)return this.scope.gMarker.setOptions(b.options),this.scope.gMarker.setIcon(b.icon),this.scope.gMarker.setMap(null),this.scope.gMarker.setMap(this.mapCtrl.getMap()),this.scope.gMarker.setPosition(new google.maps.LatLng(b.coords.latitude,b.coords.longitude)),this.scope.gMarker.setVisible(b.coords.latitude&&null!=b.coords.longitude);break;case"options":if(null!=b.coords&&null!=b.icon&&b.options)return null!=this.scope.gMarker&&this.scope.gMarker.setMap(null),delete this.scope.gMarker,this.scope.gMarker=new google.maps.Marker(this.createMarkerOptions(b.coords,b.icon,b.options,this.mapCtrl.getMap()))}},d.prototype.onDestroy=function(){var a;return void 0===this.scope.gMarker?void(a=void 0):(this.scope.gMarker.setMap(null),delete this.scope.gMarker,a=void 0) +},d.prototype.setEvents=function(a,b){return angular.isDefined(b.events)&&null!=b.events&&angular.isObject(b.events)?_.compact(_.each(b.events,function(c,d){return b.events.hasOwnProperty(d)&&angular.isFunction(b.events[d])?google.maps.event.addListener(a,d,function(){return c.apply(b,[a,d,arguments])}):void 0})):void 0},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api.models.parent",function(){return this.MarkersParentModel=function(b){function d(b,c,e,f,g,h){this.fit=a(this.fit,this),this.onDestroy=a(this.onDestroy,this),this.onWatch=a(this.onWatch,this),this.reBuildMarkers=a(this.reBuildMarkers,this),this.createMarkers=a(this.createMarkers,this),this.validateScope=a(this.validateScope,this),this.onTimeOut=a(this.onTimeOut,this);var i;d.__super__.constructor.call(this,b,c,e,f,g,h),i=this,this.markersIndex=0,this.gMarkerManager=void 0,this.scope=b,this.scope.markerModels=[],this.bigGulp=directives.api.utils.AsyncProcessor,this.$timeout=g,this.$injector=h,this.$log.info(this)}return c(d,b),d.include(directives.api.utils.ModelsWatcher),d.prototype.onTimeOut=function(a){return this.watch("models",a),this.watch("doCluster",a),this.watch("clusterOptions",a),this.watch("fit",a),this.createMarkers(a)},d.prototype.validateScope=function(a){var b;return b=angular.isUndefined(a.models)||void 0===a.models,b&&this.$log.error(this.constructor.name+": no valid models attribute found"),d.__super__.validateScope.call(this,a)||b},d.prototype.createMarkers=function(a){var b,c=this;return null!=a.doCluster&&a.doCluster===!0?null!=a.clusterOptions?void 0===this.gMarkerManager?this.gMarkerManager=new directives.api.managers.ClustererMarkerManager(this.mapCtrl.getMap(),void 0,a.clusterOptions):this.gMarkerManager.opt_options!==a.clusterOptions&&(this.gMarkerManager=new directives.api.managers.ClustererMarkerManager(this.mapCtrl.getMap(),void 0,a.clusterOptions)):this.gMarkerManager=new directives.api.managers.ClustererMarkerManager(this.mapCtrl.getMap()):this.gMarkerManager=new directives.api.managers.MarkerManager(this.mapCtrl.getMap()),b=[],a.isMarkerModelsReady=!1,this.bigGulp.handleLargeArray(a.models,function(d){var e;return a.doRebuild=!0,e=new directives.api.models.child.MarkerChildModel(c.markersIndex,d,a,c.mapCtrl,c.$timeout,c.DEFAULTS,c.doClick,c.gMarkerManager,c.$injector),c.$log.info("child",e,"markers",b),b.push(e),c.markersIndex++},function(){},function(){return c.gMarkerManager.draw(),a.markerModels=b,angular.isDefined(c.attrs.fit)&&null!=a.fit&&a.fit&&c.fit(),a.isMarkerModelsReady=!0,null!=a.onMarkerModelsReady?a.onMarkerModelsReady(a):void 0})},d.prototype.reBuildMarkers=function(a){if(a.doRebuild||void 0===a.doRebuild)return _.each(a.markerModels,function(a){return a.destroy()}),this.markersIndex=0,null!=this.gMarkerManager&&this.gMarkerManager.clear(),this.createMarkers(a)},d.prototype.onWatch=function(a,b,c,d){return"models"!==a||this.didModelsChange(c,d)?"options"===a&&null!=c?void(this.DEFAULTS=c):this.reBuildMarkers(b):void 0},d.prototype.onDestroy=function(a){var b,c,d,e;for(e=a.markerModels,c=0,d=e.length;d>c;c++)b=e[c],b.destroy();return null!=this.gMarkerManager?this.gMarkerManager.clear():void 0},d.prototype.fit=function(){var a,b;return this.mapCtrl&&null!=this.scope.markerModels&&this.scope.markerModels.length>0&&(a=new google.maps.LatLngBounds,b=!1,_.each(this.scope.markerModels,function(c){return null!=c.gMarker?(b||(b=!0),a.extend(c.gMarker.getPosition())):void 0}),b)?this.mapCtrl.getMap().fitBounds(a):void 0},d}(directives.api.models.parent.IMarkerParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api.models.parent",function(){return this.WindowsParentModel=function(b){function d(b,c,e,f,g,h,i,j,k){this.interpolateContent=a(this.interpolateContent,this),this.setChildScope=a(this.setChildScope,this),this.createWindow=a(this.createWindow,this),this.setContentKeys=a(this.setContentKeys,this),this.createChildScopesWindows=a(this.createChildScopesWindows,this),this.onMarkerModelsReady=a(this.onMarkerModelsReady,this),this.watchOurScope=a(this.watchOurScope,this),this.destroy=a(this.destroy,this),this.watchDestroy=a(this.watchDestroy,this),this.watchModels=a(this.watchModels,this),this.watch=a(this.watch,this);var l,m,n,o,p,q=this;for(d.__super__.constructor.call(this,b,c,e,f,g,h,i,j,k),m=this,this.$interpolate=k,this.windows=[],this.windwsIndex=0,this.scopePropNames=["show","coords","templateUrl","templateParameter","isIconVisibleOnClick","closeClick"],p=this.scopePropNames,n=0,o=p.length;o>n;n++)l=p[n],this[l+"Key"]=void 0;this.linked=new directives.api.utils.Linked(b,c,e,f),this.models=void 0,this.contentKeys=void 0,this.isIconVisibleOnClick=void 0,this.firstTime=!0,this.bigGulp=directives.api.utils.AsyncProcessor,this.$log.info(m),this.$timeout(function(){return q.watchOurScope(b),q.createChildScopesWindows()},50)}return c(d,b),d.include(directives.api.utils.ModelsWatcher),d.prototype.watch=function(a,b,c){var d=this;return a.$watch(b,function(a,e){return a!==e?(d[c]="function"==typeof a?a():a,_.each(d.windows,function(a){return a.scope[b]="self"===d[c]?a:a[d[c]]})):void 0},!0)},d.prototype.watchModels=function(a){var b=this;return a.$watch("models",function(a,c){return b.didModelsChange(a,c)?(b.destroy(),b.createChildScopesWindows()):void 0})},d.prototype.watchDestroy=function(a){var b=this;return a.$on("$destroy",function(){return b.destroy()})},d.prototype.destroy=function(){return _.each(this.windows,function(a){return a.destroy()}),delete this.windows,this.windows=[],this.windowsIndex=0},d.prototype.watchOurScope=function(a){var b=this;return _.each(this.scopePropNames,function(c){var d;return d=c+"Key",b[d]="function"==typeof a[c]?a[c]():a[c],b.watch(a,c,d)})},d.prototype.onMarkerModelsReady=function(a){var b=this;return this.destroy(),this.models=a.models,this.firstTime&&this.watchDestroy(a),this.setContentKeys(a.models),this.bigGulp.handleLargeArray(a.markerModels,function(a){return b.createWindow(a.model,a.gMarker,b.gMap)},function(){},function(){return b.firstTime=!1})},d.prototype.createChildScopesWindows=function(){var a,b,c=this;if(this.isIconVisibleOnClick=!0,angular.isDefined(this.linked.attrs.isiconvisibleonclick)&&(this.isIconVisibleOnClick=this.linked.scope.isIconVisibleOnClick),this.gMap=this.linked.ctrls[0].getMap(),a=this.linked.ctrls.length>1&&null!=this.linked.ctrls[1]?this.linked.ctrls[1].getMarkersScope():void 0,b=angular.isUndefined(this.linked.scope.models),b&&(void 0===a||void 0===a.markerModels&&void 0===a.models))return void this.$log.info("No models to create windows from! Need direct models or models derrived from markers!");if(null!=this.gMap){if(null!=this.linked.scope.models)return this.models=this.linked.scope.models,this.firstTime&&(this.watchModels(this.linked.scope),this.watchDestroy(this.linked.scope)),this.setContentKeys(this.linked.scope.models),this.bigGulp.handleLargeArray(this.linked.scope.models,function(a){return c.createWindow(a,void 0,c.gMap)},function(){},function(){return c.firstTime=!1});if(a.onMarkerModelsReady=this.onMarkerModelsReady,a.isMarkerModelsReady)return this.onMarkerModelsReady(a)}},d.prototype.setContentKeys=function(a){return a.length>0?this.contentKeys=Object.keys(a[0]):void 0},d.prototype.createWindow=function(a,b,c){var d,e,f,g=this;return d=this.linked.scope.$new(!1),this.setChildScope(d,a),d.$watch("model",function(a,b){return a!==b?g.setChildScope(d,a):void 0},!0),f=this.interpolateContent(this.linked.element.html(),a),e=this.createWindowOptions(b,d,f,this.DEFAULTS),this.windows.push(new directives.api.models.child.WindowChildModel(d,e,this.isIconVisibleOnClick,c,b,this.$http,this.$templateCache,this.$compile,void 0,!0))},d.prototype.setChildScope=function(a,b){var c,d,e,f,g,h=this;for(g=this.scopePropNames,d=function(c){var d,e;return d=c+"Key",e="self"===h[d]?b:b[h[d]],e!==a[c]?a[c]=e:void 0},e=0,f=g.length;f>e;e++)c=g[e],d(c);return a.model=b},d.prototype.interpolateContent=function(a,b){var c,d,e,f,g,h;if(void 0!==this.contentKeys&&0!==this.contentKeys.length){for(c=this.$interpolate(a),d={},h=this.contentKeys,f=0,g=h.length;g>f;f++)e=h[f],d[e]=b[e];return c(d)}},d}(directives.api.models.parent.IWindowParentModel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.ILabel=function(b){function d(b){this.link=a(this.link,this);var c;c=this,this.restrict="ECMA",this.replace=!0,this.template=void 0,this.require=void 0,this.transclude=!0,this.priority=-100,this.scope={labelContent:"=content",labelAnchor:"@anchor",labelClass:"@class",labelStyle:"=style"},this.$log=directives.api.utils.Logger,this.$timeout=b}return c(d,b),d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.IMarker=function(b){function d(b){this.link=a(this.link,this);var c;c=this,this.$log=directives.api.utils.Logger,this.$timeout=b,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.replace=!0,this.scope={coords:"=coords",icon:"=icon",click:"&click",options:"=options",events:"=events"}}return c(d,b),d.prototype.controller=["$scope","$element",function(){throw new Exception("Not Implemented!!")}],d.prototype.link=function(){throw new Exception("Not implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.IWindow=function(b){function d(b,c,d,e){var f;this.$timeout=b,this.$compile=c,this.$http=d,this.$templateCache=e,this.link=a(this.link,this),f=this,this.restrict="ECMA",this.template=void 0,this.transclude=!0,this.priority=-100,this.require=void 0,this.replace=!0,this.scope={coords:"=coords",show:"=show",templateUrl:"=templateurl",templateParameter:"=templateparameter",isIconVisibleOnClick:"=isiconvisibleonclick",closeClick:"&closeclick",options:"=options"},this.$log=directives.api.utils.Logger}return c(d,b),d.include(directives.api.utils.ChildEvents),d.prototype.link=function(){throw new Exception("Not Implemented!!")},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.Label=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.require="^marker",this.template='<span class="angular-google-maps-marker-label" ng-transclude></span>',this.$log.info(this)}return c(d,b),d.prototype.link=function(a,b,c,d){return this.$timeout(function(){var b,c;return c=d.getMarkerScope().gMarker,null!=c&&(b=new directives.api.models.child.MarkerLabelChildModel(c,a)),a.$on("$destroy",function(){return b.destroy()})},directives.api.utils.GmapUtil.defaultDelay+25)},d}(directives.api.ILabel)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.Layer=function(b){function d(b){this.$timeout=b,this.link=a(this.link,this),this.$log=directives.api.utils.Logger,this.restrict="ECMA",this.require="^googleMap",this.priority=-1,this.transclude=!0,this.template='<span class="angular-google-map-layer" ng-transclude></span>',this.replace=!0,this.scope={show:"=show",type:"=type",namespace:"=namespace",options:"=options",onCreated:"&oncreated"}}return c(d,b),d.prototype.link=function(a,b,c,d){return null!=c.oncreated?new directives.api.models.parent.LayerParentModel(a,b,c,d,this.$timeout,a.onCreated):new directives.api.models.parent.LayerParentModel(a,b,c,d,this.$timeout)},d}(oo.BaseObject)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.Marker=function(b){function d(b){this.link=a(this.link,this);var c;d.__super__.constructor.call(this,b),c=this,this.template='<span class="angular-google-map-marker" ng-transclude></span>',this.$log.info(this)}return c(d,b),d.prototype.controller=["$scope","$element",function(a){return{getMarkerScope:function(){return a}}}],d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkerParentModel(a,b,c,d,this.$timeout)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.Markers=function(b){function d(b,c){this.link=a(this.link,this);var e;d.__super__.constructor.call(this,b),e=this,this.template='<span class="angular-google-map-markers" ng-transclude></span>',this.scope.models="=models",this.scope.doCluster="=docluster",this.scope.clusterOptions="=clusteroptions",this.scope.fit="=fit",this.scope.labelContent="=labelcontent",this.scope.labelAnchor="@labelanchor",this.scope.labelClass="@labelclass",this.$timeout=b,this.$injector=c,this.$log.info(this)}return c(d,b),d.prototype.controller=["$scope","$element",function(a){return{getMarkersScope:function(){return a}}}],d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.MarkersParentModel(a,b,c,d,this.$timeout,this.$injector)},d}(directives.api.IMarker)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.Window=function(b){function d(b,c,e,f){this.link=a(this.link,this);var g;d.__super__.constructor.call(this,b,c,e,f),g=this,this.require=["^googleMap","^?marker"],this.template='<span class="angular-google-maps-window" ng-transclude></span>',this.$log.info(g)}return c(d,b),d.include(directives.api.utils.GmapUtil),d.prototype.link=function(a,b,c,d){var e=this;return this.$timeout(function(){var f,g,h,i,j,k,l,m;return h=!0,angular.isDefined(c.isiconvisibleonclick)&&(h=a.isIconVisibleOnClick),i=d[0].getMap(),j=d.length>1&&null!=d[1]?d[1].getMarkerScope().gMarker:void 0,f=null!=a.options?a.options:{},g=null!=a&&null!=a.coords&&null!=a.coords.latitude&&null!=a.coords.longitude,l=g?e.createWindowOptions(j,a,b.html(),f):f,null!=i&&(m=new directives.api.models.child.WindowChildModel(a,l,h,i,j,e.$http,e.$templateCache,e.$compile,b)),a.$on("$destroy",function(){return m.destroy()}),null!=d[1]&&(k=d[1].getMarkerScope(),k.$watch("coords",function(a){return null==a?m.hideWindow():void 0}),k.$watch("coords.latitude",function(a,b){return a!==b?m.getLatestPosition():void 0})),null!=e.onChildCreation&&null!=m?e.onChildCreation(m):void 0},directives.api.utils.GmapUtil.defaultDelay+25)},d}(directives.api.IWindow)})}.call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};this.ngGmapModule("directives.api",function(){return this.Windows=function(b){function d(b,c,e,f,g){this.link=a(this.link,this);var h;d.__super__.constructor.call(this,b,c,e,f),h=this,this.$interpolate=g,this.require=["^googleMap","^?markers"],this.template='<span class="angular-google-maps-windows" ng-transclude></span>',this.scope.models="=models",this.$log.info(h)}return c(d,b),d.prototype.link=function(a,b,c,d){return new directives.api.models.parent.WindowsParentModel(a,b,c,d,this.$timeout,this.$compile,this.$http,this.$templateCache,this.$interpolate)},d}(directives.api.IWindow)})}.call(this),function(){angular.module("google-maps").directive("googleMap",["$log","$timeout",function(a){"use strict";var b,c,d;return d=function(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a},directives.api.utils.Logger.logger=a,b={mapTypeId:google.maps.MapTypeId.ROADMAP},c=function(a){return new google.maps.LatLng(a.latitude,a.longitude)},{self:this,restrict:"ECMA",transclude:!0,replace:!1,template:'<div class="angular-google-map"><div class="angular-google-map-container"></div><div ng-transclude style="display: none"></div></div>',scope:{center:"=center",zoom:"=zoom",dragging:"=dragging",control:"=",windows:"=windows",options:"=options",events:"=events",styles:"=styles",bounds:"=bounds"},controller:["$scope",function(a){return{getMap:function(){return a.map}}}],link:function(e,f,g){var h,i,j,k,l,m,n,o;if(!angular.isDefined(e.center)||!angular.isDefined(e.center.latitude)||!angular.isDefined(e.center.longitude))return void a.error("angular-google-maps: could not find a valid center property");if(!angular.isDefined(e.zoom))return void a.error("angular-google-maps: map zoom property not set");if(i=angular.element(f),i.addClass("angular-google-map"),l={options:{}},g.options&&(l.options=e.options),g.styles&&(l.styles=e.styles),g.type&&(n=g.type.toUpperCase(),google.maps.MapTypeId.hasOwnProperty(n)?l.mapTypeId=google.maps.MapTypeId[g.type.toUpperCase()]:a.error('angular-google-maps: invalid map type "'+g.type+'"')),o=new google.maps.Map(i.find("div")[1],angular.extend({},b,l,{center:new google.maps.LatLng(e.center.latitude,e.center.longitude),draggable:d(g.draggable),zoom:e.zoom,bounds:e.bounds})),h=!1,google.maps.event.addListener(o,"dragstart",function(){return h=!0,_.defer(function(){return e.$apply(function(a){return null!=a.dragging?a.dragging=h:void 0})})}),google.maps.event.addListener(o,"dragend",function(){return h=!1,_.defer(function(){return e.$apply(function(a){return null!=a.dragging?a.dragging=h:void 0})})}),google.maps.event.addListener(o,"drag",function(){var a;return a=o.center,_.defer(function(){return e.$apply(function(b){return b.center.latitude=a.lat(),b.center.longitude=a.lng()})})}),google.maps.event.addListener(o,"zoom_changed",function(){return e.zoom!==o.zoom?_.defer(function(){return e.$apply(function(a){return a.zoom=o.zoom})}):void 0}),m=!1,google.maps.event.addListener(o,"center_changed",function(){var a;return a=o.center,m?void 0:_.defer(function(){return e.$apply(function(b){return o.dragging||(b.center.latitude!==a.lat()&&(b.center.latitude=a.lat()),b.center.longitude===a.lng())?void 0:b.center.longitude=a.lng()})})}),google.maps.event.addListener(o,"idle",function(){var a,b,c;return a=o.getBounds(),b=a.getNorthEast(),c=a.getSouthWest(),_.defer(function(){return e.$apply(function(a){return null!==a.bounds&&void 0!==a.bounds&&void 0!==a.bounds?(a.bounds.northeast={latitude:b.lat(),longitude:b.lng()},a.bounds.southwest={latitude:c.lat(),longitude:c.lng()}):void 0})})}),angular.isDefined(e.events)&&null!==e.events&&angular.isObject(e.events)){k=function(a){return function(){return e.events[a].apply(e,[o,a,arguments])}};for(j in e.events)e.events.hasOwnProperty(j)&&angular.isFunction(e.events[j])&&google.maps.event.addListener(o,j,k(j))}return e.map=o,null!=g.control&&null!=e.control&&(e.control.refresh=function(a){var b;if(null!=o)return google.maps.event.trigger(o,"resize"),null!=(null!=a?a.latitude:void 0)&&null!=(null!=a?a.latitude:void 0)?(b=c(a),d(g.pan)?o.panTo(b):o.setCenter(b)):void 0},e.control.getGMap=function(){return o}),e.$watch("center",function(b,f){var i;return i=c(b),b===f||i.lat()===o.center.lat()&&i.lng()===o.center.lng()?void 0:(m=!0,h||((null==b.latitude||null==b.longitude)&&a.error("Invalid center for newValue: "+JSON.stringify(b)),d(g.pan)&&e.zoom===o.zoom?o.panTo(i):o.setCenter(i)),m=!1)},!0),e.$watch("zoom",function(a,b){return a!==b&&a!==o.zoom?_.defer(function(){return o.setZoom(a)}):void 0}),e.$watch("bounds",function(b,c){var d,e,f;if(b!==c)return null==b.northeast.latitude||null==b.northeast.longitude||null==b.southwest.latitude||null==b.southwest.longitude?void a.error("Invalid map bounds for new value: "+JSON.stringify(b)):(e=new google.maps.LatLng(b.northeast.latitude,b.northeast.longitude),f=new google.maps.LatLng(b.southwest.latitude,b.southwest.longitude),d=new google.maps.LatLngBounds(f,e),o.fitBounds(d))}),e.$watch("options",function(a,b){return _.isEqual(a,b)||(l.options=a,null==o)?void 0:o.setOptions(l)},!0),e.$watch("styles",function(a,b){return _.isEqual(a,b)||(l.styles=a,null==o)?void 0:o.setOptions(l)},!0)}}}])}.call(this),function(){angular.module("google-maps").directive("marker",["$timeout",function(a){return new directives.api.Marker(a)}])}.call(this),function(){angular.module("google-maps").directive("markers",["$timeout","$injector",function(a,b){return new directives.api.Markers(a,b)}])}.call(this),function(){angular.module("google-maps").directive("markerLabel",["$log","$timeout",function(a,b){return new directives.api.Label(b)}])}.call(this),function(){angular.module("google-maps").directive("polygon",["$log","$timeout",function(a,b){var c,d,e,f,g;return g=function(a){var b;for(b=0;b<a.length;){if(angular.isUndefined(a[b].latitude)||angular.isUndefined(a[b].longitude))return!1;b++}return!0},d=function(a){var b,c;for(c=new google.maps.MVCArray,b=0;b<a.length;)c.push(new google.maps.LatLng(a[b].latitude,a[b].longitude)),b++;return c},e=function(a,b){var c,d;for(c=new google.maps.LatLngBounds,d=0;d<b.length;)c.extend(b.getAt(d)),d++;return a.fitBounds(c)},f=function(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a},c={},{restrict:"ECA",require:"^googleMap",replace:!0,scope:{path:"=path",stroke:"=stroke",clickable:"=",draggable:"=",editable:"=",geodesic:"=",icons:"=icons",visible:"="},link:function(h,i,j,k){return angular.isUndefined(h.path)||null===h.path||h.path.length<2||!g(h.path)?void a.error("polyline: no valid path attribute found"):b(function(){var a,b,g,i,l,m,n,o;return a=k.getMap(),i=d(h.path),b=angular.extend({},c,{map:a,path:i,strokeColor:h.stroke&&h.stroke.color,strokeOpacity:h.stroke&&h.stroke.opacity,strokeWeight:h.stroke&&h.stroke.weight}),angular.forEach({clickable:!0,draggable:!1,editable:!1,geodesic:!1,visible:!0},function(a,c){return b[c]=angular.isUndefined(h[c])||null===h[c]?a:h[c]}),o=new google.maps.Polyline(b),f(j.fit)&&e(a,i),angular.isDefined(h.editable)&&h.$watch("editable",function(a){return o.setEditable(a)}),angular.isDefined(h.draggable)&&h.$watch("draggable",function(a){return o.setDraggable(a)}),angular.isDefined(h.visible)&&h.$watch("visible",function(a){return o.setVisible(a)}),m=void 0,g=void 0,l=void 0,n=o.getPath(),m=google.maps.event.addListener(n,"set_at",function(a){var b;return b=n.getAt(a),b&&b.lng&&b.lat?(h.path[a].latitude=b.lat(),h.path[a].longitude=b.lng(),h.$apply()):void 0}),g=google.maps.event.addListener(n,"insert_at",function(a){var b;return b=n.getAt(a),b&&b.lng&&b.lat?(h.path.splice(a,0,{latitude:b.lat(),longitude:b.lng()}),h.$apply()):void 0}),l=google.maps.event.addListener(n,"remove_at",function(a){return h.path.splice(a,1),h.$apply()}),h.$watch("path",function(b){var c,d,g,h,i,k,l;if(i=o.getPath(),b!==i){if(!b)return o.setMap(null);for(o.setMap(a),c=0,k=i.getLength(),g=b.length,d=Math.min(k,g);d>c;)l=i.getAt(c),h=b[c],(l.lat()!==h.latitude||l.lng()!==h.longitude)&&i.setAt(c,new google.maps.LatLng(h.latitude,h.longitude)),c++;for(;g>c;)h=b[c],i.push(new google.maps.LatLng(h.latitude,h.longitude)),c++;for(;k>c;)i.pop(),c++;if(f(j.fit))return e(a,i)}},!0),h.$on("$destroy",function(){return o.setMap(null),m(),m=null,g(),g=null,l(),l=null})})}}}])}.call(this),function(){angular.module("google-maps").directive("polyline",["$log","$timeout","array-sync",function(a,b,c){var d,e,f,g,h;return h=function(a){var b;for(b=0;b<a.length;){if(angular.isUndefined(a[b].latitude)||angular.isUndefined(a[b].longitude))return!1;b++}return!0},e=function(a){var b,c;for(c=new google.maps.MVCArray,b=0;b<a.length;)c.push(new google.maps.LatLng(a[b].latitude,a[b].longitude)),b++;return c},f=function(a,b){var c,d;for(c=new google.maps.LatLngBounds,d=0;d<b.length;)c.extend(b.getAt(d)),d++;return a.fitBounds(c)},g=function(a){return angular.isDefined(a)&&null!==a&&a===!0||"1"===a||"y"===a||"true"===a},d={},{restrict:"ECA",replace:!0,require:"^googleMap",scope:{path:"=path",stroke:"=stroke",clickable:"=",draggable:"=",editable:"=",geodesic:"=",icons:"=icons",visible:"="},link:function(i,j,k,l){return angular.isUndefined(i.path)||null===i.path||i.path.length<2||!h(i.path)?void a.error("polyline: no valid path attribute found"):b(function(){var a,b,h,j;return b=function(a){var b;return b=angular.extend({},d,{map:h,path:a,strokeColor:i.stroke&&i.stroke.color,strokeOpacity:i.stroke&&i.stroke.opacity,strokeWeight:i.stroke&&i.stroke.weight}),angular.forEach({clickable:!0,draggable:!1,editable:!1,geodesic:!1,visible:!0},function(a,c){return b[c]=angular.isUndefined(i[c])||null===i[c]?a:i[c]}),b},h=l.getMap(),j=new google.maps.Polyline(b(e(i.path))),g(k.fit)&&f(h,pathPoints),angular.isDefined(i.editable)&&i.$watch("editable",function(a){return j.setEditable(a)}),angular.isDefined(i.draggable)&&i.$watch("draggable",function(a){return j.setDraggable(a)}),angular.isDefined(i.visible)&&i.$watch("visible",function(a){return j.setVisible(a)}),angular.isDefined(i.geodesic)&&i.$watch("geodesic",function(){return j.setOptions(b(j.getPath()))}),angular.isDefined(i.stroke)&&angular.isDefined(i.stroke.weight)&&i.$watch("stroke.weight",function(){return j.setOptions(b(j.getPath()))}),angular.isDefined(i.stroke)&&angular.isDefined(i.stroke.color)&&i.$watch("stroke.color",function(){return j.setOptions(b(j.getPath()))}),a=c(j.getPath(),i,"path"),i.$on("$destroy",function(){return j.setMap(null),a?(a(),a=null):void 0})})}}}])}.call(this),function(){angular.module("google-maps").directive("window",["$timeout","$compile","$http","$templateCache",function(a,b,c,d){return new directives.api.Window(a,b,c,d)}])}.call(this),function(){angular.module("google-maps").directive("windows",["$timeout","$compile","$http","$templateCache","$interpolate",function(a,b,c,d,e){return new directives.api.Windows(a,b,c,d,e)}])}.call(this),function(){angular.module("google-maps").directive("layer",["$timeout",function(a){return new directives.api.Layer(a)}])}.call(this),InfoBox.prototype=new google.maps.OverlayView,InfoBox.prototype.createInfoBoxDiv_=function(){var a,b,c,d=this,e=function(a){a.cancelBubble=!0,a.stopPropagation&&a.stopPropagation()},f=function(a){a.returnValue=!1,a.preventDefault&&a.preventDefault(),d.enableEventPropagation_||e(a)};if(!this.div_){if(this.div_=document.createElement("div"),this.setBoxStyle_(),"undefined"==typeof this.content_.nodeType?this.div_.innerHTML=this.getCloseBoxImg_()+this.content_:(this.div_.innerHTML=this.getCloseBoxImg_(),this.div_.appendChild(this.content_)),this.getPanes()[this.pane_].appendChild(this.div_),this.addClickHandler_(),this.div_.style.width?this.fixedWidthSet_=!0:0!==this.maxWidth_&&this.div_.offsetWidth>this.maxWidth_?(this.div_.style.width=this.maxWidth_,this.div_.style.overflow="auto",this.fixedWidthSet_=!0):(c=this.getBoxWidths_(),this.div_.style.width=this.div_.offsetWidth-c.left-c.right+"px",this.fixedWidthSet_=!1),this.panBox_(this.disableAutoPan_),!this.enableEventPropagation_){for(this.eventListeners_=[],b=["mousedown","mouseover","mouseout","mouseup","click","dblclick","touchstart","touchend","touchmove"],a=0;a<b.length;a++)this.eventListeners_.push(google.maps.event.addDomListener(this.div_,b[a],e));this.eventListeners_.push(google.maps.event.addDomListener(this.div_,"mouseover",function(){this.style.cursor="default"}))}this.contextListener_=google.maps.event.addDomListener(this.div_,"contextmenu",f),google.maps.event.trigger(this,"domready")}},InfoBox.prototype.getCloseBoxImg_=function(){var a="";return""!==this.closeBoxURL_&&(a="<img",a+=" src='"+this.closeBoxURL_+"'",a+=" align=right",a+=" style='",a+=" position: relative;",a+=" cursor: pointer;",a+=" margin: "+this.closeBoxMargin_+";",a+="'>"),a},InfoBox.prototype.addClickHandler_=function(){var a;""!==this.closeBoxURL_?(a=this.div_.firstChild,this.closeListener_=google.maps.event.addDomListener(a,"click",this.getCloseClickHandler_())):this.closeListener_=null},InfoBox.prototype.getCloseClickHandler_=function(){var a=this;return function(b){b.cancelBubble=!0,b.stopPropagation&&b.stopPropagation(),google.maps.event.trigger(a,"closeclick"),a.close()}},InfoBox.prototype.panBox_=function(a){var b,c,d=0,e=0;if(!a&&(b=this.getMap(),b instanceof google.maps.Map)){b.getBounds().contains(this.position_)||b.setCenter(this.position_),c=b.getBounds();var f=b.getDiv(),g=f.offsetWidth,h=f.offsetHeight,i=this.pixelOffset_.width,j=this.pixelOffset_.height,k=this.div_.offsetWidth,l=this.div_.offsetHeight,m=this.infoBoxClearance_.width,n=this.infoBoxClearance_.height,o=this.getProjection().fromLatLngToContainerPixel(this.position_);if(o.x<-i+m?d=o.x+i-m:o.x+k+i+m>g&&(d=o.x+k+i+m-g),this.alignBottom_?o.y<-j+n+l?e=o.y+j-n-l:o.y+j+n>h&&(e=o.y+j+n-h):o.y<-j+n?e=o.y+j-n:o.y+l+j+n>h&&(e=o.y+l+j+n-h),0!==d||0!==e){{b.getCenter()}b.panBy(d,e)}}},InfoBox.prototype.setBoxStyle_=function(){var a,b;if(this.div_){this.div_.className=this.boxClass_,this.div_.style.cssText="",b=this.boxStyle_;for(a in b)b.hasOwnProperty(a)&&(this.div_.style[a]=b[a]);"undefined"!=typeof this.div_.style.opacity&&""!==this.div_.style.opacity&&(this.div_.style.filter="alpha(opacity="+100*this.div_.style.opacity+")"),this.div_.style.position="absolute",this.div_.style.visibility="hidden",null!==this.zIndex_&&(this.div_.style.zIndex=this.zIndex_)}},InfoBox.prototype.getBoxWidths_=function(){var a,b={top:0,bottom:0,left:0,right:0},c=this.div_;return document.defaultView&&document.defaultView.getComputedStyle?(a=c.ownerDocument.defaultView.getComputedStyle(c,""),a&&(b.top=parseInt(a.borderTopWidth,10)||0,b.bottom=parseInt(a.borderBottomWidth,10)||0,b.left=parseInt(a.borderLeftWidth,10)||0,b.right=parseInt(a.borderRightWidth,10)||0)):document.documentElement.currentStyle&&c.currentStyle&&(b.top=parseInt(c.currentStyle.borderTopWidth,10)||0,b.bottom=parseInt(c.currentStyle.borderBottomWidth,10)||0,b.left=parseInt(c.currentStyle.borderLeftWidth,10)||0,b.right=parseInt(c.currentStyle.borderRightWidth,10)||0),b},InfoBox.prototype.onRemove=function(){this.div_&&(this.div_.parentNode.removeChild(this.div_),this.div_=null) +},InfoBox.prototype.draw=function(){this.createInfoBoxDiv_();var a=this.getProjection().fromLatLngToDivPixel(this.position_);this.div_.style.left=a.x+this.pixelOffset_.width+"px",this.alignBottom_?this.div_.style.bottom=-(a.y+this.pixelOffset_.height)+"px":this.div_.style.top=a.y+this.pixelOffset_.height+"px",this.div_.style.visibility=this.isHidden_?"hidden":"visible"},InfoBox.prototype.setOptions=function(a){"undefined"!=typeof a.boxClass&&(this.boxClass_=a.boxClass,this.setBoxStyle_()),"undefined"!=typeof a.boxStyle&&(this.boxStyle_=a.boxStyle,this.setBoxStyle_()),"undefined"!=typeof a.content&&this.setContent(a.content),"undefined"!=typeof a.disableAutoPan&&(this.disableAutoPan_=a.disableAutoPan),"undefined"!=typeof a.maxWidth&&(this.maxWidth_=a.maxWidth),"undefined"!=typeof a.pixelOffset&&(this.pixelOffset_=a.pixelOffset),"undefined"!=typeof a.alignBottom&&(this.alignBottom_=a.alignBottom),"undefined"!=typeof a.position&&this.setPosition(a.position),"undefined"!=typeof a.zIndex&&this.setZIndex(a.zIndex),"undefined"!=typeof a.closeBoxMargin&&(this.closeBoxMargin_=a.closeBoxMargin),"undefined"!=typeof a.closeBoxURL&&(this.closeBoxURL_=a.closeBoxURL),"undefined"!=typeof a.infoBoxClearance&&(this.infoBoxClearance_=a.infoBoxClearance),"undefined"!=typeof a.isHidden&&(this.isHidden_=a.isHidden),"undefined"!=typeof a.visible&&(this.isHidden_=!a.visible),"undefined"!=typeof a.enableEventPropagation&&(this.enableEventPropagation_=a.enableEventPropagation),this.div_&&this.draw()},InfoBox.prototype.setContent=function(a){this.content_=a,this.div_&&(this.closeListener_&&(google.maps.event.removeListener(this.closeListener_),this.closeListener_=null),this.fixedWidthSet_||(this.div_.style.width=""),"undefined"==typeof a.nodeType?this.div_.innerHTML=this.getCloseBoxImg_()+a:(this.div_.innerHTML=this.getCloseBoxImg_(),this.div_.appendChild(a)),this.fixedWidthSet_||(this.div_.style.width=this.div_.offsetWidth+"px","undefined"==typeof a.nodeType?this.div_.innerHTML=this.getCloseBoxImg_()+a:(this.div_.innerHTML=this.getCloseBoxImg_(),this.div_.appendChild(a))),this.addClickHandler_()),google.maps.event.trigger(this,"content_changed")},InfoBox.prototype.setPosition=function(a){this.position_=a,this.div_&&this.draw(),google.maps.event.trigger(this,"position_changed")},InfoBox.prototype.setZIndex=function(a){this.zIndex_=a,this.div_&&(this.div_.style.zIndex=a),google.maps.event.trigger(this,"zindex_changed")},InfoBox.prototype.setVisible=function(a){this.isHidden_=!a,this.div_&&(this.div_.style.visibility=this.isHidden_?"hidden":"visible")},InfoBox.prototype.getContent=function(){return this.content_},InfoBox.prototype.getPosition=function(){return this.position_},InfoBox.prototype.getZIndex=function(){return this.zIndex_},InfoBox.prototype.getVisible=function(){var a;return a="undefined"==typeof this.getMap()||null===this.getMap()?!1:!this.isHidden_},InfoBox.prototype.show=function(){this.isHidden_=!1,this.div_&&(this.div_.style.visibility="visible")},InfoBox.prototype.hide=function(){this.isHidden_=!0,this.div_&&(this.div_.style.visibility="hidden")},InfoBox.prototype.open=function(a,b){var c=this;b&&(this.position_=b.getPosition(),this.moveListener_=google.maps.event.addListener(b,"position_changed",function(){c.setPosition(this.getPosition())})),this.setMap(a),this.div_&&this.panBox_()},InfoBox.prototype.close=function(){var a;if(this.closeListener_&&(google.maps.event.removeListener(this.closeListener_),this.closeListener_=null),this.eventListeners_){for(a=0;a<this.eventListeners_.length;a++)google.maps.event.removeListener(this.eventListeners_[a]);this.eventListeners_=null}this.moveListener_&&(google.maps.event.removeListener(this.moveListener_),this.moveListener_=null),this.contextListener_&&(google.maps.event.removeListener(this.contextListener_),this.contextListener_=null),this.setMap(null)},ClusterIcon.prototype.onAdd=function(){var a,b,c=this;this.div_=document.createElement("div"),this.div_.className=this.className_,this.visible_&&this.show(),this.getPanes().overlayMouseTarget.appendChild(this.div_),this.boundsChangedListener_=google.maps.event.addListener(this.getMap(),"bounds_changed",function(){b=a}),google.maps.event.addDomListener(this.div_,"mousedown",function(){a=!0,b=!1}),google.maps.event.addDomListener(this.div_,"click",function(d){if(a=!1,!b){var e,f,g=c.cluster_.getMarkerClusterer();google.maps.event.trigger(g,"click",c.cluster_),google.maps.event.trigger(g,"clusterclick",c.cluster_),g.getZoomOnClick()&&(f=g.getMaxZoom(),e=c.cluster_.getBounds(),g.getMap().fitBounds(e),setTimeout(function(){g.getMap().fitBounds(e),null!==f&&g.getMap().getZoom()>f&&g.getMap().setZoom(f+1)},100)),d.cancelBubble=!0,d.stopPropagation&&d.stopPropagation()}}),google.maps.event.addDomListener(this.div_,"mouseover",function(){var a=c.cluster_.getMarkerClusterer();google.maps.event.trigger(a,"mouseover",c.cluster_)}),google.maps.event.addDomListener(this.div_,"mouseout",function(){var a=c.cluster_.getMarkerClusterer();google.maps.event.trigger(a,"mouseout",c.cluster_)})},ClusterIcon.prototype.onRemove=function(){this.div_&&this.div_.parentNode&&(this.hide(),google.maps.event.removeListener(this.boundsChangedListener_),google.maps.event.clearInstanceListeners(this.div_),this.div_.parentNode.removeChild(this.div_),this.div_=null)},ClusterIcon.prototype.draw=function(){if(this.visible_){var a=this.getPosFromLatLng_(this.center_);this.div_.style.top=a.y+"px",this.div_.style.left=a.x+"px"}},ClusterIcon.prototype.hide=function(){this.div_&&(this.div_.style.display="none"),this.visible_=!1},ClusterIcon.prototype.show=function(){if(this.div_){var a="",b=this.backgroundPosition_.split(" "),c=parseInt(b[0].trim(),10),d=parseInt(b[1].trim(),10),e=this.getPosFromLatLng_(this.center_);this.div_.style.cssText=this.createCss(e),a="<img src='"+this.url_+"' style='position: absolute; top: "+d+"px; left: "+c+"px; ",this.cluster_.getMarkerClusterer().enableRetinaIcons_||(a+="clip: rect("+-1*d+"px, "+(-1*c+this.width_)+"px, "+(-1*d+this.height_)+"px, "+-1*c+"px);"),a+="'>",this.div_.innerHTML=a+"<div style='position: absolute;top: "+this.anchorText_[0]+"px;left: "+this.anchorText_[1]+"px;color: "+this.textColor_+";font-size: "+this.textSize_+"px;font-family: "+this.fontFamily_+";font-weight: "+this.fontWeight_+";font-style: "+this.fontStyle_+";text-decoration: "+this.textDecoration_+";text-align: center;width: "+this.width_+"px;line-height:"+this.height_+"px;'>"+this.sums_.text+"</div>",this.div_.title="undefined"==typeof this.sums_.title||""===this.sums_.title?this.cluster_.getMarkerClusterer().getTitle():this.sums_.title,this.div_.style.display=""}this.visible_=!0},ClusterIcon.prototype.useStyle=function(a){this.sums_=a;var b=Math.max(0,a.index-1);b=Math.min(this.styles_.length-1,b);var c=this.styles_[b];this.url_=c.url,this.height_=c.height,this.width_=c.width,this.anchorText_=c.anchorText||[0,0],this.anchorIcon_=c.anchorIcon||[parseInt(this.height_/2,10),parseInt(this.width_/2,10)],this.textColor_=c.textColor||"black",this.textSize_=c.textSize||11,this.textDecoration_=c.textDecoration||"none",this.fontWeight_=c.fontWeight||"bold",this.fontStyle_=c.fontStyle||"normal",this.fontFamily_=c.fontFamily||"Arial,sans-serif",this.backgroundPosition_=c.backgroundPosition||"0 0"},ClusterIcon.prototype.setCenter=function(a){this.center_=a},ClusterIcon.prototype.createCss=function(a){var b=[];return b.push("cursor: pointer;"),b.push("position: absolute; top: "+a.y+"px; left: "+a.x+"px;"),b.push("width: "+this.width_+"px; height: "+this.height_+"px;"),b.join("")},ClusterIcon.prototype.getPosFromLatLng_=function(a){var b=this.getProjection().fromLatLngToDivPixel(a);return b.x-=this.anchorIcon_[1],b.y-=this.anchorIcon_[0],b.x=parseInt(b.x,10),b.y=parseInt(b.y,10),b},Cluster.prototype.getSize=function(){return this.markers_.length},Cluster.prototype.getMarkers=function(){return this.markers_},Cluster.prototype.getCenter=function(){return this.center_},Cluster.prototype.getMap=function(){return this.map_},Cluster.prototype.getMarkerClusterer=function(){return this.markerClusterer_},Cluster.prototype.getBounds=function(){var a,b=new google.maps.LatLngBounds(this.center_,this.center_),c=this.getMarkers();for(a=0;a<c.length;a++)b.extend(c[a].getPosition());return b},Cluster.prototype.remove=function(){this.clusterIcon_.setMap(null),this.markers_=[],delete this.markers_},Cluster.prototype.addMarker=function(a){var b,c,d;if(this.isMarkerAlreadyAdded_(a))return!1;if(this.center_){if(this.averageCenter_){var e=this.markers_.length+1,f=(this.center_.lat()*(e-1)+a.getPosition().lat())/e,g=(this.center_.lng()*(e-1)+a.getPosition().lng())/e;this.center_=new google.maps.LatLng(f,g),this.calculateBounds_()}}else this.center_=a.getPosition(),this.calculateBounds_();if(a.isAdded=!0,this.markers_.push(a),c=this.markers_.length,d=this.markerClusterer_.getMaxZoom(),null!==d&&this.map_.getZoom()>d)a.getMap()!==this.map_&&a.setMap(this.map_);else if(c<this.minClusterSize_)a.getMap()!==this.map_&&a.setMap(this.map_);else if(c===this.minClusterSize_)for(b=0;c>b;b++)this.markers_[b].setMap(null);else a.setMap(null);return this.updateIcon_(),!0},Cluster.prototype.isMarkerInClusterBounds=function(a){return this.bounds_.contains(a.getPosition())},Cluster.prototype.calculateBounds_=function(){var a=new google.maps.LatLngBounds(this.center_,this.center_);this.bounds_=this.markerClusterer_.getExtendedBounds(a)},Cluster.prototype.updateIcon_=function(){var a=this.markers_.length,b=this.markerClusterer_.getMaxZoom();if(null!==b&&this.map_.getZoom()>b)return void this.clusterIcon_.hide();if(a<this.minClusterSize_)return void this.clusterIcon_.hide();var c=this.markerClusterer_.getStyles().length,d=this.markerClusterer_.getCalculator()(this.markers_,c);this.clusterIcon_.setCenter(this.center_),this.clusterIcon_.useStyle(d),this.clusterIcon_.show()},Cluster.prototype.isMarkerAlreadyAdded_=function(a){var b;if(this.markers_.indexOf)return-1!==this.markers_.indexOf(a);for(b=0;b<this.markers_.length;b++)if(a===this.markers_[b])return!0;return!1},MarkerClusterer.prototype.onAdd=function(){var a=this;this.activeMap_=this.getMap(),this.ready_=!0,this.repaint(),this.listeners_=[google.maps.event.addListener(this.getMap(),"zoom_changed",function(){a.resetViewport_(!1),(this.getZoom()===(this.get("minZoom")||0)||this.getZoom()===this.get("maxZoom"))&&google.maps.event.trigger(this,"idle")}),google.maps.event.addListener(this.getMap(),"idle",function(){a.redraw_()})]},MarkerClusterer.prototype.onRemove=function(){var a;for(a=0;a<this.markers_.length;a++)this.markers_[a].getMap()!==this.activeMap_&&this.markers_[a].setMap(this.activeMap_);for(a=0;a<this.clusters_.length;a++)this.clusters_[a].remove();for(this.clusters_=[],a=0;a<this.listeners_.length;a++)google.maps.event.removeListener(this.listeners_[a]);this.listeners_=[],this.activeMap_=null,this.ready_=!1},MarkerClusterer.prototype.draw=function(){},MarkerClusterer.prototype.setupStyles_=function(){var a,b;if(!(this.styles_.length>0))for(a=0;a<this.imageSizes_.length;a++)b=this.imageSizes_[a],this.styles_.push({url:this.imagePath_+(a+1)+"."+this.imageExtension_,height:b,width:b})},MarkerClusterer.prototype.fitMapToMarkers=function(){var a,b=this.getMarkers(),c=new google.maps.LatLngBounds;for(a=0;a<b.length;a++)c.extend(b[a].getPosition());this.getMap().fitBounds(c)},MarkerClusterer.prototype.getGridSize=function(){return this.gridSize_},MarkerClusterer.prototype.setGridSize=function(a){this.gridSize_=a},MarkerClusterer.prototype.getMinimumClusterSize=function(){return this.minClusterSize_},MarkerClusterer.prototype.setMinimumClusterSize=function(a){this.minClusterSize_=a},MarkerClusterer.prototype.getMaxZoom=function(){return this.maxZoom_},MarkerClusterer.prototype.setMaxZoom=function(a){this.maxZoom_=a},MarkerClusterer.prototype.getStyles=function(){return this.styles_},MarkerClusterer.prototype.setStyles=function(a){this.styles_=a},MarkerClusterer.prototype.getTitle=function(){return this.title_},MarkerClusterer.prototype.setTitle=function(a){this.title_=a},MarkerClusterer.prototype.getZoomOnClick=function(){return this.zoomOnClick_},MarkerClusterer.prototype.setZoomOnClick=function(a){this.zoomOnClick_=a},MarkerClusterer.prototype.getAverageCenter=function(){return this.averageCenter_},MarkerClusterer.prototype.setAverageCenter=function(a){this.averageCenter_=a},MarkerClusterer.prototype.getIgnoreHidden=function(){return this.ignoreHidden_},MarkerClusterer.prototype.setIgnoreHidden=function(a){this.ignoreHidden_=a},MarkerClusterer.prototype.getEnableRetinaIcons=function(){return this.enableRetinaIcons_},MarkerClusterer.prototype.setEnableRetinaIcons=function(a){this.enableRetinaIcons_=a},MarkerClusterer.prototype.getImageExtension=function(){return this.imageExtension_},MarkerClusterer.prototype.setImageExtension=function(a){this.imageExtension_=a},MarkerClusterer.prototype.getImagePath=function(){return this.imagePath_},MarkerClusterer.prototype.setImagePath=function(a){this.imagePath_=a},MarkerClusterer.prototype.getImageSizes=function(){return this.imageSizes_},MarkerClusterer.prototype.setImageSizes=function(a){this.imageSizes_=a},MarkerClusterer.prototype.getCalculator=function(){return this.calculator_},MarkerClusterer.prototype.setCalculator=function(a){this.calculator_=a},MarkerClusterer.prototype.getBatchSizeIE=function(){return this.batchSizeIE_},MarkerClusterer.prototype.setBatchSizeIE=function(a){this.batchSizeIE_=a},MarkerClusterer.prototype.getClusterClass=function(){return this.clusterClass_},MarkerClusterer.prototype.setClusterClass=function(a){this.clusterClass_=a},MarkerClusterer.prototype.getMarkers=function(){return this.markers_},MarkerClusterer.prototype.getTotalMarkers=function(){return this.markers_.length},MarkerClusterer.prototype.getClusters=function(){return this.clusters_},MarkerClusterer.prototype.getTotalClusters=function(){return this.clusters_.length},MarkerClusterer.prototype.addMarker=function(a,b){this.pushMarkerTo_(a),b||this.redraw_()},MarkerClusterer.prototype.addMarkers=function(a,b){var c;for(c in a)a.hasOwnProperty(c)&&this.pushMarkerTo_(a[c]);b||this.redraw_()},MarkerClusterer.prototype.pushMarkerTo_=function(a){if(a.getDraggable()){var b=this;google.maps.event.addListener(a,"dragend",function(){b.ready_&&(this.isAdded=!1,b.repaint())})}a.isAdded=!1,this.markers_.push(a)},MarkerClusterer.prototype.removeMarker=function(a,b){var c=this.removeMarker_(a);return!b&&c&&this.repaint(),c},MarkerClusterer.prototype.removeMarkers=function(a,b){var c,d,e=!1;for(c=0;c<a.length;c++)d=this.removeMarker_(a[c]),e=e||d;return!b&&e&&this.repaint(),e},MarkerClusterer.prototype.removeMarker_=function(a){var b,c=-1;if(this.markers_.indexOf)c=this.markers_.indexOf(a);else for(b=0;b<this.markers_.length;b++)if(a===this.markers_[b]){c=b;break}return-1===c?!1:(a.setMap(null),this.markers_.splice(c,1),!0)},MarkerClusterer.prototype.clearMarkers=function(){this.resetViewport_(!0),this.markers_=[]},MarkerClusterer.prototype.repaint=function(){var a=this.clusters_.slice();this.clusters_=[],this.resetViewport_(!1),this.redraw_(),setTimeout(function(){var b;for(b=0;b<a.length;b++)a[b].remove()},0)},MarkerClusterer.prototype.getExtendedBounds=function(a){var b=this.getProjection(),c=new google.maps.LatLng(a.getNorthEast().lat(),a.getNorthEast().lng()),d=new google.maps.LatLng(a.getSouthWest().lat(),a.getSouthWest().lng()),e=b.fromLatLngToDivPixel(c);e.x+=this.gridSize_,e.y-=this.gridSize_;var f=b.fromLatLngToDivPixel(d);f.x-=this.gridSize_,f.y+=this.gridSize_;var g=b.fromDivPixelToLatLng(e),h=b.fromDivPixelToLatLng(f);return a.extend(g),a.extend(h),a},MarkerClusterer.prototype.redraw_=function(){this.createClusters_(0)},MarkerClusterer.prototype.resetViewport_=function(a){var b,c;for(b=0;b<this.clusters_.length;b++)this.clusters_[b].remove();for(this.clusters_=[],b=0;b<this.markers_.length;b++)c=this.markers_[b],c.isAdded=!1,a&&c.setMap(null)},MarkerClusterer.prototype.distanceBetweenPoints_=function(a,b){var c=6371,d=(b.lat()-a.lat())*Math.PI/180,e=(b.lng()-a.lng())*Math.PI/180,f=Math.sin(d/2)*Math.sin(d/2)+Math.cos(a.lat()*Math.PI/180)*Math.cos(b.lat()*Math.PI/180)*Math.sin(e/2)*Math.sin(e/2),g=2*Math.atan2(Math.sqrt(f),Math.sqrt(1-f)),h=c*g;return h},MarkerClusterer.prototype.isMarkerInBounds_=function(a,b){return b.contains(a.getPosition())},MarkerClusterer.prototype.addToClosestCluster_=function(a){var b,c,d,e,f=4e4,g=null;for(b=0;b<this.clusters_.length;b++)d=this.clusters_[b],e=d.getCenter(),e&&(c=this.distanceBetweenPoints_(e,a.getPosition()),f>c&&(f=c,g=d));g&&g.isMarkerInClusterBounds(a)?g.addMarker(a):(d=new Cluster(this),d.addMarker(a),this.clusters_.push(d))},MarkerClusterer.prototype.createClusters_=function(a){var b,c,d,e=this;if(this.ready_){0===a&&(google.maps.event.trigger(this,"clusteringbegin",this),"undefined"!=typeof this.timerRefStatic&&(clearTimeout(this.timerRefStatic),delete this.timerRefStatic)),d=this.getMap().getZoom()>3?new google.maps.LatLngBounds(this.getMap().getBounds().getSouthWest(),this.getMap().getBounds().getNorthEast()):new google.maps.LatLngBounds(new google.maps.LatLng(85.02070771743472,-178.48388434375),new google.maps.LatLng(-85.08136444384544,178.00048865625));var f=this.getExtendedBounds(d),g=Math.min(a+this.batchSize_,this.markers_.length);for(b=a;g>b;b++)c=this.markers_[b],!c.isAdded&&this.isMarkerInBounds_(c,f)&&(!this.ignoreHidden_||this.ignoreHidden_&&c.getVisible())&&this.addToClosestCluster_(c);g<this.markers_.length?this.timerRefStatic=setTimeout(function(){e.createClusters_(g)},0):(delete this.timerRefStatic,google.maps.event.trigger(this,"clusteringend",this))}},MarkerClusterer.prototype.extend=function(a,b){return function(a){var b;for(b in a.prototype)this.prototype[b]=a.prototype[b];return this}.apply(a,[b])},MarkerClusterer.CALCULATOR=function(a,b){for(var c=0,d="",e=a.length.toString(),f=e;0!==f;)f=parseInt(f/10,10),c++;return c=Math.min(c,b),{text:e,index:c,title:d}},MarkerClusterer.BATCH_SIZE=2e3,MarkerClusterer.BATCH_SIZE_IE=500,MarkerClusterer.IMAGE_PATH="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclustererplus/images/m",MarkerClusterer.IMAGE_EXTENSION="png",MarkerClusterer.IMAGE_SIZES=[53,56,66,78,90],"function"!=typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),inherits(MarkerLabel_,google.maps.OverlayView),MarkerLabel_.getSharedCross=function(a){var b;return"undefined"==typeof MarkerLabel_.getSharedCross.crossDiv&&(b=document.createElement("img"),b.style.cssText="position: absolute; z-index: 1000002; display: none;",b.style.marginLeft="-8px",b.style.marginTop="-9px",b.src=a,MarkerLabel_.getSharedCross.crossDiv=b),MarkerLabel_.getSharedCross.crossDiv},MarkerLabel_.prototype.onAdd=function(){var a,b,c,d,e,f,g,h=this,i=!1,j=!1,k=20,l="url("+this.handCursorURL_+")",m=function(a){a.preventDefault&&a.preventDefault(),a.cancelBubble=!0,a.stopPropagation&&a.stopPropagation()},n=function(){h.marker_.setAnimation(null)};this.getPanes().overlayImage.appendChild(this.labelDiv_),this.getPanes().overlayMouseTarget.appendChild(this.eventDiv_),"undefined"==typeof MarkerLabel_.getSharedCross.processed&&(this.getPanes().overlayImage.appendChild(this.crossDiv_),MarkerLabel_.getSharedCross.processed=!0),this.listeners_=[google.maps.event.addDomListener(this.eventDiv_,"mouseover",function(a){(h.marker_.getDraggable()||h.marker_.getClickable())&&(this.style.cursor="pointer",google.maps.event.trigger(h.marker_,"mouseover",a))}),google.maps.event.addDomListener(this.eventDiv_,"mouseout",function(a){!h.marker_.getDraggable()&&!h.marker_.getClickable()||j||(this.style.cursor=h.marker_.getCursor(),google.maps.event.trigger(h.marker_,"mouseout",a))}),google.maps.event.addDomListener(this.eventDiv_,"mousedown",function(a){j=!1,h.marker_.getDraggable()&&(i=!0,this.style.cursor=l),(h.marker_.getDraggable()||h.marker_.getClickable())&&(google.maps.event.trigger(h.marker_,"mousedown",a),m(a))}),google.maps.event.addDomListener(document,"mouseup",function(b){var c;if(i&&(i=!1,h.eventDiv_.style.cursor="pointer",google.maps.event.trigger(h.marker_,"mouseup",b)),j){if(e){c=h.getProjection().fromLatLngToDivPixel(h.marker_.getPosition()),c.y+=k,h.marker_.setPosition(h.getProjection().fromDivPixelToLatLng(c));try{h.marker_.setAnimation(google.maps.Animation.BOUNCE),setTimeout(n,1406)}catch(f){}}h.crossDiv_.style.display="none",h.marker_.setZIndex(a),d=!0,j=!1,b.latLng=h.marker_.getPosition(),google.maps.event.trigger(h.marker_,"dragend",b)}}),google.maps.event.addListener(h.marker_.getMap(),"mousemove",function(d){var l;i&&(j?(d.latLng=new google.maps.LatLng(d.latLng.lat()-b,d.latLng.lng()-c),l=h.getProjection().fromLatLngToDivPixel(d.latLng),e&&(h.crossDiv_.style.left=l.x+"px",h.crossDiv_.style.top=l.y+"px",h.crossDiv_.style.display="",l.y-=k),h.marker_.setPosition(h.getProjection().fromDivPixelToLatLng(l)),e&&(h.eventDiv_.style.top=l.y+k+"px"),google.maps.event.trigger(h.marker_,"drag",d)):(b=d.latLng.lat()-h.marker_.getPosition().lat(),c=d.latLng.lng()-h.marker_.getPosition().lng(),a=h.marker_.getZIndex(),f=h.marker_.getPosition(),g=h.marker_.getMap().getCenter(),e=h.marker_.get("raiseOnDrag"),j=!0,h.marker_.setZIndex(1e6),d.latLng=h.marker_.getPosition(),google.maps.event.trigger(h.marker_,"dragstart",d)))}),google.maps.event.addDomListener(document,"keydown",function(a){j&&27===a.keyCode&&(e=!1,h.marker_.setPosition(f),h.marker_.getMap().setCenter(g),google.maps.event.trigger(document,"mouseup",a))}),google.maps.event.addDomListener(this.eventDiv_,"click",function(a){(h.marker_.getDraggable()||h.marker_.getClickable())&&(d?d=!1:(google.maps.event.trigger(h.marker_,"click",a),m(a)))}),google.maps.event.addDomListener(this.eventDiv_,"dblclick",function(a){(h.marker_.getDraggable()||h.marker_.getClickable())&&(google.maps.event.trigger(h.marker_,"dblclick",a),m(a))}),google.maps.event.addListener(this.marker_,"dragstart",function(){j||(e=this.get("raiseOnDrag"))}),google.maps.event.addListener(this.marker_,"drag",function(){j||e&&(h.setPosition(k),h.labelDiv_.style.zIndex=1e6+(this.get("labelInBackground")?-1:1))}),google.maps.event.addListener(this.marker_,"dragend",function(){j||e&&h.setPosition(0)}),google.maps.event.addListener(this.marker_,"position_changed",function(){h.setPosition()}),google.maps.event.addListener(this.marker_,"zindex_changed",function(){h.setZIndex()}),google.maps.event.addListener(this.marker_,"visible_changed",function(){h.setVisible()}),google.maps.event.addListener(this.marker_,"labelvisible_changed",function(){h.setVisible()}),google.maps.event.addListener(this.marker_,"title_changed",function(){h.setTitle()}),google.maps.event.addListener(this.marker_,"labelcontent_changed",function(){h.setContent()}),google.maps.event.addListener(this.marker_,"labelanchor_changed",function(){h.setAnchor()}),google.maps.event.addListener(this.marker_,"labelclass_changed",function(){h.setStyles()}),google.maps.event.addListener(this.marker_,"labelstyle_changed",function(){h.setStyles()})]},MarkerLabel_.prototype.onRemove=function(){var a;for(null!==this.labelDiv_.parentNode&&this.labelDiv_.parentNode.removeChild(this.labelDiv_),null!==this.eventDiv_.parentNode&&this.eventDiv_.parentNode.removeChild(this.eventDiv_),a=0;a<this.listeners_.length;a++)google.maps.event.removeListener(this.listeners_[a])},MarkerLabel_.prototype.draw=function(){this.setContent(),this.setTitle(),this.setStyles()},MarkerLabel_.prototype.setContent=function(){var a=this.marker_.get("labelContent");"undefined"==typeof a.nodeType?(this.labelDiv_.innerHTML=a,this.eventDiv_.innerHTML=this.labelDiv_.innerHTML):(this.labelDiv_.innerHTML="",this.labelDiv_.appendChild(a),a=a.cloneNode(!0),this.eventDiv_.appendChild(a))},MarkerLabel_.prototype.setTitle=function(){this.eventDiv_.title=this.marker_.getTitle()||""},MarkerLabel_.prototype.setStyles=function(){var a,b;this.labelDiv_.className=this.marker_.get("labelClass"),this.eventDiv_.className=this.labelDiv_.className,this.labelDiv_.style.cssText="",this.eventDiv_.style.cssText="",b=this.marker_.get("labelStyle");for(a in b)b.hasOwnProperty(a)&&(this.labelDiv_.style[a]=b[a],this.eventDiv_.style[a]=b[a]);this.setMandatoryStyles()},MarkerLabel_.prototype.setMandatoryStyles=function(){this.labelDiv_.style.position="absolute",this.labelDiv_.style.overflow="hidden","undefined"!=typeof this.labelDiv_.style.opacity&&""!==this.labelDiv_.style.opacity&&(this.labelDiv_.style.MsFilter='"progid:DXImageTransform.Microsoft.Alpha(opacity='+100*this.labelDiv_.style.opacity+')"',this.labelDiv_.style.filter="alpha(opacity="+100*this.labelDiv_.style.opacity+")"),this.eventDiv_.style.position=this.labelDiv_.style.position,this.eventDiv_.style.overflow=this.labelDiv_.style.overflow,this.eventDiv_.style.opacity=.01,this.eventDiv_.style.MsFilter='"progid:DXImageTransform.Microsoft.Alpha(opacity=1)"',this.eventDiv_.style.filter="alpha(opacity=1)",this.setAnchor(),this.setPosition(),this.setVisible()},MarkerLabel_.prototype.setAnchor=function(){var a=this.marker_.get("labelAnchor");this.labelDiv_.style.marginLeft=-a.x+"px",this.labelDiv_.style.marginTop=-a.y+"px",this.eventDiv_.style.marginLeft=-a.x+"px",this.eventDiv_.style.marginTop=-a.y+"px"},MarkerLabel_.prototype.setPosition=function(a){var b=this.getProjection().fromLatLngToDivPixel(this.marker_.getPosition());"undefined"==typeof a&&(a=0),this.labelDiv_.style.left=Math.round(b.x)+"px",this.labelDiv_.style.top=Math.round(b.y-a)+"px",this.eventDiv_.style.left=this.labelDiv_.style.left,this.eventDiv_.style.top=this.labelDiv_.style.top,this.setZIndex()},MarkerLabel_.prototype.setZIndex=function(){var a=this.marker_.get("labelInBackground")?-1:1;"undefined"==typeof this.marker_.getZIndex()?(this.labelDiv_.style.zIndex=parseInt(this.labelDiv_.style.top,10)+a,this.eventDiv_.style.zIndex=this.labelDiv_.style.zIndex):(this.labelDiv_.style.zIndex=this.marker_.getZIndex()+a,this.eventDiv_.style.zIndex=this.labelDiv_.style.zIndex)},MarkerLabel_.prototype.setVisible=function(){this.labelDiv_.style.display=this.marker_.get("labelVisible")&&this.marker_.getVisible()?"block":"none",this.eventDiv_.style.display=this.labelDiv_.style.display},inherits(MarkerWithLabel,google.maps.Marker),MarkerWithLabel.prototype.setMap=function(a){google.maps.Marker.prototype.setMap.apply(this,arguments),this.label.setMap(a)}; +\ No newline at end of file diff --git a/src/main/webapp/vendor/ui-router.js b/src/main/webapp/vendor/ui-router.js @@ -0,0 +1,3223 @@ +/** + * State-based routing for AngularJS + * @version v0.2.10 + * @link http://angular-ui.github.com/ + * @license MIT License, http://www.opensource.org/licenses/MIT + */ + +/* commonjs package manager support (eg componentjs) */ +if (typeof module !== "undefined" && typeof exports !== "undefined" && module.exports === exports){ + module.exports = 'ui.router'; +} + +(function (window, angular, undefined) { +/*jshint globalstrict:true*/ +/*global angular:false*/ +'use strict'; + +var isDefined = angular.isDefined, + isFunction = angular.isFunction, + isString = angular.isString, + isObject = angular.isObject, + isArray = angular.isArray, + forEach = angular.forEach, + extend = angular.extend, + copy = angular.copy; + +function inherit(parent, extra) { + return extend(new (extend(function() {}, { prototype: parent }))(), extra); +} + +function merge(dst) { + forEach(arguments, function(obj) { + if (obj !== dst) { + forEach(obj, function(value, key) { + if (!dst.hasOwnProperty(key)) dst[key] = value; + }); + } + }); + return dst; +} + +/** + * Finds the common ancestor path between two states. + * + * @param {Object} first The first state. + * @param {Object} second The second state. + * @return {Array} Returns an array of state names in descending order, not including the root. + */ +function ancestors(first, second) { + var path = []; + + for (var n in first.path) { + if (first.path[n] !== second.path[n]) break; + path.push(first.path[n]); + } + return path; +} + +/** + * IE8-safe wrapper for `Object.keys()`. + * + * @param {Object} object A JavaScript object. + * @return {Array} Returns the keys of the object as an array. + */ +function keys(object) { + if (Object.keys) { + return Object.keys(object); + } + var result = []; + + angular.forEach(object, function(val, key) { + result.push(key); + }); + return result; +} + +/** + * IE8-safe wrapper for `Array.prototype.indexOf()`. + * + * @param {Array} array A JavaScript array. + * @param {*} value A value to search the array for. + * @return {Number} Returns the array index value of `value`, or `-1` if not present. + */ +function arraySearch(array, value) { + if (Array.prototype.indexOf) { + return array.indexOf(value, Number(arguments[2]) || 0); + } + var len = array.length >>> 0, from = Number(arguments[2]) || 0; + from = (from < 0) ? Math.ceil(from) : Math.floor(from); + + if (from < 0) from += len; + + for (; from < len; from++) { + if (from in array && array[from] === value) return from; + } + return -1; +} + +/** + * Merges a set of parameters with all parameters inherited between the common parents of the + * current state and a given destination state. + * + * @param {Object} currentParams The value of the current state parameters ($stateParams). + * @param {Object} newParams The set of parameters which will be composited with inherited params. + * @param {Object} $current Internal definition of object representing the current state. + * @param {Object} $to Internal definition of object representing state to transition to. + */ +function inheritParams(currentParams, newParams, $current, $to) { + var parents = ancestors($current, $to), parentParams, inherited = {}, inheritList = []; + + for (var i in parents) { + if (!parents[i].params || !parents[i].params.length) continue; + parentParams = parents[i].params; + + for (var j in parentParams) { + if (arraySearch(inheritList, parentParams[j]) >= 0) continue; + inheritList.push(parentParams[j]); + inherited[parentParams[j]] = currentParams[parentParams[j]]; + } + } + return extend({}, inherited, newParams); +} + +/** + * Normalizes a set of values to string or `null`, filtering them by a list of keys. + * + * @param {Array} keys The list of keys to normalize/return. + * @param {Object} values An object hash of values to normalize. + * @return {Object} Returns an object hash of normalized string values. + */ +function normalize(keys, values) { + var normalized = {}; + + forEach(keys, function (name) { + var value = values[name]; + normalized[name] = (value != null) ? String(value) : null; + }); + return normalized; +} + +/** + * Performs a non-strict comparison of the subset of two objects, defined by a list of keys. + * + * @param {Object} a The first object. + * @param {Object} b The second object. + * @param {Array} keys The list of keys within each object to compare. If the list is empty or not specified, + * it defaults to the list of keys in `a`. + * @return {Boolean} Returns `true` if the keys match, otherwise `false`. + */ +function equalForKeys(a, b, keys) { + if (!keys) { + keys = []; + for (var n in a) keys.push(n); // Used instead of Object.keys() for IE8 compatibility + } + + for (var i=0; i<keys.length; i++) { + var k = keys[i]; + if (a[k] != b[k]) return false; // Not '===', values aren't necessarily normalized + } + return true; +} + +/** + * Returns the subset of an object, based on a list of keys. + * + * @param {Array} keys + * @param {Object} values + * @return {Boolean} Returns a subset of `values`. + */ +function filterByKeys(keys, values) { + var filtered = {}; + + forEach(keys, function (name) { + filtered[name] = values[name]; + }); + return filtered; +} +/** + * @ngdoc overview + * @name ui.router.util + * + * @description + * # ui.router.util sub-module + * + * This module is a dependency of other sub-modules. Do not include this module as a dependency + * in your angular app (use {@link ui.router} module instead). + * + */ +angular.module('ui.router.util', ['ng']); + +/** + * @ngdoc overview + * @name ui.router.router + * + * @requires ui.router.util + * + * @description + * # ui.router.router sub-module + * + * This module is a dependency of other sub-modules. Do not include this module as a dependency + * in your angular app (use {@link ui.router} module instead). + */ +angular.module('ui.router.router', ['ui.router.util']); + +/** + * @ngdoc overview + * @name ui.router.state + * + * @requires ui.router.router + * @requires ui.router.util + * + * @description + * # ui.router.state sub-module + * + * This module is a dependency of the main ui.router module. Do not include this module as a dependency + * in your angular app (use {@link ui.router} module instead). + * + */ +angular.module('ui.router.state', ['ui.router.router', 'ui.router.util']); + +/** + * @ngdoc overview + * @name ui.router + * + * @requires ui.router.state + * + * @description + * # ui.router + * + * ## The main module for ui.router + * There are several sub-modules included with the ui.router module, however only this module is needed + * as a dependency within your angular app. The other modules are for organization purposes. + * + * The modules are: + * * ui.router - the main "umbrella" module + * * ui.router.router - + * + * *You'll need to include **only** this module as the dependency within your angular app.* + * + * <pre> + * <!doctype html> + * <html ng-app="myApp"> + * <head> + * <script src="js/angular.js"></script> + * <!-- Include the ui-router script --> + * <script src="js/angular-ui-router.min.js"></script> + * <script> + * // ...and add 'ui.router' as a dependency + * var myApp = angular.module('myApp', ['ui.router']); + * </script> + * </head> + * <body> + * </body> + * </html> + * </pre> + */ +angular.module('ui.router', ['ui.router.state']); + +angular.module('ui.router.compat', ['ui.router']); + +/** + * @ngdoc object + * @name ui.router.util.$resolve + * + * @requires $q + * @requires $injector + * + * @description + * Manages resolution of (acyclic) graphs of promises. + */ +$Resolve.$inject = ['$q', '$injector']; +function $Resolve( $q, $injector) { + + var VISIT_IN_PROGRESS = 1, + VISIT_DONE = 2, + NOTHING = {}, + NO_DEPENDENCIES = [], + NO_LOCALS = NOTHING, + NO_PARENT = extend($q.when(NOTHING), { $$promises: NOTHING, $$values: NOTHING }); + + + /** + * @ngdoc function + * @name ui.router.util.$resolve#study + * @methodOf ui.router.util.$resolve + * + * @description + * Studies a set of invocables that are likely to be used multiple times. + * <pre> + * $resolve.study(invocables)(locals, parent, self) + * </pre> + * is equivalent to + * <pre> + * $resolve.resolve(invocables, locals, parent, self) + * </pre> + * 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"); + + // 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, cycle.indexOf(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 = true; // keep for isResolve() + 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; + } + + // Merge parent values if the parent has already resolved, or merge + // parent promises and wait if the parent resolve is still in progress. + if (parent.$$values) { + merged = merge(values, parent.$$values); + done(); + } else { + extend(promises, parent.$$promises); + 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<ii; i+=3) { + if (locals.hasOwnProperty(plan[i])) done(); + else invoke(plan[i], plan[i+1], plan[i+2]); + } + + function invoke(key, invocable, params) { + // Create a deferred for this invocation. Failures will propagate to the resolution as well. + var invocation = $q.defer(), waitParams = 0; + function onfailure(reason) { + invocation.reject(reason); + fail(reason); + } + // Wait for any parameter that we have a promise for (either from parent or from this + // resolve; in that case study() will have made sure it's ordered before us in the plan). + forEach(params, function (dep) { + if (promises.hasOwnProperty(dep) && !locals.hasOwnProperty(dep)) { + waitParams++; + promises[dep].then(function (result) { + values[dep] = result; + if (!(--waitParams)) proceed(); + }, onfailure); + } + }); + if (!waitParams) proceed(); + function proceed() { + if (isDefined(result.$$failure)) return; + try { + invocation.resolve($injector.invoke(invocable, self, values)); + invocation.promise.then(function (result) { + values[key] = result; + done(); + }, onfailure); + } catch (e) { + onfailure(e); + } + } + // Publish promise synchronously; invocations further down in the plan may depend on it. + promises[key] = invocation.promise; + } + + return result; + }; + }; + + /** + * @ngdoc function + * @name ui.router.util.$resolve#resolve + * @methodOf ui.router.util.$resolve + * + * @description + * Resolves a set of invocables. An invocable is a function to be invoked via + * `$injector.invoke()`, and can have an arbitrary number of dependencies. + * An invocable can either return a value directly, + * or a `$q` promise. If a promise is returned it will be resolved and the + * resulting value will be used instead. Dependencies of invocables are resolved + * (in this order of precedence) + * + * - from the specified `locals` + * - from another invocable that is part of this `$resolve` call + * - from an invocable that is inherited from a `parent` call to `$resolve` + * (or recursively + * - from any ancestor `$resolve` of that parent). + * + * The return value of `$resolve` is a promise for an object that contains + * (in this order of precedence) + * + * - any `locals` (if specified) + * - the resolved return values of all injectables + * - any values inherited from a `parent` call to `$resolve` (if specified) + * + * The promise will resolve after the `parent` promise (if any) and all promises + * returned by injectables have been resolved. If any invocable + * (or `$injector.invoke`) throws an exception, or if a promise returned by an + * invocable is rejected, the `$resolve` promise is immediately rejected with the + * same error. A rejection of a `parent` promise (if specified) will likewise be + * propagated immediately. Once the `$resolve` promise has been rejected, no + * further invocables will be called. + * + * Cyclic dependencies between invocables are not permitted and will caues `$resolve` + * to throw an error. As a special case, an injectable can depend on a parameter + * with the same name as the injectable, which will be fulfilled from the `parent` + * injectable of the same name. This allows inherited values to be decorated. + * Note that in this case any other injectable in the same `$resolve` with the same + * dependency would see the decorated value, not the inherited value. + * + * Note that missing dependencies -- unlike cyclic dependencies -- will cause an + * (asynchronous) rejection of the `$resolve` promise rather than a (synchronous) + * exception. + * + * Invocables are invoked eagerly as soon as all dependencies are available. + * This is true even for dependencies inherited from a `parent` call to `$resolve`. + * + * As a special case, an invocable can be a string, in which case it is taken to + * be a service name to be passed to `$injector.get()`. This is supported primarily + * for backwards-compatibility with the `resolve` property of `$routeProvider` + * routes. + * + * @param {object} invocables functions to invoke or + * `$injector` services to fetch. + * @param {object} locals values to make available to the injectables + * @param {object} parent a promise returned by another call to `$resolve`. + * @param {object} self the `this` for the invoked methods + * @return {object} Promise for an object that contains the resolved return value + * of all invocables, as well as any inherited and local values. + */ + this.resolve = function (invocables, locals, parent, self) { + return this.study(invocables)(locals, parent, self); + }; +} + +angular.module('ui.router.util').service('$resolve', $Resolve); + + +/** + * @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.<string>} The template html as a string, or a promise + * for that string. + */ + this.fromUrl = function (url, params) { + if (isFunction(url)) url = url(params); + if (url == null) return null; + else return $http + .get(url, { cache: $templateCache }) + .then(function(response) { return response.data; }); + }; + + /** + * @ngdoc function + * @name ui.router.util.$templateFactory#fromUrl + * @methodOf ui.router.util.$templateFactory + * + * @description + * Creates a template by invoking an injectable provider function. + * + * @param {Function} provider Function to invoke via `$injector.invoke` + * @param {Object} params Parameters for the template. + * @param {Object} locals Locals to pass to `invoke`. Defaults to + * `{ params: params }`. + * @return {string|Promise.<string>} The template html as a string, or a promise + * for that string. + */ + this.fromProvider = function (provider, params, locals) { + return $injector.invoke(provider, null, locals || { params: params }); + }; +} + +angular.module('ui.router.util').service('$templateFactory', $TemplateFactory); + +/** + * @ngdoc object + * @name ui.router.util.type:UrlMatcher + * + * @description + * Matches URLs against patterns and extracts named parameters from the path or the search + * part of the URL. A URL pattern consists of a path pattern, optionally followed by '?' and a list + * of search parameters. Multiple search parameter names are separated by '&'. Search parameters + * do not influence whether or not a URL is matched, but their values are passed through into + * the matched parameters returned by {@link ui.router.util.type:UrlMatcher#methods_exec exec}. + * + * Path parameter placeholders can be specified using simple colon/catch-all syntax or curly brace + * syntax, which optionally allows a regular expression for the parameter to be specified: + * + * * `':'` name - colon placeholder + * * `'*'` name - catch-all placeholder + * * `'{' name '}'` - curly placeholder + * * `'{' name ':' regexp '}'` - curly placeholder with regexp. Should the regexp itself contain + * curly braces, they must be in matched pairs or escaped with a backslash. + * + * Parameter names may contain only word characters (latin letters, digits, and underscore) and + * must be unique within the pattern (across both path and search parameters). For colon + * placeholders or curly placeholders without an explicit regexp, a path parameter matches any + * number of characters other than '/'. For catch-all placeholders the path parameter matches + * any number of characters. + * + * Examples: + * + * * `'/hello/'` - Matches only if the path is exactly '/hello/'. There is no special treatment for + * trailing slashes, and patterns have to match the entire path, not just a prefix. + * * `'/user/:id'` - Matches '/user/bob' or '/user/1234!!!' or even '/user/' but not '/user' or + * '/user/bob/details'. The second path segment will be captured as the parameter 'id'. + * * `'/user/{id}'` - Same as the previous example, but using curly brace syntax. + * * `'/user/{id:[^/]*}'` - Same as the previous example. + * * `'/user/{id:[0-9a-fA-F]{1,8}}'` - Similar to the previous example, but only matches if the id + * parameter consists of 1 to 8 hex digits. + * * `'/files/{path:.*}'` - Matches any URL starting with '/files/' and captures the rest of the + * path into the parameter 'path'. + * * `'/files/*path'` - ditto. + * + * @param {string} pattern the pattern to compile into a matcher. + * + * @property {string} prefix A static prefix of this pattern. The matcher guarantees that any + * URL matching this matcher (i.e. any string for which {@link ui.router.util.type:UrlMatcher#methods_exec exec()} returns + * non-null) will start with this prefix. + * + * @property {string} source The pattern that was passed into the contructor + * + * @property {string} sourcePath The path portion of the source property + * + * @property {string} sourceSearch The search portion of the source property + * + * @property {string} regex The constructed regex that will be used to match against the url when + * it is time to determine which url will match. + * + * @returns {Object} New UrlMatcher object + */ +function UrlMatcher(pattern) { + + // Find all placeholders and create a compiled pattern, using either classic or curly syntax: + // '*' name + // ':' name + // '{' name '}' + // '{' name ':' regexp '}' + // The regular expression is somewhat complicated due to the need to allow curly braces + // inside the regular expression. The placeholder regexp breaks down as follows: + // ([:*])(\w+) classic placeholder ($1 / $2) + // \{(\w+)(?:\:( ... ))?\} curly brace placeholder ($3) with optional regexp ... ($4) + // (?: ... | ... | ... )+ the regexp consists of any number of atoms, an atom being either + // [^{}\\]+ - anything other than curly braces or backslash + // \\. - a backslash escape + // \{(?:[^{}\\]+|\\.)*\} - a matched set of curly braces containing other atoms + var placeholder = /([:*])(\w+)|\{(\w+)(?:\:((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g, + names = {}, compiled = '^', last = 0, m, + segments = this.segments = [], + params = this.params = []; + + function addParameter(id) { + if (!/^\w+(-+\w+)*$/.test(id)) throw new Error("Invalid parameter name '" + id + "' in pattern '" + pattern + "'"); + if (names[id]) throw new Error("Duplicate parameter name '" + id + "' in pattern '" + pattern + "'"); + names[id] = true; + params.push(id); + } + + function quoteRegExp(string) { + return string.replace(/[\\\[\]\^$*+?.()|{}]/g, "\\$&"); + } + + this.source = pattern; + + // Split into static segments separated by path parameter placeholders. + // The number of segments is always 1 more than the number of parameters. + var id, regexp, segment; + while ((m = placeholder.exec(pattern))) { + id = m[2] || m[3]; // IE[78] returns '' for unmatched groups instead of null + regexp = m[4] || (m[1] == '*' ? '.*' : '[^/]*'); + segment = pattern.substring(last, m.index); + if (segment.indexOf('?') >= 0) break; // we're into the search part + compiled += quoteRegExp(segment) + '(' + regexp + ')'; + addParameter(id); + segments.push(segment); + last = placeholder.lastIndex; + } + segment = pattern.substring(last); + + // Find any search parameter names and remove them from the last segment + var i = segment.indexOf('?'); + if (i >= 0) { + var search = this.sourceSearch = segment.substring(i); + segment = segment.substring(0, i); + this.sourcePath = pattern.substring(0, last+i); + + // Allow parameters to be separated by '?' as well as '&' to make concat() easier + forEach(search.substring(1).split(/[&?]/), addParameter); + } else { + this.sourcePath = pattern; + this.sourceSearch = ''; + } + + compiled += quoteRegExp(segment) + '$'; + segments.push(segment); + this.regexp = new RegExp(compiled); + this.prefix = segments[0]; +} + +/** + * @ngdoc function + * @name ui.router.util.type:UrlMatcher#concat + * @methodOf ui.router.util.type:UrlMatcher + * + * @description + * Returns a new matcher for a pattern constructed by appending the path part and adding the + * search parameters of the specified pattern to this pattern. The current pattern is not + * modified. This can be understood as creating a pattern for URLs that are relative to (or + * suffixes of) the current pattern. + * + * @example + * The following two matchers are equivalent: + * ``` + * new UrlMatcher('/user/{id}?q').concat('/details?date'); + * new UrlMatcher('/user/{id}/details?q&date'); + * ``` + * + * @param {string} pattern The pattern to append. + * @returns {ui.router.util.type:UrlMatcher} A matcher for the concatenated pattern. + */ +UrlMatcher.prototype.concat = function (pattern) { + // 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. + return new UrlMatcher(this.sourcePath + pattern + this.sourceSearch); +}; + +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; + + var params = this.params, nTotal = params.length, + nPath = this.segments.length-1, + values = {}, i; + + if (nPath !== m.length - 1) throw new Error("Unbalanced capture group in route '" + this.source + "'"); + + for (i=0; i<nPath; i++) values[params[i]] = m[i+1]; + for (/**/; i<nTotal; i++) values[params[i]] = searchParams[params[i]]; + + 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.<string>} An array of parameter names. Must be treated as read-only. If the + * pattern has no parameters, an empty array is returned. + */ +UrlMatcher.prototype.parameters = function () { + return this.params; +}; + +/** + * @ngdoc function + * @name ui.router.util.type:UrlMatcher#format + * @methodOf ui.router.util.type:UrlMatcher + * + * @description + * Creates a URL that matches this pattern by substituting the specified values + * for the path and search parameters. Null values for path parameters are + * treated as empty strings. + * + * @example + * ``` + * 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) { + var segments = this.segments, params = this.params; + if (!values) return segments.join(''); + + var nPath = segments.length-1, nTotal = params.length, + result = segments[0], i, search, value; + + for (i=0; i<nPath; i++) { + value = values[params[i]]; + // TODO: Maybe we should throw on null here? It's not really good style to use '' and null interchangeabley + if (value != null) result += encodeURIComponent(value); + result += segments[i+1]; + } + for (/**/; i<nTotal; i++) { + value = values[params[i]]; + if (value != null) { + result += (search ? '&' : '?') + params[i] + '=' + encodeURIComponent(value); + search = true; + } + } + + return result; +}; + + + +/** + * @ngdoc object + * @name ui.router.util.$urlMatcherFactory + * + * @description + * Factory for {@link ui.router.util.type:UrlMatcher} instances. The factory is also available to providers + * under the name `$urlMatcherFactoryProvider`. + */ +function $UrlMatcherFactory() { + + /** + * @ngdoc function + * @name ui.router.util.$urlMatcherFactory#compile + * @methodOf ui.router.util.$urlMatcherFactory + * + * @description + * Creates a {@link ui.router.util.type:UrlMatcher} for the specified pattern. + * + * @param {string} pattern The URL pattern. + * @returns {ui.router.util.type:UrlMatcher} The UrlMatcher. + */ + this.compile = function (pattern) { + return new UrlMatcher(pattern); + }; + + /** + * @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 has the following functions: `exec`, `format`, and `concat`. + */ + this.isMatcher = function (o) { + return isObject(o) && isFunction(o.exec) && isFunction(o.format) && isFunction(o.concat); + }; + + /* No need to document $get, since it returns this */ + this.$get = function () { + return this; + }; +} + +// Register as a provider so it's available to other providers +angular.module('ui.router.util').provider('$urlMatcherFactory', $UrlMatcherFactory); + +/** + * @ngdoc object + * @name ui.router.router.$urlRouterProvider + * + * @requires ui.router.util.$urlMatcherFactoryProvider + * + * @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 = ['$urlMatcherFactoryProvider']; +function $UrlRouterProvider( $urlMatcherFactory) { + var rules = [], + otherwise = null; + + // 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 + * <pre> + * 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; + * } + * }); + * }); + * </pre> + * + * @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 invalied route is requested. + * + * @example + * <pre> + * 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) { + * ... + * }); + * }); + * </pre> + * + * @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. + * + * @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 syyntax 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 + * <pre> + * 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); + * } + * }); + * }); + * </pre> + * + * @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 object + * @name ui.router.router.$urlRouter + * + * @requires $location + * @requires $rootScope + * @requires $injector + * + * @description + * + */ + this.$get = + [ '$location', '$rootScope', '$injector', + function ($location, $rootScope, $injector) { + // TODO: Optimize groups of rules with non-empty prefix into some sort of decision tree + function update(evt) { + if (evt && evt.defaultPrevented) return; + function check(rule) { + var handled = rule($injector, $location); + if (handled) { + if (isString(handled)) $location.replace().url(handled); + return true; + } + return false; + } + 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); + } + + $rootScope.$on('$locationChangeSuccess', update); + + 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 + * <pre> + * 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(); + * }); + * }); + * </pre> + */ + sync: function () { + update(); + } + }; + }]; +} + +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 + * @requires $locationProvider + * + * @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', '$locationProvider']; +function $StateProvider( $urlRouterProvider, $urlMatcherFactory, $locationProvider) { + + 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; + + if (isString(url)) { + if (url.charAt(0) == '^') { + return $urlMatcherFactory.compile(url.substring(1)); + } + return (state.parent.navigable || root).url.concat(url); + } + + if ($urlMatcherFactory.isMatcher(url) || url == null) { + 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); + }, + + // Derive parameters for this state and ensure they're a super-set of parent's parameters + params: function(state) { + if (!state.params) { + return state.url ? state.url.parameters() : state.parent.params; + } + if (!isArray(state.params)) throw new Error("Invalid params in state '" + state + "'"); + if (state.url) throw new Error("Both params and url specicified in state '" + state + "'"); + return state.params; + }, + + // 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; + }, + + ownParams: function(state) { + if (!state.parent) { + return state.params; + } + var paramNames = {}; forEach(state.params, function (p) { paramNames[p] = true; }); + + forEach(state.parent.params, function (p) { + if (!paramNames[p]) { + throw new Error("Missing required parameter '" + p + "' in state '" + state.name + "'"); + } + paramNames[p] = false; + }); + var ownParams = []; + + forEach(paramNames, function (own, p) { + if (own) ownParams.push(p); + }); + return ownParams; + }, + + // 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) { + 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 + "'"); + 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 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 + : ''; + + // 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, { location: false }); + } + }]); + } + + // Register any queued children + if (queue[name]) { + for (var i = 0; i < queue[name].length; i++) { + registerState(queue[name][i]); + } + } + + 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(segments.indexOf(globSegments[1])); + segments.unshift('**'); + } + //match greedy ends + if (globSegments[globSegments.length - 1] === '**') { + segments.splice(segments.indexOf(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} 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 + * <pre> + * // 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(view, 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. + * </pre> + * + * @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. + * + * <a id='template'></a> + * + * - **`template`** - {string|function=} - 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 + * + * <a id='templateUrl'></a> + * + * - **`templateUrl`** - {string|function=} - 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 + * + * <a id='templateProvider'></a> + * + * - **`templateProvider`** - {function=} - Provider function that returns HTML content + * string. + * + * <a id='controller'></a> + * + * - **`controller`** - {string|function=} - Controller fn that should be associated with newly + * related scope or the name of a registered controller if passed as a string. + * + * <a id='controllerProvider'></a> + * + * - **`controllerProvider`** - {function=} - Injectable provider function that returns + * the actual controller or string. + * + * <a id='controllerAs'></a> + * + * - **`controllerAs`** – {string=} – A controller alias name. If present the controller will be + * published to scope under the controllerAs name. + * + * <a id='resolve'></a> + * + * - **`resolve`** - {object.<string, function>=} - An optional map 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 or one to be rejected before the + * controller is instantiated. If all the promises are resolved successfully, the values + * of the resolved promises are injected and $stateChangeSuccess event is fired. 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. + * + * <a id='url'></a> + * + * - **`url`** - {string=} - A url with optional parameters. When a state is navigated or + * transitioned to, the `$stateParams` service will be populated with any + * parameters that were passed. + * + * <a id='params'></a> + * + * - **`params`** - {object=} - An array of parameter names or regular expressions. Only + * use this within a state if you are not using url. Otherwise you can specify your + * parameters within the url. When a state is navigated or transitioned to, the + * $stateParams service will be populated with any parameters that were passed. + * + * <a id='views'></a> + * + * - **`views`** - {object=} - Use the views property to set up multiple views or to target views + * manually/explicitly. + * + * <a id='abstract'></a> + * + * - **`abstract`** - {boolean=} - An abstract state will never be directly activated, + * but can provide inherited properties to its common children states. + * + * <a id='onEnter'></a> + * + * - **`onEnter`** - {object=} - Callback function for when a state is entered. Good way + * to trigger an action or dispatch an event, such as opening a dialog. + * + * <a id='onExit'></a> + * + * - **`onExit`** - {object=} - Callback function for when a state is exited. Good way to + * trigger an action or dispatch an event, such as opening a dialog. + * + * <a id='reloadOnSearch'></a> + * + * - **`reloadOnSearch = true`** - {boolean=} - 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. + * + * <a id='data'></a> + * + * - **`data`** - {object=} - Arbitrary data object, useful for custom configuration. + * + * @example + * <pre> + * // 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", {}); + * </pre> + * + * @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} definition State configuration object. + */ + 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 + * + * @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. + */ + // $urlRouter is injected just to ensure it gets instantiated + this.$get = $get; + $get.$inject = ['$rootScope', '$q', '$view', '$injector', '$resolve', '$stateParams', '$location', '$urlRouter', '$browser']; + function $get( $rootScope, $q, $view, $injector, $resolve, $stateParams, $location, $urlRouter, $browser) { + + 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')); + var currentLocation = $location.url(); + var baseHref = $browser.baseHref(); + + function syncUrl() { + if ($location.url() !== currentLocation) { + $location.url(currentLocation); + $location.replace(); + } + } + + 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 + * <pre> + * var app angular.module('app', ['ui.router']); + * + * app.controller('ctrl', function ($scope, $state) { + * $scope.reload = function(){ + * $state.reload(); + * } + * }); + * </pre> + * + * `reload()` is just an alias for: + * <pre> + * $state.transitionTo($state.current, $stateParams, { + * reload: true, inherit: false, notify: false + * }); + * </pre> + */ + $state.reload = function reload() { + $state.transitionTo($state.current, $stateParams, { reload: true, inherit: false, notify: false }); + }; + + /** + * @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 + * <pre> + * var app = angular.module('app', ['ui.router']); + * + * app.controller('ctrl', function ($scope, $state) { + * $scope.changeState = function () { + * $state.go('contact.detail'); + * }; + * }); + * </pre> + * <img src='../ngdoc_assets/StateGoExamples.png'/> + * + * @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 + * + * <br/>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 this.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 + * <pre> + * var app = angular.module('app', ['ui.router']); + * + * app.controller('ctrl', function ($scope, $state) { + * $scope.changeState = function () { + * $state.transitionTo('contact.detail'); + * }; + * }); + * </pre> + * + * @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)) { + // Broadcast not found event and abort the transition if prevented + var redirect = { to: to, toParams: toParams, options: 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 + * + * <pre> + * // 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 + * }) + * </pre> + */ + evt = $rootScope.$broadcast('$stateNotFound', redirect, from.self, fromParams); + if (evt.defaultPrevented) { + syncUrl(); + return TransitionAborted; + } + + // Allow the handler to return a promise to defer state lookup retry + if (evt.retry) { + if (options.$retry) { + syncUrl(); + 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; + }); + syncUrl(); + return retryTransition; + } + + // 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("Could not resolve '" + to + "' from state '" + options.relative + "'"); + throw new Error("No such state '" + to + "'"); + } + } + if (toState[abstractKey]) throw new Error("Cannot transition to abstract state '" + to + "'"); + if (options.inherit) toParams = inheritParams($stateParams, toParams || {}, $state.$current, toState); + to = toState; + + var toPath = to.path; + + // Starting from the root of the path, keep all levels that haven't changed + var keep, state, locals = root.locals, toLocals = []; + for (keep = 0, state = toPath[keep]; + state && state === fromPath[keep] && equalForKeys(toParams, fromParams, state.ownParams) && !options.reload; + keep++, state = toPath[keep]) { + locals = toLocals[keep] = state.locals; + } + + // 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 ) + syncUrl(); + $state.transition = null; + return $q.when($state.current); + } + + // Normalize/filter parameters before we pass them to event handlers etc. + toParams = normalize(to.params, 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 + * + * <pre> + * $rootScope.$on('$stateChangeStart', + * function(event, toState, toParams, fromState, fromParams){ + * event.preventDefault(); + * // transitionTo() promise will be rejected with + * // a 'transition prevented' error + * }) + * </pre> + */ + evt = $rootScope.$broadcast('$stateChangeStart', to.self, toParams, from.self, fromParams); + if (evt.defaultPrevented) { + syncUrl(); + 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); + } + + // 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; + + // Update $location + var toNav = to.navigable; + if (options.location && toNav) { + $location.url(toNav.url.format(toNav.locals.globals.$stateParams)); + + if (options.location === 'replace') { + $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); + } + currentLocation = $location.url(); + + 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. + */ + $rootScope.$broadcast('$stateChangeError', to.self, toParams, from.self, fromParams, error); + syncUrl(); + + 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 + * <pre> + * $state.is('contact.details.item'); // returns true + * $state.is(contactDetailItemStateObject); // returns true + * + * // everything else would return false + * </pre> + * + * @param {string|object} stateName The state name 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. + * @returns {boolean} Returns true if it is the state. + */ + $state.is = function is(stateOrName, params) { + var state = findState(stateOrName); + + if (!isDefined(state)) { + return undefined; + } + + if ($state.$current !== state) { + return false; + } + + return isDefined(params) && params !== null ? angular.equals($stateParams, params) : 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 + * <pre> + * $state.$current.name = 'contacts.details.item'; + * + * $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 + * </pre> + * + * @description + * Basic globing patterns will also work. + * + * @example + * <pre> + * $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 + * </pre> + * + * @param {string} stateOrName A partial name 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. + * @returns {boolean} Returns true if it does include the state + */ + + $state.includes = function includes(stateOrName, params) { + if (isString(stateOrName) && isGlob(stateOrName)) { + if (doesStateMatchGlob(stateOrName)) { + stateOrName = $state.$current.name; + } else { + return false; + } + } + + var state = findState(stateOrName); + if (!isDefined(state)) { + return undefined; + } + + if (!isDefined($state.$current.includes[state.name])) { + return false; + } + + var validParams = true; + angular.forEach(params, function(value, key) { + if (!isDefined($stateParams[key]) || $stateParams[key] !== value) { + validParams = false; + } + }); + return validParams; + }; + + + /** + * @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 + * <pre> + * expect($state.href("about.person", { person: "bob" })).toEqual("/about/bob"); + * </pre> + * + * @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=false}, 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: false, absolute: false, relative: $state.$current }, options || {}); + var state = findState(stateOrName, options.relative); + if (!isDefined(state)) return null; + + params = inheritParams($stateParams, params || {}, $state.$current, state); + var nav = (state && options.lossy) ? state.navigable : state; + var url = (nav && nav.url) ? nav.url.format(normalize(state.params, params || {})) : null; + if (!$locationProvider.html5Mode() && url) { + url = "#" + $locationProvider.hashPrefix() + url; + } + + if (baseHref !== '/') { + if ($locationProvider.html5Mode()) { + url = baseHref.slice(0, -1) + url; + } else if (options.absolute){ + url = baseHref.slice(1) + url; + } + } + + if (options.absolute && url) { + url = $location.protocol() + '://' + + $location.host() + + ($location.port() == 80 || $location.port() == 443 ? '' : ':' + $location.port()) + + (!$locationProvider.html5Mode() && url ? '/' : '') + + url; + } + return url; + }; + + /** + * @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 If provided, will only get the config for + * the requested state. If not provided, returns an array of ALL state configs. + * @returns {object|array} State configuration object or array of all objects. + */ + $state.get = function (stateOrName, context) { + if (!isDefined(stateOrName)) { + var list = []; + forEach(states, function(state) { list.push(state.self); }); + return list; + } + var state = findState(stateOrName, context); + return (state && state.self) ? state.self : null; + }; + + function resolveState(state, params, paramsAreFiltered, inherited, dst) { + // 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, 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: false }) || ''; + }]; + + 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 + * + * <pre> + * $scope.$on('$viewContentLoading', + * function(event, viewConfig){ + * // Access to all the view config properties. + * // and one special property 'targetView' + * // viewConfig.targetView + * }); + * </pre> + */ + $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=} ui-view 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. + * <pre> + * <!-- Unnamed --> + * <div ui-view></div> + * + * <!-- Named --> + * <div ui-view="viewName"></div> + * </pre> + * + * 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: + * <pre> + * <div ui-view></div> + * $stateProvider.state("home", { + * template: "<h1>HELLO!</h1>" + * }) + * </pre> + * + * 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: + * <pre> + * $stateProvider.state("home", { + * views: { + * "": { + * template: "<h1>HELLO!</h1>" + * } + * } + * }) + * </pre> + * + * 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: + * <pre> + * <div ui-view="main"></div> + * </pre> + * <pre> + * $stateProvider.state("home", { + * views: { + * "main": { + * template: "<h1>HELLO!</h1>" + * } + * } + * }) + * </pre> + * + * Really though, you'll use views to set up multiple views: + * <pre> + * <div ui-view></div> + * <div ui-view="chart"></div> + * <div ui-view="data"></div> + * </pre> + * + * <pre> + * $stateProvider.state("home", { + * views: { + * "": { + * template: "<h1>HELLO!</h1>" + * }, + * "chart": { + * template: "<chart_thing/>" + * }, + * "data": { + * template: "<data_thing/>" + * } + * } + * }) + * </pre> + * + * Examples for `autoscroll`: + * + * <pre> + * <!-- If autoscroll present with no expression, + * then scroll ui-view into view --> + * <ui-view autoscroll/> + * + * <!-- If autoscroll present with valid expression, + * then scroll ui-view into view if expression evaluates to true --> + * <ui-view autoscroll='true'/> + * <ui-view autoscroll='false'/> + * <ui-view autoscroll='scopeVariable'/> + * </pre> + */ +$ViewDirective.$inject = ['$state', '$injector', '$uiViewScroll']; +function $ViewDirective( $state, $injector, $uiViewScroll) { + + 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) { $animate.enter(element, null, target, cb); }, + leave: function(element, cb) { $animate.leave(element, 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 = scope.$new(), + name = currentEl && currentEl.data('$uiViewName'), + previousLocals = name && $state.$current && $state.$current.locals[name]; + + if (!firstTime && previousLocals === latestLocals) return; // nothing to do + + var clone = $transclude(newScope, function(clone) { + renderer.enter(clone, $element, function onUiViewEnter() { + if (angular.isDefined(autoScrollExp) && !autoScrollExp || scope.$eval(autoScrollExp)) { + $uiViewScroll(clone); + } + }); + cleanupLastView(); + }); + + latestLocals = $state.$current.locals[clone.data('$uiViewName')]; + + 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']; +function $ViewDirectiveFill ($compile, $controller, $state) { + return { + restrict: 'ECA', + priority: -400, + compile: function (tElement) { + var initial = tElement.html(); + return function (scope, $element, attrs) { + var name = attrs.uiView || attrs.name || '', + inherited = $element.inheritedData('$uiView'); + + if (name.indexOf('@') < 0) { + name = name + '@' + (inherited ? inherited.state.name : ''); + } + + $element.data('$uiViewName', name); + + var current = $state.$current, + 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); + }; + } + }; +} + +angular.module('ui.router.state').directive('uiView', $ViewDirective); +angular.module('ui.router.state').directive('uiView', $ViewDirectiveFill); + +function parseStateRef(ref) { + var 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 (`<a>` 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: + * <pre> + * <a ui-sref="home">Home</a> | <a ui-sref="about">About</a> + * + * <ul> + * <li ng-repeat="contact in contacts"> + * <a ui-sref="contacts.detail({ id: contact.id })">{{ contact.name }}</a> + * </li> + * </ul> + * </pre> + * + * Then the compiled html would be (assuming Html5Mode is off): + * <pre> + * <a href="#/home" ui-sref="home">Home</a> | <a href="#/about" ui-sref="about">About</a> + * + * <ul> + * <li ng-repeat="contact in contacts"> + * <a href="#/contacts/1" ui-sref="contacts.detail({ id: contact.id })">Joe</a> + * </li> + * <li ng-repeat="contact in contacts"> + * <a href="#/contacts/2" ui-sref="contacts.detail({ id: contact.id })">Alice</a> + * </li> + * <li ng-repeat="contact in contacts"> + * <a href="#/contacts/3" ui-sref="contacts.detail({ id: contact.id })">Bob</a> + * </li> + * </ul> + * + * <a ui-sref="home" ui-sref-opts="{reload: true}">Home</a> + * </pre> + * + * @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', + link: function(scope, element, attrs, uiSrefActive) { + var ref = parseStateRef(attrs.uiSref); + var params = null, url = null, base = stateContext(element) || $state.$current; + var isForm = element[0].nodeName === "FORM"; + var attr = isForm ? "action" : "href", nav = true; + + var options = { + relative: base + }; + 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 = newVal; + if (!nav) return; + + var newHref = $state.href(ref.state, params, options); + + if (uiSrefActive) { + uiSrefActive.$$setStateInfo(ref.state, params); + } + if (!newHref) { + nav = false; + return false; + } + element[0][attr] = newHref; + }; + + if (ref.paramExpr) { + scope.$watch(ref.paramExpr, function(newVal, oldVal) { + if (newVal !== params) update(newVal); + }, true); + params = 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: + $timeout(function() { + $state.go(ref.state, params, options); + }); + e.preventDefault(); + } + }); + } + }; +} + +/** + * @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. + * + * @example + * Given the following template: + * <pre> + * <ul> + * <li ui-sref-active="active" class="item"> + * <a href ui-sref="app.user({user: 'bilbobaggins'})">@bilbobaggins</a> + * </li> + * </ul> + * </pre> + * + * When the app state is "app.user", and contains the state parameter "user" with value "bilbobaggins", + * the resulting HTML will appear as (note the 'active' class): + * <pre> + * <ul> + * <li ui-sref-active="active" class="item active"> + * <a ui-sref="app.user({user: 'bilbobaggins'})" href="/users/bilbobaggins">@bilbobaggins</a> + * </li> + * </ul> + * </pre> + * + * 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: + * <pre> + * <ul> + * <li ui-sref-active='class1 class2 class3'> + * <a ui-sref="app.user">link</a> + * </li> + * </ul> + * </pre> + */ +$StateActiveDirective.$inject = ['$state', '$stateParams', '$interpolate']; +function $StateActiveDirective($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 + activeClass = $interpolate($attrs.uiSrefActive || '', false)($scope); + + // Allow uiSref to communicate with uiSrefActive + this.$$setStateInfo = function(newState, newParams) { + state = $state.get(newState, stateContext($element)); + params = newParams; + update(); + }; + + $scope.$on('$stateChangeSuccess', update); + + // Update route state + function update() { + if ($state.$current.self === state && matchesParams()) { + $element.addClass(activeClass); + } else { + $element.removeClass(activeClass); + } + } + + function matchesParams() { + return !params || equalForKeys(params, $stateParams); + } + }] + }; +} + +angular.module('ui.router.state') + .directive('uiSref', $StateRefDirective) + .directive('uiSrefActive', $StateActiveDirective); + +/** + * @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) { + return function(state) { + return $state.is(state); + }; +} + +/** + * @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) { + return function(state) { + return $state.includes(state); + }; +} + +angular.module('ui.router.state') + .filter('isState', $IsStateFilter) + .filter('includedByState', $IncludedByStateFilter); + +/* + * @ngdoc object + * @name ui.router.compat.$routeProvider + * + * @requires ui.router.state.$stateProvider + * @requires ui.router.router.$urlRouterProvider + * + * @description + * `$routeProvider` of the `ui.router.compat` module overwrites the existing + * `routeProvider` from the core. This is done to provide compatibility between + * the UI Router and the core router. + * + * It also provides a `when()` method to register routes that map to certain urls. + * Behind the scenes it actually delegates either to + * {@link ui.router.router.$urlRouterProvider $urlRouterProvider} or to the + * {@link ui.router.state.$stateProvider $stateProvider} to postprocess the given + * router definition object. + */ +$RouteProvider.$inject = ['$stateProvider', '$urlRouterProvider']; +function $RouteProvider( $stateProvider, $urlRouterProvider) { + + var routes = []; + + onEnterRoute.$inject = ['$$state']; + function onEnterRoute( $$state) { + /*jshint validthis: true */ + this.locals = $$state.locals.globals; + this.params = this.locals.$stateParams; + } + + function onExitRoute() { + /*jshint validthis: true */ + this.locals = null; + this.params = null; + } + + this.when = when; + /* + * @ngdoc function + * @name ui.router.compat.$routeProvider#when + * @methodOf ui.router.compat.$routeProvider + * + * @description + * Registers a route with a given route definition object. The route definition + * object has the same interface the angular core route definition object has. + * + * @example + * <pre> + * var app = angular.module('app', ['ui.router.compat']); + * + * app.config(function ($routeProvider) { + * $routeProvider.when('home', { + * controller: function () { ... }, + * templateUrl: 'path/to/template' + * }); + * }); + * </pre> + * + * @param {string} url URL as string + * @param {object} route Route definition object + * + * @return {object} $routeProvider - $routeProvider instance + */ + function when(url, route) { + /*jshint validthis: true */ + if (route.redirectTo != null) { + // Redirect, configure directly on $urlRouterProvider + var redirect = route.redirectTo, handler; + if (isString(redirect)) { + handler = redirect; // leave $urlRouterProvider to handle + } else if (isFunction(redirect)) { + // Adapt to $urlRouterProvider API + handler = function (params, $location) { + return redirect(params, $location.path(), $location.search()); + }; + } else { + throw new Error("Invalid 'redirectTo' in when()"); + } + $urlRouterProvider.when(url, handler); + } else { + // Regular route, configure as state + $stateProvider.state(inherit(route, { + parent: null, + name: 'route:' + encodeURIComponent(url), + url: url, + onEnter: onEnterRoute, + onExit: onExitRoute + })); + } + routes.push(route); + return this; + } + + /* + * @ngdoc object + * @name ui.router.compat.$route + * + * @requires ui.router.state.$state + * @requires $rootScope + * @requires $routeParams + * + * @property {object} routes - Array of registered routes. + * @property {object} params - Current route params as object. + * @property {string} current - Name of the current route. + * + * @description + * The `$route` service provides interfaces to access defined routes. It also let's + * you access route params through `$routeParams` service, so you have fully + * control over all the stuff you would actually get from angular's core `$route` + * service. + */ + this.$get = $get; + $get.$inject = ['$state', '$rootScope', '$routeParams']; + function $get( $state, $rootScope, $routeParams) { + + var $route = { + routes: routes, + params: $routeParams, + current: undefined + }; + + function stateAsRoute(state) { + return (state.name !== '') ? state : undefined; + } + + $rootScope.$on('$stateChangeStart', function (ev, to, toParams, from, fromParams) { + $rootScope.$broadcast('$routeChangeStart', stateAsRoute(to), stateAsRoute(from)); + }); + + $rootScope.$on('$stateChangeSuccess', function (ev, to, toParams, from, fromParams) { + $route.current = stateAsRoute(to); + $rootScope.$broadcast('$routeChangeSuccess', stateAsRoute(to), stateAsRoute(from)); + copy(toParams, $route.params); + }); + + $rootScope.$on('$stateChangeError', function (ev, to, toParams, from, fromParams, error) { + $rootScope.$broadcast('$routeChangeError', stateAsRoute(to), stateAsRoute(from), error); + }); + + return $route; + } +} + +angular.module('ui.router.compat') + .provider('$route', $RouteProvider) + .directive('ngView', $ViewDirective); +})(window, window.angular); +\ No newline at end of file diff --git a/src/main/webapp/vendor/underscore.min.js b/src/main/webapp/vendor/underscore.min.js @@ -0,0 +1,5 @@ +// Underscore.js 1.6.0 +// http://underscorejs.org +// (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors +// Underscore may be freely distributed under the MIT license. +(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,h=e.reduce,v=e.reduceRight,g=e.filter,d=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,w=Object.keys,_=i.bind,j=function(n){return n instanceof j?n:this instanceof j?void(this._wrapped=n):new j(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=j),exports._=j):n._=j,j.VERSION="1.6.0";var A=j.each=j.forEach=function(n,t,e){if(null==n)return n;if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a=j.keys(n),u=0,i=a.length;i>u;u++)if(t.call(e,n[a[u]],a[u],n)===r)return;return n};j.map=j.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e.push(t.call(r,n,u,i))}),e)};var O="Reduce of empty array with no initial value";j.reduce=j.foldl=j.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduce===h)return e&&(t=j.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(O);return r},j.reduceRight=j.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduceRight===v)return e&&(t=j.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=j.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(O);return r},j.find=j.detect=function(n,t,r){var e;return k(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},j.filter=j.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&e.push(n)}),e)},j.reject=function(n,t,r){return j.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},j.every=j.all=function(n,t,e){t||(t=j.identity);var u=!0;return null==n?u:d&&n.every===d?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var k=j.some=j.any=function(n,t,e){t||(t=j.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};j.contains=j.include=function(n,t){return null==n?!1:y&&n.indexOf===y?n.indexOf(t)!=-1:k(n,function(n){return n===t})},j.invoke=function(n,t){var r=o.call(arguments,2),e=j.isFunction(t);return j.map(n,function(n){return(e?t:n[t]).apply(n,r)})},j.pluck=function(n,t){return j.map(n,j.property(t))},j.where=function(n,t){return j.filter(n,j.matches(t))},j.findWhere=function(n,t){return j.find(n,j.matches(t))},j.max=function(n,t,r){if(!t&&j.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.max.apply(Math,n);var e=-1/0,u=-1/0;return A(n,function(n,i,a){var o=t?t.call(r,n,i,a):n;o>u&&(e=n,u=o)}),e},j.min=function(n,t,r){if(!t&&j.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.min.apply(Math,n);var e=1/0,u=1/0;return A(n,function(n,i,a){var o=t?t.call(r,n,i,a):n;u>o&&(e=n,u=o)}),e},j.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=j.random(r++),e[r-1]=e[t],e[t]=n}),e},j.sample=function(n,t,r){return null==t||r?(n.length!==+n.length&&(n=j.values(n)),n[j.random(n.length-1)]):j.shuffle(n).slice(0,Math.max(0,t))};var E=function(n){return null==n?j.identity:j.isFunction(n)?n:j.property(n)};j.sortBy=function(n,t,r){return t=E(t),j.pluck(j.map(n,function(n,e,u){return{value:n,index:e,criteria:t.call(r,n,e,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index-t.index}),"value")};var F=function(n){return function(t,r,e){var u={};return r=E(r),A(t,function(i,a){var o=r.call(e,i,a,t);n(u,o,i)}),u}};j.groupBy=F(function(n,t,r){j.has(n,t)?n[t].push(r):n[t]=[r]}),j.indexBy=F(function(n,t,r){n[t]=r}),j.countBy=F(function(n,t){j.has(n,t)?n[t]++:n[t]=1}),j.sortedIndex=function(n,t,r,e){r=E(r);for(var u=r.call(e,t),i=0,a=n.length;a>i;){var o=i+a>>>1;r.call(e,n[o])<u?i=o+1:a=o}return i},j.toArray=function(n){return n?j.isArray(n)?o.call(n):n.length===+n.length?j.map(n,j.identity):j.values(n):[]},j.size=function(n){return null==n?0:n.length===+n.length?n.length:j.keys(n).length},j.first=j.head=j.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:0>t?[]:o.call(n,0,t)},j.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},j.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},j.rest=j.tail=j.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},j.compact=function(n){return j.filter(n,j.identity)};var M=function(n,t,r){return t&&j.every(n,j.isArray)?c.apply(r,n):(A(n,function(n){j.isArray(n)||j.isArguments(n)?t?a.apply(r,n):M(n,t,r):r.push(n)}),r)};j.flatten=function(n,t){return M(n,t,[])},j.without=function(n){return j.difference(n,o.call(arguments,1))},j.partition=function(n,t){var r=[],e=[];return A(n,function(n){(t(n)?r:e).push(n)}),[r,e]},j.uniq=j.unique=function(n,t,r,e){j.isFunction(t)&&(e=r,r=t,t=!1);var u=r?j.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:j.contains(a,r))||(a.push(r),i.push(n[e]))}),i},j.union=function(){return j.uniq(j.flatten(arguments,!0))},j.intersection=function(n){var t=o.call(arguments,1);return j.filter(j.uniq(n),function(n){return j.every(t,function(t){return j.contains(t,n)})})},j.difference=function(n){var t=c.apply(e,o.call(arguments,1));return j.filter(n,function(n){return!j.contains(t,n)})},j.zip=function(){for(var n=j.max(j.pluck(arguments,"length").concat(0)),t=new Array(n),r=0;n>r;r++)t[r]=j.pluck(arguments,""+r);return t},j.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},j.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=j.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},j.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},j.range=function(n,t,r){arguments.length<=1&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=new Array(e);e>u;)i[u++]=n,n+=r;return i};var R=function(){};j.bind=function(n,t){var r,e;if(_&&n.bind===_)return _.apply(n,o.call(arguments,1));if(!j.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));R.prototype=n.prototype;var u=new R;R.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},j.partial=function(n){var t=o.call(arguments,1);return function(){for(var r=0,e=t.slice(),u=0,i=e.length;i>u;u++)e[u]===j&&(e[u]=arguments[r++]);for(;r<arguments.length;)e.push(arguments[r++]);return n.apply(this,e)}},j.bindAll=function(n){var t=o.call(arguments,1);if(0===t.length)throw new Error("bindAll must be passed function names");return A(t,function(t){n[t]=j.bind(n[t],n)}),n},j.memoize=function(n,t){var r={};return t||(t=j.identity),function(){var e=t.apply(this,arguments);return j.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},j.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},j.defer=function(n){return j.delay.apply(j,[n,1].concat(o.call(arguments,1)))},j.throttle=function(n,t,r){var e,u,i,a=null,o=0;r||(r={});var c=function(){o=r.leading===!1?0:j.now(),a=null,i=n.apply(e,u),e=u=null};return function(){var l=j.now();o||r.leading!==!1||(o=l);var f=t-(l-o);return e=this,u=arguments,0>=f?(clearTimeout(a),a=null,o=l,i=n.apply(e,u),e=u=null):a||r.trailing===!1||(a=setTimeout(c,f)),i}},j.debounce=function(n,t,r){var e,u,i,a,o,c=function(){var l=j.now()-a;t>l?e=setTimeout(c,t-l):(e=null,r||(o=n.apply(i,u),i=u=null))};return function(){i=this,u=arguments,a=j.now();var l=r&&!e;return e||(e=setTimeout(c,t)),l&&(o=n.apply(i,u),i=u=null),o}},j.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},j.wrap=function(n,t){return j.partial(t,n)},j.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},j.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},j.keys=function(n){if(!j.isObject(n))return[];if(w)return w(n);var t=[];for(var r in n)j.has(n,r)&&t.push(r);return t},j.values=function(n){for(var t=j.keys(n),r=t.length,e=new Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},j.pairs=function(n){for(var t=j.keys(n),r=t.length,e=new Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},j.invert=function(n){for(var t={},r=j.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},j.functions=j.methods=function(n){var t=[];for(var r in n)j.isFunction(n[r])&&t.push(r);return t.sort()},j.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},j.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},j.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)j.contains(r,u)||(t[u]=n[u]);return t},j.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]===void 0&&(n[r]=t[r])}),n},j.clone=function(n){return j.isObject(n)?j.isArray(n)?n.slice():j.extend({},n):n},j.tap=function(n,t){return t(n),n};var S=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof j&&(n=n._wrapped),t instanceof j&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==String(t);case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;var a=n.constructor,o=t.constructor;if(a!==o&&!(j.isFunction(a)&&a instanceof a&&j.isFunction(o)&&o instanceof o)&&"constructor"in n&&"constructor"in t)return!1;r.push(n),e.push(t);var c=0,f=!0;if("[object Array]"==u){if(c=n.length,f=c==t.length)for(;c--&&(f=S(n[c],t[c],r,e)););}else{for(var s in n)if(j.has(n,s)&&(c++,!(f=j.has(t,s)&&S(n[s],t[s],r,e))))break;if(f){for(s in t)if(j.has(t,s)&&!c--)break;f=!c}}return r.pop(),e.pop(),f};j.isEqual=function(n,t){return S(n,t,[],[])},j.isEmpty=function(n){if(null==n)return!0;if(j.isArray(n)||j.isString(n))return 0===n.length;for(var t in n)if(j.has(n,t))return!1;return!0},j.isElement=function(n){return!(!n||1!==n.nodeType)},j.isArray=x||function(n){return"[object Array]"==l.call(n)},j.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){j["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),j.isArguments(arguments)||(j.isArguments=function(n){return!(!n||!j.has(n,"callee"))}),"function"!=typeof/./&&(j.isFunction=function(n){return"function"==typeof n}),j.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},j.isNaN=function(n){return j.isNumber(n)&&n!=+n},j.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},j.isNull=function(n){return null===n},j.isUndefined=function(n){return n===void 0},j.has=function(n,t){return f.call(n,t)},j.noConflict=function(){return n._=t,this},j.identity=function(n){return n},j.constant=function(n){return function(){return n}},j.property=function(n){return function(t){return t[n]}},j.matches=function(n){return function(t){if(t===n)return!0;for(var r in n)if(n[r]!==t[r])return!1;return!0}},j.times=function(n,t,r){for(var e=Array(Math.max(0,n)),u=0;n>u;u++)e[u]=t.call(r,u);return e},j.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))},j.now=Date.now||function(){return(new Date).getTime()};var T={escape:{"&":"&","<":"<",">":">",'"':""","'":"'"}};T.unescape=j.invert(T.escape);var I={escape:new RegExp("["+j.keys(T.escape).join("")+"]","g"),unescape:new RegExp("("+j.keys(T.unescape).join("|")+")","g")};j.each(["escape","unescape"],function(n){j[n]=function(t){return null==t?"":(""+t).replace(I[n],function(t){return T[n][t]})}}),j.result=function(n,t){if(null==n)return void 0;var r=n[t];return j.isFunction(r)?r.call(n):r},j.mixin=function(n){A(j.functions(n),function(t){var r=j[t]=n[t];j.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),z.call(this,r.apply(j,n))}})};var N=0;j.uniqueId=function(n){var t=++N+"";return n?n+t:t},j.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;j.template=function(n,t,r){var e;r=j.defaults({},r,j.templateSettings);var u=new RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(D,function(n){return"\\"+B[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=new Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,j);var c=function(n){return e.call(this,n,j)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},j.chain=function(n){return j(n).chain()};var z=function(n){return this._chain?j(n).chain():n};j.mixin(j),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];j.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],z.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];j.prototype[n]=function(){return z.call(this,t.apply(this._wrapped,arguments))}}),j.extend(j.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}}),"function"==typeof define&&define.amd&&define("underscore",[],function(){return j})}).call(this); +\ No newline at end of file