r58152 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58151‎ | r58152 | r58153 >
Date:18:17, 26 October 2009
Author:adam
Status:deferred
Tags:
Comment:
Making CollapsibleTabs work in RTL layouts
Modified paths:
  • /trunk/extensions/UsabilityInitiative/CollapsibleTabs/CollapsibleTabs.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/CollapsibleTabs/CollapsibleTabs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/CollapsibleTabs/CollapsibleTabs.php
@@ -13,12 +13,12 @@
1414 *
1515 * @author Adam Miller <amiller@wikimedia.org>
1616 * @license GPL v2 or later
17 - * @version 0.0.6
 17+ * @version 0.0.7
1818 */
1919
2020 /* Configuration */
2121 // Bump the version number every time you change any of the .css/.js files
22 -$wgCollapsibleTabsStyleVersion = 6;
 22+$wgCollapsibleTabsStyleVersion = 7;
2323
2424 /* Setup */
2525
@@ -27,7 +27,7 @@
2828 'path' => __FILE__,
2929 'name' => 'CollapsibleTabs',
3030 'author' => 'Adam Miller',
31 - 'version' => '0.0.6',
 31+ 'version' => '0.0.7',
3232 'url' => 'http://www.mediawiki.org/wiki/Extension:CollapsibleTabs',
3333 'descriptionmsg' => 'collapsibletabs-desc',
3434 );
Index: trunk/extensions/UsabilityInitiative/CollapsibleTabs/CollapsibleTabs.js
@@ -1,5 +1,7 @@
22 js2AddOnloadHook( function() {
33
 4+ var rtl = $j( 'body.rtl' ).size() ? true : false;
 5+
46 //Overloading the moveToCollapsed function to animate the transition
57 $j.collapsibleTabs.moveToCollapsed = function( ele ) {
68 var $moving = $j(ele);
@@ -7,11 +9,12 @@
810 var data = $moving.data('collapsibleTabsSettings');
911 // Remove the element from where it's at and put it in the dropdown menu
1012 var target = $moving.data('collapsibleTabsSettings').collapsedContainer;
11 - // $moving.hide(500);
12 - $moving.css("position", "relative").css('right',0);
 13+ $moving.css("position", "relative").css( ( rtl ? 'left' : 'right'), 0 );
1314 $moving.animate({width: '1px'},"normal",function(){
1415 //$j(this).remove().prependTo(target).data('collapsibleTabsSettings', data).show();
1516 $j(this).hide();
 17+ // add the placeholder
 18+ $j('<span class="placeholder" style="display:none;"></span>').insertAfter(this);
1619 $j(this).remove().prependTo(target).data('collapsibleTabsSettings', data);
1720 $j(this).attr('style', '');
1821 $j($j(ele).data('collapsibleTabsSettings').expandedContainer).data('collapsibleTabsSettings').shifting = false;
@@ -24,16 +27,16 @@
2528 var $moving = $j(ele);
2629 $j($moving.data('collapsibleTabsSettings').expandedContainer).data('collapsibleTabsSettings').shifting = true;
2730 var data = $moving.data('collapsibleTabsSettings');
28 - // remove this element from where it's at and put it in the dropdown menu
29 - var target = $moving.data('collapsibleTabsSettings').prevElement;
 31+ // grab the next appearing placeholder so we can use it for replacing
 32+ var $target = $j($moving.data('collapsibleTabsSettings').expandedContainer).find('span.placeholder:first');
3033 var expandedWidth = $moving.data('collapsibleTabsSettings').expandedWidth;
31 - $moving.css("position", "relative").css('left',0).css('width','1px');
32 - $moving.remove().css('width','1px').insertAfter(target).data('collapsibleTabsSettings', data)
 34+ $moving.css("position", "relative").css( ( rtl ? 'right' : 'left'), 0 ).css('width','1px');
 35+ $target.replaceWith($moving.remove().css('width','1px').data('collapsibleTabsSettings', data)
3336 .animate({width: expandedWidth+"px"}, "normal", function(){
3437 $j(this).attr('style', '');
3538 $j($moving.data('collapsibleTabsSettings').expandedContainer).data('collapsibleTabsSettings').shifting = false;
3639 $j.collapsibleTabs.handleResize();
37 - });
 40+ }));
3841 };
3942
4043 // Bind callback functions to animate our drop down menu in and out
@@ -47,6 +50,24 @@
4851 $j("#p-cactions h5").animate({'width':'1px'},370, function(){
4952 $j(this).attr('style','').parent().addClass("emptyPortlet").removeClass("filledPortlet");
5053 });
51 - }).collapsibleTabs();
52 -
 54+ }).collapsibleTabs({
 55+ expandCondition: function(eleWidth) {
 56+ if( rtl ){
 57+ return ( $j('#right-navigation').position().left + $j('#right-navigation').width())
 58+ < ($j('#left-navigation').position().left - eleWidth);
 59+ } else {
 60+ return ( $j('#left-navigation').position().left + $j('#left-navigation').width())
 61+ < ($j('#right-navigation').position().left - eleWidth);
 62+ }
 63+ },
 64+ collapseCondition: function() {
 65+ if( rtl ){
 66+ return ( $j('#right-navigation').position().left + $j('#right-navigation').width())
 67+ > $j('#left-navigation').position().left;
 68+ } else {
 69+ return ( $j('#left-navigation').position().left + $j('#left-navigation').width())
 70+ > $j('#right-navigation').position().left;
 71+ }
 72+ }
 73+ });
5374 });
\ No newline at end of file

Status & tagging log