[pLog-svn] r7099 - plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource
mark at devel.lifetype.net
mark at devel.lifetype.net
Tue Dec 21 12:37:54 EST 2010
Author: mark
Date: 2010-12-21 12:37:54 -0500 (Tue, 21 Dec 2010)
New Revision: 7099
Modified:
plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/editor_plugin.js
plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/editor_plugin_src.js
Log:
Rename some functions to make the code more clear
Modified: plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/editor_plugin.js
===================================================================
--- plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/editor_plugin.js 2010-12-21 17:37:19 UTC (rev 7098)
+++ plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/editor_plugin.js 2010-12-21 17:37:54 UTC (rev 7099)
@@ -1,4 +1,4 @@
-(function(){tinymce.PluginManager.requireLangPack('insertresource');tinymce.create('tinymce.plugins.InsertResourcePlugin',{init:function(ed,url){var t=this;t.ed=ed;t.url=url;ed.onBeforeSetContent.add(function(ed,o){o.content=t._edit2html(t,o.content);});ed.onPostProcess.add(function(ed,o){if(o.set){o.content=t._edit2html(t,o.content);}
-if(o.get){o.content=t._html2edit(t,o.content);}});ed.addCommand('mceInsertResource',function(){ed.windowManager.open({file:url+'../../../../../admin.php?op=resourceList&mode=1',width:500+parseInt(ed.getLang('InsertResource.delta_width',0)),height:450+parseInt(ed.getLang('InsertResource.delta_height',0)),inline:1},{plugin_url:url,});});ed.addButton('insertresource',{title:'insertresource.desc',cmd:'mceInsertResource',image:url+'/img/insertresource.gif'});ed.onInit.add(function(){if(ed.settings.content_css!==false)
-ed.dom.loadCSS(url+"/css/content.css");});},getInfo:function(){return{longname:'Insert Resource',author:'LifeType Team',authorurl:'http://www.lifetype.net',infourl:'http://www.lifetype.net',version:tinymce.majorVersion+"."+tinymce.minorVersion};},_edit2html:function(t,content){cdom=t.ed.dom.create('div');t.ed.dom.setHTML(cdom,content);elems=t.ed.dom.select('object[class=ltPlayer]',cdom);tinymce.each(elems,function(e){html=e.innerHTML;result=html.match(/.*file=([a-zA-Z0-9\-\/:._%]*)/i);src=(result?result[1]:0);if(src){height=(e.height?e.height:20);width=(e.width?e.width:320);imgHTML=t._createImg(src,height,width);t.ed.dom.setOuterHTML(e,imgHTML);}});content=cdom.innerHTML;t.ed.dom.remove(cdom);return content;},_html2edit:function(t,content){cdom=t.ed.dom.create('div');t.ed.dom.setHTML(cdom,content);elems=t.ed.dom.select('img[class=ltFlashPlayer]',cdom);tinymce.each(elems,function(e){if(e.alt){height=(e.height?e.height:20);width=(e.width?e.width:320);src=e.alt;embedHTML=getFla
shPlayerHTML(src,height,width);t.ed.dom.setOuterHTML(e,embedHTML);}});content=cdom.innerHTML;t.ed.dom.remove(cdom);return content;},_createImg:function(src,height,width){imgHTML='<img width="'+width+'" height="'+height+'"';imgHTML+=' src="'+this.url+'/img/spacer.gif'+'" title="'+src+'"';imgHTML+=' alt="'+src+'" class="ltFlashPlayer" />';return imgHTML;}});tinymce.PluginManager.add('insertresource',tinymce.plugins.InsertResourcePlugin);})();
\ No newline at end of file
+(function(){tinymce.PluginManager.requireLangPack('insertresource');tinymce.create('tinymce.plugins.InsertResourcePlugin',{init:function(ed,url){var t=this;t.ed=ed;t.url=url;ed.onBeforeSetContent.add(function(ed,o){o.content=t._insertToEditor(t,o.content);});ed.onPostProcess.add(function(ed,o){if(o.set){o.content=t._insertToEditor(t,o.content);}
+if(o.get){o.content=t._getFromEditor(t,o.content);}});ed.addCommand('mceInsertResource',function(){ed.windowManager.open({file:url+'../../../../../admin.php?op=resourceList&mode=1',width:500,height:450,inline:1},{plugin_url:url});});ed.addButton('insertresource',{title:'insertresource.desc',cmd:'mceInsertResource',image:url+'/img/insertresource.gif'});ed.onInit.add(function(){if(ed.settings.content_css!==false)
+ed.dom.loadCSS(url+"/css/content.css");});},getInfo:function(){return{longname:'Insert Resource',author:'LifeType Team',authorurl:'http://www.lifetype.net',infourl:'http://www.lifetype.net',version:tinymce.majorVersion+"."+tinymce.minorVersion};},_insertToEditor:function(t,content){cdom=t.ed.dom.create('div');t.ed.dom.setHTML(cdom,content);elems=t.ed.dom.select('object[class=ltPlayer]',cdom);tinymce.each(elems,function(e){html=e.innerHTML;result=html.match(/.*file=([a-zA-Z0-9\-\/:._%]*)/i);src=(result?result[1]:0);if(src){height=(e.height?e.height:20);width=(e.width?e.width:320);imgHTML=t._getImgPlayerHTML(src,height,width);t.ed.dom.setOuterHTML(e,imgHTML);}});content=cdom.innerHTML;t.ed.dom.remove(cdom);return content;},_getFromEditor:function(t,content){cdom=t.ed.dom.create('div');t.ed.dom.setHTML(cdom,content);elems=t.ed.dom.select('img[class=ltFlashPlayer]',cdom);tinymce.each(elems,function(e){src=e.alt;if(src){height=(e.height?e.height:20);width=(e.width?e.width:320);em
bedHTML=getFlashPlayerHTML(src,height,width);t.ed.dom.setOuterHTML(e,embedHTML);}});content=cdom.innerHTML;t.ed.dom.remove(cdom);return content;},_getImgPlayerHTML:function(src,height,width){html='<img width="'+width+'" height="'+height+'"'+' src="'+this.url+'/img/spacer.gif'+'" title="'+src+'"'+' alt="'+src+'" class="ltFlashPlayer" />';return html;}});tinymce.PluginManager.add('insertresource',tinymce.plugins.InsertResourcePlugin);})();
\ No newline at end of file
Modified: plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/editor_plugin_src.js
===================================================================
--- plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/editor_plugin_src.js 2010-12-21 17:37:19 UTC (rev 7098)
+++ plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/editor_plugin_src.js 2010-12-21 17:37:54 UTC (rev 7099)
@@ -14,26 +14,26 @@
t.url = url;
ed.onBeforeSetContent.add(function(ed, o) {
- o.content = t._edit2html(t, o.content);
+ o.content = t._insertToEditor(t, o.content);
});
ed.onPostProcess.add(function(ed, o) {
if (o.set){
- o.content = t._edit2html(t, o.content);
+ o.content = t._insertToEditor(t, o.content);
}
if (o.get){
- o.content = t._html2edit(t, o.content);
+ o.content = t._getFromEditor(t, o.content);
}
});
ed.addCommand('mceInsertResource', function() {
ed.windowManager.open({
file : url + '../../../../../admin.php?op=resourceList&mode=1', // Relative to theme
- width : 500 + parseInt(ed.getLang('InsertResource.delta_width', 0)),
- height : 450 + parseInt(ed.getLang('InsertResource.delta_height', 0)),
+ width : 500,
+ height : 450,
inline : 1
}, {
- plugin_url : url, // Plugin absolute URL
+ plugin_url : url
});
});
@@ -50,12 +50,6 @@
});
},
- /**
- * Returns information about the plugin as a name/value array.
- * The current keys are longname, author, authorurl, infourl and version.
- *
- * @return {Object} Name/value array containing information about the plugin.
- */
getInfo : function() {
return {
longname : 'Insert Resource',
@@ -66,7 +60,7 @@
};
},
- _edit2html : function(t,content){
+ _insertToEditor : function(t,content){
// Parse all object[class=ltPlayer] tags and replace them with img
cdom = t.ed.dom.create('div');
t.ed.dom.setHTML(cdom, content);
@@ -79,7 +73,7 @@
if (src) {
height = (e.height? e.height : 20);
width = (e.width ? e.width : 320);
- imgHTML = t._createImg(src, height, width);
+ imgHTML = t._getImgPlayerHTML(src, height, width);
t.ed.dom.setOuterHTML(e, imgHTML);
}
});
@@ -90,17 +84,17 @@
return content;
},
- _html2edit : function(t, content) {
+ _getFromEditor : function(t, content) {
// Parse all img[class=ltFlashPlayer] tags and replace them with object+embed
cdom = t.ed.dom.create('div');
t.ed.dom.setHTML(cdom, content);
elems = t.ed.dom.select('img[class=ltFlashPlayer]', cdom);
tinymce.each(elems, function(e) {
- if (e.alt) {
+ src = e.alt;
+ if (src) {
height = (e.height? e.height : 20);
width = (e.width ? e.width : 320);
- src = e.alt;
embedHTML = getFlashPlayerHTML(src, height, width);
t.ed.dom.setOuterHTML(e, embedHTML);
}
@@ -112,12 +106,12 @@
return content;
},
- _createImg : function(src, height, width) {
- imgHTML = '<img width="' + width + '" height="' + height + '"';
- imgHTML += ' src="' + this.url + '/img/spacer.gif' + '" title="' + src + '"';
- imgHTML += ' alt="' + src + '" class="ltFlashPlayer" />';
+ _getImgPlayerHTML : function(src, height, width) {
+ html = '<img width="' + width + '" height="' + height + '"' +
+ ' src="' + this.url + '/img/spacer.gif' + '" title="' + src + '"' +
+ ' alt="' + src + '" class="ltFlashPlayer" />';
- return imgHTML;
+ return html;
}
});
// Register plugin
More information about the pLog-svn
mailing list