// -- Options overrides -----------------------------------------------------
var cms_wym_options = {
initSkin: false,
lang: $('meta[name="cms-locale"]').attr('content'),
basePath: $('meta[name="cms-js-assets-base-path"]').attr('content') + '/wymeditor/',
wymPath: 'disabled',
jQueryPath: 'disabled',
updateSelector: 'form',
updateEvent: 'submit',
containersItems: [
{ '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': 'P', 'title': 'Paragraph', 'css': 'wym_containers_p' },
{ 'name': 'PRE', 'title': 'Preformatted', 'css': 'wym_containers_pre' }
],
toolsItems: [
{ 'name': 'Bold', 'title': 'Strong', 'css': 'wym_tools_strong' },
{ 'name': 'Italic', 'title': 'Emphasis', 'css': 'wym_tools_emphasis' },
{ 'name': 'InsertOrderedList', 'title': 'Ordered_List', 'css': 'wym_tools_ordered_list' },
{ 'name': 'InsertUnorderedList', 'title': 'Unordered_List', 'css': 'wym_tools_unordered_list' },
{ 'name': 'InsertTable', 'title': 'Table', 'css': 'wym_tools_table' },
{ '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': 'Paste', 'title': 'Paste_From_Word', 'css': 'wym_tools_paste' },
{ 'name': 'ToggleHtml', 'title': 'HTML', 'css': 'wym_tools_html' }
],
classesItems: [
{ 'name': 'align_left', 'title': 'Align_Left', 'expr': '*' },
{ 'name': 'align_center', 'title': 'Align_Center', 'expr': '*' },
{ 'name': 'align_right', 'title': 'Align_Left', 'expr': '*' }
],
dialog: jQuery(jQuery('#cms_dialog').get(0) || jQuery('
')),
boxHtml: ''
+ '
'
+ WYMeditor.CONTAINERS
+ WYMeditor.CLASSES
+ WYMeditor.TOOLS
+ '
'
+ '
'
+ WYMeditor.HTML
+ WYMeditor.IFRAME
+ '
'
+ '
',
containersHtml: '',
toolsHtml: '',
classesHtml: '',
htmlHtml: ''
+ ''
+ '
',
dialogLinkHtml: '',
dialogImageHtml: '',
dialogTableHtml: '',
dialogPasteHtml: ''
};
// -- New dialog pop-up -----------------------------------------------------
WYMeditor.editor.prototype.dialog = function( dialogType, dialogFeatures, bodyHtml ) {
var body = '';
switch(dialogType) {
case WYMeditor.DIALOG_LINK:
body = this._options.dialogLinkHtml;
break;
case WYMeditor.DIALOG_IMAGE:
body = this._options.dialogImageHtml;
break;
case WYMeditor.DIALOG_TABLE:
body = this._options.dialogTableHtml;
break;
case WYMeditor.DIALOG_PASTE:
body = this._options.dialogPasteHtml;
break;
default:
body = bodyHtmls;
}
this._options.dialog.html(this.replaceStrings(body));
this._options.dialog.dialog({
title: this.replaceStrings(this.encloseString(dialogType)),
modal: true,
width: 800,
resizable: false
});
WYMeditor.INIT_DIALOG(this, dialogType);
};
// -- Dialog processing -----------------------------------------------------
WYMeditor.INIT_DIALOG = function(wym, type) {
var form = jQuery('form#wym_dialog_form');
var selected = wym.selected();
if(selected) {
form.find('input[name="href"]').val(jQuery(selected).attr(WYMeditor.HREF));
form.find('input[name="src"]').val(jQuery(selected).attr(WYMeditor.SRC));
form.find('input[name="title"]').val(jQuery(selected).attr(WYMeditor.TITLE));
form.find('input[name="alt"]').val(jQuery(selected).attr(WYMeditor.ALT));
}
if(wym._selected_image) {
form.find('input[name="src"]').val(jQuery(wym._selected_image).attr(WYMeditor.SRC));
form.find('input[name="alt"]').val(jQuery(wym._selected_image).attr(WYMeditor.ALT));
form.find('input[name="title"]').val(jQuery(wym._selected_image).attr(WYMeditor.TITLE));
}
form.submit(function(){
var data = { };
var form_data = $(this).serializeArray();
jQuery.each(form_data, function(){
if (data[this.name] !== undefined) {
if (!data[this.name].push) {
data[this.name] = [data[this.name]];
}
data[this.name].push(this.value || '');
} else {
data[this.name] = this.value || '';
}
});
switch(type){
case WYMeditor.DIALOG_LINK:
WYMeditor.PROCESS_DIALOG_LINK(wym, data);
break;
case WYMeditor.DIALOG_IMAGE:
WYMeditor.PROCESS_DIALOG_IMAGE(wym, data);
break;
case WYMeditor.DIALOG_TABLE:
WYMeditor.PROCESS_DIALOG_TABLE(wym, data);
break;
case WYMeditor.DIALOG_PASTE:
WYMeditor.PROCESS_DIALOG_PASTE(wym, data);
break;
}
wym._options.dialog.dialog('close');
return false;
})
}
WYMeditor.PROCESS_DIALOG_LINK = function(wym, data) {
var sStamp = wym.uniqueStamp();
var selected = wym.selected();
//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);
}
var sUrl = data['href'];
if(sUrl.length > 0) {
var link;
if (selected[0] && selected[0].tagName.toLowerCase() == WYMeditor.A) {
link = selected;
} else {
wym._exec(WYMeditor.CREATE_LINK, sStamp);
link = jQuery("a[href=" + sStamp + "]", wym._doc.body);
}
link.attr(WYMeditor.HREF, sUrl).attr(WYMeditor.TITLE, data['title']);
}
}
WYMeditor.PROCESS_DIALOG_IMAGE = function(wym, data) {
var sStamp = wym.uniqueStamp();
var sUrl = data['src'];
if(sUrl.length > 0) {
wym._exec(WYMeditor.INSERT_IMAGE, sStamp);
jQuery("img[src$=" + sStamp + "]", wym._doc.body)
.attr(WYMeditor.SRC, sUrl)
.attr(WYMeditor.TITLE, data['title'])
.attr(WYMeditor.ALT, data['alt']);
}
}
WYMeditor.PROCESS_DIALOG_TABLE = function(wym, data) {
var iRows = data['rows'];
var iCols = data['cols'];
if(iRows > 0 && iCols > 0) {
var table = wym._doc.createElement(WYMeditor.TABLE);
var newRow = null;
var newCol = null;
var sCaption = data['caption'];
var newCaption = table.createCaption();
newCaption.innerHTML = sCaption;
for(x=0; x)(<)(\/*)/g;
html = html.replace(reg, '$1\r\n$2$3');
return html;
};
/**
* WYMeditor : what you see is What You Mean web-based editor
* Copyright (c) 2005 - 2009 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 Name:
* jquery.wymeditor.embed.js
* Experimental embed plugin
*
* File Authors:
* Jonatan Lundin (jonatan.lundin a-t gmail dotcom)
* Roger Hu (roger.hu a-t gmail dotcom)
* Scott Nixon (citadelgrad a-t gmail dotcom)
*/
(function () {
function removeItem(item, arr) {
for (var i = arr.length; i--;) {
if (arr[i] === item) {
arr.splice(i, 1);
}
}
return arr;
}
if (WYMeditor && WYMeditor.XhtmlValidator._tags.param.attributes) {
WYMeditor.XhtmlValidator._tags.embed = {
"attributes":[
"allowscriptaccess",
"allowfullscreen",
"height",
"src",
"type",
"width"
]
};
WYMeditor.XhtmlValidator._tags.param.attributes = {
'0':'name',
'1':'type',
'valuetype':/^(data|ref|object)$/,
'2':'valuetype',
'3':'value'
};
WYMeditor.XhtmlValidator._tags.iframe = {
"attributes":[
"allowfullscreen",
"width",
"height",
"src",
"title",
"frameborder"
]
};
// Override the XhtmlSaxListener to allow param, embed and iframe.
//
// We have to do an explicit override
// of the function instead of just changing the startup parameters
// because those are only used on creation, and changing them after
// the fact won't affect the existing XhtmlSaxListener
var XhtmlSaxListener = WYMeditor.XhtmlSaxListener;
WYMeditor.XhtmlSaxListener = function () {
var listener = XhtmlSaxListener.call(this);
// param, embed and iframe should be inline tags so that they can
// be nested inside other elements
removeItem('param', listener.block_tags);
listener.inline_tags.push('param');
listener.inline_tags.push('embed');
listener.inline_tags.push('iframe');
return listener;
};
WYMeditor.XhtmlSaxListener.prototype = XhtmlSaxListener.prototype;
}
})();