Index: openacs-4/packages/acs-templating/www/resources/tinymce/jscripts/tiny_mce/plugins/fullpage/editor_plugin_src.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/tinymce/jscripts/tiny_mce/plugins/fullpage/editor_plugin_src.js,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-templating/www/resources/tinymce/jscripts/tiny_mce/plugins/fullpage/editor_plugin_src.js 25 Jan 2008 21:44:01 -0000 1.1 +++ openacs-4/packages/acs-templating/www/resources/tinymce/jscripts/tiny_mce/plugins/fullpage/editor_plugin_src.js 8 May 2009 18:18:33 -0000 1.2 @@ -2,234 +2,145 @@ * $Id$ * * @author Moxiecode - * @copyright Copyright � 2004-2007, Moxiecode Systems AB, All rights reserved. + * @copyright Copyright � 2004-2008, Moxiecode Systems AB, All rights reserved. */ -/* Import plugin specific language pack */ -tinyMCE.importPluginLanguagePack('fullpage'); +(function() { + tinymce.create('tinymce.plugins.FullPagePlugin', { + init : function(ed, url) { + var t = this; -var TinyMCE_FullPagePlugin = { - getInfo : function() { - return { - longname : 'Fullpage', - author : 'Moxiecode Systems AB', - authorurl : 'http://tinymce.moxiecode.com', - infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/fullpage', - version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion - }; - }, + t.editor = ed; - getControlHTML : function(cn) { - switch (cn) { - case "fullpage": - return tinyMCE.getButtonHTML(cn, 'lang_fullpage_desc', '{$pluginurl}/images/fullpage.gif', 'mceFullPageProperties'); - } + // Register commands + ed.addCommand('mceFullPageProperties', function() { + ed.windowManager.open({ + file : url + '/fullpage.htm', + width : 430 + parseInt(ed.getLang('fullpage.delta_width', 0)), + height : 495 + parseInt(ed.getLang('fullpage.delta_height', 0)), + inline : 1 + }, { + plugin_url : url, + head_html : t.head + }); + }); - return ""; - }, + // Register buttons + ed.addButton('fullpage', {title : 'fullpage.desc', cmd : 'mceFullPageProperties'}); - execCommand : function(editor_id, element, command, user_interface, value) { - // Handle commands - switch (command) { - case "mceFullPageProperties": - var template = new Array(); + ed.onBeforeSetContent.add(t._setContent, t); + ed.onSetContent.add(t._setBodyAttribs, t); + ed.onGetContent.add(t._getContent, t); + }, - template['file'] = '../../plugins/fullpage/fullpage.htm'; - template['width'] = 430; - template['height'] = 485 + (tinyMCE.isOpera ? 5 : 0); + getInfo : function() { + return { + longname : 'Fullpage', + author : 'Moxiecode Systems AB', + authorurl : 'http://tinymce.moxiecode.com', + infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/fullpage', + version : tinymce.majorVersion + "." + tinymce.minorVersion + }; + }, - template['width'] += tinyMCE.getLang('lang_fullpage_delta_width', 0); - template['height'] += tinyMCE.getLang('lang_fullpage_delta_height', 0); + // Private plugin internal methods - tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"}); - return true; + _setBodyAttribs : function(ed, o) { + var bdattr, i, len, kv, k, v, t, attr = this.head.match(/body(.*?)>/i); - case "mceFullPageUpdate": - TinyMCE_FullPagePlugin._addToHead(tinyMCE.getInstanceById(editor_id)); - return true; - } + if (attr && attr[1]) { + bdattr = attr[1].match(/\s*(\w+\s*=\s*".*?"|\w+\s*=\s*'.*?'|\w+\s*=\s*\w+|\w+)\s*/g); - // Pass to next handler in chain - return false; - }, + if (bdattr) { + for(i = 0, len = bdattr.length; i < len; i++) { + kv = bdattr[i].split('='); + k = kv[0].replace(/\s/,''); + v = kv[1]; - cleanup : function(type, content, inst) { - switch (type) { - case "insert_to_editor": - var tmp = content.toLowerCase(); - var pos = tmp.indexOf('', pos); - pos2 = tmp.lastIndexOf(''); - inst.fullpageTopContent = content.substring(0, pos + 1); - content = content.substring(pos + 1, pos2); - // tinyMCE.debug(inst.fullpageTopContent, content); - } else { - if (!inst.fullpageTopContent) { - var docType = tinyMCE.getParam("fullpage_default_doctype", ''); - var enc = tinyMCE.getParam("fullpage_default_encoding", 'utf-8'); - var title = tinyMCE.getParam("fullpage_default_title", 'Untitled document'); - var lang = tinyMCE.getParam("fullpage_default_langcode", 'en'); - var pi = tinyMCE.getParam("fullpage_default_xml_pi", true); - var ff = tinyMCE.getParam("fullpage_default_font_family", ""); - var fz = tinyMCE.getParam("fullpage_default_font_size", ""); - var ds = tinyMCE.getParam("fullpage_default_style", ""); - var dtc = tinyMCE.getParam("fullpage_default_text_color", ""); + if (t) + v = t[1]; + } else + v = k; - // Xml encode it - title = title.replace(/&/g, '&'); - title = title.replace(/\"/g, '"'); - title = title.replace(//g, '>'); - - tmp = ''; - - // Make default chunk - if (pi) - tmp += '\n'; - - tmp += docType + '\n'; - tmp += '\n'; - tmp += '\n'; - tmp += '\t' + title + '\n'; - tmp += '\t\n'; - tmp += '\n'; - tmp += ']+(\s|\>)/i, ''); // Remove internal stuff - content = inst.fullpageTopContent + content + "\n\n"; - } + if (o.source_view && ed.getParam('fullpage_hide_in_source_view')) + return; - break; + // Parse out head, body and footer + c = c.replace(/<(\/?)BODY/gi, '<$1body'); + sp = c.indexOf('\n"; + if (sp != -1) { + sp = c.indexOf('>', sp); + t.head = c.substring(0, sp + 1); - break; - } + ep = c.indexOf('\n'; - // Remove stuff we don't want - h = h.replace(/(\r|\n)/gi, ''); - h = h.replace(/<\?[^\>]*\>/gi, ''); - h = h.replace(/<\/?(!DOCTYPE|head|html)[^\>]*\>/gi, ''); - h = h.replace(//gi, ''); - h = h.replace(//gi, ''); - h = h.replace(/<(meta|base)[^>]*>/gi, ''); + t.head += ed.getParam('fullpage_default_doctype', ''); + t.head += '\n\n\n' + ed.getParam('fullpage_default_title', 'Untitled document') + '\n'; - // Make link and style elements into pre - h = h.replace(/]*)\/>/gi, '
');
-		//h = h.replace(/]*)>(.*?)<\/style>/gi, '
$2
'); + if (v = ed.getParam('fullpage_default_encoding')) + t.head += '\n'; - // Make body a div - h = h.replace(/\n'; + t.foot = '\n\n'; } - } + }, - // Add body attributes - nl = e.getElementsByTagName('div'); - if (nl.length > 0) { - body.style.cssText = tinyMCE.getAttrib(nl[0], 'style'); + _getContent : function(ed, o) { + var t = this; - if ((tmp = tinyMCE.getAttrib(nl[0], 'leftmargin')) != '' && body.style.marginLeft == '') - body.style.marginLeft = tmp + "px"; - - if ((tmp = tinyMCE.getAttrib(nl[0], 'rightmargin')) != '' && body.style.marginRight == '') - body.style.marginRight = tmp + "px"; - - if ((tmp = tinyMCE.getAttrib(nl[0], 'topmargin')) != '' && body.style.marginTop == '') - body.style.marginTop = tmp + "px"; - - if ((tmp = tinyMCE.getAttrib(nl[0], 'bottommargin')) != '' && body.style.marginBottom == '') - body.style.marginBottom = tmp + "px"; - - body.dir = tinyMCE.getAttrib(nl[0], 'dir'); - body.vLink = tinyMCE.getAttrib(nl[0], 'vlink'); - body.aLink = tinyMCE.getAttrib(nl[0], 'alink'); - body.link = tinyMCE.getAttrib(nl[0], 'link'); - body.text = tinyMCE.getAttrib(nl[0], 'text'); - - if ((tmp = tinyMCE.getAttrib(nl[0], 'background')) != '') - body.style.backgroundImage = "url('" + tmp + "')"; - - if ((tmp = tinyMCE.getAttrib(nl[0], 'bgcolor')) != '') - body.style.backgroundColor = tmp; + if (!o.source_view || !ed.getParam('fullpage_hide_in_source_view')) + o.content = tinymce.trim(t.head) + '\n' + tinymce.trim(o.content) + '\n' + tinymce.trim(t.foot); } - } -}; + }); -tinyMCE.addPlugin("fullpage", TinyMCE_FullPagePlugin); + // Register plugin + tinymce.PluginManager.add('fullpage', tinymce.plugins.FullPagePlugin); +})(); \ No newline at end of file