X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Ftemplates%2Fdialogs%2Ftemplates.js;h=d0bd148eaba984418c77a6faa17eac8959cc7179;hb=48b1db88210b4160dce439c6e3e32e14af8c106b;hp=98c8feb88759c614a94fcfcd6e153788f7d8e7c6;hpb=059b4c2fef02528bf1af189f7996e80652faddfb;p=ckeditor.git diff --git a/_source/plugins/templates/dialogs/templates.js b/_source/plugins/templates/dialogs/templates.js index 98c8feb..d0bd148 100644 --- a/_source/plugins/templates/dialogs/templates.js +++ b/_source/plugins/templates/dialogs/templates.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -15,7 +15,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // clear loading wait text. container.setHtml( '' ); - for ( var i = 0 ; i < templatesDefinitions.length ; i++ ) + for ( var i = 0, totalDefs = templatesDefinitions.length ; i < totalDefs ; i++ ) { var definition = CKEDITOR.getTemplates( templatesDefinitions[ i ] ), imagesPath = definition.imagesPath, @@ -41,10 +41,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license '' ); // Build the inner HTML of our new item DIV. - var html = '
'; + html += ' | '; html += ' | ' + template.title + ' '; @@ -80,12 +80,12 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // Place the cursor at the first editable place. var range = new CKEDITOR.dom.range( editor.document ); range.moveToElementEditStart( editor.document.getBody() ); - range.select( true ); - setTimeout( function () + range.select( 1 ); + setTimeout( function() { editor.fire( 'saveSnapshot' ); }, 0 ); - } ); + }); editor.fire( 'saveSnapshot' ); editor.setData( html ); @@ -100,10 +100,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license function keyNavigation( evt ) { var target = evt.data.getTarget(), - position = listContainer.getPosition( target ); + onList = listContainer.equals( target ); // Keyboard navigation for template list. - if ( position > CKEDITOR.POSITION_CONTAINS ) + if ( onList || listContainer.contains( target ) ) { var keystroke = evt.data.getKeystroke(), items = listContainer.getElementsByTag( 'a' ), @@ -111,19 +111,25 @@ For licensing, see LICENSE.html or http://ckeditor.com/license if ( items ) { - switch ( keystroke ) + // Focus not yet onto list items? + if ( onList ) + focusItem = items.getItem( 0 ); + else { - case 40 : // ARROW-DOWN - focusItem = target.getNext(); - break; + switch ( keystroke ) + { + case 40 : // ARROW-DOWN + focusItem = target.getNext(); + break; - case 38 : // ARROW-UP - focusItem = target.getPrevious(); - break; + case 38 : // ARROW-UP + focusItem = target.getPrevious(); + break; - case 13 : // ENTER - case 32 : // SPACE - target.fire( 'click' ); + case 13 : // ENTER + case 32 : // SPACE + target.fire( 'click' ); + } } if ( focusItem ) @@ -140,6 +146,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license var listContainer; + var templateListLabelId = 'cke_tpl_list_label_' + CKEDITOR.tools.getNextNumber(), + lang = editor.lang.templates, + config = editor.config; return { title :editor.lang.templates.title, @@ -150,7 +159,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license [ { id :'selectTpl', - label : editor.lang.templates.title, + label : lang.title, elements : [ { @@ -162,29 +171,24 @@ For licensing, see LICENSE.html or http://ckeditor.com/license type : 'html', html : '' + - editor.lang.templates.selectPromptMsg + + lang.selectPromptMsg + '' }, { - id : "templatesList", + id : 'templatesList', type : 'html', - focus: function() - { - // Move focus to the first list item if available. - try { this.getElement().getElementsByTag( 'a' ).getItem( 0 ).focus(); } - catch( er ){} - }, + focus: true, html : - ' ' +
+ ' ' +
' ' +
- '' + editor.lang.common.options+ ''
+ '' + lang.options+ ''
},
{
id : 'chkInsertOpt',
type : 'checkbox',
- label : editor.lang.templates.insertOption,
- 'default' : editor.config.templates_replaceContent
+ label : lang.insertOption,
+ 'default' : config.templates_replaceContent
}
]
}
@@ -199,9 +203,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
var templatesListField = this.getContentElement( 'selectTpl' , 'templatesList' );
listContainer = templatesListField.getElement();
- CKEDITOR.loadTemplates( editor.config.templates_files, function()
+ CKEDITOR.loadTemplates( config.templates_files, function()
{
- var templates = editor.config.templates.split( ',' );
+ var templates = ( config.templates || 'default' ).split( ',' );
if ( templates.length )
{
@@ -212,7 +216,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
listContainer.setHtml(
'' +
' ' +
- '' + editor.lang.templates.emptyListMsg + '' +
+ '' + lang.emptyListMsg + '' +
' ' );
}
});
@@ -220,7 +224,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
this._.element.on( 'keydown', keyNavigation );
},
- onHide : function ()
+ onHide : function()
{
this._.element.removeListener( 'keydown', keyNavigation );
}
|