Commit | Line | Data |
---|---|---|
7266e09b CW |
1 | // https://civicrm.org/licensing |
2 | (function($, _) { | |
3 | 'use strict'; | |
4 | ||
5 | // Weird conflict with drupal styles | |
6 | $('body').removeClass('toolbar'); | |
7 | ||
8 | function format(item) { | |
9 | var icon = '<span class="ui-icon ui-icon-gear"></span>'; | |
10 | if (item.icon) { | |
11 | icon = '<img src="' + CRM.config.resourceBase + item.icon + '" />'; | |
12 | } | |
13 | return icon + ' ' + item.text; | |
14 | } | |
15 | ||
16 | $('#extraPlugins').crmSelect2({ | |
17 | multiple: true, | |
18 | closeOnSelect: false, | |
19 | data: CRM.vars.ckConfig.plugins, | |
20 | escapeMarkup: _.identity, | |
21 | formatResult: format, | |
22 | formatSelection: format | |
23 | }); | |
24 | ||
25 | var toolbarModifier = new ToolbarConfigurator.ToolbarModifier( 'editor-basic' ); | |
26 | ||
27 | toolbarModifier.init(_.noop); | |
28 | ||
29 | CKEDITOR.document.getById( 'toolbarModifierWrapper' ).append( toolbarModifier.mainContainer ); | |
30 | ||
7266e09b CW |
31 | $(function() { |
32 | var selectorOpen = false, | |
33 | changedWhileOpen = false; | |
34 | ||
35 | $('#toolbarModifierForm') | |
7266e09b CW |
36 | .on('submit', function(e) { |
37 | $('.toolbar button:last', '#toolbarModifierWrapper')[0].click(); | |
38 | $('.configContainer textarea', '#toolbarModifierWrapper').attr('name', 'config'); | |
39 | }) | |
40 | .on('change', '.config-param', function(e) { | |
41 | changedWhileOpen = true; | |
42 | if (!selectorOpen) { | |
43 | $('#toolbarModifierForm').submit().block(); | |
44 | } | |
45 | }) | |
46 | // Debounce the change event so it only fires after the multiselect is closed | |
47 | .on('select2-open', 'input.config-param', function(e) { | |
48 | selectorOpen = true; | |
49 | changedWhileOpen = false; | |
50 | }) | |
51 | .on('select2-close', 'input.config-param', function(e) { | |
52 | selectorOpen = false; | |
53 | if (changedWhileOpen) { | |
54 | $(this).change(); | |
55 | } | |
56 | }); | |
57 | }); | |
58 | ||
f4b168fd | 59 | })(CRM.$, CRM._); |