From a6bf328e03c0745d23e077b59a7871864a19179e Mon Sep 17 00:00:00 2001 From: Eric Fernandez Date: Tue, 16 Oct 2018 16:16:32 -0300 Subject: [PATCH] =?UTF-8?q?Primera=20versi=C3=B3n=20estable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 5 +++ .jshintrc | 64 ++++++++++++++++++++++++++++++++++++ gulpfile.js | 77 ++++++++++++++++++++++++++++++++++++++++++++ package.json | 35 ++++++++++++++++++++ src/js/app.js | 2 ++ src/js/controller.js | 22 +++++++++++++ src/js/service.js | 31 ++++++++++++++++++ src/views/modal-alert.html | 11 +++++++ src/views/modal-confirm.html | 12 +++++++ 9 files changed, 259 insertions(+) create mode 100644 .gitignore create mode 100644 .jshintrc create mode 100644 gulpfile.js create mode 100644 package.json create mode 100644 src/js/app.js create mode 100644 src/js/controller.js create mode 100644 src/js/service.js create mode 100644 src/views/modal-alert.html create mode 100644 src/views/modal-confirm.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..31a0ef5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/node_modules +/dist +/tmp +package-lock\.json +/src/etc/develop.js diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..4665bfa --- /dev/null +++ b/.jshintrc @@ -0,0 +1,64 @@ +{ + /* + * ENVIRONMENTS + * ================= + */ + + // Define globals exposed by modern browsers. + "browser": true, + + // Define globals exposed by jQuery. + "jquery": true, + + // Define globals exposed by Node.js. + "node": true, + + // Allow ES6. + "esversion": 6, + + /* + * ENFORCING OPTIONS + * ================= + */ + + // Force all variable names to use either camelCase style or UPPER_CASE + // with underscores. + "camelcase": true, + + // Prohibit use of == and != in favor of === and !==. + "eqeqeq": true, + + // Enforce tab width of 2 spaces. + "indent": 4, + + // Prohibit use of a variable before it is defined. + "latedef": true, + + // Enforce line length to 100 characters + "maxlen": 100, + + // Require capitalized names for constructor functions. + "newcap": true, + + // Enforce use of single quotation marks for strings. + "quotmark": "single", + + // Enforce placing 'use strict' at the top function scope + "strict": false, + + // Prohibit use of explicitly undeclared variables. + "undef": true, + + // Warn when variables are defined but never used. + "unused": true, + + // Para que funcione en angular + "predef": ["angular", "alert", "spyOn", "expect", "it", "inject", "beforeEach", "describe", "confirm"], + /* + * RELAXING OPTIONS + * ================= + */ + + // Suppress warnings about == null comparisons. + "eqnull": true +} diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..41d2262 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,77 @@ +const templateCache = require('gulp-angular-templatecache'); +const concat = require('gulp-concat'); +const clean = require('gulp-clean'); +const htmlmin = require('gulp-htmlmin'); +const rename = require('gulp-rename'); +const uglify = require('gulp-uglify'); +const gulp = require('gulp'); +const pump = require('pump'); +const jshint = require('gulp-jshint'); +const replace = require('gulp-replace'); + +var paths = { + srcJS: 'src/js/*.js', + srcViews: 'src/views/*.html', + tmp: 'tmp', + dist: 'dist/' +}; + +gulp.task('templates', function() { + return pump( + [ + gulp.src(paths.srcViews), + htmlmin(), + templateCache('views.js', { + module: 'focaModal', + root: '' + }), + gulp.dest(paths.tmp) + ] + ); +}); + +gulp.task('uglify', ['templates'], function() { + return pump( + [ + gulp.src([ + paths.srcJS, + 'tmp/views.js' + ]), + concat('foca-modal.js'), + gulp.dest(paths.tmp), + rename('foca-modal.min.js'), + uglify(), + gulp.dest(paths.dist) + ] + ); +}); + +gulp.task('clean', function() { + return gulp.src(['tmp', 'dist'], {read: false}) + .pipe(clean()); +}); + +gulp.task('pre-commit', function() { + pump( + [ + gulp.src(paths.srcJS), + jshint('.jshintrc'), + jshint.reporter('default'), + jshint.reporter('fail') + ] + ); +}); + +gulp.task('clean-post-install', function() { + return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js', + 'index.html'], {read: false}) + .pipe(clean()); +}); + +gulp.task('webserver', function() { + pump [ + connect.server({port: 3000}) + ] +}); + +gulp.task('default', ['webserver']); diff --git a/package.json b/package.json new file mode 100644 index 0000000..2a7a64b --- /dev/null +++ b/package.json @@ -0,0 +1,35 @@ +{ + "name": "foca-modal-confirm", + "version": "0.0.1", + "description": "Modal de confirmacion", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "gulp-pre-commit":"gulp pre-commit", + "postinstall": "npm run compile && gulp clean-post-install", + "install-dev": "npm install -D angular gulp gulp-angular-templatecache gulp-clean gulp-connect gulp-htmlmin gulp-jshint gulp-rename gulp-replace gulp-uglify jshint pump" + }, + "pre-commit":[ + "gulp-pre-commit" + ], + "repository": { + "type": "git", + "url": "https://192.168.0.11/modulos-npm/foca-modal.git" + }, + "author": "Foca Software", + "license": "ISC", + "devDependencies": { + "angular": "^1.7.5", + "gulp": "^3.9.1", + "gulp-angular-templatecache": "^2.2.2", + "gulp-clean": "^0.4.0", + "gulp-connect": "^5.6.1", + "gulp-htmlmin": "^5.0.1", + "gulp-jshint": "^2.1.0", + "gulp-rename": "^1.4.0", + "gulp-replace": "^1.0.0", + "gulp-uglify": "^3.0.1", + "jshint": "^2.9.6", + "pump": "^3.0.0" + } +} diff --git a/src/js/app.js b/src/js/app.js new file mode 100644 index 0000000..d3fdafe --- /dev/null +++ b/src/js/app.js @@ -0,0 +1,2 @@ +angular.module('focaModal', []); + \ No newline at end of file diff --git a/src/js/controller.js b/src/js/controller.js new file mode 100644 index 0000000..3119636 --- /dev/null +++ b/src/js/controller.js @@ -0,0 +1,22 @@ +angular.module('focaModal') +.controller('focaModalConfirmController', [ + '$uibModalInstance', '$scope', 'text', + function($uibModalInstance, $scope, text) { + $scope.param = text; + $scope.cancelar = function() { + $uibModalInstance.close(false); + }; + $scope.aceptar = function() { + $uibModalInstance.close(true); + }; + } +]) +.controller('focaModalAlertController', [ + '$uibModalInstance', '$scope', 'text', + function($uibModalInstance, $scope, text) { + $scope.param = text; + $scope.aceptar = function() { + $uibModalInstance.close(true); + }; + } +]) \ No newline at end of file diff --git a/src/js/service.js b/src/js/service.js new file mode 100644 index 0000000..18053eb --- /dev/null +++ b/src/js/service.js @@ -0,0 +1,31 @@ +angular.module('focaModal') + .service('modal', [ + '$uibModal', + function ($uibModal) { + return { + confirm: function (a) { + return $uibModal.open({ + templateUrl: 'modal-confirm.html', + controller: 'focaModalConfirmController', + animation: false, + backdrop: false, + resolve: { text: function () { return a; } } + }) + .result.then( + function (p) { + return p; + } + ) + }, + alert: function (a) { + return $uibModal.open({ + templateUrl: 'modal-alert.html', + controller: 'focaModalAlertController', + animation: false, + backdrop: false, + resolve: { text: function () { return a; } } + }) + } + } + } + ]); diff --git a/src/views/modal-alert.html b/src/views/modal-alert.html new file mode 100644 index 0000000..cfbf8ad --- /dev/null +++ b/src/views/modal-alert.html @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/src/views/modal-confirm.html b/src/views/modal-confirm.html new file mode 100644 index 0000000..4824059 --- /dev/null +++ b/src/views/modal-confirm.html @@ -0,0 +1,12 @@ + + + -- 1.9.1