2012-05-16 07:33:54 +00:00
|
|
|
function load_tinymce() {
|
|
|
|
$('.tinymce_textarea').tinymce({
|
|
|
|
|
|
|
|
// General options
|
|
|
|
theme: 'advanced',
|
|
|
|
file_browser_callback : 'myFileBrowser',
|
|
|
|
plugins : "autolink,lists,pagebreak,style,layer,table,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave",
|
|
|
|
|
|
|
|
// Theme options
|
|
|
|
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,fontselect,fontsizeselect",
|
|
|
|
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,bullist,numlist,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,forecolor,backcolor",
|
|
|
|
theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,fullscreen",
|
|
|
|
theme_advanced_toolbar_location : "top",
|
|
|
|
theme_advanced_toolbar_align : "left",
|
|
|
|
theme_advanced_statusbar_location : "bottom",
|
|
|
|
theme_advanced_resizing : true,
|
|
|
|
|
|
|
|
// Skin options
|
|
|
|
skin : "o2k7",
|
|
|
|
skin_variant : "silver",
|
|
|
|
|
|
|
|
// Drop lists for link/image/media/template dialogs
|
|
|
|
template_external_list_url : "js/template_list.js",
|
|
|
|
// external_link_list_url : "js/link_list.js",
|
|
|
|
// external_image_list_url : "js/image_list.js",
|
|
|
|
// media_external_list_url : "js/media_list.js"
|
|
|
|
|
|
|
|
// Style formats
|
|
|
|
style_formats : [
|
|
|
|
{title : 'Bold text', inline : 'b'},
|
|
|
|
{title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},
|
|
|
|
{title : 'Red header', block : 'h1', styles : {color : '#ff0000'}},
|
|
|
|
{title : 'Example 1', inline : 'span', classes : 'example1'},
|
|
|
|
{title : 'Example 2', inline : 'span', classes : 'example2'},
|
|
|
|
{title : 'Table styles'},
|
|
|
|
{title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}
|
|
|
|
],
|
|
|
|
|
|
|
|
// Replace values for the template plugin
|
|
|
|
template_replace_values : {
|
|
|
|
username : "Some User",
|
|
|
|
staffid : "991234"
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
function myFileBrowser(field_name, url, type, win) {
|
|
|
|
var cmsURL = window.location.toString();
|
|
|
|
cmsURL = cmsURL.split("/");
|
2012-05-16 22:28:29 +00:00
|
|
|
cmsURL = "<%= Rails.application.routes.url_helpers.file_upload_admin_assets_path %>";
|
2012-08-07 09:32:15 +00:00
|
|
|
// console.log(cmsURL);
|
2012-05-16 07:33:54 +00:00
|
|
|
// script URL - use an absolute path!
|
|
|
|
if (cmsURL.indexOf("?") < 0) {
|
|
|
|
//add the type as the only query parameter
|
|
|
|
cmsURL = cmsURL + "?type=" + type;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
//add the type as an additional query parameter
|
|
|
|
// (PHP session ID is now included if there is one at all)
|
|
|
|
cmsURL = cmsURL + "&type=" + type;
|
|
|
|
}
|
|
|
|
|
|
|
|
tinyMCE.activeEditor.windowManager.open({
|
|
|
|
file : cmsURL,
|
|
|
|
title : 'File Browser',
|
2012-05-17 12:19:31 +00:00
|
|
|
width : 530, // Your dimensions may differ - toy around with them!
|
|
|
|
height : 350,
|
2012-05-16 07:33:54 +00:00
|
|
|
resizable : "no",
|
|
|
|
inline : "no", // This parameter only has an effect if you use the inlinepopups plugin!
|
|
|
|
close_previous : "no"
|
|
|
|
}, {
|
|
|
|
window : win,
|
2012-05-16 08:22:50 +00:00
|
|
|
input : field_name,
|
2012-05-17 12:19:31 +00:00
|
|
|
alt : "alt",
|
|
|
|
title : "title"
|
2012-05-16 07:33:54 +00:00
|
|
|
});
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
function ajaxSave() {
|
|
|
|
var ed = tinyMCE.get('content');
|
|
|
|
// Do you ajax call here, window.setTimeout fakes ajax call
|
|
|
|
ed.setProgressState(1); // Show progress
|
|
|
|
window.setTimeout(function() {
|
|
|
|
ed.setProgressState(0); // Hide progress
|
|
|
|
alert(ed.getContent());
|
|
|
|
}, 3000);
|
|
|
|
}
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
load_tinymce();
|
|
|
|
});
|