/forum/site_media/js/wym/wymeditor/jquery.wymeditor.js
JavaScript | 4606 lines | 3655 code | 347 blank | 604 comment | 245 complexity | df0c1374d0b1ce0c425d4d0e2eb4f41e MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0
Large files files are truncated, but you can click here to view the full file
- /*
- * WYMeditor : what you see is What You Mean web-based editor
- * Copyright (c) 2008 Jean-Francois Hovinne, http://www.wymeditor.org/
- * Dual licensed under the MIT (MIT-license.txt)
- * and GPL (GPL-license.txt) licenses.
- *
- * For further information visit:
- * http://www.wymeditor.org/
- *
- * File: jquery.wymeditor.js
- *
- * Main JS file with core classes and functions.
- * See the documentation for more info.
- *
- * About: authors
- *
- * Jean-Francois Hovinne (jf.hovinne a-t wymeditor dotorg)
- * Volker Mische (vmx a-t gmx dotde)
- * Scott Lewis (lewiscot a-t gmail dotcom)
- * Bermi Ferrer (wymeditor a-t bermi dotorg)
- * Daniel Reszka (d.reszka a-t wymeditor dotorg)
- * Jonatan Lundin (jonatan.lundin _at_ gmail.com)
- */
- /*
- Namespace: WYMeditor
- Global WYMeditor namespace.
- */
- if(!WYMeditor) var WYMeditor = {};
- jQuery.extend(WYMeditor, {
- /*
- Constants: Global WYMeditor constants.
- VERSION - Defines WYMeditor version.
- INSTANCES - An array of loaded WYMeditor.editor instances.
- STRINGS - An array of loaded WYMeditor language pairs/values.
- SKINS - An array of loaded WYMeditor skins.
- NAME - The "name" attribute.
- INDEX - A string replaced by the instance index.
- WYM_INDEX - A string used to get/set the instance index.
- BASE_PATH - A string replaced by WYMeditor's base path.
- SKIN_PATH - A string replaced by WYMeditor's skin path.
- WYM_PATH - A string replaced by WYMeditor's main JS file path.
- SKINS_DEFAULT_PATH - The skins default base path.
- SKINS_DEFAULT_CSS - The skins default CSS file.
- LANG_DEFAULT_PATH - The language files default path.
- IFRAME_BASE_PATH - A string replaced by the designmode iframe's base path.
- IFRAME_DEFAULT - The iframe's default base path.
- JQUERY_PATH - A string replaced by the computed jQuery path.
- DIRECTION - A string replaced by the text direction (rtl or ltr).
- LOGO - A string replaced by WYMeditor logo.
- TOOLS - A string replaced by the toolbar's HTML.
- TOOLS_ITEMS - A string replaced by the toolbar items.
- TOOL_NAME - A string replaced by a toolbar item's name.
- TOOL_TITLE - A string replaced by a toolbar item's title.
- TOOL_CLASS - A string replaced by a toolbar item's class.
- CLASSES - A string replaced by the classes panel's HTML.
- CLASSES_ITEMS - A string replaced by the classes items.
- CLASS_NAME - A string replaced by a class item's name.
- CLASS_TITLE - A string replaced by a class item's title.
- CONTAINERS - A string replaced by the containers panel's HTML.
- CONTAINERS_ITEMS - A string replaced by the containers items.
- CONTAINER_NAME - A string replaced by a container item's name.
- CONTAINER_TITLE - A string replaced by a container item's title.
- CONTAINER_CLASS - A string replaced by a container item's class.
- HTML - A string replaced by the HTML view panel's HTML.
- IFRAME - A string replaced by the designmode iframe.
- STATUS - A string replaced by the status panel's HTML.
- DIALOG_TITLE - A string replaced by a dialog's title.
- DIALOG_BODY - A string replaced by a dialog's HTML body.
- BODY - The BODY element.
- STRING - The "string" type.
- BODY,DIV,P,
- H1,H2,H3,H4,H5,H6,
- PRE,BLOCKQUOTE,
- A,BR,IMG,
- TABLE,TD,TH,
- UL,OL,LI - HTML elements string representation.
- CLASS,HREF,SRC,
- TITLE,ALT - HTML attributes string representation.
- DIALOG_LINK - A link dialog type.
- DIALOG_IMAGE - An image dialog type.
- DIALOG_TABLE - A table dialog type.
- DIALOG_PASTE - A 'Paste from Word' dialog type.
- BOLD - Command: (un)set selection to <strong>.
- ITALIC - Command: (un)set selection to <em>.
- CREATE_LINK - Command: open the link dialog or (un)set link.
- INSERT_IMAGE - Command: open the image dialog or insert an image.
- INSERT_TABLE - Command: open the table dialog.
- PASTE - Command: open the paste dialog.
- INDENT - Command: nest a list item.
- OUTDENT - Command: unnest a list item.
- TOGGLE_HTML - Command: display/hide the HTML view.
- FORMAT_BLOCK - Command: set a block element to another type.
- PREVIEW - Command: open the preview dialog.
- UNLINK - Command: unset a link.
- INSERT_UNORDEREDLIST- Command: insert an unordered list.
- INSERT_ORDEREDLIST - Command: insert an ordered list.
- MAIN_CONTAINERS - An array of the main HTML containers used in WYMeditor.
- BLOCKS - An array of the HTML block elements.
- KEY - Standard key codes.
- NODE - Node types.
- */
- VERSION : "0.5-a2",
- INSTANCES : [],
- STRINGS : [],
- SKINS : [],
- NAME : "name",
- INDEX : "{Wym_Index}",
- WYM_INDEX : "wym_index",
- BASE_PATH : "{Wym_Base_Path}",
- CSS_PATH : "{Wym_Css_Path}",
- WYM_PATH : "{Wym_Wym_Path}",
- SKINS_DEFAULT_PATH : "skins/",
- SKINS_DEFAULT_CSS : "skin.css",
- SKINS_DEFAULT_JS : "skin.js",
- LANG_DEFAULT_PATH : "lang/",
- IFRAME_BASE_PATH : "{Wym_Iframe_Base_Path}",
- IFRAME_DEFAULT : "iframe/default/",
- JQUERY_PATH : "{Wym_Jquery_Path}",
- DIRECTION : "{Wym_Direction}",
- LOGO : "{Wym_Logo}",
- TOOLS : "{Wym_Tools}",
- TOOLS_ITEMS : "{Wym_Tools_Items}",
- TOOL_NAME : "{Wym_Tool_Name}",
- TOOL_TITLE : "{Wym_Tool_Title}",
- TOOL_CLASS : "{Wym_Tool_Class}",
- CLASSES : "{Wym_Classes}",
- CLASSES_ITEMS : "{Wym_Classes_Items}",
- CLASS_NAME : "{Wym_Class_Name}",
- CLASS_TITLE : "{Wym_Class_Title}",
- CONTAINERS : "{Wym_Containers}",
- CONTAINERS_ITEMS : "{Wym_Containers_Items}",
- CONTAINER_NAME : "{Wym_Container_Name}",
- CONTAINER_TITLE : "{Wym_Containers_Title}",
- CONTAINER_CLASS : "{Wym_Container_Class}",
- HTML : "{Wym_Html}",
- IFRAME : "{Wym_Iframe}",
- STATUS : "{Wym_Status}",
- DIALOG_TITLE : "{Wym_Dialog_Title}",
- DIALOG_BODY : "{Wym_Dialog_Body}",
- STRING : "string",
- BODY : "body",
- DIV : "div",
- P : "p",
- H1 : "h1",
- H2 : "h2",
- H3 : "h3",
- H4 : "h4",
- H5 : "h5",
- H6 : "h6",
- PRE : "pre",
- BLOCKQUOTE : "blockquote",
- A : "a",
- BR : "br",
- IMG : "img",
- TABLE : "table",
- TD : "td",
- TH : "th",
- UL : "ul",
- OL : "ol",
- LI : "li",
- CLASS : "class",
- HREF : "href",
- SRC : "src",
- TITLE : "title",
- ALT : "alt",
- DIALOG_LINK : "Link",
- DIALOG_IMAGE : "Image",
- DIALOG_TABLE : "Table",
- DIALOG_PASTE : "Paste_From_Word",
- BOLD : "Bold",
- ITALIC : "Italic",
- CREATE_LINK : "CreateLink",
- INSERT_IMAGE : "InsertImage",
- INSERT_TABLE : "InsertTable",
- INSERT_HTML : "InsertHTML",
- PASTE : "Paste",
- INDENT : "Indent",
- OUTDENT : "Outdent",
- TOGGLE_HTML : "ToggleHtml",
- FORMAT_BLOCK : "FormatBlock",
- PREVIEW : "Preview",
-
- UNLINK : "Unlink",
- INSERT_UNORDEREDLIST : "InsertUnorderedList",
- INSERT_ORDEREDLIST : "InsertOrderedList",
- MAIN_CONTAINERS : new Array("p","h1","h2","h3","h4","h5","h6","pre","blockquote"),
- BLOCKS : new Array("address", "blockquote", "div", "dl",
- "fieldset", "form", "h1", "h2", "h3", "h4", "h5", "h6", "hr",
- "noscript", "ol", "p", "pre", "table", "ul", "dd", "dt",
- "li", "tbody", "td", "tfoot", "th", "thead", "tr"),
- KEY : {
- BACKSPACE: 8,
- ENTER: 13,
- END: 35,
- HOME: 36,
- LEFT: 37,
- UP: 38,
- RIGHT: 39,
- DOWN: 40,
- CURSOR: new Array(37, 38, 39, 40),
- DELETE: 46
- },
- NODE : {
- ELEMENT: 1,
- ATTRIBUTE: 2,
- TEXT: 3
- },
-
- /*
- Class: WYMeditor.editor
- WYMeditor editor main class, instanciated for each editor occurrence.
- */
- editor : function(elem, options) {
- /*
- Constructor: WYMeditor.editor
- Initializes main values (index, elements, paths, ...)
- and call WYMeditor.editor.init which initializes the editor.
- Parameters:
- elem - The HTML element to be replaced by the editor.
- options - The hash of options.
- Returns:
- Nothing.
- See Also:
- <WYMeditor.editor.init>
- */
- //store the instance in the INSTANCES array and store the index
- this._index = WYMeditor.INSTANCES.push(this) - 1;
- //store the element replaced by the editor
- this._element = elem;
- //store the options
- this._options = options;
- //store the element's inner value
- this._html = jQuery(elem).val();
- //store the HTML option, if any
- if(this._options.html) this._html = this._options.html;
- //get or compute the base path (where the main JS file is located)
- this._options.basePath = this._options.basePath
- || this.computeBasePath();
- //get or set the skin path (where the skin files are located)
- this._options.skinPath = this._options.skinPath
- || this._options.basePath + WYMeditor.SKINS_DEFAULT_PATH
- + this._options.skin + '/';
- //get or compute the main JS file location
- this._options.wymPath = this._options.wymPath
- || this.computeWymPath();
- //get or set the language files path
- this._options.langPath = this._options.langPath
- || this._options.basePath + WYMeditor.LANG_DEFAULT_PATH;
- //get or set the designmode iframe's base path
- this._options.iframeBasePath = this._options.iframeBasePath
- || this._options.basePath + WYMeditor.IFRAME_DEFAULT;
- //get or compute the jQuery JS file location
- this._options.jQueryPath = this._options.jQueryPath
- || this.computeJqueryPath();
- //initialize the editor instance
- this.init();
-
- }
- });
- /********** JQUERY **********/
- /**
- * Replace an HTML element by WYMeditor
- *
- * @example jQuery(".wymeditor").wymeditor(
- * {
- *
- * }
- * );
- * @desc Example description here
- *
- * @name WYMeditor
- * @description WYMeditor is a web-based WYSIWYM XHTML editor
- * @param Hash hash A hash of parameters
- * @option Integer iExample Description here
- * @option String sExample Description here
- *
- * @type jQuery
- * @cat Plugins/WYMeditor
- * @author Jean-Francois Hovinne
- */
- jQuery.fn.wymeditor = function(options) {
- options = jQuery.extend({
- html: "",
-
- basePath: false,
-
- skinPath: false,
-
- wymPath: false,
-
- iframeBasePath: false,
-
- jQueryPath: false,
-
- styles: false,
-
- stylesheet: false,
-
- skin: "default",
- initSkin: true,
- loadSkin: true,
- lang: "en",
- direction: "ltr",
- boxHtml: "<div class='wym_box'>"
- + "<div class='wym_area_top'>"
- + WYMeditor.TOOLS
- + "</div>"
- + "<div class='wym_area_left'></div>"
- + "<div class='wym_area_right'>"
- + WYMeditor.CONTAINERS
- + WYMeditor.CLASSES
- + "</div>"
- + "<div class='wym_area_main'>"
- + WYMeditor.HTML
- + WYMeditor.IFRAME
- + WYMeditor.STATUS
- + "</div>"
- + "<div class='wym_area_bottom'>"
- + WYMeditor.LOGO
- + "</div>"
- + "</div>",
- logoHtml: "<a class='wym_wymeditor_link' "
- + "href='http://www.wymeditor.org/'>WYMeditor</a>",
- iframeHtml:"<div class='wym_iframe wym_section'>"
- + "<iframe "
- + "src='"
- + WYMeditor.IFRAME_BASE_PATH
- + "wymiframe.html' "
- + "onload='this.contentWindow.parent.WYMeditor.INSTANCES["
- + WYMeditor.INDEX + "].initIframe(this)'"
- + "></iframe>"
- + "</div>",
-
- editorStyles: [],
- toolsHtml: "<div class='wym_tools wym_section'>"
- + "<h2>{Tools}</h2>"
- + "<ul>"
- + WYMeditor.TOOLS_ITEMS
- + "</ul>"
- + "</div>",
-
- toolsItemHtml: "<li class='"
- + WYMeditor.TOOL_CLASS
- + "'><a href='#' name='"
- + WYMeditor.TOOL_NAME
- + "' title='"
- + WYMeditor.TOOL_TITLE
- + "'>"
- + WYMeditor.TOOL_TITLE
- + "</a></li>",
- toolsItems: [
- {'name': 'Bold', 'title': 'Strong', 'css': 'wym_tools_strong'},
- {'name': 'Italic', 'title': 'Emphasis', 'css': 'wym_tools_emphasis'},
- {'name': 'Superscript', 'title': 'Superscript',
- 'css': 'wym_tools_superscript'},
- {'name': 'Subscript', 'title': 'Subscript',
- 'css': 'wym_tools_subscript'},
- {'name': 'InsertOrderedList', 'title': 'Ordered_List',
- 'css': 'wym_tools_ordered_list'},
- {'name': 'InsertUnorderedList', 'title': 'Unordered_List',
- 'css': 'wym_tools_unordered_list'},
- {'name': 'Indent', 'title': 'Indent', 'css': 'wym_tools_indent'},
- {'name': 'Outdent', 'title': 'Outdent', 'css': 'wym_tools_outdent'},
- {'name': 'Undo', 'title': 'Undo', 'css': 'wym_tools_undo'},
- {'name': 'Redo', 'title': 'Redo', 'css': 'wym_tools_redo'},
- {'name': 'CreateLink', 'title': 'Link', 'css': 'wym_tools_link'},
- {'name': 'Unlink', 'title': 'Unlink', 'css': 'wym_tools_unlink'},
- {'name': 'InsertImage', 'title': 'Image', 'css': 'wym_tools_image'},
- {'name': 'InsertTable', 'title': 'Table', 'css': 'wym_tools_table'},
- {'name': 'Paste', 'title': 'Paste_From_Word',
- 'css': 'wym_tools_paste'},
- {'name': 'ToggleHtml', 'title': 'HTML', 'css': 'wym_tools_html'},
- {'name': 'Preview', 'title': 'Preview', 'css': 'wym_tools_preview'}
- ],
- containersHtml: "<div class='wym_containers wym_section'>"
- + "<h2>{Containers}</h2>"
- + "<ul>"
- + WYMeditor.CONTAINERS_ITEMS
- + "</ul>"
- + "</div>",
-
- containersItemHtml:"<li class='"
- + WYMeditor.CONTAINER_CLASS
- + "'>"
- + "<a href='#' name='"
- + WYMeditor.CONTAINER_NAME
- + "'>"
- + WYMeditor.CONTAINER_TITLE
- + "</a></li>",
-
- containersItems: [
- {'name': 'P', 'title': 'Paragraph', 'css': 'wym_containers_p'},
- {'name': 'H1', 'title': 'Heading_1', 'css': 'wym_containers_h1'},
- {'name': 'H2', 'title': 'Heading_2', 'css': 'wym_containers_h2'},
- {'name': 'H3', 'title': 'Heading_3', 'css': 'wym_containers_h3'},
- {'name': 'H4', 'title': 'Heading_4', 'css': 'wym_containers_h4'},
- {'name': 'H5', 'title': 'Heading_5', 'css': 'wym_containers_h5'},
- {'name': 'H6', 'title': 'Heading_6', 'css': 'wym_containers_h6'},
- {'name': 'PRE', 'title': 'Preformatted', 'css': 'wym_containers_pre'},
- {'name': 'BLOCKQUOTE', 'title': 'Blockquote',
- 'css': 'wym_containers_blockquote'},
- {'name': 'TH', 'title': 'Table_Header', 'css': 'wym_containers_th'}
- ],
- classesHtml: "<div class='wym_classes wym_section'>"
- + "<h2>{Classes}</h2><ul>"
- + WYMeditor.CLASSES_ITEMS
- + "</ul></div>",
- classesItemHtml: "<li><a href='#' name='"
- + WYMeditor.CLASS_NAME
- + "'>"
- + WYMeditor.CLASS_TITLE
- + "</a></li>",
- classesItems: [],
- statusHtml: "<div class='wym_status wym_section'>"
- + "<h2>{Status}</h2>"
- + "</div>",
- htmlHtml: "<div class='wym_html wym_section'>"
- + "<h2>{Source_Code}</h2>"
- + "<textarea class='wym_html_val'></textarea>"
- + "</div>",
- boxSelector: ".wym_box",
- toolsSelector: ".wym_tools",
- toolsListSelector: " ul",
- containersSelector:".wym_containers",
- classesSelector: ".wym_classes",
- htmlSelector: ".wym_html",
- iframeSelector: ".wym_iframe iframe",
- iframeBodySelector:".wym_iframe",
- statusSelector: ".wym_status",
- toolSelector: ".wym_tools a",
- containerSelector: ".wym_containers a",
- classSelector: ".wym_classes a",
- htmlValSelector: ".wym_html_val",
-
- hrefSelector: ".wym_href",
- srcSelector: ".wym_src",
- titleSelector: ".wym_title",
- altSelector: ".wym_alt",
- textSelector: ".wym_text",
-
- rowsSelector: ".wym_rows",
- colsSelector: ".wym_cols",
- captionSelector: ".wym_caption",
- summarySelector: ".wym_summary",
-
- submitSelector: ".wym_submit",
- cancelSelector: ".wym_cancel",
- previewSelector: "",
-
- dialogTypeSelector: ".wym_dialog_type",
- dialogLinkSelector: ".wym_dialog_link",
- dialogImageSelector: ".wym_dialog_image",
- dialogTableSelector: ".wym_dialog_table",
- dialogPasteSelector: ".wym_dialog_paste",
- dialogPreviewSelector: ".wym_dialog_preview",
-
- updateSelector: ".wymupdate",
- updateEvent: "click",
-
- dialogFeatures: "menubar=no,titlebar=no,toolbar=no,resizable=no"
- + ",width=560,height=300,top=0,left=0",
- dialogHtml: "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'"
- + " 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>"
- + "<html dir='"
- + WYMeditor.DIRECTION
- + "'><head>"
- + "<link rel='stylesheet' type='text/css' media='screen'"
- + " href='"
- + WYMeditor.CSS_PATH
- + "' />"
- + "<title>"
- + WYMeditor.DIALOG_TITLE
- + "</title>"
- + "<script type='text/javascript'"
- + " src='"
- + WYMeditor.JQUERY_PATH
- + "'></script>"
- + "<script type='text/javascript'"
- + " src='"
- + WYMeditor.WYM_PATH
- + "'></script>"
- + "</head>"
- + WYMeditor.DIALOG_BODY
- + "</html>",
-
- dialogLinkHtml: "<body class='wym_dialog wym_dialog_link'"
- + " onload='WYMeditor.INIT_DIALOG(" + WYMeditor.INDEX + ")'"
- + ">"
- + "<form>"
- + "<fieldset>"
- + "<input type='hidden' class='wym_dialog_type' value='"
- + WYMeditor.DIALOG_LINK
- + "' />"
- + "<legend>{Link}</legend>"
- + "<div class='row'>"
- + "<label>{URL}</label>"
- + "<input type='text' class='wym_href' value='' size='40' />"
- + "</div>"
- + "<div class='row'>"
- + "<label>{Title}</label>"
- + "<input type='text' class='wym_title' value='' size='40' />"
- + "</div>"
- + "<div class='row row-indent'>"
- + "<input class='wym_submit' type='button'"
- + " value='{Submit}' />"
- + "<input class='wym_cancel' type='button'"
- + "value='{Cancel}' />"
- + "</div>"
- + "</fieldset>"
- + "</form>"
- + "</body>",
-
- dialogImageHtml: "<body class='wym_dialog wym_dialog_image'"
- + " onload='WYMeditor.INIT_DIALOG(" + WYMeditor.INDEX + ")'"
- + ">"
- + "<form>"
- + "<fieldset>"
- + "<input type='hidden' class='wym_dialog_type' value='"
- + WYMeditor.DIALOG_IMAGE
- + "' />"
- + "<legend>{Image}</legend>"
- + "<div class='row'>"
- + "<label>{URL}</label>"
- + "<input type='text' class='wym_src' value='' size='40' />"
- + "</div>"
- + "<div class='row'>"
- + "<label>{Alternative_Text}</label>"
- + "<input type='text' class='wym_alt' value='' size='40' />"
- + "</div>"
- + "<div class='row'>"
- + "<label>{Title}</label>"
- + "<input type='text' class='wym_title' value='' size='40' />"
- + "</div>"
- + "<div class='row row-indent'>"
- + "<input class='wym_submit' type='button'"
- + " value='{Submit}' />"
- + "<input class='wym_cancel' type='button'"
- + "value='{Cancel}' />"
- + "</div>"
- + "</fieldset>"
- + "</form>"
- + "</body>",
-
- dialogTableHtml: "<body class='wym_dialog wym_dialog_table'"
- + " onload='WYMeditor.INIT_DIALOG(" + WYMeditor.INDEX + ")'"
- + ">"
- + "<form>"
- + "<fieldset>"
- + "<input type='hidden' class='wym_dialog_type' value='"
- + WYMeditor.DIALOG_TABLE
- + "' />"
- + "<legend>{Table}</legend>"
- + "<div class='row'>"
- + "<label>{Caption}</label>"
- + "<input type='text' class='wym_caption' value='' size='40' />"
- + "</div>"
- + "<div class='row'>"
- + "<label>{Summary}</label>"
- + "<input type='text' class='wym_summary' value='' size='40' />"
- + "</div>"
- + "<div class='row'>"
- + "<label>{Number_Of_Rows}</label>"
- + "<input type='text' class='wym_rows' value='3' size='3' />"
- + "</div>"
- + "<div class='row'>"
- + "<label>{Number_Of_Cols}</label>"
- + "<input type='text' class='wym_cols' value='2' size='3' />"
- + "</div>"
- + "<div class='row row-indent'>"
- + "<input class='wym_submit' type='button'"
- + " value='{Submit}' />"
- + "<input class='wym_cancel' type='button'"
- + "value='{Cancel}' />"
- + "</div>"
- + "</fieldset>"
- + "</form>"
- + "</body>",
- dialogPasteHtml: "<body class='wym_dialog wym_dialog_paste'"
- + " onload='WYMeditor.INIT_DIALOG(" + WYMeditor.INDEX + ")'"
- + ">"
- + "<form>"
- + "<input type='hidden' class='wym_dialog_type' value='"
- + WYMeditor.DIALOG_PASTE
- + "' />"
- + "<fieldset>"
- + "<legend>{Paste_From_Word}</legend>"
- + "<div class='row'>"
- + "<textarea class='wym_text' rows='10' cols='50'></textarea>"
- + "</div>"
- + "<div class='row'>"
- + "<input class='wym_submit' type='button'"
- + " value='{Submit}' />"
- + "<input class='wym_cancel' type='button'"
- + "value='{Cancel}' />"
- + "</div>"
- + "</fieldset>"
- + "</form>"
- + "</body>",
- dialogPreviewHtml: "<body class='wym_dialog wym_dialog_preview'"
- + " onload='WYMeditor.INIT_DIALOG(" + WYMeditor.INDEX + ")'"
- + "></body>",
-
- dialogStyles: [],
- stringDelimiterLeft: "{",
- stringDelimiterRight:"}",
-
- preInit: null,
- preBind: null,
- postInit: null,
-
- preInitDialog: null,
- postInitDialog: null
- }, options);
- return this.each(function() {
- new WYMeditor.editor(jQuery(this),options);
- });
- };
- /* @name extend
- * @description Returns the WYMeditor instance based on its index
- */
- jQuery.extend({
- wymeditors: function(i) {
- return (WYMeditor.INSTANCES[i]);
- }
- });
- /********** WYMeditor **********/
- /* @name Wymeditor
- * @description WYMeditor class
- */
- /* @name init
- * @description Initializes a WYMeditor instance
- */
- WYMeditor.editor.prototype.init = function() {
- //load subclass - browser specific
- //unsupported browsers: do nothing
- if (jQuery.browser.msie) {
- var WymClass = new WYMeditor.WymClassExplorer(this);
- }
- else if (jQuery.browser.mozilla) {
- var WymClass = new WYMeditor.WymClassMozilla(this);
- }
- else if (jQuery.browser.opera) {
- var WymClass = new WYMeditor.WymClassOpera(this);
- }
- else if (jQuery.browser.safari) {
- var WymClass = new WYMeditor.WymClassSafari(this);
- }
-
- if(WymClass) {
-
- if(jQuery.isFunction(this._options.preInit)) this._options.preInit(this);
- var SaxListener = new WYMeditor.XhtmlSaxListener();
- jQuery.extend(SaxListener, WymClass);
- this.parser = new WYMeditor.XhtmlParser(SaxListener);
-
- if(this._options.styles || this._options.stylesheet){
- this.configureEditorUsingRawCss();
- }
-
- this.helper = new WYMeditor.XmlHelper();
-
- //extend the Wymeditor object
- //don't use jQuery.extend since 1.1.4
- //jQuery.extend(this, WymClass);
- for (var prop in WymClass) { this[prop] = WymClass[prop]; }
- //load wymbox
- this._box = jQuery(this._element).hide().after(this._options.boxHtml).next();
- //store the instance index in the wymbox element
- jQuery(this._box).data(WYMeditor.WYM_INDEX, this._index);
-
- var h = WYMeditor.Helper;
- //construct the iframe
- var iframeHtml = this._options.iframeHtml;
- iframeHtml = h.replaceAll(iframeHtml, WYMeditor.INDEX, this._index);
- iframeHtml = h.replaceAll(iframeHtml, WYMeditor.IFRAME_BASE_PATH, this._options.iframeBasePath);
-
- //construct wymbox
- var boxHtml = jQuery(this._box).html();
-
- boxHtml = h.replaceAll(boxHtml, WYMeditor.LOGO, this._options.logoHtml);
- boxHtml = h.replaceAll(boxHtml, WYMeditor.TOOLS, this._options.toolsHtml);
- boxHtml = h.replaceAll(boxHtml, WYMeditor.CONTAINERS,this._options.containersHtml);
- boxHtml = h.replaceAll(boxHtml, WYMeditor.CLASSES, this._options.classesHtml);
- boxHtml = h.replaceAll(boxHtml, WYMeditor.HTML, this._options.htmlHtml);
- boxHtml = h.replaceAll(boxHtml, WYMeditor.IFRAME, iframeHtml);
- boxHtml = h.replaceAll(boxHtml, WYMeditor.STATUS, this._options.statusHtml);
-
- //construct tools list
- var aTools = eval(this._options.toolsItems);
- var sTools = "";
- for(var i = 0; i < aTools.length; i++) {
- var oTool = aTools[i];
- if(oTool.name && oTool.title)
- var sTool = this._options.toolsItemHtml;
- var sTool = h.replaceAll(sTool, WYMeditor.TOOL_NAME, oTool.name);
- sTool = h.replaceAll(sTool, WYMeditor.TOOL_TITLE, this._options.stringDelimiterLeft
- + oTool.title
- + this._options.stringDelimiterRight);
- sTool = h.replaceAll(sTool, WYMeditor.TOOL_CLASS, oTool.css);
- sTools += sTool;
- }
- boxHtml = h.replaceAll(boxHtml, WYMeditor.TOOLS_ITEMS, sTools);
- //construct classes list
- var aClasses = eval(this._options.classesItems);
- var sClasses = "";
- for(var i = 0; i < aClasses.length; i++) {
- var oClass = aClasses[i];
- if(oClass.name && oClass.title)
- var sClass = this._options.classesItemHtml;
- sClass = h.replaceAll(sClass, WYMeditor.CLASS_NAME, oClass.name);
- sClass = h.replaceAll(sClass, WYMeditor.CLASS_TITLE, oClass.title);
- sClasses += sClass;
- }
- boxHtml = h.replaceAll(boxHtml, WYMeditor.CLASSES_ITEMS, sClasses);
-
- //construct containers list
- var aContainers = eval(this._options.containersItems);
- var sContainers = "";
- for(var i = 0; i < aContainers.length; i++) {
- var oContainer = aContainers[i];
- if(oContainer.name && oContainer.title)
- var sContainer = this._options.containersItemHtml;
- sContainer = h.replaceAll(sContainer, WYMeditor.CONTAINER_NAME, oContainer.name);
- sContainer = h.replaceAll(sContainer, WYMeditor.CONTAINER_TITLE,
- this._options.stringDelimiterLeft
- + oContainer.title
- + this._options.stringDelimiterRight);
- sContainer = h.replaceAll(sContainer, WYMeditor.CONTAINER_CLASS, oContainer.css);
- sContainers += sContainer;
- }
- boxHtml = h.replaceAll(boxHtml, WYMeditor.CONTAINERS_ITEMS, sContainers);
- //l10n
- boxHtml = this.replaceStrings(boxHtml);
-
- //load html in wymbox
- jQuery(this._box).html(boxHtml);
-
- //hide the html value
- jQuery(this._box).find(this._options.htmlSelector).hide();
-
- //enable the skin
- this.loadSkin();
-
- }
- };
- WYMeditor.editor.prototype.bindEvents = function() {
- //copy the instance
- var wym = this;
-
- //handle click event on tools buttons
- jQuery(this._box).find(this._options.toolSelector).click(function() {
- wym.exec(jQuery(this).attr(WYMeditor.NAME));
- return(false);
- });
-
- //handle click event on containers buttons
- jQuery(this._box).find(this._options.containerSelector).click(function() {
- wym.container(jQuery(this).attr(WYMeditor.NAME));
- return(false);
- });
-
- //handle keyup event on html value: set the editor value
- jQuery(this._box).find(this._options.htmlValSelector).keyup(function() {
- jQuery(wym._doc.body).html(jQuery(this).val());
- });
-
- //handle click event on classes buttons
- jQuery(this._box).find(this._options.classSelector).click(function() {
-
- var aClasses = eval(wym._options.classesItems);
- var sName = jQuery(this).attr(WYMeditor.NAME);
-
- var oClass = WYMeditor.Helper.findByName(aClasses, sName);
-
- if(oClass) {
- var jqexpr = oClass.expr;
- wym.toggleClass(sName, jqexpr);
- }
- return(false);
- });
-
- //handle event on update element
- jQuery(this._options.updateSelector)
- .bind(this._options.updateEvent, function() {
- wym.update();
- });
- };
- WYMeditor.editor.prototype.ready = function() {
- return(this._doc != null);
- };
- /********** METHODS **********/
- /* @name box
- * @description Returns the WYMeditor container
- */
- WYMeditor.editor.prototype.box = function() {
- return(this._box);
- };
- /* @name html
- * @description Get/Set the html value
- */
- WYMeditor.editor.prototype.html = function(html) {
- if(typeof html === 'string') jQuery(this._doc.body).html(html);
- else return(jQuery(this._doc.body).html());
- };
- /* @name xhtml
- * @description Cleans up the HTML
- */
- WYMeditor.editor.prototype.xhtml = function() {
- return this.parser.parse(this.html());
- };
- /* @name exec
- * @description Executes a button command
- */
- WYMeditor.editor.prototype.exec = function(cmd) {
-
- //base function for execCommand
- //open a dialog or exec
- switch(cmd) {
- case WYMeditor.CREATE_LINK:
- var container = this.container();
- if(container || this._selected_image) this.dialog(WYMeditor.DIALOG_LINK);
- break;
-
- case WYMeditor.INSERT_IMAGE:
- this.dialog(WYMeditor.DIALOG_IMAGE);
- break;
-
- case WYMeditor.INSERT_TABLE:
- this.dialog(WYMeditor.DIALOG_TABLE);
- break;
-
- case WYMeditor.PASTE:
- this.dialog(WYMeditor.DIALOG_PASTE);
- break;
-
- case WYMeditor.TOGGLE_HTML:
- this.update();
- this.toggleHtml();
- break;
-
- case WYMeditor.PREVIEW:
- this.dialog(WYMeditor.PREVIEW);
- break;
-
- default:
- this._exec(cmd);
- break;
- }
- };
- /* @name container
- * @description Get/Set the selected container
- */
- WYMeditor.editor.prototype.container = function(sType) {
- if(sType) {
-
- var container = null;
-
- if(sType.toLowerCase() == WYMeditor.TH) {
-
- container = this.container();
-
- //find the TD or TH container
- switch(container.tagName.toLowerCase()) {
-
- case WYMeditor.TD: case WYMeditor.TH:
- break;
- default:
- var aTypes = new Array(WYMeditor.TD,WYMeditor.TH);
- container = this.findUp(this.container(), aTypes);
- break;
- }
-
- //if it exists, switch
- if(container!=null) {
-
- sType = (container.tagName.toLowerCase() == WYMeditor.TD)? WYMeditor.TH: WYMeditor.TD;
- this.switchTo(container,sType);
- this.update();
- }
- } else {
-
- //set the container type
- var aTypes=new Array(WYMeditor.P,WYMeditor.H1,WYMeditor.H2,WYMeditor.H3,WYMeditor.H4,WYMeditor.H5,
- WYMeditor.H6,WYMeditor.PRE,WYMeditor.BLOCKQUOTE);
- container = this.findUp(this.container(), aTypes);
-
- if(container) {
-
- var newNode = null;
-
- //blockquotes must contain a block level element
- if(sType.toLowerCase() == WYMeditor.BLOCKQUOTE) {
-
- var blockquote = this.findUp(this.container(), WYMeditor.BLOCKQUOTE);
-
- if(blockquote == null) {
-
- newNode = this._doc.createElement(sType);
- container.parentNode.insertBefore(newNode,container);
- newNode.appendChild(container);
- this.setFocusToNode(newNode.firstChild);
-
- } else {
-
- var nodes = blockquote.childNodes;
- var lgt = nodes.length;
- var firstNode = null;
-
- if(lgt > 0) firstNode = nodes.item(0);
- for(var x=0; x<lgt; x++) {
- blockquote.parentNode.insertBefore(nodes.item(0),blockquote);
- }
- blockquote.parentNode.removeChild(blockquote);
- if(firstNode) this.setFocusToNode(firstNode);
- }
- }
-
- else this.switchTo(container,sType);
-
- this.update();
- }
- }
- }
- else return(this.selected());
- };
- /* @name toggleClass
- * @description Toggles class on selected element, or one of its parents
- */
- WYMeditor.editor.prototype.toggleClass = function(sClass, jqexpr) {
- var container = (this._selected_image
- ? this._selected_image
- : jQuery(this.selected()));
- container = jQuery(container).parentsOrSelf(jqexpr);
- jQuery(container).toggleClass(sClass);
- if(!jQuery(container).attr(WYMeditor.CLASS)) jQuery(container).removeAttr(this._class);
- };
- /* @name findUp
- * @description Returns the first parent or self container, based on its type
- */
- WYMeditor.editor.prototype.findUp = function(node, filter) {
- //filter is a string or an array of strings
- if(node) {
- var tagname = node.tagName.toLowerCase();
-
- if(typeof(filter) == WYMeditor.STRING) {
-
- while(tagname != filter && tagname != WYMeditor.BODY) {
-
- node = node.parentNode;
- tagname = node.tagName.toLowerCase();
- }
-
- } else {
-
- var bFound = false;
-
- while(!bFound && tagname != WYMeditor.BODY) {
- for(var i = 0; i < filter.length; i++) {
- if(tagname == filter[i]) {
- bFound = true;
- break;
- }
- }
- if(!bFound) {
- node = node.parentNode;
- tagname = node.tagName.toLowerCase();
- }
- }
- }
-
- if(tagname != WYMeditor.BODY) return(node);
- else return(null);
-
- } else return(null);
- };
- /* @name switchTo
- * @description Switch the node's type
- */
- WYMeditor.editor.prototype.switchTo = function(node,sType) {
- var newNode = this._doc.createElement(sType);
- var html = jQuery(node).html();
- node.parentNode.replaceChild(newNode,node);
- jQuery(newNode).html(html);
- this.setFocusToNode(newNode);
- };
- WYMeditor.editor.prototype.replaceStrings = function(sVal) {
- //check if the language file has already been loaded
- //if not, get it via a synchronous ajax call
- if(!WYMeditor.STRINGS[this._options.lang])
- eval(jQuery.ajax({url:this._options.langPath
- + this._options.lang + '.js', async:false}).responseText);
- //replace all the strings in sVal and return it
- for (var key in WYMeditor.STRINGS[this._options.lang]) {
- sVal = WYMeditor.Helper.replaceAll(sVal, this._options.stringDelimiterLeft + key
- + this._options.stringDelimiterRight,
- WYMeditor.STRINGS[this._options.lang][key]);
- };
- return(sVal);
- };
- WYMeditor.editor.prototype.encloseString = function(sVal) {
- return(this._options.stringDelimiterLeft
- + sVal
- + this._options.stringDelimiterRight);
- };
- /* @name status
- * @description Prints a status message
- */
- WYMeditor.editor.prototype.status = function(sMessage) {
- //print status message
- jQuery(this._box).find(this._options.statusSelector).html(sMessage);
- };
- /* @name update
- * @description Updates the element and textarea values
- */
- WYMeditor.editor.prototype.update = function() {
- var html = this.xhtml();
- jQuery(this._element).val(html);
- jQuery(this._box).find(this._options.htmlValSelector).val(html);
- };
- /* @name dialog
- * @description Opens a dialog box
- */
- WYMeditor.editor.prototype.dialog = function(sType) {
-
- var wDialog = window.open(
- '',
- 'dialog',
- this._wym._options.dialogFeatures);
- if(wDialog) {
- var sBodyHtml = "";
-
- switch(sType) {
- case(WYMeditor.DIALOG_LINK):
- sBodyHtml = this._options.dialogLinkHtml;
- break;
- case(WYMeditor.DIALOG_IMAGE):
- sBodyHtml = this._options.dialogImageHtml;
- break;
- case(WYMeditor.DIALOG_TABLE):
- sBodyHtml = this._options.dialogTableHtml;
- break;
- case(WYMeditor.DIALOG_PASTE):
- sBodyHtml = this._options.dialogPasteHtml;
- break;
- case(WYMeditor.PREVIEW):
- sBodyHtml = this._options.dialogPreviewHtml;
- break;
- }
-
- var h = WYMeditor.Helper;
- //construct the dialog
- var dialogHtml = this._options.dialogHtml;
- dialogHtml = h.replaceAll(dialogHtml, WYMeditor.BASE_PATH, this._options.basePath);
- dialogHtml = h.replaceAll(dialogHtml, WYMeditor.DIRECTION, this._options.direction);
- dialogHtml = h.replaceAll(dialogHtml, WYMeditor.CSS_PATH, this._options.skinPath + WYMeditor.SKINS_DEFAULT_CSS);
- dialogHtml = h.replaceAll(dialogHtml, WYMeditor.WYM_PATH, this._options.wymPath);
- dialogHtml = h.replaceAll(dialogHtml, WYMeditor.JQUERY_PATH, this._options.jQueryPath);
- dialogHtml = h.replaceAll(dialogHtml, WYMeditor.DIALOG_TITLE, this.encloseString(sType));
- dialogHtml = h.replaceAll(dialogHtml, WYMeditor.DIALOG_BODY, sBodyHtml);
- dialogHtml = h.replaceAll(dialogHtml, WYMeditor.INDEX, this._index);
-
- dialogHtml = this.replaceStrings(dialogHtml);
-
- var doc = wDialog.document;
- doc.write(dialogHtml);
- doc.close();
- }
- };
- /* @name toggleHtml
- * @description Shows/Hides the HTML
- */
- WYMeditor.editor.prototype.toggleHtml = function() {
- jQuery(this._box).find(this._options.htmlSelector).toggle();
- };
- WYMeditor.editor.prototype.uniqueStamp = function() {
- var now = new Date();
- return("wym-" + now.getTime());
- };
- WYMeditor.editor.prototype.paste = function(sData) {
- var sTmp;
- var container = this.selected();
-
- //split the data, using double newlines as the separator
- var aP = sData.split(this._newLine + this._newLine);
- var rExp = new RegExp(this._newLine, "g");
- //add a P for each item
- if(container && container.tagName.toLowerCase() != WYMeditor.BODY) {
- for(x = aP.length - 1; x >= 0; x--) {
- sTmp = aP[x];
- //simple newlines are replaced by a break
- sTmp = sTmp.replace(rExp, "<br />");
- jQuery(container).after("<p>" + sTmp + "</p>");
- }
- } else {
- for(x = 0; x < aP.length; x++) {
- sTmp = aP[x];
- //simple newlines are replaced by a break
- sTmp = sTmp.replace(rExp, "<br />");
- jQuery(this._doc.body).append("<p>" + sTmp + "</p>");
- }
-
- }
- };
- WYMeditor.editor.prototype.insert = function(html) {
- // Do we have a selection?
- if (this._iframe.contentWindow.getSelection().focusNode != null) {
- // Overwrite selection with provided html
- this._exec( WYMeditor.INSERT_HTML, html);
- } else {
- // Fall back to the internal paste function if there's no selection
- this.paste(html)
- }
- };
- WYMeditor.editor.prototype.addCssRules = function(doc, aCss) {
- var styles = doc.styleSheets[0];
- if(styles) {
- for(var i = 0; i < aCss.length; i++) {
- var oCss = aCss[i];
- if(oCss.name && oCss.css) this.addCssRule(styles, oCss);
- }
- }
- };
- /********** CONFIGURATION **********/
- WYMeditor.editor.prototype.computeBasePath = function() {
- return jQuery(jQuery.grep(jQuery('script'), function(s){
- return (s.src && s.src.match(/jquery\.wymeditor(\.pack){0,1}\.js(\?.*)?$/ ))
- })).attr('src').replace(/jquery\.wymeditor(\.pack){0,1}\.js(\?.*)?$/, '');
- };
- WYMeditor.editor.prototype.computeWymPath = function() {
- return jQuery(jQuery.grep(jQuery('script'), function(s){
- return (s.src && s.src.match(/jquery\.wymeditor(\.pack){0,1}\.js(\?.*)?$/ ))
- })).attr('src');
- };
- WYMeditor.editor.prototype.computeJqueryPath = function() {
- return jQuery(jQuery.grep(jQuery('script'), function(s){
- return (s.src && s.src.match(/jquery(-(.*)){0,1}(\.pack){0,1}\.js(\?.*)?$/ ))
- })).attr('src');
- };
- WYMeditor.editor.prototype.computeCssPath = function() {
- return jQuery(jQuery.grep(jQuery('link'), function(s){
- return (s.href && s.href.match(/wymeditor\/skins\/(.*)screen\.css(\?.*)?$/ ))
- })).attr('href');
- };
- WYMeditor.editor.prototype.configureEditorUsingRawCss = function() {
- var CssParser = new WYMeditor.WymCssParser();
- if(this._options.stylesheet){
- CssParser.parse(jQuery.ajax({url: this._options.stylesheet,async:false}).responseText);
- }else{
- CssParser.parse(this._options.styles, false);
- }
- if(this._options.classesItems.length == 0) {
- this._options.classesItems = CssParser.css_settings.classesItems;
- }
- if(this._options.editorStyles.length == 0) {
- this._options.editorStyles = CssParser.css_settings.editorStyles;
- }
- if(this._options.dialogStyles.length == 0) {
- this._options.dialogStyles = CssParser.css_settings.dialogStyles;
- }
- };
- /********** EVENTS **********/
- WYMeditor.editor.prototype.listen = function() {
- //don't use jQuery.find() on the iframe body
- //because of MSIE + jQuery + expando issue (#JQ1143)
- //jQuery(this._doc.body).find("*").bind("mouseup", this.mouseup);
-
- jQuery(this._doc.body).bind("mousedown", this.mousedown);
- var images = this._doc.body.getElementsByTagName("img");
- for(var i=0; i < images.length; i++) {
- jQuery(images[i]).bind("mousedown", this.mousedown);
- }
- };
- WYMeditor.editor.prototype.mousedown = function(evt) {
-
- var wym = WYMeditor.INSTANCES[this.ownerDocument.title];
- wym._selected_image = (this.tagName.toLowerCase() == WYMeditor.IMG) ? this : null;
- evt.stopPropagation();
- };
- /********** SKINS **********/
- /*
- * Function: WYMeditor.loadCss
- * Loads a stylesheet in the document.
- *
- * Parameters:
- * href - The CSS path.
- */
- WYMeditor.loadCss = function(href) {
-
- var link = document.createElement('link');
- link.rel = 'stylesheet';
- link.href = href;
- var head = jQuery('head').get(0);
- head.appendChild(link);
- };
- /*
- * Function: WYMeditor.editor.loadSkin
- * Loads the skin CSS and initialization script (if needed).
- */
- WYMeditor.editor.prototype.loadSkin = function() {
- //does the user want to automatically load the CSS (default: yes)?
- //we also test if it hasn't been already loaded by another instance
- //see below for a better (second) test
- if(this._options.loadSkin && !WYMeditor.SKINS[this._options.skin]) {
- //check if it hasn't been already loaded
- //so we don't load it more than once
- //(we check the existing <link> elements)
- var found = false;
- var rExp = new RegExp(this._options.skin
- + '\/' + WYMeditor.SKINS_DEFAULT_CSS + '$');
- jQuery('link').each( function() {
- if(this.href.match(rExp)) found = true;
- });
- //load it, using the skin path
- if(!found) WYMeditor.loadCss( this._options.skinPath
- + WYMeditor.SKINS_DEFAULT_CSS );
- }
- //put the classname (ex. wym_skin_default) on wym_box
- jQuery(this._box).addClass( "wym_skin_" + this._options.skin );
- //does the user want to use some JS to initialize the skin (default: yes)?
- //also check if it hasn't already been loaded by another instance
- if(this._options.initSkin && !WYMeditor.SKINS[this._options.skin]) {
- eval(jQuery.ajax({url:this._options.skinPath
- + WYMeditor.SKINS_DEFAULT_JS, async:false}).responseText);
- }
- //init the skin, if needed
- if(WYMeditor.SKINS[this._options.skin]
- && WYMeditor.SKINS[this._options.skin].init)
- WYMeditor.SKINS[this._options.skin].init(this);
- };
- /********** DIALOGS **********/
- WYMeditor.INIT_DIALOG = function(index) {
- var wym = window.opener.WYMeditor.INSTANCES[index];
- var doc = window.document;
- var selected = wym.selected();
- var dialogType = jQuery(wym._options.dialogTypeSelector).val();
- var sStamp = wym.uniqueStamp();
- switch(dialogType) {
- case WYMeditor.DIALOG_LINK:
- //ensure that we select the link to populate the fields
- if(selected && selected.tagName && selected.tagName.toLowerCase != WYMeditor.A)
- selected = jQuery(selected).parentsOrSelf(WYMeditor.A);
- //fix MSIE selection if link image has been clicked
- if(!selected && wym._selected_image)
- selected = jQuery(wym._selected_image).parentsOrSelf(WYMeditor.A);
- break;
- }
- //pre-init functions
- if(jQuery.isFunction(wym._options.preInitDialog))
- wym._options.preInitDialog(wym,window);
- //add css rules from options
- var styles = doc.styleSheets[0];
- var aCss = eval(wym._options.dialogStyles);
- wym.addCssRules(doc, aCss);
- //auto populate fields if selected container (e.g. A)
- if(selected) {
- jQuery(wym._options.hrefSelector).val(jQuery(selected).attr(WYMeditor.HREF));
- jQuery(wym._options.srcSelector).val(jQuery(selected).attr(WYMeditor.SRC));
- jQuery(wym._options.titleSelector).val(jQuery(selected).attr(WYMeditor.TITLE));
- jQuery(wym._options.altSelector).val(jQuery(selected).attr(WYMeditor.ALT));
- }
- //auto populate image fields if selected image
- if(wym._selected_image) {
- jQuery(wym._options.dialogImageSelector + " " + wym._options.srcSelector)
- .val(jQuery(wym._selected_image).attr(WYMeditor.SRC));
- jQuery(wym._options.dialogImageSelector + " " + wym._options.titleSelector)
- .val(jQuery(wym._selected_image).attr(WYMeditor.TITLE));
- jQuery(wym._options.dialogImageSelector + " " + wym._options.altSelector)
- .val(jQuery(wym._selected_image).attr(WYMeditor.ALT));
- }
- jQuery(wym._options.dialogLinkSelector + " "
- + wym._options.submitSelector).click(function() {
- var sUrl = jQuery(wym._options.hrefSelector).val();
- if(sUrl.length > 0) {
- wym._exec(WYMeditor.CREATE_LINK, sStamp);
- jQuery("a[@href=" + sStamp + "]", wym._doc.body)
- .attr(WYMeditor.HREF, sUrl)
- .attr(WYMeditor.TITLE, jQuery(wym._options.titleSelector).val());
- }
- window.close();
- });
- jQuery(wym._options.dialogImageSelector + " "
- + wym._options.submitSelector).click(function() {
- var sUrl = jQuery(wym._options.srcSelector).val();
- if(sUrl.length > 0) {
- wym._exec(WYMeditor.INSERT_IMAGE, sStamp);
- jQuery("img[@src=" + sStamp + "]", wym._doc.body)
- .attr(WYMeditor.SRC, sUrl)
- .attr(WYMeditor.TITLE, jQuery(wym._options.titleSelector).val())
- .attr(WYMeditor.ALT, jQuery(wym._options.altSelector).val());
- }
- window.close();
- });
- jQuery(wym._options.dialogTableSelector + " "
- + wym._options.submitSelector).click(function() {
- var iRows = jQuery(wym._options.rowsSelector).val();
- var iCols = jQuery(wym._options.colsSelector).val();
- if(iRows > 0 && iCols > 0) {
- var table = wym._doc.createElement(WYMeditor.TABLE);
- var newRow = null;
- var newCol = null;
- var sCaption = jQuery(wym._options.captionSelector).val();
- //we create the caption
- var newCaption = table.createCaption();
- newCaption.innerHTML = sCaption;
- //we create the rows and cells
- for(x=0; x<iRows; x++) {
- newRow = table.insertRow(x);
- for(y=0; y<iCols; y++) {newRow.insertCell(y);}
- }
- //set t…
Large files files are truncated, but you can click here to view the full file