Commit c0cb35795da9df094e0a991e6905f1b60a1a09c0
Exists in
develop
Merge branch 'develop' into 'master'
Develop See merge request !19
Showing
2 changed files
Show diff stats
package.json
1 | { | 1 | { |
2 | "name": "foca-directivas", | 2 | "name": "foca-directivas", |
3 | "version": "0.0.1", | 3 | "version": "0.0.1", |
4 | "description": "Directivas para usarse en los productos Debo Suite", | 4 | "description": "Directivas para usarse en los productos Debo Suite", |
5 | "main": "index.js", | 5 | "main": "index.js", |
6 | "scripts": { | 6 | "scripts": { |
7 | "refresh": "gulp uglify && cp tmp/foca-directivas.js ../wrapper-demo/node_modules/foca-directivas/dist/foca-directivas.min.js", | ||
8 | "frefresh": "gulp uglify && cp tmp/foca-directivas.js ../wrapper-facturador/node_modules/foca-directivas/dist/foca-directivas.min.js", | ||
7 | "test": "echo \"Error: no test specified\" && exit 1", | 9 | "test": "echo \"Error: no test specified\" && exit 1", |
8 | "compile": "gulp uglify", | 10 | "compile": "gulp uglify", |
9 | "postinstall": "npm run compile && gulp clean-post-install", | 11 | "postinstall": "npm run compile && gulp clean-post-install", |
10 | "install-dev": "npm install -D angular gulp gulp-clean gulp-concat gulp-jshint gulp-rename gulp-replace gulp-uglify jquery jshint pump" | 12 | "install-dev": "npm install -D angular gulp gulp-clean gulp-concat gulp-jshint gulp-rename gulp-replace gulp-uglify jquery jshint pump" |
11 | }, | 13 | }, |
12 | "pre-commit": [ | 14 | "pre-commit": [ |
13 | "gulp-pre-commit" | 15 | "gulp-pre-commit" |
14 | ], | 16 | ], |
15 | "repository": { | 17 | "repository": { |
16 | "type": "git", | 18 | "type": "git", |
17 | "url": "https://debo.suite.repo/modulos-npm/foca-directivas.git" | 19 | "url": "https://debo.suite.repo/modulos-npm/foca-directivas.git" |
18 | }, | 20 | }, |
19 | "author": "Nicolás Guarnieri", | 21 | "author": "Nicolás Guarnieri", |
20 | "license": "ISC", | 22 | "license": "ISC", |
21 | "peerDependencies": { | 23 | "peerDependencies": { |
22 | "angular": "^1.7.4", | 24 | "angular": "^1.7.4", |
23 | "gulp": "^3.9.1", | 25 | "gulp": "^3.9.1", |
24 | "gulp-concat": "^2.6.1", | 26 | "gulp-concat": "^2.6.1", |
25 | "gulp-jshint": "^2.1.0", | 27 | "gulp-jshint": "^2.1.0", |
26 | "gulp-rename": "^1.4.0", | 28 | "gulp-rename": "^1.4.0", |
27 | "gulp-replace": "^1.0.0", | 29 | "gulp-replace": "^1.0.0", |
28 | "gulp-uglify": "^3.0.1", | 30 | "gulp-uglify": "^3.0.1", |
29 | "jquery": "^3.3.1", | 31 | "jquery": "^3.3.1", |
30 | "jshint": "^2.9.6", | 32 | "jshint": "^2.9.6", |
31 | "pump": "^3.0.0" | 33 | "pump": "^3.0.0" |
32 | }, | 34 | }, |
33 | "devDependencies": { | 35 | "devDependencies": { |
34 | "angular": "^1.7.5", | 36 | "angular": "^1.7.5", |
35 | "gulp": "^3.9.1", | 37 | "gulp": "^3.9.1", |
36 | "gulp-clean": "^0.4.0", | 38 | "gulp-clean": "^0.4.0", |
37 | "gulp-concat": "^2.6.1", | 39 | "gulp-concat": "^2.6.1", |
38 | "gulp-jshint": "^2.1.0", | 40 | "gulp-jshint": "^2.1.0", |
39 | "gulp-rename": "^1.4.0", | 41 | "gulp-rename": "^1.4.0", |
40 | "gulp-replace": "^1.0.0", | 42 | "gulp-replace": "^1.0.0", |
41 | "gulp-uglify": "^3.0.1", | 43 | "gulp-uglify": "^3.0.1", |
42 | "jquery": "^3.3.1", | 44 | "jquery": "^3.3.1", |
43 | "jshint": "^2.9.6", | 45 | "jshint": "^2.9.6", |
44 | "pump": "^3.0.0" | 46 | "pump": "^3.0.0" |
45 | } | 47 | } |
46 | } | 48 | } |
47 | 49 |
src/js/onMouseHold-directive.js
File was created | 1 | angular.module('focaDirectivas') | |
2 | .directive('onMouseHold', function ($parse, $interval) { | ||
3 | var stop; | ||
4 | |||
5 | var dirDefObj = { | ||
6 | restrict: 'A', | ||
7 | scope: { method: '&onMouseHold' }, | ||
8 | link: function (scope, element, attrs) { | ||
9 | |||
10 | var expressionHandler = scope.method(); | ||
11 | var actionInterval = (attrs.mouseHoldRepeat) ? attrs.mouseHoldRepeat : 500; | ||
12 | |||
13 | var startAction = function () { | ||
14 | expressionHandler(); | ||
15 | stop = $interval(function () { | ||
16 | expressionHandler(); | ||
17 | }, actionInterval); | ||
18 | }; | ||
19 | |||
20 | var stopAction = function () { | ||
21 | if (stop) { | ||
22 | $interval.cancel(stop); | ||
23 | stop = undefined; | ||
24 | } | ||
25 | }; | ||
26 | |||
27 | element.bind('mousedown', startAction); | ||
28 | element.bind('mouseup', stopAction); | ||
29 | element.bind('mouseout', stopAction); | ||
30 | } | ||
31 | }; | ||
32 | |||
33 | return dirDefObj; | ||
34 | }); | ||
35 |