scratch – Blame information for rev 125
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
58 | office | 1 | (function($) { |
2 | 'use strict'; |
||
3 | |||
4 | // Adds the language variables |
||
5 | $.extend(true, $.trumbowyg, { |
||
6 | langs: { |
||
7 | en: { |
||
8 | template: 'Template' |
||
9 | }, |
||
10 | nl: { |
||
11 | template: 'Sjabloon' |
||
125 | office | 12 | }, |
13 | ja: { |
||
14 | template: 'テンプレート' |
||
58 | office | 15 | } |
16 | } |
||
17 | }); |
||
18 | |||
19 | // Adds the extra button definition |
||
20 | $.extend(true, $.trumbowyg, { |
||
21 | plugins: { |
||
22 | template: { |
||
23 | shouldInit: function(trumbowyg) { |
||
24 | return trumbowyg.o.plugins.hasOwnProperty('templates'); |
||
25 | }, |
||
26 | init: function(trumbowyg) { |
||
27 | trumbowyg.addBtnDef('template', { |
||
28 | dropdown: templateSelector(trumbowyg), |
||
29 | hasIcon: false, |
||
30 | text: trumbowyg.lang.template |
||
31 | }); |
||
32 | } |
||
33 | } |
||
34 | } |
||
35 | }); |
||
36 | |||
37 | // Creates the template-selector dropdown. |
||
38 | function templateSelector(trumbowyg) { |
||
39 | var available = trumbowyg.o.plugins.templates; |
||
40 | var templates = []; |
||
41 | |||
42 | $.each(available, function(index, template) { |
||
43 | trumbowyg.addBtnDef('template_' + index, { |
||
44 | fn: function(){ |
||
45 | trumbowyg.html(template.html); |
||
46 | }, |
||
47 | hasIcon: false, |
||
48 | title: template.name |
||
49 | }); |
||
50 | templates.push('template_' + index); |
||
51 | }); |
||
52 | |||
53 | return templates; |
||
54 | } |
||
55 | })(jQuery); |