kms 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/kms/application.js +1 -0
  3. data/app/assets/javascripts/kms/application/controllers/assets_controller.coffee.erb +14 -4
  4. data/app/assets/javascripts/kms/application/controllers/pages_controller.coffee.erb +12 -2
  5. data/app/assets/javascripts/kms/application/controllers/snippets_controller.coffee.erb +13 -3
  6. data/app/assets/javascripts/kms/application/controllers/templates_controller.coffee.erb +13 -3
  7. data/app/assets/javascripts/kms/application/controllers/users_controller.coffee +5 -5
  8. data/app/assets/javascripts/kms/application/module.coffee +6 -2
  9. data/app/assets/javascripts/kms/application/routes.coffee.erb +10 -0
  10. data/app/assets/javascripts/templates/assets/edit.html.slim +2 -1
  11. data/app/assets/javascripts/templates/assets/form.html.slim +1 -1
  12. data/app/assets/javascripts/templates/pages/edit.html.slim +1 -0
  13. data/app/assets/javascripts/templates/shared/hotkey_notification.html.slim +6 -0
  14. data/app/assets/javascripts/templates/snippets/edit.html.slim +1 -0
  15. data/app/assets/javascripts/templates/templates/edit.html.slim +1 -0
  16. data/app/assets/javascripts/templates/users/edit.html.slim +5 -0
  17. data/app/assets/javascripts/templates/users/form.html.slim +3 -2
  18. data/app/assets/javascripts/templates/users/index.html.slim +2 -1
  19. data/app/assets/stylesheets/kms/custom.css.scss +10 -0
  20. data/app/controllers/kms/assets_controller.rb +6 -3
  21. data/app/controllers/kms/users_controller.rb +14 -0
  22. data/app/services/kms/resource_service.rb +3 -1
  23. data/app/views/layouts/kms/kms.html.erb +1 -1
  24. data/config/initializers/devise.rb +9 -0
  25. data/config/locales/en.yml +12 -0
  26. data/config/locales/ru.yml +12 -0
  27. data/config/routes.rb +1 -1
  28. data/lib/kms/engine.rb +1 -1
  29. data/lib/kms/version.rb +1 -1
  30. data/spec/controllers/kms/assets_controller_spec.rb +28 -10
  31. data/spec/controllers/kms/users_controller_spec.rb +23 -0
  32. data/spec/internal/config/routes.rb +1 -1
  33. data/spec/internal/log/test.log +0 -105823
  34. data/vendor/assets/bower.json +5 -4
  35. data/vendor/assets/bower_components/angular-cookies/angular-cookies.js +22 -18
  36. data/vendor/assets/bower_components/angular-cookies/angular-cookies.min.js +4 -4
  37. data/vendor/assets/bower_components/angular-cookies/angular-cookies.min.js.map +2 -2
  38. data/vendor/assets/bower_components/angular-cookies/bower.json +2 -2
  39. data/vendor/assets/bower_components/angular-cookies/package.json +1 -1
  40. data/vendor/assets/bower_components/angular-hotkeys/Gruntfile.js +118 -0
  41. data/vendor/assets/bower_components/angular-hotkeys/LICENSE +20 -0
  42. data/vendor/assets/bower_components/angular-hotkeys/README.md +248 -0
  43. data/vendor/assets/bower_components/angular-hotkeys/bower.json +19 -0
  44. data/vendor/assets/bower_components/angular-hotkeys/build/hotkeys.css +110 -0
  45. data/vendor/assets/bower_components/angular-hotkeys/build/hotkeys.js +1661 -0
  46. data/vendor/assets/bower_components/angular-hotkeys/build/hotkeys.min.css +1 -0
  47. data/vendor/assets/bower_components/angular-hotkeys/build/hotkeys.min.js +7 -0
  48. data/vendor/assets/bower_components/angular-hotkeys/package.json +45 -0
  49. data/vendor/assets/bower_components/angular-hotkeys/src/hotkeys.css +104 -0
  50. data/vendor/assets/bower_components/angular-hotkeys/src/hotkeys.js +633 -0
  51. data/vendor/assets/bower_components/angular-loading-bar/CHANGELOG.md +33 -0
  52. data/vendor/assets/bower_components/angular-loading-bar/CONTRIBUTING.md +17 -0
  53. data/vendor/assets/bower_components/angular-loading-bar/Gruntfile.js +9 -1
  54. data/vendor/assets/bower_components/angular-loading-bar/ISSUE_TEMPLATE.md +14 -0
  55. data/vendor/assets/bower_components/angular-loading-bar/PULL_REQUEST_TEMPLATE.md +13 -0
  56. data/vendor/assets/bower_components/angular-loading-bar/README.md +30 -3
  57. data/vendor/assets/bower_components/angular-loading-bar/bower.json +11 -6
  58. data/vendor/assets/bower_components/angular-loading-bar/build/loading-bar.css +5 -5
  59. data/vendor/assets/bower_components/angular-loading-bar/build/loading-bar.js +39 -12
  60. data/vendor/assets/bower_components/angular-loading-bar/build/loading-bar.min.css +1 -8
  61. data/vendor/assets/bower_components/angular-loading-bar/build/loading-bar.min.js +3 -3
  62. data/vendor/assets/bower_components/angular-loading-bar/index.js +2 -0
  63. data/vendor/assets/bower_components/angular-loading-bar/package.json +12 -15
  64. data/vendor/assets/bower_components/angular-loading-bar/src/loading-bar.css +3 -3
  65. data/vendor/assets/bower_components/angular-loading-bar/src/loading-bar.js +37 -10
  66. data/vendor/assets/bower_components/angular-sanitize/angular-sanitize.js +504 -386
  67. data/vendor/assets/bower_components/angular-sanitize/angular-sanitize.min.js +13 -12
  68. data/vendor/assets/bower_components/angular-sanitize/angular-sanitize.min.js.map +3 -3
  69. data/vendor/assets/bower_components/angular-sanitize/bower.json +2 -2
  70. data/vendor/assets/bower_components/angular-sanitize/package.json +1 -1
  71. data/vendor/assets/bower_components/angular-ui-router/CHANGELOG.md +1410 -0
  72. data/vendor/assets/bower_components/angular-ui-router/CONTRIBUTING.md +64 -16
  73. data/vendor/assets/bower_components/angular-ui-router/DOCS.md +48 -0
  74. data/vendor/assets/bower_components/angular-ui-router/ISSUE_TEMPLATE.md +53 -0
  75. data/vendor/assets/bower_components/angular-ui-router/LICENSE +1 -1
  76. data/vendor/assets/bower_components/angular-ui-router/README.md +24 -211
  77. data/vendor/assets/bower_components/angular-ui-router/artifacts.json +8 -0
  78. data/vendor/assets/bower_components/angular-ui-router/bower.json +1 -23
  79. data/vendor/assets/bower_components/angular-ui-router/karma.conf.js +105 -0
  80. data/vendor/assets/bower_components/angular-ui-router/release/angular-ui-router.js +9744 -3901
  81. data/vendor/assets/bower_components/angular-ui-router/release/angular-ui-router.js.map +192 -0
  82. data/vendor/assets/bower_components/angular-ui-router/release/angular-ui-router.min.js +9 -4
  83. data/vendor/assets/bower_components/angular-ui-router/release/angular-ui-router.min.js.map +1679 -0
  84. data/vendor/assets/bower_components/angular-ui-router/release/resolveService.js +83 -0
  85. data/vendor/assets/bower_components/angular-ui-router/release/resolveService.js.map +19 -0
  86. data/vendor/assets/bower_components/angular-ui-router/release/resolveService.min.js +8 -0
  87. data/vendor/assets/bower_components/angular-ui-router/release/resolveService.min.js.map +47 -0
  88. data/vendor/assets/bower_components/angular-ui-router/release/stateEvents.js +294 -0
  89. data/vendor/assets/bower_components/angular-ui-router/release/stateEvents.js.map +17 -0
  90. data/vendor/assets/bower_components/angular-ui-router/release/stateEvents.min.js +8 -0
  91. data/vendor/assets/bower_components/angular-ui-router/release/stateEvents.min.js.map +102 -0
  92. data/vendor/assets/bower_components/angular-ui-router/release/ui-router-angularjs.js +2014 -0
  93. data/vendor/assets/bower_components/angular-ui-router/release/ui-router-angularjs.js.map +70 -0
  94. data/vendor/assets/bower_components/angular-ui-router/release/ui-router-angularjs.min.js +9 -0
  95. data/vendor/assets/bower_components/angular-ui-router/release/ui-router-angularjs.min.js.map +541 -0
  96. data/vendor/assets/bower_components/angular-ui-router/rollup.config.js +116 -0
  97. data/vendor/assets/bower_components/angular-ui-router/tslint.json +60 -0
  98. data/vendor/assets/bower_components/angular-ui-router/yarn.lock +4146 -0
  99. data/vendor/assets/bower_components/angular-ui-tree/yarn.lock +4945 -0
  100. data/vendor/assets/bower_components/angular/angular.js +4019 -2449
  101. data/vendor/assets/bower_components/angular/angular.min.js +331 -319
  102. data/vendor/assets/bower_components/angular/angular.min.js.gzip +0 -0
  103. data/vendor/assets/bower_components/angular/angular.min.js.map +3 -3
  104. data/vendor/assets/bower_components/angular/bower.json +1 -1
  105. data/vendor/assets/bower_components/angular/package.json +1 -1
  106. data/vendor/assets/bower_components/angularjs-dropdown-multiselect/LICENSE +21 -0
  107. data/vendor/assets/bower_components/angularjs-dropdown-multiselect/README.md +14 -14
  108. data/vendor/assets/bower_components/angularjs-dropdown-multiselect/bower.json +25 -12
  109. data/vendor/assets/bower_components/angularjs-dropdown-multiselect/development_index.html +59 -52
  110. data/vendor/assets/bower_components/angularjs-dropdown-multiselect/dist/angularjs-dropdown-multiselect.min.js +1 -1
  111. data/vendor/assets/bower_components/angularjs-dropdown-multiselect/index.html +73 -0
  112. data/vendor/assets/bower_components/angularjs-dropdown-multiselect/package.json +19 -7
  113. data/vendor/assets/bower_components/angularjs-dropdown-multiselect/pages/javascripts/pages/home/ExampleCtrl.js +126 -3
  114. data/vendor/assets/bower_components/angularjs-dropdown-multiselect/pages/javascripts/pages/home/home.html +1262 -852
  115. data/vendor/assets/bower_components/angularjs-dropdown-multiselect/pages/stylesheets/stylesheet.css +10 -5
  116. data/vendor/assets/bower_components/angularjs-dropdown-multiselect/src/angularjs-dropdown-multiselect.js +612 -287
  117. metadata +66 -169
  118. data/spec/internal/config/database.yml +0 -7
  119. data/spec/internal/public/uploads/kms/asset/file/1/avatar.jpg +0 -0
  120. data/spec/internal/public/uploads/kms/asset/file/2/avatar.jpg +0 -0
  121. data/spec/internal/public/uploads/kms/asset/file/2/style.css +0 -1
  122. data/spec/internal/public/uploads/kms/asset/file/3/style.css +0 -1
  123. data/spec/internal/public/uploads/kms/asset/file/4/style.css +0 -1
  124. data/spec/internal/public/uploads/tmp/1500976987-41025-0002-0883/style.css +0 -1
  125. data/spec/internal/public/uploads/tmp/1500977082-41195-0002-6495/style.css +0 -1
  126. data/spec/internal/public/uploads/tmp/1500977109-41364-0002-4518/style.css +0 -1
  127. data/spec/internal/public/uploads/tmp/1500977152-41405-0002-2345/style.css +0 -1
  128. data/spec/internal/public/uploads/tmp/1500977327-41694-0002-5448/style.css +0 -1
  129. data/spec/internal/public/uploads/tmp/1500977376-41732-0002-7916/style.css +0 -1
  130. data/spec/internal/public/uploads/tmp/1500977392-41759-0002-7593/style.css +0 -1
  131. data/spec/internal/public/uploads/tmp/1500977410-42259-0002-7527/style.css +0 -1
  132. data/spec/internal/public/uploads/tmp/1500977429-42306-0002-5937/style.css +0 -1
  133. data/spec/internal/public/uploads/tmp/1500977437-42324-0002-5880/style.css +0 -1
  134. data/spec/internal/public/uploads/tmp/1500983228-53594-0002-4559/style.css +0 -1
  135. data/spec/internal/public/uploads/tmp/1500983284-53632-0002-6590/style.css +0 -1
  136. data/spec/internal/public/uploads/tmp/1500983360-53784-0002-7289/style.css +0 -1
  137. data/spec/internal/public/uploads/tmp/1500983469-54321-0002-0386/avatar.jpg +0 -0
  138. data/spec/internal/public/uploads/tmp/1500983469-54321-0004-5691/style.css +0 -1
  139. data/spec/internal/public/uploads/tmp/1500983511-54352-0002-5720/avatar.jpg +0 -0
  140. data/spec/internal/public/uploads/tmp/1500983511-54352-0004-1399/style.css +0 -1
  141. data/spec/internal/public/uploads/tmp/1500983610-54507-0002-4280/avatar.jpg +0 -0
  142. data/spec/internal/public/uploads/tmp/1500983610-54507-0004-9758/style.css +0 -1
  143. data/spec/internal/public/uploads/tmp/1500984466-57012-0002-4146/avatar.jpg +0 -0
  144. data/spec/internal/public/uploads/tmp/1500984466-57012-0004-5895/style.css +0 -1
  145. data/spec/internal/public/uploads/tmp/1500984509-57158-0002-9657/avatar.jpg +0 -0
  146. data/spec/internal/public/uploads/tmp/1500984509-57158-0004-5003/style.css +0 -1
  147. data/spec/internal/public/uploads/tmp/1500984616-57697-0002-7201/avatar.jpg +0 -0
  148. data/spec/internal/public/uploads/tmp/1500984616-57697-0004-6255/style.css +0 -1
  149. data/spec/internal/public/uploads/tmp/1500985257-58947-0002-3629/avatar.jpg +0 -0
  150. data/spec/internal/public/uploads/tmp/1500985257-58947-0004-5338/style.css +0 -1
  151. data/spec/internal/public/uploads/tmp/1500985407-58947-0006-5929/style.css +0 -1
  152. data/spec/internal/public/uploads/tmp/1500985473-59264-0002-0397/avatar.jpg +0 -0
  153. data/spec/internal/public/uploads/tmp/1500985473-59264-0004-6493/style.css +0 -1
  154. data/spec/internal/public/uploads/tmp/1500985475-59264-0007-8674/style.css +0 -1
  155. data/spec/internal/public/uploads/tmp/1500985538-59468-0002-9206/avatar.jpg +0 -0
  156. data/spec/internal/public/uploads/tmp/1500985538-59468-0004-2586/style.css +0 -1
  157. data/spec/internal/public/uploads/tmp/1500985538-59468-0007-6200/style.css +0 -1
  158. data/spec/internal/public/uploads/tmp/1500988358-65877-0002-4528/avatar.jpg +0 -0
  159. data/spec/internal/public/uploads/tmp/1500988358-65877-0004-5904/style.css +0 -1
  160. data/spec/internal/public/uploads/tmp/1500988358-65877-0007-7320/style.css +0 -1
  161. data/spec/internal/public/uploads/tmp/1500988407-65916-0002-3138/avatar.jpg +0 -0
  162. data/spec/internal/public/uploads/tmp/1500988407-65916-0004-5400/style.css +0 -1
  163. data/spec/internal/public/uploads/tmp/1500988407-65916-0007-1655/style.css +0 -1
  164. data/spec/internal/public/uploads/tmp/1500988421-65950-0002-9415/avatar.jpg +0 -0
  165. data/spec/internal/public/uploads/tmp/1500988421-65950-0004-7130/style.css +0 -1
  166. data/spec/internal/public/uploads/tmp/1500988421-65950-0007-9886/style.css +0 -1
  167. data/spec/internal/public/uploads/tmp/1500988435-65981-0002-3228/avatar.jpg +0 -0
  168. data/spec/internal/public/uploads/tmp/1500988435-65981-0004-3682/style.css +0 -1
  169. data/spec/internal/public/uploads/tmp/1500988435-65981-0007-1582/style.css +0 -1
  170. data/spec/internal/public/uploads/tmp/1500988475-66122-0002-9516/avatar.jpg +0 -0
  171. data/spec/internal/public/uploads/tmp/1500988475-66122-0004-5634/style.css +0 -1
  172. data/spec/internal/public/uploads/tmp/1500988530-66122-0007-2272/style.css +0 -1
  173. data/spec/internal/public/uploads/tmp/1500988554-66315-0002-6262/avatar.jpg +0 -0
  174. data/spec/internal/public/uploads/tmp/1500988554-66315-0004-6099/style.css +0 -1
  175. data/spec/internal/public/uploads/tmp/1500988554-66315-0007-1632/style.css +0 -1
  176. data/spec/internal/public/uploads/tmp/1500991751-73722-0002-9937/avatar.jpg +0 -0
  177. data/spec/internal/public/uploads/tmp/1500991751-73722-0004-8034/style.css +0 -1
  178. data/spec/internal/public/uploads/tmp/1500991751-73722-0007-7763/style.css +0 -1
  179. data/spec/internal/public/uploads/tmp/1501233238-34385-0002-3210/avatar.jpg +0 -0
  180. data/spec/internal/public/uploads/tmp/1501233238-34385-0004-5881/style.css +0 -1
  181. data/spec/internal/public/uploads/tmp/1501233238-34385-0007-6280/style.css +0 -1
  182. data/spec/internal/tmp/cache/assets/test/sprockets/v3.0/1XyAFYlYI0pK7WAgjR4PgXV6BgU6huJSviWmHetdCRs.cache +0 -1
  183. data/vendor/assets/bower_components/angular-ui-router/api/angular-ui-router.d.ts +0 -126
  184. data/vendor/assets/bower_components/angular-ui-router/src/common.js +0 -292
  185. data/vendor/assets/bower_components/angular-ui-router/src/resolve.js +0 -252
  186. data/vendor/assets/bower_components/angular-ui-router/src/state.js +0 -1373
  187. data/vendor/assets/bower_components/angular-ui-router/src/stateDirectives.js +0 -268
  188. data/vendor/assets/bower_components/angular-ui-router/src/stateFilters.js +0 -39
  189. data/vendor/assets/bower_components/angular-ui-router/src/templateFactory.js +0 -110
  190. data/vendor/assets/bower_components/angular-ui-router/src/urlMatcherFactory.js +0 -1036
  191. data/vendor/assets/bower_components/angular-ui-router/src/urlRouter.js +0 -413
  192. data/vendor/assets/bower_components/angular-ui-router/src/view.js +0 -71
  193. data/vendor/assets/bower_components/angular-ui-router/src/viewDirective.js +0 -302
  194. data/vendor/assets/bower_components/angular-ui-router/src/viewScroll.js +0 -52
  195. data/vendor/assets/bower_components/angularjs-dropdown-multiselect/pages/index.html +0 -67
  196. data/vendor/assets/bower_components/bootstrap/Gemfile.lock +0 -43
