Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -60,8 +60,8 @@ |
61 | 61 | array( 'src' => 'js/plugins/jquery.async.js', 'version' => 3 ), |
62 | 62 | array( 'src' => 'js/plugins/jquery.autoEllipse.js', 'version' => 3 ), |
63 | 63 | array( 'src' => 'js/plugins/jquery.browser.js', 'version' => 3 ), |
| 64 | + array( 'src' => 'js/plugins/jquery.collapsibleTabs.js', 'version' => 2 ), |
64 | 65 | array( 'src' => 'js/plugins/jquery.cookie.js', 'version' => 3 ), |
65 | | - array( 'src' => 'js/plugins/jquery.collapsibleTabs.js', 'version' => 1 ), |
66 | 66 | array( 'src' => 'js/plugins/jquery.delayedBind.js', 'version' => 1 ), |
67 | 67 | array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 1 ), |
68 | 68 | array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 5 ), |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.js |
— | — | @@ -221,7 +221,100 @@ |
222 | 222 | $.browserTest(navigator.userAgent); |
223 | 223 | })(jQuery); |
224 | 224 | |
225 | | -/** |
| 225 | +( function( $ ) { |
| 226 | + |
| 227 | +$.fn.collapsibleTabs = function( $$options ) { |
| 228 | + // return if the function is called on an empty jquery object |
| 229 | + if( !this.length ) return this; |
| 230 | + //merge options into the defaults |
| 231 | + var $settings = $.extend( {}, $.collapsibleTabs.defaults, $$options ); |
| 232 | + |
| 233 | + this.each( function() { |
| 234 | + var $this = $( this ); |
| 235 | + // add the element to our array of collapsible managers |
| 236 | + $.collapsibleTabs.instances = ( $.collapsibleTabs.instances.length == 0 ? $this : $.collapsibleTabs.instances.add( $this ) ); |
| 237 | + // attach the settings to the elements |
| 238 | + $this.data( 'collapsibleTabsSettings', $settings ); |
| 239 | + // attach data to our collapsible elements |
| 240 | + $this.children( $settings.collapsible ).each(function() { |
| 241 | + var $collapsible = $(this); |
| 242 | + $collapsible.data('collapsibleTabsSettings', { |
| 243 | + 'expandedContainer': $settings.expandedContainer, |
| 244 | + 'collapsedContainer': $settings.collapsedContainer, |
| 245 | + 'expandedWidth': $collapsible.width(), |
| 246 | + 'prevElement': $collapsible.prev() |
| 247 | + }); |
| 248 | + } ); |
| 249 | + } ); |
| 250 | + |
| 251 | + // if we haven't already bound our resize hanlder, bind it now |
| 252 | + if(!$.collapsibleTabs.boundEvent) $(window).delayedBind('500','resize', function(){ $.collapsibleTabs.handleResize(); }); |
| 253 | + // call our resize handler to setup the page |
| 254 | + $.collapsibleTabs.handleResize(); |
| 255 | + return this; |
| 256 | +}; |
| 257 | + |
| 258 | +$.collapsibleTabs = { |
| 259 | + instances: [], |
| 260 | + boundEvent: null, |
| 261 | + defaults: { |
| 262 | + expandedContainer: '#p-views ul', |
| 263 | + collapsedContainer: '#p-cactions ul', |
| 264 | + collapsible: 'li.collapsible', |
| 265 | + shifting: false, |
| 266 | + expandCondition: function(eleWidth) { |
| 267 | + return ( $('#left-navigation').position().left + $('#left-navigation').width() + 4) |
| 268 | + < ($('#right-navigation').position().left - eleWidth); |
| 269 | + }, |
| 270 | + collapseCondition: function() { |
| 271 | + return ( $('#left-navigation').position().left + $('#left-navigation').width() + 4) |
| 272 | + > $('#right-navigation').position().left; |
| 273 | + } |
| 274 | + }, |
| 275 | + handleResize: function(e){ |
| 276 | + $.collapsibleTabs.instances.each(function() { |
| 277 | + var $this = $(this), data = $this.data('collapsibleTabsSettings'); |
| 278 | + if(data.shifting) return; |
| 279 | + |
| 280 | + // if the two navigations are colliding |
| 281 | + if( $this.children(data.collapsible).length > 0 && data.collapseCondition() ) { |
| 282 | + |
| 283 | + $this.trigger("beforeTabCollapse"); |
| 284 | + // move the element to the dropdown menu |
| 285 | + $.collapsibleTabs.moveToCollapsed($this.children(data.collapsible+':last')); |
| 286 | + } |
| 287 | + |
| 288 | + // if there are still moveable items in the dropdown menu, |
| 289 | + // and there is sufficient space to place them in the tab container |
| 290 | + if($(data.collapsedContainer + ' ' + data.collapsible ).length > 0 |
| 291 | + && data.expandCondition( $(data.collapsedContainer).children( |
| 292 | + data.collapsible+":first").data('collapsibleTabsSettings').expandedWidth)) { |
| 293 | + //move the element from the dropdown to the tab |
| 294 | + $this.trigger("beforeTabExpand"); |
| 295 | + $.collapsibleTabs.moveToExpanded( data.collapsedContainer + " " + data.collapsible + ':first' ); |
| 296 | + } |
| 297 | + }); |
| 298 | + }, |
| 299 | + moveToCollapsed: function( ele ) { |
| 300 | + var $moving = $(ele); |
| 301 | + var data = $moving.data('collapsibleTabsSettings'); |
| 302 | + $(data.expandedContainer).data('collapsibleTabsSettings').shifting = true; |
| 303 | + $moving.remove().prependTo(data.collapsedContainer).data('collapsibleTabsSettings', data); |
| 304 | + $(data.expandedContainer).data('collapsibleTabsSettings').shifting = false; |
| 305 | + $.collapsibleTabs.handleResize(); |
| 306 | + }, |
| 307 | + moveToExpanded: function( ele ) { |
| 308 | + var $moving = $(ele); |
| 309 | + var data = $moving.data('collapsibleTabsSettings'); |
| 310 | + $(data.expandedContainer).data('collapsibleTabsSettings').shifting = true; |
| 311 | + // remove this element from where it's at and put it in the dropdown menu |
| 312 | + $moving.remove().insertAfter(data.prevElement).data('collapsibleTabsSettings', data); |
| 313 | + $(data.expandedContainer).data('collapsibleTabsSettings').shifting = false; |
| 314 | + $.collapsibleTabs.handleResize(); |
| 315 | + } |
| 316 | +}; |
| 317 | + |
| 318 | +} )( jQuery );/** |
226 | 319 | * Cookie plugin |
227 | 320 | * |
228 | 321 | * Copyright (c) 2006 Klaus Hartl (stilbuero.de) |
Index: trunk/extensions/UsabilityInitiative/js/plugins.combined.min.js |
— | — | @@ -18,7 +18,8 @@ |
19 | 19 | $text.attr('title',text);}});};})(jQuery);(function($){$.browserTest=function(a,z){var u='unknown',x='X',m=function(r,h){for(var i=0;i<h.length;i=i+1){r=r.replace(h[i][0],h[i][1]);} |
20 | 20 | return r;},c=function(i,a,b,c){var r={name:m((a.exec(i)||[u,u])[1],b)};r[r.name]=true;r.version=(c.exec(i)||[x,x,x,x])[3];if(r.name.match(/safari/)&&r.version>400){r.version='2.0';} |
21 | 21 | if(r.name==='presto'){r.version=($.browser.version>9.27)?'futhark':'linear_b';} |
22 | | -r.versionNumber=parseFloat(r.version,10)||0;r.versionX=(r.version!==x)?(r.version+'').substr(0,1):x;r.className=r.name+r.versionX;return r;};a=(a.match(/Opera|Navigator|Minefield|KHTML|Chrome/)?m(a,[[/(Firefox|MSIE|KHTML,\slike\sGecko|Konqueror)/,''],['Chrome Safari','Chrome'],['KHTML','Konqueror'],['Minefield','Firefox'],['Navigator','Netscape']]):a).toLowerCase();$.browser=$.extend((!z)?$.browser:{},c(a,/(camino|chrome|firefox|netscape|konqueror|lynx|msie|opera|safari)/,[],/(camino|chrome|firefox|netscape|netscape6|opera|version|konqueror|lynx|msie|safari)(\/|\s)([a-z0-9\.\+]*?)(\;|dev|rel|\s|$)/));$.layout=c(a,/(gecko|konqueror|msie|opera|webkit)/,[['konqueror','khtml'],['msie','trident'],['opera','presto']],/(applewebkit|rv|konqueror|msie)(\:|\/|\s)([a-z0-9\.]*?)(\;|\)|\s)/);$.os={name:(/(win|mac|linux|sunos|solaris|iphone)/.exec(navigator.platform.toLowerCase())||[u])[0].replace('sunos','solaris')};if(!z){$('html').addClass([$.os.name,$.browser.name,$.browser.className,$.layout.name,$.layout.className].join(' '));}};$.browserTest(navigator.userAgent);})(jQuery);jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;} |
| 22 | +r.versionNumber=parseFloat(r.version,10)||0;r.versionX=(r.version!==x)?(r.version+'').substr(0,1):x;r.className=r.name+r.versionX;return r;};a=(a.match(/Opera|Navigator|Minefield|KHTML|Chrome/)?m(a,[[/(Firefox|MSIE|KHTML,\slike\sGecko|Konqueror)/,''],['Chrome Safari','Chrome'],['KHTML','Konqueror'],['Minefield','Firefox'],['Navigator','Netscape']]):a).toLowerCase();$.browser=$.extend((!z)?$.browser:{},c(a,/(camino|chrome|firefox|netscape|konqueror|lynx|msie|opera|safari)/,[],/(camino|chrome|firefox|netscape|netscape6|opera|version|konqueror|lynx|msie|safari)(\/|\s)([a-z0-9\.\+]*?)(\;|dev|rel|\s|$)/));$.layout=c(a,/(gecko|konqueror|msie|opera|webkit)/,[['konqueror','khtml'],['msie','trident'],['opera','presto']],/(applewebkit|rv|konqueror|msie)(\:|\/|\s)([a-z0-9\.]*?)(\;|\)|\s)/);$.os={name:(/(win|mac|linux|sunos|solaris|iphone)/.exec(navigator.platform.toLowerCase())||[u])[0].replace('sunos','solaris')};if(!z){$('html').addClass([$.os.name,$.browser.name,$.browser.className,$.layout.name,$.layout.className].join(' '));}};$.browserTest(navigator.userAgent);})(jQuery);(function($){$.fn.collapsibleTabs=function($$options){if(!this.length)return this;var $settings=$.extend({},$.collapsibleTabs.defaults,$$options);this.each(function(){var $this=$(this);$.collapsibleTabs.instances=($.collapsibleTabs.instances.length==0?$this:$.collapsibleTabs.instances.add($this));$this.data('collapsibleTabsSettings',$settings);$this.children($settings.collapsible).each(function(){var $collapsible=$(this);$collapsible.data('collapsibleTabsSettings',{'expandedContainer':$settings.expandedContainer,'collapsedContainer':$settings.collapsedContainer,'expandedWidth':$collapsible.width(),'prevElement':$collapsible.prev()});});});if(!$.collapsibleTabs.boundEvent)$(window).delayedBind('500','resize',function(){$.collapsibleTabs.handleResize();});$.collapsibleTabs.handleResize();return this;};$.collapsibleTabs={instances:[],boundEvent:null,defaults:{expandedContainer:'#p-views ul',collapsedContainer:'#p-cactions ul',collapsible:'li.collapsible',shifting:false,expandCondition:function(eleWidth){return($('#left-navigation').position().left+$('#left-navigation').width()+4)<($('#right-navigation').position().left-eleWidth);},collapseCondition:function(){return($('#left-navigation').position().left+$('#left-navigation').width()+4)>$('#right-navigation').position().left;}},handleResize:function(e){$.collapsibleTabs.instances.each(function(){var $this=$(this),data=$this.data('collapsibleTabsSettings');if(data.shifting)return;if($this.children(data.collapsible).length>0&&data.collapseCondition()){$this.trigger("beforeTabCollapse");$.collapsibleTabs.moveToCollapsed($this.children(data.collapsible+':last'));} |
| 23 | +if($(data.collapsedContainer+' '+data.collapsible).length>0&&data.expandCondition($(data.collapsedContainer).children(data.collapsible+":first").data('collapsibleTabsSettings').expandedWidth)){$this.trigger("beforeTabExpand");$.collapsibleTabs.moveToExpanded(data.collapsedContainer+" "+data.collapsible+':first');}});},moveToCollapsed:function(ele){var $moving=$(ele);var data=$moving.data('collapsibleTabsSettings');$(data.expandedContainer).data('collapsibleTabsSettings').shifting=true;$moving.remove().prependTo(data.collapsedContainer).data('collapsibleTabsSettings',data);$(data.expandedContainer).data('collapsibleTabsSettings').shifting=false;$.collapsibleTabs.handleResize();},moveToExpanded:function(ele){var $moving=$(ele);var data=$moving.data('collapsibleTabsSettings');$(data.expandedContainer).data('collapsibleTabsSettings').shifting=true;$moving.remove().insertAfter(data.prevElement).data('collapsibleTabsSettings',data);$(data.expandedContainer).data('collapsibleTabsSettings').shifting=false;$.collapsibleTabs.handleResize();}};})(jQuery);jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires=-1;} |
23 | 24 | var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;} |
24 | 25 | expires='; expires='+date.toUTCString();} |
25 | 26 | var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}} |
Index: trunk/extensions/UsabilityInitiative/Makefile |
— | — | @@ -20,6 +20,7 @@ |
21 | 21 | js/plugins/jquery.async.js\ |
22 | 22 | js/plugins/jquery.autoEllipse.js\ |
23 | 23 | js/plugins/jquery.browser.js\ |
| 24 | + js/plugins/jquery.collapsibleTabs.js\ |
24 | 25 | js/plugins/jquery.cookie.js\ |
25 | 26 | js/plugins/jquery.delayedBind.js\ |
26 | 27 | js/plugins/jquery.namespaceSelect.js\ |