X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Ftiny_mce%2Fplugins%2Ffullpage%2Feditor_plugin_src.js;h=23de7c5a1a258cfbe1358155fab84db3b3ca8caf;hb=b05f4eef4014db3885787ef15107cba93c932ac9;hp=8c618235591cf2d44958eb2aed6fe0d3a4bb64b1;hpb=932f4feaa7b2afe4553e5e669e2312614d3f6140;p=citadel.git diff --git a/webcit/tiny_mce/plugins/fullpage/editor_plugin_src.js b/webcit/tiny_mce/plugins/fullpage/editor_plugin_src.js old mode 100755 new mode 100644 index 8c6182355..23de7c5a1 --- a/webcit/tiny_mce/plugins/fullpage/editor_plugin_src.js +++ b/webcit/tiny_mce/plugins/fullpage/editor_plugin_src.js @@ -1,235 +1,405 @@ /** - * $Id: editor_plugin_src.js 232 2007-03-05 17:00:27Z spocke $ + * editor_plugin_src.js * - * @author Moxiecode - * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. + * Copyright 2009, Moxiecode Systems AB + * Released under LGPL License. + * + * License: http://tinymce.moxiecode.com/license + * Contributing: http://tinymce.moxiecode.com/contributing */ -/* Import plugin specific language pack */ -tinyMCE.importPluginLanguagePack('fullpage'); - -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 - }; - }, - - getControlHTML : function(cn) { - switch (cn) { - case "fullpage": - return tinyMCE.getButtonHTML(cn, 'lang_fullpage_desc', '{$pluginurl}/images/fullpage.gif', 'mceFullPageProperties'); - } +(function() { + var each = tinymce.each, Node = tinymce.html.Node; + + tinymce.create('tinymce.plugins.FullPagePlugin', { + init : function(ed, url) { + var t = this; + + t.editor = ed; + + // 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, + data : t._htmlToData() + }); + }); + + // Register buttons + ed.addButton('fullpage', {title : 'fullpage.desc', cmd : 'mceFullPageProperties'}); + + ed.onBeforeSetContent.add(t._setContent, t); + ed.onGetContent.add(t._getContent, t); + }, + + 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 + }; + }, + + // Private plugin internal methods + + _htmlToData : function() { + var headerFragment = this._parseHeader(), data = {}, nodes, elm, matches, editor = this.editor; + + function getAttr(elm, name) { + var value = elm.attr(name); + + return value || ''; + }; + + // Default some values + data.fontface = editor.getParam("fullpage_default_fontface", ""); + data.fontsize = editor.getParam("fullpage_default_fontsize", ""); + + // Parse XML PI + elm = headerFragment.firstChild; + if (elm.type == 7) { + data.xml_pi = true; + matches = /encoding="([^"]+)"/.exec(elm.value); + if (matches) + data.docencoding = matches[1]; + } - return ""; - }, - - execCommand : function(editor_id, element, command, user_interface, value) { - // Handle commands - switch (command) { - case "mceFullPageProperties": - var template = new Array(); - - template['file'] = '../../plugins/fullpage/fullpage.htm'; - template['width'] = 430; - template['height'] = 485 + (tinyMCE.isOpera ? 5 : 0); - - template['width'] += tinyMCE.getLang('lang_fullpage_delta_width', 0); - template['height'] += tinyMCE.getLang('lang_fullpage_delta_height', 0); - - tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"}); - return true; - - case "mceFullPageUpdate": - TinyMCE_FullPagePlugin._addToHead(tinyMCE.getInstanceById(editor_id)); - return true; - } - - // Pass to next handler in chain - return false; - }, - - 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", ""); - - // 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