@@ -0,0 +1,17 @@
1
+ {
2
+ "version": 3,
3
+ "file": "stateEvents.js",
4
+ "sources": [
5
+ "@uirouter/angularjs/src/angular.ts",
6
+ "@uirouter/angularjs/src/legacy/stateEvents.ts"
7
+ ],
8
+ "sourcesContent": [
9
+ "/**\n * @hidden\n * @module ng1\n */ /** */\ndeclare var angular;\nimport * as ng_from_import from \"angular\";\nlet ng_from_global = angular;\n\nexport const ng = (ng_from_import && ng_from_import.module) ? ng_from_import : ng_from_global;\n",
10
+ "/**\n * # Legacy state events\n *\n * Polyfill implementation of the UI-Router 0.2.x state events.\n *\n * The 0.2.x state events are deprecated. We recommend moving to Transition Hooks instead, as they\n * provide much more flexibility, support async, and provide the context (the Transition, etc) necessary\n * to implement meaningful application behaviors.\n *\n * To enable these state events, include the `stateEvents.js` file in your project, e.g.,\n * ```\n * <script src=\"stateEvents.js\"></script>\n * ```\n * and also make sure you depend on the `ui.router.state.events` angular module, e.g.,\n * ```\n * angular.module(\"myApplication\", ['ui.router', 'ui.router.state.events']\n * ```\n *\n * @module ng1_state_events\n */ /** */\nimport { ng as angular } from \"../angular\";\nimport { IScope, IAngularEvent, IServiceProviderFactory } from \"angular\";\nimport {\n Obj, TargetState, StateService, Transition, TransitionService, UrlRouter, HookResult, UIInjector\n} from \"@uirouter/core\";\nimport { StateProvider } from \"../stateProvider\";\n\n/**\n * An event broadcast on `$rootScope` when the state transition **begins**.\n *\n * ### Deprecation warning: use [[TransitionService.onStart]] instead\n *\n * You can use `event.preventDefault()`\n * to prevent the transition from happening and then the transition promise will be\n * rejected with a `'transition prevented'` value.\n *\n * Additional arguments to the event handler are provided:\n * - `toState`: the Transition Target state\n * - `toParams`: the Transition Target Params\n * - `fromState`: the state the transition is coming from\n * - `fromParams`: the parameters from the state the transition is coming from\n * - `options`: any Transition Options\n * - `$transition$`: the [[Transition]]\n *\n * #### Example:\n * ```js\n * $rootScope.$on('$stateChangeStart', function(event, transition) {\n * event.preventDefault();\n * // transitionTo() promise will be rejected with\n * // a 'transition prevented' error\n * })\n * ```\n *\n * @event $stateChangeStart\n * @deprecated\n */\nexport var $stateChangeStart: IAngularEvent;\n\n/**\n * An event broadcast on `$rootScope` if a transition is **cancelled**.\n *\n * ### Deprecation warning: use [[TransitionService.onStart]] instead\n *\n * Additional arguments to the event handler are provided:\n * - `toState`: the Transition Target state\n * - `toParams`: the Transition Target Params\n * - `fromState`: the state the transition is coming from\n * - `fromParams`: the parameters from the state the transition is coming from\n * - `options`: any Transition Options\n * - `$transition$`: the [[Transition]] that was cancelled\n *\n * @event $stateChangeCancel\n * @deprecated\n */\nexport var $stateChangeCancel: IAngularEvent;\n\n/**\n * An event broadcast on `$rootScope` once the state transition is **complete**.\n *\n * ### Deprecation warning: use [[TransitionService.onStart]] and [[Transition.promise]], or [[Transition.onSuccess]]\n *\n * Additional arguments to the event handler are provided:\n * - `toState`: the Transition Target state\n * - `toParams`: the Transition Target Params\n * - `fromState`: the state the transition is coming from\n * - `fromParams`: the parameters from the state the transition is coming from\n * - `options`: any Transition Options\n * - `$transition$`: the [[Transition]] that just succeeded\n *\n * @event $stateChangeSuccess\n * @deprecated\n */\nexport var $stateChangeSuccess: IAngularEvent;\n\n/**\n * An event broadcast on `$rootScope` when an **error occurs** during transition.\n *\n * ### Deprecation warning: use [[TransitionService.onStart]] and [[Transition.promise]], or [[Transition.onError]]\n *\n * It's important to note that if you\n * have any errors in your resolve functions (javascript errors, non-existent services, etc)\n * they will not throw traditionally. You must listen for this $stateChangeError event to\n * catch **ALL** errors.\n *\n * Additional arguments to the event handler are provided:\n * - `toState`: the Transition Target state\n * - `toParams`: the Transition Target Params\n * - `fromState`: the state the transition is coming from\n * - `fromParams`: the parameters from the state the transition is coming from\n * - `error`: The reason the transition errored.\n * - `options`: any Transition Options\n * - `$transition$`: the [[Transition]] that errored\n *\n * @event $stateChangeError\n * @deprecated\n */\nexport var $stateChangeError: IAngularEvent;\n\n/**\n * An event broadcast on `$rootScope` when a requested state **cannot be found** using the provided state name.\n *\n * ### Deprecation warning: use [[StateService.onInvalid]] instead\n *\n * The event is broadcast allowing any handlers a single chance to deal with the error (usually by\n * lazy-loading the unfound state). A `TargetState` object is passed to the listener handler,\n * you can see its properties in the example. You can use `event.preventDefault()` to abort the\n * transition and the promise returned from `transitionTo()` will be rejected with a\n * `'transition aborted'` error.\n *\n * Additional arguments to the event handler are provided:\n * - `unfoundState` Unfound State information. Contains: `to, toParams, options` properties.\n * - `fromState`: the state the transition is coming from\n * - `fromParams`: the parameters from the state the transition is coming from\n * - `options`: any Transition Options\n *\n * #### Example:\n * ```js\n * // somewhere, assume lazy.state has not been defined\n * $state.go(\"lazy.state\", { a: 1, b: 2 }, { inherit: false });\n *\n * // somewhere else\n * $scope.$on('$stateNotFound', function(event, transition) {\n * function(event, unfoundState, fromState, fromParams){\n * console.log(unfoundState.to); // \"lazy.state\"\n * console.log(unfoundState.toParams); // {a:1, b:2}\n * console.log(unfoundState.options); // {inherit:false} + default options\n * });\n * ```\n *\n * @event $stateNotFound\n * @deprecated\n */\nexport var $stateNotFound: IAngularEvent;\n\n\n(function () {\n let { isFunction, isString } = angular;\n\n function applyPairs(memo: Obj, keyValTuple: any[]) {\n let key: string, value: any;\n if (Array.isArray(keyValTuple)) [key, value] = keyValTuple;\n if (!isString(key)) throw new Error(\"invalid parameters to applyPairs\");\n memo[key] = value;\n return memo;\n }\n\n function stateChangeStartHandler($transition$: Transition) {\n if (!$transition$.options().notify || !$transition$.valid() || $transition$.ignored())\n return;\n\n let $injector = $transition$.injector();\n let $stateEvents = $injector.get('$stateEvents');\n let $rootScope = $injector.get('$rootScope');\n let $state = $injector.get('$state');\n let $urlRouter = $injector.get('$urlRouter');\n\n let enabledEvents = $stateEvents.provider.enabled();\n\n\n let toParams = $transition$.params(\"to\");\n let fromParams = $transition$.params(\"from\");\n\n if (enabledEvents.$stateChangeSuccess) {\n let startEvent = $rootScope.$broadcast('$stateChangeStart', $transition$.to(), toParams, $transition$.from(), fromParams, $transition$.options(), $transition$);\n\n if (startEvent.defaultPrevented) {\n if (enabledEvents.$stateChangeCancel) {\n $rootScope.$broadcast('$stateChangeCancel', $transition$.to(), toParams, $transition$.from(), fromParams, $transition$.options(), $transition$);\n }\n //Don't update and resync url if there's been a new transition started. see issue #2238, #600\n if ($state.transition == null) $urlRouter.update();\n return false;\n }\n\n // right after global state is updated\n let successOpts = { priority: 9999 };\n $transition$.onSuccess({}, function () {\n $rootScope.$broadcast('$stateChangeSuccess', $transition$.to(), toParams, $transition$.from(), fromParams, $transition$.options(), $transition$);\n }, successOpts);\n }\n\n if (enabledEvents.$stateChangeError) {\n $transition$.promise[\"catch\"](function (error) {\n if (error && (error.type === 2 /* RejectType.SUPERSEDED */ || error.type === 3 /* RejectType.ABORTED */))\n return;\n\n\n let evt = $rootScope.$broadcast('$stateChangeError', $transition$.to(), toParams, $transition$.from(), fromParams, error, $transition$.options(), $transition$);\n\n if (!evt.defaultPrevented) {\n $urlRouter.update();\n }\n });\n }\n }\n\n stateNotFoundHandler.$inject = ['$to$', '$from$', '$state', '$rootScope', '$urlRouter'];\n function stateNotFoundHandler($to$: TargetState, $from$: TargetState, injector: UIInjector): HookResult {\n let $state: StateService = injector.get('$state');\n let $rootScope: IScope = injector.get('$rootScope');\n let $urlRouter: UrlRouter = injector.get('$urlRouter');\n\n interface StateNotFoundEvent extends IAngularEvent {\n retry: Promise<any>;\n }\n\n let redirect = { to: $to$.identifier(), toParams: $to$.params(), options: $to$.options() };\n let e = <StateNotFoundEvent> $rootScope.$broadcast('$stateNotFound', redirect, $from$.state(), $from$.params());\n\n if (e.defaultPrevented || e.retry)\n $urlRouter.update();\n\n function redirectFn(): TargetState {\n return $state.target(redirect.to, redirect.toParams, redirect.options);\n }\n\n if (e.defaultPrevented) {\n return false;\n } else if (e.retry || !!$state.get(redirect.to)) {\n return e.retry && isFunction(e.retry.then) ? e.retry.then(redirectFn) : redirectFn();\n }\n }\n\n $StateEventsProvider.$inject = ['$stateProvider'];\n function $StateEventsProvider($stateProvider: StateProvider) {\n $StateEventsProvider.prototype.instance = this;\n\n interface IEventsToggle {\n [key: string]: boolean;\n $stateChangeStart: boolean;\n $stateNotFound: boolean;\n $stateChangeSuccess: boolean;\n $stateChangeError: boolean;\n }\n\n let runtime = false;\n let allEvents = ['$stateChangeStart', '$stateNotFound', '$stateChangeSuccess', '$stateChangeError'];\n let enabledStateEvents = <IEventsToggle> allEvents.map(e => [e, true]).reduce(applyPairs, {});\n\n function assertNotRuntime() {\n if (runtime) throw new Error(\"Cannot enable events at runtime (use $stateEventsProvider\");\n }\n\n /**\n * Enables the deprecated UI-Router 0.2.x State Events\n * [ '$stateChangeStart', '$stateNotFound', '$stateChangeSuccess', '$stateChangeError' ]\n */\n this.enable = function (...events: string[]) {\n assertNotRuntime();\n if (!events || !events.length) events = allEvents;\n events.forEach(event => enabledStateEvents[event] = true);\n };\n\n /**\n * Disables the deprecated UI-Router 0.2.x State Events\n * [ '$stateChangeStart', '$stateNotFound', '$stateChangeSuccess', '$stateChangeError' ]\n */\n this.disable = function (...events: string[]) {\n assertNotRuntime();\n if (!events || !events.length) events = allEvents;\n events.forEach(event => delete enabledStateEvents[event]);\n };\n\n this.enabled = () => enabledStateEvents;\n\n this.$get = $get;\n $get.$inject = ['$transitions'];\n function $get($transitions: TransitionService) {\n runtime = true;\n\n if (enabledStateEvents[\"$stateNotFound\"])\n $stateProvider.onInvalid(stateNotFoundHandler);\n if (enabledStateEvents.$stateChangeStart)\n $transitions.onBefore({}, stateChangeStartHandler, { priority: 1000 });\n\n return {\n provider: $StateEventsProvider.prototype.instance\n };\n }\n }\n\n\n angular.module('ui.router.state.events', ['ui.router.state'])\n .provider(\"$stateEvents\", <IServiceProviderFactory> $StateEventsProvider)\n .run(['$stateEvents', function ($stateEvents: any) { /* Invokes $get() */\n }]);\n})();\n"
11
+ ],
12
+ "names": [
13
+ "ng_from_import.module",
14
+ "angular"
15
+ ],
16
+ "mappings": "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"
17
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * State-based routing for AngularJS 1.x
3
+ * @version v1.0.11
4
+ * @link https://ui-router.github.io
5
+ * @license MIT License, http://www.opensource.org/licenses/MIT
6
+ */
7
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("angular")):"function"==typeof define&&define.amd?define(["exports","angular"],e):e(t["@uirouter/angularjs-state-events"]={},t.angular)}(this,function(t,e){"use strict";var r=angular,n=e&&e.module?e:r;!function(){function t(t,e){var r,n;if(Array.isArray(e)&&(r=e[0],n=e[1]),!s(r))throw new Error("invalid parameters to applyPairs");return t[r]=n,t}function e(t){if(t.options().notify&&t.valid()&&!t.ignored()){var e=t.injector(),r=e.get("$stateEvents"),n=e.get("$rootScope"),o=e.get("$state"),a=e.get("$urlRouter"),s=r.provider.enabled(),i=t.params("to"),u=t.params("from");if(s.$stateChangeSuccess){if(n.$broadcast("$stateChangeStart",t.to(),i,t.from(),u,t.options(),t).defaultPrevented)return s.$stateChangeCancel&&n.$broadcast("$stateChangeCancel",t.to(),i,t.from(),u,t.options(),t),null==o.transition&&a.update(),!1;var c={priority:9999};t.onSuccess({},function(){n.$broadcast("$stateChangeSuccess",t.to(),i,t.from(),u,t.options(),t)},c)}s.$stateChangeError&&t.promise.catch(function(e){(!e||2!==e.type&&3!==e.type)&&(n.$broadcast("$stateChangeError",t.to(),i,t.from(),u,e,t.options(),t).defaultPrevented||a.update())})}}function r(t,e,r){function n(){return o.target(u.to,u.toParams,u.options)}var o=r.get("$state"),s=r.get("$rootScope"),i=r.get("$urlRouter"),u={to:t.identifier(),toParams:t.params(),options:t.options()},c=s.$broadcast("$stateNotFound",u,e.state(),e.params());return(c.defaultPrevented||c.retry)&&i.update(),!c.defaultPrevented&&(c.retry||o.get(u.to)?c.retry&&a(c.retry.then)?c.retry.then(n):n():void 0)}function o(n){function a(){if(i)throw new Error("Cannot enable events at runtime (use $stateEventsProvider")}function s(t){return i=!0,c.$stateNotFound&&n.onInvalid(r),c.$stateChangeStart&&t.onBefore({},e,{priority:1e3}),{provider:o.prototype.instance}}o.prototype.instance=this;var i=!1,u=["$stateChangeStart","$stateNotFound","$stateChangeSuccess","$stateChangeError"],c=u.map(function(t){return[t,!0]}).reduce(t,{});this.enable=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];a(),t&&t.length||(t=u),t.forEach(function(t){return c[t]=!0})},this.disable=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];a(),t&&t.length||(t=u),t.forEach(function(t){return delete c[t]})},this.enabled=function(){return c},this.$get=s,s.$inject=["$transitions"]}var a=n.isFunction,s=n.isString;r.$inject=["$to$","$from$","$state","$rootScope","$urlRouter"],o.$inject=["$stateProvider"],n.module("ui.router.state.events",["ui.router.state"]).provider("$stateEvents",o).run(["$stateEvents",function(t){}])}(),t.$stateChangeStart=void 0,t.$stateChangeCancel=void 0,t.$stateChangeSuccess=void 0,t.$stateChangeError=void 0,t.$stateNotFound=void 0,Object.defineProperty(t,"__esModule",{value:!0})});
8
+ //# sourceMappingURL=stateEvents.min.js.map
@@ -0,0 +1,102 @@
1
+ {
2
+ "version": 3,
3
+ "file": "stateEvents.min.js",
4
+ "sources": [
5
+ "@uirouter/angularjs/src/angular.ts",
6
+ "@uirouter/angularjs/src/legacy/stateEvents.ts"
7
+ ],
8
+ "sourcesContent": [
9
+ "/**\n * @hidden\n * @module ng1\n */ /** */\ndeclare var angular;\nimport * as ng_from_import from \"angular\";\nlet ng_from_global = angular;\n\nexport const ng = (ng_from_import && ng_from_import.module) ? ng_from_import : ng_from_global;\n",
10
+ "/**\n * # Legacy state events\n *\n * Polyfill implementation of the UI-Router 0.2.x state events.\n *\n * The 0.2.x state events are deprecated. We recommend moving to Transition Hooks instead, as they\n * provide much more flexibility, support async, and provide the context (the Transition, etc) necessary\n * to implement meaningful application behaviors.\n *\n * To enable these state events, include the `stateEvents.js` file in your project, e.g.,\n * ```\n * <script src=\"stateEvents.js\"></script>\n * ```\n * and also make sure you depend on the `ui.router.state.events` angular module, e.g.,\n * ```\n * angular.module(\"myApplication\", ['ui.router', 'ui.router.state.events']\n * ```\n *\n * @module ng1_state_events\n */ /** */\nimport { ng as angular } from \"../angular\";\nimport { IScope, IAngularEvent, IServiceProviderFactory } from \"angular\";\nimport {\n Obj, TargetState, StateService, Transition, TransitionService, UrlRouter, HookResult, UIInjector\n} from \"@uirouter/core\";\nimport { StateProvider } from \"../stateProvider\";\n\n/**\n * An event broadcast on `$rootScope` when the state transition **begins**.\n *\n * ### Deprecation warning: use [[TransitionService.onStart]] instead\n *\n * You can use `event.preventDefault()`\n * to prevent the transition from happening and then the transition promise will be\n * rejected with a `'transition prevented'` value.\n *\n * Additional arguments to the event handler are provided:\n * - `toState`: the Transition Target state\n * - `toParams`: the Transition Target Params\n * - `fromState`: the state the transition is coming from\n * - `fromParams`: the parameters from the state the transition is coming from\n * - `options`: any Transition Options\n * - `$transition$`: the [[Transition]]\n *\n * #### Example:\n * ```js\n * $rootScope.$on('$stateChangeStart', function(event, transition) {\n * event.preventDefault();\n * // transitionTo() promise will be rejected with\n * // a 'transition prevented' error\n * })\n * ```\n *\n * @event $stateChangeStart\n * @deprecated\n */\nexport var $stateChangeStart: IAngularEvent;\n\n/**\n * An event broadcast on `$rootScope` if a transition is **cancelled**.\n *\n * ### Deprecation warning: use [[TransitionService.onStart]] instead\n *\n * Additional arguments to the event handler are provided:\n * - `toState`: the Transition Target state\n * - `toParams`: the Transition Target Params\n * - `fromState`: the state the transition is coming from\n * - `fromParams`: the parameters from the state the transition is coming from\n * - `options`: any Transition Options\n * - `$transition$`: the [[Transition]] that was cancelled\n *\n * @event $stateChangeCancel\n * @deprecated\n */\nexport var $stateChangeCancel: IAngularEvent;\n\n/**\n * An event broadcast on `$rootScope` once the state transition is **complete**.\n *\n * ### Deprecation warning: use [[TransitionService.onStart]] and [[Transition.promise]], or [[Transition.onSuccess]]\n *\n * Additional arguments to the event handler are provided:\n * - `toState`: the Transition Target state\n * - `toParams`: the Transition Target Params\n * - `fromState`: the state the transition is coming from\n * - `fromParams`: the parameters from the state the transition is coming from\n * - `options`: any Transition Options\n * - `$transition$`: the [[Transition]] that just succeeded\n *\n * @event $stateChangeSuccess\n * @deprecated\n */\nexport var $stateChangeSuccess: IAngularEvent;\n\n/**\n * An event broadcast on `$rootScope` when an **error occurs** during transition.\n *\n * ### Deprecation warning: use [[TransitionService.onStart]] and [[Transition.promise]], or [[Transition.onError]]\n *\n * It's important to note that if you\n * have any errors in your resolve functions (javascript errors, non-existent services, etc)\n * they will not throw traditionally. You must listen for this $stateChangeError event to\n * catch **ALL** errors.\n *\n * Additional arguments to the event handler are provided:\n * - `toState`: the Transition Target state\n * - `toParams`: the Transition Target Params\n * - `fromState`: the state the transition is coming from\n * - `fromParams`: the parameters from the state the transition is coming from\n * - `error`: The reason the transition errored.\n * - `options`: any Transition Options\n * - `$transition$`: the [[Transition]] that errored\n *\n * @event $stateChangeError\n * @deprecated\n */\nexport var $stateChangeError: IAngularEvent;\n\n/**\n * An event broadcast on `$rootScope` when a requested state **cannot be found** using the provided state name.\n *\n * ### Deprecation warning: use [[StateService.onInvalid]] instead\n *\n * The event is broadcast allowing any handlers a single chance to deal with the error (usually by\n * lazy-loading the unfound state). A `TargetState` object is passed to the listener handler,\n * you can see its properties in the example. You can use `event.preventDefault()` to abort the\n * transition and the promise returned from `transitionTo()` will be rejected with a\n * `'transition aborted'` error.\n *\n * Additional arguments to the event handler are provided:\n * - `unfoundState` Unfound State information. Contains: `to, toParams, options` properties.\n * - `fromState`: the state the transition is coming from\n * - `fromParams`: the parameters from the state the transition is coming from\n * - `options`: any Transition Options\n *\n * #### Example:\n * ```js\n * // somewhere, assume lazy.state has not been defined\n * $state.go(\"lazy.state\", { a: 1, b: 2 }, { inherit: false });\n *\n * // somewhere else\n * $scope.$on('$stateNotFound', function(event, transition) {\n * function(event, unfoundState, fromState, fromParams){\n * console.log(unfoundState.to); // \"lazy.state\"\n * console.log(unfoundState.toParams); // {a:1, b:2}\n * console.log(unfoundState.options); // {inherit:false} + default options\n * });\n * ```\n *\n * @event $stateNotFound\n * @deprecated\n */\nexport var $stateNotFound: IAngularEvent;\n\n\n(function () {\n let { isFunction, isString } = angular;\n\n function applyPairs(memo: Obj, keyValTuple: any[]) {\n let key: string, value: any;\n if (Array.isArray(keyValTuple)) [key, value] = keyValTuple;\n if (!isString(key)) throw new Error(\"invalid parameters to applyPairs\");\n memo[key] = value;\n return memo;\n }\n\n function stateChangeStartHandler($transition$: Transition) {\n if (!$transition$.options().notify || !$transition$.valid() || $transition$.ignored())\n return;\n\n let $injector = $transition$.injector();\n let $stateEvents = $injector.get('$stateEvents');\n let $rootScope = $injector.get('$rootScope');\n let $state = $injector.get('$state');\n let $urlRouter = $injector.get('$urlRouter');\n\n let enabledEvents = $stateEvents.provider.enabled();\n\n\n let toParams = $transition$.params(\"to\");\n let fromParams = $transition$.params(\"from\");\n\n if (enabledEvents.$stateChangeSuccess) {\n let startEvent = $rootScope.$broadcast('$stateChangeStart', $transition$.to(), toParams, $transition$.from(), fromParams, $transition$.options(), $transition$);\n\n if (startEvent.defaultPrevented) {\n if (enabledEvents.$stateChangeCancel) {\n $rootScope.$broadcast('$stateChangeCancel', $transition$.to(), toParams, $transition$.from(), fromParams, $transition$.options(), $transition$);\n }\n //Don't update and resync url if there's been a new transition started. see issue #2238, #600\n if ($state.transition == null) $urlRouter.update();\n return false;\n }\n\n // right after global state is updated\n let successOpts = { priority: 9999 };\n $transition$.onSuccess({}, function () {\n $rootScope.$broadcast('$stateChangeSuccess', $transition$.to(), toParams, $transition$.from(), fromParams, $transition$.options(), $transition$);\n }, successOpts);\n }\n\n if (enabledEvents.$stateChangeError) {\n $transition$.promise[\"catch\"](function (error) {\n if (error && (error.type === 2 /* RejectType.SUPERSEDED */ || error.type === 3 /* RejectType.ABORTED */))\n return;\n\n\n let evt = $rootScope.$broadcast('$stateChangeError', $transition$.to(), toParams, $transition$.from(), fromParams, error, $transition$.options(), $transition$);\n\n if (!evt.defaultPrevented) {\n $urlRouter.update();\n }\n });\n }\n }\n\n stateNotFoundHandler.$inject = ['$to$', '$from$', '$state', '$rootScope', '$urlRouter'];\n function stateNotFoundHandler($to$: TargetState, $from$: TargetState, injector: UIInjector): HookResult {\n let $state: StateService = injector.get('$state');\n let $rootScope: IScope = injector.get('$rootScope');\n let $urlRouter: UrlRouter = injector.get('$urlRouter');\n\n interface StateNotFoundEvent extends IAngularEvent {\n retry: Promise<any>;\n }\n\n let redirect = { to: $to$.identifier(), toParams: $to$.params(), options: $to$.options() };\n let e = <StateNotFoundEvent> $rootScope.$broadcast('$stateNotFound', redirect, $from$.state(), $from$.params());\n\n if (e.defaultPrevented || e.retry)\n $urlRouter.update();\n\n function redirectFn(): TargetState {\n return $state.target(redirect.to, redirect.toParams, redirect.options);\n }\n\n if (e.defaultPrevented) {\n return false;\n } else if (e.retry || !!$state.get(redirect.to)) {\n return e.retry && isFunction(e.retry.then) ? e.retry.then(redirectFn) : redirectFn();\n }\n }\n\n $StateEventsProvider.$inject = ['$stateProvider'];\n function $StateEventsProvider($stateProvider: StateProvider) {\n $StateEventsProvider.prototype.instance = this;\n\n interface IEventsToggle {\n [key: string]: boolean;\n $stateChangeStart: boolean;\n $stateNotFound: boolean;\n $stateChangeSuccess: boolean;\n $stateChangeError: boolean;\n }\n\n let runtime = false;\n let allEvents = ['$stateChangeStart', '$stateNotFound', '$stateChangeSuccess', '$stateChangeError'];\n let enabledStateEvents = <IEventsToggle> allEvents.map(e => [e, true]).reduce(applyPairs, {});\n\n function assertNotRuntime() {\n if (runtime) throw new Error(\"Cannot enable events at runtime (use $stateEventsProvider\");\n }\n\n /**\n * Enables the deprecated UI-Router 0.2.x State Events\n * [ '$stateChangeStart', '$stateNotFound', '$stateChangeSuccess', '$stateChangeError' ]\n */\n this.enable = function (...events: string[]) {\n assertNotRuntime();\n if (!events || !events.length) events = allEvents;\n events.forEach(event => enabledStateEvents[event] = true);\n };\n\n /**\n * Disables the deprecated UI-Router 0.2.x State Events\n * [ '$stateChangeStart', '$stateNotFound', '$stateChangeSuccess', '$stateChangeError' ]\n */\n this.disable = function (...events: string[]) {\n assertNotRuntime();\n if (!events || !events.length) events = allEvents;\n events.forEach(event => delete enabledStateEvents[event]);\n };\n\n this.enabled = () => enabledStateEvents;\n\n this.$get = $get;\n $get.$inject = ['$transitions'];\n function $get($transitions: TransitionService) {\n runtime = true;\n\n if (enabledStateEvents[\"$stateNotFound\"])\n $stateProvider.onInvalid(stateNotFoundHandler);\n if (enabledStateEvents.$stateChangeStart)\n $transitions.onBefore({}, stateChangeStartHandler, { priority: 1000 });\n\n return {\n provider: $StateEventsProvider.prototype.instance\n };\n }\n }\n\n\n angular.module('ui.router.state.events', ['ui.router.state'])\n .provider(\"$stateEvents\", <IServiceProviderFactory> $StateEventsProvider)\n .run(['$stateEvents', function ($stateEvents: any) { /* Invokes $get() */\n }]);\n})();\n"
11
+ ],
12
+ "names": [
13
+ "ng_from_global",
14
+ "angular",
15
+ "ng",
16
+ "ng_from_import",
17
+ "ng_from_import.module",
18
+ "memo",
19
+ "keyValTuple",
20
+ "key",
21
+ "value",
22
+ "Array",
23
+ "isArray",
24
+ "isString",
25
+ "Error",
26
+ "$transition$",
27
+ "options",
28
+ "notify",
29
+ "valid",
30
+ "ignored",
31
+ "$injector",
32
+ "injector",
33
+ "$stateEvents",
34
+ "get",
35
+ "$rootScope",
36
+ "$state",
37
+ "$urlRouter",
38
+ "enabledEvents",
39
+ "provider",
40
+ "enabled",
41
+ "toParams",
42
+ "params",
43
+ "fromParams",
44
+ "$stateChangeSuccess",
45
+ "$broadcast",
46
+ "to",
47
+ "from",
48
+ "defaultPrevented",
49
+ "$stateChangeCancel",
50
+ "transition",
51
+ "update",
52
+ "successOpts",
53
+ "priority",
54
+ "onSuccess",
55
+ "$stateChangeError",
56
+ "promise",
57
+ "error",
58
+ "type",
59
+ "$to$",
60
+ "$from$",
61
+ "target",
62
+ "redirect",
63
+ "identifier",
64
+ "e",
65
+ "state",
66
+ "retry",
67
+ "isFunction",
68
+ "then",
69
+ "redirectFn",
70
+ "$stateProvider",
71
+ "runtime",
72
+ "$transitions",
73
+ "enabledStateEvents",
74
+ "onInvalid",
75
+ "stateNotFoundHandler",
76
+ "$stateChangeStart",
77
+ "onBefore",
78
+ "stateChangeStartHandler",
79
+ "$StateEventsProvider",
80
+ "prototype",
81
+ "instance",
82
+ "this",
83
+ "allEvents",
84
+ "map",
85
+ "reduce",
86
+ "applyPairs",
87
+ "enable",
88
+ "_i",
89
+ "events",
90
+ "assertNotRuntime",
91
+ "length",
92
+ "forEach",
93
+ "event",
94
+ "disable",
95
+ "$get",
96
+ "$inject",
97
+ "module",
98
+ "run",
99
+ "$stateNotFound"
100
+ ],
101
+ "mappings": "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"
102
+ }
@@ -0,0 +1,2014 @@
1
+ /**
2
+ * State-based routing for AngularJS 1.x
3
+ * This bundle requires the ui-router-core.js bundle from the @uirouter/core package.
4
+ * @version v1.0.11
5
+ * @link https://ui-router.github.io
6
+ * @license MIT License, http://www.opensource.org/licenses/MIT
7
+ */
8
+ (function (global, factory) {
9
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('angular'), require('@uirouter/core')) :
10
+ typeof define === 'function' && define.amd ? define(['exports', 'angular', '@uirouter/core'], factory) :
11
+ (factory((global['@uirouter/angularjs'] = {}),global.angular,global['@uirouter/core']));
12
+ }(this, (function (exports,ng_from_import,core) { 'use strict';
13
+
14
+ var ng_from_global = angular;
15
+ var ng = (ng_from_import && ng_from_import.module) ? ng_from_import : ng_from_global;
16
+
17
+ function getNg1ViewConfigFactory() {
18
+ var templateFactory = null;
19
+ return function (path, view) {
20
+ templateFactory = templateFactory || core.services.$injector.get("$templateFactory");
21
+ return [new Ng1ViewConfig(path, view, templateFactory)];
22
+ };
23
+ }
24
+ var hasAnyKey = function (keys, obj) {
25
+ return keys.reduce(function (acc, key) { return acc || core.isDefined(obj[key]); }, false);
26
+ };
27
+ /**
28
+ * This is a [[StateBuilder.builder]] function for angular1 `views`.
29
+ *
30
+ * When the [[StateBuilder]] builds a [[StateObject]] object from a raw [[StateDeclaration]], this builder
31
+ * handles the `views` property with logic specific to @uirouter/angularjs (ng1).
32
+ *
33
+ * If no `views: {}` property exists on the [[StateDeclaration]], then it creates the `views` object
34
+ * and applies the state-level configuration to a view named `$default`.
35
+ */
36
+ function ng1ViewsBuilder(state) {
37
+ // Do not process root state
38
+ if (!state.parent)
39
+ return {};
40
+ var tplKeys = ['templateProvider', 'templateUrl', 'template', 'notify', 'async'], ctrlKeys = ['controller', 'controllerProvider', 'controllerAs', 'resolveAs'], compKeys = ['component', 'bindings', 'componentProvider'], nonCompKeys = tplKeys.concat(ctrlKeys), allViewKeys = compKeys.concat(nonCompKeys);
41
+ // Do not allow a state to have both state-level props and also a `views: {}` property.
42
+ // A state without a `views: {}` property can declare properties for the `$default` view as properties of the state.
43
+ // However, the `$default` approach should not be mixed with a separate `views: ` block.
44
+ if (core.isDefined(state.views) && hasAnyKey(allViewKeys, state)) {
45
+ throw new Error("State '" + state.name + "' has a 'views' object. " +
46
+ "It cannot also have \"view properties\" at the state level. " +
47
+ "Move the following properties into a view (in the 'views' object): " +
48
+ (" " + allViewKeys.filter(function (key) { return core.isDefined(state[key]); }).join(", ")));
49
+ }
50
+ var views = {}, viewsObject = state.views || { "$default": core.pick(state, allViewKeys) };
51
+ core.forEach(viewsObject, function (config, name) {
52
+ // Account for views: { "": { template... } }
53
+ name = name || "$default";
54
+ // Account for views: { header: "headerComponent" }
55
+ if (core.isString(config))
56
+ config = { component: config };
57
+ // Make a shallow copy of the config object
58
+ config = core.extend({}, config);
59
+ // Do not allow a view to mix props for component-style view with props for template/controller-style view
60
+ if (hasAnyKey(compKeys, config) && hasAnyKey(nonCompKeys, config)) {
61
+ throw new Error("Cannot combine: " + compKeys.join("|") + " with: " + nonCompKeys.join("|") + " in stateview: '" + name + "@" + state.name + "'");
62
+ }
63
+ config.resolveAs = config.resolveAs || '$resolve';
64
+ config.$type = "ng1";
65
+ config.$context = state;
66
+ config.$name = name;
67
+ var normalized = core.ViewService.normalizeUIViewTarget(config.$context, config.$name);
68
+ config.$uiViewName = normalized.uiViewName;
69
+ config.$uiViewContextAnchor = normalized.uiViewContextAnchor;
70
+ views[name] = config;
71
+ });
72
+ return views;
73
+ }
74
+ var id = 0;
75
+ var Ng1ViewConfig = /** @class */ (function () {
76
+ function Ng1ViewConfig(path, viewDecl, factory) {
77
+ var _this = this;
78
+ this.path = path;
79
+ this.viewDecl = viewDecl;
80
+ this.factory = factory;
81
+ this.$id = id++;
82
+ this.loaded = false;
83
+ this.getTemplate = function (uiView, context) {
84
+ return _this.component ? _this.factory.makeComponentTemplate(uiView, context, _this.component, _this.viewDecl.bindings) : _this.template;
85
+ };
86
+ }
87
+ Ng1ViewConfig.prototype.load = function () {
88
+ var _this = this;
89
+ var $q = core.services.$q;
90
+ var context = new core.ResolveContext(this.path);
91
+ var params = this.path.reduce(function (acc, node) { return core.extend(acc, node.paramValues); }, {});
92
+ var promises = {
93
+ template: $q.when(this.factory.fromConfig(this.viewDecl, params, context)),
94
+ controller: $q.when(this.getController(context))
95
+ };
96
+ return $q.all(promises).then(function (results) {
97
+ core.trace.traceViewServiceEvent("Loaded", _this);
98
+ _this.controller = results.controller;
99
+ core.extend(_this, results.template); // Either { template: "tpl" } or { component: "cmpName" }
100
+ return _this;
101
+ });
102
+ };
103
+ /**
104
+ * Gets the controller for a view configuration.
105
+ *
106
+ * @returns {Function|Promise.<Function>} Returns a controller, or a promise that resolves to a controller.
107
+ */
108
+ Ng1ViewConfig.prototype.getController = function (context) {
109
+ var provider = this.viewDecl.controllerProvider;
110
+ if (!core.isInjectable(provider))
111
+ return this.viewDecl.controller;
112
+ var deps = core.services.$injector.annotate(provider);
113
+ var providerFn = core.isArray(provider) ? core.tail(provider) : provider;
114
+ var resolvable = new core.Resolvable("", providerFn, deps);
115
+ return resolvable.get(context);
116
+ };
117
+ return Ng1ViewConfig;
118
+ }());
119
+
120
+ /** @module view */
121
+ /** for typedoc */
122
+ /**
123
+ * Service which manages loading of templates from a ViewConfig.
124
+ */
125
+ var TemplateFactory = /** @class */ (function () {
126
+ function TemplateFactory() {
127
+ var _this = this;
128
+ /** @hidden */ this._useHttp = ng.version.minor < 3;
129
+ /** @hidden */ this.$get = ['$http', '$templateCache', '$injector', function ($http, $templateCache, $injector) {
130
+ _this.$templateRequest = $injector.has && $injector.has('$templateRequest') && $injector.get('$templateRequest');
131
+ _this.$http = $http;
132
+ _this.$templateCache = $templateCache;
133
+ return _this;
134
+ }];
135
+ }
136
+ /** @hidden */
137
+ TemplateFactory.prototype.useHttpService = function (value) {
138
+ this._useHttp = value;
139
+ };
140
+
141
+ /**
142
+ * Creates a template from a configuration object.
143
+ *
144
+ * @param config Configuration object for which to load a template.
145
+ * The following properties are search in the specified order, and the first one
146
+ * that is defined is used to create the template:
147
+ *
148
+ * @param params Parameters to pass to the template function.
149
+ * @param context The resolve context associated with the template's view
150
+ *
151
+ * @return {string|object} The template html as a string, or a promise for
152
+ * that string,or `null` if no template is configured.
153
+ */
154
+ TemplateFactory.prototype.fromConfig = function (config, params, context) {
155
+ var defaultTemplate = "<ui-view></ui-view>";
156
+ var asTemplate = function (result) { return core.services.$q.when(result).then(function (str) { return ({ template: str }); }); };
157
+ var asComponent = function (result) { return core.services.$q.when(result).then(function (str) { return ({ component: str }); }); };
158
+ return (core.isDefined(config.template) ? asTemplate(this.fromString(config.template, params)) :
159
+ core.isDefined(config.templateUrl) ? asTemplate(this.fromUrl(config.templateUrl, params)) :
160
+ core.isDefined(config.templateProvider) ? asTemplate(this.fromProvider(config.templateProvider, params, context)) :
161
+ core.isDefined(config.component) ? asComponent(config.component) :
162
+ core.isDefined(config.componentProvider) ? asComponent(this.fromComponentProvider(config.componentProvider, params, context)) :
163
+ asTemplate(defaultTemplate));
164
+ };
165
+
166
+ /**
167
+ * Creates a template from a string or a function returning a string.
168
+ *
169
+ * @param template html template as a string or function that returns an html template as a string.
170
+ * @param params Parameters to pass to the template function.
171
+ *
172
+ * @return {string|object} The template html as a string, or a promise for that
173
+ * string.
174
+ */
175
+ TemplateFactory.prototype.fromString = function (template, params) {
176
+ return core.isFunction(template) ? template(params) : template;
177
+ };
178
+
179
+ /**
180
+ * Loads a template from the a URL via `$http` and `$templateCache`.
181
+ *
182
+ * @param {string|Function} url url of the template to load, or a function
183
+ * that returns a url.
184
+ * @param {Object} params Parameters to pass to the url function.
185
+ * @return {string|Promise.<string>} The template html as a string, or a promise
186
+ * for that string.
187
+ */
188
+ TemplateFactory.prototype.fromUrl = function (url, params) {
189
+ if (core.isFunction(url))
190
+ url = url(params);
191
+ if (url == null)
192
+ return null;
193
+ if (this._useHttp) {
194
+ return this.$http.get(url, { cache: this.$templateCache, headers: { Accept: 'text/html' } })
195
+ .then(function (response) {
196
+ return response.data;
197
+ });
198
+ }
199
+ return this.$templateRequest(url);
200
+ };
201
+
202
+ /**
203
+ * Creates a template by invoking an injectable provider function.
204
+ *
205
+ * @param provider Function to invoke via `locals`
206
+ * @param {Function} injectFn a function used to invoke the template provider
207
+ * @return {string|Promise.<string>} The template html as a string, or a promise
208
+ * for that string.
209
+ */
210
+ TemplateFactory.prototype.fromProvider = function (provider, params, context) {
211
+ var deps = core.services.$injector.annotate(provider);
212
+ var providerFn = core.isArray(provider) ? core.tail(provider) : provider;
213
+ var resolvable = new core.Resolvable("", providerFn, deps);
214
+ return resolvable.get(context);
215
+ };
216
+
217
+ /**
218
+ * Creates a component's template by invoking an injectable provider function.
219
+ *
220
+ * @param provider Function to invoke via `locals`
221
+ * @param {Function} injectFn a function used to invoke the template provider
222
+ * @return {string} The template html as a string: "<component-name input1='::$resolve.foo'></component-name>".
223
+ */
224
+ TemplateFactory.prototype.fromComponentProvider = function (provider, params, context) {
225
+ var deps = core.services.$injector.annotate(provider);
226
+ var providerFn = core.isArray(provider) ? core.tail(provider) : provider;
227
+ var resolvable = new core.Resolvable("", providerFn, deps);
228
+ return resolvable.get(context);
229
+ };
230
+
231
+ /**
232
+ * Creates a template from a component's name
233
+ *
234
+ * This implements route-to-component.
235
+ * It works by retrieving the component (directive) metadata from the injector.
236
+ * It analyses the component's bindings, then constructs a template that instantiates the component.
237
+ * The template wires input and output bindings to resolves or from the parent component.
238
+ *
239
+ * @param uiView {object} The parent ui-view (for binding outputs to callbacks)
240
+ * @param context The ResolveContext (for binding outputs to callbacks returned from resolves)
241
+ * @param component {string} Component's name in camel case.
242
+ * @param bindings An object defining the component's bindings: {foo: '<'}
243
+ * @return {string} The template as a string: "<component-name input1='::$resolve.foo'></component-name>".
244
+ */
245
+ TemplateFactory.prototype.makeComponentTemplate = function (uiView, context, component, bindings) {
246
+ bindings = bindings || {};
247
+ // Bind once prefix
248
+ var prefix = ng.version.minor >= 3 ? "::" : "";
249
+ // Convert to kebob name. Add x- prefix if the string starts with `x-` or `data-`
250
+ var kebob = function (camelCase) {
251
+ var kebobed = core.kebobString(camelCase);
252
+ return /^(x|data)-/.exec(kebobed) ? "x-" + kebobed : kebobed;
253
+ };
254
+ var attributeTpl = function (input) {
255
+ var name = input.name, type = input.type;
256
+ var attrName = kebob(name);
257
+ // If the ui-view has an attribute which matches a binding on the routed component
258
+ // then pass that attribute through to the routed component template.
259
+ // Prefer ui-view wired mappings to resolve data, unless the resolve was explicitly bound using `bindings:`
260
+ if (uiView.attr(attrName) && !bindings[name])
261
+ return attrName + "='" + uiView.attr(attrName) + "'";
262
+ var resolveName = bindings[name] || name;
263
+ // Pre-evaluate the expression for "@" bindings by enclosing in {{ }}
264
+ // some-attr="{{ ::$resolve.someResolveName }}"
265
+ if (type === '@')
266
+ return attrName + "='{{" + prefix + "$resolve." + resolveName + "}}'";
267
+ // Wire "&" callbacks to resolves that return a callback function
268
+ // Get the result of the resolve (should be a function) and annotate it to get its arguments.
269
+ // some-attr="$resolve.someResolveResultName(foo, bar)"
270
+ if (type === '&') {
271
+ var res = context.getResolvable(resolveName);
272
+ var fn = res && res.data;
273
+ var args = fn && core.services.$injector.annotate(fn) || [];
274
+ // account for array style injection, i.e., ['foo', function(foo) {}]
275
+ var arrayIdxStr = core.isArray(fn) ? "[" + (fn.length - 1) + "]" : '';
276
+ return attrName + "='$resolve." + resolveName + arrayIdxStr + "(" + args.join(",") + ")'";
277
+ }
278
+ // some-attr="::$resolve.someResolveName"
279
+ return attrName + "='" + prefix + "$resolve." + resolveName + "'";
280
+ };
281
+ var attrs = getComponentBindings(component).map(attributeTpl).join(" ");
282
+ var kebobName = kebob(component);
283
+ return "<" + kebobName + " " + attrs + "></" + kebobName + ">";
284
+ };
285
+
286
+ return TemplateFactory;
287
+ }());
288
+ // Gets all the directive(s)' inputs ('@', '=', and '<') and outputs ('&')
289
+ function getComponentBindings(name) {
290
+ var cmpDefs = core.services.$injector.get(name + "Directive"); // could be multiple
291
+ if (!cmpDefs || !cmpDefs.length)
292
+ throw new Error("Unable to find component named '" + name + "'");
293
+ return cmpDefs.map(getBindings).reduce(core.unnestR, []);
294
+ }
295
+ // Given a directive definition, find its object input attributes
296
+ // Use different properties, depending on the type of directive (component, bindToController, normal)
297
+ var getBindings = function (def) {
298
+ if (core.isObject(def.bindToController))
299
+ return scopeBindings(def.bindToController);
300
+ return scopeBindings(def.scope);
301
+ };
302
+ // for ng 1.2 style, process the scope: { input: "=foo" }
303
+ // for ng 1.3 through ng 1.5, process the component's bindToController: { input: "=foo" } object
304
+ var scopeBindings = function (bindingsObj) { return Object.keys(bindingsObj || {})
305
+ .map(function (key) { return [key, /^([=<@&])[?]?(.*)/.exec(bindingsObj[key])]; })
306
+ .filter(function (tuple) { return core.isDefined(tuple) && core.isArray(tuple[1]); })
307
+ .map(function (tuple) { return ({ name: tuple[1][2] || tuple[0], type: tuple[1][1] }); }); };
308
+
309
+ /** @module ng1 */ /** for typedoc */
310
+ /**
311
+ * The Angular 1 `StateProvider`
312
+ *
313
+ * The `$stateProvider` works similar to Angular's v1 router, but it focuses purely
314
+ * on state.
315
+ *
316
+ * A state corresponds to a "place" in the application in terms of the overall UI and
317
+ * navigation. A state describes (via the controller / template / view properties) what
318
+ * the UI looks like and does at that place.
319
+ *
320
+ * States often have things in common, and the primary way of factoring out these
321
+ * commonalities in this model is via the state hierarchy, i.e. parent/child states aka
322
+ * nested states.
323
+ *
324
+ * The `$stateProvider` provides interfaces to declare these states for your app.
325
+ */
326
+ var StateProvider = /** @class */ (function () {
327
+ function StateProvider(stateRegistry, stateService) {
328
+ this.stateRegistry = stateRegistry;
329
+ this.stateService = stateService;
330
+ core.createProxyFunctions(core.val(StateProvider.prototype), this, core.val(this));
331
+ }
332
+ /**
333
+ * Decorates states when they are registered
334
+ *
335
+ * Allows you to extend (carefully) or override (at your own peril) the
336
+ * `stateBuilder` object used internally by [[StateRegistry]].
337
+ * This can be used to add custom functionality to ui-router,
338
+ * for example inferring templateUrl based on the state name.
339
+ *
340
+ * When passing only a name, it returns the current (original or decorated) builder
341
+ * function that matches `name`.
342
+ *
343
+ * The builder functions that can be decorated are listed below. Though not all
344
+ * necessarily have a good use case for decoration, that is up to you to decide.
345
+ *
346
+ * In addition, users can attach custom decorators, which will generate new
347
+ * properties within the state's internal definition. There is currently no clear
348
+ * use-case for this beyond accessing internal states (i.e. $state.$current),
349
+ * however, expect this to become increasingly relevant as we introduce additional
350
+ * meta-programming features.
351
+ *
352
+ * **Warning**: Decorators should not be interdependent because the order of
353
+ * execution of the builder functions in non-deterministic. Builder functions
354
+ * should only be dependent on the state definition object and super function.
355
+ *
356
+ *
357
+ * Existing builder functions and current return values:
358
+ *
359
+ * - **parent** `{object}` - returns the parent state object.
360
+ * - **data** `{object}` - returns state data, including any inherited data that is not
361
+ * overridden by own values (if any).
362
+ * - **url** `{object}` - returns a {@link ui.router.util.type:UrlMatcher UrlMatcher}
363
+ * or `null`.
364
+ * - **navigable** `{object}` - returns closest ancestor state that has a URL (aka is
365
+ * navigable).
366
+ * - **params** `{object}` - returns an array of state params that are ensured to
367
+ * be a super-set of parent's params.
368
+ * - **views** `{object}` - returns a views object where each key is an absolute view
369
+ * name (i.e. "viewName@stateName") and each value is the config object
370
+ * (template, controller) for the view. Even when you don't use the views object
371
+ * explicitly on a state config, one is still created for you internally.
372
+ * So by decorating this builder function you have access to decorating template
373
+ * and controller properties.
374
+ * - **ownParams** `{object}` - returns an array of params that belong to the state,
375
+ * not including any params defined by ancestor states.
376
+ * - **path** `{string}` - returns the full path from the root down to this state.
377
+ * Needed for state activation.
378
+ * - **includes** `{object}` - returns an object that includes every state that
379
+ * would pass a `$state.includes()` test.
380
+ *
381
+ * #### Example:
382
+ * Override the internal 'views' builder with a function that takes the state
383
+ * definition, and a reference to the internal function being overridden:
384
+ * ```js
385
+ * $stateProvider.decorator('views', function (state, parent) {
386
+ * let result = {},
387
+ * views = parent(state);
388
+ *
389
+ * angular.forEach(views, function (config, name) {
390
+ * let autoName = (state.name + '.' + name).replace('.', '/');
391
+ * config.templateUrl = config.templateUrl || '/partials/' + autoName + '.html';
392
+ * result[name] = config;
393
+ * });
394
+ * return result;
395
+ * });
396
+ *
397
+ * $stateProvider.state('home', {
398
+ * views: {
399
+ * 'contact.list': { controller: 'ListController' },
400
+ * 'contact.item': { controller: 'ItemController' }
401
+ * }
402
+ * });
403
+ * ```
404
+ *
405
+ *
406
+ * ```js
407
+ * // Auto-populates list and item views with /partials/home/contact/list.html,
408
+ * // and /partials/home/contact/item.html, respectively.
409
+ * $state.go('home');
410
+ * ```
411
+ *
412
+ * @param {string} name The name of the builder function to decorate.
413
+ * @param {object} func A function that is responsible for decorating the original
414
+ * builder function. The function receives two parameters:
415
+ *
416
+ * - `{object}` - state - The state config object.
417
+ * - `{object}` - super - The original builder function.
418
+ *
419
+ * @return {object} $stateProvider - $stateProvider instance
420
+ */
421
+ StateProvider.prototype.decorator = function (name, func) {
422
+ return this.stateRegistry.decorator(name, func) || this;
423
+ };
424
+ StateProvider.prototype.state = function (name, definition) {
425
+ if (core.isObject(name)) {
426
+ definition = name;
427
+ }
428
+ else {
429
+ definition.name = name;
430
+ }
431
+ this.stateRegistry.register(definition);
432
+ return this;
433
+ };
434
+ /**
435
+ * Registers an invalid state handler
436
+ *
437
+ * This is a passthrough to [[StateService.onInvalid]] for ng1.
438
+ */
439
+ StateProvider.prototype.onInvalid = function (callback) {
440
+ return this.stateService.onInvalid(callback);
441
+ };
442
+ return StateProvider;
443
+ }());
444
+
445
+ /** @module ng1 */ /** */
446
+ /**
447
+ * This is a [[StateBuilder.builder]] function for angular1 `onEnter`, `onExit`,
448
+ * `onRetain` callback hooks on a [[Ng1StateDeclaration]].
449
+ *
450
+ * When the [[StateBuilder]] builds a [[StateObject]] object from a raw [[StateDeclaration]], this builder
451
+ * ensures that those hooks are injectable for @uirouter/angularjs (ng1).
452
+ */
453
+ var getStateHookBuilder = function (hookName) {
454
+ return function stateHookBuilder(state, parentFn) {
455
+ var hook = state[hookName];
456
+ var pathname = hookName === 'onExit' ? 'from' : 'to';
457
+ function decoratedNg1Hook(trans, state) {
458
+ var resolveContext = new core.ResolveContext(trans.treeChanges(pathname));
459
+ var locals = core.extend(getLocals(resolveContext), { $state$: state, $transition$: trans });
460
+ return core.services.$injector.invoke(hook, this, locals);
461
+ }
462
+ return hook ? decoratedNg1Hook : undefined;
463
+ };
464
+ };
465
+
466
+ /**
467
+ * Implements UI-Router LocationServices and LocationConfig using Angular 1's $location service
468
+ */
469
+ var Ng1LocationServices = /** @class */ (function () {
470
+ function Ng1LocationServices($locationProvider) {
471
+ // .onChange() registry
472
+ this._urlListeners = [];
473
+ this.$locationProvider = $locationProvider;
474
+ var _lp = core.val($locationProvider);
475
+ core.createProxyFunctions(_lp, this, _lp, ['hashPrefix']);
476
+ }
477
+ Ng1LocationServices.prototype.dispose = function () { };
478
+ Ng1LocationServices.prototype.onChange = function (callback) {
479
+ var _this = this;
480
+ this._urlListeners.push(callback);
481
+ return function () { return core.removeFrom(_this._urlListeners)(callback); };
482
+ };
483
+ Ng1LocationServices.prototype.html5Mode = function () {
484
+ var html5Mode = this.$locationProvider.html5Mode();
485
+ html5Mode = core.isObject(html5Mode) ? html5Mode.enabled : html5Mode;
486
+ return html5Mode && this.$sniffer.history;
487
+ };
488
+ Ng1LocationServices.prototype.url = function (newUrl, replace, state) {
489
+ if (replace === void 0) { replace = false; }
490
+ if (newUrl)
491
+ this.$location.url(newUrl);
492
+ if (replace)
493
+ this.$location.replace();
494
+ if (state)
495
+ this.$location.state(state);
496
+ return this.$location.url();
497
+ };
498
+ Ng1LocationServices.prototype._runtimeServices = function ($rootScope, $location, $sniffer, $browser) {
499
+ var _this = this;
500
+ this.$location = $location;
501
+ this.$sniffer = $sniffer;
502
+ // Bind $locationChangeSuccess to the listeners registered in LocationService.onChange
503
+ $rootScope.$on("$locationChangeSuccess", function (evt) { return _this._urlListeners.forEach(function (fn) { return fn(evt); }); });
504
+ var _loc = core.val($location);
505
+ var _browser = core.val($browser);
506
+ // Bind these LocationService functions to $location
507
+ core.createProxyFunctions(_loc, this, _loc, ["replace", "path", "search", "hash"]);
508
+ // Bind these LocationConfig functions to $location
509
+ core.createProxyFunctions(_loc, this, _loc, ['port', 'protocol', 'host']);
510
+ // Bind these LocationConfig functions to $browser
511
+ core.createProxyFunctions(_browser, this, _browser, ['baseHref']);
512
+ };
513
+ /**
514
+ * Applys ng1-specific path parameter encoding
515
+ *
516
+ * The Angular 1 `$location` service is a bit weird.
517
+ * It doesn't allow slashes to be encoded/decoded bi-directionally.
518
+ *
519
+ * See the writeup at https://github.com/angular-ui/ui-router/issues/2598
520
+ *
521
+ * This code patches the `path` parameter type so it encoded/decodes slashes as ~2F
522
+ *
523
+ * @param router
524
+ */
525
+ Ng1LocationServices.monkeyPatchPathParameterType = function (router) {
526
+ var pathType = router.urlMatcherFactory.type('path');
527
+ pathType.encode = function (val$$1) {
528
+ return val$$1 != null ? val$$1.toString().replace(/(~|\/)/g, function (m) { return ({ '~': '~~', '/': '~2F' }[m]); }) : val$$1;
529
+ };
530
+ pathType.decode = function (val$$1) {
531
+ return val$$1 != null ? val$$1.toString().replace(/(~~|~2F)/g, function (m) { return ({ '~~': '~', '~2F': '/' }[m]); }) : val$$1;
532
+ };
533
+ };
534
+ return Ng1LocationServices;
535
+ }());
536
+
537
+ /** @module url */ /** */
538
+ /**
539
+ * Manages rules for client-side URL
540
+ *
541
+ * ### Deprecation warning:
542
+ * This class is now considered to be an internal API
543
+ * Use the [[UrlService]] instead.
544
+ * For configuring URL rules, use the [[UrlRulesApi]] which can be found as [[UrlService.rules]].
545
+ *
546
+ * This class manages the router rules for what to do when the URL changes.
547
+ *
548
+ * This provider remains for backwards compatibility.
549
+ *
550
+ * @deprecated
551
+ */
552
+ var UrlRouterProvider = /** @class */ (function () {
553
+ /** @hidden */
554
+ function UrlRouterProvider(router) {
555
+ this._router = router;
556
+ this._urlRouter = router.urlRouter;
557
+ }
558
+ /** @hidden */
559
+ UrlRouterProvider.prototype.$get = function () {
560
+ var urlRouter = this._urlRouter;
561
+ urlRouter.update(true);
562
+ if (!urlRouter.interceptDeferred)
563
+ urlRouter.listen();
564
+ return urlRouter;
565
+ };
566
+ /**
567
+ * Registers a url handler function.
568
+ *
569
+ * Registers a low level url handler (a `rule`).
570
+ * A rule detects specific URL patterns and returns a redirect, or performs some action.
571
+ *
572
+ * If a rule returns a string, the URL is replaced with the string, and all rules are fired again.
573
+ *
574
+ * #### Example:
575
+ * ```js
576
+ * var app = angular.module('app', ['ui.router.router']);
577
+ *
578
+ * app.config(function ($urlRouterProvider) {
579
+ * // Here's an example of how you might allow case insensitive urls
580
+ * $urlRouterProvider.rule(function ($injector, $location) {
581
+ * var path = $location.path(),
582
+ * normalized = path.toLowerCase();
583
+ *
584
+ * if (path !== normalized) {
585
+ * return normalized;
586
+ * }
587
+ * });
588
+ * });
589
+ * ```
590
+ *
591
+ * @param ruleFn
592
+ * Handler function that takes `$injector` and `$location` services as arguments.
593
+ * You can use them to detect a url and return a different url as a string.
594
+ *
595
+ * @return [[UrlRouterProvider]] (`this`)
596
+ */
597
+ UrlRouterProvider.prototype.rule = function (ruleFn) {
598
+ var _this = this;
599
+ if (!core.isFunction(ruleFn))
600
+ throw new Error("'rule' must be a function");
601
+ var match = function () {
602
+ return ruleFn(core.services.$injector, _this._router.locationService);
603
+ };
604
+ var rule = new core.BaseUrlRule(match, core.identity);
605
+ this._urlRouter.rule(rule);
606
+ return this;
607
+ };
608
+
609
+ /**
610
+ * Defines the path or behavior to use when no url can be matched.
611
+ *
612
+ * #### Example:
613
+ * ```js
614
+ * var app = angular.module('app', ['ui.router.router']);
615
+ *
616
+ * app.config(function ($urlRouterProvider) {
617
+ * // if the path doesn't match any of the urls you configured
618
+ * // otherwise will take care of routing the user to the
619
+ * // specified url
620
+ * $urlRouterProvider.otherwise('/index');
621
+ *
622
+ * // Example of using function rule as param
623
+ * $urlRouterProvider.otherwise(function ($injector, $location) {
624
+ * return '/a/valid/url';
625
+ * });
626
+ * });
627
+ * ```
628
+ *
629
+ * @param rule
630
+ * The url path you want to redirect to or a function rule that returns the url path or performs a `$state.go()`.
631
+ * The function version is passed two params: `$injector` and `$location` services, and should return a url string.
632
+ *
633
+ * @return {object} `$urlRouterProvider` - `$urlRouterProvider` instance
634
+ */
635
+ UrlRouterProvider.prototype.otherwise = function (rule) {
636
+ var _this = this;
637
+ var urlRouter = this._urlRouter;
638
+ if (core.isString(rule)) {
639
+ urlRouter.otherwise(rule);
640
+ }
641
+ else if (core.isFunction(rule)) {
642
+ urlRouter.otherwise(function () { return rule(core.services.$injector, _this._router.locationService); });
643
+ }
644
+ else {
645
+ throw new Error("'rule' must be a string or function");
646
+ }
647
+ return this;
648
+ };
649
+
650
+ /**
651
+ * Registers a handler for a given url matching.
652
+ *
653
+ * If the handler is a string, it is
654
+ * treated as a redirect, and is interpolated according to the syntax of match
655
+ * (i.e. like `String.replace()` for `RegExp`, or like a `UrlMatcher` pattern otherwise).
656
+ *
657
+ * If the handler is a function, it is injectable.
658
+ * It gets invoked if `$location` matches.
659
+ * You have the option of inject the match object as `$match`.
660
+ *
661
+ * The handler can return
662
+ *
663
+ * - **falsy** to indicate that the rule didn't match after all, then `$urlRouter`
664
+ * will continue trying to find another one that matches.
665
+ * - **string** which is treated as a redirect and passed to `$location.url()`
666
+ * - **void** or any **truthy** value tells `$urlRouter` that the url was handled.
667
+ *
668
+ * #### Example:
669
+ * ```js
670
+ * var app = angular.module('app', ['ui.router.router']);
671
+ *
672
+ * app.config(function ($urlRouterProvider) {
673
+ * $urlRouterProvider.when($state.url, function ($match, $stateParams) {
674
+ * if ($state.$current.navigable !== state ||
675
+ * !equalForKeys($match, $stateParams) {
676
+ * $state.transitionTo(state, $match, false);
677
+ * }
678
+ * });
679
+ * });
680
+ * ```
681
+ *
682
+ * @param what A pattern string to match, compiled as a [[UrlMatcher]].
683
+ * @param handler The path (or function that returns a path) that you want to redirect your user to.
684
+ * @param ruleCallback [optional] A callback that receives the `rule` registered with [[UrlMatcher.rule]]
685
+ *
686
+ * Note: the handler may also invoke arbitrary code, such as `$state.go()`
687
+ */
688
+ UrlRouterProvider.prototype.when = function (what, handler) {
689
+ if (core.isArray(handler) || core.isFunction(handler)) {
690
+ handler = UrlRouterProvider.injectableHandler(this._router, handler);
691
+ }
692
+ this._urlRouter.when(what, handler);
693
+ return this;
694
+ };
695
+
696
+ UrlRouterProvider.injectableHandler = function (router, handler) {
697
+ return function (match) {
698
+ return core.services.$injector.invoke(handler, null, { $match: match, $stateParams: router.globals.params });
699
+ };
700
+ };
701
+ /**
702
+ * Disables monitoring of the URL.
703
+ *
704
+ * Call this method before UI-Router has bootstrapped.
705
+ * It will stop UI-Router from performing the initial url sync.
706
+ *
707
+ * This can be useful to perform some asynchronous initialization before the router starts.
708
+ * Once the initialization is complete, call [[listen]] to tell UI-Router to start watching and synchronizing the URL.
709
+ *
710
+ * #### Example:
711
+ * ```js
712
+ * var app = angular.module('app', ['ui.router']);
713
+ *
714
+ * app.config(function ($urlRouterProvider) {
715
+ * // Prevent $urlRouter from automatically intercepting URL changes;
716
+ * $urlRouterProvider.deferIntercept();
717
+ * })
718
+ *
719
+ * app.run(function (MyService, $urlRouter, $http) {
720
+ * $http.get("/stuff").then(function(resp) {
721
+ * MyService.doStuff(resp.data);
722
+ * $urlRouter.listen();
723
+ * $urlRouter.sync();
724
+ * });
725
+ * });
726
+ * ```
727
+ *
728
+ * @param defer Indicates whether to defer location change interception.
729
+ * Passing no parameter is equivalent to `true`.
730
+ */
731
+ UrlRouterProvider.prototype.deferIntercept = function (defer) {
732
+ this._urlRouter.deferIntercept(defer);
733
+ };
734
+
735
+ return UrlRouterProvider;
736
+ }());
737
+
738
+ /**
739
+ * # Angular 1 types
740
+ *
741
+ * UI-Router core provides various Typescript types which you can use for code completion and validating parameter values, etc.
742
+ * The customizations to the core types for Angular UI-Router are documented here.
743
+ *
744
+ * The optional [[$resolve]] service is also documented here.
745
+ *
746
+ * @module ng1
747
+ * @preferred
748
+ */
749
+ /** for typedoc */
750
+ ng.module("ui.router.angular1", []);
751
+ var mod_init = ng.module('ui.router.init', []);
752
+ var mod_util = ng.module('ui.router.util', ['ng', 'ui.router.init']);
753
+ var mod_rtr = ng.module('ui.router.router', ['ui.router.util']);
754
+ var mod_state = ng.module('ui.router.state', ['ui.router.router', 'ui.router.util', 'ui.router.angular1']);
755
+ var mod_main = ng.module('ui.router', ['ui.router.init', 'ui.router.state', 'ui.router.angular1']);
756
+ var mod_cmpt = ng.module('ui.router.compat', ['ui.router']); // tslint:disable-line
757
+ var router = null;
758
+ $uiRouter.$inject = ['$locationProvider'];
759
+ /** This angular 1 provider instantiates a Router and exposes its services via the angular injector */
760
+ function $uiRouter($locationProvider) {
761
+ // Create a new instance of the Router when the $uiRouterProvider is initialized
762
+ router = this.router = new core.UIRouter();
763
+ router.stateProvider = new StateProvider(router.stateRegistry, router.stateService);
764
+ // Apply ng1 specific StateBuilder code for `views`, `resolve`, and `onExit/Retain/Enter` properties
765
+ router.stateRegistry.decorator("views", ng1ViewsBuilder);
766
+ router.stateRegistry.decorator("onExit", getStateHookBuilder("onExit"));
767
+ router.stateRegistry.decorator("onRetain", getStateHookBuilder("onRetain"));
768
+ router.stateRegistry.decorator("onEnter", getStateHookBuilder("onEnter"));
769
+ router.viewService._pluginapi._viewConfigFactory('ng1', getNg1ViewConfigFactory());
770
+ var ng1LocationService = router.locationService = router.locationConfig = new Ng1LocationServices($locationProvider);
771
+ Ng1LocationServices.monkeyPatchPathParameterType(router);
772
+ // backwards compat: also expose router instance as $uiRouterProvider.router
773
+ router['router'] = router;
774
+ router['$get'] = $get;
775
+ $get.$inject = ['$location', '$browser', '$sniffer', '$rootScope', '$http', '$templateCache'];
776
+ function $get($location, $browser, $sniffer, $rootScope, $http, $templateCache) {
777
+ ng1LocationService._runtimeServices($rootScope, $location, $sniffer, $browser);
778
+ delete router['router'];
779
+ delete router['$get'];
780
+ return router;
781
+ }
782
+ return router;
783
+ }
784
+ var getProviderFor = function (serviceName) { return ['$uiRouterProvider', function ($urp) {
785
+ var service = $urp.router[serviceName];
786
+ service["$get"] = function () { return service; };
787
+ return service;
788
+ }]; };
789
+ // This effectively calls $get() on `$uiRouterProvider` to trigger init (when ng enters runtime)
790
+ runBlock.$inject = ['$injector', '$q', '$uiRouter'];
791
+ function runBlock($injector, $q, $uiRouter) {
792
+ core.services.$injector = $injector;
793
+ core.services.$q = $q;
794
+ // The $injector is now available.
795
+ // Find any resolvables that had dependency annotation deferred
796
+ $uiRouter.stateRegistry.get()
797
+ .map(function (x) { return x.$$state().resolvables; })
798
+ .reduce(core.unnestR, [])
799
+ .filter(function (x) { return x.deps === "deferred"; })
800
+ .forEach(function (resolvable) { return resolvable.deps = $injector.annotate(resolvable.resolveFn, $injector.strictDi); });
801
+ }
802
+ // $urlRouter service and $urlRouterProvider
803
+ var getUrlRouterProvider = function (uiRouter) {
804
+ return uiRouter.urlRouterProvider = new UrlRouterProvider(uiRouter);
805
+ };
806
+ // $state service and $stateProvider
807
+ // $urlRouter service and $urlRouterProvider
808
+ var getStateProvider = function () {
809
+ return core.extend(router.stateProvider, { $get: function () { return router.stateService; } });
810
+ };
811
+ watchDigests.$inject = ['$rootScope'];
812
+ function watchDigests($rootScope) {
813
+ $rootScope.$watch(function () { core.trace.approximateDigests++; });
814
+ }
815
+ mod_init.provider("$uiRouter", $uiRouter);
816
+ mod_rtr.provider('$urlRouter', ['$uiRouterProvider', getUrlRouterProvider]);
817
+ mod_util.provider('$urlService', getProviderFor('urlService'));
818
+ mod_util.provider('$urlMatcherFactory', ['$uiRouterProvider', function () { return router.urlMatcherFactory; }]);
819
+ mod_util.provider('$templateFactory', function () { return new TemplateFactory(); });
820
+ mod_state.provider('$stateRegistry', getProviderFor('stateRegistry'));
821
+ mod_state.provider('$uiRouterGlobals', getProviderFor('globals'));
822
+ mod_state.provider('$transitions', getProviderFor('transitionService'));
823
+ mod_state.provider('$state', ['$uiRouterProvider', getStateProvider]);
824
+ mod_state.factory('$stateParams', ['$uiRouter', function ($uiRouter) { return $uiRouter.globals.params; }]);
825
+ mod_main.factory('$view', function () { return router.viewService; });
826
+ mod_main.service("$trace", function () { return core.trace; });
827
+ mod_main.run(watchDigests);
828
+ mod_util.run(['$urlMatcherFactory', function ($urlMatcherFactory) { }]);
829
+ mod_state.run(['$state', function ($state) { }]);
830
+ mod_rtr.run(['$urlRouter', function ($urlRouter) { }]);
831
+ mod_init.run(runBlock);
832
+ /** @hidden TODO: find a place to move this */
833
+ var getLocals = function (ctx) {
834
+ var tokens = ctx.getTokens().filter(core.isString);
835
+ var tuples = tokens.map(function (key) {
836
+ var resolvable = ctx.getResolvable(key);
837
+ var waitPolicy = ctx.getPolicy(resolvable).async;
838
+ return [key, waitPolicy === 'NOWAIT' ? resolvable.promise : resolvable.data];
839
+ });
840
+ return tuples.reduce(core.applyPairs, {});
841
+ };
842
+
843
+ /**
844
+ * # Angular 1 injectable services
845
+ *
846
+ * This is a list of the objects which can be injected using angular's injector.
847
+ *
848
+ * There are three different kind of injectable objects:
849
+ *
850
+ * ## **Provider** objects
851
+ * #### injectable into a `.config()` block during configtime
852
+ *
853
+ * - [[$uiRouterProvider]]: The UI-Router instance
854
+ * - [[$stateProvider]]: State registration
855
+ * - [[$transitionsProvider]]: Transition hooks
856
+ * - [[$urlServiceProvider]]: All URL related public APIs
857
+ *
858
+ * - [[$uiViewScrollProvider]]: Disable ui-router view scrolling
859
+ * - [[$urlRouterProvider]]: (deprecated) Url matching rules
860
+ * - [[$urlMatcherFactoryProvider]]: (deprecated) Url parsing config
861
+ *
862
+ * ## **Service** objects
863
+ * #### injectable globally during runtime
864
+ *
865
+ * - [[$uiRouter]]: The UI-Router instance
866
+ * - [[$trace]]: Enable transition trace/debug
867
+ * - [[$transitions]]: Transition hooks
868
+ * - [[$state]]: Imperative state related APIs
869
+ * - [[$stateRegistry]]: State registration
870
+ * - [[$urlService]]: All URL related public APIs
871
+ * - [[$uiRouterGlobals]]: Global variables
872
+ * - [[$uiViewScroll]]: Scroll an element into view
873
+ *
874
+ * - [[$stateParams]]: (deprecated) Global state param values
875
+ * - [[$urlRouter]]: (deprecated) URL synchronization
876
+ * - [[$urlMatcherFactory]]: (deprecated) URL parsing config
877
+ *
878
+ * ## **Per-Transition** objects
879
+ *
880
+ * - These kind of objects are injectable into:
881
+ * - Resolves ([[Ng1StateDeclaration.resolve]]),
882
+ * - Transition Hooks ([[TransitionService.onStart]], etc),
883
+ * - Routed Controllers ([[Ng1ViewDeclaration.controller]])
884
+ *
885
+ * #### Different instances are injected based on the [[Transition]]
886
+ *
887
+ * - [[$transition$]]: The current Transition object
888
+ * - [[$stateParams]]: State param values for pending Transition (deprecated)
889
+ * - Any resolve data defined using [[Ng1StateDeclaration.resolve]]
890
+ *
891
+ * @ng1api
892
+ * @preferred
893
+ * @module injectables
894
+ */ /** */
895
+ /**
896
+ * The current (or pending) State Parameters
897
+ *
898
+ * An injectable global **Service Object** which holds the state parameters for the latest **SUCCESSFUL** transition.
899
+ *
900
+ * The values are not updated until *after* a `Transition` successfully completes.
901
+ *
902
+ * **Also:** an injectable **Per-Transition Object** object which holds the pending state parameters for the pending `Transition` currently running.
903
+ *
904
+ * ### Deprecation warning:
905
+ *
906
+ * The value injected for `$stateParams` is different depending on where it is injected.
907
+ *
908
+ * - When injected into an angular service, the object injected is the global **Service Object** with the parameter values for the latest successful `Transition`.
909
+ * - When injected into transition hooks, resolves, or view controllers, the object is the **Per-Transition Object** with the parameter values for the running `Transition`.
910
+ *
911
+ * Because of these confusing details, this service is deprecated.
912
+ *
913
+ * ### Instead of using the global `$stateParams` service object,
914
+ * inject [[$uiRouterGlobals]] and use [[UIRouterGlobals.params]]
915
+ *
916
+ * ```js
917
+ * MyService.$inject = ['$uiRouterGlobals'];
918
+ * function MyService($uiRouterGlobals) {
919
+ * return {
920
+ * paramValues: function () {
921
+ * return $uiRouterGlobals.params;
922
+ * }
923
+ * }
924
+ * }
925
+ * ```
926
+ *
927
+ * ### Instead of using the per-transition `$stateParams` object,
928
+ * inject the current `Transition` (as [[$transition$]]) and use [[Transition.params]]
929
+ *
930
+ * ```js
931
+ * MyController.$inject = ['$transition$'];
932
+ * function MyController($transition$) {
933
+ * var username = $transition$.params().username;
934
+ * // .. do something with username
935
+ * }
936
+ * ```
937
+ *
938
+ * ---
939
+ *
940
+ * This object can be injected into other services.
941
+ *
942
+ * #### Deprecated Example:
943
+ * ```js
944
+ * SomeService.$inject = ['$http', '$stateParams'];
945
+ * function SomeService($http, $stateParams) {
946
+ * return {
947
+ * getUser: function() {
948
+ * return $http.get('/api/users/' + $stateParams.username);
949
+ * }
950
+ * }
951
+ * };
952
+ * angular.service('SomeService', SomeService);
953
+ * ```
954
+ * @deprecated
955
+ */
956
+
957
+ /**
958
+ * # Angular 1 Directives
959
+ *
960
+ * These are the directives included in UI-Router for Angular 1.
961
+ * These directives are used in templates to create viewports and link/navigate to states.
962
+ *
963
+ * @ng1api
964
+ * @preferred
965
+ * @module directives
966
+ */ /** for typedoc */
967
+ /** @hidden */
968
+ function parseStateRef(ref) {
969
+ var paramsOnly = ref.match(/^\s*({[^}]*})\s*$/), parsed;
970
+ if (paramsOnly)
971
+ ref = '(' + paramsOnly[1] + ')';
972
+ parsed = ref.replace(/\n/g, " ").match(/^\s*([^(]*?)\s*(\((.*)\))?\s*$/);
973
+ if (!parsed || parsed.length !== 4)
974
+ throw new Error("Invalid state ref '" + ref + "'");
975
+ return { state: parsed[1] || null, paramExpr: parsed[3] || null };
976
+ }
977
+ /** @hidden */
978
+ function stateContext(el) {
979
+ var $uiView = el.parent().inheritedData('$uiView');
980
+ var path = core.parse('$cfg.path')($uiView);
981
+ return path ? core.tail(path).state.name : undefined;
982
+ }
983
+ /** @hidden */
984
+ function processedDef($state, $element, def) {
985
+ var uiState = def.uiState || $state.current.name;
986
+ var uiStateOpts = core.extend(defaultOpts($element, $state), def.uiStateOpts || {});
987
+ var href = $state.href(uiState, def.uiStateParams, uiStateOpts);
988
+ return { uiState: uiState, uiStateParams: def.uiStateParams, uiStateOpts: uiStateOpts, href: href };
989
+ }
990
+ /** @hidden */
991
+ function getTypeInfo(el) {
992
+ // SVGAElement does not use the href attribute, but rather the 'xlinkHref' attribute.
993
+ var isSvg = Object.prototype.toString.call(el.prop('href')) === '[object SVGAnimatedString]';
994
+ var isForm = el[0].nodeName === "FORM";
995
+ return {
996
+ attr: isForm ? "action" : (isSvg ? 'xlink:href' : 'href'),
997
+ isAnchor: el.prop("tagName").toUpperCase() === "A",
998
+ clickable: !isForm
999
+ };
1000
+ }
1001
+ /** @hidden */
1002
+ function clickHook(el, $state, $timeout, type, getDef) {
1003
+ return function (e) {
1004
+ var button = e.which || e.button, target = getDef();
1005
+ if (!(button > 1 || e.ctrlKey || e.metaKey || e.shiftKey || el.attr('target'))) {
1006
+ // HACK: This is to allow ng-clicks to be processed before the transition is initiated:
1007
+ var transition = $timeout(function () {
1008
+ $state.go(target.uiState, target.uiStateParams, target.uiStateOpts);
1009
+ });
1010
+ e.preventDefault();
1011
+ // if the state has no URL, ignore one preventDefault from the <a> directive.
1012
+ var ignorePreventDefaultCount = type.isAnchor && !target.href ? 1 : 0;
1013
+ e.preventDefault = function () {
1014
+ if (ignorePreventDefaultCount-- <= 0)
1015
+ $timeout.cancel(transition);
1016
+ };
1017
+ }
1018
+ };
1019
+ }
1020
+ /** @hidden */
1021
+ function defaultOpts(el, $state) {
1022
+ return {
1023
+ relative: stateContext(el) || $state.$current,
1024
+ inherit: true,
1025
+ source: "sref"
1026
+ };
1027
+ }
1028
+ /** @hidden */
1029
+ function bindEvents(element, scope, hookFn, uiStateOpts) {
1030
+ var events;
1031
+ if (uiStateOpts) {
1032
+ events = uiStateOpts.events;
1033
+ }
1034
+ if (!core.isArray(events)) {
1035
+ events = ['click'];
1036
+ }
1037
+ var on = element.on ? 'on' : 'bind';
1038
+ for (var _i = 0, events_1 = events; _i < events_1.length; _i++) {
1039
+ var event_1 = events_1[_i];
1040
+ element[on](event_1, hookFn);
1041
+ }
1042
+ scope.$on('$destroy', function () {
1043
+ var off = element.off ? 'off' : 'unbind';
1044
+ for (var _i = 0, events_2 = events; _i < events_2.length; _i++) {
1045
+ var event_2 = events_2[_i];
1046
+ element[off](event_2, hookFn);
1047
+ }
1048
+ });
1049
+ }
1050
+ /**
1051
+ * `ui-sref`: A directive for linking to a state
1052
+ *
1053
+ * A directive which links to a state (and optionally, parameters).
1054
+ * When clicked, this directive activates the linked state with the supplied parameter values.
1055
+ *
1056
+ * ### Linked State
1057
+ * The attribute value of the `ui-sref` is the name of the state to link to.
1058
+ *
1059
+ * #### Example:
1060
+ * This will activate the `home` state when the link is clicked.
1061
+ * ```html
1062
+ * <a ui-sref="home">Home</a>
1063
+ * ```
1064
+ *
1065
+ * ### Relative Links
1066
+ * You can also use relative state paths within `ui-sref`, just like a relative path passed to `$state.go()` ([[StateService.go]]).
1067
+ * You just need to be aware that the path is relative to the state that *created* the link.
1068
+ * This allows a state to create a relative `ui-sref` which always targets the same destination.
1069
+ *
1070
+ * #### Example:
1071
+ * Both these links are relative to the parent state, even when a child state is currently active.
1072
+ * ```html
1073
+ * <a ui-sref=".child1">child 1 state</a>
1074
+ * <a ui-sref=".child2">child 2 state</a>
1075
+ * ```
1076
+ *
1077
+ * This link activates the parent state.
1078
+ * ```html
1079
+ * <a ui-sref="^">Return</a>
1080
+ * ```
1081
+ *
1082
+ * ### hrefs
1083
+ * If the linked state has a URL, the directive will automatically generate and
1084
+ * update the `href` attribute (using the [[StateService.href]] method).
1085
+ *
1086
+ * #### Example:
1087
+ * Assuming the `users` state has a url of `/users/`
1088
+ * ```html
1089
+ * <a ui-sref="users" href="/users/">Users</a>
1090
+ * ```
1091
+ *
1092
+ * ### Parameter Values
1093
+ * In addition to the state name, a `ui-sref` can include parameter values which are applied when activating the state.
1094
+ * Param values can be provided in the `ui-sref` value after the state name, enclosed by parentheses.
1095
+ * The content inside the parentheses is an expression, evaluated to the parameter values.
1096
+ *
1097
+ * #### Example:
1098
+ * This example renders a list of links to users.
1099
+ * The state's `userId` parameter value comes from each user's `user.id` property.
1100
+ * ```html
1101
+ * <li ng-repeat="user in users">
1102
+ * <a ui-sref="users.detail({ userId: user.id })">{{ user.displayName }}</a>
1103
+ * </li>
1104
+ * ```
1105
+ *
1106
+ * Note:
1107
+ * The parameter values expression is `$watch`ed for updates.
1108
+ *
1109
+ * ### Transition Options
1110
+ * You can specify [[TransitionOptions]] to pass to [[StateService.go]] by using the `ui-sref-opts` attribute.
1111
+ * Options are restricted to `location`, `inherit`, and `reload`.
1112
+ *
1113
+ * #### Example:
1114
+ * ```html
1115
+ * <a ui-sref="home" ui-sref-opts="{ reload: true }">Home</a>
1116
+ * ```
1117
+ *
1118
+ * ### Other DOM Events
1119
+ *
1120
+ * You can also customize which DOM events to respond to (instead of `click`) by
1121
+ * providing an `events` array in the `ui-sref-opts` attribute.
1122
+ *
1123
+ * #### Example:
1124
+ * ```html
1125
+ * <input type="text" ui-sref="contacts" ui-sref-opts="{ events: ['change', 'blur'] }">
1126
+ * ```
1127
+ *
1128
+ * ### Highlighting the active link
1129
+ * This directive can be used in conjunction with [[uiSrefActive]] to highlight the active link.
1130
+ *
1131
+ * ### Examples
1132
+ * If you have the following template:
1133
+ *
1134
+ * ```html
1135
+ * <a ui-sref="home">Home</a>
1136
+ * <a ui-sref="about">About</a>
1137
+ * <a ui-sref="{page: 2}">Next page</a>
1138
+ *
1139
+ * <ul>
1140
+ * <li ng-repeat="contact in contacts">
1141
+ * <a ui-sref="contacts.detail({ id: contact.id })">{{ contact.name }}</a>
1142
+ * </li>
1143
+ * </ul>
1144
+ * ```
1145
+ *
1146
+ * Then (assuming the current state is `contacts`) the rendered html including hrefs would be:
1147
+ *
1148
+ * ```html
1149
+ * <a href="#/home" ui-sref="home">Home</a>
1150
+ * <a href="#/about" ui-sref="about">About</a>
1151
+ * <a href="#/contacts?page=2" ui-sref="{page: 2}">Next page</a>
1152
+ *
1153
+ * <ul>
1154
+ * <li ng-repeat="contact in contacts">
1155
+ * <a href="#/contacts/1" ui-sref="contacts.detail({ id: contact.id })">Joe</a>
1156
+ * </li>
1157
+ * <li ng-repeat="contact in contacts">
1158
+ * <a href="#/contacts/2" ui-sref="contacts.detail({ id: contact.id })">Alice</a>
1159
+ * </li>
1160
+ * <li ng-repeat="contact in contacts">
1161
+ * <a href="#/contacts/3" ui-sref="contacts.detail({ id: contact.id })">Bob</a>
1162
+ * </li>
1163
+ * </ul>
1164
+ *
1165
+ * <a href="#/home" ui-sref="home" ui-sref-opts="{reload: true}">Home</a>
1166
+ * ```
1167
+ *
1168
+ * ### Notes
1169
+ *
1170
+ * - You can use `ui-sref` to change **only the parameter values** by omitting the state name and parentheses.
1171
+ * #### Example:
1172
+ * Sets the `lang` parameter to `en` and remains on the same state.
1173
+ *
1174
+ * ```html
1175
+ * <a ui-sref="{ lang: 'en' }">English</a>
1176
+ * ```
1177
+ *
1178
+ * - A middle-click, right-click, or ctrl-click is handled (natively) by the browser to open the href in a new window, for example.
1179
+ *
1180
+ * - Unlike the parameter values expression, the state name is not `$watch`ed (for performance reasons).
1181
+ * If you need to dynamically update the state being linked to, use the fully dynamic [[uiState]] directive.
1182
+ */
1183
+ var uiSref;
1184
+ uiSref = ['$uiRouter', '$timeout',
1185
+ function $StateRefDirective($uiRouter, $timeout) {
1186
+ var $state = $uiRouter.stateService;
1187
+ return {
1188
+ restrict: 'A',
1189
+ require: ['?^uiSrefActive', '?^uiSrefActiveEq'],
1190
+ link: function (scope, element, attrs, uiSrefActive) {
1191
+ var type = getTypeInfo(element);
1192
+ var active = uiSrefActive[1] || uiSrefActive[0];
1193
+ var unlinkInfoFn = null;
1194
+ var hookFn;
1195
+ var rawDef = {};
1196
+ var getDef = function () { return processedDef($state, element, rawDef); };
1197
+ var ref = parseStateRef(attrs.uiSref);
1198
+ rawDef.uiState = ref.state;
1199
+ rawDef.uiStateOpts = attrs.uiSrefOpts ? scope.$eval(attrs.uiSrefOpts) : {};
1200
+ function update() {
1201
+ var def = getDef();
1202
+ if (unlinkInfoFn)
1203
+ unlinkInfoFn();
1204
+ if (active)
1205
+ unlinkInfoFn = active.$$addStateInfo(def.uiState, def.uiStateParams);
1206
+ if (def.href != null)
1207
+ attrs.$set(type.attr, def.href);
1208
+ }
1209
+ if (ref.paramExpr) {
1210
+ scope.$watch(ref.paramExpr, function (val$$1) {
1211
+ rawDef.uiStateParams = core.extend({}, val$$1);
1212
+ update();
1213
+ }, true);
1214
+ rawDef.uiStateParams = core.extend({}, scope.$eval(ref.paramExpr));
1215
+ }
1216
+ update();
1217
+ scope.$on('$destroy', $uiRouter.stateRegistry.onStatesChanged(update));
1218
+ scope.$on('$destroy', $uiRouter.transitionService.onSuccess({}, update));
1219
+ if (!type.clickable)
1220
+ return;
1221
+ hookFn = clickHook(element, $state, $timeout, type, getDef);
1222
+ bindEvents(element, scope, hookFn, rawDef.uiStateOpts);
1223
+ }
1224
+ };
1225
+ }];
1226
+ /**
1227
+ * `ui-state`: A fully dynamic directive for linking to a state
1228
+ *
1229
+ * A directive which links to a state (and optionally, parameters).
1230
+ * When clicked, this directive activates the linked state with the supplied parameter values.
1231
+ *
1232
+ * **This directive is very similar to [[uiSref]], but it `$observe`s and `$watch`es/evaluates all its inputs.**
1233
+ *
1234
+ * A directive which links to a state (and optionally, parameters).
1235
+ * When clicked, this directive activates the linked state with the supplied parameter values.
1236
+ *
1237
+ * ### Linked State
1238
+ * The attribute value of `ui-state` is an expression which is `$watch`ed and evaluated as the state to link to.
1239
+ * **This is in contrast with `ui-sref`, which takes a state name as a string literal.**
1240
+ *
1241
+ * #### Example:
1242
+ * Create a list of links.
1243
+ * ```html
1244
+ * <li ng-repeat="link in navlinks">
1245
+ * <a ui-state="link.state">{{ link.displayName }}</a>
1246
+ * </li>
1247
+ * ```
1248
+ *
1249
+ * ### Relative Links
1250
+ * If the expression evaluates to a relative path, it is processed like [[uiSref]].
1251
+ * You just need to be aware that the path is relative to the state that *created* the link.
1252
+ * This allows a state to create relative `ui-state` which always targets the same destination.
1253
+ *
1254
+ * ### hrefs
1255
+ * If the linked state has a URL, the directive will automatically generate and
1256
+ * update the `href` attribute (using the [[StateService.href]] method).
1257
+ *
1258
+ * ### Parameter Values
1259
+ * In addition to the state name expression, a `ui-state` can include parameter values which are applied when activating the state.
1260
+ * Param values should be provided using the `ui-state-params` attribute.
1261
+ * The `ui-state-params` attribute value is `$watch`ed and evaluated as an expression.
1262
+ *
1263
+ * #### Example:
1264
+ * This example renders a list of links with param values.
1265
+ * The state's `userId` parameter value comes from each user's `user.id` property.
1266
+ * ```html
1267
+ * <li ng-repeat="link in navlinks">
1268
+ * <a ui-state="link.state" ui-state-params="link.params">{{ link.displayName }}</a>
1269
+ * </li>
1270
+ * ```
1271
+ *
1272
+ * ### Transition Options
1273
+ * You can specify [[TransitionOptions]] to pass to [[StateService.go]] by using the `ui-state-opts` attribute.
1274
+ * Options are restricted to `location`, `inherit`, and `reload`.
1275
+ * The value of the `ui-state-opts` is `$watch`ed and evaluated as an expression.
1276
+ *
1277
+ * #### Example:
1278
+ * ```html
1279
+ * <a ui-state="returnto.state" ui-state-opts="{ reload: true }">Home</a>
1280
+ * ```
1281
+ *
1282
+ * ### Other DOM Events
1283
+ *
1284
+ * You can also customize which DOM events to respond to (instead of `click`) by
1285
+ * providing an `events` array in the `ui-state-opts` attribute.
1286
+ *
1287
+ * #### Example:
1288
+ * ```html
1289
+ * <input type="text" ui-state="contacts" ui-state-opts="{ events: ['change', 'blur'] }">
1290
+ * ```
1291
+ *
1292
+ * ### Highlighting the active link
1293
+ * This directive can be used in conjunction with [[uiSrefActive]] to highlight the active link.
1294
+ *
1295
+ * ### Notes
1296
+ *
1297
+ * - You can use `ui-params` to change **only the parameter values** by omitting the state name and supplying only `ui-state-params`.
1298
+ * However, it might be simpler to use [[uiSref]] parameter-only links.
1299
+ *
1300
+ * #### Example:
1301
+ * Sets the `lang` parameter to `en` and remains on the same state.
1302
+ *
1303
+ * ```html
1304
+ * <a ui-state="" ui-state-params="{ lang: 'en' }">English</a>
1305
+ * ```
1306
+ *
1307
+ * - A middle-click, right-click, or ctrl-click is handled (natively) by the browser to open the href in a new window, for example.
1308
+ * ```
1309
+ */
1310
+ var uiState;
1311
+ uiState = ['$uiRouter', '$timeout',
1312
+ function $StateRefDynamicDirective($uiRouter, $timeout) {
1313
+ var $state = $uiRouter.stateService;
1314
+ return {
1315
+ restrict: 'A',
1316
+ require: ['?^uiSrefActive', '?^uiSrefActiveEq'],
1317
+ link: function (scope, element, attrs, uiSrefActive) {
1318
+ var type = getTypeInfo(element);
1319
+ var active = uiSrefActive[1] || uiSrefActive[0];
1320
+ var unlinkInfoFn = null;
1321
+ var hookFn;
1322
+ var rawDef = {};
1323
+ var getDef = function () { return processedDef($state, element, rawDef); };
1324
+ var inputAttrs = ['uiState', 'uiStateParams', 'uiStateOpts'];
1325
+ var watchDeregFns = inputAttrs.reduce(function (acc, attr) { return (acc[attr] = core.noop, acc); }, {});
1326
+ function update() {
1327
+ var def = getDef();
1328
+ if (unlinkInfoFn)
1329
+ unlinkInfoFn();
1330
+ if (active)
1331
+ unlinkInfoFn = active.$$addStateInfo(def.uiState, def.uiStateParams);
1332
+ if (def.href != null)
1333
+ attrs.$set(type.attr, def.href);
1334
+ }
1335
+ inputAttrs.forEach(function (field) {
1336
+ rawDef[field] = attrs[field] ? scope.$eval(attrs[field]) : null;
1337
+ attrs.$observe(field, function (expr) {
1338
+ watchDeregFns[field]();
1339
+ watchDeregFns[field] = scope.$watch(expr, function (newval) {
1340
+ rawDef[field] = newval;
1341
+ update();
1342
+ }, true);
1343
+ });
1344
+ });
1345
+ update();
1346
+ scope.$on('$destroy', $uiRouter.stateRegistry.onStatesChanged(update));
1347
+ scope.$on('$destroy', $uiRouter.transitionService.onSuccess({}, update));
1348
+ if (!type.clickable)
1349
+ return;
1350
+ hookFn = clickHook(element, $state, $timeout, type, getDef);
1351
+ bindEvents(element, scope, hookFn, rawDef.uiStateOpts);
1352
+ }
1353
+ };
1354
+ }];
1355
+ /**
1356
+ * `ui-sref-active` and `ui-sref-active-eq`: A directive that adds a CSS class when a `ui-sref` is active
1357
+ *
1358
+ * A directive working alongside [[uiSref]] and [[uiState]] to add classes to an element when the
1359
+ * related directive's state is active (and remove them when it is inactive).
1360
+ *
1361
+ * The primary use-case is to highlight the active link in navigation menus,
1362
+ * distinguishing it from the inactive menu items.
1363
+ *
1364
+ * ### Linking to a `ui-sref` or `ui-state`
1365
+ * `ui-sref-active` can live on the same element as `ui-sref`/`ui-state`, or it can be on a parent element.
1366
+ * If a `ui-sref-active` is a parent to more than one `ui-sref`/`ui-state`, it will apply the CSS class when **any of the links are active**.
1367
+ *
1368
+ * ### Matching
1369
+ *
1370
+ * The `ui-sref-active` directive applies the CSS class when the `ui-sref`/`ui-state`'s target state **or any child state is active**.
1371
+ * This is a "fuzzy match" which uses [[StateService.includes]].
1372
+ *
1373
+ * The `ui-sref-active-eq` directive applies the CSS class when the `ui-sref`/`ui-state`'s target state is directly active (not when child states are active).
1374
+ * This is an "exact match" which uses [[StateService.is]].
1375
+ *
1376
+ * ### Parameter values
1377
+ * If the `ui-sref`/`ui-state` includes parameter values, the current parameter values must match the link's values for the link to be highlighted.
1378
+ * This allows a list of links to the same state with different parameters to be rendered, and the correct one highlighted.
1379
+ *
1380
+ * #### Example:
1381
+ * ```html
1382
+ * <li ng-repeat="user in users" ui-sref-active="active">
1383
+ * <a ui-sref="user.details({ userId: user.id })">{{ user.lastName }}</a>
1384
+ * </li>
1385
+ * ```
1386
+ *
1387
+ * ### Examples
1388
+ *
1389
+ * Given the following template:
1390
+ * #### Example:
1391
+ * ```html
1392
+ * <ul>
1393
+ * <li ui-sref-active="active" class="item">
1394
+ * <a href ui-sref="app.user({user: 'bilbobaggins'})">@bilbobaggins</a>
1395
+ * </li>
1396
+ * </ul>
1397
+ * ```
1398
+ *
1399
+ * When the app state is `app.user` (or any child state),
1400
+ * and contains the state parameter "user" with value "bilbobaggins",
1401
+ * the resulting HTML will appear as (note the 'active' class):
1402
+ *
1403
+ * ```html
1404
+ * <ul>
1405
+ * <li ui-sref-active="active" class="item active">
1406
+ * <a ui-sref="app.user({user: 'bilbobaggins'})" href="/users/bilbobaggins">@bilbobaggins</a>
1407
+ * </li>
1408
+ * </ul>
1409
+ * ```
1410
+ *
1411
+ * ### Glob mode
1412
+ *
1413
+ * It is possible to pass `ui-sref-active` an expression that evaluates to an object.
1414
+ * The objects keys represent active class names and values represent the respective state names/globs.
1415
+ * `ui-sref-active` will match if the current active state **includes** any of
1416
+ * the specified state names/globs, even the abstract ones.
1417
+ *
1418
+ * #### Example:
1419
+ * Given the following template, with "admin" being an abstract state:
1420
+ * ```html
1421
+ * <div ui-sref-active="{'active': 'admin.**'}">
1422
+ * <a ui-sref-active="active" ui-sref="admin.roles">Roles</a>
1423
+ * </div>
1424
+ * ```
1425
+ *
1426
+ * When the current state is "admin.roles" the "active" class will be applied to both the <div> and <a> elements.
1427
+ * It is important to note that the state names/globs passed to `ui-sref-active` override any state provided by a linked `ui-sref`.
1428
+ *
1429
+ * ### Notes:
1430
+ *
1431
+ * - The class name is interpolated **once** during the directives link time (any further changes to the
1432
+ * interpolated value are ignored).
1433
+ *
1434
+ * - Multiple classes may be specified in a space-separated format: `ui-sref-active='class1 class2 class3'`
1435
+ */
1436
+ var uiSrefActive;
1437
+ uiSrefActive = ['$state', '$stateParams', '$interpolate', '$uiRouter',
1438
+ function $StateRefActiveDirective($state, $stateParams, $interpolate, $uiRouter) {
1439
+ return {
1440
+ restrict: "A",
1441
+ controller: ['$scope', '$element', '$attrs',
1442
+ function ($scope, $element, $attrs) {
1443
+ var states = [], activeEqClass, uiSrefActive;
1444
+ // There probably isn't much point in $observing this
1445
+ // uiSrefActive and uiSrefActiveEq share the same directive object with some
1446
+ // slight difference in logic routing
1447
+ activeEqClass = $interpolate($attrs.uiSrefActiveEq || '', false)($scope);
1448
+ try {
1449
+ uiSrefActive = $scope.$eval($attrs.uiSrefActive);
1450
+ }
1451
+ catch (e) {
1452
+ // Do nothing. uiSrefActive is not a valid expression.
1453
+ // Fall back to using $interpolate below
1454
+ }
1455
+ uiSrefActive = uiSrefActive || $interpolate($attrs.uiSrefActive || '', false)($scope);
1456
+ if (core.isObject(uiSrefActive)) {
1457
+ core.forEach(uiSrefActive, function (stateOrName, activeClass) {
1458
+ if (core.isString(stateOrName)) {
1459
+ var ref = parseStateRef(stateOrName);
1460
+ addState(ref.state, $scope.$eval(ref.paramExpr), activeClass);
1461
+ }
1462
+ });
1463
+ }
1464
+ // Allow uiSref to communicate with uiSrefActive[Equals]
1465
+ this.$$addStateInfo = function (newState, newParams) {
1466
+ // we already got an explicit state provided by ui-sref-active, so we
1467
+ // shadow the one that comes from ui-sref
1468
+ if (core.isObject(uiSrefActive) && states.length > 0) {
1469
+ return;
1470
+ }
1471
+ var deregister = addState(newState, newParams, uiSrefActive);
1472
+ update();
1473
+ return deregister;
1474
+ };
1475
+ function updateAfterTransition(trans) {
1476
+ trans.promise.then(update, core.noop);
1477
+ }
1478
+ $scope.$on('$stateChangeSuccess', update);
1479
+ $scope.$on('$destroy', $uiRouter.transitionService.onStart({}, updateAfterTransition));
1480
+ if ($uiRouter.globals.transition) {
1481
+ updateAfterTransition($uiRouter.globals.transition);
1482
+ }
1483
+ function addState(stateName, stateParams, activeClass) {
1484
+ var state = $state.get(stateName, stateContext($element));
1485
+ var stateInfo = {
1486
+ state: state || { name: stateName },
1487
+ params: stateParams,
1488
+ activeClass: activeClass
1489
+ };
1490
+ states.push(stateInfo);
1491
+ return function removeState() {
1492
+ core.removeFrom(states)(stateInfo);
1493
+ };
1494
+ }
1495
+ // Update route state
1496
+ function update() {
1497
+ var splitClasses = function (str) {
1498
+ return str.split(/\s/).filter(core.identity);
1499
+ };
1500
+ var getClasses = function (stateList) {
1501
+ return stateList.map(function (x) { return x.activeClass; }).map(splitClasses).reduce(core.unnestR, []);
1502
+ };
1503
+ var allClasses = getClasses(states).concat(splitClasses(activeEqClass)).reduce(core.uniqR, []);
1504
+ var fuzzyClasses = getClasses(states.filter(function (x) { return $state.includes(x.state.name, x.params); }));
1505
+ var exactlyMatchesAny = !!states.filter(function (x) { return $state.is(x.state.name, x.params); }).length;
1506
+ var exactClasses = exactlyMatchesAny ? splitClasses(activeEqClass) : [];
1507
+ var addClasses = fuzzyClasses.concat(exactClasses).reduce(core.uniqR, []);
1508
+ var removeClasses = allClasses.filter(function (cls) { return !core.inArray(addClasses, cls); });
1509
+ $scope.$evalAsync(function () {
1510
+ addClasses.forEach(function (className) { return $element.addClass(className); });
1511
+ removeClasses.forEach(function (className) { return $element.removeClass(className); });
1512
+ });
1513
+ }
1514
+ update();
1515
+ }]
1516
+ };
1517
+ }];
1518
+ ng.module('ui.router.state')
1519
+ .directive('uiSref', uiSref)
1520
+ .directive('uiSrefActive', uiSrefActive)
1521
+ .directive('uiSrefActiveEq', uiSrefActive)
1522
+ .directive('uiState', uiState);
1523
+
1524
+ /** @module ng1 */ /** for typedoc */
1525
+ /**
1526
+ * `isState` Filter: truthy if the current state is the parameter
1527
+ *
1528
+ * Translates to [[StateService.is]] `$state.is("stateName")`.
1529
+ *
1530
+ * #### Example:
1531
+ * ```html
1532
+ * <div ng-if="'stateName' | isState">show if state is 'stateName'</div>
1533
+ * ```
1534
+ */
1535
+ $IsStateFilter.$inject = ['$state'];
1536
+ function $IsStateFilter($state) {
1537
+ var isFilter = function (state, params, options) {
1538
+ return $state.is(state, params, options);
1539
+ };
1540
+ isFilter.$stateful = true;
1541
+ return isFilter;
1542
+ }
1543
+ /**
1544
+ * `includedByState` Filter: truthy if the current state includes the parameter
1545
+ *
1546
+ * Translates to [[StateService.includes]]` $state.is("fullOrPartialStateName")`.
1547
+ *
1548
+ * #### Example:
1549
+ * ```html
1550
+ * <div ng-if="'fullOrPartialStateName' | includedByState">show if state includes 'fullOrPartialStateName'</div>
1551
+ * ```
1552
+ */
1553
+ $IncludedByStateFilter.$inject = ['$state'];
1554
+ function $IncludedByStateFilter($state) {
1555
+ var includesFilter = function (state, params, options) {
1556
+ return $state.includes(state, params, options);
1557
+ };
1558
+ includesFilter.$stateful = true;
1559
+ return includesFilter;
1560
+ }
1561
+ ng.module('ui.router.state')
1562
+ .filter('isState', $IsStateFilter)
1563
+ .filter('includedByState', $IncludedByStateFilter);
1564
+
1565
+ /**
1566
+ * @ng1api
1567
+ * @module directives
1568
+ */ /** for typedoc */
1569
+ /**
1570
+ * `ui-view`: A viewport directive which is filled in by a view from the active state.
1571
+ *
1572
+ * ### Attributes
1573
+ *
1574
+ * - `name`: (Optional) A view name.
1575
+ * The name should be unique amongst the other views in the same state.
1576
+ * You can have views of the same name that live in different states.
1577
+ * The ui-view can be targeted in a View using the name ([[Ng1StateDeclaration.views]]).
1578
+ *
1579
+ * - `autoscroll`: an expression. When it evaluates to true, the `ui-view` will be scrolled into view when it is activated.
1580
+ * Uses [[$uiViewScroll]] to do the scrolling.
1581
+ *
1582
+ * - `onload`: Expression to evaluate whenever the view updates.
1583
+ *
1584
+ * #### Example:
1585
+ * A view can be unnamed or named.
1586
+ * ```html
1587
+ * <!-- Unnamed -->
1588
+ * <div ui-view></div>
1589
+ *
1590
+ * <!-- Named -->
1591
+ * <div ui-view="viewName"></div>
1592
+ *
1593
+ * <!-- Named (different style) -->
1594
+ * <ui-view name="viewName"></ui-view>
1595
+ * ```
1596
+ *
1597
+ * You can only have one unnamed view within any template (or root html). If you are only using a
1598
+ * single view and it is unnamed then you can populate it like so:
1599
+ *
1600
+ * ```html
1601
+ * <div ui-view></div>
1602
+ * $stateProvider.state("home", {
1603
+ * template: "<h1>HELLO!</h1>"
1604
+ * })
1605
+ * ```
1606
+ *
1607
+ * The above is a convenient shortcut equivalent to specifying your view explicitly with the
1608
+ * [[Ng1StateDeclaration.views]] config property, by name, in this case an empty name:
1609
+ *
1610
+ * ```js
1611
+ * $stateProvider.state("home", {
1612
+ * views: {
1613
+ * "": {
1614
+ * template: "<h1>HELLO!</h1>"
1615
+ * }
1616
+ * }
1617
+ * })
1618
+ * ```
1619
+ *
1620
+ * But typically you'll only use the views property if you name your view or have more than one view
1621
+ * in the same template. There's not really a compelling reason to name a view if its the only one,
1622
+ * but you could if you wanted, like so:
1623
+ *
1624
+ * ```html
1625
+ * <div ui-view="main"></div>
1626
+ * ```
1627
+ *
1628
+ * ```js
1629
+ * $stateProvider.state("home", {
1630
+ * views: {
1631
+ * "main": {
1632
+ * template: "<h1>HELLO!</h1>"
1633
+ * }
1634
+ * }
1635
+ * })
1636
+ * ```
1637
+ *
1638
+ * Really though, you'll use views to set up multiple views:
1639
+ *
1640
+ * ```html
1641
+ * <div ui-view></div>
1642
+ * <div ui-view="chart"></div>
1643
+ * <div ui-view="data"></div>
1644
+ * ```
1645
+ *
1646
+ * ```js
1647
+ * $stateProvider.state("home", {
1648
+ * views: {
1649
+ * "": {
1650
+ * template: "<h1>HELLO!</h1>"
1651
+ * },
1652
+ * "chart": {
1653
+ * template: "<chart_thing/>"
1654
+ * },
1655
+ * "data": {
1656
+ * template: "<data_thing/>"
1657
+ * }
1658
+ * }
1659
+ * })
1660
+ * ```
1661
+ *
1662
+ * #### Examples for `autoscroll`:
1663
+ * ```html
1664
+ * <!-- If autoscroll present with no expression,
1665
+ * then scroll ui-view into view -->
1666
+ * <ui-view autoscroll/>
1667
+ *
1668
+ * <!-- If autoscroll present with valid expression,
1669
+ * then scroll ui-view into view if expression evaluates to true -->
1670
+ * <ui-view autoscroll='true'/>
1671
+ * <ui-view autoscroll='false'/>
1672
+ * <ui-view autoscroll='scopeVariable'/>
1673
+ * ```
1674
+ *
1675
+ * Resolve data:
1676
+ *
1677
+ * The resolved data from the state's `resolve` block is placed on the scope as `$resolve` (this
1678
+ * can be customized using [[Ng1ViewDeclaration.resolveAs]]). This can be then accessed from the template.
1679
+ *
1680
+ * Note that when `controllerAs` is being used, `$resolve` is set on the controller instance *after* the
1681
+ * controller is instantiated. The `$onInit()` hook can be used to perform initialization code which
1682
+ * depends on `$resolve` data.
1683
+ *
1684
+ * #### Example:
1685
+ * ```js
1686
+ * $stateProvider.state('home', {
1687
+ * template: '<my-component user="$resolve.user"></my-component>',
1688
+ * resolve: {
1689
+ * user: function(UserService) { return UserService.fetchUser(); }
1690
+ * }
1691
+ * });
1692
+ * ```
1693
+ */
1694
+ var uiView;
1695
+ uiView = ['$view', '$animate', '$uiViewScroll', '$interpolate', '$q',
1696
+ function $ViewDirective($view, $animate, $uiViewScroll, $interpolate, $q) {
1697
+ function getRenderer(attrs, scope) {
1698
+ return {
1699
+ enter: function (element, target, cb) {
1700
+ if (ng.version.minor > 2) {
1701
+ $animate.enter(element, null, target).then(cb);
1702
+ }
1703
+ else {
1704
+ $animate.enter(element, null, target, cb);
1705
+ }
1706
+ },
1707
+ leave: function (element, cb) {
1708
+ if (ng.version.minor > 2) {
1709
+ $animate.leave(element).then(cb);
1710
+ }
1711
+ else {
1712
+ $animate.leave(element, cb);
1713
+ }
1714
+ }
1715
+ };
1716
+ }
1717
+ function configsEqual(config1, config2) {
1718
+ return config1 === config2;
1719
+ }
1720
+ var rootData = {
1721
+ $cfg: { viewDecl: { $context: $view._pluginapi._rootViewContext() } },
1722
+ $uiView: {}
1723
+ };
1724
+ var directive = {
1725
+ count: 0,
1726
+ restrict: 'ECA',
1727
+ terminal: true,
1728
+ priority: 400,
1729
+ transclude: 'element',
1730
+ compile: function (tElement, tAttrs, $transclude) {
1731
+ return function (scope, $element, attrs) {
1732
+ var previousEl, currentEl, currentScope, unregister, onloadExp = attrs['onload'] || '', autoScrollExp = attrs['autoscroll'], renderer = getRenderer(attrs, scope), viewConfig = undefined, inherited = $element.inheritedData('$uiView') || rootData, name = $interpolate(attrs['uiView'] || attrs['name'] || '')(scope) || '$default';
1733
+ var activeUIView = {
1734
+ $type: 'ng1',
1735
+ id: directive.count++,
1736
+ name: name,
1737
+ fqn: inherited.$uiView.fqn ? inherited.$uiView.fqn + "." + name : name,
1738
+ config: null,
1739
+ configUpdated: configUpdatedCallback,
1740
+ get creationContext() {
1741
+ var fromParentTagConfig = core.parse('$cfg.viewDecl.$context')(inherited);
1742
+ // Allow <ui-view name="foo"><ui-view name="bar"></ui-view></ui-view>
1743
+ // See https://github.com/angular-ui/ui-router/issues/3355
1744
+ var fromParentTag = core.parse('$uiView.creationContext')(inherited);
1745
+ return fromParentTagConfig || fromParentTag;
1746
+ }
1747
+ };
1748
+ core.trace.traceUIViewEvent("Linking", activeUIView);
1749
+ function configUpdatedCallback(config) {
1750
+ if (config && !(config instanceof Ng1ViewConfig))
1751
+ return;
1752
+ if (configsEqual(viewConfig, config))
1753
+ return;
1754
+ core.trace.traceUIViewConfigUpdated(activeUIView, config && config.viewDecl && config.viewDecl.$context);
1755
+ viewConfig = config;
1756
+ updateView(config);
1757
+ }
1758
+ $element.data('$uiView', { $uiView: activeUIView });
1759
+ updateView();
1760
+ unregister = $view.registerUIView(activeUIView);
1761
+ scope.$on("$destroy", function () {
1762
+ core.trace.traceUIViewEvent("Destroying/Unregistering", activeUIView);
1763
+ unregister();
1764
+ });
1765
+ function cleanupLastView() {
1766
+ if (previousEl) {
1767
+ core.trace.traceUIViewEvent("Removing (previous) el", previousEl.data('$uiView'));
1768
+ previousEl.remove();
1769
+ previousEl = null;
1770
+ }
1771
+ if (currentScope) {
1772
+ core.trace.traceUIViewEvent("Destroying scope", activeUIView);
1773
+ currentScope.$destroy();
1774
+ currentScope = null;
1775
+ }
1776
+ if (currentEl) {
1777
+ var _viewData_1 = currentEl.data('$uiViewAnim');
1778
+ core.trace.traceUIViewEvent("Animate out", _viewData_1);
1779
+ renderer.leave(currentEl, function () {
1780
+ _viewData_1.$$animLeave.resolve();
1781
+ previousEl = null;
1782
+ });
1783
+ previousEl = currentEl;
1784
+ currentEl = null;
1785
+ }
1786
+ }
1787
+ function updateView(config) {
1788
+ var newScope = scope.$new();
1789
+ var animEnter = $q.defer(), animLeave = $q.defer();
1790
+ var $uiViewData = {
1791
+ $cfg: config,
1792
+ $uiView: activeUIView,
1793
+ };
1794
+ var $uiViewAnim = {
1795
+ $animEnter: animEnter.promise,
1796
+ $animLeave: animLeave.promise,
1797
+ $$animLeave: animLeave
1798
+ };
1799
+ /**
1800
+ * @ngdoc event
1801
+ * @name ui.router.state.directive:ui-view#$viewContentLoading
1802
+ * @eventOf ui.router.state.directive:ui-view
1803
+ * @eventType emits on ui-view directive scope
1804
+ * @description
1805
+ *
1806
+ * Fired once the view **begins loading**, *before* the DOM is rendered.
1807
+ *
1808
+ * @param {Object} event Event object.
1809
+ * @param {string} viewName Name of the view.
1810
+ */
1811
+ newScope.$emit('$viewContentLoading', name);
1812
+ var cloned = $transclude(newScope, function (clone) {
1813
+ clone.data('$uiViewAnim', $uiViewAnim);
1814
+ clone.data('$uiView', $uiViewData);
1815
+ renderer.enter(clone, $element, function onUIViewEnter() {
1816
+ animEnter.resolve();
1817
+ if (currentScope)
1818
+ currentScope.$emit('$viewContentAnimationEnded');
1819
+ if (core.isDefined(autoScrollExp) && !autoScrollExp || scope.$eval(autoScrollExp)) {
1820
+ $uiViewScroll(clone);
1821
+ }
1822
+ });
1823
+ cleanupLastView();
1824
+ });
1825
+ currentEl = cloned;
1826
+ currentScope = newScope;
1827
+ /**
1828
+ * @ngdoc event
1829
+ * @name ui.router.state.directive:ui-view#$viewContentLoaded
1830
+ * @eventOf ui.router.state.directive:ui-view
1831
+ * @eventType emits on ui-view directive scope
1832
+ * @description *
1833
+ * Fired once the view is **loaded**, *after* the DOM is rendered.
1834
+ *
1835
+ * @param {Object} event Event object.
1836
+ */
1837
+ currentScope.$emit('$viewContentLoaded', config || viewConfig);
1838
+ currentScope.$eval(onloadExp);
1839
+ }
1840
+ };
1841
+ }
1842
+ };
1843
+ return directive;
1844
+ }];
1845
+ $ViewDirectiveFill.$inject = ['$compile', '$controller', '$transitions', '$view', '$q', '$timeout'];
1846
+ /** @hidden */
1847
+ function $ViewDirectiveFill($compile, $controller, $transitions, $view, $q, $timeout) {
1848
+ var getControllerAs = core.parse('viewDecl.controllerAs');
1849
+ var getResolveAs = core.parse('viewDecl.resolveAs');
1850
+ return {
1851
+ restrict: 'ECA',
1852
+ priority: -400,
1853
+ compile: function (tElement) {
1854
+ var initial = tElement.html();
1855
+ tElement.empty();
1856
+ return function (scope, $element) {
1857
+ var data = $element.data('$uiView');
1858
+ if (!data) {
1859
+ $element.html(initial);
1860
+ $compile($element.contents())(scope);
1861
+ return;
1862
+ }
1863
+ var cfg = data.$cfg || { viewDecl: {}, getTemplate: core.noop };
1864
+ var resolveCtx = cfg.path && new core.ResolveContext(cfg.path);
1865
+ $element.html(cfg.getTemplate($element, resolveCtx) || initial);
1866
+ core.trace.traceUIViewFill(data.$uiView, $element.html());
1867
+ var link = $compile($element.contents());
1868
+ var controller = cfg.controller;
1869
+ var controllerAs = getControllerAs(cfg);
1870
+ var resolveAs = getResolveAs(cfg);
1871
+ var locals = resolveCtx && getLocals(resolveCtx);
1872
+ scope[resolveAs] = locals;
1873
+ if (controller) {
1874
+ var controllerInstance = $controller(controller, core.extend({}, locals, { $scope: scope, $element: $element }));
1875
+ if (controllerAs) {
1876
+ scope[controllerAs] = controllerInstance;
1877
+ scope[controllerAs][resolveAs] = locals;
1878
+ }
1879
+ // TODO: Use $view service as a central point for registering component-level hooks
1880
+ // Then, when a component is created, tell the $view service, so it can invoke hooks
1881
+ // $view.componentLoaded(controllerInstance, { $scope: scope, $element: $element });
1882
+ // scope.$on('$destroy', () => $view.componentUnloaded(controllerInstance, { $scope: scope, $element: $element }));
1883
+ $element.data('$ngControllerController', controllerInstance);
1884
+ $element.children().data('$ngControllerController', controllerInstance);
1885
+ registerControllerCallbacks($q, $transitions, controllerInstance, scope, cfg);
1886
+ }
1887
+ // Wait for the component to appear in the DOM
1888
+ if (core.isString(cfg.viewDecl.component)) {
1889
+ var cmp_1 = cfg.viewDecl.component;
1890
+ var kebobName = core.kebobString(cmp_1);
1891
+ var tagRegexp_1 = new RegExp("^(x-|data-)?" + kebobName + "$", "i");
1892
+ var getComponentController = function () {
1893
+ var directiveEl = [].slice.call($element[0].children)
1894
+ .filter(function (el) { return el && el.tagName && tagRegexp_1.exec(el.tagName); });
1895
+ return directiveEl && ng.element(directiveEl).data("$" + cmp_1 + "Controller");
1896
+ };
1897
+ var deregisterWatch_1 = scope.$watch(getComponentController, function (ctrlInstance) {
1898
+ if (!ctrlInstance)
1899
+ return;
1900
+ registerControllerCallbacks($q, $transitions, ctrlInstance, scope, cfg);
1901
+ deregisterWatch_1();
1902
+ });
1903
+ }
1904
+ link(scope);
1905
+ };
1906
+ }
1907
+ };
1908
+ }
1909
+ /** @hidden */
1910
+ var hasComponentImpl = typeof ng.module('ui.router')['component'] === 'function';
1911
+ /** @hidden incrementing id */
1912
+ var _uiCanExitId = 0;
1913
+ /** @hidden TODO: move these callbacks to $view and/or `/hooks/components.ts` or something */
1914
+ function registerControllerCallbacks($q, $transitions, controllerInstance, $scope, cfg) {
1915
+ // Call $onInit() ASAP
1916
+ if (core.isFunction(controllerInstance.$onInit) && !(cfg.viewDecl.component && hasComponentImpl)) {
1917
+ controllerInstance.$onInit();
1918
+ }
1919
+ var viewState = core.tail(cfg.path).state.self;
1920
+ var hookOptions = { bind: controllerInstance };
1921
+ // Add component-level hook for onParamsChange
1922
+ if (core.isFunction(controllerInstance.uiOnParamsChanged)) {
1923
+ var resolveContext = new core.ResolveContext(cfg.path);
1924
+ var viewCreationTrans_1 = resolveContext.getResolvable('$transition$').data;
1925
+ // Fire callback on any successful transition
1926
+ var paramsUpdated = function ($transition$) {
1927
+ // Exit early if the $transition$ is the same as the view was created within.
1928
+ // Exit early if the $transition$ will exit the state the view is for.
1929
+ if ($transition$ === viewCreationTrans_1 || $transition$.exiting().indexOf(viewState) !== -1)
1930
+ return;
1931
+ var toParams = $transition$.params("to");
1932
+ var fromParams = $transition$.params("from");
1933
+ var toSchema = $transition$.treeChanges().to.map(function (node) { return node.paramSchema; }).reduce(core.unnestR, []);
1934
+ var fromSchema = $transition$.treeChanges().from.map(function (node) { return node.paramSchema; }).reduce(core.unnestR, []);
1935
+ // Find the to params that have different values than the from params
1936
+ var changedToParams = toSchema.filter(function (param) {
1937
+ var idx = fromSchema.indexOf(param);
1938
+ return idx === -1 || !fromSchema[idx].type.equals(toParams[param.id], fromParams[param.id]);
1939
+ });
1940
+ // Only trigger callback if a to param has changed or is new
1941
+ if (changedToParams.length) {
1942
+ var changedKeys_1 = changedToParams.map(function (x) { return x.id; });
1943
+ // Filter the params to only changed/new to params. `$transition$.params()` may be used to get all params.
1944
+ var newValues = core.filter(toParams, function (val$$1, key) { return changedKeys_1.indexOf(key) !== -1; });
1945
+ controllerInstance.uiOnParamsChanged(newValues, $transition$);
1946
+ }
1947
+ };
1948
+ $scope.$on('$destroy', $transitions.onSuccess({}, paramsUpdated, hookOptions));
1949
+ }
1950
+ // Add component-level hook for uiCanExit
1951
+ if (core.isFunction(controllerInstance.uiCanExit)) {
1952
+ var id_1 = _uiCanExitId++;
1953
+ var cacheProp_1 = '_uiCanExitIds';
1954
+ // Returns true if a redirect transition already answered truthy
1955
+ var prevTruthyAnswer_1 = function (trans) {
1956
+ return !!trans && (trans[cacheProp_1] && trans[cacheProp_1][id_1] === true || prevTruthyAnswer_1(trans.redirectedFrom()));
1957
+ };
1958
+ // If a user answered yes, but the transition was later redirected, don't also ask for the new redirect transition
1959
+ var wrappedHook = function (trans) {
1960
+ var promise, ids = trans[cacheProp_1] = trans[cacheProp_1] || {};
1961
+ if (!prevTruthyAnswer_1(trans)) {
1962
+ promise = $q.when(controllerInstance.uiCanExit(trans));
1963
+ promise.then(function (val$$1) { return ids[id_1] = (val$$1 !== false); });
1964
+ }
1965
+ return promise;
1966
+ };
1967
+ var criteria = { exiting: viewState.name };
1968
+ $scope.$on('$destroy', $transitions.onBefore(criteria, wrappedHook, hookOptions));
1969
+ }
1970
+ }
1971
+ ng.module('ui.router.state').directive('uiView', uiView);
1972
+ ng.module('ui.router.state').directive('uiView', $ViewDirectiveFill);
1973
+
1974
+ /** @module ng1 */ /** */
1975
+ /** @hidden */
1976
+ function $ViewScrollProvider() {
1977
+ var useAnchorScroll = false;
1978
+ this.useAnchorScroll = function () {
1979
+ useAnchorScroll = true;
1980
+ };
1981
+ this.$get = ['$anchorScroll', '$timeout', function ($anchorScroll, $timeout) {
1982
+ if (useAnchorScroll) {
1983
+ return $anchorScroll;
1984
+ }
1985
+ return function ($element) {
1986
+ return $timeout(function () {
1987
+ $element[0].scrollIntoView();
1988
+ }, 0, false);
1989
+ };
1990
+ }];
1991
+ }
1992
+ ng.module('ui.router.state').provider('$uiViewScroll', $ViewScrollProvider);
1993
+
1994
+ /**
1995
+ * Main entry point for angular 1.x build
1996
+ * @module ng1
1997
+ */ /** */
1998
+ var index = "ui.router";
1999
+
2000
+ exports['default'] = index;
2001
+ exports.core = core;
2002
+ exports.watchDigests = watchDigests;
2003
+ exports.getLocals = getLocals;
2004
+ exports.getNg1ViewConfigFactory = getNg1ViewConfigFactory;
2005
+ exports.ng1ViewsBuilder = ng1ViewsBuilder;
2006
+ exports.Ng1ViewConfig = Ng1ViewConfig;
2007
+ exports.StateProvider = StateProvider;
2008
+ exports.UrlRouterProvider = UrlRouterProvider;
2009
+ Object.keys(core).forEach(function (key) { exports[key] = core[key]; });
2010
+
2011
+ Object.defineProperty(exports, '__esModule', { value: true });
2012
+
2013
+ })));
2014
+ //# sourceMappingURL=ui-router-angularjs.js.map