为此,我编写了插件jquery.cleditor.fullscreen.js (与jquery.cleditor.js位于同一位置)
(function($) {
//Style for fullscreen mode
var fullscreen = 'height: 100%; left: 0; position: fixed; top: 0; width: 100%; z-index: 9999;',
style = '';
// Define the fullscreen button
$.cleditor.buttons.fullscreen = {
name: 'fullscreen',
image: 'fullscreen.gif',
title: 'Fullscreen',
command: '',
popupName: '',
popupClass: '',
popupContent: '',
getPressed: fullscreenGetPressed,
buttonClick: fullscreenButtonClick,
};
// Add the button to the default controls before the bold button
$.cleditor.defaultOptions.controls = $.cleditor.defaultOptions.controls.replace("bold", "fullscreen | bold");
function fullscreenGetPressed(data) {
return data.editor.$main.hasClass('fullscreen');
};
function fullscreenButtonClick(e, data) {
var main = data.editor.$main;
if (main.hasClass('fullscreen')) main.attr('style', style).removeClass('fullscreen');
else {
style = main.attr('style');
main.attr('style', fullscreen).addClass('fullscreen');
};
editor.focus();
return false;
}
})(jQuery);
在 cleditor images文件夹中,我放了fullscreen.gif
。比在jquery.cleditor.js之后的我的html的head部分中添加这个插件。