mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-20 11:49:56 +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
55
modules/editor/skins/xquared/javascripts/macro/Base.js
Normal file
55
modules/editor/skins/xquared/javascripts/macro/Base.js
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/**
|
||||
* @namespace
|
||||
*/
|
||||
xq.macro = {};
|
||||
|
||||
/**
|
||||
* @requires Xquared.js
|
||||
*/
|
||||
xq.macro.Base = xq.Class(/** @lends xq.macro.Base.prototype */{
|
||||
/**
|
||||
* @constructs
|
||||
*
|
||||
* @param {Object} Parameters or HTML fragment.
|
||||
* @param {String} URL to place holder image.
|
||||
*/
|
||||
initialize: function(id, paramsOrHtml, placeHolderImgSrc) {
|
||||
this.id = id;
|
||||
this.placeHolderImgSrc = placeHolderImgSrc;
|
||||
|
||||
if(typeof paramsOrHtml === "string") {
|
||||
this.html = paramsOrHtml;
|
||||
this.params = {};
|
||||
|
||||
this.initFromHtml();
|
||||
} else {
|
||||
this.html = null;
|
||||
this.params = paramsOrHtml;
|
||||
|
||||
this.initFromParams();
|
||||
}
|
||||
},
|
||||
|
||||
initFromHtml: function() {},
|
||||
initFromParams: function() {},
|
||||
createHtml: function() {throw "Not implemented";},
|
||||
onLayerInitialzied: function(layer) {},
|
||||
|
||||
createPlaceHolderHtml: function() {
|
||||
var size = {width: 5, height: 5};
|
||||
var def = {};
|
||||
def.id = this.id;
|
||||
def.params = this.params;
|
||||
|
||||
sb = [];
|
||||
sb.push('<img ');
|
||||
sb.push( 'class="xqlayer" ');
|
||||
sb.push( 'src="' + this.placeHolderImgSrc + '" ');
|
||||
sb.push( 'width="' + (size.width + 4) + '" height="' + (size.height + 4) + '" ');
|
||||
sb.push( 'longdesc="' + escape(JSON.stringify(def)) + '" ');
|
||||
sb.push( 'style="border: 1px solid #ccc" ');
|
||||
sb.push('/>');
|
||||
|
||||
return sb.join('');
|
||||
}
|
||||
})
|
||||
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);
|
||||
}
|
||||
})
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
/**
|
||||
* @requires macro/Base.js
|
||||
*/
|
||||
xq.macro.FlashMovieMacro = xq.Class(xq.macro.Base,
|
||||
/**
|
||||
* Flash movie macro
|
||||
*
|
||||
* @name xq.macro.FlashMovieMacro
|
||||
* @lends xq.macro.FlashMovieMacro.prototype
|
||||
* @extends xq.macro.Base
|
||||
* @constructor
|
||||
*/
|
||||
{
|
||||
initFromHtml: function() {
|
||||
this.params.html = this.html;
|
||||
},
|
||||
initFromParams: function() {
|
||||
if(!xq.macro.FlashMovieMacro.recognize(this.params.html)) throw "Unknown src";
|
||||
},
|
||||
createHtml: function() {
|
||||
return this.params.html;
|
||||
}
|
||||
});
|
||||
xq.macro.FlashMovieMacro.recognize = function(html) {
|
||||
var providers = {
|
||||
tvpot: /http:\/\/flvs\.daum\.net\/flvPlayer\.swf\?/,
|
||||
youtube: /http:\/\/(?:www\.)?youtube\.com\/v\//,
|
||||
pandoratv: /http:\/\/flvr\.pandora\.tv\/flv2pan\/flvmovie\.dll\?/,
|
||||
pandoratv2: /http:\/\/imgcdn\.pandora\.tv\/gplayer\/pandora\_EGplayer\.swf\?/,
|
||||
mncast: /http:\/\/dory\.mncast\.com\/mncHMovie\.swf\?/,
|
||||
yahoo: /http:\/\/d\.yimg\.com\//
|
||||
};
|
||||
|
||||
for(var id in providers) {
|
||||
if(html.match(providers[id])) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
/**
|
||||
* @requires macro/Base.js
|
||||
*/
|
||||
xq.macro.IFrameMacro = xq.Class(xq.macro.Base,
|
||||
/**
|
||||
* IFrame macro
|
||||
*
|
||||
* @name xq.macro.IFrameMacro
|
||||
* @lends xq.macro.IFrameMacro.prototype
|
||||
* @extends xq.macro.Base
|
||||
* @constructor
|
||||
*/
|
||||
{
|
||||
initFromHtml: function() {
|
||||
this.params.html = this.html;
|
||||
},
|
||||
initFromParams: function() {
|
||||
if(this.params.html) return;
|
||||
|
||||
var sb = [];
|
||||
sb.push('<iframe');
|
||||
for(var attrName in this.params) {
|
||||
var attrValue = this.params[attrName];
|
||||
if(attrValue) sb.push(' ' + attrName.substring("p_".length) + '="' + attrValue + '"');
|
||||
}
|
||||
sb.push('></iframe>');
|
||||
this.params = {html:sb.join("")};
|
||||
},
|
||||
createHtml: function() {
|
||||
return this.params.html;
|
||||
}
|
||||
});
|
||||
xq.macro.IFrameMacro.recognize = function(html) {
|
||||
var p = xq.compilePattern("<IFRAME\\s+[^>]+(?:/>|>.*?</(?:IFRAME)>)", "img");
|
||||
return !!html.match(p);
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
* @requires macro/Base.js
|
||||
*/
|
||||
xq.macro.JavascriptMacro = xq.Class(xq.macro.Base,
|
||||
/**
|
||||
* Javascript macro
|
||||
*
|
||||
* @name xq.macro.JavascriptMacro
|
||||
* @lends xq.macro.JavascriptMacro.prototype
|
||||
* @extends xq.macro.Base
|
||||
* @constructor
|
||||
*/
|
||||
{
|
||||
initFromHtml: function() {
|
||||
var p = xq.compilePattern("src=[\"'](.+?)[\"']", "img");
|
||||
this.params.url = p.exec(this.html)[1];
|
||||
},
|
||||
initFromParams: function() {
|
||||
if(!xq.macro.JavascriptMacro.isSafeScript(this.params.url)) throw "Unknown src";
|
||||
},
|
||||
createHtml: function() {return '<script type="text/javascript" src="' + this.params.url + '"></script>'},
|
||||
|
||||
onLayerInitialzied: function(layer) {
|
||||
layer.getDoc().write(this.createHtml());
|
||||
}
|
||||
});
|
||||
|
||||
xq.macro.JavascriptMacro.recognize = function(html) {
|
||||
var p = xq.compilePattern("<SCRIPT\\s+[^>]*src=[\"']([^\"']+)[\"'][^>]*(?:/>|>.*?</(?:SCRIPT)>)", "img");
|
||||
var m = p.exec(html);
|
||||
if(!m || !m[1]) return false;
|
||||
return this.isSafeScript(m[1]);
|
||||
}
|
||||
xq.macro.JavascriptMacro.isSafeScript = function(url) {
|
||||
var safeSrcs = {
|
||||
googleGadget: /http:\/\/gmodules\.com\/ig\/ifr\?/img
|
||||
};
|
||||
for(var id in safeSrcs) {
|
||||
if(url.match(safeSrcs[id])) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue