inyeccion para minimificar

This commit is contained in:
nelo 2016-12-13 15:09:54 +01:00
parent 7fd675df34
commit 68b5c7aa8e
18 changed files with 89 additions and 94 deletions

View File

@ -14,5 +14,5 @@ export const bootstrap = () => {
throw new Error("element is not defined"); throw new Error("element is not defined");
} }
ng.bootstrap(_element, [SALIX]); ng.bootstrap(_element, [SALIX]);
}; };

View File

@ -3,9 +3,6 @@ import {module} from '../../module';
export const NAME = 'vnSearchbar' export const NAME = 'vnSearchbar'
export const COMPONENT = { export const COMPONENT = {
template: template, template: template
controller: function(){
}
}; };
module.component(NAME, COMPONENT); module.component(NAME, COMPONENT);

View File

@ -2,15 +2,18 @@ import * as core from 'core';
import * as spliting from './spliting'; import * as spliting from './spliting';
import * as deps from './spliting/deps.json'; import * as deps from './spliting/deps.json';
function loader(module) { function loader(module) {
return function ($ocLazyLoad, $q) { return function load($ocLazyLoad, $q){
return $q((resolve) => { return $q((resolve) => {
core.splitingRegister.execute(module).then(function (dependencies) { core.splitingRegister.execute(module).then(function (dependencies) {
var array = dependencies.map((item) => { return { name: item } }); var array = dependencies.map((item) => { return { name: item } });
resolve($ocLazyLoad.load(array)); resolve($ocLazyLoad.load(array));
}); });
}); });
};
}
load.$inject = ['$ocLazyLoad', '$q'];
} }
function getParams(route){ function getParams(route){
@ -48,7 +51,5 @@ function config($stateProvider, $urlRouterProvider) {
} }
} }
config.$inject = ['$stateProvider', '$urlRouterProvider']; config.$inject = ['$stateProvider', '$urlRouterProvider'];
core.module.config(config); core.module.config(config);

View File

@ -1,4 +1,4 @@
import {module} from '../module'; import {module as _module} from '../module';
import * as resolveFactory from '../resolveDefaultComponents'; import * as resolveFactory from '../resolveDefaultComponents';
import * as util from '../util'; import * as util from '../util';
@ -15,4 +15,4 @@ export function directive(resolve) {
} }
}; };
} }
module.directive(NAME, directive); _module.directive(NAME, directive);

View File

@ -1,4 +1,4 @@
import {module} from '../module'; import {module as _module} from '../module';
import * as resolveFactory from '../resolveDefaultComponents'; import * as resolveFactory from '../resolveDefaultComponents';
import * as util from '../util'; import * as util from '../util';
@ -14,4 +14,4 @@ export function directive(resolve) {
} }
}; };
} }
module.directive(NAME, directive); _module.directive(NAME, directive);

View File

@ -1,4 +1,4 @@
import {module} from '../module'; import {module as _module} from '../module';
import * as resolveFactory from '../resolveDefaultComponents'; import * as resolveFactory from '../resolveDefaultComponents';
import * as util from '../util'; import * as util from '../util';
@ -14,4 +14,4 @@ export function directive(resolve) {
} }
}; };
} }
module.directive(NAME, directive); _module.directive(NAME, directive);

View File

@ -36,32 +36,7 @@ $interpolateMinErr.interr = function (text, err) {
return $interpolateMinErr('interr', 'Can\'t interpolate: {0}\n{1}', text, err.toString()); return $interpolateMinErr('interr', 'Can\'t interpolate: {0}\n{1}', text, err.toString());
}; };
export class Interpolate function $get($parse, $exceptionHandler, $sce) {
{
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) {
var startSymbolLength = this._startSymbol.length, var startSymbolLength = this._startSymbol.length,
endSymbolLength = this._endSymbol.length, endSymbolLength = this._endSymbol.length,
escapedStartRegexp = new RegExp(this._startSymbol.replace(/./g, escape), 'g'), escapedStartRegexp = new RegExp(this._startSymbol.replace(/./g, escape), 'g'),
@ -195,8 +170,37 @@ export class Interpolate
return $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(); var interpolate = new Interpolate();
interpolate.$get.$inject = ['$parse', '$exceptionHandler', '$sce'];
module.provider(NAME, () => interpolate); module.provider(NAME, () => interpolate);

View File

@ -1,4 +1,4 @@
import {module} from '../module'; import {module as _module} from '../module';
import * as resolveFactory from '../resolveDefaultComponents'; import * as resolveFactory from '../resolveDefaultComponents';
import * as util from '../util'; import * as util from '../util';
@ -15,4 +15,4 @@ export function directive (resolve){
} }
} }
module.directive(NAME,directive); _module.directive(NAME,directive);

View File

