Index: CKEditor/releases/latest/plugins/templates/dialogs/templates.js
===================================================================
--- CKEditor/releases/latest/plugins/templates/dialogs/templates.js	(revision 4887)
+++ CKEditor/releases/latest/plugins/templates/dialogs/templates.js	(revision 5194)
@@ -4,3 +4,4 @@
 */
 
-(function(){var a=CKEDITOR.document,b='cke'+CKEDITOR.tools.getNextNumber();function c(f,g){var h=a.getById(b);h.setHtml('');for(var i=0;i<g.length;i++){var j=CKEDITOR.getTemplates(g[i]),k=j.imagesPath,l=j.templates;for(var m=0;m<l.length;m++){var n=l[m];h.append(d(f,n,k));}}};function d(f,g,h){var i=a.createElement('div');i.setAttribute('class','cke_tpl_item');var j='<table style="width:350px;" class="cke_tpl_preview"><tr>';if(g.image&&h)j+='<td class="cke_tpl_preview_img"><img src="'+CKEDITOR.getUrl(h+g.image)+'"></td>';j+='<td style="white-space:normal;"><span class="cke_tpl_title">'+g.title+'</span><br/>';if(g.description)j+='<span>'+g.description+'</span>';j+='</td></tr></table>';i.setHtml(j);i.on('mouseover',function(){i.addClass('cke_tpl_hover');});i.on('mouseout',function(){i.removeClass('cke_tpl_hover');});i.on('click',function(){e(f,g.html);});return i;};function e(f,g){var h=CKEDITOR.dialog.getCurrent(),i=h.getValueOf('selectTpl','chkInsertOpt');if(i){f.on('contentDom',function(j){j.removeListener();h.hide();var k=new CKEDITOR.dom.range(f.document);k.moveToElementEditStart(f.document.getBody());k.select(true);});f.setData(g);}else{f.insertHtml(g);h.hide();}};CKEDITOR.dialog.add('templates',function(f){CKEDITOR.skins.load(f,'templates');var g=false;return{title:f.lang.templates.title,minWidth:CKEDITOR.env.ie?440:400,minHeight:340,contents:[{id:'selectTpl',label:f.lang.templates.title,elements:[{type:'vbox',padding:5,children:[{type:'html',html:'<span>'+f.lang.templates.selectPromptMsg+'</span>'},{type:'html',html:'<div id="'+b+'" class="cke_tpl_list">'+'<div class="cke_tpl_loading"><span></span></div>'+'</div>'},{id:'chkInsertOpt',type:'checkbox',label:f.lang.templates.insertOption,'default':f.config.templates_replaceContent}]}]}],buttons:[CKEDITOR.dialog.cancelButton],onShow:function(){CKEDITOR.loadTemplates(f.config.templates_files,function(){var h=f.config.templates.split(',');if(h.length)c(f,h);else{var i=a.getById(b);i.setHtml('<div class="cke_tpl_empty"><span>'+f.lang.templates.emptyListMsg+'</span>'+'</div>');}});}};});})();
+(function(){var a=CKEDITOR.document;CKEDITOR.dialog.add('templates',function(b){function c(h,i){h.setHtml('');for(var j=0;j<i.length;j++){var k=CKEDITOR.getTemplates(i[j]),l=k.imagesPath,m=k.templates,n=m.length;for(var o=0;o<n;o++){var p=m[o],q=d(p,l);q.setAttribute('aria-posinset',o+1);q.setAttribute('aria-setsize',n);h.append(q);}}};function d(h,i){var j=CKEDITOR.dom.element.createFromHtml('<a href="javascript:void(0)" tabIndex="-1" role="option" ><div class="cke_tpl_item"></div></a>'),k='<table style="width:350px;" class="cke_tpl_preview"><tr>';if(h.image&&i)k+='<td class="cke_tpl_preview_img"><img src="'+CKEDITOR.getUrl(i+h.image)+'"></td>';k+='<td style="white-space:normal;"><span class="cke_tpl_title">'+h.title+'</span><br/>';if(h.description)k+='<span>'+h.description+'</span>';k+='</td></tr></table>';j.getFirst().setHtml(k);j.on('click',function(){e(h.html);});return j;};function e(h){var i=CKEDITOR.dialog.getCurrent(),j=i.getValueOf('selectTpl','chkInsertOpt');if(j){b.on('contentDom',function(k){k.removeListener();i.hide();var l=new CKEDITOR.dom.range(b.document);l.moveToElementEditStart(b.document.getBody());l.select(true);setTimeout(function(){b.fire('saveSnapshot');},0);});b.fire('saveSnapshot');b.setData(h);}else{b.insertHtml(h);i.hide();}};function f(h){var i=h.data.getTarget(),j=g.getPosition(i);if(j>CKEDITOR.POSITION_CONTAINS){var k=h.data.getKeystroke(),l=g.getElementsByTag('a'),m;if(l){switch(k){case 40:m=i.getNext();break;case 38:m=i.getPrevious();break;case 13:case 32:i.fire('click');}if(m){m.focus();h.data.preventDefault();}}}};CKEDITOR.skins.load(b,'templates');var g;return{title:b.lang.templates.title,minWidth:CKEDITOR.env.ie?440:400,minHeight:340,contents:[{id:'selectTpl',label:b.lang.templates.title,elements:[{type:'vbox',padding:5,children:[{type:'html',html:'<span>'+b.lang.templates.selectPromptMsg+'</span>'},{id:'templatesList',type:'html',focus:function(){try{this.getElement().getElementsByTag('a').getItem(0).focus();}catch(h){}},html:'<div class="cke_tpl_list" tabIndex="-1" role="listbox" aria-labelledby="cke_tpl_list_label"><div class="cke_tpl_loading"><span></span></div></div><span class="cke_voice_label" id="cke_tpl_list_label">'+b.lang.common.options+'</span>'},{id:'chkInsertOpt',type:'checkbox',label:b.lang.templates.insertOption,'default':b.config.templates_replaceContent}]}]}],buttons:[CKEDITOR.dialog.cancelButton],onShow:function(){var h=this.getContentElement('selectTpl','templatesList');g=h.getElement();CKEDITOR.loadTemplates(b.config.templates_files,function(){var i=b.config.templates.split(',');
+if(i.length){c(g,i);h.focus();}else g.setHtml('<div class="cke_tpl_empty"><span>'+b.lang.templates.emptyListMsg+'</span>'+'</div>');});this._.element.on('keydown',f);},onHide:function(){this._.element.removeListener('keydown',f);}};});})();
