1 | CKEDITOR.addTemplates( |
---|
2 | 'default', |
---|
3 | { imagesPath: CKEDITOR.getUrl(CKEDITOR.plugins.getPath("templates")+"templates/images/") , |
---|
4 | templates : [ |
---|
5 | { title: 'Dynamic table', |
---|
6 | image: 'example.png', |
---|
7 | description: "", |
---|
8 | form: { |
---|
9 | 'columnCount': { |
---|
10 | type: 'range', // input type |
---|
11 | min: 2, |
---|
12 | max: 5, |
---|
13 | default: 2, |
---|
14 | label: 'Column count:' |
---|
15 | // pattern: "", |
---|
16 | // validate: function(){}, |
---|
17 | // ui-depends: { |
---|
18 | // ui dependencies such as show/hide/disable/enable |
---|
19 | // } |
---|
20 | // etc. |
---|
21 | } |
---|
22 | }, |
---|
23 | html: function(formState){ |
---|
24 | var s = ''; |
---|
25 | var colCount = parseInt(formState.columnCount.value); // formState: {controlName1: value, controlName2: value} |
---|
26 | s += '<table class="col-' + colCount + '"><tr>'; // consider: '<table class="col-{{colCount}}"><tr>'; |
---|
27 | for(var i=0; i<colCount; i++){ |
---|
28 | s += '<td> </td>'; |
---|
29 | } |
---|
30 | s += '</tr></table>'; |
---|
31 | return s; |
---|
32 | } |
---|
33 | } |
---|
34 | ] |
---|
35 | }); |
---|