r61277 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61276‎ | r61277 | r61278 >
Date:23:40, 19 January 2010
Author:adam
Status:deferred
Tags:
Comment:
scrollToTop fix for wikiEditor
Modified paths:
  • /trunk/extensions/UsabilityInitiative/css/combined.css (modified) (history)
  • /trunk/extensions/UsabilityInitiative/css/combined.min.css (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/css/combined.css
@@ -470,21 +470,9 @@
471471 }
472472
473473 /* Self Clearing for the wikiText view */
474 -.wikiEditor-ui-view-wikiText:after {
475 - content: ".";
476 - display: block;
477 - height: 0;
478 - clear: both;
479 - visibility: hidden;
480 -}
481474 .wikiEditor-ui-view-wikiText {
482 - display: inline-block;
483 -}
484 -* html .wikiEditor-ui-view-wikiText {
485 - height: 1%;
486 -}
487 -.wikiEditor-ui-view-wikiText {
488 - display:block;
 475+ overflow: auto;
 476+ width: 100%;
489477 }/* wikiEditor toolbar module */
490478
491479 .wikiEditor-ui-toolbar {
Index: trunk/extensions/UsabilityInitiative/css/combined.min.css
@@ -439,22 +439,10 @@
440440 .wikiEditor-ui-text textarea:focus{
441441 outline:none;
442442 }
443 -.wikiEditor-ui-view-wikiText:after{
444 -content:".";
445 -display:block;
446 -height:0;
447 -clear:both;
448 -visibility:hidden;
449 -}
450443 .wikiEditor-ui-view-wikiText{
451 -display:inline-block;
 444+overflow:auto;
 445+width:100%;
452446 }
453 -* html .wikiEditor-ui-view-wikiText{
454 -height:1%;
455 -}
456 -.wikiEditor-ui-view-wikiText{
457 -display:block;
458 -}
459447 .wikiEditor-ui-toolbar{
460448 position:relative;
461449 width:100%;
Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js
@@ -561,11 +561,16 @@
562562 'scrollToTop': function( $element, force ) {
563563 var html = context.$content.closest( 'html' ),
564564 body = context.$content.closest( 'body' ),
565 - parent = $( 'html' );
566 - var y = $element.offset().top - context.$content.offset().top;
567 - y = parent.scrollTop() > 0 ? y + html.scrollTop() - parent.scrollTop() : y;
 565+ parentHtml = $( 'html' ),
 566+ parentBody = $( 'body' );
 567+ var y = $element.offset().top;
 568+ if ( !$.browser.msie ) {
 569+ y = parentHtml.scrollTop() > 0 ? y + html.scrollTop() - parentHtml.scrollTop() : y;
 570+ y = parentBody.scrollTop() > 0 ? y + body.scrollTop() - parentBody.scrollTop() : y;
 571+ }
568572 if ( force || y < html.scrollTop() || y > html.scrollTop() + context.$iframe.height() ) {
569573 html.scrollTop( y );
 574+ body.scrollTop( y );
570575 }
571576 $element.trigger( 'scrollToTop' );
572577 },
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -7042,11 +7042,16 @@
70437043 'scrollToTop': function( $element, force ) {
70447044 var html = context.$content.closest( 'html' ),
70457045 body = context.$content.closest( 'body' ),
7046 - parent = $( 'html' );
7047 - var y = $element.offset().top - context.$content.offset().top;
7048 - y = parent.scrollTop() > 0 ? y + html.scrollTop() - parent.scrollTop() : y;
 7046+ parentHtml = $( 'html' ),
 7047+ parentBody = $( 'body' );
 7048+ var y = $element.offset().top;
 7049+ if ( !$.browser.msie ) {
 7050+ y = parentHtml.scrollTop() > 0 ? y + html.scrollTop() - parentHtml.scrollTop() : y;
 7051+ y = parentBody.scrollTop() > 0 ? y + body.scrollTop() - parentBody.scrollTop() : y;
 7052+ }
70497053 if ( force || y < html.scrollTop() || y > html.scrollTop() + context.$iframe.height() ) {
70507054 html.scrollTop( y );
 7055+ body.scrollTop( y );
70517056 }
70527057 $element.trigger( 'scrollToTop' );
70537058 },
@@ -9301,10 +9306,10 @@
93029307 context.$ui.find( '.sections' ).height( context.$ui.find( '.sections .section:visible' ).outerHeight() );
93039308 },
93049309 tocCollapse: function( context, event ) {
9305 - $.wikiEditor.modules.toolbar( context, event );
 9310+ $.wikiEditor.modules.toolbar.evt.resize( context, event );
93069311 },
93079312 tocExpand: function( context, event ) {
9308 - $.wikiEditor.modules.toolbar( context, event );
 9313+ $.wikiEditor.modules.toolbar.evt.resize( context, event );
93099314 }
93109315 },
93119316 /**
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -460,7 +460,8 @@
461461 range.pasteHTML((pre+selText+post).replace(/\</g,'&lt;').replace(/>/g,'&gt;').replace(/\r?\n/g,'<br />'));}
462462 context.$content.trigger('encapsulateSelection',[pre,options.peri,post,options.ownline,options.replace]);return context.$textarea;},'getCaretPosition':function(options){},'setSelection':function(options){var sc=options.startContainer,ec=options.endContainer;sc=sc.jquery?sc[0]:sc;ec=ec.jquery?ec[0]:ec;if(context.$iframe[0].contentWindow.getSelection){var sel=context.$iframe[0].contentWindow.getSelection();while(sc.firstChild&&sc.nodeName!='#text'){sc=sc.firstChild;}
463463 while(ec.firstChild&&ec.nodeName!='#text'){ec=ec.firstChild;}
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'),parent=$('html');var y=$element.offset().top-context.$content.offset().top;y=parent.scrollTop()>0?y+html.scrollTop()-parent.scrollTop():y;if(force||y<html.scrollTop()||y>html.scrollTop()+context.$iframe.height()){html.scrollTop(y);}
 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+if(force||y<html.scrollTop()||y>html.scrollTop()+context.$iframe.height()){html.scrollTop(y);body.scrollTop(y);}
465466 $element.trigger('scrollToTop');},'beforeSelection':function(selector,strict){if(typeof selector=='undefined'){selector='*';}
466467 var e;if(context.$iframe[0].contentWindow.getSelection){var range=context.$iframe[0].contentWindow.getSelection().getRangeAt(0);e=range.startContainer;}else if(context.$iframe[0].contentWindow.document.selection){return $([]);}
467468 if(e.nodeName!='#text'){var newE=e.firstChild;for(var i=0;i<range.startOffset-1&&newE;i++){newE=newE.nextSibling;}
@@ -618,7 +619,7 @@
619620 break;case'characters':if(!('section'in data&&'page'in data)){continue;}
620621 $characters=context.modules.toolbar.$toolbar.find('div[rel='+data.section+'].section '+'div[rel='+data.page+'].page div');var actions=$characters.data('actions');for(character in data[type]){$characters.append($($.wikiEditor.modules.toolbar.fn.buildCharacter(data[type][character],actions)).click(function(){$.wikiEditor.modules.toolbar.fn.doAction($(this).parent().data('context'),$(this).parent().data('actions')[$(this).attr('rel')]);return false;}));}
621622 break;default:break;}}},removeFromToolbar:function(context,data){js_log("f:removeFromToolbar");if(typeof data.section=='string'){var tab='div.tabs span[rel='+data.section+'].tab';var target='div[rel='+data.section+'].section';if(typeof data.group=='string'){target+=' div[rel='+data.group+'].group';if(typeof data.tool=='string'){target+=' div[rel='+data.tool+'].tool';}}else if(typeof data.page=='string'){var index=target+' div.index div[rel='+data.page+']';target+=' div.pages div[rel='+data.page+'].page';if(typeof data.character=='string'){target+=' a[rel='+data.character+']';}else if(typeof data.row=='number'){target+=' table tr:not(:has(th)):eq('+data.row+')';}else{context.modules.toolbar.$toolbar.find(index).remove();$.wikiEditor.modules.toolbar.fn.updateBookletSelection(context,null,context.modules.toolbar.$toolbar.find(target),context.modules.toolbar.$toolbar.find(index));}}else{context.modules.toolbar.$toolbar.find(tab).remove();}
622 -js_log('target is: '+target);context.modules.toolbar.$toolbar.find(target).remove();}}},evt:{resize:function(context,event){context.$ui.find('.sections').height(context.$ui.find('.sections .section:visible').outerHeight());},tocCollapse:function(context,event){$.wikiEditor.modules.toolbar(context,event);},tocExpand:function(context,event){$.wikiEditor.modules.toolbar(context,event);}},fn:{create:function(context,config){if('$toolbar'in context.modules.toolbar){return;}
 623+js_log('target is: '+target);context.modules.toolbar.$toolbar.find(target).remove();}}},evt:{resize:function(context,event){context.$ui.find('.sections').height(context.$ui.find('.sections .section:visible').outerHeight());},tocCollapse:function(context,event){$.wikiEditor.modules.toolbar.evt.resize(context,event);},tocExpand:function(context,event){$.wikiEditor.modules.toolbar.evt.resize(context,event);}},fn:{create:function(context,config){if('$toolbar'in context.modules.toolbar){return;}
623624 context.modules.toolbar.$toolbar=$('<div />').addClass('wikiEditor-ui-toolbar').attr('id','wikiEditor-ui-toolbar');$.wikiEditor.modules.toolbar.fn.build(context,config);context.$ui.find('.wikiEditor-ui-top').append(context.modules.toolbar.$toolbar);},doAction:function(context,action,source){if($.trackAction!=undefined&&source.closest('.wikiEditor-ui-toolbar').size()){var rels=[];var step=source;var i=0;while(!step.hasClass('wikiEditor-ui-toolbar')){if(i>25){break;}
624625 i++;var rel=step.attr('rel');if(rel){rels.push(step.attr('rel'));}
625626 step=step.parent();}

Status & tagging log