Commit a6bf328e03c0745d23e077b59a7871864a19179e

Authored by Eric Fernandez
1 parent 89aca201eb
Exists in master and in 1 other branch develop

Primera versión estable

... ... @@ -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,35 @@
  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 + "postinstall": "npm run compile && gulp clean-post-install",
  10 + "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"
  11 + },
  12 + "pre-commit":[
  13 + "gulp-pre-commit"
  14 + ],
  15 + "repository": {
  16 + "type": "git",
  17 + "url": "https://192.168.0.11/modulos-npm/foca-modal.git"
  18 + },
  19 + "author": "Foca Software",
  20 + "license": "ISC",
  21 + "devDependencies": {
  22 + "angular": "^1.7.5",
  23 + "gulp": "^3.9.1",
  24 + "gulp-angular-templatecache": "^2.2.2",
  25 + "gulp-clean": "^0.4.0",
  26 + "gulp-connect": "^5.6.1",
  27 + "gulp-htmlmin": "^5.0.1",
  28 + "gulp-jshint": "^2.1.0",
  29 + "gulp-rename": "^1.4.0",
  30 + "gulp-replace": "^1.0.0",
  31 + "gulp-uglify": "^3.0.1",
  32 + "jshint": "^2.9.6",
  33 + "pump": "^3.0.0"
  34 + }
  35 +}
... ... @@ -0,0 +1,2 @@
  1 +angular.module('focaModal', []);
  2 +
0 3 \ No newline at end of file
src/js/controller.js
... ... @@ -0,0 +1,22 @@
  1 +angular.module('focaModal')
  2 +.controller('focaModalConfirmController', [
  3 + '$uibModalInstance', '$scope', 'text',
  4 + function($uibModalInstance, $scope, text) {
  5 + $scope.param = text;
  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', 'text',
  16 + function($uibModalInstance, $scope, text) {
  17 + $scope.param = text;
  18 + $scope.aceptar = function() {
  19 + $uibModalInstance.close(true);
  20 + };
  21 + }
  22 +])
0 23 \ No newline at end of file
... ... @@ -0,0 +1,31 @@
  1 +angular.module('focaModal')
  2 + .service('modal', [
  3 + '$uibModal',
  4 + function ($uibModal) {
  5 + return {
  6 + confirm: function (a) {
  7 + return $uibModal.open({
  8 + templateUrl: 'modal-confirm.html',
  9 + controller: 'focaModalConfirmController',
  10 + animation: false,
  11 + backdrop: false,
  12 + resolve: { text: function () { return a; } }
  13 + })
  14 + .result.then(
  15 + function (p) {
  16 + return p;
  17 + }
  18 + )
  19 + },
  20 + alert: function (a) {
  21 + return $uibModal.open({
  22 + templateUrl: 'modal-alert.html',
  23 + controller: 'focaModalAlertController',
  24 + animation: false,
  25 + backdrop: false,
  26 + resolve: { text: function () { return a; } }
  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>
  6 + {{param}}
  7 + </p>
  8 +</div>
  9 +<div class="modal-footer">
  10 + <button class="btn btn-info" ng-click="aceptar()">Aceptar</button>
  11 +</div>
0 12 \ No newline at end of file
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>
  6 + {{param}}
  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>