<script src="[% ctx.media_prefix %]/js/ui/default/staff/build/js/angular-route.min.js"></script>
<script src="[% ctx.media_prefix %]/js/ui/default/staff/build/js/ui-bootstrap-tpls.min.js"></script>
<script src="[% ctx.media_prefix %]/js/ui/default/staff/build/js/hotkeys.min.js"></script>
+<script src="[% ctx.media_prefix %]/js/ui/default/staff/build/js/angular-location-update.min.js"></script>
<!-- IDL / opensrf (network) -->
<script src="[% ctx.media_prefix %]/js/dojo/opensrf/JSON_v1.js"></script>
'bower_components/angular-bootstrap/ui-bootstrap.min.js',
'bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js',
'bower_components/angular-hotkeys/build/hotkeys.min.js',
+ 'bower_components/angular-location-update/angular-location-update.min.js',
'bower_components/jquery/dist/jquery.min.js',
]
}]
"angular-bootstrap": "~0.11.0"
},
"dependencies": {
- "angular-hotkeys": "chieffancypants/angular-hotkeys#~1.2.0"
+ "angular-hotkeys": "chieffancypants/angular-hotkeys#~1.2.0",
+ "angular-location-update": "./extern/angular-location-update/"
}
}
--- /dev/null
+{
+ "name": "angular-location-update",
+ "homepage": "https://github.com/anglibs/angular-location-update",
+ "authors": [
+ "garmoshka-mo <dan@dub.ink>"
+ ],
+ "main": "angular-location-update.js",
+ "description": "Updates location path without reloading of controller",
+ "ignore": [
+ "**/.*",
+ "*.yml",
+ "*.xml",
+ "node_modules",
+ "bower_components",
+ "test",
+ "tests"
+ ],
+ "dependencies": {
+ "angular": "*"
+ },
+ "_release": "103e945c53",
+ "_resolution": {
+ "type": "branch",
+ "branch": "master",
+ "commit": "103e945c535f9c0e3479c4faf77930404c823f21"
+ },
+ "_source": "git://github.com/anglibs/angular-location-update.git",
+ "_target": "*",
+ "_originalSource": "angular-location-update",
+ "_direct": true
+}
\ No newline at end of file
--- /dev/null
+The MIT License (MIT)
+
+Copyright (c) 2015 anglibs
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
--- /dev/null
+# angular-location-update
+
+Updates location path without reloading of controller
+
+## Install
+
+1 `bower install angular-location-update --save` or [download](http://anglibs.github.io/angular-location-update/angular-location-update.min.js) or include hosted from github.io
+````
+ <script src="//anglibs.github.io/angular-location-update/angular-location-update.min.js"></script>
+````
+
+2 Add module to your app:
+````
+ angular.module('your_app', ['ngLocationUpdate']);
+````
+
+## Usage
+
+````
+$location.update_path('/notes/1');
+$location.update_path('/notes/1/wysiwyg', true);
+````
+Parameters:
+ 1. New path
+ 1. Keep old path in browser history (By default it will be **replaced** by new one)
+
+## When it's needed?
+
+For example you have route `/notes/new` which shows form for new note.
+
+In modern web app you may have no "Save" button - note created and saved to database once user made any change.
+Then you would like to change route to `/notes/1` showing to user, that here is URL of his new document.
+Also if he will refresh page or go back and forward using browser buttons - he will see what he expects.
+
+## FYI
+
+Did you know, that you can easily change your URLs
+
+from `http://mysite.com/#/notes/1` to `http://mysite.com/notes/1`
+
+For this:
+ 1. Config app: `angular.module('your_app').config(function($locationProvider) { $locationProvider.html5Mode(true); });`
+ 2. Add in your HTML `<base href="/">`
+
+More info: https://docs.angularjs.org/guide/$location
+
+## Credits
+
+Solution invented by guys in these threads:
+ 1. https://github.com/angular/angular.js/issues/1699
+ 1. https://github.com/angular-ui/ui-router/issues/427
+ 1. http://stackoverflow.com/questions/14974271/can-you-change-a-path-without-reloading-the-controller-in-angularjs
--- /dev/null
+!function(angular, undefined) { 'use strict';
+
+ angular.module('ngLocationUpdate', [])
+ .run(['$route', '$rootScope', '$location', function ($route, $rootScope, $location) {
+ // todo: would be proper to change this to decorators of $location and $route
+ $location.update_path = function (path, keep_previous_path_in_history) {
+ if ($location.path() == path) return;
+
+ var routeToKeep = $route.current;
+ $rootScope.$on('$locationChangeSuccess', function () {
+ if (routeToKeep) {
+ $route.current = routeToKeep;
+ routeToKeep = null;
+ }
+ });
+
+ $location.path(path);
+ if (!keep_previous_path_in_history) $location.replace();
+ };
+ }]);
+
+}(window.angular);
--- /dev/null
+!function(n){"use strict";n.module("ngLocationUpdate",[]).run(["$route","$rootScope","$location",function(n,t,o){o.update_path=function(c,u){if(o.path()!=c){var a=n.current;t.$on("$locationChangeSuccess",function(){a&&(n.current=a,a=null)}),o.path(c),u||o.replace()}}}])}(window.angular);
\ No newline at end of file
--- /dev/null
+{
+ "name": "angular-location-update",
+ "version": "0.0.2",
+ "homepage": "https://github.com/anglibs/angular-location-update",
+ "authors": [
+ "garmoshka-mo <dan@dub.ink>"
+ ],
+ "main": "angular-location-update.js",
+ "description": "Updates location path without reloading of controller",
+ "ignore": [
+ "**/.*",
+ "*.yml",
+ "*.xml",
+ "node_modules",
+ "bower_components",
+ "test",
+ "tests"
+ ],
+ "dependencies": {
+ "angular": "*"
+ }
+}
--- /dev/null
+{
+ "name": "angular-location-update",
+ "version": "0.0.2",
+ "main": "angular-location-update.js",
+ "description": "Updates location path without reloading of controller",
+ "homepage": "https://github.com/anglibs/angular-location-update",
+ "bugs": "https://github.com/anglibs/angular-location-update/issues",
+ "author": {
+ "name": "garmoshka-mo",
+ "email": "dan@dub.ink"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git@github.com:anglibs/angular-location-update.git"
+ },
+ "licenses": [
+ {
+ "type": "MIT"
+ }
+ ],
+ "dependencies": {
+ },
+ "devDependencies": {
+ }
+}