kms 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/kms/application.js +1 -0
- data/app/assets/javascripts/kms/application/controllers/assets_controller.coffee.erb +14 -4
- data/app/assets/javascripts/kms/application/controllers/pages_controller.coffee.erb +12 -2
- data/app/assets/javascripts/kms/application/controllers/snippets_controller.coffee.erb +13 -3
- data/app/assets/javascripts/kms/application/controllers/templates_controller.coffee.erb +13 -3
- data/app/assets/javascripts/kms/application/controllers/users_controller.coffee +5 -5
- data/app/assets/javascripts/kms/application/module.coffee +6 -2
- data/app/assets/javascripts/kms/application/routes.coffee.erb +10 -0
- data/app/assets/javascripts/templates/assets/edit.html.slim +2 -1
- data/app/assets/javascripts/templates/assets/form.html.slim +1 -1
- data/app/assets/javascripts/templates/pages/edit.html.slim +1 -0
- data/app/assets/javascripts/templates/shared/hotkey_notification.html.slim +6 -0
- data/app/assets/javascripts/templates/snippets/edit.html.slim +1 -0
- data/app/assets/javascripts/templates/templates/edit.html.slim +1 -0
- data/app/assets/javascripts/templates/users/edit.html.slim +5 -0
- data/app/assets/javascripts/templates/users/form.html.slim +3 -2
- data/app/assets/javascripts/templates/users/index.html.slim +2 -1
- data/app/assets/stylesheets/kms/custom.css.scss +10 -0
- data/app/controllers/kms/assets_controller.rb +6 -3
- data/app/controllers/kms/users_controller.rb +14 -0
- data/app/services/kms/resource_service.rb +3 -1
- data/app/views/layouts/kms/kms.html.erb +1 -1
- data/config/initializers/devise.rb +9 -0
- data/config/locales/en.yml +12 -0
- data/config/locales/ru.yml +12 -0
- data/config/routes.rb +1 -1
- data/lib/kms/engine.rb +1 -1
- data/lib/kms/version.rb +1 -1
- data/spec/controllers/kms/assets_controller_spec.rb +28 -10
- data/spec/controllers/kms/users_controller_spec.rb +23 -0
- data/spec/internal/config/routes.rb +1 -1
- data/spec/internal/log/test.log +0 -105823
- data/vendor/assets/bower.json +5 -4
- data/vendor/assets/bower_components/angular-cookies/angular-cookies.js +22 -18
- data/vendor/assets/bower_components/angular-cookies/angular-cookies.min.js +4 -4
- data/vendor/assets/bower_components/angular-cookies/angular-cookies.min.js.map +2 -2
- data/vendor/assets/bower_components/angular-cookies/bower.json +2 -2
- data/vendor/assets/bower_components/angular-cookies/package.json +1 -1
- data/vendor/assets/bower_components/angular-hotkeys/Gruntfile.js +118 -0
- data/vendor/assets/bower_components/angular-hotkeys/LICENSE +20 -0
- data/vendor/assets/bower_components/angular-hotkeys/README.md +248 -0
- data/vendor/assets/bower_components/angular-hotkeys/bower.json +19 -0
- data/vendor/assets/bower_components/angular-hotkeys/build/hotkeys.css +110 -0
- data/vendor/assets/bower_components/angular-hotkeys/build/hotkeys.js +1661 -0
- data/vendor/assets/bower_components/angular-hotkeys/build/hotkeys.min.css +1 -0
- data/vendor/assets/bower_components/angular-hotkeys/build/hotkeys.min.js +7 -0
- data/vendor/assets/bower_components/angular-hotkeys/package.json +45 -0
- data/vendor/assets/bower_components/angular-hotkeys/src/hotkeys.css +104 -0
- data/vendor/assets/bower_components/angular-hotkeys/src/hotkeys.js +633 -0
- data/vendor/assets/bower_components/angular-loading-bar/CHANGELOG.md +33 -0
- data/vendor/assets/bower_components/angular-loading-bar/CONTRIBUTING.md +17 -0
- data/vendor/assets/bower_components/angular-loading-bar/Gruntfile.js +9 -1
- data/vendor/assets/bower_components/angular-loading-bar/ISSUE_TEMPLATE.md +14 -0
- data/vendor/assets/bower_components/angular-loading-bar/PULL_REQUEST_TEMPLATE.md +13 -0
- data/vendor/assets/bower_components/angular-loading-bar/README.md +30 -3
- data/vendor/assets/bower_components/angular-loading-bar/bower.json +11 -6
- data/vendor/assets/bower_components/angular-loading-bar/build/loading-bar.css +5 -5
- data/vendor/assets/bower_components/angular-loading-bar/build/loading-bar.js +39 -12
- data/vendor/assets/bower_components/angular-loading-bar/build/loading-bar.min.css +1 -8
- data/vendor/assets/bower_components/angular-loading-bar/build/loading-bar.min.js +3 -3
- data/vendor/assets/bower_components/angular-loading-bar/index.js +2 -0
- data/vendor/assets/bower_components/angular-loading-bar/package.json +12 -15
- data/vendor/assets/bower_components/angular-loading-bar/src/loading-bar.css +3 -3
- data/vendor/assets/bower_components/angular-loading-bar/src/loading-bar.js +37 -10
- data/vendor/assets/bower_components/angular-sanitize/angular-sanitize.js +504 -386
- data/vendor/assets/bower_components/angular-sanitize/angular-sanitize.min.js +13 -12
- data/vendor/assets/bower_components/angular-sanitize/angular-sanitize.min.js.map +3 -3
- data/vendor/assets/bower_components/angular-sanitize/bower.json +2 -2
- data/vendor/assets/bower_components/angular-sanitize/package.json +1 -1
- data/vendor/assets/bower_components/angular-ui-router/CHANGELOG.md +1410 -0
- data/vendor/assets/bower_components/angular-ui-router/CONTRIBUTING.md +64 -16
- data/vendor/assets/bower_components/angular-ui-router/DOCS.md +48 -0
- data/vendor/assets/bower_components/angular-ui-router/ISSUE_TEMPLATE.md +53 -0
- data/vendor/assets/bower_components/angular-ui-router/LICENSE +1 -1
- data/vendor/assets/bower_components/angular-ui-router/README.md +24 -211
- data/vendor/assets/bower_components/angular-ui-router/artifacts.json +8 -0
- data/vendor/assets/bower_components/angular-ui-router/bower.json +1 -23
- data/vendor/assets/bower_components/angular-ui-router/karma.conf.js +105 -0
- data/vendor/assets/bower_components/angular-ui-router/release/angular-ui-router.js +9744 -3901
- data/vendor/assets/bower_components/angular-ui-router/release/angular-ui-router.js.map +192 -0
- data/vendor/assets/bower_components/angular-ui-router/release/angular-ui-router.min.js +9 -4
- data/vendor/assets/bower_components/angular-ui-router/release/angular-ui-router.min.js.map +1679 -0
- data/vendor/assets/bower_components/angular-ui-router/release/resolveService.js +83 -0
- data/vendor/assets/bower_components/angular-ui-router/release/resolveService.js.map +19 -0
- data/vendor/assets/bower_components/angular-ui-router/release/resolveService.min.js +8 -0
- data/vendor/assets/bower_components/angular-ui-router/release/resolveService.min.js.map +47 -0
- data/vendor/assets/bower_components/angular-ui-router/release/stateEvents.js +294 -0
- data/vendor/assets/bower_components/angular-ui-router/release/stateEvents.js.map +17 -0
- data/vendor/assets/bower_components/angular-ui-router/release/stateEvents.min.js +8 -0
- data/vendor/assets/bower_components/angular-ui-router/release/stateEvents.min.js.map +102 -0
- data/vendor/assets/bower_components/angular-ui-router/release/ui-router-angularjs.js +2014 -0
- data/vendor/assets/bower_components/angular-ui-router/release/ui-router-angularjs.js.map +70 -0
- data/vendor/assets/bower_components/angular-ui-router/release/ui-router-angularjs.min.js +9 -0
- data/vendor/assets/bower_components/angular-ui-router/release/ui-router-angularjs.min.js.map +541 -0
- data/vendor/assets/bower_components/angular-ui-router/rollup.config.js +116 -0
- data/vendor/assets/bower_components/angular-ui-router/tslint.json +60 -0
- data/vendor/assets/bower_components/angular-ui-router/yarn.lock +4146 -0
- data/vendor/assets/bower_components/angular-ui-tree/yarn.lock +4945 -0
- data/vendor/assets/bower_components/angular/angular.js +4019 -2449
- data/vendor/assets/bower_components/angular/angular.min.js +331 -319
- data/vendor/assets/bower_components/angular/angular.min.js.gzip +0 -0
- data/vendor/assets/bower_components/angular/angular.min.js.map +3 -3
- data/vendor/assets/bower_components/angular/bower.json +1 -1
- data/vendor/assets/bower_components/angular/package.json +1 -1
- data/vendor/assets/bower_components/angularjs-dropdown-multiselect/LICENSE +21 -0
- data/vendor/assets/bower_components/angularjs-dropdown-multiselect/README.md +14 -14
- data/vendor/assets/bower_components/angularjs-dropdown-multiselect/bower.json +25 -12
- data/vendor/assets/bower_components/angularjs-dropdown-multiselect/development_index.html +59 -52
- data/vendor/assets/bower_components/angularjs-dropdown-multiselect/dist/angularjs-dropdown-multiselect.min.js +1 -1
- data/vendor/assets/bower_components/angularjs-dropdown-multiselect/index.html +73 -0
- data/vendor/assets/bower_components/angularjs-dropdown-multiselect/package.json +19 -7
- data/vendor/assets/bower_components/angularjs-dropdown-multiselect/pages/javascripts/pages/home/ExampleCtrl.js +126 -3
- data/vendor/assets/bower_components/angularjs-dropdown-multiselect/pages/javascripts/pages/home/home.html +1262 -852
- data/vendor/assets/bower_components/angularjs-dropdown-multiselect/pages/stylesheets/stylesheet.css +10 -5
- data/vendor/assets/bower_components/angularjs-dropdown-multiselect/src/angularjs-dropdown-multiselect.js +612 -287
- metadata +66 -169
- data/spec/internal/config/database.yml +0 -7
- data/spec/internal/public/uploads/kms/asset/file/1/avatar.jpg +0 -0
- data/spec/internal/public/uploads/kms/asset/file/2/avatar.jpg +0 -0
- data/spec/internal/public/uploads/kms/asset/file/2/style.css +0 -1
- data/spec/internal/public/uploads/kms/asset/file/3/style.css +0 -1
- data/spec/internal/public/uploads/kms/asset/file/4/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500976987-41025-0002-0883/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500977082-41195-0002-6495/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500977109-41364-0002-4518/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500977152-41405-0002-2345/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500977327-41694-0002-5448/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500977376-41732-0002-7916/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500977392-41759-0002-7593/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500977410-42259-0002-7527/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500977429-42306-0002-5937/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500977437-42324-0002-5880/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500983228-53594-0002-4559/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500983284-53632-0002-6590/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500983360-53784-0002-7289/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500983469-54321-0002-0386/avatar.jpg +0 -0
- data/spec/internal/public/uploads/tmp/1500983469-54321-0004-5691/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500983511-54352-0002-5720/avatar.jpg +0 -0
- data/spec/internal/public/uploads/tmp/1500983511-54352-0004-1399/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500983610-54507-0002-4280/avatar.jpg +0 -0
- data/spec/internal/public/uploads/tmp/1500983610-54507-0004-9758/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500984466-57012-0002-4146/avatar.jpg +0 -0
- data/spec/internal/public/uploads/tmp/1500984466-57012-0004-5895/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500984509-57158-0002-9657/avatar.jpg +0 -0
- data/spec/internal/public/uploads/tmp/1500984509-57158-0004-5003/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500984616-57697-0002-7201/avatar.jpg +0 -0
- data/spec/internal/public/uploads/tmp/1500984616-57697-0004-6255/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500985257-58947-0002-3629/avatar.jpg +0 -0
- data/spec/internal/public/uploads/tmp/1500985257-58947-0004-5338/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500985407-58947-0006-5929/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500985473-59264-0002-0397/avatar.jpg +0 -0
- data/spec/internal/public/uploads/tmp/1500985473-59264-0004-6493/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500985475-59264-0007-8674/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500985538-59468-0002-9206/avatar.jpg +0 -0
- data/spec/internal/public/uploads/tmp/1500985538-59468-0004-2586/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500985538-59468-0007-6200/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500988358-65877-0002-4528/avatar.jpg +0 -0
- data/spec/internal/public/uploads/tmp/1500988358-65877-0004-5904/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500988358-65877-0007-7320/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500988407-65916-0002-3138/avatar.jpg +0 -0
- data/spec/internal/public/uploads/tmp/1500988407-65916-0004-5400/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500988407-65916-0007-1655/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500988421-65950-0002-9415/avatar.jpg +0 -0
- data/spec/internal/public/uploads/tmp/1500988421-65950-0004-7130/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500988421-65950-0007-9886/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500988435-65981-0002-3228/avatar.jpg +0 -0
- data/spec/internal/public/uploads/tmp/1500988435-65981-0004-3682/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500988435-65981-0007-1582/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500988475-66122-0002-9516/avatar.jpg +0 -0
- data/spec/internal/public/uploads/tmp/1500988475-66122-0004-5634/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500988530-66122-0007-2272/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500988554-66315-0002-6262/avatar.jpg +0 -0
- data/spec/internal/public/uploads/tmp/1500988554-66315-0004-6099/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500988554-66315-0007-1632/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500991751-73722-0002-9937/avatar.jpg +0 -0
- data/spec/internal/public/uploads/tmp/1500991751-73722-0004-8034/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1500991751-73722-0007-7763/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1501233238-34385-0002-3210/avatar.jpg +0 -0
- data/spec/internal/public/uploads/tmp/1501233238-34385-0004-5881/style.css +0 -1
- data/spec/internal/public/uploads/tmp/1501233238-34385-0007-6280/style.css +0 -1
- data/spec/internal/tmp/cache/assets/test/sprockets/v3.0/1XyAFYlYI0pK7WAgjR4PgXV6BgU6huJSviWmHetdCRs.cache +0 -1
- data/vendor/assets/bower_components/angular-ui-router/api/angular-ui-router.d.ts +0 -126
- data/vendor/assets/bower_components/angular-ui-router/src/common.js +0 -292
- data/vendor/assets/bower_components/angular-ui-router/src/resolve.js +0 -252
- data/vendor/assets/bower_components/angular-ui-router/src/state.js +0 -1373
- data/vendor/assets/bower_components/angular-ui-router/src/stateDirectives.js +0 -268
- data/vendor/assets/bower_components/angular-ui-router/src/stateFilters.js +0 -39
- data/vendor/assets/bower_components/angular-ui-router/src/templateFactory.js +0 -110
- data/vendor/assets/bower_components/angular-ui-router/src/urlMatcherFactory.js +0 -1036
- data/vendor/assets/bower_components/angular-ui-router/src/urlRouter.js +0 -413
- data/vendor/assets/bower_components/angular-ui-router/src/view.js +0 -71
- data/vendor/assets/bower_components/angular-ui-router/src/viewDirective.js +0 -302
- data/vendor/assets/bower_components/angular-ui-router/src/viewScroll.js +0 -52
- data/vendor/assets/bower_components/angularjs-dropdown-multiselect/pages/index.html +0 -67
- data/vendor/assets/bower_components/bootstrap/Gemfile.lock +0 -43
data/vendor/assets/bower.json
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
{
|
2
2
|
"name": "dsl-generated dependencies",
|
3
3
|
"dependencies": {
|
4
|
-
"angular": "1.
|
5
|
-
"angular-cookies": "1.
|
4
|
+
"angular": "1.6.7",
|
5
|
+
"angular-cookies": "1.6.7",
|
6
6
|
"rdash-ui": "latest",
|
7
7
|
"bootstrap": "3.3.7",
|
8
8
|
"lodash": "3.6.0",
|
@@ -11,7 +11,7 @@
|
|
11
11
|
"angular-ui-codemirror": "latest",
|
12
12
|
"ng-flow": "latest",
|
13
13
|
"angular-ui-select": "0.17.0",
|
14
|
-
"angular-sanitize": "1.
|
14
|
+
"angular-sanitize": "1.6.7",
|
15
15
|
"ng-ckeditor": "latest",
|
16
16
|
"font-awesome": "4.2.0",
|
17
17
|
"angular-toggle-switch": "latest",
|
@@ -21,6 +21,7 @@
|
|
21
21
|
"ng-alertify": "latest",
|
22
22
|
"angular-xeditable": "latest",
|
23
23
|
"ng-sortable": "latest",
|
24
|
-
"angular-i18n": "latest"
|
24
|
+
"angular-i18n": "latest",
|
25
|
+
"angular-hotkeys": "chieffancypants/angular-hotkeys"
|
25
26
|
}
|
26
27
|
}
|
@@ -1,34 +1,30 @@
|
|
1
1
|
/**
|
2
|
-
* @license AngularJS v1.
|
3
|
-
* (c) 2010-
|
2
|
+
* @license AngularJS v1.6.7
|
3
|
+
* (c) 2010-2017 Google, Inc. http://angularjs.org
|
4
4
|
* License: MIT
|
5
5
|
*/
|
6
|
-
(function(window, angular
|
6
|
+
(function(window, angular) {'use strict';
|
7
7
|
|
8
8
|
/**
|
9
9
|
* @ngdoc module
|
10
10
|
* @name ngCookies
|
11
11
|
* @description
|
12
12
|
*
|
13
|
-
* # ngCookies
|
14
|
-
*
|
15
13
|
* The `ngCookies` module provides a convenient wrapper for reading and writing browser cookies.
|
16
14
|
*
|
17
|
-
*
|
18
|
-
* <div doc-module-components="ngCookies"></div>
|
19
|
-
*
|
20
15
|
* See {@link ngCookies.$cookies `$cookies`} for usage.
|
21
16
|
*/
|
22
17
|
|
23
18
|
|
24
19
|
angular.module('ngCookies', ['ng']).
|
20
|
+
info({ angularVersion: '1.6.7' }).
|
25
21
|
/**
|
26
22
|
* @ngdoc provider
|
27
23
|
* @name $cookiesProvider
|
28
24
|
* @description
|
29
25
|
* Use `$cookiesProvider` to change the default behavior of the {@link ngCookies.$cookies $cookies} service.
|
30
26
|
* */
|
31
|
-
provider('$cookies', [function $CookiesProvider() {
|
27
|
+
provider('$cookies', [/** @this */function $CookiesProvider() {
|
32
28
|
/**
|
33
29
|
* @ngdoc property
|
34
30
|
* @name $cookiesProvider#defaults
|
@@ -51,6 +47,16 @@ angular.module('ngCookies', ['ng']).
|
|
51
47
|
* Note: By default, the address that appears in your `<base>` tag will be used as the path.
|
52
48
|
* This is important so that cookies will be visible for all routes when html5mode is enabled.
|
53
49
|
*
|
50
|
+
* @example
|
51
|
+
*
|
52
|
+
* ```js
|
53
|
+
* angular.module('cookiesProviderExample', ['ngCookies'])
|
54
|
+
* .config(['$cookiesProvider', function($cookiesProvider) {
|
55
|
+
* // Setting default options
|
56
|
+
* $cookiesProvider.defaults.domain = 'foo.com';
|
57
|
+
* $cookiesProvider.defaults.secure = true;
|
58
|
+
* }]);
|
59
|
+
* ```
|
54
60
|
**/
|
55
61
|
var defaults = this.defaults = {};
|
56
62
|
|
@@ -184,6 +190,9 @@ angular.module('ngCookies').
|
|
184
190
|
* @ngdoc service
|
185
191
|
* @name $cookieStore
|
186
192
|
* @deprecated
|
193
|
+
* sinceVersion="v1.4.0"
|
194
|
+
* Please use the {@link ngCookies.$cookies `$cookies`} service instead.
|
195
|
+
*
|
187
196
|
* @requires $cookies
|
188
197
|
*
|
189
198
|
* @description
|
@@ -193,11 +202,6 @@ angular.module('ngCookies').
|
|
193
202
|
*
|
194
203
|
* Requires the {@link ngCookies `ngCookies`} module to be installed.
|
195
204
|
*
|
196
|
-
* <div class="alert alert-danger">
|
197
|
-
* **Note:** The $cookieStore service is **deprecated**.
|
198
|
-
* Please use the {@link ngCookies.$cookies `$cookies`} service instead.
|
199
|
-
* </div>
|
200
|
-
*
|
201
205
|
* @example
|
202
206
|
*
|
203
207
|
* ```js
|
@@ -299,9 +303,9 @@ function $$CookieWriter($document, $log, $browser) {
|
|
299
303
|
// - 4096 bytes per cookie
|
300
304
|
var cookieLength = str.length + 1;
|
301
305
|
if (cookieLength > 4096) {
|
302
|
-
$log.warn(
|
303
|
-
|
304
|
-
cookieLength +
|
306
|
+
$log.warn('Cookie \'' + name +
|
307
|
+
'\' possibly not set or overflowed because it was too large (' +
|
308
|
+
cookieLength + ' > 4096 bytes)!');
|
305
309
|
}
|
306
310
|
|
307
311
|
return str;
|
@@ -314,7 +318,7 @@ function $$CookieWriter($document, $log, $browser) {
|
|
314
318
|
|
315
319
|
$$CookieWriter.$inject = ['$document', '$log', '$browser'];
|
316
320
|
|
317
|
-
angular.module('ngCookies').provider('$$cookieWriter', function $$CookieWriterProvider() {
|
321
|
+
angular.module('ngCookies').provider('$$cookieWriter', /** @this */ function $$CookieWriterProvider() {
|
318
322
|
this.$get = $$CookieWriter;
|
319
323
|
});
|
320
324
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
/*
|
2
|
-
AngularJS v1.
|
3
|
-
(c) 2010-
|
2
|
+
AngularJS v1.6.7
|
3
|
+
(c) 2010-2017 Google, Inc. http://angularjs.org
|
4
4
|
License: MIT
|
5
5
|
*/
|
6
|
-
(function(
|
7
|
-
f+" > 4096 bytes)!");k.cookie=e}}c.module("ngCookies",["ng"]).provider("$cookies",[function(){var b=this.defaults={};this.$get=["$$cookieReader","$$cookieWriter",function(a,g){return{get:function(d){return a()[d]},getObject:function(d){return(d=this.get(d))?c.fromJson(d):d},getAll:function(){return a()},put:function(d,a,m){g(d,a,m?c.extend({},b,m):b)},putObject:function(d,b,a){this.put(d,c.toJson(b),a)},remove:function(a,k){g(a,
|
6
|
+
(function(n,c){'use strict';function l(b,a,g){var d=g.baseHref(),k=b[0];return function(b,e,f){var g,h;f=f||{};h=f.expires;g=c.isDefined(f.path)?f.path:d;c.isUndefined(e)&&(h="Thu, 01 Jan 1970 00:00:00 GMT",e="");c.isString(h)&&(h=new Date(h));e=encodeURIComponent(b)+"="+encodeURIComponent(e);e=e+(g?";path="+g:"")+(f.domain?";domain="+f.domain:"");e+=h?";expires="+h.toUTCString():"";e+=f.secure?";secure":"";f=e.length+1;4096<f&&a.warn("Cookie '"+b+"' possibly not set or overflowed because it was too large ("+
|
7
|
+
f+" > 4096 bytes)!");k.cookie=e}}c.module("ngCookies",["ng"]).info({angularVersion:"1.6.7"}).provider("$cookies",[function(){var b=this.defaults={};this.$get=["$$cookieReader","$$cookieWriter",function(a,g){return{get:function(d){return a()[d]},getObject:function(d){return(d=this.get(d))?c.fromJson(d):d},getAll:function(){return a()},put:function(d,a,m){g(d,a,m?c.extend({},b,m):b)},putObject:function(d,b,a){this.put(d,c.toJson(b),a)},remove:function(a,k){g(a,void 0,k?c.extend({},b,k):b)}}}]}]);c.module("ngCookies").factory("$cookieStore",
|
8
8
|
["$cookies",function(b){return{get:function(a){return b.getObject(a)},put:function(a,c){b.putObject(a,c)},remove:function(a){b.remove(a)}}}]);l.$inject=["$document","$log","$browser"];c.module("ngCookies").provider("$$cookieWriter",function(){this.$get=l})})(window,window.angular);
|
9
9
|
//# sourceMappingURL=angular-cookies.min.js.map
|
@@ -2,7 +2,7 @@
|
|
2
2
|
"version":3,
|
3
3
|
"file":"angular-cookies.min.js",
|
4
4
|
"lineCount":8,
|
5
|
-
"mappings":"A;;;;;aAKC,SAAQ,CAACA,CAAD,CAASC,CAAT,
|
5
|
+
"mappings":"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",
|
6
6
|
"sources":["angular-cookies.js"],
|
7
|
-
"names":["window","angular","
|
7
|
+
"names":["window","angular","$$CookieWriter","$document","$log","$browser","cookiePath","baseHref","rawDocument","name","value","options","path","expires","isDefined","isUndefined","isString","Date","str","encodeURIComponent","domain","toUTCString","secure","cookieLength","length","warn","cookie","module","info","angularVersion","provider","$CookiesProvider","defaults","$get","$$cookieReader","$$cookieWriter","get","key","getObject","fromJson","getAll","put","extend","putObject","toJson","remove","undefined","factory","$cookies","$inject","$$CookieWriterProvider"]
|
8
8
|
}
|
@@ -0,0 +1,118 @@
|
|
1
|
+
/*global module:false*/
|
2
|
+
module.exports = function(grunt) {
|
3
|
+
|
4
|
+
grunt.initConfig({
|
5
|
+
|
6
|
+
// Metadata.
|
7
|
+
pkg: grunt.file.readJSON('package.json'),
|
8
|
+
banner: '/*! \n * <%= pkg.title || pkg.name %> v<%= pkg.version %>\n' +
|
9
|
+
' * <%= pkg.homepage %>\n' +
|
10
|
+
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
|
11
|
+
' * License: <%= pkg.license %>\n' +
|
12
|
+
' */\n',
|
13
|
+
|
14
|
+
// Task configuration.
|
15
|
+
uglify: {
|
16
|
+
options: {
|
17
|
+
banner: '<%= banner %>',
|
18
|
+
report: 'gzip'
|
19
|
+
},
|
20
|
+
build: {
|
21
|
+
src: ['build/hotkeys.js', 'bower_components/mousetrap/mousetrap.js'],
|
22
|
+
dest: 'build/hotkeys.min.js'
|
23
|
+
}
|
24
|
+
},
|
25
|
+
|
26
|
+
ngAnnotate: {
|
27
|
+
options: {
|
28
|
+
singleQuotes: true,
|
29
|
+
},
|
30
|
+
source: {
|
31
|
+
expand: true,
|
32
|
+
cwd: 'src',
|
33
|
+
src: ['*.js'],
|
34
|
+
dest: 'build'
|
35
|
+
}
|
36
|
+
},
|
37
|
+
|
38
|
+
cssmin: {
|
39
|
+
options: {
|
40
|
+
banner: '<%= banner %>',
|
41
|
+
report: 'gzip'
|
42
|
+
},
|
43
|
+
minify: {
|
44
|
+
src: 'src/hotkeys.css',
|
45
|
+
dest: 'build/hotkeys.min.css'
|
46
|
+
}
|
47
|
+
},
|
48
|
+
|
49
|
+
karma: {
|
50
|
+
unit: {
|
51
|
+
configFile: 'test/karma.conf.js',
|
52
|
+
singleRun: true,
|
53
|
+
coverageReporter: {
|
54
|
+
type: 'text',
|
55
|
+
dir: 'coverage/'
|
56
|
+
}
|
57
|
+
},
|
58
|
+
watch: {
|
59
|
+
configFile: 'test/karma.conf.js',
|
60
|
+
singleRun: false,
|
61
|
+
reporters: ['progress'] // Don't display coverage
|
62
|
+
}
|
63
|
+
},
|
64
|
+
|
65
|
+
jshint: {
|
66
|
+
jshintrc: '.jshintrc',
|
67
|
+
gruntfile: {
|
68
|
+
src: 'Gruntfile.js'
|
69
|
+
},
|
70
|
+
src: {
|
71
|
+
src: ['src/*.js']
|
72
|
+
}
|
73
|
+
},
|
74
|
+
|
75
|
+
concat: {
|
76
|
+
build: {
|
77
|
+
options: {
|
78
|
+
banner: '<%= banner %>'
|
79
|
+
},
|
80
|
+
files: {
|
81
|
+
'build/hotkeys.css': 'src/hotkeys.css',
|
82
|
+
'build/hotkeys.js': ['build/hotkeys.js', 'bower_components/mousetrap/mousetrap.js'],
|
83
|
+
}
|
84
|
+
}
|
85
|
+
},
|
86
|
+
|
87
|
+
watch: {
|
88
|
+
scripts: {
|
89
|
+
files: ['src/*.js'],
|
90
|
+
tasks: ['uglify', 'concat:build'],
|
91
|
+
options: {
|
92
|
+
spawn: false,
|
93
|
+
},
|
94
|
+
},
|
95
|
+
css: {
|
96
|
+
files: ['src/*.css'],
|
97
|
+
tasks: ['cssmin', 'concat:build'],
|
98
|
+
options: {
|
99
|
+
spawn: false,
|
100
|
+
},
|
101
|
+
}
|
102
|
+
},
|
103
|
+
|
104
|
+
});
|
105
|
+
|
106
|
+
grunt.loadNpmTasks('grunt-contrib-uglify');
|
107
|
+
grunt.loadNpmTasks('grunt-ng-annotate');
|
108
|
+
grunt.loadNpmTasks('grunt-contrib-jshint');
|
109
|
+
grunt.loadNpmTasks('grunt-contrib-cssmin');
|
110
|
+
grunt.loadNpmTasks('grunt-contrib-concat');
|
111
|
+
grunt.loadNpmTasks('grunt-contrib-watch');
|
112
|
+
grunt.loadNpmTasks('grunt-karma');
|
113
|
+
|
114
|
+
grunt.registerTask('default', ['jshint', 'karma:unit', 'ngAnnotate', 'uglify', 'cssmin', 'concat:build']);
|
115
|
+
grunt.registerTask('test', ['karma:watch']);
|
116
|
+
grunt.registerTask('build', ['default']);
|
117
|
+
|
118
|
+
};
|
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Wes Cruver
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,248 @@
|
|
1
|
+
angular-hotkeys
|
2
|
+
================
|
3
|
+
Configuration-centric keyboard shortcuts for your Angular apps.
|
4
|
+
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/chieffancypants/angular-hotkeys/badge.png?branch=master)](https://coveralls.io/r/chieffancypants/angular-hotkeys?branch=master)
|
6
|
+
![Build Status](https://magnum-ci.com/status/89743485de3e7311dfc9793e26f39b41.png)
|
7
|
+
|
8
|
+
**Requirements**: Angular 1.2+
|
9
|
+
|
10
|
+
### Features:
|
11
|
+
- Define hotkeys on an entire route, automatically binding and unbinding them as you navigate
|
12
|
+
- Automatic listing of shortcuts when users hit the `?` key
|
13
|
+
- Super duper unit tests
|
14
|
+
|
15
|
+
|
16
|
+
### Installation:
|
17
|
+
|
18
|
+
#### via bower:
|
19
|
+
|
20
|
+
```
|
21
|
+
$ bower install chieffancypants/angular-hotkeys --save
|
22
|
+
```
|
23
|
+
|
24
|
+
#### via npm:
|
25
|
+
|
26
|
+
```
|
27
|
+
$ npm install angular-hotkeys --save
|
28
|
+
```
|
29
|
+
|
30
|
+
|
31
|
+
*please use either the minified or unminified file in the `build` directory*
|
32
|
+
|
33
|
+
### Why I made this:
|
34
|
+
Other projects out there rely too heavily on HTML markup for keyboard shortcuts. For example:
|
35
|
+
|
36
|
+
```html
|
37
|
+
<div class="player">
|
38
|
+
<div class="playPause-btn" hotkey="{space: playPause}"></div>
|
39
|
+
<div class="mute-btn" hotkey="{'ctrl+down': mute}"></div>
|
40
|
+
</div>
|
41
|
+
```
|
42
|
+
|
43
|
+
While this is a great approach for many Angular apps, some applications do not have a 1 to 1 relationship between DOM elements and controller methods. In my case, many methods on the controller were **only** accessible through the keyboard.
|
44
|
+
|
45
|
+
Additionally, this only allows you to pass a function reference, you can't pass arguments to the function you intend to call. So instead of simply calling `seek(currentTime + 30)` and `seek(currentTime + 60)`, I needed to create a ton of helper functions on the scope (such as `forward30` and `forward60`), and litter my HTML like this:
|
46
|
+
|
47
|
+
```html
|
48
|
+
<div class="player" hotkey="{space: playPause,
|
49
|
+
'alt+right': forward30,
|
50
|
+
'ctrl+right': forward60,
|
51
|
+
'left': back30,
|
52
|
+
'ctrl+left': back60,
|
53
|
+
up: volumeUp,
|
54
|
+
down: volumeDown,
|
55
|
+
'ctrl+down': mute,
|
56
|
+
'ctrl+up': unmute,
|
57
|
+
f: fullscreen,
|
58
|
+
h: showHelp}">
|
59
|
+
<div class="playPause-btn"></div>
|
60
|
+
<div class="mute-btn"></div>
|
61
|
+
</div>
|
62
|
+
|
63
|
+
```
|
64
|
+
|
65
|
+
With a few dozen shortcuts, this left the DOM really messy, and with multiple views and directive templates, it was next to impossible to remember where all the different shortcuts were. This became a maintenance nightmare.
|
66
|
+
|
67
|
+
|
68
|
+
### Usage:
|
69
|
+
You can either define hotkeys in your Controller, or in your Route configuration (or both). To start, though, require the lib as a dependency for your angular app:
|
70
|
+
|
71
|
+
```js
|
72
|
+
angular.module('myApp', ['ngRoute', 'cfp.hotkeys']);
|
73
|
+
```
|
74
|
+
|
75
|
+
Behind the scenes, I'm using the [Mousetrap](https://github.com/ccampbell/mousetrap) library to manage the key bindings. Check out the docs there for more information on what kind of key combinations can be used. This library is included in the files from the `build` directory, so there is no need to install and include Mousetrap separately.
|
76
|
+
|
77
|
+
**Update:** [A YouTube video tutorial was created for this project](https://www.youtube.com/watch?v=silr0L7rJOY). Thanks guys!
|
78
|
+
|
79
|
+
|
80
|
+
#### Binding hotkeys in controllers:
|
81
|
+
It is important to note that by default, hotkeys bound using the `hotkeys.add()`
|
82
|
+
method are persistent, meaning they will continue to exist through route
|
83
|
+
changes, DOM manipulation, or anything else.
|
84
|
+
|
85
|
+
However, it is possible to bind the hotkey to a particular scope, and when that
|
86
|
+
scope is destroyed, the hotkey is automatically removed. This should be
|
87
|
+
considered the best practice when binding hotkeys from a controller. For this
|
88
|
+
usage example, see the `hotkeys.bindTo()` method below:
|
89
|
+
|
90
|
+
```js
|
91
|
+
angular.module('myApp').controller('NavbarCtrl', function($scope, hotkeys) {
|
92
|
+
$scope.volume = 5;
|
93
|
+
|
94
|
+
// You can pass it an object. This hotkey will not be unbound unless manually removed
|
95
|
+
// using the hotkeys.del() method
|
96
|
+
hotkeys.add({
|
97
|
+
combo: 'ctrl+up',
|
98
|
+
description: 'This one goes to 11',
|
99
|
+
callback: function() {
|
100
|
+
$scope.volume += 1;
|
101
|
+
}
|
102
|
+
});
|
103
|
+
|
104
|
+
// when you bind it to the controller's scope, it will automatically unbind
|
105
|
+
// the hotkey when the scope is destroyed (due to ng-if or something that changes the DOM)
|
106
|
+
hotkeys.bindTo($scope)
|
107
|
+
.add({
|
108
|
+
combo: 'w',
|
109
|
+
description: 'blah blah',
|
110
|
+
callback: function() {}
|
111
|
+
})
|
112
|
+
// you can chain these methods for ease of use:
|
113
|
+
.add ({...});
|
114
|
+
|
115
|
+
});
|
116
|
+
```
|
117
|
+
|
118
|
+
#### Binding hotkeys in routes:
|
119
|
+
You can also define hotkeys on an entire route, and this lib will bind and unbind them as you navigate the app.
|
120
|
+
|
121
|
+
```js
|
122
|
+
angular.module('myApp').config(function ($routeProvider) {
|
123
|
+
$routeProvider.when('/', {
|
124
|
+
controller: 'RestaurantsController',
|
125
|
+
templateUrl: 'views/restaurants.html',
|
126
|
+
hotkeys: [
|
127
|
+
['p', 'Sort by price', 'sort(price)']
|
128
|
+
]
|
129
|
+
});
|
130
|
+
});
|
131
|
+
```
|
132
|
+
|
133
|
+
#### Binding hotkeys in directives:
|
134
|
+
Lastly, even though binding hotkeys in your templates/html tends to be a bad idea, it can be super useful for simple shortcuts. Think along the lines of a modal directive where you simply want to bind to the escape key or something equally simple. Accomplishing this within a controller is too much overhead, and it may lead to code-reuse.
|
135
|
+
|
136
|
+
Example of how directive-based hotkeys works:
|
137
|
+
|
138
|
+
```html
|
139
|
+
<modal title="Modal Title" hotkey="{esc: close}">
|
140
|
+
```
|
141
|
+
|
142
|
+
#### Cheatsheet
|
143
|
+
|
144
|
+
A cheatsheet is created automatically for you, showing which hotkeys are available for the current route, along with a description as to what it does. The default binding to show the cheatsheet is `?`. Be sure to include the `build/hotkeys.css` stylesheet. [Cheatsheet demo](http://chieffancypants.github.io/angular-hotkeys/#features)
|
145
|
+
|
146
|
+
**Disable the cheatsheet:**
|
147
|
+
|
148
|
+
Disabling the cheatsheet can be accomplished by configuring the `hotkeysProvider`:
|
149
|
+
|
150
|
+
```js
|
151
|
+
angular.module('myApp', ['cfp.hotkeys'])
|
152
|
+
.config(function(hotkeysProvider) {
|
153
|
+
hotkeysProvider.includeCheatSheet = false;
|
154
|
+
})
|
155
|
+
```
|
156
|
+
|
157
|
+
### Configuration
|
158
|
+
|
159
|
+
**Disable ngRoute integration:**
|
160
|
+
|
161
|
+
To prevent listening for $routeChangeSuccess events use `hotkeysProvider`.
|
162
|
+
This option defaults to false if ngRoute module is not loaded:
|
163
|
+
|
164
|
+
```js
|
165
|
+
angular.module('myApp', ['cfp.hotkeys'])
|
166
|
+
.config(function(hotkeysProvider) {
|
167
|
+
hotkeysProvider.useNgRoute = false;
|
168
|
+
})
|
169
|
+
```
|
170
|
+
|
171
|
+
**Cheatsheet template:**
|
172
|
+
|
173
|
+
```js
|
174
|
+
angular.module('myApp', ['cfp.hotkeys'])
|
175
|
+
.config(function(hotkeysProvider) {
|
176
|
+
hotkeysProvider.template = '<div class="my-own-cheatsheet">...</div>';
|
177
|
+
})
|
178
|
+
```
|
179
|
+
|
180
|
+
**Header and footer:**
|
181
|
+
|
182
|
+
You can specify a custom header and footer for the cheatsheet. Both are HTML, and if the header is set it will override the normal title.
|
183
|
+
|
184
|
+
```js
|
185
|
+
angular.module('myApp', ['cfp.hotkeys'])
|
186
|
+
.config(function(hotkeysProvider) {
|
187
|
+
hotkeysProvider.templateHeader = '<div class="my-own-header">...</div>';
|
188
|
+
hotkeysProvider.templateFooter = '<div class="my-own-footer">...</div>';
|
189
|
+
})
|
190
|
+
```
|
191
|
+
|
192
|
+
### API
|
193
|
+
|
194
|
+
#### hotkeys.add(object)
|
195
|
+
`object`: An object with the following parameters:
|
196
|
+
- `combo`: They keyboard combo (shortcut) you want to bind to
|
197
|
+
- `description`: [OPTIONAL] The description for what the combo does and is only used for the Cheat Sheet. If it is not supplied, it will not show up, and in effect, allows you to have unlisted hotkeys.
|
198
|
+
- `callback`: The function to execute when the key(s) are pressed. Passes along two arguments, `event` and `hotkey`
|
199
|
+
- `action`: [OPTIONAL] The type of event to listen for, such as `keypress`, `keydown` or `keyup`. Usage of this parameter is discouraged as the underlying library will pick the most suitable option automatically. This should only be necessary in advanced situations.
|
200
|
+
- `allowIn`: [OPTIONAL] an array of tag names to allow this combo in ('INPUT', 'SELECT', and/or 'TEXTAREA')
|
201
|
+
|
202
|
+
```js
|
203
|
+
hotkeys.add({
|
204
|
+
combo: 'ctrl+w',
|
205
|
+
description: 'Description goes here',
|
206
|
+
callback: function(event, hotkey) {
|
207
|
+
event.preventDefault();
|
208
|
+
}
|
209
|
+
});
|
210
|
+
|
211
|
+
// this hotkey will not show up on the cheat sheet:
|
212
|
+
hotkeys.add({
|
213
|
+
combo: 'ctrl+x',
|
214
|
+
callback: function(event, hotkey) {...}
|
215
|
+
});
|
216
|
+
```
|
217
|
+
|
218
|
+
#### hotkeys.get(key)
|
219
|
+
Returns the Hotkey object
|
220
|
+
|
221
|
+
```js
|
222
|
+
hotkeys.get('ctrl+w');
|
223
|
+
// -> Hotkey { combo: ['ctrl+w'], description: 'Description goes here', callback: function (event, hotkey) }
|
224
|
+
```
|
225
|
+
|
226
|
+
#### hotkeys.del(key)
|
227
|
+
Removes and unbinds a hotkey
|
228
|
+
|
229
|
+
```js
|
230
|
+
hotkeys.del('ctrl+w');
|
231
|
+
```
|
232
|
+
|
233
|
+
### Allowing hotkeys in form elements
|
234
|
+
By default, Mousetrap prevents hotkey callbacks from firing when their event originates from an `input`, `select`, or `textarea` element. To enable hotkeys in these elements, specify them in the `allowIn` parameter:
|
235
|
+
```js
|
236
|
+
hotkeys.add({
|
237
|
+
combo: 'ctrl+w',
|
238
|
+
description: 'Description goes here',
|
239
|
+
allowIn: ['INPUT', 'SELECT', 'TEXTAREA'],
|
240
|
+
callback: function(event, hotkey) {
|
241
|
+
event.preventDefault();
|
242
|
+
}
|
243
|
+
});
|
244
|
+
```
|
245
|
+
|
246
|
+
## Credits:
|
247
|
+
|
248
|
+
Muchas gracias to Craig Campbell for his [Mousetrap](https://github.com/ccampbell/mousetrap) library, which provides the underlying library for handling keyboard shortcuts.
|