Commit 0ba2e78ce45c99c8c5b6e92b0280a2e8cb0e767d

Authored by Eric Fernandez
Exists in master

Merge branch 'master' into 'master'

Master(efernandez)

See merge request modulos-npm/foca-modal-confirm!1
... ... @@ -0,0 +1,5 @@
  1 +/node_modules
  2 +/dist
  3 +/tmp
  4 +package-lock\.json
  5 +/src/etc/develop.js
... ... @@ -0,0 +1,64 @@
  1 +{
  2 + /*
  3 + * ENVIRONMENTS
  4 + * =================
  5 + */
  6 +
  7 + // Define globals exposed by modern browsers.
  8 + "browser": true,
  9 +
  10 + // Define globals exposed by jQuery.
  11 + "jquery": true,
  12 +
  13 + // Define globals exposed by Node.js.
  14 + "node": true,
  15 +
  16 + // Allow ES6.
  17 + "esversion": 6,
  18 +
  19 + /*
  20 + * ENFORCING OPTIONS
  21 + * =================
  22 + */
  23 +
  24 + // Force all variable names to use either camelCase style or UPPER_CASE
  25 + // with underscores.
  26 + "camelcase": true,
  27 +
  28 + // Prohibit use of == and != in favor of === and !==.
  29 + "eqeqeq": true,
  30 +
  31 + // Enforce tab width of 2 spaces.
  32 + "indent": 4,
  33 +
  34 + // Prohibit use of a variable before it is defined.
  35 + "latedef": true,
  36 +
  37 + // Enforce line length to 100 characters
  38 + "maxlen": 100,
  39 +
  40 + // Require capitalized names for constructor functions.
  41 + "newcap": true,
  42 +
  43 + // Enforce use of single quotation marks for strings.
  44 + "quotmark": "single",
  45 +
  46 + // Enforce placing 'use strict' at the top function scope
  47 + "strict": false,
  48 +
  49 + // Prohibit use of explicitly undeclared variables.
  50 + "undef": true,
  51 +
  52 + // Warn when variables are defined but never used.
  53 + "unused": true,
  54 +
  55 + // Para que funcione en angular
  56 + "predef": ["angular", "alert", "spyOn", "expect", "it", "inject", "beforeEach", "describe", "confirm"],
  57 + /*
  58 + * RELAXING OPTIONS
  59 + * =================
  60 + */
  61 +
  62 + // Suppress warnings about == null comparisons.
  63 + "eqnull": true
  64 +}
... ... @@ -0,0 +1,77 @@
  1 +const templateCache = require('gulp-angular-templatecache');
  2 +const concat = require('gulp-concat');
  3 +const clean = require('gulp-clean');
  4 +const htmlmin = require('gulp-htmlmin');
  5 +const rename = require('gulp-rename');
  6 +const uglify = require('gulp-uglify');
  7 +const gulp = require('gulp');
  8 +const pump = require('pump');
  9 +const jshint = require('gulp-jshint');
  10 +const replace = require('gulp-replace');
  11 +
  12 +var paths = {
  13 + srcJS: 'src/js/*.js',
  14 + srcViews: 'src/views/*.html',
  15 + tmp: 'tmp',
  16 + dist: 'dist/'
  17 +};
  18 +
  19 +gulp.task('templates', function() {
  20 + return pump(
  21 + [
  22 + gulp.src(paths.srcViews),
  23 + htmlmin(),
  24 + templateCache('views.js', {
  25 + module: 'focaModal',
  26 + root: ''
  27 + }),
  28 + gulp.dest(paths.tmp)
  29 + ]
  30 + );
  31 +});
  32 +
  33 +gulp.task('uglify', ['templates'], function() {
  34 + return pump(
  35 + [
  36 + gulp.src([
  37 + paths.srcJS,
  38 + 'tmp/views.js'
  39 + ]),
  40 + concat('foca-modal.js'),
  41 + gulp.dest(paths.tmp),
  42 + rename('foca-modal.min.js'),
  43 + uglify(),
  44 + gulp.dest(paths.dist)
  45 + ]
  46 + );
  47 +});
  48 +
  49 +gulp.task('clean', function() {
  50 + return gulp.src(['tmp', 'dist'], {read: false})
  51 + .pipe(clean());
  52 +});
  53 +
  54 +gulp.task('pre-commit', function() {
  55 + pump(
  56 + [
  57 + gulp.src(paths.srcJS),
  58 + jshint('.jshintrc'),
  59 + jshint.reporter('default'),
  60 + jshint.reporter('fail')
  61 + ]
  62 + );
  63 +});
  64 +
  65 +gulp.task('clean-post-install', function() {
  66 + return gulp.src(['src', 'tmp', '.jshintrc','readme.md', '.gitignore', 'gulpfile.js',
  67 + 'index.html'], {read: false})
  68 + .pipe(clean());
  69 +});
  70 +
  71 +gulp.task('webserver', function() {
  72 + pump [
  73 + connect.server({port: 3000})
  74 + ]
  75 +});
  76 +
  77 +gulp.task('default', ['webserver']);
