Index: branches/wmf/1.16wmf4/extensions/UsabilityInitiative/css/suggestions.css |
— | — | @@ -9,6 +9,7 @@ |
10 | 10 | border: none; |
11 | 11 | z-index: 99; |
12 | 12 | padding: 0; |
| 13 | + margin: -1px 0 0 0; |
13 | 14 | } |
14 | 15 | .suggestions-special { |
15 | 16 | position: relative; |
— | — | @@ -29,7 +30,6 @@ |
30 | 31 | font-size: 0.8em; |
31 | 32 | cursor: pointer; |
32 | 33 | border: solid 1px #aaaaaa; |
33 | | - border-top-width: 0; |
34 | 34 | padding: 0; |
35 | 35 | margin: 0; |
36 | 36 | } |
Index: branches/wmf/1.16wmf4/extensions/UsabilityInitiative/css/combined.css |
— | — | @@ -9,6 +9,7 @@ |
10 | 10 | border: none; |
11 | 11 | z-index: 99; |
12 | 12 | padding: 0; |
| 13 | + margin: -1px 0 0 0; |
13 | 14 | } |
14 | 15 | .suggestions-special { |
15 | 16 | position: relative; |
— | — | @@ -29,7 +30,6 @@ |
30 | 31 | font-size: 0.8em; |
31 | 32 | cursor: pointer; |
32 | 33 | border: solid 1px #aaaaaa; |
33 | | - border-top-width: 0; |
34 | 34 | padding: 0; |
35 | 35 | margin: 0; |
36 | 36 | } |
Index: branches/wmf/1.16wmf4/extensions/UsabilityInitiative/css/combined.min.css |
— | — | @@ -7,6 +7,7 @@ |
8 | 8 | border:none; |
9 | 9 | z-index:99; |
10 | 10 | padding:0; |
| 11 | +margin:-1px 0 0 0; |
11 | 12 | } |
12 | 13 | .suggestions-special{ |
13 | 14 | position:relative; |
— | — | @@ -27,7 +28,6 @@ |
28 | 29 | font-size:0.8em; |
29 | 30 | cursor:pointer; |
30 | 31 | border:solid 1px #aaaaaa; |
31 | | -border-top-width:0; |
32 | 32 | padding:0; |
33 | 33 | margin:0; |
34 | 34 | } |
Property changes on: branches/wmf/1.16wmf4/extensions/UsabilityInitiative/OptIn |
___________________________________________________________________ |
Name: svn:mergeinfo |
35 | 35 | - /branches/REL1_15/phase3/extensions/UsabilityInitiative/OptIn:51646 |
/branches/wmf-deployment/extensions/UsabilityInitiative/OptIn:60970 |
/trunk/extensions/UsabilityInitiative/OptIn:56207,56209,56296,56333,56355,62041,62043,62127,62139-62140,62142-62143,62145-62146,62256,62263,62266-63865,63867-63877,63879-64124,64129-64645,64647-64648,64650-66321,66402 |
/trunk/phase3/extensions/UsabilityInitiative/OptIn:56213,56215-56216,56218,56325,56334-56336,56338,56340,56343,56345,56347,56350,57154-57447,57541,57916,58151,58219,58633,58816 |
36 | 36 | + /branches/REL1_15/phase3/extensions/UsabilityInitiative/OptIn:51646 |
/branches/wmf-deployment/extensions/UsabilityInitiative/OptIn:60970 |
/trunk/extensions/UsabilityInitiative/OptIn:56207,56209,56296,56333,56355,62041,62043,62127,62139-62140,62142-62143,62145-62146,62256,62263,62266-63865,63867-63877,63879-64124,64129-64645,64647-64648,64650-66321,66402,66565,66623,66631,66642-66644,66655 |
/trunk/phase3/extensions/UsabilityInitiative/OptIn:56213,56215-56216,56218,56325,56334-56336,56338,56340,56343,56345,56347,56350,57154-57447,57541,57916,58151,58219,58633,58816 |
Index: branches/wmf/1.16wmf4/extensions/UsabilityInitiative/Vector/Modules/SimpleSearch/SimpleSearch.js |
— | — | @@ -74,7 +74,8 @@ |
75 | 75 | $textbox.closest( 'form' ).submit(); |
76 | 76 | } |
77 | 77 | }, |
78 | | - delay: 120 |
| 78 | + delay: 120, |
| 79 | + positionFromLeft: $j( 'body' ).is( '.rtl' ) |
79 | 80 | } ); |
80 | 81 | $j( '#searchInput' ).suggestions( { |
81 | 82 | result: { |
Index: branches/wmf/1.16wmf4/extensions/UsabilityInitiative/Vector/Vector.hooks.php |
— | — | @@ -16,13 +16,13 @@ |
17 | 17 | array( 'src' => 'Modules/CollapsibleTabs/CollapsibleTabs.js', 'version' => 8 ), |
18 | 18 | array( 'src' => 'Modules/EditWarning/EditWarning.js', 'version' => 8 ), |
19 | 19 | array( 'src' => 'Modules/FooterCleanup/FooterCleanup.js', 'version' => 5 ), |
20 | | - array( 'src' => 'Modules/SimpleSearch/SimpleSearch.js', 'version' => 9 ), |
| 20 | + array( 'src' => 'Modules/SimpleSearch/SimpleSearch.js', 'version' => 11 ), |
21 | 21 | ), |
22 | 22 | 'combined' => array( |
23 | | - array( 'src' => 'Vector.combined.js', 'version' => 29 ), |
| 23 | + array( 'src' => 'Vector.combined.js', 'version' => 31 ), |
24 | 24 | ), |
25 | 25 | 'minified' => array( |
26 | | - array( 'src' => 'Vector.combined.min.js', 'version' => 29 ), |
| 26 | + array( 'src' => 'Vector.combined.min.js', 'version' => 31 ), |
27 | 27 | ), |
28 | 28 | ); |
29 | 29 | static $modules = array( |
Index: branches/wmf/1.16wmf4/extensions/UsabilityInitiative/Vector/Vector.combined.js |
— | — | @@ -335,7 +335,8 @@ |
336 | 336 | $textbox.closest( 'form' ).submit(); |
337 | 337 | } |
338 | 338 | }, |
339 | | - delay: 120 |
| 339 | + delay: 120, |
| 340 | + positionFromLeft: $j( 'body' ).is( '.rtl' ) |
340 | 341 | } ); |
341 | 342 | $j( '#searchInput' ).suggestions( { |
342 | 343 | result: { |
Index: branches/wmf/1.16wmf4/extensions/UsabilityInitiative/Vector/Vector.combined.min.js |
— | — | @@ -14,5 +14,5 @@ |
15 | 15 | +transclusionCount |
16 | 16 | +'</strong> other pages.</label>');$j('.mw-templatesUsedExplanation').remove();$j('.collapsible-list label').click(function(){$j(this).parent().toggleClass('expanded').toggleClass('collapsed').find('ul').slideToggle('fast');return false;}).trigger('click');$j('#wpPreview, #wpDiff, .editHelp, #editpage-specialchars').remove();$j('#mw-editform-cancel').remove().appendTo('.editButtons');});if(wgVectorEnabledModules.simplesearch&&skin=='vector'&&typeof os_autoload_inputs!=='undefined'&&os_autoload_forms!=='undefined'){os_autoload_inputs=[];os_autoload_forms=[];} |
17 | 17 | $j(document).ready(function(){if(!wgVectorEnabledModules.simplesearch||skin!='vector'){return true;} |
18 | | -$j('div#simpleSearch > input#searchInput').each(function(){$j('<label />').text(mw.usability.getMsg('vector-simplesearch-search')).css({'display':'none','position':'absolute','bottom':0,'padding':'0.25em','color':'#999999','cursor':'text'}).css(($j('body').is('.rtl')?'right':'left'),0).click(function(){$j(this).parent().find('input#searchInput').focus();}).appendTo($j(this).parent());if($j(this).val()==''){$j(this).parent().find('label').fadeIn(100);}}).focus(function(){$j(this).parent().find('label').fadeOut(100);}).blur(function(){if($j(this).val()==''){$j(this).parent().find('label').fadeIn(100);}});$j('#searchInput, #searchInput2, #powerSearchText, #searchText').suggestions({fetch:function(query){var $this=$j(this);var request=$j.ajax({url:wgScriptPath+'/api.php',data:{'action':'opensearch','search':query,'namespace':0,'suggest':''},dataType:'json',success:function(data){$this.suggestions('suggestions',data[1]);}});$j(this).data('request',request);},cancel:function(){var request=$j(this).data('request');if(request&&typeof request.abort=='function'){request.abort();$j(this).removeData('request');}},result:{select:function($textbox){$textbox.closest('form').submit();}},delay:120});$j('#searchInput').suggestions({result:{select:function($textbox){$textbox.closest('form').submit();}},special:{render:function(query){if($j(this).children().size()==0){$j(this).show() |
| 18 | +$j('div#simpleSearch > input#searchInput').each(function(){$j('<label />').text(mw.usability.getMsg('vector-simplesearch-search')).css({'display':'none','position':'absolute','bottom':0,'padding':'0.25em','color':'#999999','cursor':'text'}).css(($j('body').is('.rtl')?'right':'left'),0).click(function(){$j(this).parent().find('input#searchInput').focus();}).appendTo($j(this).parent());if($j(this).val()==''){$j(this).parent().find('label').fadeIn(100);}}).focus(function(){$j(this).parent().find('label').fadeOut(100);}).blur(function(){if($j(this).val()==''){$j(this).parent().find('label').fadeIn(100);}});$j('#searchInput, #searchInput2, #powerSearchText, #searchText').suggestions({fetch:function(query){var $this=$j(this);var request=$j.ajax({url:wgScriptPath+'/api.php',data:{'action':'opensearch','search':query,'namespace':0,'suggest':''},dataType:'json',success:function(data){$this.suggestions('suggestions',data[1]);}});$j(this).data('request',request);},cancel:function(){var request=$j(this).data('request');if(request&&typeof request.abort=='function'){request.abort();$j(this).removeData('request');}},result:{select:function($textbox){$textbox.closest('form').submit();}},delay:120,positionFromLeft:$j('body').is('.rtl')});$j('#searchInput').suggestions({result:{select:function($textbox){$textbox.closest('form').submit();}},special:{render:function(query){if($j(this).children().size()==0){$j(this).show() |
19 | 19 | $label=$j('<div />').addClass('special-label').text(mw.usability.getMsg('vector-simplesearch-containing')).appendTo($j(this));$query=$j('<div />').addClass('special-query').text(query).appendTo($j(this));$query.autoEllipsis();}else{$j(this).find('.special-query').empty().text(query).autoEllipsis();}},select:function($textbox){$textbox.closest('form').append($j('<input />').attr({'type':'hidden','name':'fulltext','value':1}));$textbox.closest('form').submit();}},$region:$j('#simpleSearch')});}); |
\ No newline at end of file |
Index: branches/wmf/1.16wmf4/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | private static $styleFiles = array( |
20 | 20 | 'base_sets' => array( |
21 | 21 | 'raw' => array( |
22 | | - array( 'src' => 'css/suggestions.css', 'version' => 12 ), |
| 22 | + array( 'src' => 'css/suggestions.css', 'version' => 13 ), |
23 | 23 | array( 'src' => 'css/vector.collapsibleNav.css', 'version' => 9 ), |
24 | 24 | array( 'src' => 'css/vector.footerCleanup.css', 'version' => 2 ), |
25 | 25 | array( 'src' => 'css/wikiEditor.css', 'version' => 13 ), |
— | — | @@ -29,11 +29,11 @@ |
30 | 30 | array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2y' ), |
31 | 31 | ), |
32 | 32 | 'combined' => array( |
33 | | - array( 'src' => 'css/combined.css', 'version' => 92 ), |
| 33 | + array( 'src' => 'css/combined.css', 'version' => 93 ), |
34 | 34 | array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2y' ), |
35 | 35 | ), |
36 | 36 | 'minified' => array( |
37 | | - array( 'src' => 'css/combined.min.css', 'version' => 92 ), |
| 37 | + array( 'src' => 'css/combined.min.css', 'version' => 93 ), |
38 | 38 | array( 'src' => 'css/vector/jquery-ui-1.7.2.css', 'version' => '1.7.2y' ), |
39 | 39 | ), |
40 | 40 | ) |
— | — | @@ -64,13 +64,14 @@ |
65 | 65 | |
66 | 66 | // Core functionality of extension scripts |
67 | 67 | array( 'src' => 'js/plugins/jquery.async.js', 'version' => 3 ), |
68 | | - array( 'src' => 'js/plugins/jquery.autoEllipsis.js', 'version' => 7 ), |
| 68 | + array( 'src' => 'js/plugins/jquery.autoEllipsis.js', 'version' => 8 ), |
69 | 69 | array( 'src' => 'js/plugins/jquery.browser.js', 'version' => 6 ), |
70 | 70 | array( 'src' => 'js/plugins/jquery.collapsibleTabs.js', 'version' => 6 ), |
71 | 71 | array( 'src' => 'js/plugins/jquery.color.js', 'version' => 1 ), |
72 | 72 | array( 'src' => 'js/plugins/jquery.cookie.js', 'version' => 4 ), |
73 | 73 | array( 'src' => 'js/plugins/jquery.delayedBind.js', 'version' => 1 ), |
74 | | - array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 14 ), |
| 74 | + array( 'src' => 'js/plugins/jquery.expandableField.js', 'version' => 15 ), |
| 75 | + array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 18 ), |
75 | 76 | array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 33 ), |
76 | 77 | array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 187 ), |
77 | 78 | array( 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', 'version' => 53 ), |
— | — | @@ -83,10 +84,10 @@ |
84 | 85 | array( 'src' => 'js/plugins/jquery.wikiEditor.publish.js', 'version' => 5 ), |
85 | 86 | ), |
86 | 87 | 'combined' => array( |
87 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 396 ), |
| 88 | + array( 'src' => 'js/plugins.combined.js', 'version' => 402 ), |
88 | 89 | ), |
89 | 90 | 'minified' => array( |
90 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 396 ), |
| 91 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 402 ), |
91 | 92 | ), |
92 | 93 | ), |
93 | 94 | ); |
Property changes on: branches/wmf/1.16wmf4/extensions/UsabilityInitiative/js/plugins/jquery.textSelection.js |
___________________________________________________________________ |
Name: svn:mergeinfo |
94 | 95 | - /branches/wmf-deployment/extensions/UsabilityInitiative/js/plugins/jquery.textSelection.js:60970 |
/trunk/extensions/UsabilityInitiative/js/plugins/jquery.textSelection.js:62041,62043,62127,62139,62142-62143,62145-62146,62256,62263,62274,62341,62371,62380,62384,62392-62396,62458,62552,63864-63865,63867-63877,63879-64124,64129-64645,64647-64648,64650-66321,66331-66335,66402 |
95 | 96 | + /branches/wmf-deployment/extensions/UsabilityInitiative/js/plugins/jquery.textSelection.js:60970 |
/trunk/extensions/UsabilityInitiative/js/plugins/jquery.textSelection.js:62041,62043,62127,62139,62142-62143,62145-62146,62256,62263,62274,62341,62371,62380,62384,62392-62396,62458,62552,63864-63865,63867-63877,63879-64124,64129-64645,64647-64648,64650-66321,66331-66335,66402,66565,66623,66631,66642-66644,66655 |
Property changes on: branches/wmf/1.16wmf4/extensions/UsabilityInitiative/js/plugins/jquery.cookie.js |
___________________________________________________________________ |
Name: svn:mergeinfo |
96 | 97 | - /branches/wmf-deployment/extensions/UsabilityInitiative/js/plugins/jquery.cookie.js:60970 |
/trunk/extensions/UsabilityInitiative/js/plugins/jquery.cookie.js:62041,62043,62127,62139,62142-62143,62145-62146,62256,62263,62274,62341,62371,62380,62384,62392-62396,62458,62552,63864-63865,63867-63877,63879-64124,64129-64645,64647-64648,64650-66321,66402 |
97 | 98 | + /branches/wmf-deployment/extensions/UsabilityInitiative/js/plugins/jquery.cookie.js:60970 |
/trunk/extensions/UsabilityInitiative/js/plugins/jquery.cookie.js:62041,62043,62127,62139,62142-62143,62145-62146,62256,62263,62274,62341,62371,62380,62384,62392-62396,62458,62552,63864-63865,63867-63877,63879-64124,64129-64645,64647-64648,64650-66321,66402,66565,66623,66631,66642-66644,66655 |
Index: branches/wmf/1.16wmf4/extensions/UsabilityInitiative/js/plugins/jquery.suggestions.js |
— | — | @@ -31,6 +31,13 @@ |
32 | 32 | * Type: Number, Range: 1 - 100, Default: 7 |
33 | 33 | * delay: Number of ms to wait for the user to stop typing |
34 | 34 | * Type: Number, Range: 0 - 1200, Default: 120 |
| 35 | + * submitOnClick: Whether to submit the form containing the textbox when a suggestion is clicked |
| 36 | + * Type: Boolean, Default: false |
| 37 | + * maxExpandFactor: Maximum suggestions box width relative to the textbox width. If set to e.g. 2, the suggestions box |
| 38 | + * will never be grown beyond 2 times the width of the textbox. |
| 39 | + * Type: Number, Range: 1 - infinity, Default: 3 |
| 40 | + * positionFromLeft: Whether to position the suggestion box with the left attribute or the right |
| 41 | + * Type: Boolean, Default: true |
35 | 42 | */ |
36 | 43 | ( function( $ ) { |
37 | 44 | |
— | — | @@ -120,18 +127,26 @@ |
121 | 128 | // Rebuild the suggestions list |
122 | 129 | context.data.$container.show(); |
123 | 130 | // Update the size and position of the list |
124 | | - context.data.$container.css( { |
| 131 | + var newCSS = { |
125 | 132 | 'top': context.config.$region.offset().top + context.config.$region.outerHeight(), |
126 | 133 | 'bottom': 'auto', |
127 | 134 | 'width': context.config.$region.outerWidth(), |
128 | | - 'height': 'auto', |
129 | | - 'left': context.config.$region.offset().left, |
130 | | - 'right': 'auto' |
131 | | - } ); |
| 135 | + 'height': 'auto' |
| 136 | + } |
| 137 | + if ( context.config.positionFromLeft ) { |
| 138 | + newCSS['left'] = context.config.$region.offset().left; |
| 139 | + newCSS['right'] = 'auto'; |
| 140 | + } else { |
| 141 | + newCSS['left'] = 'auto'; |
| 142 | + newCSS['right'] = $( 'body' ).width() - ( context.config.$region.offset().left + context.config.$region.outerWidth() ); |
| 143 | + } |
| 144 | + context.data.$container.css( newCSS ); |
132 | 145 | var $results = context.data.$container.children( '.suggestions-results' ); |
133 | 146 | $results.empty(); |
| 147 | + var expWidth = -1; |
| 148 | + var $autoEllipseMe = $( [] ); |
134 | 149 | for ( var i = 0; i < context.config.suggestions.length; i++ ) { |
135 | | - $result = $( '<div />' ) |
| 150 | + var $result = $( '<div />' ) |
136 | 151 | .addClass( 'suggestions-result' ) |
137 | 152 | .attr( 'rel', i ) |
138 | 153 | .data( 'text', context.config.suggestions[i] ) |
— | — | @@ -141,13 +156,33 @@ |
142 | 157 | ); |
143 | 158 | } ) |
144 | 159 | .appendTo( $results ); |
| 160 | + |
145 | 161 | // Allow custom rendering |
146 | 162 | if ( typeof context.config.result.render == 'function' ) { |
147 | 163 | context.config.result.render.call( $result, context.config.suggestions[i] ); |
148 | 164 | } else { |
149 | | - $result.text( context.config.suggestions[i] ).autoEllipsis(); |
| 165 | + // Add <span> with text |
| 166 | + $result.append( $( '<span />' ) |
| 167 | + .css( 'whiteSpace', 'nowrap' ) |
| 168 | + .text( context.config.suggestions[i] ) |
| 169 | + ); |
| 170 | + |
| 171 | + // Widen results box if needed |
| 172 | + // New width is only calculated here, applied later |
| 173 | + var $span = $result.children( 'span' ); |
| 174 | + if ( $span.outerWidth() > $result.width() && $span.outerWidth() > expWidth ) { |
| 175 | + expWidth = $span.outerWidth(); |
| 176 | + } |
| 177 | + $autoEllipseMe = $autoEllipseMe.add( $result ); |
150 | 178 | } |
151 | 179 | } |
| 180 | + // Apply new width for results box, if any |
| 181 | + if ( expWidth > context.data.$container.width() ) { |
| 182 | + var maxWidth = context.config.maxExpandFactor*context.data.$textbox.width(); |
| 183 | + context.data.$container.width( Math.min( expWidth, maxWidth ) ); |
| 184 | + } |
| 185 | + // autoEllipse the results. Has to be done after changing the width |
| 186 | + $autoEllipseMe.autoEllipsis( { hasSpan: true, tooltip: true } ); |
152 | 187 | } |
153 | 188 | } |
154 | 189 | break; |
— | — | @@ -157,7 +192,11 @@ |
158 | 193 | case 'delay': |
159 | 194 | context.config[property] = Math.max( 0, Math.min( 1200, value ) ); |
160 | 195 | break; |
| 196 | + case 'maxExpandFactor': |
| 197 | + context.config[property] = Math.max( 1, value ); |
| 198 | + break; |
161 | 199 | case 'submitOnClick': |
| 200 | + case 'positionFromLeft': |
162 | 201 | context.config[property] = value ? true : false; |
163 | 202 | break; |
164 | 203 | } |
— | — | @@ -258,7 +297,11 @@ |
259 | 298 | context.data.$container.hide(); |
260 | 299 | preventDefault = wasVisible; |
261 | 300 | selected = context.data.$container.find( '.suggestions-result-current' ); |
262 | | - if ( selected.is( '.suggestions-special' ) ) { |
| 301 | + if ( selected.size() == 0 ) { |
| 302 | + // if nothing is selected, cancel any current requests and submit the form |
| 303 | + $.suggestions.cancel( context ); |
| 304 | + context.config.$region.closest( 'form' ).submit(); |
| 305 | + } else if ( selected.is( '.suggestions-special' ) ) { |
263 | 306 | if ( typeof context.config.special.select == 'function' ) { |
264 | 307 | context.config.special.select.call( selected, context.data.$textbox ); |
265 | 308 | } |
— | — | @@ -292,10 +335,10 @@ |
293 | 336 | /* Construction / Loading */ |
294 | 337 | |
295 | 338 | var context = $(this).data( 'suggestions-context' ); |
296 | | - if ( typeof context == 'undefined' ) { |
| 339 | + if ( typeof context == 'undefined' || context == null ) { |
297 | 340 | context = { |
298 | 341 | config: { |
299 | | - 'fetch' : function() {}, |
| 342 | + 'fetch' : function() {}, |
300 | 343 | 'cancel': function() {}, |
301 | 344 | 'special': {}, |
302 | 345 | 'result': {}, |
— | — | @@ -303,7 +346,9 @@ |
304 | 347 | 'suggestions': [], |
305 | 348 | 'maxRows': 7, |
306 | 349 | 'delay': 120, |
307 | | - 'submitOnClick': false |
| 350 | + 'submitOnClick': false, |
| 351 | + 'maxExpandFactor': 3, |
| 352 | + 'positionFromLeft': true |
308 | 353 | } |
309 | 354 | }; |
310 | 355 | } |
— | — | @@ -342,13 +387,22 @@ |
343 | 388 | 'mouseDownOn': $( [] ), |
344 | 389 | '$textbox': $(this) |
345 | 390 | }; |
| 391 | + // Setup the css for positioning the results box |
| 392 | + var newCSS = { |
| 393 | + 'top': Math.round( context.data.$textbox.offset().top + context.data.$textbox.outerHeight() ), |
| 394 | + 'width': context.data.$textbox.outerWidth(), |
| 395 | + 'display': 'none' |
| 396 | + } |
| 397 | + if ( context.config.positionFromLeft ) { |
| 398 | + newCSS['left'] = context.config.$region.offset().left; |
| 399 | + newCSS['right'] = 'auto'; |
| 400 | + } else { |
| 401 | + newCSS['left'] = 'auto'; |
| 402 | + newCSS['right'] = $( 'body' ).width() - ( context.config.$region.offset().left + context.config.$region.outerWidth() ); |
| 403 | + } |
| 404 | + |
346 | 405 | context.data.$container = $( '<div />' ) |
347 | | - .css( { |
348 | | - 'top': Math.round( context.data.$textbox.offset().top + context.data.$textbox.outerHeight() ), |
349 | | - 'left': Math.round( context.data.$textbox.offset().left ), |
350 | | - 'width': context.data.$textbox.outerWidth(), |
351 | | - 'display': 'none' |
352 | | - } ) |
| 406 | + .css( newCSS ) |
353 | 407 | .addClass( 'suggestions' ) |
354 | 408 | .append( |
355 | 409 | $( '<div />' ).addClass( 'suggestions-results' ) |
Index: branches/wmf/1.16wmf4/extensions/UsabilityInitiative/js/plugins/jquery.autoEllipsis.js |
— | — | @@ -10,7 +10,8 @@ |
11 | 11 | options = $.extend( { |
12 | 12 | 'position': 'center', |
13 | 13 | 'tooltip': false, |
14 | | - 'restoreText': false |
| 14 | + 'restoreText': false, |
| 15 | + 'hasSpan': false |
15 | 16 | }, options ); |
16 | 17 | $(this).each( function() { |
17 | 18 | var $this = $(this); |
— | — | @@ -23,8 +24,13 @@ |
24 | 25 | } |
25 | 26 | var text = $this.text(); |
26 | 27 | var w = $this.width(); |
27 | | - var $text = $( '<span />' ).css( 'whiteSpace', 'nowrap' ); |
28 | | - $this.empty().append( $text ); |
| 28 | + var $text; |
| 29 | + if ( options.hasSpan ) { |
| 30 | + $text = $this.children( 'span' ); |
| 31 | + } else { |
| 32 | + $text = $( '<span />' ).css( 'whiteSpace', 'nowrap' ); |
| 33 | + $this.empty().append( $text ); |
| 34 | + } |
29 | 35 | |
30 | 36 | // Try cache |
31 | 37 | if ( !( text in cache ) ) { |
Index: branches/wmf/1.16wmf4/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -5182,7 +5182,8 @@ |
5183 | 5183 | options = $.extend( { |
5184 | 5184 | 'position': 'center', |
5185 | 5185 | 'tooltip': false, |
5186 | | - 'restoreText': false |
| 5186 | + 'restoreText': false, |
| 5187 | + 'hasSpan': false |
5187 | 5188 | }, options ); |
5188 | 5189 | $(this).each( function() { |
5189 | 5190 | var $this = $(this); |
— | — | @@ -5195,8 +5196,13 @@ |
5196 | 5197 | } |
5197 | 5198 | var text = $this.text(); |
5198 | 5199 | var w = $this.width(); |
5199 | | - var $text = $( '<span />' ).css( 'whiteSpace', 'nowrap' ); |
5200 | | - $this.empty().append( $text ); |
| 5200 | + var $text; |
| 5201 | + if ( options.hasSpan ) { |
| 5202 | + $text = $this.children( 'span' ); |
| 5203 | + } else { |
| 5204 | + $text = $( '<span />' ).css( 'whiteSpace', 'nowrap' ); |
| 5205 | + $this.empty().append( $text ); |
| 5206 | + } |
5201 | 5207 | |
5202 | 5208 | // Try cache |
5203 | 5209 | if ( !( text in cache ) ) { |
— | — | @@ -5782,6 +5788,13 @@ |
5783 | 5789 | * Type: Number, Range: 1 - 100, Default: 7 |
5784 | 5790 | * delay: Number of ms to wait for the user to stop typing |
5785 | 5791 | * Type: Number, Range: 0 - 1200, Default: 120 |
| 5792 | + * submitOnClick: Whether to submit the form containing the textbox when a suggestion is clicked |
| 5793 | + * Type: Boolean, Default: false |
| 5794 | + * maxExpandFactor: Maximum suggestions box width relative to the textbox width. If set to e.g. 2, the suggestions box |
| 5795 | + * will never be grown beyond 2 times the width of the textbox. |
| 5796 | + * Type: Number, Range: 1 - infinity, Default: 3 |
| 5797 | + * positionFromLeft: Whether to position the suggestion box with the left attribute or the right |
| 5798 | + * Type: Boolean, Default: true |
5786 | 5799 | */ |
5787 | 5800 | ( function( $ ) { |
5788 | 5801 | |
— | — | @@ -5871,18 +5884,26 @@ |
5872 | 5885 | // Rebuild the suggestions list |
5873 | 5886 | context.data.$container.show(); |
5874 | 5887 | // Update the size and position of the list |
5875 | | - context.data.$container.css( { |
| 5888 | + var newCSS = { |
5876 | 5889 | 'top': context.config.$region.offset().top + context.config.$region.outerHeight(), |
5877 | 5890 | 'bottom': 'auto', |
5878 | 5891 | 'width': context.config.$region.outerWidth(), |
5879 | | - 'height': 'auto', |
5880 | | - 'left': context.config.$region.offset().left, |
5881 | | - 'right': 'auto' |
5882 | | - } ); |
| 5892 | + 'height': 'auto' |
| 5893 | + } |
| 5894 | + if ( context.config.positionFromLeft ) { |
| 5895 | + newCSS['left'] = context.config.$region.offset().left; |
| 5896 | + newCSS['right'] = 'auto'; |
| 5897 | + } else { |
| 5898 | + newCSS['left'] = 'auto'; |
| 5899 | + newCSS['right'] = $( 'body' ).width() - ( context.config.$region.offset().left + context.config.$region.outerWidth() ); |
| 5900 | + } |
| 5901 | + context.data.$container.css( newCSS ); |
5883 | 5902 | var $results = context.data.$container.children( '.suggestions-results' ); |
5884 | 5903 | $results.empty(); |
| 5904 | + var expWidth = -1; |
| 5905 | + var $autoEllipseMe = $( [] ); |
5885 | 5906 | for ( var i = 0; i < context.config.suggestions.length; i++ ) { |
5886 | | - $result = $( '<div />' ) |
| 5907 | + var $result = $( '<div />' ) |
5887 | 5908 | .addClass( 'suggestions-result' ) |
5888 | 5909 | .attr( 'rel', i ) |
5889 | 5910 | .data( 'text', context.config.suggestions[i] ) |
— | — | @@ -5892,13 +5913,33 @@ |
5893 | 5914 | ); |
5894 | 5915 | } ) |
5895 | 5916 | .appendTo( $results ); |
| 5917 | + |
5896 | 5918 | // Allow custom rendering |
5897 | 5919 | if ( typeof context.config.result.render == 'function' ) { |
5898 | 5920 | context.config.result.render.call( $result, context.config.suggestions[i] ); |
5899 | 5921 | } else { |
5900 | | - $result.text( context.config.suggestions[i] ).autoEllipsis(); |
| 5922 | + // Add <span> with text |
| 5923 | + $result.append( $( '<span />' ) |
| 5924 | + .css( 'whiteSpace', 'nowrap' ) |
| 5925 | + .text( context.config.suggestions[i] ) |
| 5926 | + ); |
| 5927 | + |
| 5928 | + // Widen results box if needed |
| 5929 | + // New width is only calculated here, applied later |
| 5930 | + var $span = $result.children( 'span' ); |
| 5931 | + if ( $span.outerWidth() > $result.width() && $span.outerWidth() > expWidth ) { |
| 5932 | + expWidth = $span.outerWidth(); |
| 5933 | + } |
| 5934 | + $autoEllipseMe = $autoEllipseMe.add( $result ); |
5901 | 5935 | } |
5902 | 5936 | } |
| 5937 | + // Apply new width for results box, if any |
| 5938 | + if ( expWidth > context.data.$container.width() ) { |
| 5939 | + var maxWidth = context.config.maxExpandFactor*context.data.$textbox.width(); |
| 5940 | + context.data.$container.width( Math.min( expWidth, maxWidth ) ); |
| 5941 | + } |
| 5942 | + // autoEllipse the results. Has to be done after changing the width |
| 5943 | + $autoEllipseMe.autoEllipsis( { hasSpan: true, tooltip: true } ); |
5903 | 5944 | } |
5904 | 5945 | } |
5905 | 5946 | break; |
— | — | @@ -5908,7 +5949,11 @@ |
5909 | 5950 | case 'delay': |
5910 | 5951 | context.config[property] = Math.max( 0, Math.min( 1200, value ) ); |
5911 | 5952 | break; |
| 5953 | + case 'maxExpandFactor': |
| 5954 | + context.config[property] = Math.max( 1, value ); |
| 5955 | + break; |
5912 | 5956 | case 'submitOnClick': |
| 5957 | + case 'positionFromLeft': |
5913 | 5958 | context.config[property] = value ? true : false; |
5914 | 5959 | break; |
5915 | 5960 | } |
— | — | @@ -6009,7 +6054,11 @@ |
6010 | 6055 | context.data.$container.hide(); |
6011 | 6056 | preventDefault = wasVisible; |
6012 | 6057 | selected = context.data.$container.find( '.suggestions-result-current' ); |
6013 | | - if ( selected.is( '.suggestions-special' ) ) { |
| 6058 | + if ( selected.size() == 0 ) { |
| 6059 | + // if nothing is selected, cancel any current requests and submit the form |
| 6060 | + $.suggestions.cancel( context ); |
| 6061 | + context.config.$region.closest( 'form' ).submit(); |
| 6062 | + } else if ( selected.is( '.suggestions-special' ) ) { |
6014 | 6063 | if ( typeof context.config.special.select == 'function' ) { |
6015 | 6064 | context.config.special.select.call( selected, context.data.$textbox ); |
6016 | 6065 | } |
— | — | @@ -6043,10 +6092,10 @@ |
6044 | 6093 | /* Construction / Loading */ |
6045 | 6094 | |
6046 | 6095 | var context = $(this).data( 'suggestions-context' ); |
6047 | | - if ( typeof context == 'undefined' ) { |
| 6096 | + if ( typeof context == 'undefined' || context == null ) { |
6048 | 6097 | context = { |
6049 | 6098 | config: { |
6050 | | - 'fetch' : function() {}, |
| 6099 | + 'fetch' : function() {}, |
6051 | 6100 | 'cancel': function() {}, |
6052 | 6101 | 'special': {}, |
6053 | 6102 | 'result': {}, |
— | — | @@ -6054,7 +6103,9 @@ |
6055 | 6104 | 'suggestions': [], |
6056 | 6105 | 'maxRows': 7, |
6057 | 6106 | 'delay': 120, |
6058 | | - 'submitOnClick': false |
| 6107 | + 'submitOnClick': false, |
| 6108 | + 'maxExpandFactor': 3, |
| 6109 | + 'positionFromLeft': true |
6059 | 6110 | } |
6060 | 6111 | }; |
6061 | 6112 | } |
— | — | @@ -6093,13 +6144,22 @@ |
6094 | 6145 | 'mouseDownOn': $( [] ), |
6095 | 6146 | '$textbox': $(this) |
6096 | 6147 | }; |
| 6148 | + // Setup the css for positioning the results box |
| 6149 | + var newCSS = { |
| 6150 | + 'top': Math.round( context.data.$textbox.offset().top + context.data.$textbox.outerHeight() ), |
| 6151 | + 'width': context.data.$textbox.outerWidth(), |
| 6152 | + 'display': 'none' |
| 6153 | + } |
| 6154 | + if ( context.config.positionFromLeft ) { |
| 6155 | + newCSS['left'] = context.config.$region.offset().left; |
| 6156 | + newCSS['right'] = 'auto'; |
| 6157 | + } else { |
| 6158 | + newCSS['left'] = 'auto'; |
| 6159 | + newCSS['right'] = $( 'body' ).width() - ( context.config.$region.offset().left + context.config.$region.outerWidth() ); |
| 6160 | + } |
| 6161 | + |
6097 | 6162 | context.data.$container = $( '<div />' ) |
6098 | | - .css( { |
6099 | | - 'top': Math.round( context.data.$textbox.offset().top + context.data.$textbox.outerHeight() ), |
6100 | | - 'left': Math.round( context.data.$textbox.offset().left ), |
6101 | | - 'width': context.data.$textbox.outerWidth(), |
6102 | | - 'display': 'none' |
6103 | | - } ) |
| 6163 | + .css( newCSS ) |
6104 | 6164 | .addClass( 'suggestions' ) |
6105 | 6165 | .append( |
6106 | 6166 | $( '<div />' ).addClass( 'suggestions-results' ) |
— | — | @@ -6689,6 +6749,7 @@ |
6690 | 6750 | return module.supported = false; |
6691 | 6751 | } |
6692 | 6752 | var mod = module && 'browsers' in module ? module : $.wikiEditor; |
| 6753 | + return mod.supported = true; |
6693 | 6754 | // Check for and make use of cached value and early opportunities to bail |
6694 | 6755 | if ( typeof mod.supported !== 'undefined' ) { |
6695 | 6756 | // Cache hit |
— | — | @@ -7025,8 +7086,12 @@ |
7026 | 7087 | 'paste': function( event ) { |
7027 | 7088 | // Save the cursor position to restore it after all this voodoo |
7028 | 7089 | var cursorPos = context.fn.getCaretPosition(); |
7029 | | - var oldLength = context.fn.getContents().length - ( cursorPos[1] - cursorPos[0] ); |
7030 | | - context.$content.find( ':not(.wikiEditor)' ).addClass( 'wikiEditor' ); |
| 7090 | + if ( !context.$content.text() ) { |
| 7091 | + context.$content.empty(); |
| 7092 | + } |
| 7093 | + var oldLength = context.fn.getContents().length; |
| 7094 | + |
| 7095 | + context.$content.find( '*' ).addClass( 'wikiEditor' ); |
7031 | 7096 | if ( $.layout.name !== 'webkit' ) { |
7032 | 7097 | context.$content.addClass( 'pasting' ); |
7033 | 7098 | } |
— | — | @@ -7046,58 +7111,82 @@ |
7047 | 7112 | var outerParent = $(this).parent(); |
7048 | 7113 | outerParent.replaceWith( outerParent.childNodes ); |
7049 | 7114 | } ); |
| 7115 | + |
7050 | 7116 | // Unwrap the span found in webkit copies (Apple Richtext) |
7051 | | - context.$content.find( 'span.Apple-style-span' ).each( function() { |
7052 | | - $(this).replaceWith( this.childNodes ); |
7053 | | - } ); |
| 7117 | + if ( ! $.browser.msie ) { |
| 7118 | + context.$content.find( 'span.Apple-style-span' ).each( function() { |
| 7119 | + $(this).replaceWith( this.childNodes ); |
| 7120 | + } ); |
| 7121 | + } |
7054 | 7122 | |
7055 | | - // If the pasted content is plain text then wrap it in a <p> and adjust the <br> accordingly |
7056 | | - var pasteContent = context.fn.getOffset( cursorPos[0] ).node; |
7057 | | - var removeNextBR = false; |
7058 | | - while ( pasteContent != null && !$( pasteContent ).hasClass( 'wikiEditor' ) ) { |
7059 | | - var currentNode = pasteContent; |
7060 | | - pasteContent = pasteContent.nextSibling; |
7061 | | - if ( currentNode.nodeName == '#text' && currentNode.nodeValue == currentNode.wholeText ) { |
7062 | | - var pWrapper = $( '<p />' ).addClass( 'wikiEditor' ); |
7063 | | - $( currentNode ).wrap( pWrapper ); |
7064 | | - $( currentNode ).addClass( 'wikiEditor' ); |
7065 | | - removeNextBR = true; |
7066 | | - } else if ( currentNode.nodeName == 'BR' && removeNextBR ) { |
7067 | | - $( currentNode ).remove(); |
7068 | | - removeNextBR = false; |
7069 | | - } else { |
7070 | | - removeNextBR = false; |
7071 | | - } |
7072 | | - } |
7073 | 7123 | var $selection = context.$content.find( ':not(.wikiEditor)' ); |
| 7124 | + var $previousElement; |
7074 | 7125 | while ( $selection.length && $selection.length > 0 ) { |
7075 | 7126 | var $currentElement = $selection.eq( 0 ); |
| 7127 | + |
| 7128 | + //go up till we find the first pasted element |
7076 | 7129 | while ( !$currentElement.parent().is( 'body' ) && !$currentElement.parent().is( '.wikiEditor' ) ) { |
7077 | 7130 | $currentElement = $currentElement.parent(); |
7078 | 7131 | } |
| 7132 | + //go to the previous element till we find the first pasted element |
| 7133 | + while ( $currentElement[0] != null && |
| 7134 | + $currentElement[0].previousSibling != null && |
| 7135 | + !$( $currentElement[0].previousSibling ).hasClass( 'wikiEditor' ) ) { |
| 7136 | + $currentElement = $( $currentElement[0].previousSibling ); |
| 7137 | + } |
7079 | 7138 | |
| 7139 | + //each pasted element is always wrapped in a <p> |
7080 | 7140 | var $newElement; |
7081 | | - if ( $currentElement.is( 'p' ) || $currentElement.is( 'div' ) || $currentElement.is( 'pre' ) ) { |
7082 | | - //Convert all <div>, <p> and <pre> that was pasted into a <p> element |
7083 | | - $newElement = $( '<p />' ); |
| 7141 | + var textNode = false; |
| 7142 | + if ( $currentElement[0].nodeName == '#text' ) { |
| 7143 | + $newElement = $( '<p></p>' ); |
| 7144 | + textNode = true; |
| 7145 | + } else if ( $currentElement.is( 'p' ) || $currentElement.is( 'pre' ) || $currentElement.is( 'br' ) ) { |
| 7146 | + $newElement = $( '<p></p>' ); |
7084 | 7147 | } else { |
7085 | | - // everything else becomes a <span> |
7086 | | - $newElement = $( '<span />' ).addClass( 'wikiEditor' ); |
| 7148 | + $newElement = $( '<span></span>' ); |
7087 | 7149 | } |
| 7150 | + var newElementHTML = ''; |
| 7151 | + var currentHTML = ''; |
7088 | 7152 | |
7089 | | - // If the pasted content was html, just convert it into text and <br> |
7090 | | - var pieces = $.trim( $currentElement.text() ).split( '\n' ); |
7091 | | - var newElementHTML = ''; |
| 7153 | + |
| 7154 | + if ( $currentElement[0].nodeName == '#text' ) { |
| 7155 | + //if it is a text node then just append it |
| 7156 | + currentHTML = $currentElement[0].nodeValue; |
| 7157 | + } else { |
| 7158 | + currentHTML = $currentElement.html(); |
| 7159 | + //replace all forms of <p> tags with a \n. All other tags get removed. |
| 7160 | + currentHTML = currentHTML.replace(/(<[\s]*p[^>]*>)|(<[\s]*\/p[^>]*>)|(<[\s]*p[^\/>]*\/>)/gi, '\n'); |
| 7161 | + currentHTML = currentHTML.replace(/(<[^>]*>)|(<[^\>]*\>)/gi, ''); |
| 7162 | + |
| 7163 | + } |
| 7164 | + |
| 7165 | + //wrap each piece in a <p> with a <br> in between. |
| 7166 | + var pieces = currentHTML.split( '\n' ); |
7092 | 7167 | for ( var i = 0; i < pieces.length; i++ ) { |
7093 | 7168 | if ( pieces[i] ) { |
7094 | | - newElementHTML += $.trim( pieces[i] ); |
7095 | | - } else { |
7096 | | - newElementHTML += '<span><br class="wikiEditor" /></span>'; |
| 7169 | + if ( textNode || ! $newElement.is( 'p' ) ) { |
| 7170 | + newElementHTML += '<p class="wikiEditor">' + pieces[i] + '</p>'; |
| 7171 | + } else { |
| 7172 | + newElementHTML += pieces[i]; |
| 7173 | + } |
| 7174 | + } else if ( textNode || ! $newElement.is( 'p' ) ) { |
| 7175 | + newElementHTML += '<br class="wikiEditor" >'; |
7097 | 7176 | } |
| 7177 | + |
| 7178 | + if ( !textNode ) { |
| 7179 | + newElementHTML += '<br class="wikiEditor" >'; |
| 7180 | + } |
7098 | 7181 | } |
7099 | | - $newElement.html( newElementHTML ) |
7100 | | - .addClass( 'wikiEditor' ) |
7101 | | - .insertAfter( $currentElement ); |
| 7182 | + |
| 7183 | + $newElement.html( newElementHTML ).addClass( 'wikiEditor' ); |
| 7184 | + |
| 7185 | + //remove extra <br>s |
| 7186 | + if ( $newElement.is( 'p' ) && $currentElement[0].nextSibling != null && $( $currentElement[0].nextSibling ).is( 'br' ) ) { |
| 7187 | + $( $currentElement[0].nextSibling ).remove(); |
| 7188 | + } |
| 7189 | + //swap out the original content with with newly sanitized one |
| 7190 | + $newElement.insertAfter( $currentElement ); |
7102 | 7191 | $currentElement.remove(); |
7103 | 7192 | |
7104 | 7193 | $selection = context.$content.find( ':not(.wikiEditor)' ); |
— | — | @@ -7108,10 +7197,14 @@ |
7109 | 7198 | context.$content.removeClass( 'pasting' ); |
7110 | 7199 | } |
7111 | 7200 | |
| 7201 | + |
7112 | 7202 | // Restore cursor position |
7113 | 7203 | context.fn.purgeOffsets(); |
7114 | 7204 | var newLength = context.fn.getContents().length; |
7115 | 7205 | var restoreTo = cursorPos[0] + newLength - oldLength; |
| 7206 | + if ( restoreTo > newLength ) { |
| 7207 | + restoreTo = newLength; |
| 7208 | + } |
7116 | 7209 | context.fn.setSelection( { start: restoreTo, end: restoreTo } ); |
7117 | 7210 | }, 0 ); |
7118 | 7211 | return true; |
— | — | @@ -8233,10 +8326,10 @@ |
8234 | 8327 | end = e ? e.offset : null; |
8235 | 8328 | // Don't try to set the selection past the end of a node, causes errors |
8236 | 8329 | // Just put the selection at the end of the node in this case |
8237 | | - if ( sc.nodeName == '#text' && start > sc.nodeValue.length ) { |
| 8330 | + if ( sc != null && sc.nodeName == '#text' && start > sc.nodeValue.length ) { |
8238 | 8331 | start = sc.nodeValue.length - 1; |
8239 | 8332 | } |
8240 | | - if ( ec.nodeName == '#text' && end > ec.nodeValue.length ) { |
| 8333 | + if ( ec != null && ec.nodeName == '#text' && end > ec.nodeValue.length ) { |
8241 | 8334 | end = ec.nodeValue.length - 1; |
8242 | 8335 | } |
8243 | 8336 | } |
Index: branches/wmf/1.16wmf4/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -359,8 +359,9 @@ |
360 | 360 | {var i=0,l=array.length,loop=opts.loop||function(){};$.whileAsync($.extend(opts,{test:function(){return i<l;},loop:function() |
361 | 361 | {var val=array[i];return loop.call(val,i++,val);}}));} |
362 | 362 | $.fn.eachAsync=function(opts) |
363 | | -{$.eachAsync(this,opts);return this;}})(jQuery);(function($){var cache={};$.fn.autoEllipsis=function(options){options=$.extend({'position':'center','tooltip':false,'restoreText':false},options);$(this).each(function(){var $this=$(this);if(options.restoreText){if(!$this.data('autoEllipsis.originalText')){$this.data('autoEllipsis.originalText',$this.text());}else{$this.text($this.data('autoEllipsis.originalText'));}} |
364 | | -var text=$this.text();var w=$this.width();var $text=$('<span />').css('whiteSpace','nowrap');$this.empty().append($text);if(!(text in cache)){cache[text]={};} |
| 363 | +{$.eachAsync(this,opts);return this;}})(jQuery);(function($){var cache={};$.fn.autoEllipsis=function(options){options=$.extend({'position':'center','tooltip':false,'restoreText':false,'hasSpan':false},options);$(this).each(function(){var $this=$(this);if(options.restoreText){if(!$this.data('autoEllipsis.originalText')){$this.data('autoEllipsis.originalText',$this.text());}else{$this.text($this.data('autoEllipsis.originalText'));}} |
| 364 | +var text=$this.text();var w=$this.width();var $text;if(options.hasSpan){$text=$this.children('span');}else{$text=$('<span />').css('whiteSpace','nowrap');$this.empty().append($text);} |
| 365 | +if(!(text in cache)){cache[text]={};} |
365 | 366 | if(w in cache[text]){$text.text(cache[text][w]);return;} |
366 | 367 | $text.text(text);if($text.width()>w){switch(options.position){case'right':var l=0,r=text.length;do{var m=Math.ceil((l+r)/2);$text.text(text.substr(0,m)+'...');if($text.width()>w){r=m-1;}else{l=m;}}while(l<r);$text.text(text.substr(0,l)+'...');break;case'center':var i=[Math.round(text.length/2),Math.round(text.length/2)];var side=1;while($text.outerWidth()>w&&i[0]>0){$text.text(text.substr(0,i[0])+'...'+text.substr(i[1]));if(side==0){i[0]--;side=1;}else{i[1]++;side=0;}} |
367 | 368 | break;case'left':var r=0;while($text.outerWidth()>w&&r<text.length){$text.text('...'+text.substr(r));r++;} |
— | — | @@ -394,18 +395,25 @@ |
395 | 396 | if(typeof context.config.cancel=='function'){context.config.cancel.call(context.data.$textbox);}},restore:function(context){context.data.$textbox.val(context.data.prevText);},update:function(context,delayed){function maybeFetch(){if(context.data.$textbox.val()!==context.data.prevText){context.data.prevText=context.data.$textbox.val();if(typeof context.config.fetch=='function'){context.config.fetch.call(context.data.$textbox,context.data.$textbox.val());}}} |
396 | 397 | if(context.data.timerID!=null){clearTimeout(context.data.timerID);} |
397 | 398 | if(delayed){context.data.timerID=setTimeout(maybeFetch,context.config.delay);}else{maybeFetch();} |
398 | | -$.suggestions.special(context);},special:function(context){if(typeof context.config.special.render=='function'){setTimeout(function(){$special=context.data.$container.find('.suggestions-special');context.config.special.render.call($special,context.data.$textbox.val());},1);}},configure:function(context,property,value){switch(property){case'fetch':case'cancel':case'special':case'result':case'$region':context.config[property]=value;break;case'suggestions':context.config[property]=value;if(typeof context.data!=='undefined'){if(context.data.$textbox.val().length==0){context.data.$container.hide();}else{context.data.$container.show();context.data.$container.css({'top':context.config.$region.offset().top+context.config.$region.outerHeight(),'bottom':'auto','width':context.config.$region.outerWidth(),'height':'auto','left':context.config.$region.offset().left,'right':'auto'});var $results=context.data.$container.children('.suggestions-results');$results.empty();for(var i=0;i<context.config.suggestions.length;i++){$result=$('<div />').addClass('suggestions-result').attr('rel',i).data('text',context.config.suggestions[i]).mouseover(function(e){$.suggestions.highlight(context,$(this).closest('.suggestions-results div'),false);}).appendTo($results);if(typeof context.config.result.render=='function'){context.config.result.render.call($result,context.config.suggestions[i]);}else{$result.text(context.config.suggestions[i]).autoEllipsis();}}}} |
399 | | -break;case'maxRows':context.config[property]=Math.max(1,Math.min(100,value));break;case'delay':context.config[property]=Math.max(0,Math.min(1200,value));break;case'submitOnClick':context.config[property]=value?true:false;break;}},highlight:function(context,result,updateTextbox){var selected=context.data.$container.find('.suggestions-result-current');if(!result.get||selected.get(0)!=result.get(0)){if(result=='prev'){if(selected.is('.suggestions-special')){result=context.data.$container.find('.suggestions-results div:last')}else{result=selected.prev();if(selected.length==0){if(context.data.$container.find('.suggestions-special').html()!=""){result=context.data.$container.find('.suggestions-special');}else{result=context.data.$container.find('.suggestions-results div:last');}}}}else if(result=='next'){if(selected.length==0){result=context.data.$container.find('.suggestions-results div:first');if(result.length==0&&context.data.$container.find('.suggestions-special').html()!=""){result=context.data.$container.find('.suggestions-special');}}else{result=selected.next();if(selected.is('.suggestions-special')){result=$([]);}else if(result.length==0&&context.data.$container.find('.suggestions-special').html()!=""){result=context.data.$container.find('.suggestions-special');}}} |
| 399 | +$.suggestions.special(context);},special:function(context){if(typeof context.config.special.render=='function'){setTimeout(function(){$special=context.data.$container.find('.suggestions-special');context.config.special.render.call($special,context.data.$textbox.val());},1);}},configure:function(context,property,value){switch(property){case'fetch':case'cancel':case'special':case'result':case'$region':context.config[property]=value;break;case'suggestions':context.config[property]=value;if(typeof context.data!=='undefined'){if(context.data.$textbox.val().length==0){context.data.$container.hide();}else{context.data.$container.show();var newCSS={'top':context.config.$region.offset().top+context.config.$region.outerHeight(),'bottom':'auto','width':context.config.$region.outerWidth(),'height':'auto'} |
| 400 | +if(context.config.positionFromLeft){newCSS['left']=context.config.$region.offset().left;newCSS['right']='auto';}else{newCSS['left']='auto';newCSS['right']=$('body').width()-(context.config.$region.offset().left+context.config.$region.outerWidth());} |
| 401 | +context.data.$container.css(newCSS);var $results=context.data.$container.children('.suggestions-results');$results.empty();var expWidth=-1;var $autoEllipseMe=$([]);for(var i=0;i<context.config.suggestions.length;i++){var $result=$('<div />').addClass('suggestions-result').attr('rel',i).data('text',context.config.suggestions[i]).mouseover(function(e){$.suggestions.highlight(context,$(this).closest('.suggestions-results div'),false);}).appendTo($results);if(typeof context.config.result.render=='function'){context.config.result.render.call($result,context.config.suggestions[i]);}else{$result.append($('<span />').css('whiteSpace','nowrap').text(context.config.suggestions[i]));var $span=$result.children('span');if($span.outerWidth()>$result.width()&&$span.outerWidth()>expWidth){expWidth=$span.outerWidth();} |
| 402 | +$autoEllipseMe=$autoEllipseMe.add($result);}} |
| 403 | +if(expWidth>context.data.$container.width()){var maxWidth=context.config.maxExpandFactor*context.data.$textbox.width();context.data.$container.width(Math.min(expWidth,maxWidth));} |
| 404 | +$autoEllipseMe.autoEllipsis({hasSpan:true,tooltip:true});}} |
| 405 | +break;case'maxRows':context.config[property]=Math.max(1,Math.min(100,value));break;case'delay':context.config[property]=Math.max(0,Math.min(1200,value));break;case'maxExpandFactor':context.config[property]=Math.max(1,value);break;case'submitOnClick':case'positionFromLeft':context.config[property]=value?true:false;break;}},highlight:function(context,result,updateTextbox){var selected=context.data.$container.find('.suggestions-result-current');if(!result.get||selected.get(0)!=result.get(0)){if(result=='prev'){if(selected.is('.suggestions-special')){result=context.data.$container.find('.suggestions-results div:last')}else{result=selected.prev();if(selected.length==0){if(context.data.$container.find('.suggestions-special').html()!=""){result=context.data.$container.find('.suggestions-special');}else{result=context.data.$container.find('.suggestions-results div:last');}}}}else if(result=='next'){if(selected.length==0){result=context.data.$container.find('.suggestions-results div:first');if(result.length==0&&context.data.$container.find('.suggestions-special').html()!=""){result=context.data.$container.find('.suggestions-special');}}else{result=selected.next();if(selected.is('.suggestions-special')){result=$([]);}else if(result.length==0&&context.data.$container.find('.suggestions-special').html()!=""){result=context.data.$container.find('.suggestions-special');}}} |
400 | 406 | selected.removeClass('suggestions-result-current');result.addClass('suggestions-result-current');} |
401 | 407 | if(updateTextbox){if(result.length==0){$.suggestions.restore(context);}else{context.data.$textbox.val(result.data('text'));context.data.$textbox.change();} |
402 | 408 | context.data.$textbox.trigger('change');} |
403 | 409 | $.suggestions.special(context);},keypress:function(e,context,key){var wasVisible=context.data.$container.is(':visible');var preventDefault=false;switch(key){case 40:if(wasVisible){$.suggestions.highlight(context,'next',false);}else{$.suggestions.update(context,false);} |
404 | 410 | preventDefault=true;break;case 38:if(wasVisible){$.suggestions.highlight(context,'prev',false);} |
405 | | -preventDefault=wasVisible;break;case 27:context.data.$container.hide();$.suggestions.restore(context);$.suggestions.cancel(context);context.data.$textbox.trigger('change');preventDefault=wasVisible;break;case 13:context.data.$container.hide();preventDefault=wasVisible;selected=context.data.$container.find('.suggestions-result-current');if(selected.is('.suggestions-special')){if(typeof context.config.special.select=='function'){context.config.special.select.call(selected,context.data.$textbox);}}else{if(typeof context.config.result.select=='function'){$.suggestions.highlight(context,selected,true);context.config.result.select.call(selected,context.data.$textbox);}else{$.suggestions.highlight(context,selected,true);}} |
| 411 | +preventDefault=wasVisible;break;case 27:context.data.$container.hide();$.suggestions.restore(context);$.suggestions.cancel(context);context.data.$textbox.trigger('change');preventDefault=wasVisible;break;case 13:context.data.$container.hide();preventDefault=wasVisible;selected=context.data.$container.find('.suggestions-result-current');if(selected.size()==0){$.suggestions.cancel(context);context.config.$region.closest('form').submit();}else if(selected.is('.suggestions-special')){if(typeof context.config.special.select=='function'){context.config.special.select.call(selected,context.data.$textbox);}}else{if(typeof context.config.result.select=='function'){$.suggestions.highlight(context,selected,true);context.config.result.select.call(selected,context.data.$textbox);}else{$.suggestions.highlight(context,selected,true);}} |
406 | 412 | break;default:$.suggestions.update(context,true);break;} |
407 | | -if(preventDefault){e.preventDefault();e.stopImmediatePropagation();}}};$.fn.suggestions=function(){var returnValue=null;var args=arguments;$(this).each(function(){var context=$(this).data('suggestions-context');if(typeof context=='undefined'){context={config:{'fetch':function(){},'cancel':function(){},'special':{},'result':{},'$region':$(this),'suggestions':[],'maxRows':7,'delay':120,'submitOnClick':false}};} |
| 413 | +if(preventDefault){e.preventDefault();e.stopImmediatePropagation();}}};$.fn.suggestions=function(){var returnValue=null;var args=arguments;$(this).each(function(){var context=$(this).data('suggestions-context');if(typeof context=='undefined'||context==null){context={config:{'fetch':function(){},'cancel':function(){},'special':{},'result':{},'$region':$(this),'suggestions':[],'maxRows':7,'delay':120,'submitOnClick':false,'maxExpandFactor':3,'positionFromLeft':true}};} |
408 | 414 | if(args.length>0){if(typeof args[0]=='object'){for(var key in args[0]){$.suggestions.configure(context,key,args[0][key]);}}else if(typeof args[0]=='string'){if(args.length>1){$.suggestions.configure(context,args[0],args[1]);}else if(returnValue==null){returnValue=(args[0]in context.config?undefined:context.config[args[0]]);}}} |
409 | | -if(typeof context.data=='undefined'){context.data={'timerID':null,'prevText':null,'visibleResults':0,'mouseDownOn':$([]),'$textbox':$(this)};context.data.$container=$('<div />').css({'top':Math.round(context.data.$textbox.offset().top+context.data.$textbox.outerHeight()),'left':Math.round(context.data.$textbox.offset().left),'width':context.data.$textbox.outerWidth(),'display':'none'}).addClass('suggestions').append($('<div />').addClass('suggestions-results').mousedown(function(e){context.data.mouseDownOn=$(e.target).closest('.suggestions-results div');}).mouseup(function(e){var $result=$(e.target).closest('.suggestions-results div');var $other=context.data.mouseDownOn;context.data.mouseDownOn=$([]);if($result.get(0)!=$other.get(0)){return;} |
| 415 | +if(typeof context.data=='undefined'){context.data={'timerID':null,'prevText':null,'visibleResults':0,'mouseDownOn':$([]),'$textbox':$(this)};var newCSS={'top':Math.round(context.data.$textbox.offset().top+context.data.$textbox.outerHeight()),'width':context.data.$textbox.outerWidth(),'display':'none'} |
| 416 | +if(context.config.positionFromLeft){newCSS['left']=context.config.$region.offset().left;newCSS['right']='auto';}else{newCSS['left']='auto';newCSS['right']=$('body').width()-(context.config.$region.offset().left+context.config.$region.outerWidth());} |
| 417 | +context.data.$container=$('<div />').css(newCSS).addClass('suggestions').append($('<div />').addClass('suggestions-results').mousedown(function(e){context.data.mouseDownOn=$(e.target).closest('.suggestions-results div');}).mouseup(function(e){var $result=$(e.target).closest('.suggestions-results div');var $other=context.data.mouseDownOn;context.data.mouseDownOn=$([]);if($result.get(0)!=$other.get(0)){return;} |
410 | 418 | $.suggestions.highlight(context,$result,true);context.data.$container.hide();if(typeof context.config.result.select=='function'){context.config.result.select.call($result,context.data.$textbox);} |
411 | 419 | context.data.$textbox.focus();})).append($('<div />').addClass('suggestions-special').mousedown(function(e){context.data.mouseDownOn=$(e.target).closest('.suggestions-special');}).mouseup(function(e){var $special=$(e.target).closest('.suggestions-special');var $other=context.data.mouseDownOn;context.data.mouseDownOn=$([]);if($special.get(0)!=$other.get(0)){return;} |
412 | 420 | context.data.$container.hide();if(typeof context.config.special.select=='function'){context.config.special.select.call($special,context.data.$textbox);} |
— | — | @@ -444,8 +452,7 @@ |
445 | 453 | options.endContainer=options.startContainer;break;case'scrollToCaretPosition':options=$.extend({'force':false},options);break;} |
446 | 454 | var context=$(this).data('wikiEditor-context');var hasIframe=context!==undefined&&context.$iframe!==undefined;var needSave=false;if(hasIframe&&context.savedSelection!==null){context.fn.restoreSelection();needSave=true;} |
447 | 455 | retval=(hasIframe?context.fn:fn)[command].call(this,options);if(hasIframe&&needSave){context.fn.saveSelection();} |
448 | | -return retval;};})(jQuery);(function($){$.wikiEditor={'modules':{},'instances':[],'browsers':{'ltr':{'msie':[['>=',7]],'firefox':[['>=',2]],'opera':[['>=',9.6]],'safari':[['>=',3]],'chrome':[['>=',3]],'blackberry':false,'ipod':false,'iphone':false},'rtl':{'msie':[['>=',8]],'firefox':[['>=',2]],'opera':[['>=',9.6]],'safari':[['>=',3]],'chrome':[['>=',3]],'blackberry':false,'ipod':false,'iphone':false}},'imgPath':wgScriptPath+'/extensions/UsabilityInitiative/images/wikiEditor/','isSupported':function(module){if(module&&typeof module.name!='undefined'&&(module.name=='toc'||module.name=='highlight')&&typeof wgReallyGiveMeTOC=='undefined'){return module.supported=false;} |
449 | | -var mod=module&&'browsers'in module?module:$.wikiEditor;if(typeof mod.supported!=='undefined'){return mod.supported;} |
| 456 | +return retval;};})(jQuery);(function($){$.wikiEditor={'modules':{},'instances':[],'browsers':{'ltr':{'msie':[['>=',7]],'firefox':[['>=',2]],'opera':[['>=',9.6]],'safari':[['>=',3]],'chrome':[['>=',3]],'blackberry':false,'ipod':false,'iphone':false},'rtl':{'msie':[['>=',8]],'firefox':[['>=',2]],'opera':[['>=',9.6]],'safari':[['>=',3]],'chrome':[['>=',3]],'blackberry':false,'ipod':false,'iphone':false}},'imgPath':wgScriptPath+'/extensions/UsabilityInitiative/images/wikiEditor/','isSupported':function(module){var mod=module&&'browsers'in module?module:$.wikiEditor;return mod.supported=true;if(typeof mod.supported!=='undefined'){return mod.supported;} |
450 | 457 | if(!($.browser.name in mod.browsers[$('body').is('.rtl')?'rtl':'ltr'])){return mod.supported=true;} |
451 | 458 | var browser=mod.browsers[$('body').is('.rtl')?'rtl':'ltr'][$.browser.name];if(typeof browser!='object'){return mod.supported=false;} |
452 | 459 | for(var condition in browser){var op=browser[condition][0];var val=browser[condition][1];if(val===false){return mod.supported=false;}else if(typeof val=='string'){if(!(eval('$.browser.version'+op+'"'+val+'"'))){return mod.supported=false;}}else if(typeof val=='number'){if(!(eval('$.browser.versionNumber'+op+val))){return mod.supported=false;}}} |
— | — | @@ -455,21 +462,30 @@ |
456 | 463 | return src+'?'+wgWikiEditorIconVersion;}};$.fn.wikiEditor=function(){if(!$j.wikiEditor.isSupported()){return $(this);} |
457 | 464 | var context=$(this).data('wikiEditor-context');if(!context||typeof context=='undefined'){context={'$textarea':$(this),'views':{},'modules':{},'data':{},'instance':$.wikiEditor.instances.push($(this))-1,'offsets':null,'htmlToTextMap':{},'oldHTML':null,'oldDelayedHTML':null,'oldDelayedSel':null,'savedSelection':null,'history':[],'historyPosition':-1,'oldDelayedHistoryPosition':-1};context.api={'addModule':function(context,data){var modules={};if(typeof data=='string'){modules[data]={};}else if(typeof data=='object'){modules=data;} |
458 | 465 | for(var module in modules){if(typeof module=='string'&&$.wikiEditor.isSupported($.wikiEditor.modules[module])){if('api'in $.wikiEditor.modules[module]){for(var call in $.wikiEditor.modules[module].api){if(!(call in context.api)){context.api[call]=$.wikiEditor.modules[module].api[call];}}} |
459 | | -if('fn'in $.wikiEditor.modules[module]&&'create'in $.wikiEditor.modules[module].fn){context.modules[module]={};$.wikiEditor.modules[module].fn.create(context,modules[module]);}}}}};context.evt={'keydown':function(event){switch(event.which){case 9:if(event.ctrlKey||event.altKey||event.shiftKey){return true;}else{var $tabindexList=$j('[tabindex]:visible').sort(function(a,b){return a.tabIndex-b.tabIndex;});for(var i=0;i<$tabindexList.length;i++){if($tabindexList.eq(i).attr('id')==context.$iframe.attr('id')){$tabindexList.get(i+1).focus();break;}} |
| 466 | +if('fn'in $.wikiEditor.modules[module]&&'create'in $.wikiEditor.modules[module].fn){context.modules[module]={};$.wikiEditor.modules[module].fn.create(context,modules[module]);}}}}};context.evt={'keydown':function(event){switch(event.which){case 90:case 89:if(event.which==89&&!$.browser.msie){return true;}else if((event.ctrlKey||event.metaKey)&&context.history.length){var newPosition;if(event.shiftKey||event.which==89){newPosition=context.historyPosition+1;}else{newPosition=context.historyPosition-1;} |
| 467 | +if(newPosition>=(context.history.length*-1)&&newPosition<0){context.fn.updateHistory(context.oldDelayedHTML!=context.$content.html());context.oldDelayedHistoryPosition=context.historyPosition;context.historyPosition=newPosition;context.$content.html(context.history[context.history.length+context.historyPosition].html);context.fn.purgeOffsets();if(context.history[context.history.length+context.historyPosition].sel){context.fn.setSelection({start:context.history[context.history.length+context.historyPosition].sel[0],end:context.history[context.history.length+context.historyPosition].sel[1]});}} |
460 | 468 | return false;} |
| 469 | +break;case 9:if(event.ctrlKey||event.altKey||event.shiftKey){return true;}else{var $tabindexList=$j('[tabindex]:visible').sort(function(a,b){return a.tabIndex-b.tabIndex;});for(var i=0;i<$tabindexList.length;i++){if($tabindexList.eq(i).attr('id')==context.$iframe.attr('id')){$tabindexList.get(i+1).focus();break;}} |
| 470 | +return false;} |
461 | 471 | break;case 86:if(event.ctrlKey&&$.browser.msie){context.evt.paste(event);} |
462 | 472 | break;} |
463 | 473 | return true;},'change':function(event){event.data.scope='division';var newHTML=context.$content.html();if(context.oldHTML!=newHTML){context.fn.purgeOffsets();context.oldHTML=newHTML;event.data.scope='realchange';} |
464 | 474 | if(context.$content.children().length==0){context.$content.append('<p></p>');} |
465 | 475 | return true;},'delayedChange':function(event){event.data.scope='division';var newHTML=context.$content.html();if(context.oldDelayedHTML!=newHTML){context.oldDelayedHTML=newHTML;event.data.scope='realchange';var cursorPos=context.fn.getCaretPosition();var t=context.fn.getOffset(cursorPos[0]);if(t&&t.node.nodeName=='#text'&&t.node.parentNode.nodeName.toLowerCase()=='body'){$(t.node).wrap("<p></p>");context.fn.purgeOffsets();context.fn.setSelection({start:cursorPos[0],end:cursorPos[1]});}} |
466 | | -context.fn.updateHistory(event.data.scope=='realchange');return true;},'cut':function(event){setTimeout(function(){context.$content.find('br').each(function(){if($(this).parent().is('body')){$(this).wrap($('<p></p>'));}});},100);return true;},'paste':function(event){var cursorPos=context.fn.getCaretPosition();var oldLength=context.fn.getContents().length-(cursorPos[1]-cursorPos[0]);context.$content.find(':not(.wikiEditor)').addClass('wikiEditor');if($.layout.name!=='webkit'){context.$content.addClass('pasting');} |
467 | | -setTimeout(function(){context.$content.find('script,style,img,input,select,textarea,hr,button,link,meta').remove();context.$content.find('*').each(function(){if($(this).children().length==0&&this.childNodes.length>0){$(this).text($(this).text());}});context.$content.find('p:not(.wikiEditor) p:not(.wikiEditor)').each(function(){var outerParent=$(this).parent();outerParent.replaceWith(outerParent.childNodes);});context.$content.find('span.Apple-style-span').each(function(){$(this).replaceWith(this.childNodes);});var pasteContent=context.fn.getOffset(cursorPos[0]).node;var removeNextBR=false;while(pasteContent!=null&&!$(pasteContent).hasClass('wikiEditor')){var currentNode=pasteContent;pasteContent=pasteContent.nextSibling;if(currentNode.nodeName=='#text'&¤tNode.nodeValue==currentNode.wholeText){var pWrapper=$('<p />').addClass('wikiEditor');$(currentNode).wrap(pWrapper);$(currentNode).addClass('wikiEditor');removeNextBR=true;}else if(currentNode.nodeName=='BR'&&removeNextBR){$(currentNode).remove();removeNextBR=false;}else{removeNextBR=false;}} |
468 | | -var $selection=context.$content.find(':not(.wikiEditor)');while($selection.length&&$selection.length>0){var $currentElement=$selection.eq(0);while(!$currentElement.parent().is('body')&&!$currentElement.parent().is('.wikiEditor')){$currentElement=$currentElement.parent();} |
469 | | -var $newElement;if($currentElement.is('p')||$currentElement.is('div')||$currentElement.is('pre')){$newElement=$('<p />');}else{$newElement=$('<span />').addClass('wikiEditor');} |
470 | | -var pieces=$.trim($currentElement.text()).split('\n');var newElementHTML='';for(var i=0;i<pieces.length;i++){if(pieces[i]){newElementHTML+=$.trim(pieces[i]);}else{newElementHTML+='<span><br class="wikiEditor" /></span>';}} |
471 | | -$newElement.html(newElementHTML).addClass('wikiEditor').insertAfter($currentElement);$currentElement.remove();$selection=context.$content.find(':not(.wikiEditor)');} |
| 476 | +context.fn.updateHistory(event.data.scope=='realchange');return true;},'cut':function(event){setTimeout(function(){context.$content.find('br').each(function(){if($(this).parent().is('body')){$(this).wrap($('<p></p>'));}});},100);return true;},'paste':function(event){var cursorPos=context.fn.getCaretPosition();if(!context.$content.text()){context.$content.empty();} |
| 477 | +var oldLength=context.fn.getContents().length;context.$content.find('*').addClass('wikiEditor');if($.layout.name!=='webkit'){context.$content.addClass('pasting');} |
| 478 | +setTimeout(function(){context.$content.find('script,style,img,input,select,textarea,hr,button,link,meta').remove();context.$content.find('*').each(function(){if($(this).children().length==0&&this.childNodes.length>0){$(this).text($(this).text());}});context.$content.find('p:not(.wikiEditor) p:not(.wikiEditor)').each(function(){var outerParent=$(this).parent();outerParent.replaceWith(outerParent.childNodes);});if(!$.browser.msie){context.$content.find('span.Apple-style-span').each(function(){$(this).replaceWith(this.childNodes);});} |
| 479 | +var $selection=context.$content.find(':not(.wikiEditor)');var $previousElement;while($selection.length&&$selection.length>0){var $currentElement=$selection.eq(0);while(!$currentElement.parent().is('body')&&!$currentElement.parent().is('.wikiEditor')){$currentElement=$currentElement.parent();} |
| 480 | +while($currentElement[0]!=null&&$currentElement[0].previousSibling!=null&&!$($currentElement[0].previousSibling).hasClass('wikiEditor')){$currentElement=$($currentElement[0].previousSibling);} |
| 481 | +var $newElement;var textNode=false;if($currentElement[0].nodeName=='#text'){$newElement=$('<p></p>');textNode=true;}else if($currentElement.is('p')||$currentElement.is('pre')||$currentElement.is('br')){$newElement=$('<p></p>');}else{$newElement=$('<span></span>');} |
| 482 | +var newElementHTML='';var currentHTML='';if($currentElement[0].nodeName=='#text'){currentHTML=$currentElement[0].nodeValue;}else{currentHTML=$currentElement.html();currentHTML=currentHTML.replace(/(<[\s]*p[^>]*>)|(<[\s]*\/p[^>]*>)|(<[\s]*p[^\/>]*\/>)/gi,'\n');currentHTML=currentHTML.replace(/(<[^>]*>)|(<[^\>]*\>)/gi,'');} |
| 483 | +var pieces=currentHTML.split('\n');for(var i=0;i<pieces.length;i++){if(pieces[i]){if(textNode||!$newElement.is('p')){newElementHTML+='<p class="wikiEditor">'+pieces[i]+'</p>';}else{newElementHTML+=pieces[i];}}else if(textNode||!$newElement.is('p')){newElementHTML+='<br class="wikiEditor" >';} |
| 484 | +if(!textNode){newElementHTML+='<br class="wikiEditor" >';}} |
| 485 | +$newElement.html(newElementHTML).addClass('wikiEditor');if($newElement.is('p')&&$currentElement[0].nextSibling!=null&&$($currentElement[0].nextSibling).is('br')){$($currentElement[0].nextSibling).remove();} |
| 486 | +$newElement.insertAfter($currentElement);$currentElement.remove();$selection=context.$content.find(':not(.wikiEditor)');} |
472 | 487 | context.$content.find('.wikiEditor').removeClass('wikiEditor');if($.layout.name!=='webkit'){context.$content.removeClass('pasting');} |
473 | | -context.fn.purgeOffsets();var newLength=context.fn.getContents().length;var restoreTo=cursorPos[0]+newLength-oldLength;context.fn.setSelection({start:restoreTo,end:restoreTo});},0);return true;},'ready':function(event){context.history.push({'html':context.$content.html(),'sel':context.fn.getCaretPosition()});return true;}};context.fn={'trigger':function(name,event){if(typeof event=='undefined'){event={'type':'custom'};} |
| 488 | +context.fn.purgeOffsets();var newLength=context.fn.getContents().length;var restoreTo=cursorPos[0]+newLength-oldLength;if(restoreTo>newLength){restoreTo=newLength;} |
| 489 | +context.fn.setSelection({start:restoreTo,end:restoreTo});},0);return true;},'ready':function(event){context.history.push({'html':context.$content.html(),'sel':context.fn.getCaretPosition()});return true;}};context.fn={'trigger':function(name,event){if(typeof event=='undefined'){event={'type':'custom'};} |
474 | 490 | if(typeof event.data=='undefined'){event.data={};} |
475 | 491 | if(name in context.evt){if(!context.evt[name](event)){return false;}} |
476 | 492 | var returnFromModules=null;for(var module in context.modules){if(module in $.wikiEditor.modules&&'evt'in $.wikiEditor.modules[module]&&name in $.wikiEditor.modules[module].evt){var ret=$.wikiEditor.modules[module].evt[name](context,event);if(ret!=null){if(returnFromModules==null){returnFromModules=ret;}else{returnFromModules=returnFromModules&&ret;}}}} |
— | — | @@ -559,8 +575,8 @@ |
560 | 576 | if(periRange.text==periText){rawPeriText+="\r\n";}else{periFinished=true;}}} |
561 | 577 | if(!postFinished){if(postRange.compareEndPoints("StartToEnd",postRange)==0){postFinished=true;}else{postRange.moveEnd("character",-1) |
562 | 578 | if(postRange.text==postText){rawPostText+="\r\n";}else{postFinished=true;}}}}while((!postFinished||!periFinished||!postFinished));startPos=rawPreText.replace(/\r\n/g,"\n").length;endPos=startPos+rawPeriText.replace(/\r\n/g,"\n").length;}catch(e){startPos=endPos=0;}} |
563 | | -return[startPos,endPos];},'setSelection':function(options){var sc=options.startContainer,ec=options.endContainer;sc=sc&&sc.jquery?sc[0]:sc;ec=ec&&ec.jquery?ec[0]:ec;if(context.$iframe[0].contentWindow.getSelection){var start=options.start,end=options.end;if(!sc||!ec){var s=context.fn.getOffset(start);var e=context.fn.getOffset(end);sc=s?s.node:null;ec=e?e.node:null;start=s?s.offset:null;end=e?e.offset:null;if(sc.nodeName=='#text'&&start>sc.nodeValue.length){start=sc.nodeValue.length-1;} |
564 | | -if(ec.nodeName=='#text'&&end>ec.nodeValue.length){end=ec.nodeValue.length-1;}} |
| 579 | +return[startPos,endPos];},'setSelection':function(options){var sc=options.startContainer,ec=options.endContainer;sc=sc&&sc.jquery?sc[0]:sc;ec=ec&&ec.jquery?ec[0]:ec;if(context.$iframe[0].contentWindow.getSelection){var start=options.start,end=options.end;if(!sc||!ec){var s=context.fn.getOffset(start);var e=context.fn.getOffset(end);sc=s?s.node:null;ec=e?e.node:null;start=s?s.offset:null;end=e?e.offset:null;if(sc!=null&&sc.nodeName=='#text'&&start>sc.nodeValue.length){start=sc.nodeValue.length-1;} |
| 580 | +if(ec!=null&&ec.nodeName=='#text'&&end>ec.nodeValue.length){end=ec.nodeValue.length-1;}} |
565 | 581 | if(!sc||!ec){return context.$textarea;} |
566 | 582 | var sel=context.$iframe[0].contentWindow.getSelection();while(sc.firstChild&&sc.nodeName!='#text'){sc=sc.firstChild;} |
567 | 583 | while(ec.firstChild&&ec.nodeName!='#text'){ec=ec.firstChild;} |
— | — | @@ -587,7 +603,7 @@ |
588 | 604 | configuration.newButtons[mw.usability.getMsg(msg)]=configuration.buttons[msg];configuration.buttons=configuration.newButtons;var dialogDiv=$('<div />').attr('id',module.id).html(module.html).data('context',context).appendTo($('body')).each(module.init).dialog(configuration);$.wikiEditor.modules.dialogs.fn.setTabindexes(dialogDiv.closest('.ui-dialog').find('button').not('[tabindex]'));if(!('resizeme'in module)||module.resizeme){dialogDiv.bind('dialogopen',$.wikiEditor.modules.dialogs.fn.resize).find('.ui-tabs').bind('tabsshow',function(){$(this).closest('.ui-dialog-content').each($.wikiEditor.modules.dialogs.fn.resize);});} |
589 | 605 | dialogDiv.bind('dialogclose',function(){context.fn.restoreSelection();});context.$textarea.trigger('wikiEditor-dialogs-loaded-'+mod);});},resize:function(){var wrapper=$(this).closest('.ui-dialog');var oldWidth=wrapper.width();var oldHidden=$(this).find('*').not(':visible');oldHidden.each(function(){$(this).data('oldstyle',$(this).attr('style'));});oldHidden.show();var oldWS=$(this).css('white-space');$(this).css('white-space','nowrap');if(wrapper.width()<=$(this).get(0).scrollWidth){var thisWidth=$(this).data('thisWidth')?$(this).data('thisWidth'):0;thisWidth=Math.max($(this).get(0).scrollWidth,thisWidth);$(this).width(thisWidth);$(this).data('thisWidth',thisWidth);var wrapperWidth=$(this).data('wrapperWidth')?$(this).data('wrapperWidth'):0;wrapperWidth=Math.max(wrapper.get(0).scrollWidth,wrapperWidth);wrapper.width(wrapperWidth);$(this).data('wrapperWidth',wrapperWidth);$(this).dialog({'width':wrapper.width()});wrapper.css('left',parseInt(wrapper.css('left'))-(wrapper.width()-oldWidth)/2);} |
590 | 606 | $(this).css('white-space',oldWS);oldHidden.each(function(){$(this).attr('style',$(this).data('oldstyle'));});},setTabindexes:function($elements){var maxTI=0;$j('[tabindex]').each(function(){var ti=parseInt($j(this).attr('tabindex'));if(ti>maxTI) |
591 | | -maxTI=ti;});var tabIndex=maxTI+1;$elements.each(function(){$j(this).attr('tabindex',tabIndex++);});}},modules:{},quickDialog:function(body,settings){$('<div />').text(body).appendTo($('body')).dialog($.extend({bgiframe:true,modal:true},settings)).dialog('open');}};})(jQuery);(function($){$.wikiEditor.modules.highlight={'req':['iframe'],'name':'highlight','cfg':{'styleVersion':3},'evt':{'delayedChange':function(context,event){if(event.data.scope=='realchange'){$.wikiEditor.modules.highlight.fn.scan(context);$.wikiEditor.modules.highlight.fn.mark(context,event.data.scope);}},'ready':function(context,event){$.wikiEditor.modules.highlight.fn.scan(context);$.wikiEditor.modules.highlight.fn.mark(context,'ready');}},'fn':{'create':function(context,config){context.modules.highlight.markersStr='';},'scan':function(context,division){var tokenArray=context.modules.highlight.tokenArray=[];var text=context.fn.getContents();for(var module in context.modules){if(module in $.wikiEditor.modules&&'exp'in $.wikiEditor.modules[module]){for(var exp in $.wikiEditor.modules[module].exp){var regex=$.wikiEditor.modules[module].exp[exp].regex;var label=$.wikiEditor.modules[module].exp[exp].label;var markAfter=$.wikiEditor.modules[module].exp[exp].markAfter||false;var offset=0,left,right,match;while((match=text.substr(offset).match(regex))!=null){right=(left=offset+match.index)+match[0].length;tokenArray[tokenArray.length]={'offset':markAfter?right:left,'label':label,'tokenStart':left,'match':match};offset=right;}}}} |
| 607 | +maxTI=ti;});var tabIndex=maxTI+1;$elements.each(function(){$j(this).attr('tabindex',tabIndex++);});}},modules:{},quickDialog:function(body,settings){$('<div />').text(body).appendTo($('body')).dialog($.extend({bgiframe:true,modal:true},settings)).dialog('open');}};})(jQuery);(function($){$.wikiEditor.modules.highlight={'req':['iframe'],'cfg':{'styleVersion':3},'evt':{'delayedChange':function(context,event){if(event.data.scope=='realchange'){$.wikiEditor.modules.highlight.fn.scan(context);$.wikiEditor.modules.highlight.fn.mark(context,event.data.scope);}},'ready':function(context,event){$.wikiEditor.modules.highlight.fn.scan(context);$.wikiEditor.modules.highlight.fn.mark(context,'ready');}},'fn':{'create':function(context,config){context.modules.highlight.markersStr='';},'scan':function(context,division){var tokenArray=context.modules.highlight.tokenArray=[];var text=context.fn.getContents();for(var module in context.modules){if(module in $.wikiEditor.modules&&'exp'in $.wikiEditor.modules[module]){for(var exp in $.wikiEditor.modules[module].exp){var regex=$.wikiEditor.modules[module].exp[exp].regex;var label=$.wikiEditor.modules[module].exp[exp].label;var markAfter=$.wikiEditor.modules[module].exp[exp].markAfter||false;var offset=0,left,right,match;while((match=text.substr(offset).match(regex))!=null){right=(left=offset+match.index)+match[0].length;tokenArray[tokenArray.length]={'offset':markAfter?right:left,'label':label,'tokenStart':left,'match':match};offset=right;}}}} |
592 | 608 | tokenArray.sort(function(a,b){return a.tokenStart-b.tokenStart;});context.fn.trigger('scan');},'mark':function(context,division,tokens){var markers=[];if(context.modules.highlight.markers&&division!=''){for(var i=0;i<context.modules.highlight.markers.length;i++){if(context.modules.highlight.markers[i].skipDivision==division){markers.push(context.modules.highlight.markers[i]);}}} |
593 | 609 | context.modules.highlight.markers=markers;context.fn.trigger('mark');markers.sort(function(a,b){return a.start-b.start||a.end-b.end;});var markersStr='';for(var i=0;i<markers.length;i++){markersStr+=markers[i].start+','+markers[i].end+','+markers[i].type+',';} |
594 | 610 | if(context.modules.highlight.markersStr==markersStr){return;} |
— | — | @@ -698,7 +714,7 @@ |
699 | 715 | nameEndIndex=nameEnd.index+oldDivider+2;ranges.push(new Range(ranges[ranges.length-1].end,nameBeginIndex));nameIndex=ranges.push(new Range(nameBeginIndex,nameEndIndex))-1;currentValue=currentField.substring(currentField.indexOf('=')+1);oldDivider+=currentField.indexOf('=')+1;valueBeginIndex=oldDivider+1;valueEndIndex=oldDivider+1;valueBegin=currentValue.match(/\S+/);if(valueBegin!=null){valueBeginIndex=valueBegin.index+oldDivider+1;valueEnd=currentValue.match(/[^\s]\s*$/);if(valueEnd==null){continue;} |
700 | 716 | valueEndIndex=valueEnd.index+oldDivider+2;} |
701 | 717 | equalsIndex=ranges.push(new Range(ranges[ranges.length-1].end,valueBeginIndex))-1;valueIndex=ranges.push(new Range(valueBeginIndex,valueEndIndex))-1;params.push(new Param(wikitext.substring(nameBeginIndex,nameEndIndex),wikitext.substring(valueBeginIndex,valueEndIndex),currentParamNumber,nameIndex,equalsIndex,valueIndex));paramsByName[wikitext.substring(nameBeginIndex,nameEndIndex)]=currentParamNumber;}} |
702 | | -ranges.push(new Range(valueEndIndex,wikitext.length));this.ranges=ranges;this.wikitext=wikitext;this.params=params;this.paramsByName=paramsByName;this.templateNameIndex=templateNameIndex;}}};})(jQuery);(function($){$.wikiEditor.modules.toc={'browsers':{'ltr':{'msie':[['>=',7]],'firefox':[['>=',3]],'opera':[['>=',10]],'safari':[['>=',4]],'chrome':[['>=',4]]},'rtl':{'msie':[['>=',8]],'firefox':[['>=',3]],'opera':[['>=',10]],'safari':[['>=',4]],'chrome':[['>=',4]]}},'req':['iframe'],'name':'toc',cfg:{defaultWidth:'166px',minimumWidth:'70px',textMinimumWidth:'450px',flexProperty:'marginRight',rtl:false},api:{},evt:{change:function(context,event){$.wikiEditor.modules.toc.fn.update(context);},ready:function(context,event){$.wikiEditor.modules.toc.fn.build(context);context.$content.parent().blur(function(){var context=event.data.context;$.wikiEditor.modules.toc.fn.unhighlight(context);});$.wikiEditor.modules.toc.evt.resize(context);},resize:function(context,event){var availableWidth=context.$wikitext.width()-parseFloat($.wikiEditor.modules.toc.cfg.textMinimumWidth),totalMinWidth=parseFloat($.wikiEditor.modules.toc.cfg.minimumWidth)+ |
| 718 | +ranges.push(new Range(valueEndIndex,wikitext.length));this.ranges=ranges;this.wikitext=wikitext;this.params=params;this.paramsByName=paramsByName;this.templateNameIndex=templateNameIndex;}}};})(jQuery);(function($){$.wikiEditor.modules.toc={'browsers':{'ltr':{'msie':[['>=',7]],'firefox':[['>=',3]],'opera':[['>=',10]],'safari':[['>=',4]],'chrome':[['>=',4]]},'rtl':{'msie':[['>=',8]],'firefox':[['>=',3]],'opera':[['>=',10]],'safari':[['>=',4]],'chrome':[['>=',4]]}},'req':['iframe'],cfg:{defaultWidth:'166px',minimumWidth:'70px',textMinimumWidth:'450px',flexProperty:'marginRight',rtl:false},api:{},evt:{change:function(context,event){$.wikiEditor.modules.toc.fn.update(context);},ready:function(context,event){$.wikiEditor.modules.toc.fn.build(context);context.$content.parent().blur(function(){var context=event.data.context;$.wikiEditor.modules.toc.fn.unhighlight(context);});$.wikiEditor.modules.toc.evt.resize(context);},resize:function(context,event){var availableWidth=context.$wikitext.width()-parseFloat($.wikiEditor.modules.toc.cfg.textMinimumWidth),totalMinWidth=parseFloat($.wikiEditor.modules.toc.cfg.minimumWidth)+ |
703 | 719 | parseFloat($.wikiEditor.modules.toc.cfg.textMinimumWidth);context.$ui.find('.wikiEditor-ui-right').resizable('option','maxWidth',availableWidth);if(context.modules.toc.$toc.data('positionMode')!='disabled'&&context.$wikitext.width()<totalMinWidth){$.wikiEditor.modules.toc.fn.disable(context);}else if(context.modules.toc.$toc.data('positionMode')=='disabled'&&context.$wikitext.width()>totalMinWidth){$.wikiEditor.modules.toc.fn.enable(context);}else if(context.modules.toc.$toc.data('positionMode')=='regular'&&context.$ui.find('.wikiEditor-ui-right').width()>availableWidth){$.wikiEditor.modules.toc.fn.switchLayout(context);}else if(context.modules.toc.$toc.data('positionMode')=='goofy'&&context.modules.toc.$toc.data('previousWidth')<context.$wikitext.width()){$.wikiEditor.modules.toc.fn.switchLayout(context);} |
704 | 720 | if(context.modules.toc.$toc.data('positionMode')=='goofy'){context.modules.toc.$toc.find('div').autoEllipsis({'position':'right','tooltip':true,'restoreText':true});} |
705 | 721 | if(!context.modules.toc.$toc.data('collapsed')){context.modules.toc.$toc.height(context.$ui.find('.wikiEditor-ui-left').height()- |
Property changes on: branches/wmf/1.16wmf4/extensions/UsabilityInitiative/PrefSwitch |
___________________________________________________________________ |
Name: svn:mergeinfo |
706 | 722 | - /branches/REL1_15/phase3/extensions/UsabilityInitiative/PrefSwitch:51646 |
/branches/wmf-deployment/extensions/UsabilityInitiative/PrefSwitch:60970 |
/trunk/extensions/UsabilityInitiative/PrefSwitch:56207,56209,56296,56333,56355,62041,62043,62127,62139,62142-62143,62145-62146,62256,62263,62266-63865,63867-63877,63879-64124,64129-64645,64647-64648,64650-66321,66331-66335,66402 |
/trunk/phase3/extensions/UsabilityInitiative/PrefSwitch:56213,56215-56216,56218,56325,56334-56336,56338,56340,56343,56345,56347,56350,57154-57447,57541,57916,58151,58219,58633,58816 |
707 | 723 | + /branches/REL1_15/phase3/extensions/UsabilityInitiative/PrefSwitch:51646 |
/branches/wmf-deployment/extensions/UsabilityInitiative/PrefSwitch:60970 |
/trunk/extensions/UsabilityInitiative/PrefSwitch:56207,56209,56296,56333,56355,62041,62043,62127,62139,62142-62143,62145-62146,62256,62263,62266-63865,63867-63877,63879-64124,64129-64645,64647-64648,64650-66321,66331-66335,66402,66565,66623,66631,66642-66644,66655 |
/trunk/phase3/extensions/UsabilityInitiative/PrefSwitch:56213,56215-56216,56218,56325,56334-56336,56338,56340,56343,56345,56347,56350,57154-57447,57541,57916,58151,58219,58633,58816 |
Property changes on: branches/wmf/1.16wmf4/extensions/UsabilityInitiative |
___________________________________________________________________ |
Name: svn:mergeinfo |
708 | 724 | - /branches/REL1_15/phase3/extensions/UsabilityInitiative:51646 |
/branches/wmf-deployment/extensions/UsabilityInitiative:60970 |
/trunk/extensions/UsabilityInitiative:56207,56209,56296,56333,56355,62041,62043,62127,62139,62142-62143,62145-62146,62256,62263,62266-63865,63867-63877,63879-64124,64129-64645,64647-64648,64650-66321,66324,66331-66335,66402 |
/trunk/phase3/extensions/UsabilityInitiative:56213,56215-56216,56218,56325,56334-56336,56338,56340,56343,56345,56347,56350,57154-57447,57541,57916,58151,58219,58633,58816,65387,65391,65555,65590 |
709 | 725 | + /branches/REL1_15/phase3/extensions/UsabilityInitiative:51646 |
/branches/wmf-deployment/extensions/UsabilityInitiative:60970 |
/trunk/extensions/UsabilityInitiative:56207,56209,56296,56333,56355,62041,62043,62127,62139,62142-62143,62145-62146,62256,62263,62266-63865,63867-63877,63879-64124,64129-64645,64647-64648,64650-66321,66324,66331-66335,66402,66565,66623,66631,66642-66644,66655 |
/trunk/phase3/extensions/UsabilityInitiative:56213,56215-56216,56218,56325,56334-56336,56338,56340,56343,56345,56347,56350,57154-57447,57541,57916,58151,58219,58633,58816,65387,65391,65555,65590 |