Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -153,7 +153,7 @@ |
154 | 154 | array( |
155 | 155 | 'src' => 'js/plugins/jquery.wikiEditor.js', |
156 | 156 | 'class' => 'j.wikiEditor', |
157 | | - 'version' => 56 |
| 157 | + 'version' => 57 |
158 | 158 | ), |
159 | 159 | array( |
160 | 160 | 'src' => 'js/plugins/jquery.wikiEditor.highlight.js', |
— | — | @@ -173,7 +173,7 @@ |
174 | 174 | array( |
175 | 175 | 'src' => 'js/plugins/jquery.wikiEditor.toc.js', |
176 | 176 | 'class' => 'j.wikiEditor.modules.toc', |
177 | | - 'version' => 65 |
| 177 | + 'version' => 66 |
178 | 178 | ), |
179 | 179 | array( |
180 | 180 | 'src' => 'js/plugins/jquery.wikiEditor.preview.js', |
— | — | @@ -191,10 +191,10 @@ |
192 | 192 | 'version' => 1 ), |
193 | 193 | ), |
194 | 194 | 'combined' => array( |
195 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 160 ), |
| 195 | + array( 'src' => 'js/plugins.combined.js', 'version' => 161 ), |
196 | 196 | ), |
197 | 197 | 'minified' => array( |
198 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 160 ), |
| 198 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 161 ), |
199 | 199 | ), |
200 | 200 | ), |
201 | 201 | ); |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js |
— | — | @@ -231,10 +231,7 @@ |
232 | 232 | } |
233 | 233 | }, |
234 | 234 | unhighlight: function( context ) { |
235 | | - // FIXME: I don't know why this is undefined sometimes in Webkit, but it is, and this helps |
236 | | - if ( context ) { |
237 | | - context.modules.toc.$toc.find( 'div' ).removeClass( 'current' ); |
238 | | - } |
| 235 | + context.modules.toc.$toc.find( 'div' ).removeClass( 'current' ); |
239 | 236 | }, |
240 | 237 | /** |
241 | 238 | * Highlight the section the cursor is currently within |
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -589,13 +589,15 @@ |
590 | 590 | var e; |
591 | 591 | if ( context.$iframe[0].contentWindow.getSelection ) { |
592 | 592 | // Firefox and Opera |
593 | | - // This needs to be here for webkit, or the selection is invalid |
594 | | - context.$iframe[0].contentWindow.focus(); |
595 | | - var range = context.$iframe[0].contentWindow.getSelection().getRangeAt( 0 ); |
596 | | - // Start at the selection's start and traverse the DOM backwards |
597 | | - // This is done by traversing an element's children first, then the |
598 | | - // element itself, then its parent |
599 | | - e = range.startContainer; |
| 593 | + var selection = context.$iframe[0].contentWindow.getSelection(); |
| 594 | + // On load, webkit seems to not have a valid selection |
| 595 | + if ( selection.baseNode !== null ) { |
| 596 | + // Start at the selection's start and traverse the DOM backwards |
| 597 | + // This is done by traversing an element's children first, then the element itself, then its parent |
| 598 | + e = selection.getRangeAt( 0 ).startContainer; |
| 599 | + } else { |
| 600 | + return $( [] ); |
| 601 | + } |
600 | 602 | } else if ( context.$iframe[0].contentWindow.document.selection ) { |
601 | 603 | // IE |
602 | 604 | // TODO |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -7070,13 +7070,15 @@ |
7071 | 7071 | var e; |
7072 | 7072 | if ( context.$iframe[0].contentWindow.getSelection ) { |
7073 | 7073 | // Firefox and Opera |
7074 | | - // This needs to be here for webkit, or the selection is invalid |
7075 | | - context.$iframe[0].contentWindow.focus(); |
7076 | | - var range = context.$iframe[0].contentWindow.getSelection().getRangeAt( 0 ); |
7077 | | - // Start at the selection's start and traverse the DOM backwards |
7078 | | - // This is done by traversing an element's children first, then the |
7079 | | - // element itself, then its parent |
7080 | | - e = range.startContainer; |
| 7074 | + var selection = context.$iframe[0].contentWindow.getSelection(); |
| 7075 | + // On load, webkit seems to not have a valid selection |
| 7076 | + if ( selection.baseNode !== null ) { |
| 7077 | + // Start at the selection's start and traverse the DOM backwards |
| 7078 | + // This is done by traversing an element's children first, then the element itself, then its parent |
| 7079 | + e = selection.getRangeAt( 0 ).startContainer; |
| 7080 | + } else { |
| 7081 | + return $( [] ); |
| 7082 | + } |
7081 | 7083 | } else if ( context.$iframe[0].contentWindow.document.selection ) { |
7082 | 7084 | // IE |
7083 | 7085 | // TODO |
— | — | @@ -8808,10 +8810,7 @@ |
8809 | 8811 | } |
8810 | 8812 | }, |
8811 | 8813 | unhighlight: function( context ) { |
8812 | | - // FIXME: I don't know why this is undefined sometimes in Webkit, but it is, and this helps |
8813 | | - if ( context ) { |
8814 | | - context.modules.toc.$toc.find( 'div' ).removeClass( 'current' ); |
8815 | | - } |
| 8814 | + context.modules.toc.$toc.find( 'div' ).removeClass( 'current' ); |
8816 | 8815 | }, |
8817 | 8816 | /** |
8818 | 8817 | * Highlight the section the cursor is currently within |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -463,7 +463,7 @@ |
464 | 464 | var range=context.$iframe[0].contentWindow.document.createRange();range.setStart(sc,options.start);range.setEnd(ec,options.end);sel.removeAllRanges();sel.addRange(range);context.$iframe[0].contentWindow.focus();}else if(context.$iframe[0].contentWindow.document.body.createTextRange){var range=context.$iframe[0].contentWindow.document.body.createTextRange();range.moveToElementText(sc);range.moveStart('character',options.start);var range2=context.$iframe[0].contentWindow.document.body.createTextRange();range2.moveToElementText(ec);range2.collapse();range2.moveEnd('character',options.end);range.setEndPoint('EndToEnd',range2);range.select();}},'scrollToCaretPosition':function(options){},'scrollToTop':function($element,force){var html=context.$content.closest('html'),body=context.$content.closest('body'),parentHtml=$('html'),parentBody=$('body');var y=$element.offset().top;if(!$.browser.msie){y=parentHtml.scrollTop()>0?y+html.scrollTop()-parentHtml.scrollTop():y;y=parentBody.scrollTop()>0?y+body.scrollTop()-parentBody.scrollTop():y;} |
465 | 465 | var topBound=html.scrollTop()>body.scrollTop()?html.scrollTop():body.scrollTop(),bottomBound=topBound+context.$iframe.height();if(force||y<topBound||y>bottomBound){html.scrollTop(y);body.scrollTop(y);} |
466 | 466 | $element.trigger('scrollToTop');},'beforeSelection':function(selector,strict){if(typeof selector=='undefined'){selector='*';} |
467 | | -var e;if(context.$iframe[0].contentWindow.getSelection){context.$iframe[0].contentWindow.focus();var range=context.$iframe[0].contentWindow.getSelection().getRangeAt(0);e=range.startContainer;}else if(context.$iframe[0].contentWindow.document.selection){return $([]);} |
| 467 | +var e;if(context.$iframe[0].contentWindow.getSelection){var selection=context.$iframe[0].contentWindow.getSelection();if(selection.baseNode!==null){e=selection.getRangeAt(0).startContainer;}else{return $([]);}}else if(context.$iframe[0].contentWindow.document.selection){return $([]);} |
468 | 468 | if(e.nodeName!='#text'){var newE=e.firstChild;for(var i=0;i<range.startOffset-1&&newE;i++){newE=newE.nextSibling;} |
469 | 469 | while(newE&&newE.lastChild){newE=newE.lastChild;} |
470 | 470 | e=newE;} |
— | — | @@ -583,7 +583,7 @@ |
584 | 584 | context.$wikitext.css({'position':'','height':''});context.$ui.find('.wikiEditor-ui-right').css({'marginRight':'','position':'','left':'','right':'','float':'','top':'','height':''});context.$ui.find('.wikiEditor-ui-left').css({'width':'','position':'','left':'','float':'','right':''});} |
585 | 585 | $.wikiEditor.modules.toc.fn.redraw(context,width);},disable:function(context){if(context.modules.toc.$toc.data('collapsed')){context.$ui.find('.wikiEditor-ui-toc-expandControl').hide();}else{if(context.modules.toc.$toc.data('positionMode')=='goofy'){$.wikiEditor.modules.toc.fn.switchLayout(context);} |
586 | 586 | context.$ui.find('.wikiEditor-ui-right').hide();context.$ui.find('.wikiEditor-ui-left').css('marginRight','').children().css('marginRight','');} |
587 | | -context.modules.toc.$toc.data('positionMode','disabled');},enable:function(context){context.modules.toc.$toc.data('positionMode','regular');if(context.modules.toc.$toc.data('collapsed')){context.$ui.find('.wikiEditor-ui-toc-expandControl').show();}else{context.$ui.find('.wikiEditor-ui-right').show();$.wikiEditor.modules.toc.fn.redraw(context,$.wikiEditor.modules.toc.cfg.minimumWidth);context.modules.toc.$toc.find('div').autoEllipsis({'position':'right','tooltip':true,'restoreText':true});}},unhighlight:function(context){if(context){context.modules.toc.$toc.find('div').removeClass('current');}},update:function(context){$.wikiEditor.modules.toc.fn.unhighlight(context);var div=context.fn.beforeSelection('div.wikiEditor-toc-header');var section=div.data('section')||0;if(context.data.outline.length>0){var sectionLink=context.modules.toc.$toc.find('div.section-'+section);sectionLink.addClass('current');var relTop=sectionLink.offset().top-context.modules.toc.$toc.offset().top;var scrollTop=context.modules.toc.$toc.scrollTop();var divHeight=context.modules.toc.$toc.height();var sectionHeight=sectionLink.height();if(relTop<0) |
| 587 | +context.modules.toc.$toc.data('positionMode','disabled');},enable:function(context){context.modules.toc.$toc.data('positionMode','regular');if(context.modules.toc.$toc.data('collapsed')){context.$ui.find('.wikiEditor-ui-toc-expandControl').show();}else{context.$ui.find('.wikiEditor-ui-right').show();$.wikiEditor.modules.toc.fn.redraw(context,$.wikiEditor.modules.toc.cfg.minimumWidth);context.modules.toc.$toc.find('div').autoEllipsis({'position':'right','tooltip':true,'restoreText':true});}},unhighlight:function(context){context.modules.toc.$toc.find('div').removeClass('current');},update:function(context){$.wikiEditor.modules.toc.fn.unhighlight(context);var div=context.fn.beforeSelection('div.wikiEditor-toc-header');var section=div.data('section')||0;if(context.data.outline.length>0){var sectionLink=context.modules.toc.$toc.find('div.section-'+section);sectionLink.addClass('current');var relTop=sectionLink.offset().top-context.modules.toc.$toc.offset().top;var scrollTop=context.modules.toc.$toc.scrollTop();var divHeight=context.modules.toc.$toc.height();var sectionHeight=sectionLink.height();if(relTop<0) |
588 | 588 | context.modules.toc.$toc.scrollTop(scrollTop+relTop);else if(relTop+sectionHeight>divHeight) |
589 | 589 | context.modules.toc.$toc.scrollTop(scrollTop+relTop+sectionHeight-divHeight);}},collapse:function(event){var $this=$(this),context=$this.data('context');if(context.modules.toc.$toc.data('positionMode')=='goofy'){$.wikiEditor.modules.toc.fn.switchLayout(context);} |
590 | 590 | var pT=$this.parent().position().top-1;context.modules.toc.$toc.data('collapsed',true);context.$ui.find('.wikiEditor-ui-left').animate({'marginRight':'-1px'},'fast',function(){$(this).css('marginRight',0);}).children().animate({'marginRight':'1px'},'fast',function(){$(this).css('marginRight',0);});context.$ui.find('.wikiEditor-ui-right').css({'marginTop':'1px','position':'absolute','left':$.wikiEditor.modules.toc.cfg.rtl?0:'auto','right':$.wikiEditor.modules.toc.cfg.rtl?'auto':0,'top':pT}).fadeOut('fast',function(){$(this).hide().css({'marginTop':'0','width':'1px'});context.$ui.find('.wikiEditor-ui-toc-expandControl').fadeIn('fast');context.fn.trigger('tocCollapse');context.fn.trigger('resize');});$.cookie('wikiEditor-'+context.instance+'-toc-width',0);return false;},expand:function(event){var $this=$(this),context=$this.data('context'),openWidth=parseFloat(context.modules.toc.$toc.data('openWidth')),availableSpace=context.$wikitext.width()-parseFloat($.wikiEditor.modules.toc.cfg.textMinimumWidth);if(availableSpace<$.wikiEditor.modules.toc.cfg.textMinmumWidth)return false;context.modules.toc.$toc.data('collapsed',false);if(availableSpace<openWidth)openWidth=availableSpace;context.$ui.find('.wikiEditor-ui-toc-expandControl').hide();context.$ui.find('.wikiEditor-ui-left').animate({'marginRight':(parseFloat(openWidth)*-1)},'fast').children().animate({'marginRight':openWidth},'fast');context.$ui.find('.wikiEditor-ui-right').show().css('marginTop','1px').animate({'width':openWidth},'fast',function(){context.$content.trigger('mouseup');$(this).css({'marginTop':'0','position':'relative','right':'auto','left':'auto','top':'auto'});context.fn.trigger('tocExpand');context.fn.trigger('resize');});$.cookie('wikiEditor-'+context.instance+'-toc-width',context.modules.toc.$toc.data('openWidth'));return false;},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;} |