From 1efb807246c15661605fe2cd32219b961ced6922 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Mon, 9 Jul 2012 17:29:35 +0800 Subject: [PATCH] tinyscrollbar extension --- .../javascripts/jquery.tinyscrollbar.js | 1 - app/assets/javascripts/orbitdesktop.js | 75 ++++++++++--------- 2 files changed, 41 insertions(+), 35 deletions(-) diff --git a/app/assets/javascripts/jquery.tinyscrollbar.js b/app/assets/javascripts/jquery.tinyscrollbar.js index e9aeffde..4bca0dfa 100644 --- a/app/assets/javascripts/jquery.tinyscrollbar.js +++ b/app/assets/javascripts/jquery.tinyscrollbar.js @@ -66,7 +66,6 @@ { oSelf.update(); setEvents(); - return oSelf; } diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js index 86b68c9f..e84349a3 100755 --- a/app/assets/javascripts/orbitdesktop.js +++ b/app/assets/javascripts/orbitdesktop.js @@ -608,12 +608,18 @@ var orbitDesktop = function(dom){ $('.tinycanvas').each(function(){ var h = $(this).parent().height(), sh = $(this).siblings('.s_tab').height(); - $(this) - .css({'height': h-sh-24}) - .tinyscrollbar({ axis: 'y'}) - .find('.scrollbar') - .delay(1500) - .addClass('op00', 500); + o.tinyscrollbar_ext({ + main : $(this), + height : h-sh-24, + },{ + axis : "y" + }) + // $(this) + // .css({'height': h-sh-24}) + // .tinyscrollbar({ axis: 'y'}) + // .find('.scrollbar') + // .delay(1500) + // .addClass('op00', 500); }); $("a#name_save_btn").click(function(){ @@ -1390,18 +1396,10 @@ var orbitDesktop = function(dom){ var list = function(){ var bindHandlers = function(){ - // fill width for tiny scroll bar - var e = $('.list_t'), - count = e.length, - baseWidth = e.eq(1).outerWidth(true); - - e.parents('.overview').width( baseWidth * count ); - - $('.tinycanvas') - .tinyscrollbar({ axis: 'x'}) - .find('.scrollbar') - .delay(1500) - .addClass('op00', 500); + o.tinyscrollbar_ext({ + main : ".tinycanvas", + fill : ".list_t" + }) } $("div#seminar_p div#panel_r").load("/desktop/seminar_p_list",function(){ @@ -1483,34 +1481,43 @@ var orbitDesktop = function(dom){ o.notify("Wallpaper saving failed!!","imp",2); }) }; - this.tinyscrollbar_ext = function(target,fill,tinysettings){ - tinysettings = ( typeof tinysettings == 'undefined' ) ? {} : tinysettings ; - tinysettings.theight = ( typeof tinysettings.theight == 'undefined' ) ? '' : tinysettings.theight ; + this.tinyscrollbar_ext = function(target,tinysettings){ + //main : dom on which tinyscrollbar has to be applied + //fill : number or object for width + //height : height for the target element + //tinysettings : tinyscrollbar settings + + if(typeof target.main == "undefined"){ + o.notify('tinyscrollbar: target undefined','imp',2); + return; + }else{ + target.main = $(target.main); + } + //var target.fill = $ + var tinysettings = ( typeof tinysettings == 'undefined' ) ? {"axis":"x"} : tinysettings ; - var count,baseWidth; + var count,baseWidth,fillArray,pxs; - if( typeof fill == 'object' ){ - count = fill.length; - baseWidth = fill.eq(1).outerWidth(true); - fill.parents('.overview').width( baseWidth * count ); + if( typeof target.fill == 'object' ){ + fillArray = target.main.find(target.fill); + count = fillArray.length; + baseWidth = fillArray.eq(1).outerWidth(true); + target.main.find('.overview').width( baseWidth * count); } else if( typeof fill == 'number' ){ - fill.parents('.overview').width( fill ); + target.main.find('.overview').width( target.fill ); } else if( typeof fill == 'undefined' ){ - fill = fill; + } else { o.notify('tinyscrollbar: setting width failed','imp',2); } + if(target.height) + target.main.height(target.height); - - if( typeof $(target) !== 'undefined' ){ - $(target) + target.main .tinyscrollbar( tinysettings ) .find('.scrollbar') .delay(1500) .addClass('op00', 500); - } else { - o.notify('tinyscrollbar: target undefined','imp',2); - } }; this.simple_drop_down = function(){ // simple dropdown menu