X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fckeditor_widgets%2Fjs%2Fplugins%2Fwidgetcommon%2Fplugin.js;fp=web%2Fmodules%2Fcontrib%2Fckeditor_widgets%2Fjs%2Fplugins%2Fwidgetcommon%2Fplugin.js;h=a45b35a776bcbc9ee306670e086a96a4af25faae;hp=0000000000000000000000000000000000000000;hb=8acec36f19c470dfcda1ae2336826a782f41874c;hpb=e0411c4e83ba0d079034db83c3f7f55be24a0e35 diff --git a/web/modules/contrib/ckeditor_widgets/js/plugins/widgetcommon/plugin.js b/web/modules/contrib/ckeditor_widgets/js/plugins/widgetcommon/plugin.js new file mode 100644 index 000000000..a45b35a77 --- /dev/null +++ b/web/modules/contrib/ckeditor_widgets/js/plugins/widgetcommon/plugin.js @@ -0,0 +1,104 @@ +CKEDITOR.plugins.add( 'widgetcommon', { + requires: 'widget', + + icons: 'widgetcommonQuotebox,widgetcommonBox', + + defaults : { + name: 'accordion', + count: 3, + activePanel: 1, + multiExpand: false + }, + + init: function( editor ) { + + // Configurable settings + var allowedFull = editor.config.widgetcommon_allowedFull != undefined ? editor.config.widgetcommon_allowedFull : + 'div(!row,two-col-left,two-col-right,accordion,two-col,three-col){width};' + + 'div(!columns,col-xs-12,col-sm-3,col-sm-9,col-sidebar,col-main,col-1,col-2,col-3,panel,panel-default,panel-heading,panel-body)'; + var allowedWidget = editor.config.widgetcommon_allowedWidget != undefined ? editor.config.widgetcommon_allowedFull : + 'p br ul ol li a strong em img[!src,alt,width,height]'; + var allowedText = editor.config.widgetcommon_allowedText != undefined ? editor.config.widgetcommon_allowedFull : + 'p br ul ol li strong em'; + var allowedTitle = editor.config.widgetcommon_allowedTitle != undefined ? editor.config.widgetcommon_allowedTitle : + 'strong em'; + + //allowedWidget = 'img[!src,alt,width,height]'; + //allowedText = allowedWidget; + + var showButtons = editor.config.widgetcommonShowButtons != undefined ? editor.config.widgetcommonShowButtons : true; + + + editor.widgets.add( 'widgetcommonBox', { + + button: showButtons ? 'Add box' : undefined, + + template: + '
' + + '
Title
' + + '
Content
' + + '
', + + editables: { + title: { + selector: '.box-title', + allowedContent: allowedTitle + }, + content: { + selector: '.box-content', + allowedContent: allowedWidget + } + }, + + allowedContent: allowedFull, + + upcast: function( element ) { + return element.name == 'div' && element.hasClass( 'two-col-right' ); + } + + } ); + + // Define the widgets + editor.widgets.add( 'widgetcommonQuotebox', { + + button: showButtons ? 'Add Quotebox' : undefined, + + template: + '
' + + '
Quote
' + + '
— Person
' + + '
', + + editables: { + quote: { + selector: '.quote', + allowedContent: allowedFull + }, + byline: { + selector: '.byline', + allowedContent: allowedTitle + } + }, + + allowedContent: allowedFull, + + upcast: function( element ) { + return element.name == 'div' && element.hasClass( 'quotebox' ); + } + + } ); + + // Append the widget's styles when in the CKEditor edit page, + // added for better user experience. + // Assign or append the widget's styles depending on the existing setup. + if (typeof editor.config.contentsCss == 'object') { + editor.config.contentsCss.push(CKEDITOR.getUrl(this.path + 'contents.css')); + } + + else { + editor.config.contentsCss = [editor.config.contentsCss, CKEDITOR.getUrl(this.path + 'contents.css')]; + } + } + + +} ); \ No newline at end of file