o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1364311663.021926:@value"x§{I"
class:EFI"BundledAsset; FI"logical_path; FI"refinery/wymeditor.js; TI"
pathname; FI"ˆ/Users/johanfrolich/.rvm/gems/ruby-1.9.3-p327@refinerycms-menus/gems/refinerycms-core-2.0.9/app/assets/javascripts/refinery/wymeditor.js; TI"content_type; FI"application/javascript; FI"
mtime; FI"2013-02-04T15:34:04+01:00; FI"length; Fib¥I"digest; F"%fb3dbf0925eb88ebc8d30cd0e0632eafI"source; FI"b¥if(!WYMeditor) { var WYMeditor = {}; }
//Wrap the Firebug console in WYMeditor.console
(function() {
if ( !window.console || !console.firebug ) {
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
WYMeditor.console = {};
for (var i = 0; i < names.length; ++i)
WYMeditor.console[names[i]] = function() {};
} else { WYMeditor.console = window.console; }
})();
$.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' dialog type.
BOLD - Command: (un)set selection to .
ITALIC - Command: (un)set selection to .
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-rc1-refinery",
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 : "/assets/wymeditor/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",
TARGET : "target",
ALT : "alt",
REL : 'rel',
DIALOG_LINK : "Link",
DIALOG_IMAGE : "Image",
DIALOG_TABLE : "Table",
DIALOG_PASTE : "Paste_From_Word",
DIALOG_CLASS : "Css_Class",
BOLD : "Bold",
ITALIC : "Italic",
CREATE_LINK : "CreateLink",
INSERT_IMAGE : "InsertImage",
INSERT_TABLE : "InsertTable",
INSERT_HTML : "InsertHTML",
APPLY_CLASS : "Apply_Style",
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", "meter",
"section", "article", "aside", "details", "header", "footer",
"nav", "dialog", "figure", "figcaption", "address", "hgroup",
"mark", "time", "canvas", "audio", "video", "source", "output",
"progress", "ruby", "rt", "rp", "summary", "command"),
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:
" + contentAfterBreak + "{Tools}
"
+ "" + WYMeditor.TOOLS_ITEMS + "
"
+ "{Containers}
"
+ ""
+ WYMeditor.CONTAINERS_ITEMS
+ "
"
+ "{Classes}
"
+ WYMeditor.CLASSES_ITEMS
+ "
{Status}
"
+"{Source_Code}
"
+ ""
+"
tag that appears when empty.
html = html.replace(/^
$/, '')
// apply changes/
$(wym._element).val(html);
$(wym._box).find(wym._options.htmlValSelector).not('.hasfocus').val(html); //#147
};
/* @name dialog
* @description Opens a dialog box
*/
WYMeditor.editor.prototype.dialog = function( dialogType ) {
var wym = this;
wym.update();
var path = this._wym._options.dialogPath + dialogType + '?wymeditor=true&' + window.location.href.match(/switch_locale=[a-z]{2}/);
wym._current_unique_stamp = wym.uniqueStamp();
// change undo or redo on cancel to true to have this happen when a user closes (cancels) a dialogue
wym._undo_on_cancel = false;
wym._redo_on_cancel = false;
var selected = this.selected();
//set to P if parent = BODY unless it's a table going in there.
if (dialogType != WYMeditor.DIALOG_TABLE) {
wym.format_block();
}
if (dialogType == WYMeditor.DIALOG_LINK && $.browser.mozilla) {
selection = wym._iframe.contentWindow.getSelection();
matches = $($(selected).html().match(new RegExp(RegExp.escape(selection.anchorNode.textContent) + "(.*)" + RegExp.escape(selection.focusNode.textContent))));
if (matches != null && matches.length > 0 && (possible_anchor_tag = matches.last()).length > 0)
{
if (((href_matches = possible_anchor_tag.get(0).match(/href="([^"]*)"/)) != null) && (href = $(href_matches).last().get(0)) != null)
{
$(wym._doc).find('a').each(function(index, possible_match)
{
if ($(possible_match).html() == selection)
{
selected = possible_match;
}
});
}
}
}
ajax_loaded_callback = function(){wym.dialog_ajax_callback(selected);};
var parent_node = wym._selected_image ? wym._selected_image.parentNode : selected;
if (typeof(parent_node) != 'undefined' && parent_node !== null) {
if (parent_node.tagName.toLowerCase() != WYMeditor.A) {
// wrap the current selection with a funky span.
if (wym._selected_image == null)
{
if (selected != null && selected.tagName.toLowerCase() != WYMeditor.A && wym._iframe.contentWindow.getSelection) {
// Fixes webkit issue where it would not paste at cursor.
selection = wym._iframe.contentWindow.getSelection();
if (selection.focusNode.insertData) {
// if you highlight backwards, it reverses the order of the anchorNode and focusNode / anchorOffset and focusOffset.
// anchorOffset is where you started the selection, focusOffset is where you ended the selection.
// So, if you highlight forwards then {anchorOffset}some text{focusOffset}
// But, if you highlight backwards then {focusOffset}some text{anchorOffset}
if (selection.anchorOffset > selection.focusOffset) {
start_node = selection.focusNode;
start = selection.focusOffset;
end_node = selection.anchorNode;
end = selection.anchorOffset;
} else {
start_node = selection.anchorNode;
start = selection.anchorOffset;
end_node = selection.focusNode;
end = selection.focusOffset;
}
// for https://github.com/refinery/refinerycms/issues/581
if (typeof (start_node.insertData) === 'undefined') {
var j = start_node.childNodes.length - 1,
tmp_start_node = start_node;
// @todo what then if function insertData is not found?
while (typeof(end_node.insertData) !== 'function' || !j) {
start_node = tmp_start_node.childNodes[j--];
}
start = 0;
}
if (typeof (end_node.insertData) === 'undefined') {
var i = end_node.childNodes.length - 1,
tmp_end_node = end_node;
while (typeof(end_node.insertData) !== 'function' || !i) {
end_node = tmp_end_node.childNodes[i--];
}
end = end_node.length;
}
// because .insertData only inserts text, we have to insert some 'meaningful' *text* only interpolation tags (no html).
start_tag = '%%' + wym._current_unique_stamp + '%%';
end_tag = '$$' + wym._current_unique_stamp + '$$';
// sometimes we may be crossing multiple "nodes" so a simple test for whether this is the case.
// this is important, see this example:
// some text with some link and then more text
// {start_node}some text {end_start_node}{anotherNode}with some link{end_anotherNode}{end_node} and then more text{end_end_node}
// the "start_node" is a separate node to the end node and therefore we can't treat them as one long node anymore.
if (start_node === end_node) {
end = end + start_tag.length;
}
// Insert the 'meaningful' text interpolation tags.
start_node.insertData(start, start_tag);
end_node.insertData(end, end_tag);
// Now that we can use HTML again, replace the simple text with a span tag.
$(selected).html($(selected).html().replace(start_tag, "")
.replace(end_tag, ""));
} else {
wym.wrap("", "");
}
} else {
wym.wrap("", "");
}
}
}
else {
if (!wym._selected_image) {
parent_node._id_before_replaceable = parent_node.id;
parent_node.id = '' + this._current_unique_stamp;
$(parent_node).attr("_id_before_replaceable", parent_node._id_before_replaceable);
}
if (dialogType != WYMeditor.DIALOG_PASTE && dialogType != WYMeditor.DIALOG_TABLE) {
path += path.indexOf("?") == -1 ? "?" : "&";
port = (window.location.port.length > 0 ? (":" + window.location.port) : "");
path += "current_link=" + parent_node.href.replace(window.location.protocol + "//" + window.location.hostname + port, "");
path += "&target_blank=" + (parent_node.target == "_blank" ? "true" : "false");
}
}
}
// launch dialog
dialog_title = wym.replaceStrings(wym.encloseString( dialogType ));
dialog_container = $("");
switch(dialogType) {
case WYMeditor.DIALOG_TABLE:
// create and open dialog
dialog_container.html(wym.replaceStrings(wym._options.dialogTableHtml))
.dialog($.extend(wym._options.dialogInlineFeatures, {
title: dialog_title
}));
ajax_loaded_callback();
break;
case WYMeditor.DIALOG_PASTE:
dialog_container.html(wym.replaceStrings(wym._options.dialogPasteHtml))
.dialog($.extend(wym._options.dialogInlineFeatures, {
title: dialog_title
}));
ajax_loaded_callback();
break;
default:
$("").appendTo(dialog_container);
dialog_container.dialog($.extend(wym._options.dialogFeatures, {
title: dialog_title
})).load(path, ajax_loaded_callback);
break;
}
};
WYMeditor.editor.prototype.dialog_ajax_callback = function(selected) {
// set variables
wym = this; _selected = selected;
// now fix the height;
$("#" + wym._options.dialogId + ".editor_dialog").css('height', 'auto');
// add corners to the buttons.
$('#' + wym._options.dialogId + " .button").corner('6px');
// look for iframes
(iframes = $("#" + this._options.dialogId).find('iframe')).load(function() {
WYMeditor.INIT_DIALOG(wym, _selected, true);
$(this).unbind('load');
});
if (iframes.length == 0) {
WYMeditor.INIT_DIALOG(this, selected);
}
};
/* @name toggleHtml
* @description Shows/Hides the HTML
*/
WYMeditor.editor.prototype.toggleHtml = function() {
$(this._box).find(this._options.htmlSelector).toggle();
};
WYMeditor.editor.prototype.uniqueStamp = function() {
return("wym-" + new Date().getTime());
};
WYMeditor.editor.prototype.paste = function(sData) {
wym = this;
wym.format_block();
var sTmp;
replaceable = $(wym._doc.body).find('#' + wym._current_unique_stamp);
// replaceable doesn't actually get replaced here, it's just used as a marker for where the cursor was.
container = replaceable.get(0) || this.selected();
//split the data, using double newlines as the separator
var aP = sData.replace(/&/g, "&").replace(//g, ">").split(wym._newLine + wym._newLine);
var rExp = new RegExp(wym._newLine, "g");
//add a P for each item
if(container && container.tagName.toLowerCase() != WYMeditor.BODY) {
contentAfterBreak = "";
insertedContentAfterBreak = "";
for(x = aP.length - 1; x >= 0; x--) {
//simple newlines are replaced by a break
sTmp = aP[x].replace(rExp, "
");
if (x == 0) {
// if we're inside a p tag but the container is not a p tag
// then we need to close the p tag first before starting a new one.
// Only if we placed more items after it (aP.length)
if (aP.length > 1
&& $(container).get(0).tagName.toLowerCase() == "span"
&& $(container).attr('id') == ('' + wym._current_unique_stamp)
&& $(container).parent().get(0).tagName.toLowerCase() == "p")
{
p = $(container).parent();
matches = p.html().match(new RegExp("([\\s\\S]*)\.*\<\/span\>"));
sTmp = matches[1] + sTmp + $(container).html();
p.html(sTmp);
if (insertedContentAfterBreak != null && insertedContentAfterBreak.length > 0) {
p.after(insertedContentAfterBreak);
}
if (contentAfterBreak != null && contentAfterBreak.length > 0) {
if ((last_paste = p.parent().find('p#last_paste')).length == 1) {
last_paste.attr('id', null).html(last_paste.html() + contentAfterBreak);
} else {
p.next().after("
$/, '') + sTmp);
}
} else {
if ((aP.length -1) == x) {
var rgx = $(container).parent().html().match(new RegExp("\.*\<\/span\>([\\s\\S]*)"));
if(rgx && rgx[1]){
contentAfterBreak = rgx[1].split('
" + sTmp + "
"; } else { sTmp = "" + sTmp + "
"; } if (insertedContentAfterBreak == "") { insertedContentAfterBreak = insertedContentAfterBreak + sTmp; } else { insertedContentAfterBreak = sTmp + insertedContentAfterBreak; } } } } else { for(x = 0; x < aP.length; x++) { sTmp = aP[x]; //simple newlines are replaced by a break sTmp = sTmp.replace(rExp, "" + sTmp + "
"); } } } if (replaceable.get(0) != null) { // set the id of the container back. if (replaceable.get(0).tagName.toLowerCase() == 'span') { replaceable.replaceWith(replaceable.html()); } replaceable.attr('id', replaceable.get(0)._id_before_replaceable || null); } }; 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.wrap = function(left, right, selection) { left = (typeof(left) != 'undefined' ? left : ''); right = (typeof(right) != 'undefined' ? right : ''); // Do we have a selection? if (selection == null) { selection = this._iframe.contentWindow.getSelection();} if (selection.focusNode != null) { // Wrap selection with provided html this._exec( WYMeditor.INSERT_HTML, left + selection.toString() + right); } }; WYMeditor.editor.prototype.unwrap = function(selection) { // Do we have a selection? if (selection == null) { selection = this._iframe.contentWindow.getSelection();} if (selection.focusNode != null) { // Unwrap selection this._exec( WYMeditor.INSERT_HTML, selection.toString() ); } }; WYMeditor.editor.prototype.setFocusToNode = function(node, toStart) { var range = this._doc.createRange(), selection = this._iframe.contentWindow.getSelection(); toStart = toStart ? 0 : 1; range.selectNodeContents(node); selection.addRange(range); selection.collapse(node, toStart); this._iframe.contentWindow.focus(); }; 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); } } } }; WYMeditor.editor.prototype.format_block = function(selected) { //'this' should be the wymeditor instance. var wym = this; var container = selected || wym.selected() || $(wym._iframe).contents().find('body').get(0); var name = container.tagName.toLowerCase(); //fix forbidden main containers if($.inArray(name, ['strong', 'b', 'em', 'i', 'sub', 'sup', 'a']) > -1) { name = container.parentNode.tagName.toLowerCase(); } if(name == WYMeditor.BODY) { wym._selected_image = null; $(wym._iframe).contents().find('.selected_by_wym').removeClass('selected_by_wym'); wym._exec(WYMeditor.FORMAT_BLOCK, WYMeditor.P); } }; /********** CONFIGURATION **********/ WYMeditor.editor.prototype.computeBasePath = function() { if ((script_path = this.computeWymPath()) != null) { if ((src_parts = script_path.split('/')).length > 1) { src_parts.pop(); } return src_parts.join('/') + "/"; } else { return null; } }; WYMeditor.editor.prototype.computeWymPath = function() { return $('script[src*=jquery.refinery.wymeditor]').attr('src'); }; WYMeditor.editor.prototype.computeJqueryPath = function() { return $($.grep($('script'), function(s){ return (s.src && s.src.match(/jquery(-(.*)){0,1}(\.pack|\.min|\.packed)?\.js(\?.*)?$/ )) })).attr('src'); }; WYMeditor.editor.prototype.computeCssPath = function() { return $($.grep($('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($.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 $.find() on the iframe body //because of MSIE + jQuery + expando issue (#JQ1143) //$(this._doc.body).find("*").bind("mouseup", this.mouseup); $(this._doc.body).bind("mousedown", this.mousedown); var images = this._doc.body.getElementsByTagName("img"); for(var i=0; i < images.length; i++) { $(images[i]).bind("mousedown", this.mousedown); } // ensure links can't be navigated to. $(this._doc).find('a[href]').click(function(e){ e.preventDefault(); }); }; WYMeditor.editor.prototype.mousedown = function(e) { var wym = WYMeditor.INSTANCES[this.ownerDocument.title]; wym._selected_image = (e.target.tagName.toLowerCase() == WYMeditor.IMG) ? e.target : null; $(wym._iframe).contents().find('.selected_by_wym').removeClass('selected_by_wym'); if (!$.browser.mozilla) { $(wym._selected_image).addClass('selected_by_wym'); } if (!$.browser.webkit) { e.stopPropagation(); } }; /********** SKINS **********/ /* * 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 elements) var found = false; var rExp = new RegExp(this._options.skin + '\/' + WYMeditor.SKINS_DEFAULT_CSS + '([\?].+?)?$'); $('link').each( function() { if(this.href.match(rExp)) found = true; }); // if not found, load it, using the skin path if(!found) { WYMeditor.loadCss( this._options.cssCompiledSkinPath + WYMeditor.SKINS_DEFAULT_CSS ); } } //put the classname (ex. wym_skin_default) on wym_box $(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($.ajax({url:this._options.jsCompiledSkinPath + 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); } }; /********** XHTML LEXER/PARSER **********/ /* * @name xml * @description Use these methods to generate XML and XHTML compliant tags and * escape tag attributes correctly * @author Bermi Ferrer - http://bermi.org * @author David Heinemeier Hansson http://loudthinking.com */ WYMeditor.XmlHelper = function() { this._entitiesDiv = document.createElement('div'); return this; }; /* * @name tag * @description * Returns an empty HTML tag of type *name* which by default is XHTML * compliant. Setting *open* to true will create an open tag compatible * with HTML 4.0 and below. Add HTML attributes by passing an attributes * array to *options*. For attributes with no value like (disabled and * readonly), give it a value of true in the *options* array. * * Examples: * * this.tag('br') * # =>Hello world!
* this.contentTag('div', this.contentTag('p', "Hello world!"), $({class : "strong"})) * # =>Hello world!