File: D:/HostingSpaces/SBogers68/resortouddorpduin.nl/wwwroot/kms/public/js/tinymce.js
var isFocused = false;
$(document).ready(function(){
/*
* Tiny MCE
*/
$('textarea.tiny_mce').tinymce({
// general options
entity_encoding : "raw",
mode : "textareas",
theme : "motheme",
skin : "mikeontwerpt",
width : "380",
height : "370",
plugins : "inlinepopups,tabfocus,paste",
// Theme options
theme_motheme_buttons1 : "bold,italic,underline,|,bullist,numlist,|,link,unlink,|,formatselect",
theme_motheme_buttons2 : "",
theme_motheme_buttons3 : "",
theme_motheme_buttons4 : "",
theme_motheme_blockformats : "h2,blockquote",
theme_motheme_toolbar_location : "top",
theme_motheme_toolbar_align : "left",
theme_motheme_statusbar_location : "bottom",
theme_motheme_resizing : false,
setup: function(ed){
ed.onInit.add(function(ed){
// Get value from editor
var val = ed.getContent();
val = val.replace(/(<([^>]+)>)/ig,"");
// Get data-label attr
var id = ed.id;
var label = $('#'+id).attr('data-label');
// Functions
tinyMceInitReset(ed,label);
$(ed.getDoc()).contents().find('body').focus(function(){tinyMceFocus(ed, label);});
$(ed.getDoc()).contents().find('body').blur(function(){tinyMceBlur(ed, label);});
});
}
});
/*
* Insert shortCode in tiny mce
*/
$('.insert_image_link').click(function(){ insertShortCode(this,'image'); });
$('.insert_video_link').click(function(){ insertShortCode(this,'video'); });
});
function tinyMceInitReset(ed,label)
{
// Get new value from editor
var val = ed.getContent();
val = val.replace(/(<([^>]+)>)/ig,"");
if(val != label)
{
var body = ed.getBody();
$(body).addClass("active");
}
}
function tinyMceFocus(ed,label)
{
var body = ed.getBody();
$(body).addClass("active");
isFocused = ed;
var val = ed.getContent();
val = val.replace(/(<([^>]+)>)/ig,"");
if(val == label)
{
ed.setContent('');
}
}
function tinyMceBlur(ed,label)
{
// Get new value from editor
var val = ed.getContent();
val = val.replace(/(<([^>]+)>)/ig,"");
if(val == '')
{
ed.setContent(label);
var body = ed.getBody();
$(body).removeClass("active");
}
}
function insertShortCode(obj,pre)
{
if(isFocused)
{
var sc = $(obj).attr('data-sc');
console.log(sc);
var insert = '['+pre+'_'+sc+']';
isFocused.execCommand('mceInsertContent', false, insert);
}
}