Index: lams_central/web/ckeditor/plugins/bootsnippets/dialogs/snippets.css =================================================================== diff -u --- lams_central/web/ckeditor/plugins/bootsnippets/dialogs/snippets.css (revision 0) +++ lams_central/web/ckeditor/plugins/bootsnippets/dialogs/snippets.css (revision 98d80295ca2398cfef80d796b9581cbc399a4077) @@ -0,0 +1,92 @@ +/* +Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. +For licensing, see LICENSE.md or http://ckeditor.com/license +*/ + +.cke_tpl_list { + border: #dcdcdc 1px solid; + background-color: #ffffff; + overflow-y: auto; + overflow-x: hidden; + width: 100%; + height: 568px; +} +.cke_dialog_contents_body { + padding-top: 10px; +} +#fakeId { + display: none; +} + +.cke_tpl_item +{ + padding: 7px; + border-bottom: 1px solid rgba(128, 128, 128, 0.22); +} + +.cke_tpl_preview +{ + border-collapse: separate; + text-indent:0; + width: 100%; +} +.cke_tpl_preview td +{ + padding: 2px; + vertical-align: middle; +} +.cke_tpl_preview .cke_tpl_preview_img +{ + width: 100px; +} +.cke_tpl_preview span +{ + white-space: normal; +} + +.cke_tpl_title{ + font-size: 16px; +} +.cke_dialog_contents { + background-color: #f3f3f3; +} + +.cke_dialog_contents a:hover { + text-decoration: none; +} + +.cke_tpl_list a:hover .cke_tpl_item, +.cke_tpl_list a:focus .cke_tpl_item, +.cke_tpl_list a:active .cke_tpl_item +{ + background-color: #fffee4; +} + +.cke_tpl_list a:hover *, +.cke_tpl_list a:focus *, +.cke_tpl_list a:active * +{ + cursor: pointer; +} + +/* IE Quirks contextual selectors children will not get :hover transition until + the hover style of the link itself contains certain CSS declarations. */ +.cke_browser_quirks .cke_tpl_list a:active, +.cke_browser_quirks .cke_tpl_list a:hover, +.cke_browser_quirks .cke_tpl_list a:focus +{ + background-position: 0 0; +} + +.cke_hc .cke_tpl_list a:hover .cke_tpl_item, +.cke_hc .cke_tpl_list a:focus .cke_tpl_item, +.cke_hc .cke_tpl_list a:active .cke_tpl_item +{ + border-width: 3px; +} + +.cke_tpl_empty, .cke_tpl_loading +{ + text-align: center; + padding: 5px; +} Index: lams_central/web/ckeditor/plugins/bootsnippets/icons/hidpi/snippets-rtl.png =================================================================== diff -u Binary files differ Index: lams_central/web/ckeditor/plugins/bootsnippets/icons/hidpi/snippets.png =================================================================== diff -u Binary files differ Index: lams_central/web/ckeditor/plugins/bootsnippets/icons/ico_image.ico =================================================================== diff -u Binary files differ Index: lams_central/web/ckeditor/plugins/bootsnippets/icons/ico_photo.gif =================================================================== diff -u Binary files differ Index: lams_central/web/ckeditor/plugins/bootsnippets/icons/ico_text.ico =================================================================== diff -u Binary files differ Index: lams_central/web/ckeditor/plugins/bootsnippets/icons/ico_video.png =================================================================== diff -u Binary files differ Index: lams_central/web/ckeditor/plugins/bootsnippets/icons/snippets-rtl.png =================================================================== diff -u Binary files differ Index: lams_central/web/ckeditor/plugins/bootsnippets/icons/snippets.png =================================================================== diff -u Binary files differ Index: lams_central/web/ckeditor/plugins/bootsnippets/lang/en.js =================================================================== diff -u --- lams_central/web/ckeditor/plugins/bootsnippets/lang/en.js (revision 0) +++ lams_central/web/ckeditor/plugins/bootsnippets/lang/en.js (revision 98d80295ca2398cfef80d796b9581cbc399a4077) @@ -0,0 +1,14 @@ +/* +Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. +For licensing, see LICENSE.md or http://ckeditor.com/license +*/ +CKEDITOR.plugins.setLang( 'bootsnippets', 'en', { + emptyListMsg: '(No snippets defined)', + insertOption: 'Replace actual contents', + options: 'Snippet Options', + title: 'Content snippets', + tableButton: 'Table Snippets', + imageButton: 'Image Snippets', + multimediaButton: 'Multimedia Snippets', + tabsButton: 'Tabs Snippets' +} ); Index: lams_central/web/ckeditor/plugins/bootsnippets/plugin.js =================================================================== diff -u --- lams_central/web/ckeditor/plugins/bootsnippets/plugin.js (revision 0) +++ lams_central/web/ckeditor/plugins/bootsnippets/plugin.js (revision 98d80295ca2398cfef80d796b9581cbc399a4077) @@ -0,0 +1,276 @@ +/** + * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. + * For licensing, see LICENSE.md or http://ckeditor.com/license + */ + +( function() { + + //add all commands, dialogs and buttons specified in ckconfig_custom.js + CKEDITOR.plugins.add( 'bootsnippets', { + requires: 'dialog', + lang: 'en', + hidpi: false, + init: function( editor ) { + var snippetNames = (CKEDITOR.config.bootsnippets).split( ',' ); + var snippetIcons = (CKEDITOR.config.bootsnippets_icons).split( ',' ); + var snippetLabels = (CKEDITOR.config.bootsnippets_labels).split( ',' ); + + if ( snippetNames.length ) { + for ( var i = 0, snippetNamesCount = snippetNames.length; i < snippetNamesCount; i++ ) { + var snippetName = snippetNames[i].trim(); + var snippetIcon = snippetIcons[i].trim(); + var snippetLabel = snippetLabels[i].trim(); + + CKEDITOR.dialog.add( snippetName, bootsnippetDialogHandler ); + editor.addCommand( snippetName, new CKEDITOR.dialogCommand( snippetName ) ); + + editor.ui.addButton && editor.ui.addButton( + snippetName, + { + label: snippetLabel, + command: snippetName, + icon : snippetIcon, + toolbar: 'bootsnippets,'+i + } + ); + } + } + } + } ); + + var bootsnippets = {}, + loadedSnippetsFiles = {}; + + CKEDITOR.addSnippets = function( name, definition ) { + bootsnippets[ name ] = definition; + }; + + CKEDITOR.getSnippets = function( name ) { + return bootsnippets[ name ]; + }; + + CKEDITOR.loadSnippets = function( snippetFiles, callback ) { + // Holds the bootsnippets files to be loaded. + var toLoad = []; + + // Look for pending snippet files to get loaded. + for ( var i = 0, count = snippetFiles.length; i < count; i++ ) { + if ( !loadedSnippetsFiles[ snippetFiles[ i ] ] ) { + toLoad.push( snippetFiles[ i ] ); + loadedSnippetsFiles[ snippetFiles[ i ] ] = 1; + } + } + + if ( toLoad.length ) + CKEDITOR.scriptLoader.load( toLoad, callback ); + else + setTimeout( callback, 0 ); + }; + + //creates dialog for each snippet category + function bootsnippetDialogHandler(editor) { + + // Constructs the HTML view of the specified snippets data. + function renderSnippetsList( container, snippetsDefinitions ) { + // clear loading wait text. + container.setHtml( '' ); + + for ( var i = 0, totalDefs = snippetsDefinitions.length; i < totalDefs; i++ ) { + var definition = CKEDITOR.getSnippets( snippetsDefinitions[ i ] ), + imagesPath = definition.imagesPath, + snippets = definition.snippets, + count = snippets.length; + + for ( var j = 0; j < count; j++ ) { + var snippet = snippets[ j ], + item = createSnippetItem( snippet, imagesPath ); + item.setAttribute( 'aria-posinset', j + 1 ); + item.setAttribute( 'aria-setsize', count ); + container.append( item ); + } + } + } + + function createSnippetItem( snippet, imagesPath ) { + var item = CKEDITOR.dom.element.createFromHtml( '' + + '
' + + '
' ); + + // Build the inner HTML of our new item DIV. + var html = ''; + + html += ''; + + if ( snippet.image && imagesPath ) { + html += ''; + } + + html += ''; + + item.getFirst().setHtml( html ); + + item.on( 'click', function() { + var htmlToInsert = ""; + if (snippet.css) { + htmlToInsert += ''; + } + htmlToInsert += snippet.html; + htmlToInsert += '
 
'; + + insertSnippet(htmlToInsert); + } ); + + return item; + } + + // Insert the specified snippet content into editor. + // @param {Number} index + function insertSnippet( html ) { + var dialog = CKEDITOR.dialog.getCurrent(), + isReplace = dialog.getValueOf( 'selectTpl', 'chkInsertOpt' ); + + if ( isReplace ) { + editor.fire( 'saveSnapshot' ); + // Everything should happen after the document is loaded (#4073). + editor.setData( html, function() { + dialog.hide(); + + // Place the cursor at the first editable place. + var range = editor.createRange(); + range.moveToElementEditStart( editor.editable() ); + range.select(); + setTimeout( function() { + editor.fire( 'saveSnapshot' ); + }, 0 ); + + } ); + } else { + editor.insertHtml( html ); + dialog.hide(); + } + } + + // Load skin at first. + var plugin = CKEDITOR.plugins.get( 'bootsnippets' ); + CKEDITOR.document.appendStyleSheet( CKEDITOR.getUrl( plugin.path + 'dialogs/snippets.css' ) ); + + + var listContainer; + + var snippetListLabelId = 'cke_tpl_list_label_' + CKEDITOR.tools.getNextNumber(), + lang = editor.lang.bootsnippets, + config = editor.config; + return { + title: lang.title, + + minWidth: CKEDITOR.env.ie ? 440 : 420, + minHeight: 600, + + contents: [ { + id: 'selectTpl', + //label: lang.title, + elements: [ + { + type: 'vbox', + children: [ + { + id: 'snippetsList', + type: 'html', + focus: false, + html: '
' + + '
' + + '
' + + '' + lang.options + '' + }, + { + id: 'chkInsertOpt', + type: 'checkbox', + label: lang.insertOption, + 'default': config.bootsnippets_replaceContent, + focus: false + } ] + } ] + } ], + + buttons: [ CKEDITOR.dialog.cancelButton ], + + onShow: function() { + var snippetsListField = this.getContentElement( 'selectTpl', 'snippetsList' ); + listContainer = snippetsListField.getElement(); + + CKEDITOR.loadSnippets( config.bootsnippets_files, function() { + //snippetsCategory is the same as the dialog's name (e.g. "bootsnippets-image") + var snippetsCategory = CKEDITOR.dialog.getCurrent().getName(); + var snippets = ( snippetsCategory || 'default' ).split( ',' ); + + //change dialog's title + var snippetNames = (CKEDITOR.config.bootsnippets).split( ',' ); + var snippetLabels = (CKEDITOR.config.bootsnippets_labels).split( ',' ); + var snippetLabel = ""; + if ( snippetNames.length ) { + for ( var i = 0, snippetNamesCount = snippetNames.length; i < snippetNamesCount; i++ ) { + var snippetName = snippetNames[i].trim(); + if (snippetName == snippets) { + snippetLabel = snippetLabels[i].trim(); + } + } + } + CKEDITOR.dialog.getCurrent().getElement().getFirst().find('.cke_dialog_title').getItem(0).setText(snippetLabel); + + if ( snippets.length ) { + renderSnippetsList( listContainer, snippets ); + } else { + listContainer.setHtml( '
' + + '' + lang.emptyListMsg + '' + + '
' ); + } + } ); + } + }; + } +} )(); + + + +/** + * The bootsnippets definition set to use. It accepts a list of names separated by + * comma. It must match definitions loaded with the {@link #snippets_files} setting. + * + * config.bootsnippets = 'my_snippets'; + * + * @cfg {String} [bootsnippets='default'] + * @member CKEDITOR.config + */ + +/** + * The list of bootsnippets definition files to load. + * + * config.snippets_files = [ + * '/editor_snippets/site_default.js', + * 'http://www.example.com/user_snippets.js + * ]; + * + * @cfg + * @member CKEDITOR.config + */ +// *LAMS* commented out by LAMS as it was overwriting properties from the main config file +//CKEDITOR.config.bootsnippets_files = [ +// CKEDITOR.getUrl( 'plugins/bootsnippets/bootsnippets/default.js' ) +//]; + +/** + * Whether the "Replace actual contents" checkbox is checked by default in the + * bootsnippets dialog. + * + * config.snippets_replaceContent = false; + * + * @cfg + * @member CKEDITOR.config + */ +CKEDITOR.config.bootsnippets_replaceContent = false; Index: lams_central/web/includes/javascript/ckconfig_custom.js =================================================================== diff -u -r5a99d991bc12eb7f09938c99ae8d3f07a1729d45 -r98d80295ca2398cfef80d796b9581cbc399a4077 --- lams_central/web/includes/javascript/ckconfig_custom.js (.../ckconfig_custom.js) (revision 5a99d991bc12eb7f09938c99ae8d3f07a1729d45) +++ lams_central/web/includes/javascript/ckconfig_custom.js (.../ckconfig_custom.js) (revision 98d80295ca2398cfef80d796b9581cbc399a4077) @@ -8,7 +8,7 @@ CKEDITOR.config.toolbar_DefaultInline = [ ['Sourcedialog','Preview','-','PasteFromWord','Undo','Redo','Bold','Italic','Underline', '-','Subscript','Superscript','NumberedList','BulletedList','-','Outdent','Indent','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','TextColor','BGColor','Jlatexmath','-'], - ['Embed','Image','Link','Iframe','Table','HorizontalRule','Emojione','Format','Font','FontSize'] + ['Embed','Image','Link','Iframe','Table','HorizontalRule','Emojione','-','bootsnippets-text','bootsnippets-image','bootsnippets-multimedia','bootsnippets-advanced-layout','Format','Font','FontSize'] ]; CKEDITOR.config.toolbar_DefaultDokuInline = [ @@ -126,19 +126,26 @@ //CKEDITOR.config.skin = 'office2013' ; CKEDITOR.config.disableNativeSpellChecker = false; CKEDITOR.config.browserContextMenuOnCtrl = true; +CKEDITOR.config.bootsnippets = 'bootsnippets-text, bootsnippets-image, bootsnippets-multimedia, bootsnippets-advanced-layout'; +CKEDITOR.config.bootsnippets_icons = CKEDITOR.basePath + '/plugins/bootsnippets/icons/ico_text.ico, ' + CKEDITOR.basePath + '/plugins/bootsnippets/icons/ico_image.ico, ' + CKEDITOR.basePath + '/plugins/bootsnippets/icons/ico_video.png, form'; +CKEDITOR.config.bootsnippets_labels = 'Text Snippets, Image Snippets, Multimedia Snippets, Advanced Layout Snippets'; +CKEDITOR.config.bootsnippets_files = [CKEDITOR.basePath + '../www/public/ckeditor-templates/bootsnippets.js']; CKEDITOR.config.format_tags = 'div;h1;h2;h3;h4;h5;h6;pre;address;p' ; CKEDITOR.config.enterMode = 'div'; CKEDITOR.plugins.addExternal('wikilink', CKEDITOR.basePath + '../tool/lawiki10/wikilink/', 'plugin.js'); -CKEDITOR.config.extraPlugins = 'wikilink,jlatexmath,image2,html5audio,bootstrapTabs'; +CKEDITOR.config.extraPlugins = 'wikilink,jlatexmath,image2,html5audio,bootstrapTabs,bootpanel,bootsnippets'; CKEDITOR.config.enterMode = CKEDITOR.ENTER_DIV; CKEDITOR.config.removePlugins = 'elementspath,about,specialchar'; CKEDITOR.config.allowedContent = true; CKEDITOR.config.toolbarCanCollapse = true; CKEDITOR.config.embed_provider = '//ckeditor.iframe.ly/api/oembed?url={url}&callback={callback}';//default URL for 'embed' plugin +//allow empty i and span tags (for font awesome) +CKEDITOR.dtd.$removeEmpty['i'] = false; +CKEDITOR.dtd.$removeEmpty['span'] = false; // ---- Additional scripts ----- -// Hides editor instaces until they are fully initialized +// Hides editor instaces until they are fully initialized CKEDITOR.on('instanceCreated', function(e){ e.editor.element.$.style.display = 'none'; });