/*
Plugin for CMSimple
Written 2009 - ESPAS IT, www.espas.ch - Manuel Brotz - Public Domain
*/
(
function () {
function show(obj) {
if (typeof obj == 'object') {
var result = [];
result.push(obj.constructor);
for (var e in obj) {
result.push(e);
}
result.sort();
alert(result.join("\n"));
} else {
alert(obj);
}
}
function is_cmsimple_img(path, img) {
for (var i = 0; i < cmsimple_images.length; i++) {
image = cmsimple_images[i];
if (path + image == img) {
return true;
}
}
return false;
}
function get_cmsimple_img(path, img) {
for (var i = 0; i < cmsimple_images.length; i++) {
image = cmsimple_images[i];
if (path + image == img) {
return image;
}
}
return '';
}
function add_images(b) {
b.ui.addRichCombo('CMSimple_Images', {
label: 'Images',
title: 'Images',
multiSelect: false,
panel: {
css : [ b.config.contentsCss, CKEDITOR.getUrl(b.skinPath + 'editor.css') ]
},
init : function() {
if (cmsimple_images.length > 0) {
this.startGroup(cmsimple_images.length + " Images");
for (var i = 0; i < cmsimple_images.length; i++) {
var image = cmsimple_images[i];
this.add('images/' + image, '' + image + '
', image);
}
} else {
this.startGroup('No Images');
}
},
onClick : function(q) {
b.focus();
b.fire('saveSnapshot');
b.insertHtml('
');
b.fire('saveSnapshot');
},
onRender : function() {
b.on('selectionChange', function(q) {
this.setValue('');
}, this);
}
});
}
function add_downloads(b) {
b.ui.addRichCombo('CMSimple_Downloads', {
label: 'Downloads',
title: 'Downloads',
multiSelect: false,
panel: {
css : [ b.config.contentsCss, CKEDITOR.getUrl(b.skinPath + 'editor.css') ]
},
init : function() {
if (cmsimple_downloads.length > 0) {
this.startGroup(cmsimple_downloads.length + " Downloads");
for (var i = 0; i < cmsimple_downloads.length; i++) {
var download = cmsimple_downloads[i];
this.add(download.title + '|' + download.url, '' + download.title + '', download.url);
}
} else {
this.startGroup("No Downloads");
}
},
onClick : function(q) {
b.focus();
b.fire('saveSnapshot');
var download = q.split('|');
b.insertHtml('' + download[0] + '');
b.fire('saveSnapshot');
},
onRender : function() {
b.on('selectionChange', function(q) {
this.setValue('');
}, this);
}
});
}
CKEDITOR.plugins.add('cmsimple', {
requires: ['richcombo'],
init: function (b) {
add_images(b);
add_downloads(b);
}
});
}
)();