Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -57,26 +57,26 @@ |
58 | 58 | 'base_sets' => array( |
59 | 59 | 'raw' => array( |
60 | 60 | array( 'src' => 'js/plugins/jquery.async.js', 'version' => 3 ), |
61 | | - array( 'src' => 'js/plugins/jquery.autoEllipse.js', 'version' => 2 ), |
| 61 | + array( 'src' => 'js/plugins/jquery.autoEllipse.js', 'version' => 3 ), |
62 | 62 | array( 'src' => 'js/plugins/jquery.browser.js', 'version' => 3 ), |
63 | 63 | array( 'src' => 'js/plugins/jquery.cookie.js', 'version' => 3 ), |
64 | 64 | array( 'src' => 'js/plugins/jquery.delayedBind.js', 'version' => 1 ), |
65 | 65 | array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 1 ), |
66 | 66 | array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 4 ), |
67 | 67 | array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 14 ), |
68 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 8 ), |
| 68 | + array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 9 ), |
69 | 69 | array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 11 ), |
70 | 70 | array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 4 ), |
71 | | - array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 15 ), |
| 71 | + array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 16 ), |
72 | 72 | // FIXME: jQuery UI doesn't belong here, should move to no_js2 |
73 | 73 | // once we figure out how to do jQuery UI properly in JS2 |
74 | 74 | array( 'src' => 'js/js2/jquery-ui-1.7.2.js', 'version' => '1.7.2y' ), |
75 | 75 | ), |
76 | 76 | 'combined' => array( |
77 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 36 ), |
| 77 | + array( 'src' => 'js/plugins.combined.js', 'version' => 37 ), |
78 | 78 | ), |
79 | 79 | 'minified' => array( |
80 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 36 ), |
| 80 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 37 ), |
81 | 81 | ), |
82 | 82 | ), |
83 | 83 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.autoEllipse.js |
— | — | @@ -15,13 +15,24 @@ |
16 | 16 | if ( $text.outerWidth() > $(this).innerWidth() ) { |
17 | 17 | switch ( options.position ) { |
18 | 18 | case 'right': |
19 | | - var l = text.length; |
20 | | - while ( $text.outerWidth() > $(this).innerWidth() && l > 0 ) { |
21 | | - $text.text( text.substr( 0, l ) + '...' ); |
22 | | - l--; |
23 | | - } |
| 19 | + // Use binary search-like technique for |
| 20 | + // efficiency |
| 21 | + var l = 0, r = text.length; |
| 22 | + var ow, iw; |
| 23 | + do { |
| 24 | + var m = Math.ceil( ( l + r ) / 2 ); |
| 25 | + $text.text( text.substr( 0, m ) + '...' ); |
| 26 | + ow = $text.outerWidth(); |
| 27 | + iw = $(this).innerWidth(); |
| 28 | + if ( ow > iw ) |
| 29 | + // Text is too long |
| 30 | + r = m - 1; |
| 31 | + else |
| 32 | + l = m; |
| 33 | + } while ( l < r ); |
24 | 34 | break; |
25 | 35 | case 'center': |
| 36 | + // TODO: Use binary search like for 'right' |
26 | 37 | var i = [Math.round( text.length / 2 ), Math.round( text.length / 2 )]; |
27 | 38 | var side = 1; // Begin with making the end shorter |
28 | 39 | while ( $text.outerWidth() > ( $(this).innerWidth() ) && i[0] > 0 ) { |
— | — | @@ -39,6 +50,7 @@ |
40 | 51 | } |
41 | 52 | break; |
42 | 53 | case 'left': |
| 54 | + // TODO: Use binary search like for 'right' |
43 | 55 | var r = 0; |
44 | 56 | while ( $text.outerWidth() > $(this).innerWidth() && r < text.length ) { |
45 | 57 | $text.text( '...' + text.substr( r ) ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -70,7 +70,7 @@ |
71 | 71 | .height( 0 ) |
72 | 72 | .width( 0 ) |
73 | 73 | .insertBefore( $.wikiEditor.instances[0] ); |
74 | | - var textarea = $( '<textarea></textarea' ) |
| 74 | + var textarea = $( '<textarea />' ) |
75 | 75 | .height( 0 ) |
76 | 76 | .appendTo( div ) |
77 | 77 | .val( "foo\r\nbar" ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js |
— | — | @@ -23,10 +23,9 @@ |
24 | 24 | if ( '$toc' in context.modules ) { |
25 | 25 | return; |
26 | 26 | } |
27 | | - context.modules.$toc = $( '<div></div>' ) |
| 27 | + context.modules.$toc = $( '<div />' ) |
28 | 28 | .addClass( 'wikiEditor-ui-toc' ) |
29 | 29 | .attr( 'id', 'wikiEditor-ui-toc' ); |
30 | | - $.wikiEditor.modules.toc.fn.build( context, config ); |
31 | 30 | context.$ui.find( '.wikiEditor-ui-bottom' ) |
32 | 31 | .append( context.modules.$toc ); |
33 | 32 | context.modules.$toc.height( |
— | — | @@ -35,12 +34,13 @@ |
36 | 35 | // Make some css modifications to make room for the toc on the right... |
37 | 36 | // Perhaps this could be configurable? |
38 | 37 | context.modules.$toc |
39 | | - .css( 'width', '12em' ) |
40 | | - .css( 'marginTop', -( context.$ui.find( '.wikiEditor-ui-bottom' ).height() ) ); |
| 38 | + .css( { 'width': '12em', |
| 39 | + 'marginTop': -( context.$ui.find( '.wikiEditor-ui-bottom' ).height() ) |
| 40 | + } ); |
41 | 41 | context.$ui.find( '.wikiEditor-ui-text' ) |
42 | 42 | .css( ( $( 'body.rtl' ).size() ? 'marginLeft' : 'marginRight' ), '12em' ); |
43 | 43 | // Add the TOC to the document |
44 | | - $.wikiEditor.modules.toc.fn.build( context ); |
| 44 | + $.wikiEditor.modules.toc.fn.build( context, config ); |
45 | 45 | context.$textarea |
46 | 46 | .delayedBind( 1000, 'keyup encapsulateSelection change', |
47 | 47 | function( event ) { |
— | — | @@ -146,11 +146,11 @@ |
147 | 147 | * @param {Object} structure Structured outline |
148 | 148 | */ |
149 | 149 | function buildList( structure ) { |
150 | | - var list = $( '<ul></ul>' ); |
| 150 | + var list = $( '<ul />' ); |
151 | 151 | for ( i in structure ) { |
152 | | - var item = $( '<li></li>' ) |
| 152 | + var item = $( '<li />' ) |
153 | 153 | .append( |
154 | | - $( '<a></a>' ) |
| 154 | + $( '<a />' ) |
155 | 155 | .attr( 'href', '#' ) |
156 | 156 | .addClass( 'section-' + structure[i].index ) |
157 | 157 | .data( 'textbox', context.$textarea ) |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -93,13 +93,24 @@ |
94 | 94 | if ( $text.outerWidth() > $(this).innerWidth() ) { |
95 | 95 | switch ( options.position ) { |
96 | 96 | case 'right': |
97 | | - var l = text.length; |
98 | | - while ( $text.outerWidth() > $(this).innerWidth() && l > 0 ) { |
99 | | - $text.text( text.substr( 0, l ) + '...' ); |
100 | | - l--; |
101 | | - } |
| 97 | + // Use binary search-like technique for |
| 98 | + // efficiency |
| 99 | + var l = 0, r = text.length; |
| 100 | + var ow, iw; |
| 101 | + do { |
| 102 | + var m = Math.ceil( ( l + r ) / 2 ); |
| 103 | + $text.text( text.substr( 0, m ) + '...' ); |
| 104 | + ow = $text.outerWidth(); |
| 105 | + iw = $(this).innerWidth(); |
| 106 | + if ( ow > iw ) |
| 107 | + // Text is too long |
| 108 | + r = m - 1; |
| 109 | + else |
| 110 | + l = m; |
| 111 | + } while ( l < r ); |
102 | 112 | break; |
103 | 113 | case 'center': |
| 114 | + // TODO: Use binary search like for 'right' |
104 | 115 | var i = [Math.round( text.length / 2 ), Math.round( text.length / 2 )]; |
105 | 116 | var side = 1; // Begin with making the end shorter |
106 | 117 | while ( $text.outerWidth() > ( $(this).innerWidth() ) && i[0] > 0 ) { |
— | — | @@ -117,6 +128,7 @@ |
118 | 129 | } |
119 | 130 | break; |
120 | 131 | case 'left': |
| 132 | + // TODO: Use binary search like for 'right' |
121 | 133 | var r = 0; |
122 | 134 | while ( $text.outerWidth() > $(this).innerWidth() && r < text.length ) { |
123 | 135 | $text.text( '...' + text.substr( r ) ); |
— | — | @@ -1191,7 +1203,7 @@ |
1192 | 1204 | .height( 0 ) |
1193 | 1205 | .width( 0 ) |
1194 | 1206 | .insertBefore( $.wikiEditor.instances[0] ); |
1195 | | - var textarea = $( '<textarea></textarea' ) |
| 1207 | + var textarea = $( '<textarea />' ) |
1196 | 1208 | .height( 0 ) |
1197 | 1209 | .appendTo( div ) |
1198 | 1210 | .val( "foo\r\nbar" ); |
— | — | @@ -2032,10 +2044,9 @@ |
2033 | 2045 | if ( '$toc' in context.modules ) { |
2034 | 2046 | return; |
2035 | 2047 | } |
2036 | | - context.modules.$toc = $( '<div></div>' ) |
| 2048 | + context.modules.$toc = $( '<div />' ) |
2037 | 2049 | .addClass( 'wikiEditor-ui-toc' ) |
2038 | 2050 | .attr( 'id', 'wikiEditor-ui-toc' ); |
2039 | | - $.wikiEditor.modules.toc.fn.build( context, config ); |
2040 | 2051 | context.$ui.find( '.wikiEditor-ui-bottom' ) |
2041 | 2052 | .append( context.modules.$toc ); |
2042 | 2053 | context.modules.$toc.height( |
— | — | @@ -2044,12 +2055,13 @@ |
2045 | 2056 | // Make some css modifications to make room for the toc on the right... |
2046 | 2057 | // Perhaps this could be configurable? |
2047 | 2058 | context.modules.$toc |
2048 | | - .css( 'width', '12em' ) |
2049 | | - .css( 'marginTop', -( context.$ui.find( '.wikiEditor-ui-bottom' ).height() ) ); |
| 2059 | + .css( { 'width': '12em', |
| 2060 | + 'marginTop': -( context.$ui.find( '.wikiEditor-ui-bottom' ).height() ) |
| 2061 | + } ); |
2050 | 2062 | context.$ui.find( '.wikiEditor-ui-text' ) |
2051 | 2063 | .css( ( $( 'body.rtl' ).size() ? 'marginLeft' : 'marginRight' ), '12em' ); |
2052 | 2064 | // Add the TOC to the document |
2053 | | - $.wikiEditor.modules.toc.fn.build( context ); |
| 2065 | + $.wikiEditor.modules.toc.fn.build( context, config ); |
2054 | 2066 | context.$textarea |
2055 | 2067 | .delayedBind( 1000, 'keyup encapsulateSelection change', |
2056 | 2068 | function( event ) { |
— | — | @@ -2155,11 +2167,11 @@ |
2156 | 2168 | * @param {Object} structure Structured outline |
2157 | 2169 | */ |
2158 | 2170 | function buildList( structure ) { |
2159 | | - var list = $( '<ul></ul>' ); |
| 2171 | + var list = $( '<ul />' ); |
2160 | 2172 | for ( i in structure ) { |
2161 | | - var item = $( '<li></li>' ) |
| 2173 | + var item = $( '<li />' ) |
2162 | 2174 | .append( |
2163 | | - $( '<a></a>' ) |
| 2175 | + $( '<a />' ) |
2164 | 2176 | .attr( 'href', '#' ) |
2165 | 2177 | .addClass( 'section-' + structure[i].index ) |
2166 | 2178 | .data( 'textbox', context.$textarea ) |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -11,8 +11,9 @@ |
12 | 12 | {var i=0,l=array.length,loop=opts.loop||function(){};$.whileAsync($.extend(opts,{test:function(){return i<l;},loop:function() |
13 | 13 | {var val=array[i];return loop.call(val,i++,val);}}));} |
14 | 14 | $.fn.eachAsync=function(opts) |
15 | | -{$.eachAsync(this,opts);return this;}})(jQuery);(function($){$.fn.autoEllipse=function(options){$(this).each(function(){options=$.extend({'position':'center','tooltip':false},options);var text=$(this).text();var $text=$('<span />').text(text).css('whiteSpace','nowrap');$(this).empty().append($text);if($text.outerWidth()>$(this).innerWidth()){switch(options.position){case'right':var l=text.length;while($text.outerWidth()>$(this).innerWidth()&&l>0){$text.text(text.substr(0,l)+'...');l--;} |
16 | | -break;case'center':var i=[Math.round(text.length/2),Math.round(text.length/2)];var side=1;while($text.outerWidth()>($(this).innerWidth())&&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;}} |
| 15 | +{$.eachAsync(this,opts);return this;}})(jQuery);(function($){$.fn.autoEllipse=function(options){$(this).each(function(){options=$.extend({'position':'center','tooltip':false},options);var text=$(this).text();var $text=$('<span />').text(text).css('whiteSpace','nowrap');$(this).empty().append($text);if($text.outerWidth()>$(this).innerWidth()){switch(options.position){case'right':var l=0,r=text.length;var ow,iw;do{var m=Math.ceil((l+r)/2);$text.text(text.substr(0,m)+'...');ow=$text.outerWidth();iw=$(this).innerWidth();if(ow>iw) |
| 16 | +r=m-1;else |
| 17 | +l=m;}while(l<r);break;case'center':var i=[Math.round(text.length/2),Math.round(text.length/2)];var side=1;while($text.outerWidth()>($(this).innerWidth())&&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;}} |
17 | 18 | break;case'left':var r=0;while($text.outerWidth()>$(this).innerWidth()&&r<text.length){$text.text('...'+text.substr(r));r++;} |
18 | 19 | break;} |
19 | 20 | if(options.tooltip) |
— | — | @@ -78,7 +79,7 @@ |
79 | 80 | $(this).scrollTop(scroll);}else if(document.selection&&document.selection.createRange){var range=document.selection.createRange();var pos=$(this).getCaretPosition();var oldScrollTop=this.scrollTop;range.moveToElementText(this);range.collapse();range.move('character',pos+1);range.select();if(this.scrollTop!=oldScrollTop) |
80 | 81 | this.scrollTop+=range.offsetTop;else if(force){range.move('character',-1);range.select();}} |
81 | 82 | $(this).trigger('scrollToPosition');});}});})(jQuery);(function($){$.wikiEditor={'modules':{},'instances':[],'supportedBrowsers':{'ltr':{'msie':7,'firefox':2,'opera':9,'safari':3,'chrome':1,'camino':1},'rtl':{'msie':8,'firefox':2,'opera':9,'safari':3,'chrome':1,'camino':1}},imgPath:wgScriptPath+'/extensions/UsabilityInitiative/images/wikiEditor/'};$.wikiEditor.isSupportKnown=function(){return(function(supportedBrowsers){return $.browser.name in supportedBrowsers;})($.wikiEditor.supportedBrowsers[$('body.rtl').size()?'rtl':'ltr']);};$.wikiEditor.isSupported=function(){return(function(supportedBrowsers){return $.browser.name in supportedBrowsers&&$.browser.versionNumber>=supportedBrowsers[$.browser.name];})($.wikiEditor.supportedBrowsers[$('body.rtl').size()?'rtl':'ltr']);};$.wikiEditor.autoMsg=function(object,property){if(typeof property=='object'){for(i in property){if(property[i]in object||property[i]+'Msg'in object){property=property[i];break;}}} |
82 | | -if(property in object){return object[property];}else if(property+'Msg'in object){return gM(object[property+'Msg']);}else{return'';}};$.wikiEditor.fixOperaBrokenness=function(s){if(typeof $.isOperaBroken=='undefined'&&$.wikiEditor.instances.length>0){var div=$('<div />').height(0).width(0).insertBefore($.wikiEditor.instances[0]);var textarea=$('<textarea></textarea').height(0).appendTo(div).val("foo\r\nbar");var index=textarea.val().indexOf('bar');textarea.select();textarea.setSelection(index,index+3);textarea.encapsulateSelection('','BAR','',false,true);if(textarea.val().substr(-1)=='R') |
| 83 | +if(property in object){return object[property];}else if(property+'Msg'in object){return gM(object[property+'Msg']);}else{return'';}};$.wikiEditor.fixOperaBrokenness=function(s){if(typeof $.isOperaBroken=='undefined'&&$.wikiEditor.instances.length>0){var div=$('<div />').height(0).width(0).insertBefore($.wikiEditor.instances[0]);var textarea=$('<textarea />').height(0).appendTo(div).val("foo\r\nbar");var index=textarea.val().indexOf('bar');textarea.select();textarea.setSelection(index,index+3);textarea.encapsulateSelection('','BAR','',false,true);if(textarea.val().substr(-1)=='R') |
83 | 84 | $.isOperaBroken=false;else |
84 | 85 | $.isOperaBroken=true;div.remove();} |
85 | 86 | if($.isOperaBroken) |
— | — | @@ -137,14 +138,14 @@ |
138 | 139 | return $section;},updateBookletSelection:function(context,id,$pages,$index){var cookie='wikiEditor-'+context.instance+'-booklet-'+id+'-page';var selected=$.cookie(cookie);var $selectedIndex=$index.find('*[rel='+selected+']');if($selectedIndex.size()==0){selected=$index.children().eq(0).attr('rel');$.cookie(cookie,selected);} |
139 | 140 | $pages.children().hide();$pages.find('*[rel='+selected+']').show();$index.children().removeClass('current');$selectedIndex.addClass('current');},build:function(context,config){var $tabs=$('<div />').addClass('tabs').appendTo(context.modules.$toolbar);var $sections=$('<div />').addClass('sections').appendTo(context.modules.$toolbar);context.modules.$toolbar.append($('<div />').css('clear','both'));var sectionQueue=[];for(section in config){if(section=='main'){context.modules.$toolbar.prepend($.wikiEditor.modules.toolbar.fn.buildSection(context,section,config[section]));}else{sectionQueue.push({'$sections':$sections,'context':context,'id':section,'config':config[section]});$tabs.append($.wikiEditor.modules.toolbar.fn.buildTab(context,section,config[section]));}} |
140 | 141 | $.eachAsync(sectionQueue,{'bulk':0,'end':function(){$('body').css('position','static');$('body').css('position','relative');},'loop':function(i,s){s.$sections.append($.wikiEditor.modules.toolbar.fn.buildSection(s.context,s.id,s.config));}});}}};})(jQuery);(function($){$.wikiEditor.modules.toc={api:{},fn:{create:function(context,config){if('$toc'in context.modules){return;} |
141 | | -context.modules.$toc=$('<div></div>').addClass('wikiEditor-ui-toc').attr('id','wikiEditor-ui-toc');$.wikiEditor.modules.toc.fn.build(context,config);context.$ui.find('.wikiEditor-ui-bottom').append(context.modules.$toc);context.modules.$toc.height(context.$ui.find('.wikiEditor-ui-bottom').height());context.modules.$toc.css('width','12em').css('marginTop',-(context.$ui.find('.wikiEditor-ui-bottom').height()));context.$ui.find('.wikiEditor-ui-text').css(($('body.rtl').size()?'marginLeft':'marginRight'),'12em');$.wikiEditor.modules.toc.fn.build(context);context.$textarea.delayedBind(1000,'keyup encapsulateSelection change',function(event){var context=$(this).data('wikiEditor-context');$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}});}).bind('mouseup scrollToPosition focus keyup encapsulateSelection change',function(event){var context=$(this).data('wikiEditor-context');$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.update(context);}});}).blur(function(){var context=$(this).data('wikiEditor-context');$.wikiEditor.modules.toc.fn.unhighlight(context);});},unhighlight:function(context){context.modules.$toc.find('a').removeClass('currentSelection');},update:function(context){$.wikiEditor.modules.toc.fn.unhighlight(context);var position=context.$textarea.getCaretPosition();var section=0;if(context.data.outline.length>0){if(!(position<context.data.outline[0].position-1)){while(section<context.data.outline.length&&context.data.outline[section].position-1<position){section++;} |
| 142 | +context.modules.$toc=$('<div />').addClass('wikiEditor-ui-toc').attr('id','wikiEditor-ui-toc');context.$ui.find('.wikiEditor-ui-bottom').append(context.modules.$toc);context.modules.$toc.height(context.$ui.find('.wikiEditor-ui-bottom').height());context.modules.$toc.css({'width':'12em','marginTop':-(context.$ui.find('.wikiEditor-ui-bottom').height())});context.$ui.find('.wikiEditor-ui-text').css(($('body.rtl').size()?'marginLeft':'marginRight'),'12em');$.wikiEditor.modules.toc.fn.build(context,config);context.$textarea.delayedBind(1000,'keyup encapsulateSelection change',function(event){var context=$(this).data('wikiEditor-context');$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}});}).bind('mouseup scrollToPosition focus keyup encapsulateSelection change',function(event){var context=$(this).data('wikiEditor-context');$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.update(context);}});}).blur(function(){var context=$(this).data('wikiEditor-context');$.wikiEditor.modules.toc.fn.unhighlight(context);});},unhighlight:function(context){context.modules.$toc.find('a').removeClass('currentSelection');},update:function(context){$.wikiEditor.modules.toc.fn.unhighlight(context);var position=context.$textarea.getCaretPosition();var section=0;if(context.data.outline.length>0){if(!(position<context.data.outline[0].position-1)){while(section<context.data.outline.length&&context.data.outline[section].position-1<position){section++;} |
142 | 143 | section=Math.max(0,section);} |
143 | 144 | var sectionLink=context.modules.$toc.find('a.section-'+section);sectionLink.addClass('currentSelection');var relTop=sectionLink.offset().top-context.modules.$toc.offset().top;var scrollTop=context.modules.$toc.scrollTop();var divHeight=context.modules.$toc.height();var sectionHeight=sectionLink.height();if(relTop<0) |
144 | 145 | context.modules.$toc.scrollTop(scrollTop+relTop);else if(relTop+sectionHeight>divHeight) |
145 | 146 | context.modules.$toc.scrollTop(scrollTop+relTop+sectionHeight-divHeight);}},build:function(context){function buildStructure(outline,offset,level){if(offset==undefined)offset=0;if(level==undefined)level=1;var sections=[];for(var i=offset;i<outline.length;i++){if(outline[i].nLevel==level){var sub=buildStructure(outline,i+1,level+1);if(sub.length){outline[i].sections=sub;} |
146 | 147 | sections[sections.length]=outline[i];}else if(outline[i].nLevel<level){break;}} |
147 | 148 | return sections;} |
148 | | -function buildList(structure){var list=$('<ul></ul>');for(i in structure){var item=$('<li></li>').append($('<a></a>').attr('href','#').addClass('section-'+structure[i].index).data('textbox',context.$textarea).data('position',structure[i].position).click(function(event){$(this).data('textbox').setSelection($(this).data('position')).scrollToCaretPosition(true);event.preventDefault();}).text(structure[i].text));if(structure[i].sections!==undefined){item.append(buildList(structure[i].sections));} |
| 149 | +function buildList(structure){var list=$('<ul />');for(i in structure){var item=$('<li />').append($('<a />').attr('href','#').addClass('section-'+structure[i].index).data('textbox',context.$textarea).data('position',structure[i].position).click(function(event){$(this).data('textbox').setSelection($(this).data('position')).scrollToCaretPosition(true);event.preventDefault();}).text(structure[i].text));if(structure[i].sections!==undefined){item.append(buildList(structure[i].sections));} |
149 | 150 | list.append(item);} |
150 | 151 | return list;} |
151 | 152 | var outline=[];var wikitext='\n'+$.wikiEditor.fixOperaBrokenness(context.$textarea.val())+'\n';var headings=wikitext.match(/^={1,6}.+={1,6}\s*$/gm);var offset=0;headings=$.makeArray(headings);for(var h=0;h<headings.length;h++){text=headings[h];var position=wikitext.indexOf(text,offset);if(position>offset){offset=position+1;}else if(position==-1){continue;} |