Ticket #2879: 2879_3.patch
File 2879_3.patch, 14.4 KB (added by , 16 years ago) |
---|
-
_source/core/config.js
147 147 * config.plugins = 'basicstyles,button,htmldataprocessor,toolbar,wysiwygarea'; 148 148 */ 149 149 150 plugins : 'basicstyles,blockquote,button,elementspath,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,newpage,pagebreak,preview,print,removeformat,smiley,sourcearea,table,specialchar,tab,t oolbar,wysiwygarea',150 plugins : 'basicstyles,blockquote,button,elementspath,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,newpage,pagebreak,preview,print,removeformat,smiley,sourcearea,table,specialchar,tab,templates,toolbar,wysiwygarea', 151 151 152 152 /** 153 153 * The theme to be used to build the UI. -
_source/lang/en.js
390 390 }, 391 391 392 392 outdent : 'Decrease Indent', 393 blockquote : 'Blockquote' 393 blockquote : 'Blockquote', 394 templates : 395 { 396 button : 'Templates', 397 title : 'Content Templates', 398 insertOption: 'Replace actual contents', 399 selectPromptMsg: 'Please select the template to open in the editor', 400 emptyListMsg : '(No templates defined)' 401 } 394 402 }; -
_source/plugins/dialog/plugin.js
883 883 return !!this._.dialogDefinitions[ name ]; 884 884 }, 885 885 886 getCurrent : function() 887 { 888 return CKEDITOR.dialog._.currentTop; 889 }, 890 886 891 /** 887 892 * The default OK button for dialogs. Fires the "ok" event and closes the dialog if the event succeeds. 888 893 * @static -
_source/plugins/templates/dialogs/templates.js
1 /* 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 */ 5 6 (function() 7 { 8 var doc = CKEDITOR.document; 9 10 var listId = 'cke' + CKEDITOR.tools.getNextNumber(); 11 12 // Constructs the HTML view of the specified templates data. 13 function renderTemplatesList( editor, templatesDefinitions ) 14 { 15 var listDiv = doc.getById( listId ); 16 17 // clear loading wait text. 18 listDiv.setHtml( '' ); 19 20 for ( var i = 0 ; i < templatesDefinitions.length ; i++ ) 21 { 22 var definition = CKEDITOR.getTemplates( templatesDefinitions[ i ] ), 23 imagesPath = definition.imagesPath, 24 templates = definition.templates; 25 26 for ( var j = 0 ; j < templates.length ; j++ ) 27 { 28 var template = templates[ j ]; 29 listDiv.append( createTemplateItem( editor, template, imagesPath ) ); 30 } 31 } 32 } 33 34 function createTemplateItem( editor, template, imagesPath ) 35 { 36 var div = doc.createElement( 'div' ); 37 div.setAttribute( 'class', 'cke_tpl_item' ); 38 39 // Build the inner HTML of our new item DIV. 40 var html = '<table class="cke_tpl_preview"><tr>'; 41 42 if( template.image && imagesPath ) 43 html += '<td class="cke_tpl_preview_img"><img src="' + CKEDITOR.getUrl( imagesPath + template.image ) + '"></td>'; 44 45 html += '<td><span class="cke_tpl_title">' + template.title + '</span><br/>'; 46 47 if( template.description ) 48 html += '<span>' + template.description + '</span>'; 49 50 html += '</td></tr></table>'; 51 52 div.setHtml( html ); 53 54 div.on( 'mouseover', function() 55 { 56 div.addClass( 'cke_tpl_hover' ); 57 }); 58 59 div.on( 'mouseout', function() 60 { 61 div.removeClass( 'cke_tpl_hover' ); 62 }); 63 64 div.on( 'click', function() 65 { 66 insertTemplate( editor, template.html ); 67 }); 68 69 return div; 70 } 71 72 /** 73 * Insert the specified template content 74 * to document. 75 * @param {Number} index 76 */ 77 function insertTemplate( editor, html ) 78 { 79 var dialog = CKEDITOR.dialog.getCurrent(), 80 isInsert = dialog.getValueOf( 'selectTpl', 'chkInsertOpt' ); 81 82 if( isInsert ) 83 { 84 editor.setData( html ); 85 } 86 else 87 { 88 if( CKEDITOR.env.ie ) 89 dialog.restoreSelection(); 90 91 editor.insertHtml( html ); 92 } 93 94 dialog.clearSavedSelection(); 95 dialog.hide(); 96 } 97 98 CKEDITOR.dialog.add( 'templates', function( editor ) 99 { 100 // Load skin at first. 101 CKEDITOR.skins.load( 'default', 'templates' ); 102 103 /** 104 * Load templates once. 105 */ 106 var isLoaded = false; 107 108 return { 109 title :editor.lang.templates.title, 110 111 minWidth :450, 112 minHeight :400, 113 114 contents : 115 [ 116 { 117 id :'selectTpl', 118 label : editor.lang.templates.title, 119 elements : 120 [ 121 { 122 type : 'vbox', 123 padding : 5, 124 children : 125 [ 126 { 127 type : 'html', 128 html : 129 '<span>' + 130 editor.lang.templates.selectPromptMsg + 131 '</span>' 132 }, 133 { 134 type : 'html', 135 html : 136 '<div id="' + listId + '" class="cke_tpl_list">' + 137 '<div class="cke_tpl_loading"><span></span></div>' + 138 '</div>' 139 }, 140 { 141 id : 'chkInsertOpt', 142 type : 'checkbox', 143 label : editor.lang.templates.insertOption, 144 'default' : editor.config.templates_replaceContent 145 } 146 ] 147 } 148 ] 149 } 150 ], 151 152 buttons : [ CKEDITOR.dialog.cancelButton ], 153 154 onShow : function() 155 { 156 CKEDITOR.loadTemplates( editor.config.templates_files, function() 157 { 158 var templates = editor.config.templates.split( ',' ); 159 160 if ( templates.length ) 161 renderTemplatesList( editor, templates ); 162 else 163 { 164 var listCtEl = doc.getById( listId ); 165 listCtEl.setHtml( 166 '<div class="cke_tpl_empty">' + 167 '<span>' + editor.lang.templates.emptyListMsg + '</span>' + 168 '</div>' ); 169 } 170 }); 171 } 172 }; 173 }); 174 })(); -
_source/plugins/templates/plugin.js
1 /* 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 */ 5 6 (function() 7 { 8 CKEDITOR.plugins.add( 'templates', 9 { 10 requires : [ 'dialog' ], 11 12 init : function( editor ) 13 { 14 CKEDITOR.dialog.add( 'templates', CKEDITOR.getUrl( this.path + 'dialogs/templates.js' ) ); 15 16 editor.addCommand( 'templates', new CKEDITOR.dialogCommand( 'templates' ) ); 17 18 editor.ui.addButton( 'Templates', 19 { 20 label : editor.lang.templates.button, 21 command : 'templates' 22 }); 23 } 24 }); 25 26 var templates = {}, 27 loadedTemplatesFiles = {}; 28 29 CKEDITOR.addTemplates = function( name, definition ) 30 { 31 templates[ name ] = definition; 32 }; 33 34 CKEDITOR.getTemplates = function( name ) 35 { 36 return templates[ name ]; 37 }; 38 39 CKEDITOR.loadTemplates = function( templateFiles, callback ) 40 { 41 // Holds the templates files to be loaded. 42 var toLoad = []; 43 44 // Look for pending template files to get loaded. 45 for ( var i = 0 ; i < templateFiles.length ; i++ ) 46 { 47 if ( !loadedTemplatesFiles[ templateFiles[ i ] ] ) 48 { 49 toLoad.push( templateFiles[ i ] ); 50 loadedTemplatesFiles[ templateFiles[ i ] ] = 1; 51 } 52 } 53 54 if ( toLoad.length > 0 ) 55 CKEDITOR.scriptLoader.load( toLoad, callback ); 56 else 57 setTimeout( callback, 0 ); 58 }; 59 })(); 60 61 62 63 /** 64 * The templates definition set to use. It accepts a list of names separated by 65 * comma. It must match definitions loaded with the templates_files setting. 66 * @type String 67 * @default 'default' 68 */ 69 CKEDITOR.config.templates = 'default'; 70 71 /** 72 * The list of templates definition files to load. 73 * @type (String) Array 74 * @default [ 'plugins/templates/templates/default.js' ] 75 */ 76 CKEDITOR.config.templates_files = 77 [ 78 CKEDITOR.getUrl( 79 '_source/' + // %REMOVE_LINE% 80 'plugins/templates/templates/default.js' ) 81 ]; 82 83 /** 84 * Whether replace the current document content OR insert current 85 * editing position. 86 * @type Boolean 87 * @default true 88 */ 89 CKEDITOR.config.templates_replaceContent = true; -
_source/plugins/templates/templates/default.js
1 /* 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 */ 5 6 // Register a templates definition set named "default". 7 CKEDITOR.addTemplates( 'default', 8 { 9 // The name of sub folder which hold the shortcut preview images of the 10 // templates. 11 imagesPath : CKEDITOR.getUrl( CKEDITOR.plugins.getPath( 'templates' ) + 'templates/images/' ), 12 13 // The templates definitions. 14 templates : 15 [ 16 { 17 title: 'Image and Title', 18 image: 'template1.gif', 19 description: 'One main image with a title and text that surround the image.', 20 html: 21 '<h3>' + 22 '<img style="margin-right: 10px" height="100" alt="" width="100" align="left"/>' + 23 'Type the title here'+ 24 '</h3>' + 25 '<p>' + 26 'Type the text here' + 27 '</p>' 28 }, 29 { 30 title: 'Strange Template', 31 image: 'template2.gif', 32 description: 'A template that defines two colums, each one with a title, and some text.', 33 html: 34 '<table cellspacing="0" cellpadding="0" width="100%" border="0">' + 35 '<tr>' + 36 '<td width="50%">' + 37 '<h3>Title 1</h3>' + 38 '</td>' + 39 '<td></td>' + 40 '<td width="50%">' + 41 '<h3>Title 2</h3>' + 42 '</td>' + 43 '</tr>' + 44 '<tr>' + 45 '<td>' + 46 'Text 1' + 47 '</td>' + 48 '<td></td>' + 49 '<td>' + 50 'Text 2' + 51 '</td>' + 52 '</tr>' + 53 '</table>' + 54 '<p>' + 55 'More text goes here.' + 56 '</p>' 57 }, 58 { 59 title: 'Text and Table', 60 image: 'template3.gif', 61 description: 'A title with some text and a table.', 62 html: 63 '<div style="width: 80%">' + 64 '<h3>' + 65 'Title goes here' + 66 '</h3>' + 67 '<table style="float: right" cellspacing="0" cellpadding="0" width="150" border="1">' + 68 '<caption style="border:solid 1px black">' + 69 '<strong>Table title</strong>' + 70 '</caption>' + 71 '</tr>' + 72 '<tr>' + 73 '<td> </td>' + 74 '<td> </td>' + 75 '<td> </td>' + 76 '</tr>' + 77 '<tr>' + 78 '<td> </td>' + 79 '<td> </td>' + 80 '<td> </td>' + 81 '</tr>' + 82 '<tr>' + 83 '<td> </td>' + 84 '<td> </td>' + 85 '<td> </td>' + 86 '</tr>' + 87 '</table>' + 88 '<p>' + 89 'Type the text here' + 90 '</p>' + 91 '</div>' 92 } 93 ] 94 }); -
_source/plugins/toolbar/plugin.js
207 207 [ 208 208 [ 209 209 'Source', '-', 210 'NewPage', 'Preview', ' Print', '-',210 'NewPage', 'Preview', 'Templates', 'Print', '-', 211 211 'Bold', 'Italic', 'Underline', 'Strike', '-', 212 212 'NumberedList', 'BulletedList', '-', 213 213 'Outdent', 'Indent', 'Blockquote', '-', -
_source/skins/default/skin.js
22 22 return { 23 23 preload : preload, 24 24 editor : { css : [ 'editor.css' ] }, 25 dialog : { css : [ 'dialog.css' ], js : dialogJs } 25 dialog : { css : [ 'dialog.css' ], js : dialogJs }, 26 templates : { css : [ 'templates.css' ] } 26 27 }; 27 28 })() ); 28 29 -
_source/skins/default/templates.css
1 /* 2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 3 For licensing, see LICENSE.html or http://ckeditor.com/license 4 */ 5 6 /** 7 * Styles for the "templates" plugin. 8 */ 9 10 .cke_skin_default .cke_tpl_list 11 { 12 border: #dcdcdc 2px solid; 13 background-color: #ffffff; 14 overflow: auto; 15 width: 100%; 16 height: 220px; 17 } 18 19 .cke_skin_default .cke_tpl_item 20 { 21 margin: 5px; 22 padding: 7px; 23 border: #eeeeee 1px solid; 24 *width: 88%; 25 } 26 27 .cke_skin_default .cke_tpl_preview 28 { 29 border-collapse: separate; 30 text-indent:0; 31 width: 100%; 32 } 33 .cke_skin_default .cke_tpl_preview td 34 { 35 padding: 2px; 36 vertical-align: middle; 37 } 38 .cke_skin_default .cke_tpl_preview .cke_tpl_preview_img 39 { 40 width: 100px; 41 } 42 .cke_skin_default .cke_tpl_preview span 43 { 44 white-space: normal; 45 } 46 47 .cke_skin_default .cke_tpl_title 48 { 49 font-weight: bold; 50 } 51 52 .cke_skin_default .cke_tpl_hover 53 { 54 border: #ff9933 1px solid !important; 55 background-color: #fffacd !important; 56 cursor: pointer; 57 cursor: hand; 58 } 59 /* 60 * Fix property 'cursor' doesn't inherit on table 61 */ 62 .cke_skin_default .cke_tpl_hover * 63 { 64 cursor: inherit; 65 } 66 67 .cke_skin_default .cke_tpl_empty, .cke_tpl_loading 68 { 69 text-align: center; 70 padding: 5px; 71 } -
_source/skins/default/toolbar.css
310 310 { 311 311 background-position: 0 -880px; 312 312 } 313 .cke_skin_default a.cke_button_templates .cke_icon 314 { 315 background-position: 0 -80px; 316 } 313 317 314 318 .cke_skin_default a.cke_button_numberedlist .cke_icon 315 319 {