JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.2
[ckeditor.git] / _source / plugins / find / dialogs / find.js
index c0f7d37..d845166 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -71,8 +71,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                // Style object for highlights: (#5018)\r
                // 1. Defined as full match style to avoid compromising ordinary text color styles.\r
                // 2. Must be apply onto inner-most text to avoid conflicting with ordinary text color styles visually.\r
-               var highlightStyle = new CKEDITOR.style( CKEDITOR.tools.extend( { fullMatch : true, childRule : function(){ return 0; } },\r
-                       editor.config.find_highlight ) );\r
+               var highlightStyle = new CKEDITOR.style(\r
+                       CKEDITOR.tools.extend( { attributes : { 'data-cke-highlight': 1 }, fullMatch : 1, ignoreReadonly : 1, childRule : function(){ return 0; } },\r
+                       editor.config.find_highlight, true ) );\r
 \r
                /**\r
                 * Iterator which walk through the specified range char by char. By\r
@@ -604,7 +605,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        title : lang.title,\r
                        resizable : CKEDITOR.DIALOG_RESIZE_NONE,\r
                        minWidth : 350,\r
-                       minHeight : 165,\r
+                       minHeight : 170,\r
                        buttons : [ CKEDITOR.dialog.cancelButton ],             // Cancel button only.\r
                        contents : [\r
                                {\r
@@ -628,6 +629,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                },\r
                                                                {\r
                                                                        type : 'button',\r
+                                                                       id : 'btnFind',\r
                                                                        align : 'left',\r
                                                                        style : 'width:100%',\r
                                                                        label : lang.find,\r
@@ -645,29 +647,36 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                        ]\r
                                                },\r
                                                {\r
-                                                       type : 'vbox',\r
-                                                       padding : 0,\r
+                                                       type : 'fieldset',\r
+                                                       label : CKEDITOR.tools.htmlEncode( lang.findOptions ),\r
+                                                       style : 'margin-top:29px',\r
                                                        children :\r
                                                        [\r
                                                                {\r
-                                                                       type : 'checkbox',\r
-                                                                       id : 'txtFindCaseChk',\r
-                                                                       isChanged : false,\r
-                                                                       style : 'margin-top:28px',\r
-                                                                       label : lang.matchCase\r
-                                                               },\r
-                                                               {\r
-                                                                       type : 'checkbox',\r
-                                                                       id : 'txtFindWordChk',\r
-                                                                       isChanged : false,\r
-                                                                       label : lang.matchWord\r
-                                                               },\r
-                                                               {\r
-                                                                       type : 'checkbox',\r
-                                                                       id : 'txtFindCyclic',\r
-                                                                       isChanged : false,\r
-                                                                       'default' : true,\r
-                                                                       label : lang.matchCyclic\r
+                                                                       type : 'vbox',\r
+                                                                       padding : 0,\r
+                                                                       children :\r
+                                                                       [\r
+                                                                               {\r
+                                                                                       type : 'checkbox',\r
+                                                                                       id : 'txtFindCaseChk',\r
+                                                                                       isChanged : false,\r
+                                                                                       label : lang.matchCase\r
+                                                                               },\r
+                                                                               {\r
+                                                                                       type : 'checkbox',\r
+                                                                                       id : 'txtFindWordChk',\r
+                                                                                       isChanged : false,\r
+                                                                                       label : lang.matchWord\r
+                                                                               },\r
+                                                                               {\r
+                                                                                       type : 'checkbox',\r
+                                                                                       id : 'txtFindCyclic',\r
+                                                                                       isChanged : false,\r
+                                                                                       'default' : true,\r
+                                                                                       label : lang.matchCyclic\r
+                                                                               }\r
+                                                                       ]\r
                                                                }\r
                                                        ]\r
                                                }\r
@@ -693,6 +702,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                },\r
                                                                {\r
                                                                        type : 'button',\r
+                                                                       id : 'btnFindReplace',\r
                                                                        align : 'left',\r
                                                                        style : 'width:100%',\r
                                                                        label : lang.replace,\r
@@ -726,6 +736,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                },\r
                                                                {\r
                                                                        type : 'button',\r
+                                                                       id : 'btnReplaceAll',\r
                                                                        align : 'left',\r
                                                                        style : 'width:100%',\r
                                                                        label : lang.replaceAll,\r
@@ -765,31 +776,35 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                        ]\r
                                                },\r
                                                {\r
-                                                       type : 'vbox',\r
-                                                       padding : 0,\r
+                                                       type : 'fieldset',\r
+                                                       label : CKEDITOR.tools.htmlEncode( lang.findOptions ),\r
                                                        children :\r
                                                        [\r
                                                                {\r
-                                                                       type : 'checkbox',\r
-                                                                       id : 'txtReplaceCaseChk',\r
-                                                                       isChanged : false,\r
-                                                                       label : lang\r
-                                                                               .matchCase\r
-                                                               },\r
-                                                               {\r
-                                                                       type : 'checkbox',\r
-                                                                       id : 'txtReplaceWordChk',\r
-                                                                       isChanged : false,\r
-                                                                       label : lang\r
-                                                                               .matchWord\r
-                                                               },\r
-                                                               {\r
-                                                                       type : 'checkbox',\r
-                                                                       id : 'txtReplaceCyclic',\r
-                                                                       isChanged : false,\r
-                                                                       'default' : true,\r
-                                                                       label : lang\r
-                                                                               .matchCyclic\r
+                                                                       type : 'vbox',\r
+                                                                       padding : 0,\r
+                                                                       children :\r
+                                                                       [\r
+                                                                               {\r
+                                                                                       type : 'checkbox',\r
+                                                                                       id : 'txtReplaceCaseChk',\r
+                                                                                       isChanged : false,\r
+                                                                                       label : lang.matchCase\r
+                                                                               },\r
+                                                                               {\r
+                                                                                       type : 'checkbox',\r
+                                                                                       id : 'txtReplaceWordChk',\r
+                                                                                       isChanged : false,\r
+                                                                                       label : lang.matchWord\r
+                                                                               },\r
+                                                                               {\r
+                                                                                       type : 'checkbox',\r
+                                                                                       id : 'txtReplaceCyclic',\r
+                                                                                       isChanged : false,\r
+                                                                                       'default' : true,\r
+                                                                                       label : lang.matchCyclic\r
+                                                                               }\r
+                                                                       ]\r
                                                                }\r
                                                        ]\r
                                                }\r
@@ -850,7 +865,17 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                // Establish initial searching start position.\r
                                finder.searchRange = getSearchRange();\r
 \r
+                               // Fill in the find field with selected text.\r
+                               var selectedText = this.getParentEditor().getSelection().getSelectedText(),\r
+                                       patternFieldId = ( startupPage == 'find' ? 'txtFindFind' : 'txtFindReplace' );\r
+\r
+                               var field = this.getContentElement( startupPage, patternFieldId );\r
+                               field.setValue( selectedText );\r
+                               field.select();\r
+\r
                                this.selectPage( startupPage );\r
+\r
+                               this[ ( startupPage == 'find' && this._.editor.readOnly? 'hide' : 'show' ) + 'Page' ]( 'replace');\r
                        },\r
                        onHide : function()\r
                        {\r