JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.4.2
[ckeditor.git] / _source / plugins / templates / dialogs / templates.js
index d3d78c6..eb86b65 100644 (file)
@@ -15,7 +15,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                // clear loading wait text.\r
                                container.setHtml( '' );\r
 \r
-                               for ( var i = 0 ; i < templatesDefinitions.length ; i++ )\r
+                               for ( var i = 0, totalDefs = templatesDefinitions.length ; i < totalDefs ; i++ )\r
                                {\r
                                        var definition = CKEDITOR.getTemplates( templatesDefinitions[ i ] ),\r
                                                imagesPath = definition.imagesPath,\r
@@ -44,7 +44,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                var html = '<table style="width:350px;" class="cke_tpl_preview" role="presentation"><tr>';\r
 \r
                                if ( template.image && imagesPath )\r
-                                       html += '<td class="cke_tpl_preview_img"><img src="' + CKEDITOR.getUrl( imagesPath + template.image ) + '"' + ( CKEDITOR.env.ie6Compat? ' onload="this.width=this.width"' : '' ) + ' alt="" title=""></td>';\r
+                                       html += '<td class="cke_tpl_preview_img"><img src="' + CKEDITOR.getUrl( imagesPath + template.image ) + '"' + ( CKEDITOR.env.ie6Compat ? ' onload="this.width=this.width"' : '' ) + ' alt="" title=""></td>';\r
 \r
                                html += '<td style="white-space:normal;"><span class="cke_tpl_title">' + template.title + '</span><br/>';\r
 \r
@@ -80,12 +80,12 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                // Place the cursor at the first editable place.\r
                                                var range = new CKEDITOR.dom.range( editor.document );\r
                                                range.moveToElementEditStart( editor.document.getBody() );\r
-                                               range.select( true );\r
-                                               setTimeout( function ()\r
+                                               range.select( 1 );\r
+                                               setTimeout( function()\r
                                                {\r
                                                        editor.fire( 'saveSnapshot' );\r
                                                }, 0 );\r
-                                       } );\r
+                                       });\r
 \r
                                        editor.fire( 'saveSnapshot' );\r
                                        editor.setData( html );\r
@@ -146,7 +146,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
                        var listContainer;\r
 \r
-                       var templateListLabelId = 'cke_tpl_list_label_' + CKEDITOR.tools.getNextNumber();\r
+                       var templateListLabelId = 'cke_tpl_list_label_' + CKEDITOR.tools.getNextNumber(),\r
+                               lang = editor.lang.templates,\r
+                               config = editor.config;\r
                        return {\r
                                title :editor.lang.templates.title,\r
 \r
@@ -157,7 +159,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                [\r
                                        {\r
                                                id :'selectTpl',\r
-                                               label : editor.lang.templates.title,\r
+                                               label : lang.title,\r
                                                elements :\r
                                                [\r
                                                        {\r
@@ -169,24 +171,24 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                                type : 'html',\r
                                                                                html :\r
                                                                                        '<span>'  +\r
-                                                                                               editor.lang.templates.selectPromptMsg +\r
+                                                                                               lang.selectPromptMsg +\r
                                                                                        '</span>'\r
                                                                        },\r
                                                                        {\r
-                                                                               id : "templatesList",\r
+                                                                               id : 'templatesList',\r
                                                                                type : 'html',\r
                                                                                focus: true,\r
                                                                                html :\r
                                                                                        '<div class="cke_tpl_list" tabIndex="-1" role="listbox" aria-labelledby="' + templateListLabelId+ '">' +\r
                                                                                                '<div class="cke_tpl_loading"><span></span></div>' +\r
                                                                                        '</div>' +\r
-                                                                                       '<span class="cke_voice_label" id="' + templateListLabelId + '">' + editor.lang.templates.options+ '</span>'\r
+                                                                                       '<span class="cke_voice_label" id="' + templateListLabelId + '">' + lang.options+ '</span>'\r
                                                                        },\r
                                                                        {\r
                                                                                id : 'chkInsertOpt',\r
                                                                                type : 'checkbox',\r
-                                                                               label : editor.lang.templates.insertOption,\r
-                                                                               'default' : editor.config.templates_replaceContent\r
+                                                                               label : lang.insertOption,\r
+                                                                               'default' : config.templates_replaceContent\r
                                                                        }\r
                                                                ]\r
                                                        }\r
@@ -201,9 +203,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                        var templatesListField = this.getContentElement( 'selectTpl' , 'templatesList' );\r
                                        listContainer = templatesListField.getElement();\r
 \r
-                                       CKEDITOR.loadTemplates( editor.config.templates_files, function()\r
+                                       CKEDITOR.loadTemplates( config.templates_files, function()\r
                                                {\r
-                                                       var templates = editor.config.templates.split( ',' );\r
+                                                       var templates = ( config.templates || 'default' ).split( ',' );\r
 \r
                                                        if ( templates.length )\r
                                                        {\r
@@ -214,7 +216,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                        {\r
                                                                listContainer.setHtml(\r
                                                                        '<div class="cke_tpl_empty">' +\r
-                                                                               '<span>' + editor.lang.templates.emptyListMsg + '</span>' +\r
+                                                                               '<span>' + lang.emptyListMsg + '</span>' +\r
                                                                        '</div>' );\r
                                                        }\r
                                                });\r
@@ -222,7 +224,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                        this._.element.on( 'keydown', keyNavigation );\r
                                },\r
 \r
-                               onHide : function ()\r
+                               onHide : function()\r
                                {\r
                                        this._.element.removeListener( 'keydown', keyNavigation );\r
                                }\r