Further modules included.
[yaffs-website] / web / modules / contrib / ckeditor_widgets / js / plugins / widgetcommon / plugin.js
1 CKEDITOR.plugins.add( 'widgetcommon', {
2     requires: 'widget',
3
4     icons: 'widgetcommonQuotebox,widgetcommonBox',
5
6     defaults : {
7         name: 'accordion',
8         count: 3,
9         activePanel: 1,
10         multiExpand: false
11     },
12
13     init: function( editor ) {
14         
15         // Configurable settings
16         var allowedFull = editor.config.widgetcommon_allowedFull != undefined ? editor.config.widgetcommon_allowedFull :
17             'div(!row,two-col-left,two-col-right,accordion,two-col,three-col){width};' +
18             '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)';
19         var allowedWidget = editor.config.widgetcommon_allowedWidget != undefined ? editor.config.widgetcommon_allowedFull :
20             'p br ul ol li a strong em img[!src,alt,width,height]';
21         var allowedText = editor.config.widgetcommon_allowedText != undefined ? editor.config.widgetcommon_allowedFull :
22             'p br ul ol li strong em';
23         var allowedTitle = editor.config.widgetcommon_allowedTitle != undefined ? editor.config.widgetcommon_allowedTitle :
24             'strong em';
25
26         //allowedWidget = 'img[!src,alt,width,height]';
27         //allowedText = allowedWidget;
28
29         var showButtons = editor.config.widgetcommonShowButtons != undefined ? editor.config.widgetcommonShowButtons : true;
30
31
32         editor.widgets.add( 'widgetcommonBox', {
33
34             button: showButtons ? 'Add box' : undefined,
35
36             template:
37                 '<div class="panel panel-default">' +
38                     '<div class="panel-heading box-title">Title</h2></div>' +
39                     '<div class="panel-body box-content">Content</div>' +
40                 '</div>',
41
42             editables: {
43                 title: {
44                     selector: '.box-title',
45                     allowedContent: allowedTitle
46                 },
47                 content: {
48                     selector: '.box-content',
49                     allowedContent: allowedWidget
50                 }
51             },
52
53             allowedContent: allowedFull,
54
55             upcast: function( element ) {
56                 return element.name == 'div' && element.hasClass( 'two-col-right' );
57             }
58
59         } );
60
61         // Define the widgets
62         editor.widgets.add( 'widgetcommonQuotebox', {
63
64             button: showButtons ? 'Add Quotebox' : undefined,
65
66             template:
67                 '<div class="row quotebox">' +
68                     '<div class="row quote">Quote</div>' +
69                     '<div class="row byline">&mdash; Person</div>' +
70                 '</div>',
71
72             editables: {
73                 quote: {
74                     selector: '.quote',
75                     allowedContent: allowedFull
76                 },
77                 byline: {
78                     selector: '.byline',
79                     allowedContent: allowedTitle
80                 }
81             },
82
83             allowedContent: allowedFull,
84
85             upcast: function( element ) {
86                 return element.name == 'div' && element.hasClass( 'quotebox' );
87             }
88             
89         } );
90
91         // Append the widget's styles when in the CKEditor edit page,
92         // added for better user experience.
93         // Assign or append the widget's styles depending on the existing setup.
94         if (typeof editor.config.contentsCss == 'object') {
95             editor.config.contentsCss.push(CKEDITOR.getUrl(this.path + 'contents.css'));
96         }
97
98         else {
99             editor.config.contentsCss = [editor.config.contentsCss, CKEDITOR.getUrl(this.path + 'contents.css')];
100         }
101     }
102
103
104 } );