Built motion from commit 1020cd7.|0.0.107
[motion.git] / public / assets / plugins / ckeditor-richparams / plugin.js
1 (function() {
2
3   var isArray = function(obj) {
4     return Object.prototype.toString.call(obj) === '[object Array]';
5   };
6
7   var addRichCombo = function(id, editor, richparams) {
8     editor.ui.addRichCombo(id, {
9       label: richparams.label,
10       title: richparams.title,
11       className: 'cke_' + id,
12       multiSelect: false,
13       panel: {
14         css: [
15           editor.config.contentsCss,
16           CKEDITOR.getUrl(CKEDITOR.skin.getPath('editor') + 'editor.css')
17         ],
18         multiSelect: false
19       },
20       init: function() {
21         var nGroups = richparams.groups.length,
22           nValues, i, j, group, value;
23         for (i = 0; i < nGroups; i++) {
24           group = richparams.groups[i];
25           this.startGroup(group.label);
26           nValues = group.values.length;
27           for (j = 0; j < nValues; j++) {
28             value = group.values[j];
29             this.add(value.value, value.label, value.description || value.label);
30           }
31         }
32       },
33       onClick: function(value) {
34         editor.insertHtml(value);
35       }
36     });
37   };
38
39   CKEDITOR.plugins.add('richparams', {
40     requires: ['richcombo'],
41     init: function(editor) {
42       var richparamsConfig = editor.config.richparams;
43       if (!isArray(richparamsConfig)) {
44         richparamsConfig = [];
45         richparamsConfig.push(editor.config.richparams);
46       }
47       for (var i = 0, l = richparamsConfig.length; i < l; i++) {
48         addRichCombo(richparamsConfig[i].id, editor, richparamsConfig[i]);
49       }
50     }
51   });
52 })();