Built motion from commit 54a160d.|0.0.140
[motion.git] / public / bower_components / ckeditor-freeparams-plugin / freeparams / 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, freeparams) {
8     editor.ui.addRichCombo(id, {
9       label: freeparams.label,
10       title: freeparams.title,
11       toolbar: (freeparams.toolbar || 'paragraph'),
12       className: 'cke_freeparams',
13       multiSelect: false,
14       panel: {
15         css: [
16           editor.config.contentsCss,
17           CKEDITOR.getUrl(CKEDITOR.skin.getPath('editor') + 'editor.css')
18         ],
19         multiSelect: false
20       },
21       init: function() {
22         var nGroups = freeparams.groups.length,
23           nValues, i, j, group, value;
24         for (i = 0; i < nGroups; i++) {
25           group = freeparams.groups[i];
26           this.startGroup(group.label);
27           nValues = group.values.length;
28           for (j = 0; j < nValues; j++) {
29             value = group.values[j];
30             this.add(value.value, value.label, value.label);
31           }
32         }
33       },
34       onClick: function(value) {
35         editor.insertHtml(value);
36       }
37     });
38   };
39
40   CKEDITOR.plugins.add('freeparams', {
41     requires: ['richcombo'],
42     init: function(editor) {
43       var freeparamsConfig = editor.config.freeparams;
44       if (!isArray(freeparamsConfig)) {
45         freeparamsConfig = [];
46         freeparamsConfig.push(editor.config.freeparams);
47       }
48       for (var i = 0, l = freeparamsConfig.length; i < l; i++) {
49         addRichCombo('freeparams' + i, editor, freeparamsConfig[i]);
50       }
51     }
52   });
53 })();