Passed
Push — master ( 25ca2a...86c16b )
by Robbie
02:46
created

tinymce_plugins/editor_plugin_src.js   A

Complexity

Total Complexity 5
Complexity/F 1.25

Size

Lines of Code 53
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 0
nc 1
dl 0
loc 53
rs 10
c 0
b 0
f 0
wmc 5
mnd 1
bc 5
fnc 4
bpm 1.25
cpm 1.25
noi 4
1
(function() {
2
3
  var each = tinymce.each;
4
5
  // TinyMCE will stop loading if it encounters non-existent external script file
6
  // when included through tiny_mce_gzip.php. Only load the external lang package if it is available.
7
  var availableLangs = ['en', 'mi_NZ'];
8
  if (jQuery.inArray(tinymce.settings.language, availableLangs) != -1) {
9
    tinymce.PluginManager.requireLangPack("ssicons");
10
  }
11
12
  /**
13
   * Load via:
14
   * HtmlEditorConfig::get('cms')->enablePlugins(array('ssmacron', '../../../agency-extensions/tinymce_plugins/editor_plugin_src.js'))
15
   * HtmlEditorConfig::get('cms')->insertButtonsAfter ('ssmacron', 'ssicons');
16
   */
17
  tinymce.create('tinymce.plugins.ssicons', {
18
19
    init : function(ed, url) {
20
21
      // Register commands
22
      ed.addCommand('mceInsertIcons', function() {
23
        ed.windowManager.open({
24
          file : url + '/icon.htm',
25
          width : 450 + parseInt(ed.getLang('advanced.iconmap_delta_width', 0)),
26
          height : 190 + parseInt(ed.getLang('advanced.iconmap_delta_height', 0)),
27
          inline : true
28
        },{
29
          plugin_url : url
30
        });
31
      });
32
33
      // Register buttons
34
      ed.addButton('ssicons', {
35
        title: 'Insert an Icon',
36
        cmd : 'mceInsertIcons',
37
        image : url + '../../../agency-extensions/tinymce_plugins/img/icon.png'
38
      });
39
40
    },
41
42
    getInfo : function() {
43
      console.log('getinfo');
44
      return {
45
          longname : 'Button to insert icons',
46
      };
47
    }
48
49
  });
50
51
  tinymce.PluginManager.add("ssicons", tinymce.plugins.ssicons);
52
53
})();
54