X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fplugins%2Ffind%2Fdialogs%2Ffind.js;h=c0f7d3734041842349fd94e7f0bfd9f2e97026c6;hp=bc9f8a4317db5d81e62c08e629b98fb752613878;hb=039a051ccf3901311661022a30afd60fc38130c9;hpb=c9fdde67e6384bd5a66adc2b3bba5c4ce9db56c7 diff --git a/_source/plugins/find/dialogs/find.js b/_source/plugins/find/dialogs/find.js index bc9f8a4..c0f7d37 100644 --- a/_source/plugins/find/dialogs/find.js +++ b/_source/plugins/find/dialogs/find.js @@ -71,7 +71,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // Style object for highlights: (#5018) // 1. Defined as full match style to avoid compromising ordinary text color styles. // 2. Must be apply onto inner-most text to avoid conflicting with ordinary text color styles visually. - var highlightStyle = new CKEDITOR.style( CKEDITOR.tools.extend( { fullMatch : true, childRule : function(){ return false; } }, + var highlightStyle = new CKEDITOR.style( CKEDITOR.tools.extend( { fullMatch : true, childRule : function(){ return 0; } }, editor.config.find_highlight ) ); /** @@ -83,11 +83,21 @@ For licensing, see LICENSE.html or http://ckeditor.com/license */ var characterWalker = function( range , matchWord ) { + var self = this; var walker = new CKEDITOR.dom.walker( range ); - walker.guard = matchWord ? nonCharactersBoundary : null; + walker.guard = matchWord ? nonCharactersBoundary : function( node ) + { + !nonCharactersBoundary( node ) && ( self._.matchBoundary = true ); + }; walker[ 'evaluator' ] = findEvaluator; - walker.breakOnFalse = true; + walker.breakOnFalse = 1; + + if ( range.startContainer.type == CKEDITOR.NODE_TEXT ) + { + this.textNode = range.startContainer; + this.offset = range.startOffset - 1; + } this._ = { matchWord : matchWord, @@ -111,7 +121,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { var currentTextNode = this.textNode; // Already at the end of document, no more character available. - if ( currentTextNode === null ) + if ( currentTextNode === null ) return cursorStep.call( this ); this._.matchBoundary = false; @@ -142,14 +152,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // Stop searching if we're need full word match OR // already reach document end. if ( this._.matchWord && !currentTextNode - ||this._.walker._.end ) + || this._.walker._.end ) break; - - // Marking as match character boundaries. - if ( !currentTextNode - && !nonCharactersBoundary( this._.walker.current ) ) - this._.matchBoundary = true; - } // Found a fresh text node. this.textNode = currentTextNode; @@ -175,7 +179,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license cursors : [], rangeLength : rangeLength, highlightRange : null, - isMatched : false + isMatched : 0 }; }; @@ -511,7 +515,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // Re-run the finding once for cyclic.(#3517) if ( matchCyclic && !cyclicRerun ) { - this.searchRange = getSearchRange( true ); + this.searchRange = getSearchRange( 1 ); this.matchRange = null; return arguments.callee.apply( this, Array.prototype.slice.call( arguments ).concat( [ true ] ) ); @@ -531,7 +535,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license isReplace = 1; // Successiveness of current replace/find. - var result = false; + var result = 0; // 1. Perform the replace when there's already a match here. // 2. Otherwise perform the find but don't replace it immediately. @@ -561,7 +565,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license this.matchRange.highlight(); this.matchRange._.isReplaced = true; this.replaceCounter++; - result = true; + result = 1; } else result = this.find( pattern, matchCase, matchWord, matchCyclic, !isReplaceAll ); @@ -595,17 +599,18 @@ For licensing, see LICENSE.html or http://ckeditor.com/license return searchRange; } + var lang = editor.lang.findAndReplace; return { - title : editor.lang.findAndReplace.title, + title : lang.title, resizable : CKEDITOR.DIALOG_RESIZE_NONE, minWidth : 350, minHeight : 165, - buttons : [ CKEDITOR.dialog.cancelButton ], //Cancel button only. + buttons : [ CKEDITOR.dialog.cancelButton ], // Cancel button only. contents : [ { id : 'find', - label : editor.lang.findAndReplace.find, - title : editor.lang.findAndReplace.find, + label : lang.find, + title : lang.find, accessKey : '', elements : [ { @@ -616,7 +621,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { type : 'text', id : 'txtFindFind', - label : editor.lang.findAndReplace.findWhat, + label : lang.findWhat, isChanged : false, labelLayout : 'horizontal', accessKey : 'F' @@ -625,7 +630,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license type : 'button', align : 'left', style : 'width:100%', - label : editor.lang.findAndReplace.find, + label : lang.find, onClick : function() { var dialog = this.getDialog(); @@ -633,7 +638,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license dialog.getValueOf( 'find', 'txtFindCaseChk' ), dialog.getValueOf( 'find', 'txtFindWordChk' ), dialog.getValueOf( 'find', 'txtFindCyclic' ) ) ) - alert( editor.lang.findAndReplace + alert( lang .notFoundMsg ); } } @@ -649,20 +654,20 @@ For licensing, see LICENSE.html or http://ckeditor.com/license id : 'txtFindCaseChk', isChanged : false, style : 'margin-top:28px', - label : editor.lang.findAndReplace.matchCase + label : lang.matchCase }, { type : 'checkbox', id : 'txtFindWordChk', isChanged : false, - label : editor.lang.findAndReplace.matchWord + label : lang.matchWord }, { type : 'checkbox', id : 'txtFindCyclic', isChanged : false, 'default' : true, - label : editor.lang.findAndReplace.matchCyclic + label : lang.matchCyclic } ] } @@ -670,7 +675,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license }, { id : 'replace', - label : editor.lang.findAndReplace.replace, + label : lang.replace, accessKey : 'M', elements : [ { @@ -681,7 +686,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { type : 'text', id : 'txtFindReplace', - label : editor.lang.findAndReplace.findWhat, + label : lang.findWhat, isChanged : false, labelLayout : 'horizontal', accessKey : 'F' @@ -690,7 +695,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license type : 'button', align : 'left', style : 'width:100%', - label : editor.lang.findAndReplace.replace, + label : lang.replace, onClick : function() { var dialog = this.getDialog(); @@ -700,7 +705,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license dialog.getValueOf( 'replace', 'txtReplaceCaseChk' ), dialog.getValueOf( 'replace', 'txtReplaceWordChk' ), dialog.getValueOf( 'replace', 'txtReplaceCyclic' ) ) ) - alert( editor.lang.findAndReplace + alert( lang .notFoundMsg ); } } @@ -714,7 +719,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { type : 'text', id : 'txtReplace', - label : editor.lang.findAndReplace.replaceWith, + label : lang.replaceWith, isChanged : false, labelLayout : 'horizontal', accessKey : 'R' @@ -723,7 +728,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license type : 'button', align : 'left', style : 'width:100%', - label : editor.lang.findAndReplace.replaceAll, + label : lang.replaceAll, isChanged : false, onClick : function() { @@ -733,7 +738,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license finder.replaceCounter = 0; // Scope to full document. - finder.searchRange = getSearchRange( true ); + finder.searchRange = getSearchRange( 1 ); if ( finder.matchRange ) { finder.matchRange.removeHighlight(); @@ -750,11 +755,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license if ( finder.replaceCounter ) { - alert( editor.lang.findAndReplace.replaceSuccessMsg.replace( /%1/, finder.replaceCounter ) ); + alert( lang.replaceSuccessMsg.replace( /%1/, finder.replaceCounter ) ); editor.fire( 'saveSnapshot' ); } else - alert( editor.lang.findAndReplace.notFoundMsg ); + alert( lang.notFoundMsg ); } } ] @@ -768,14 +773,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license type : 'checkbox', id : 'txtReplaceCaseChk', isChanged : false, - label : editor.lang.findAndReplace + label : lang .matchCase }, { type : 'checkbox', id : 'txtReplaceWordChk', isChanged : false, - label : editor.lang.findAndReplace + label : lang .matchWord }, { @@ -783,7 +788,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license id : 'txtReplaceCyclic', isChanged : false, 'default' : true, - label : editor.lang.findAndReplace + label : lang .matchCyclic } ] @@ -795,19 +800,19 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { var dialog = this; - //keep track of the current pattern field in use. + // Keep track of the current pattern field in use. var patternField, wholeWordChkField; - //Ignore initial page select on dialog show - var isUserSelect = false; - this.on('hide', function() + // Ignore initial page select on dialog show + var isUserSelect = 0; + this.on( 'hide', function() { - isUserSelect = false; - } ); - this.on('show', function() + isUserSelect = 0; + }); + this.on( 'show', function() { - isUserSelect = true; - } ); + isUserSelect = 1; + }); this.selectPage = CKEDITOR.tools.override( this.selectPage, function( originalFunc ) { @@ -825,7 +830,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license wholeWordChkField = dialog.getContentElement( pageId, wholeWordChkFieldId ); - // prepare for check pattern text filed 'keyup' event + // Prepare for check pattern text filed 'keyup' event if ( !currPage.initialized ) { patternFieldInput = CKEDITOR.document @@ -833,8 +838,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license currPage.initialized = true; } + // Synchronize fields on tab switch. if ( isUserSelect ) - // synchronize fields on tab switch. syncFieldsBetweenTabs.call( this, pageId ); }; } );