You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
2.7 KiB
97 lines
2.7 KiB
3 years ago
|
/* ------------------------------------------------------------------------------
|
||
|
*
|
||
|
* # CKEditor editor
|
||
|
*
|
||
|
* Specific JS code additions for editor_ckeditor.html page
|
||
|
*
|
||
|
* Version: 1.0
|
||
|
* Latest update: Aug 1, 2015
|
||
|
*
|
||
|
* ---------------------------------------------------------------------------- */
|
||
|
|
||
|
$(function() {
|
||
|
|
||
|
// Full featured editor
|
||
|
CKEDITOR.replace( 'editor-full', {
|
||
|
height: '400px',
|
||
|
extraPlugins: 'forms'
|
||
|
});
|
||
|
|
||
|
|
||
|
|
||
|
// Readonly editor
|
||
|
// ------------------------------
|
||
|
|
||
|
// Setup
|
||
|
var editor = CKEDITOR.replace('editor-readonly', {
|
||
|
height: '400px'
|
||
|
});
|
||
|
|
||
|
// The instanceReady event is fired, when an instance of CKEditor has finished its initialization.
|
||
|
CKEDITOR.on('instanceReady', function (ev) {
|
||
|
|
||
|
// Show this "on" button.
|
||
|
document.getElementById('readOnlyOn').style.display = '';
|
||
|
|
||
|
// Event fired when the readOnly property changes.
|
||
|
editor.on('readOnly', function() {
|
||
|
document.getElementById('readOnlyOn').style.display = this.readOnly ? 'none' : '';
|
||
|
document.getElementById('readOnlyOff').style.display = this.readOnly ? '' : 'none';
|
||
|
});
|
||
|
});
|
||
|
|
||
|
// Toggle state
|
||
|
function toggleReadOnly(isReadOnly) {
|
||
|
editor.setReadOnly(isReadOnly);
|
||
|
}
|
||
|
document.getElementById('readOnlyOn').onclick=function(){ toggleReadOnly() }
|
||
|
document.getElementById('readOnlyOff').onclick=function(){ toggleReadOnly(false) }
|
||
|
|
||
|
|
||
|
|
||
|
// Enter key configuration
|
||
|
// ------------------------------
|
||
|
|
||
|
// Define editor
|
||
|
var editor2;
|
||
|
|
||
|
// Setup editor
|
||
|
function changeEnter() {
|
||
|
// If we already have an editor, let's destroy it first.
|
||
|
if (editor2)
|
||
|
editor2.destroy(true);
|
||
|
|
||
|
// Create the editor again, with the appropriate settings.
|
||
|
editor2 = CKEDITOR.replace('editor-enter', {
|
||
|
height: '400px',
|
||
|
extraPlugins: 'enterkey',
|
||
|
enterMode: Number(document.getElementById('xEnter').value),
|
||
|
shiftEnterMode: Number(document.getElementById('xShiftEnter').value)
|
||
|
});
|
||
|
}
|
||
|
|
||
|
// Run on indow load
|
||
|
window.onload = changeEnter;
|
||
|
|
||
|
// Change configuration
|
||
|
document.getElementById('xEnter').onchange=function(){changeEnter()}
|
||
|
document.getElementById('xShiftEnter').onchange=function(){changeEnter()}
|
||
|
|
||
|
// We are using Select2 selects here
|
||
|
$('.select').select2({
|
||
|
minimumResultsForSearch: Infinity
|
||
|
})
|
||
|
|
||
|
|
||
|
|
||
|
// Inline editor
|
||
|
// ------------------------------
|
||
|
|
||
|
// We need to turn off the automatic editor creation first
|
||
|
CKEDITOR.disableAutoInline = true;
|
||
|
|
||
|
// Attach editor to the area
|
||
|
var editor3 = CKEDITOR.inline('editor-inline');
|
||
|
|
||
|
});
|