diff --git a/Gruntfile.js b/Gruntfile.js index 6c6456d..8a28751 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -3,7 +3,7 @@ module.exports = function(grunt) { pkg: grunt.file.readJSON('package.json'), qunit: { - all: [ 'test/*.html' ] + all: [ 'test/index.html' ] }, watch: { @@ -13,7 +13,7 @@ module.exports = function(grunt) { uglify: { options: { - report: 'gzip', + compress: { warnings: false }, banner: '/*\n * JSFace Object Oriented Programming Library.\n * Copyright (c) Tan Nhu, http://lnkd.in/tnhu\n */\n' }, my_target: { @@ -42,4 +42,4 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-clean'); grunt.registerTask('default', [ 'clean', 'qunit', 'copy', 'uglify' ]); -}; \ No newline at end of file +}; diff --git a/dist/jsface.js b/dist/jsface.js index 63587f4..7c8c8be 100644 --- a/dist/jsface.js +++ b/dist/jsface.js @@ -95,15 +95,16 @@ parent = (api = parent, 0); // !api means there's no parent } + // TODO remove $statics, use $static instead var clazz, constructor, singleton, statics, key, bindTo, len, i = 0, p, - ignoredKeys = { constructor: 1, $singleton: 1, $statics: 1, prototype: 1, $super: 1, $superp: 1, main: 1, toString: 0 }, + ignoredKeys = { constructor: 1, $singleton: 1, $static:1, $statics: 1, prototype: 1, $super: 1, $superp: 1, main: 1, toString: 0 }, plugins = Class.plugins, rootParent, parentClass, Stub; api = (typeof api === "function" ? api() : api) || {}; // execute api if it's a function constructor = api.hasOwnProperty("constructor") ? api.constructor : 0; // hasOwnProperty is a must, constructor is special singleton = api.$singleton; - statics = api.$statics; + statics = api.$statics || api.$static; // add plugins' keys into ignoredKeys for (key in plugins) { ignoredKeys[key] = 1; } @@ -127,7 +128,7 @@ Stub.prototype = parentClass.prototype; Stub.prototype.constructor = Stub; - clazz.prototype = new Stub; + clazz.prototype = new Stub(); clazz.prototype.constructor = clazz; // restoring proper constructor for child class parentClass.prototype.constructor = parentClass; // restoring proper constructor for parent class } @@ -146,7 +147,7 @@ clazz[key] = p[key]; } } - if ( !singleton && i != 0) { + if ( !singleton && i !== 0) { for (key in p.prototype) { if ( !ignoredKeys[key]) { bindTo[key] = p.prototype[key]; @@ -241,4 +242,4 @@ context.jsface = jsface; jsface.noConflict = function() { context.Class = oldClass; }; // no conflict } -})(this, "object", "number", "length", Object.prototype.toString, [], 0); \ No newline at end of file +})(this, "object", "number", "length", Object.prototype.toString, [], 0); diff --git a/dist/jsface.min.js b/dist/jsface.min.js index 8f3632c..5ce139f 100644 --- a/dist/jsface.min.js +++ b/dist/jsface.min.js @@ -1,12 +1,5 @@ /* - * JSFace Object Oriented Programming Library - * https://github.com/tnhu/jsface - * - * Copyright (c) Tan Nhu - * Licensed under MIT license (https://github.com/tnhu/jsface/blob/master/LICENSE.txt) + * JSFace Object Oriented Programming Library. + * Copyright (c) Tan Nhu, http://lnkd.in/tnhu */ -(function(q,x,y,z,F,A,B,G,C,r){function D(a){return a&&typeof a===x&&!(typeof a.length===y&&!a.propertyIsEnumerable(z))&&a||null}function E(a){return a&&typeof a===x&&typeof a.length===y&&!a.propertyIsEnumerable(z)&&a||null}function u(a){return a&&"function"===typeof a&&a||null}function v(a){return u(a)&&a.prototype&&a===a.prototype.constructor&&a||null}function w(a,c,b){if(E(c))for(var e=c.length;0<=--e;)w(a,c[e],b);else{b=b||{constructor:1,$super:1,prototype:1,$superp:1};var e=v(a),k=v(c),d=a.prototype, -g,h;if(D(c)||e)for(g in c){h=g;var l=c[g],f=a;b&&b.hasOwnProperty(h)||(f[h]=l)}if(k)for(g in h=c.prototype,h){var l=g,f=h[g],n=a;b&&b.hasOwnProperty(l)||(n[l]=f)}e&&k&&w(d,c.prototype,b)}}function t(a,c){c||(a=(c=a,0));var b,e,k,d,g,h,l=0,f,n={constructor:1,$singleton:1,$statics:1,prototype:1,$super:1,$superp:1,main:1,toString:0},p=t.plugins,m;c=("function"===typeof c?c():c)||{};b=c.hasOwnProperty("constructor")?c.constructor:0;e=c.$singleton;k=c.$statics;for(d in p)n[d]=1;b=e?function(){}:b?b:function(){}; -h=(a=!a||a instanceof Array?a:[a])&&a.length;m=a[0];!e&&h&&((g=m.prototype&&m===m.prototype.constructor&&m)?(f=function(){},f.prototype=g.prototype,f.prototype.constructor=f,b.prototype=new f,b.prototype.constructor=b,g.prototype.constructor=g):b.prototype=m);for(g=e?b:b.prototype;l=0;)p(a,b[d],c);else{c=c||{constructor:1,$super:1,prototype:1,$superp:1};var e,f,g=n(a),h=n(b),i=a.prototype;if(k(b)||g)for(e in b)o(e,b[e],c,a,g,i);if(h){f=b.prototype;for(e in f)o(e,f[e],c,a,g,i)}g&&h&&p(i,b.prototype,c)}}function q(a,b){b||(b=a,a=0);var c,d,e,f,g,h,i,j,k,l,m,n=0,o={constructor:1,$singleton:1,$static:1,$statics:1,prototype:1,$super:1,$superp:1,main:1,toString:0},p=q.plugins;b=("function"==typeof b?b():b)||{},d=b.hasOwnProperty("constructor")?b.constructor:0,e=b.$singleton,f=b.$statics||b.$static;for(g in p)o[g]=1;for(c=e?function(){}:d?d:function(){},a=!a||a instanceof Array?a:[a],i=a&&a.length,k=a[0],!e&&i&&(l=k.prototype&&k===k.prototype.constructor&&k,l?(m=function(){},m.prototype=l.prototype,m.prototype.constructor=m,c.prototype=new m,c.prototype.constructor=c,l.prototype.constructor=l):c.prototype=k),h=e?c:c.prototype;i>n;){j=a[n++];for(g in j)o[g]||(c[g]=j[g]);if(!e&&0!==n)for(g in j.prototype)o[g]||(h[g]=j.prototype[g])}for(g in b)if(!o[g]){var r=b[g];r&&(r.get||r.set)?Object.defineProperty(h,g,r):h[g]=r}for(g in f)c[g]=f[g];j=a&&k||a,c.$super=j,c.$superp=j&&j.prototype||j;for(g in p)p[g](c,a,b);return"function"==typeof b.main&&b.main.call(c,c),c}q.plugins={$ready:function r(a,b,c,d){for(var e,h,i,j=c.$ready,k=b?b.length:0,l=k,n=k&&b[0].$super;k--;)for(h=0;g>h&&(i=f[h],e=b[k],e===i[0]&&(i[1].call(e,a,b,c),l--),l);h++);n&&r(a,[n],c,!0),!d&&m(j)&&(j.call(a,a,b,c),f.push([a,j]),g++)}},j={Class:q,extend:p,mapOrNil:k,arrayOrNil:l,functionOrNil:m,classOrNil:n},"undefined"!=typeof module&&module.exports?module.exports=j:(i=a.Class,a.Class=q,a.jsface=j,j.noConflict=function(){a.Class=i})}(this,"object","number","length",Object.prototype.toString,[],0); \ No newline at end of file diff --git a/dist/jsface.pointcut.min.js b/dist/jsface.pointcut.min.js index fb3aeff..64bdde1 100644 --- a/dist/jsface.pointcut.min.js +++ b/dist/jsface.pointcut.min.js @@ -1,8 +1,5 @@ /* - * JSFace Object Oriented Programming Library - Plug and Play pointcut plugin - * https://github.com/tnhu/jsface - * - * Copyright (c) Tan Nhu - * Licensed under MIT license (https://github.com/tnhu/jsface/blob/master/LICENSE.txt). + * JSFace Object Oriented Programming Library. + * Copyright (c) Tan Nhu, http://lnkd.in/tnhu */ -(function(k){function p(a,d,e,f){function b(){for(var a=b.___before_fns___,f=a.length,h=b.___after_fns___,d=h.length,e=b.___origin_fn___,l;f--;)if(l=a[f].apply(this,arguments),m(l)&&!0===l.$skip)return l.$data;for(a=e.apply(this,arguments);d--&&(l=h[d].apply(this,arguments),!m(l)||!0!==l.$skip););return a}if(a.___wrapper___===a)return a.___before_fns___.push(d),a.___after_fns___.push(e),a.___advisors___.push(f),a;t(b,a,0,!0);q(a)&&(b.prototype=a.prototype);b.___before_fns___=[d];b.___after_fns___=[e];b.___origin_fn___=a;b.___advisors___=[f];b.___wrapper___=b;b.$super=a.$super;b.$superp=a.$superp;return b}function n(a,d){var e,f,b;if(a&&a===a.___wrapper___)if(d){for(f=b=a.___advisors___.length;f--&&a.___advisors___[f]!==d;);if(0<=f){if(1===b)return n(a);a.___advisors___.splice(f,1);a.___before_fns___.splice(f,1);a.___after_fns___.splice(f,1)}}else e=a.___origin_fn___,delete a.___origin_fn___,delete a.___advisors___,delete a.___before_fns___,delete a.___after_fns___,delete a.___wrapper___;return e}function u(a,d,e,f,b,c){function k(d,e){var b,g;for(b in d)g=b/1==b?d[b]:b,"constructor"===g&&f?h=n(f,e):(a[g]&&(a[g]=n(a[g],e)),c[g]&&(c[g]=n(c[g],e)))}var h;if("remove"===d)if(e)k(e,e);else{h=f&&a===a.___wrapper___&&a.___origin_fn___;for(var g in c)c[g]=n(c[g])||c[g];for(g in a)a[g]=n(a[g])||a[g]}else if(null!==(e=/^remove /.exec(d)))d=d.replace(e,"").split(" "),k(d);else throw"Invalid params";return h||a}k=k.jsface||require("./jsface");var q=k.classOrNil,g=k.functionOrNil,t=k.extend,m=k.mapOrNil,r=function(){};k.pointcut=function(a,d,e){var f=q(a)||g(a),b=m(a),c=null!==/^remove ?/.exec(d),k=c&&e,h;if(!f&&!b||!m(d)&&!c)throw"Invalid params";e=f?a.prototype:a;if(c)return u(a,d,k,f,b,e);for(h in d){c=d[h];c=g(c)?{before:c}:c;f=m(c)&&!c.before?r:c.before;c=m(c)&&!c.after?r:c.after;k=!1;if(!g(f))throw"Invalid "+h+":before";if(!g(c))throw"Invalid "+h+":after";if(b)if(g(e[h]))e[h]=p(e[h],f,c,d);else throw"Non-function property named "+h+" on instance";else if("constructor"===h)a=p(a,f,c,d);else if(g(a[h])&&(a[h]=p(a[h],f,c,d),k=!0),g(e[h])&&(e[h]=p(e[h],f,c,d),k=!0),!k)throw"Non-function property named "+h+" on class";}return a};"undefined"!==typeof module&&module.exports&&(module.exports=k.pointcut)})(this); \ No newline at end of file +!function(a){function b(a,b,c,d){function e(){for(var a,b,c=e[k],d=c.length,f=e[l],g=f.length,h=e[m];d--;)if(b=c[d].apply(this,arguments),i(b)&&b.$skip===!0)return b.$data;for(a=h.apply(this,arguments);g--;)if(b=f[g].apply(this,arguments),i(b)&&b.$skip===!0)return a;return a}return a[j]===a?(a[k].push(b),a[l].push(c),a[n].push(d),a):(h(e,a,0,!0),f(a)&&(e.prototype=a.prototype),e[k]=[b],e[l]=[c],e[m]=a,e[n]=[d],e[j]=e,e.$super=a.$super,e.$superp=a.$superp,e)}function c(a,b){var d,e,f;if(a&&a===a[j])if(b){for(e=f=a[n].length;e--&&a[n][e]!==b;);if(e>=0){if(1===f)return c(a);a[n].splice(e,1),a[k].splice(e,1),a[l].splice(e,1)}}else d=a[m],delete a[m],delete a[n],delete a[k],delete a[l],delete a[j];return d}function d(a,b,d,e,f,g){function h(b,d){var f,h,j,k;for(f in b)h=f/1==f?b[f]:f,j="constructor"===h,k=e&&a[h],"constructor"===h&&e?i=c(e,d):(a[h]&&(a[h]=c(a[h],d)),g[h]&&(g[h]=c(g[h],d)))}var i,k,l;if("remove"===b)if(d)h(d,d);else{i=e&&a===a[j]&&a[m];for(var n in g)g[n]=c(g[n])||g[n];for(var n in a)a[n]=c(a[n])||a[n]}else{if(null===(k=/^remove /.exec(b)))throw"Invalid params";l=b.replace(k,"").split(" "),h(l)}return i||a}var e=a.jsface||require("./jsface"),f=(e.Class,e.classOrNil),g=e.functionOrNil,h=e.extend,i=e.mapOrNil,j="___wrapper___",k="___before_fns___",l="___after_fns___",m="___origin_fn___",n="___advisors___",o=function(){};e.pointcut=function(a,c){var e,h,j,k=f(a)||g(a),l=i(a),m=null!==/^remove ?/.exec(c),n=m&&arguments[2];if(!k&&!l||!i(c)&&!m)throw"Invalid params";if(e=k?a.prototype:a,m)return d(a,c,n,k,l,e);for(h in c){j=c[h],j=g(j)?{before:j}:j;var p=i(j)&&!j.before?o:j.before,q=i(j)&&!j.after?o:j.after,r=!1;if(!g(p))throw"Invalid "+h+":before";if(!g(q))throw"Invalid "+h+":after";if(l){if(!g(e[h]))throw"Non-function property named "+h+" on instance";e[h]=b(e[h],p,q,c)}else if("constructor"===h)a=b(a,p,q,c);else if(g(a[h])&&(a[h]=b(a[h],p,q,c),r=!0),g(e[h])&&(e[h]=b(e[h],p,q,c),r=!0),!r)throw"Non-function property named "+h+" on class"}return a},"undefined"!=typeof module&&module.exports&&(module.exports=e.pointcut)}(this); \ No newline at end of file