... ... @@ -0,0 +1,36 @@
  1 +{
  2 + "name": "foca-modal-confirm",
  3 + "version": "0.0.1",
  4 + "description": "Modal de confirmacion",
  5 + "main": "index.js",
  6 + "scripts": {
  7 + "test": "echo \"Error: no test specified\" && exit 1",
  8 + "gulp-pre-commit": "gulp pre-commit",
  9 + "compile": "gulp uglify",
  10 + "postinstall": "npm run compile && gulp clean-post-install",
  11 + "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"
  12 + },
  13 + "pre-commit": [
  14 + "gulp-pre-commit"
  15 + ],
  16 + "repository": {
  17 + "type": "git",
  18 + "url": "https://192.168.0.11/modulos-npm/foca-modal.git"
  19 + },
  20 + "author": "Foca Software",
  21 + "license": "ISC",
  22 + "devDependencies": {
  23 + "angular": "^1.7.5",
  24 + "gulp": "^3.9.1",
  25 + "gulp-angular-templatecache": "^2.2.2",
  26 + "gulp-clean": "^0.4.0",
  27 + "gulp-connect": "^5.6.1",
  28 + "gulp-htmlmin": "^5.0.1",
  29 + "gulp-jshint": "^2.1.0",
  30 + "gulp-rename": "^1.4.0",
  31 + "gulp-replace": "^1.0.0",
  32 + "gulp-uglify": "^3.0.1",
  33 + "jshint": "^2.9.6",
  34 + "pump": "^3.0.0"
  35 + }
  36 +}
... ... @@ -0,0 +1 @@
  1 +angular.module('focaModal', []);
src/js/controller.js
... ... @@ -0,0 +1,22 @@
  1 +angular.module('focaModal')
  2 +.controller('focaModalConfirmController', [
  3 + '$uibModalInstance', '$scope', 'textoModal',
  4 + function($uibModalInstance, $scope, textoModal) {
  5 + $scope.textoModal = textoModal;
  6 + $scope.cancelar = function() {
  7 + $uibModalInstance.close(false);
  8 + };
  9 + $scope.aceptar = function() {
  10 + $uibModalInstance.close(true);
  11 + };
  12 + }
  13 +])
  14 +.controller('focaModalAlertController', [
  15 + '$uibModalInstance', '$scope', 'textoModal',
  16 + function($uibModalInstance, $scope, textoModal) {
  17 + $scope.textoModal = textoModal;
  18 + $scope.aceptar = function() {
  19 + $uibModalInstance.close(true);
  20 + };
  21 + }
  22 +]);
... ... @@ -0,0 +1,31 @@
  1 +angular.module('focaModal')
  2 + .service('modal', [
  3 + '$uibModal',
  4 + function($uibModal) {
  5 + return {
  6 + confirm: function(textoModal) {
  7 + return $uibModal.open({
  8 + templateUrl: 'modal-confirm.html',
  9 + controller: 'focaModalConfirmController',
  10 + animation: false,
  11 + backdrop: false,
  12 + resolve: { text: function() { return textoModal; } }
  13 + })
  14 + .result.then(
  15 + function(resultado) {
  16 + return resultado;
  17 + }
  18 + );
  19 + },
  20 + alert: function(textoModal) {
  21 + return $uibModal.open({
  22 + templateUrl: 'modal-alert.html',
  23 + controller: 'focaModalAlertController',
  24 + animation: false,
  25 + backdrop: false,
  26 + resolve: { text: function() { return textoModal; } }
  27 + });
  28 + }
  29 + };
  30 + }
  31 + ]);
src/views/modal-alert.html
... ... @@ -0,0 +1,11 @@
  1 +<div class="modal-header">
  2 + <h4>Alerta</h4>
  3 +</div>
  4 +<div class="modal-body">
  5 + <p ng-bind="textoModal">
  6 +
  7 + </p>
  8 +</div>
  9 +<div class="modal-footer">
  10 + <button class="btn btn-info" ng-click="aceptar()">Aceptar</button>
  11 +</div>
src/views/modal-confirm.html
... ... @@ -0,0 +1,12 @@
  1 +<div class="modal-header">
  2 + <h4>Confirmar</h4>
  3 +</div>
  4 +<div class="modal-body">
  5 + <p ng-bind="textoModal">
  6 +
  7 + </p>
  8 +</div>
  9 +<div class="modal-footer">
  10 + <button class="btn btn-danger" ng-click="aceptar()">Aceptar</button>
  11 + <button class="btn btn-default" ng-click="cancelar()">Cancelar</button>
  12 +</div>