onOpenDialog = function(dialog) {
(dialog = $('.ui-dialog')).find('.ui-dialog-titlebar').corner('1px top');
if(!$.browser.msie){
dialog.corner('6px');
}
if (dialog.height() < $(window).height()) {
if(iframed()) {
$(parent.document.body).addClass('hide-overflow');
} else {
$(document.body).addClass('hide-overflow');
}
}
};
onCloseDialog = function(dialog) {
if(iframed()) {
$(parent.document.body).removeClass('hide-overflow');
} else {
$(document.body).removeClass('hide-overflow');
}
};
WYMeditor.onload_functions = [];
var wymeditor_inputs = [];
var wymeditors_loaded = 0;
// supply custom_wymeditor_boot_options if you want to override anything here.
if (typeof(custom_wymeditor_boot_options) == "undefined") { custom_wymeditor_boot_options = {}; }
var form_actions =
"
";
var wymeditor_boot_options = $.extend({
skin: 'refinery'
, basePath: "/"
, wymPath: "/javascripts/wymeditor/jquery.refinery.wymeditor.js"
, cssSkinPath: "/stylesheets/wymeditor/skins/"
, jsSkinPath: "/javascripts/wymeditor/skins/"
, langPath: "/javascripts/wymeditor/lang/"
, iframeBasePath: '/'
, classesItems: [
{name: 'text-align', rules:[{name: 'left', title: '{Left}'}, {name: 'center', title: '{Center}'}, {name: 'right', title: '{Right}'}, {name: 'justify', title: '{Justify}'}], join: '-', title: '{Text_Align}'}
, {name: 'image-align', rules:[{name: 'left', title: '{Left}'}, {name: 'right', title: '{Right}'}], join: '-', title: '{Image_Align}'}
, {name: 'font-size', rules:[{name: 'small', title: '{Small}'}, {name: 'normal', title: '{Normal}'}, {name: 'large', title: '{Large}'}], join: '-', title: '{Font_Size}'}
]
, 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'}
]
, toolsItems: [
{'name': 'Bold', 'title': 'Bold', 'css': 'wym_tools_strong'}
,{'name': 'Italic', 'title': 'Emphasis', 'css': 'wym_tools_emphasis'}
,{'name': 'InsertUnorderedList', 'title': 'Unordered_List', 'css': 'wym_tools_unordered_list'}
,{'name': 'InsertOrderedList', 'title': 'Ordered_List', 'css': 'wym_tools_ordered_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'}
]
,toolsHtml: ""
,toolsItemHtml:
""
+ ""
+ WYMeditor.TOOL_TITLE
+ ""
+ ""
, classesHtml: ""
, classesItemHtml: ""+ WYMeditor.CLASS_TITLE+ ""
, classesItemHtmlMultiple: ""
+ "" + WYMeditor.CLASS_TITLE + ""
+ ""
+""
, containersHtml: "" + WYMeditor.CONTAINERS_ITEMS + "
"
, containersItemHtml:
""
+ ""
+ ""
, boxHtml:
""
+ "
"
+ WYMeditor.CONTAINERS
+ WYMeditor.TOOLS
+ WYMeditor.CLASSES
+ "
"
+ "
"
+ WYMeditor.HTML
+ WYMeditor.IFRAME
+ WYMeditor.STATUS
+ "
"
+ "
"
, iframeHtml:
""
+ ""
+"
"
, dialogImageHtml: ""
, dialogLinkHtml: ""
, dialogTableHtml:
""
, dialogPasteHtml:
""
, dialogPath: "/refinery/dialogs/"
, dialogFeatures: {
width: 866
, height: 455
, modal: true
, draggable: true
, resizable: false
, autoOpen: true
, open: onOpenDialog
, close: onCloseDialog
}
, dialogInlineFeatures: {
width: 600
, height: 485
, modal: true
, draggable: true
, resizable: false
, autoOpen: true
, open: onOpenDialog
, close: onCloseDialog
}
, dialogId: 'editor_dialog'
, dialogHtml:
""
+ ""
+ ""
+ ""
+ "" + WYMeditor.DIALOG_TITLE + ""
+ ""
+ ""
+ ""
+ ""
+ "" + WYMeditor.DIALOG_BODY + "
"
+ ""
+ ""
, postInit: function(wym)
{
// register loaded
wymeditors_loaded += 1;
// fire loaded if all editors loaded
if(WYMeditor.INSTANCES.length == wymeditors_loaded){
$('.wym_loading_overlay').remove();
// load any functions that have been registered to happen onload.
// these will have to be registered BEFORE postInit is fired (which is fairly quickly).
for(i=0; i < WYMeditor.onload_functions.length; i++) {
WYMeditor.onload_functions[i]();
}
}
$(wym._iframe).contents().find('body').addClass('wym_iframe_body');
$('.field.hide-overflow').removeClass('hide-overflow').css('height', 'auto');
}
, postInitDialog: function(wym) {
if($.browser.msie) {
($the_ui_dialog = $('.ui-dialog')).css('height',
$the_ui_dialog.find('iframe').height()
+ $the_ui_dialog.find('iframe').contents().find('.form-actions').height()
- 12
);
}
}
, lang: (typeof(I18n.locale) != "undefined" ? I18n.locale : 'en')
}, custom_wymeditor_boot_options);
WYMeditor.editor.prototype.loadIframe = function(iframe) {
var wym = this;
// Internet explorer doesn't like this (which versions??)
var doc = (iframe.contentDocument || iframe.contentWindow);
if(doc.document) {
doc = doc.document;
}
if (!$.browser.msie) {
doc.open('text/html', 'replace');
html = "\
\
\
WYMeditor\
\
\
\
\
\
";
doc.write(html);
doc.close();
var doc_head = doc.head || $(doc).find('head').get(0);
$.each(["wymeditor/skins/refinery/wymiframe", "formatting", "refinery/theme", "theme"], function(i, href) {
$("").appendTo(doc_head);
});
}
if ((id_of_editor = wym._element.parent().attr('id')) != null) {
$(doc.body).addClass(id_of_editor);
}
wym.initIframe(iframe);
};
WYMeditor.init = function() {
wymeditor_inputs = $('.wymeditor').filter(function(index) {
for (i=0; i < WYMeditor.INSTANCES.length; i++) {
if (WYMeditor.INSTANCES[i]._element.attr('id') == $(this).attr('id')) {
return false;
}
}
return true;
});
wymeditor_inputs.each(function(input) {
if ((containing_field = $(this).parents('.field')).length > 0 && containing_field.get(0).style.height.replace('auto', '') === '') {
containing_field.addClass('hide-overflow')
.css('height', $(this).outerHeight() - containing_field.offset().top + $(this).offset().top + 45);
}
$(this).hide();
});
wymeditor_inputs.wymeditor(wymeditor_boot_options);
};
$(function(){
WYMeditor.init();
});