]>
Commit | Line | Data |
---|---|---|
7adcb81e IB |
1 | /**\r |
2 | * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.\r | |
3 | * For licensing, see LICENSE.md or http://ckeditor.com/license\r | |
4 | */\r | |
5 | \r | |
6 | ( function() {\r | |
7 | CKEDITOR.plugins.add( 'templates', {\r | |
8 | requires: 'dialog',\r | |
9 | // jscs:disable maximumLineLength\r | |
10 | lang: 'af,ar,bg,bn,bs,ca,cs,cy,da,de,el,en,en-au,en-ca,en-gb,eo,es,et,eu,fa,fi,fo,fr,fr-ca,gl,gu,he,hi,hr,hu,id,is,it,ja,ka,km,ko,ku,lt,lv,mk,mn,ms,nb,nl,no,pl,pt,pt-br,ro,ru,si,sk,sl,sq,sr,sr-latn,sv,th,tr,tt,ug,uk,vi,zh,zh-cn', // %REMOVE_LINE_CORE%\r | |
11 | // jscs:enable maximumLineLength\r | |
12 | icons: 'templates,templates-rtl', // %REMOVE_LINE_CORE%\r | |
13 | hidpi: true, // %REMOVE_LINE_CORE%\r | |
14 | init: function( editor ) {\r | |
15 | CKEDITOR.dialog.add( 'templates', CKEDITOR.getUrl( this.path + 'dialogs/templates.js' ) );\r | |
16 | \r | |
17 | editor.addCommand( 'templates', new CKEDITOR.dialogCommand( 'templates' ) );\r | |
18 | \r | |
19 | editor.ui.addButton && editor.ui.addButton( 'Templates', {\r | |
20 | label: editor.lang.templates.button,\r | |
21 | command: 'templates',\r | |
22 | toolbar: 'doctools,10'\r | |
23 | } );\r | |
24 | }\r | |
25 | } );\r | |
26 | \r | |
27 | var templates = {},\r | |
28 | loadedTemplatesFiles = {};\r | |
29 | \r | |
30 | CKEDITOR.addTemplates = function( name, definition ) {\r | |
31 | templates[ name ] = definition;\r | |
32 | };\r | |
33 | \r | |
34 | CKEDITOR.getTemplates = function( name ) {\r | |
35 | return templates[ name ];\r | |
36 | };\r | |
37 | \r | |
38 | CKEDITOR.loadTemplates = function( templateFiles, callback ) {\r | |
39 | // Holds the templates files to be loaded.\r | |
40 | var toLoad = [];\r | |
41 | \r | |
42 | // Look for pending template files to get loaded.\r | |
43 | for ( var i = 0, count = templateFiles.length; i < count; i++ ) {\r | |
44 | if ( !loadedTemplatesFiles[ templateFiles[ i ] ] ) {\r | |
45 | toLoad.push( templateFiles[ i ] );\r | |
46 | loadedTemplatesFiles[ templateFiles[ i ] ] = 1;\r | |
47 | }\r | |
48 | }\r | |
49 | \r | |
50 | if ( toLoad.length )\r | |
51 | CKEDITOR.scriptLoader.load( toLoad, callback );\r | |
52 | else\r | |
53 | setTimeout( callback, 0 );\r | |
54 | };\r | |
55 | } )();\r | |
56 | \r | |
57 | \r | |
58 | \r | |
59 | /**\r | |
60 | * The templates definition set to use. It accepts a list of names separated by\r | |
61 | * comma. It must match definitions loaded with the {@link #templates_files} setting.\r | |
62 | *\r | |
63 | * config.templates = 'my_templates';\r | |
64 | *\r | |
65 | * @cfg {String} [templates='default']\r | |
66 | * @member CKEDITOR.config\r | |
67 | */\r | |
68 | \r | |
69 | /**\r | |
70 | * The list of templates definition files to load.\r | |
71 | *\r | |
72 | * config.templates_files = [\r | |
73 | * '/editor_templates/site_default.js',\r | |
74 | * 'http://www.example.com/user_templates.js\r | |
75 | * ];\r | |
76 | *\r | |
77 | * @cfg\r | |
78 | * @member CKEDITOR.config\r | |
79 | */\r | |
80 | CKEDITOR.config.templates_files = [\r | |
81 | CKEDITOR.getUrl( 'plugins/templates/templates/default.js' )\r | |
82 | ];\r | |
83 | \r | |
84 | /**\r | |
85 | * Whether the "Replace actual contents" checkbox is checked by default in the\r | |
86 | * Templates dialog.\r | |
87 | *\r | |
88 | * config.templates_replaceContent = false;\r | |
89 | *\r | |
90 | * @cfg\r | |
91 | * @member CKEDITOR.config\r | |
92 | */\r | |
93 | CKEDITOR.config.templates_replaceContent = true;\r |