@ -5,6 +5,26 @@ import Interpolate from './interpolate';
export const NAME = util.getProviderName('ResolveDefaultComponent'); 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 { export class ResolveDefaultComponent {
constructor() { constructor() {
this._frameworkName='Mdl'; this._frameworkName='Mdl';
@ -12,26 +32,8 @@ export class ResolveDefaultComponent {
set frameworkName(value) { set frameworkName(value) {
this._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(); var resolve = new ResolveDefaultComponent();
resolve.$get.$inject = ['$injector', 'vnInterpolate'];
_module.provider(NAME,() => resolve); _module.provider(NAME,() => resolve);

View File

@ -4,28 +4,25 @@ import * as util from './util'
export const NAME = util.getProviderName ('RoutesLoader') export const NAME = util.getProviderName ('RoutesLoader')
export class RoutesLoader function $get($http){
{ let script = document.currentScript || (() => {
constructor () {}
$get ($http)
{
let script = document.currentScript || (() => {
let scripts = document.getElementsByTagName ('script'); let scripts = document.getElementsByTagName ('script');
return scripts[scripts.length - 1]; return scripts[scripts.length - 1];
}) (); }) ();
let routesCdn = script.getAttribute ('routes-cdn'); let routesCdn = script.getAttribute ('routes-cdn');
return $http
return $http
({ ({
method: 'GET', method: 'GET',
url: routesCdn url: routesCdn
}) })
}
} }
$get.$inject = ["$http"];
export class RoutesLoader{ constructor () {} }
RoutesLoader.prototype.$get = $get;
var routes = new RoutesLoader (); var routes = new RoutesLoader ();
routes.$get.$inject = ['$http'];
_module.provider (NAME, () => routes) _module.provider (NAME, () => routes)

View File

@ -1,4 +1,4 @@
import {module} from '../module'; import {module as _module} from '../module';
import * as resolveFactory from '../resolveDefaultComponents'; import * as resolveFactory from '../resolveDefaultComponents';
import * as util from '../util'; import * as util from '../util';
@ -15,4 +15,4 @@ export function directive (resolve){
} }
} }
module.directive(NAME,directive); _module.directive(NAME,directive);

View File

@ -1,4 +1,4 @@
import {module} from '../module'; import {module as _module} from '../module';
import * as resolveFactory from '../resolveDefaultComponents'; import * as resolveFactory from '../resolveDefaultComponents';
import * as util from '../util'; import * as util from '../util';
@ -15,4 +15,4 @@ export function directive (resolve){
} }
} }
module.directive(NAME,directive); _module.directive(NAME,directive);

View File

@ -1,4 +1,4 @@
import {module} from '../module'; import {module as _module} from '../module';
import * as resolveFactory from '../resolveDefaultComponents'; import * as resolveFactory from '../resolveDefaultComponents';
import * as util from '../util'; import * as util from '../util';
@ -15,4 +15,4 @@ export function directive (resolve){
} }
} }
module.directive(NAME,directive); _module.directive(NAME,directive);

View File

@ -1,9 +1,9 @@
import template from './title.html'; import template from './title.html';
import {module} from '../module'; import {module as _module} from '../module';
export const NAME = "vnTitle"; export const NAME = "vnTitle";
export const COMPONENT = { export const COMPONENT = {
template: template, template: template,
transclude: true transclude: true
}; };
module.component(NAME, COMPONENT); _module.component(NAME, COMPONENT);

View File

@ -5,12 +5,7 @@ export const NAME = 'vnClientAddresses';
export const COMPONENT = { export const COMPONENT = {
template: template, template: template,
controller: function ($http) 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 = []; this.addresses = [];
for (var i = 1; i <= 4; i++) for (var i = 1; i <= 4; i++)
@ -27,5 +22,6 @@ export const COMPONENT = {
}); });
}, },
}; };
COMPONENT.controller.$inject = ['$http']; COMPONENT.controller.$inject = ['$http'];
module.component(NAME, COMPONENT); module.component(NAME, COMPONENT);

View File

@ -31,8 +31,6 @@ export const COMPONENT = {
href: i.state href: i.state
}); });
}); });
} }
}; };
COMPONENT.controller.$inject = ['$http', '$stateParams']; COMPONENT.controller.$inject = ['$http', '$stateParams'];

View File

@ -49,16 +49,16 @@ var config = {
] ]
}, },
plugins: [], plugins: [],
devtool: 'source-map' //devtool: 'source-map'
}; };
if (!devMode) { //if (!devMode) {
config.plugins.push ( config.plugins.push (
new webpack.optimize.UglifyJsPlugin({ new webpack.optimize.UglifyJsPlugin({
minimize: true, minimize: true,
compress: { warnings: false } compress: { warnings: false }
}) })
); );
} //}
module.exports = config; module.exports = config;

View File

@ -6,7 +6,7 @@
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head> </head>
<body> <body>
<vn-vertical id="app" class="full-height"> <vn-vertical id="app" class="full-height" >
<vn-main-menu></vn-main-menu> <vn-main-menu></vn-main-menu>
<vn-vertical ui-view scrollable></vn-vertical> <vn-vertical ui-view scrollable></vn-vertical>
</vn-vertical> </vn-vertical>