Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasJang committed Jul 30, 2016
1 parent 86ef796 commit 7112ebd
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 52 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ax5core",
"version": "1.0.8",
"version": "1.0.9",
"authors": [
"ThomasJ <[email protected]>"
],
Expand Down
45 changes: 29 additions & 16 deletions dist/ax5core.js
Original file line number Diff line number Diff line change
Expand Up @@ -2259,7 +2259,6 @@ ax5.info.errorMsg["ax5combobox"] = {
/**
* @class ax5.ui.root
* @classdesc ax5 ui class
* @version v0.1.0
* @author [email protected]
* @example
* ```
Expand Down Expand Up @@ -2323,12 +2322,19 @@ ax5.ui = function () {
this.main = function () {}.apply(this, arguments);
}

var addUI = function addUI(key, version, cls) {
/*
if (ax5.ui.root) ax5.ui.root.call(this); // 부모호출
if (ax5.util.isFunction(ax5.ui.root)) cls.prototype = new ax5.ui.root(); // 상속
ax5.ui[key] = cls;
*/
/**
* @method ax5.ui.addClass
* @param {Object} config
* @param {String} config.className - name of Class
* @param {String} [config.version=""] - version of Class
* @param {Object} [config.classStore=ax5.ui] - 클래스가 저장될 경로
* @param {Function} [config.superClass=ax5.ui.root]
* @param {Function} cls - Class Function
*/
function addClass(config, cls) {
if (!config || !config.className) throw 'invalid call';
var classStore = config.classStore ? config.classStore : ax5.ui;
if (!classStore) throw 'invalid classStore';

var factory = function factory(cls, arg) {
switch (arg.length) {
Expand All @@ -2341,28 +2347,35 @@ ax5.ui = function () {
case 2:
return new cls(arg[0], arg[1]);
break;
case 3:
return new cls(arg[0], arg[1], arg[2]);
break;
}
};
var initInstance = function initInstance(instance) {
instance.a = "";
var initInstance = function initInstance(name, version, instance) {
instance.name = name;
instance.version = version;
instance.instanceId = ax5.getGuid();
return instance;
};
var initPrototype = function initPrototype(cls) {
var fn = cls.prototype;
var superClass = config.superClass ? config.superClass : ax5.ui.root;
if (!ax5.util.isFunction(superClass)) throw 'invalid superClass';
superClass.call(this); // 부모호출
cls.prototype = new superClass(); // 상속
};

var wrapper = function wrapper() {
if (!this || !(this instanceof wrapper)) throw 'invalid call';
var instance = factory(cls, arguments);
return initInstance(instance);
return initInstance(config.className, config.version || "", instance);
};
initPrototype(cls);
ax5.ui[key] = wrapper;
};
initPrototype.call(this, cls);
classStore[config.className] = wrapper;
}

return {
root: axUi,
addUI: addUI
addClass: addClass
};
}();
/*!
Expand Down
2 changes: 1 addition & 1 deletion dist/ax5core.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ax5core",
"version": "1.0.8",
"version": "1.0.9",
"description": "`ax5core` is a collection of utility functions that have been designed for use in ax5ui",
"license": "LGPLv3",
"repository": {
Expand Down
47 changes: 29 additions & 18 deletions src/ax5-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
/**
* @class ax5.ui.root
* @classdesc ax5 ui class
* @version v0.1.0
* @author [email protected]
* @example
* ```
Expand Down Expand Up @@ -72,13 +71,19 @@ ax5.ui = (function () {
}).apply(this, arguments);
}


var addUI = function (key, version, cls) {
/*
if (ax5.ui.root) ax5.ui.root.call(this); // 부모호출
if (ax5.util.isFunction(ax5.ui.root)) cls.prototype = new ax5.ui.root(); // 상속
ax5.ui[key] = cls;
*/
/**
* @method ax5.ui.addClass
* @param {Object} config
* @param {String} config.className - name of Class
* @param {String} [config.version=""] - version of Class
* @param {Object} [config.classStore=ax5.ui] - 클래스가 저장될 경로
* @param {Function} [config.superClass=ax5.ui.root]
* @param {Function} cls - Class Function
*/
function addClass(config, cls) {
if (!config || !config.className) throw 'invalid call';
var classStore = (config.classStore) ? config.classStore : ax5.ui;
if (!classStore) throw 'invalid classStore';

var factory = function (cls, arg) {
switch (arg.length) {
Expand All @@ -91,28 +96,34 @@ ax5.ui = (function () {
case 2:
return new cls(arg[0], arg[1]);
break;
case 3:
return new cls(arg[0], arg[1], arg[2]);
break;
}
};
var initInstance = function (instance) {
instance.a = "";
var initInstance = function (name, version, instance) {
instance.name = name;
instance.version = version;
instance.instanceId = ax5.getGuid();
return instance;
};
var initPrototype = function (cls) {
var fn = cls.prototype;

var superClass = (config.superClass) ? config.superClass : ax5.ui.root;
if (!ax5.util.isFunction(superClass)) throw 'invalid superClass';
superClass.call(this); // 부모호출
cls.prototype = new superClass(); // 상속
};

var wrapper = function () {
if (!this || !(this instanceof wrapper)) throw 'invalid call';
var instance = factory(cls, arguments);
return initInstance(instance);
return initInstance(config.className, config.version || "", instance);
};
initPrototype(cls);
ax5.ui[key] = wrapper;
};
initPrototype.call(this, cls);
classStore[config.className] = wrapper;
}

return {
root: axUi,
addUI: addUI
addClass: addClass
}
})();
33 changes: 18 additions & 15 deletions test/addUI-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,38 @@
(function () {
var UI = ax5.ui;
var U = ax5.util;
var CLASS_NAME = "testClass";
var VERSION = "0.0.1";

UI.addUI(CLASS_NAME, VERSION, (function () {
UI.addClass({
className: "testClass",
version: "0.0.1"
}, (function () {

var testClass = function () {
var
self = this,
cfg,
selectableCount = 1
;

this.name = CLASS_NAME;
this.version = VERSION;
this.instanceId = ax5.getGuid();
var self = this,
cfg;

this.config = {};
cfg = this.config;

this.sampleMethod = function(){
this.sampleMethod = function () {

};

// 클래스 생성자
// 클래스 생성자
this.main = (function () {

if (arguments && U.isObject(arguments[0])) {
this.setConfig(arguments[0]);
}
}).apply(this, arguments);

};
return testClass;
})());

})());
})();

var myUI = new ax5.ui.testClass();
console.log(myUI);

Expand Down

0 comments on commit 7112ebd

Please sign in to comment.