Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 1 ), |
74 | 74 | array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 7 ), |
75 | 75 | array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 26 ), |
76 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 81 ), |
| 76 | + array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 82 ), |
77 | 77 | array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 25 ), |
78 | 78 | array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 45 ), |
79 | 79 | array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 11 ), |
— | — | @@ -82,10 +82,10 @@ |
83 | 83 | array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 2 ), |
84 | 84 | ), |
85 | 85 | 'combined' => array( |
86 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 194 ), |
| 86 | + array( 'src' => 'js/plugins.combined.js', 'version' => 195 ), |
87 | 87 | ), |
88 | 88 | 'minified' => array( |
89 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 194 ), |
| 89 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 195 ), |
90 | 90 | ), |
91 | 91 | ), |
92 | 92 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -367,7 +367,7 @@ |
368 | 368 | .replace( /\r?\n/g, "" ) // IE7 inserts newlines before block elements |
369 | 369 | .replace( / /g, " " ) // We inserted these to prevent IE from collapsing spaces |
370 | 370 | + '</pre>' ); |
371 | | - // Get rid of the noincludes when getting text |
| 371 | + // TODO: Optimize this, maybe by converting <br>->\n when not at the beginning or end |
372 | 372 | $pre.find( '.wikiEditor-noinclude' ).each( function() { $( this ).remove(); } ); |
373 | 373 | // Convert tabs, <p>s and <br>s back |
374 | 374 | $pre.find( '.wikiEditor-tab' ).each( function() { $( this ).text( "\t" ) } ); |
— | — | @@ -716,9 +716,20 @@ |
717 | 717 | } |
718 | 718 | e = newE || e; |
719 | 719 | } |
720 | | - while ( e ) { |
721 | | - if ( $( e ).is( selector ) && !strict ) |
722 | | - return $( e ); |
| 720 | + |
| 721 | + // We'd normally use if( $( e ).is( selector ) in the while loop, but running the jQuery |
| 722 | + // constructor thousands of times is very inefficient |
| 723 | + // Instead, tag all occurrences of selector |
| 724 | + if ( selector != '*' ) { |
| 725 | + var occurrences = context.$content.find( selector ); |
| 726 | + occurrences.addClass( 'wikiEditor-beforeSelection-tagged' ); |
| 727 | + } |
| 728 | + var retval = null; |
| 729 | + while ( e && !retval ) { |
| 730 | + if ( !strict && ( selector == '*' || ( ' ' + e.className + ' ' ) |
| 731 | + .indexOf( ' wikiEditor-beforeSelection-tagged ' ) != -1 ) ) { |
| 732 | + retval = $( e ); |
| 733 | + } |
723 | 734 | var next = e.previousSibling; |
724 | 735 | while ( next && next.lastChild ) { |
725 | 736 | next = next.lastChild; |
— | — | @@ -726,7 +737,9 @@ |
727 | 738 | e = next || e.parentNode; |
728 | 739 | strict = false; |
729 | 740 | } |
730 | | - return $( [] ); |
| 741 | + if ( selector != '*' ) |
| 742 | + occurrences.removeClass( 'wikiEditor-beforeSelection-tagged' ); |
| 743 | + return retval || $( [] ); |
731 | 744 | }, |
732 | 745 | /** |
733 | 746 | * Get an object used to traverse the leaf nodes in the iframe DOM. This traversal skips leaf nodes |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -6791,7 +6791,7 @@ |
6792 | 6792 | .replace( /\r?\n/g, "" ) // IE7 inserts newlines before block elements |
6793 | 6793 | .replace( / /g, " " ) // We inserted these to prevent IE from collapsing spaces |
6794 | 6794 | + '</pre>' ); |
6795 | | - // Get rid of the noincludes when getting text |
| 6795 | + // TODO: Optimize this, maybe by converting <br>->\n when not at the beginning or end |
6796 | 6796 | $pre.find( '.wikiEditor-noinclude' ).each( function() { $( this ).remove(); } ); |
6797 | 6797 | // Convert tabs, <p>s and <br>s back |
6798 | 6798 | $pre.find( '.wikiEditor-tab' ).each( function() { $( this ).text( "\t" ) } ); |
— | — | @@ -7140,9 +7140,20 @@ |
7141 | 7141 | } |
7142 | 7142 | e = newE || e; |
7143 | 7143 | } |
7144 | | - while ( e ) { |
7145 | | - if ( $( e ).is( selector ) && !strict ) |
7146 | | - return $( e ); |
| 7144 | + |
| 7145 | + // We'd normally use if( $( e ).is( selector ) in the while loop, but running the jQuery |
| 7146 | + // constructor thousands of times is very inefficient |
| 7147 | + // Instead, tag all occurrences of selector |
| 7148 | + if ( selector != '*' ) { |
| 7149 | + var occurrences = context.$content.find( selector ); |
| 7150 | + occurrences.addClass( 'wikiEditor-beforeSelection-tagged' ); |
| 7151 | + } |
| 7152 | + var retval = null; |
| 7153 | + while ( e && !retval ) { |
| 7154 | + if ( !strict && ( selector == '*' || ( ' ' + e.className + ' ' ) |
| 7155 | + .indexOf( ' wikiEditor-beforeSelection-tagged ' ) != -1 ) ) { |
| 7156 | + retval = $( e ); |
| 7157 | + } |
7147 | 7158 | var next = e.previousSibling; |
7148 | 7159 | while ( next && next.lastChild ) { |
7149 | 7160 | next = next.lastChild; |
— | — | @@ -7150,7 +7161,9 @@ |
7151 | 7162 | e = next || e.parentNode; |
7152 | 7163 | strict = false; |
7153 | 7164 | } |
7154 | | - return $( [] ); |
| 7165 | + if ( selector != '*' ) |
| 7166 | + occurrences.removeClass( 'wikiEditor-beforeSelection-tagged' ); |
| 7167 | + return retval || $( [] ); |
7155 | 7168 | }, |
7156 | 7169 | /** |
7157 | 7170 | * Get an object used to traverse the leaf nodes in the iframe DOM. This traversal skips leaf nodes |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -479,10 +479,12 @@ |
480 | 480 | if(e.nodeName!='#text'){var newE=e.firstChild;for(var i=0;i<offset-1&&newE;i++){newE=newE.nextSibling;} |
481 | 481 | while(newE&&newE.lastChild){newE=newE.lastChild;} |
482 | 482 | e=newE||e;} |
483 | | -while(e){if($(e).is(selector)&&!strict) |
484 | | -return $(e);var next=e.previousSibling;while(next&&next.lastChild){next=next.lastChild;} |
| 483 | +if(selector!='*'){var occurrences=context.$content.find(selector);occurrences.addClass('wikiEditor-beforeSelection-tagged');} |
| 484 | +var retval=null;while(e&&!retval){if(!strict&&(selector=='*'||(' '+e.className+' ').indexOf(' wikiEditor-beforeSelection-tagged ')!=-1)){retval=$(e);} |
| 485 | +var next=e.previousSibling;while(next&&next.lastChild){next=next.lastChild;} |
485 | 486 | e=next||e.parentNode;strict=false;} |
486 | | -return $([]);},'traverser':function(start){function Traverser(node,depth,inP){this.node=node;this.depth=depth;this.inP=inP;this.next=function(){var p=this.node;var nextDepth=this.depth;var nextInP=this.inP;while(p&&!p.nextSibling){if(p.nodeName=="P"){nextInP=false;} |
| 487 | +if(selector!='*') |
| 488 | +occurrences.removeClass('wikiEditor-beforeSelection-tagged');return retval||$([]);},'traverser':function(start){function Traverser(node,depth,inP){this.node=node;this.depth=depth;this.inP=inP;this.next=function(){var p=this.node;var nextDepth=this.depth;var nextInP=this.inP;while(p&&!p.nextSibling){if(p.nodeName=="P"){nextInP=false;} |
487 | 489 | p=p.parentNode;nextDepth--;if(nextDepth==0){p=null;}} |
488 | 490 | p=p?p.nextSibling:null;do{while(p&&(' '+p.className+' ').indexOf(' wikiEditor-noinclude ')!=-1){p=p.nextSibling;} |
489 | 491 | if(p&&p.firstChild){p=p.firstChild;nextDepth++;if(p.nodeName=="P"){nextInP=true;}}}while(p&&p.firstChild);return p?new Traverser(p,nextDepth,nextInP):null;};} |