mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-22 12:49:55 +09:00
17223554 : xquared upgrade to 0.7
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@4968 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
5956e254e7
commit
7c3b336e41
59 changed files with 34562 additions and 8454 deletions
52
modules/editor/skins/xquared/javascripts/macro/Factory.js
Normal file
52
modules/editor/skins/xquared/javascripts/macro/Factory.js
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/**
|
||||
* @requires Xquared.js
|
||||
* @requires macro/Base.js
|
||||
*/
|
||||
xq.macro.Factory = xq.Class(/** @lends xq.macro.Factory.prototype */{
|
||||
/**
|
||||
* @constructs
|
||||
*
|
||||
* @param {String} URL to place holder image.
|
||||
*/
|
||||
initialize: function(placeHolderImgSrc) {
|
||||
this.placeHolderImgSrc = placeHolderImgSrc;
|
||||
this.macroClazzes = {};
|
||||
},
|
||||
/**
|
||||
* Registers new macro by ID.
|
||||
*
|
||||
* @param {String} id Macro id.
|
||||
*/
|
||||
register: function(id) {
|
||||
var clazz = xq.macro[id + "Macro"];
|
||||
if(!clazz) throw "Unknown macro id: [" + id + "]";
|
||||
|
||||
this.macroClazzes[id] = clazz;
|
||||
},
|
||||
/**
|
||||
* Creates macro instance by given HTML fragment.
|
||||
*
|
||||
* @param {String} html HTML fragment.
|
||||
* @returns {xq.macro.Base} Macro instance or null if recognization of the HTML fragment fails.
|
||||
*/
|
||||
createMacroFromHtml: function(html) {
|
||||
for(var id in this.macroClazzes) {
|
||||
var clazz = this.macroClazzes[id];
|
||||
if(clazz.recognize(html)) return new clazz(id, html, this.placeHolderImgSrc);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
/**
|
||||
* Creates macro instance by given macro definition.
|
||||
*
|
||||
* @param {Object} def Macro definition.
|
||||
* @returns {xq.macro.Base} Macro instance
|
||||
* @throws If macro not found by def[id].
|
||||
*/
|
||||
createMacroFromDefinition: function(def) {
|
||||
var clazz = this.macroClazzes[def.id];
|
||||
if(!clazz) return null;
|
||||
|
||||
return new clazz(def.id, def.params, this.placeHolderImgSrc);
|
||||
}
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue