From 68b5c7aa8efe54342a5ad5a83991c13ed0ac3bf9 Mon Sep 17 00:00:00 2001 From: nelo Date: Tue, 13 Dec 2016 15:09:54 +0100 Subject: [PATCH] inyeccion para minimificar --- @salix/app/src/bootstrap.js | 2 +- .../app/src/components/searchbar/searchbar.js | 5 +- @salix/app/src/configroutes.js | 9 +-- @salix/core/src/combo/combo.js | 4 +- @salix/core/src/date-picker/date-picker.js | 4 +- @salix/core/src/icon-button/icon-button.js | 4 +- @salix/core/src/interpolate.js | 58 ++++++++++--------- @salix/core/src/password/password.js | 4 +- @salix/core/src/resolveDefaultComponents.js | 40 +++++++------ @salix/core/src/routesLoader.js | 19 +++--- @salix/core/src/snackbar/snackbar.js | 4 +- @salix/core/src/spinner/spinner.js | 4 +- @salix/core/src/submit/submit.js | 4 +- @salix/core/src/title/title.js | 4 +- @salix/crud/src/client/addresses/index.js | 8 +-- @salix/crud/src/client/card/card.js | 2 - @salix/webpack.config.js | 6 +- services/salix/client/index.ejs | 2 +- 18 files changed, 89 insertions(+), 94 deletions(-) diff --git a/@salix/app/src/bootstrap.js b/@salix/app/src/bootstrap.js index 2e2704312..b49a0112d 100644 --- a/@salix/app/src/bootstrap.js +++ b/@salix/app/src/bootstrap.js @@ -14,5 +14,5 @@ export const bootstrap = () => { throw new Error("element is not defined"); } ng.bootstrap(_element, [SALIX]); - + }; diff --git a/@salix/app/src/components/searchbar/searchbar.js b/@salix/app/src/components/searchbar/searchbar.js index 0d9e5efc2..a3f36dd72 100644 --- a/@salix/app/src/components/searchbar/searchbar.js +++ b/@salix/app/src/components/searchbar/searchbar.js @@ -3,9 +3,6 @@ import {module} from '../../module'; export const NAME = 'vnSearchbar' export const COMPONENT = { - template: template, - controller: function(){ - - } + template: template }; module.component(NAME, COMPONENT); diff --git a/@salix/app/src/configroutes.js b/@salix/app/src/configroutes.js index 1cd9004b5..c21ef7a7a 100644 --- a/@salix/app/src/configroutes.js +++ b/@salix/app/src/configroutes.js @@ -2,15 +2,18 @@ import * as core from 'core'; import * as spliting from './spliting'; import * as deps from './spliting/deps.json'; + function loader(module) { - return function ($ocLazyLoad, $q) { + return function load($ocLazyLoad, $q){ return $q((resolve) => { core.splitingRegister.execute(module).then(function (dependencies) { var array = dependencies.map((item) => { return { name: item } }); resolve($ocLazyLoad.load(array)); }); }); - }; + + } + load.$inject = ['$ocLazyLoad', '$q']; } function getParams(route){ @@ -48,7 +51,5 @@ function config($stateProvider, $urlRouterProvider) { } } - - config.$inject = ['$stateProvider', '$urlRouterProvider']; core.module.config(config); diff --git a/@salix/core/src/combo/combo.js b/@salix/core/src/combo/combo.js index de416a116..f8b7a5a68 100644 --- a/@salix/core/src/combo/combo.js +++ b/@salix/core/src/combo/combo.js @@ -1,4 +1,4 @@ -import {module} from '../module'; +import {module as _module} from '../module'; import * as resolveFactory from '../resolveDefaultComponents'; import * as util from '../util'; @@ -15,4 +15,4 @@ export function directive(resolve) { } }; } -module.directive(NAME, directive); +_module.directive(NAME, directive); diff --git a/@salix/core/src/date-picker/date-picker.js b/@salix/core/src/date-picker/date-picker.js index 371498a41..2fe1d58f9 100644 --- a/@salix/core/src/date-picker/date-picker.js +++ b/@salix/core/src/date-picker/date-picker.js @@ -1,4 +1,4 @@ -import {module} from '../module'; +import {module as _module} from '../module'; import * as resolveFactory from '../resolveDefaultComponents'; import * as util from '../util'; @@ -14,4 +14,4 @@ export function directive(resolve) { } }; } -module.directive(NAME, directive); +_module.directive(NAME, directive); diff --git a/@salix/core/src/icon-button/icon-button.js b/@salix/core/src/icon-button/icon-button.js index 095911090..180eb1b28 100644 --- a/@salix/core/src/icon-button/icon-button.js +++ b/@salix/core/src/icon-button/icon-button.js @@ -1,4 +1,4 @@ -import {module} from '../module'; +import {module as _module} from '../module'; import * as resolveFactory from '../resolveDefaultComponents'; import * as util from '../util'; @@ -14,4 +14,4 @@ export function directive(resolve) { } }; } -module.directive(NAME, directive); +_module.directive(NAME, directive); diff --git a/@salix/core/src/interpolate.js b/@salix/core/src/interpolate.js index 0c20426d1..115c1f98e 100644 --- a/@salix/core/src/interpolate.js +++ b/@salix/core/src/interpolate.js @@ -36,32 +36,7 @@ $interpolateMinErr.interr = function (text, err) { return $interpolateMinErr('interr', 'Can\'t interpolate: {0}\n{1}', text, err.toString()); }; -export class Interpolate -{ - constructor () { - this._startSymbol='*['; - this._endSymbol = ']*'; - } - - set startSymbol (value) { - if (value) { - this._startSymbol = value; - return this; - } else { - return this._startSymbol; - } - }; - - set endSymbol (value) { - if (value) { - this._endSymbol = value; - return this; - } else { - return this._endSymbol; - } - }; - - $get($parse, $exceptionHandler, $sce) { +function $get($parse, $exceptionHandler, $sce) { var startSymbolLength = this._startSymbol.length, endSymbolLength = this._endSymbol.length, escapedStartRegexp = new RegExp(this._startSymbol.replace(/./g, escape), 'g'), @@ -195,8 +170,37 @@ export class Interpolate return $interpolate; } + +$get.$inject = ['$parse', '$exceptionHandler', '$sce']; + +export class Interpolate +{ + constructor () { + this._startSymbol='*['; + this._endSymbol = ']*'; + } + + set startSymbol (value) { + if (value) { + this._startSymbol = value; + return this; + } else { + return this._startSymbol; + } + }; + + set endSymbol (value) { + if (value) { + this._endSymbol = value; + return this; + } else { + return this._endSymbol; + } + }; + + } +Interpolate.prototype.$get = $get; var interpolate = new Interpolate(); -interpolate.$get.$inject = ['$parse', '$exceptionHandler', '$sce']; module.provider(NAME, () => interpolate); diff --git a/@salix/core/src/password/password.js b/@salix/core/src/password/password.js index 86b909e92..c43d266d8 100644 --- a/@salix/core/src/password/password.js +++ b/@salix/core/src/password/password.js @@ -1,4 +1,4 @@ -import {module} from '../module'; +import {module as _module} from '../module'; import * as resolveFactory from '../resolveDefaultComponents'; import * as util from '../util'; @@ -15,4 +15,4 @@ export function directive (resolve){ } } -module.directive(NAME,directive); +_module.directive(NAME,directive); diff --git a/@salix/core/src/resolveDefaultComponents.js b/@salix/core/src/resolveDefaultComponents.js index 49f731d2a..0fa9232a9 100644 --- a/@salix/core/src/resolveDefaultComponents.js +++ b/@salix/core/src/resolveDefaultComponents.js @@ -5,6 +5,26 @@ import Interpolate from './interpolate'; export const NAME = util.getProviderName('ResolveDefaultComponent'); +function $get($injector,vnInterpolate){ + return { + getTemplate:function(name ,attr) { + this._frameworkName = 'Mdl'; + let _name = util.getFactoryName( name + this._frameworkName); + let defaultfactory = $injector.has(_name) ? $injector.get(_name) : undefined; + + if(!defaultfactory) { + throw new Error("factory is not defined"); + } + + let defaultValues = defaultfactory.default; + let template = defaultfactory.template; + let scope = Object.assign(defaultValues || {},attr||{}); + return template && vnInterpolate(template)(scope); + } + }; +} +$get.$inject = ['$injector', 'vnInterpolate']; + export class ResolveDefaultComponent { constructor() { this._frameworkName='Mdl'; @@ -12,26 +32,8 @@ export class ResolveDefaultComponent { set frameworkName(value) { this._frameworkName = value; } - $get($injector,vnInterpolate) { - return { - getTemplate:function(name ,attr) { - this._frameworkName = 'Mdl'; - let _name = util.getFactoryName( name + this._frameworkName); - let defaultfactory = $injector.has(_name) ? $injector.get(_name) : undefined; - - if(!defaultfactory) { - throw new Error("factory is not defined"); - } - - let defaultValues = defaultfactory.default; - let template = defaultfactory.template; - let scope = Object.assign(defaultValues || {},attr||{}); - return template && vnInterpolate(template)(scope); - } - }; - } } +ResolveDefaultComponent.prototype.$get = $get; var resolve = new ResolveDefaultComponent(); -resolve.$get.$inject = ['$injector', 'vnInterpolate']; _module.provider(NAME,() => resolve); \ No newline at end of file diff --git a/@salix/core/src/routesLoader.js b/@salix/core/src/routesLoader.js index 99c001786..4ea96e99d 100644 --- a/@salix/core/src/routesLoader.js +++ b/@salix/core/src/routesLoader.js @@ -4,28 +4,25 @@ import * as util from './util' export const NAME = util.getProviderName ('RoutesLoader') -export class RoutesLoader -{ - constructor () {} - - $get ($http) - { - let script = document.currentScript || (() => { +function $get($http){ + let script = document.currentScript || (() => { let scripts = document.getElementsByTagName ('script'); return scripts[scripts.length - 1]; }) (); let routesCdn = script.getAttribute ('routes-cdn'); - - return $http + return $http ({ method: 'GET', url: routesCdn }) - } } +$get.$inject = ["$http"]; + +export class RoutesLoader{ constructor () {} } + +RoutesLoader.prototype.$get = $get; var routes = new RoutesLoader (); -routes.$get.$inject = ['$http']; _module.provider (NAME, () => routes) diff --git a/@salix/core/src/snackbar/snackbar.js b/@salix/core/src/snackbar/snackbar.js index 3209b3671..b04571659 100644 --- a/@salix/core/src/snackbar/snackbar.js +++ b/@salix/core/src/snackbar/snackbar.js @@ -1,4 +1,4 @@ -import {module} from '../module'; +import {module as _module} from '../module'; import * as resolveFactory from '../resolveDefaultComponents'; import * as util from '../util'; @@ -15,4 +15,4 @@ export function directive (resolve){ } } -module.directive(NAME,directive); +_module.directive(NAME,directive); diff --git a/@salix/core/src/spinner/spinner.js b/@salix/core/src/spinner/spinner.js index b7bc987b2..03bbd9f5f 100644 --- a/@salix/core/src/spinner/spinner.js +++ b/@salix/core/src/spinner/spinner.js @@ -1,4 +1,4 @@ -import {module} from '../module'; +import {module as _module} from '../module'; import * as resolveFactory from '../resolveDefaultComponents'; import * as util from '../util'; @@ -15,4 +15,4 @@ export function directive (resolve){ } } -module.directive(NAME,directive); +_module.directive(NAME,directive); diff --git a/@salix/core/src/submit/submit.js b/@salix/core/src/submit/submit.js index 4f548ced9..a13771944 100644 --- a/@salix/core/src/submit/submit.js +++ b/@salix/core/src/submit/submit.js @@ -1,4 +1,4 @@ -import {module} from '../module'; +import {module as _module} from '../module'; import * as resolveFactory from '../resolveDefaultComponents'; import * as util from '../util'; @@ -15,4 +15,4 @@ export function directive (resolve){ } } -module.directive(NAME,directive); +_module.directive(NAME,directive); diff --git a/@salix/core/src/title/title.js b/@salix/core/src/title/title.js index 7cde9b468..8de6aad4d 100644 --- a/@salix/core/src/title/title.js +++ b/@salix/core/src/title/title.js @@ -1,9 +1,9 @@ import template from './title.html'; -import {module} from '../module'; +import {module as _module} from '../module'; export const NAME = "vnTitle"; export const COMPONENT = { template: template, transclude: true }; -module.component(NAME, COMPONENT); +_module.component(NAME, COMPONENT); diff --git a/@salix/crud/src/client/addresses/index.js b/@salix/crud/src/client/addresses/index.js index 35725150e..1770cd80c 100644 --- a/@salix/crud/src/client/addresses/index.js +++ b/@salix/crud/src/client/addresses/index.js @@ -5,12 +5,7 @@ export const NAME = 'vnClientAddresses'; export const COMPONENT = { template: template, controller: function ($http) - { -/* $http.get('/client/api/Addresses', this.model).then ( - (json) => { this.addresses = json.data; }, - (json) => console.error (json.data.error.message) - ); -*/ + { this.addresses = []; for (var i = 1; i <= 4; i++) @@ -27,5 +22,6 @@ export const COMPONENT = { }); }, }; + COMPONENT.controller.$inject = ['$http']; module.component(NAME, COMPONENT); diff --git a/@salix/crud/src/client/card/card.js b/@salix/crud/src/client/card/card.js index f11246d0e..180443dde 100644 --- a/@salix/crud/src/client/card/card.js +++ b/@salix/crud/src/client/card/card.js @@ -31,8 +31,6 @@ export const COMPONENT = { href: i.state }); }); - - } }; COMPONENT.controller.$inject = ['$http', '$stateParams']; diff --git a/@salix/webpack.config.js b/@salix/webpack.config.js index ee67c4f41..415185128 100644 --- a/@salix/webpack.config.js +++ b/@salix/webpack.config.js @@ -49,16 +49,16 @@ var config = { ] }, plugins: [], - devtool: 'source-map' + //devtool: 'source-map' }; -if (!devMode) { +//if (!devMode) { config.plugins.push ( new webpack.optimize.UglifyJsPlugin({ minimize: true, compress: { warnings: false } }) ); -} +//} module.exports = config; diff --git a/services/salix/client/index.ejs b/services/salix/client/index.ejs index 9881a4421..b26d25ee9 100644 --- a/services/salix/client/index.ejs +++ b/services/salix/client/index.ejs @@ -6,7 +6,7 @@ - +