JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.0
[ckeditor.git] / _source / plugins / templates / plugin.js
diff --git a/_source/plugins/templates/plugin.js b/_source/plugins/templates/plugin.js
new file mode 100644 (file)
index 0000000..dc88870
--- /dev/null
@@ -0,0 +1,99 @@
+/*\r
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.\r
+For licensing, see LICENSE.html or http://ckeditor.com/license\r
+*/\r
+\r
+(function()\r
+{\r
+       CKEDITOR.plugins.add( 'templates',\r
+               {\r
+                       requires : [ 'dialog' ],\r
+\r
+                       init : function( editor )\r
+                       {\r
+                               CKEDITOR.dialog.add( 'templates', CKEDITOR.getUrl( this.path + 'dialogs/templates.js' ) );\r
+\r
+                               editor.addCommand( 'templates', new CKEDITOR.dialogCommand( 'templates' ) );\r
+\r
+                               editor.ui.addButton( 'Templates',\r
+                                       {\r
+                                               label : editor.lang.templates.button,\r
+                                               command : 'templates'\r
+                                       });\r
+                       }\r
+               });\r
+\r
+       var templates = {},\r
+               loadedTemplatesFiles = {};\r
+\r
+       CKEDITOR.addTemplates = function( name, definition )\r
+       {\r
+               templates[ name ] = definition;\r
+       };\r
+\r
+       CKEDITOR.getTemplates = function( name )\r
+       {\r
+               return templates[ name ];\r
+       };\r
+\r
+       CKEDITOR.loadTemplates = function( templateFiles, callback )\r
+       {\r
+               // Holds the templates files to be loaded.\r
+               var toLoad = [];\r
+\r
+               // Look for pending template files to get loaded.\r
+               for ( var i = 0 ; i < templateFiles.length ; i++ )\r
+               {\r
+                       if ( !loadedTemplatesFiles[ templateFiles[ i ] ] )\r
+                       {\r
+                               toLoad.push( templateFiles[ i ] );\r
+                               loadedTemplatesFiles[ templateFiles[ i ] ] = 1;\r
+                       }\r
+               }\r
+\r
+               if ( toLoad.length > 0 )\r
+                       CKEDITOR.scriptLoader.load( toLoad, callback );\r
+               else\r
+                       setTimeout( callback, 0 );\r
+       };\r
+})();\r
+\r
+\r
+\r
+/**\r
+ * The templates definition set to use. It accepts a list of names separated by\r
+ * comma. It must match definitions loaded with the templates_files setting.\r
+ * @type String\r
+ * @default 'default'\r
+ * @example\r
+ * config.templates = 'my_templates';\r
+ */\r
+CKEDITOR.config.templates = 'default';\r
+\r
+/**\r
+ * The list of templates definition files to load.\r
+ * @type (String) Array\r
+ * @default [ 'plugins/templates/templates/default.js' ]\r
+ * @example\r
+ * config.templates_files =\r
+ *     [\r
+ *         '/editor_templates/site_default.js',\r
+ *         'http://www.example.com/user_templates.js\r
+ *     ];\r
+ *\r
+ */\r
+CKEDITOR.config.templates_files =\r
+       [\r
+               CKEDITOR.getUrl(\r
+                       'plugins/templates/templates/default.js' )\r
+       ];\r
+\r
+/**\r
+ * Whether the "Replace actual contents" checkbox is checked by default in the\r
+ * Templates dialog.\r
+ * @type Boolean\r
+ * @default true\r
+ * @example\r
+ * config.templates_replaceContent = false;\r
+ */\r
+CKEDITOR.config.templates_replaceContent = true;\r