From bfedf207c963e1884c3d3ef7275953f625c289f1 Mon Sep 17 00:00:00 2001 From: devin Date: Mon, 9 Jul 2012 15:37:47 +0800 Subject: [PATCH] some changes --- app/assets/javascripts/orbitdesktop.js | 147 +++++++++++++------------ 1 file changed, 79 insertions(+), 68 deletions(-) diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js index 2cd970214..82ebe221a 100755 --- a/app/assets/javascripts/orbitdesktop.js +++ b/app/assets/javascripts/orbitdesktop.js @@ -149,7 +149,7 @@ var orbitDesktop = function(dom){ $(window).resize(function(){ var ww = $(window).width(); $("img#thmbackground").attr({"width":ww}); - if( $('.tinycanvas') ){ $('.tinycanvas').tinyscrollbar_update(); } + if( $('.tinycanvas').length > 0 ){ $('.tinycanvas').tinyscrollbar_update(); } if($(o.contentHolder).find("div.app_frame").length > 0){ $(o.contentHolder).find("div.app_frame").each(function(){ var app_holder_height = $(this).height() - 72; @@ -254,18 +254,8 @@ var orbitDesktop = function(dom){ .find('.scrollbar') .delay(1500) .addClass('op00', 500); - // simple dropdown menu - var $sdm = $('.sdm'); - - if( !$sdm.children('.sdm_o') ){ - return; - } else { - $sdm.hover(function(){ - $(this).addClass('thmc2'); - }, function(){ - $(this).removeClass('thmc2'); - }); - } + + o.simple_drop_down(); $("div#group_wrapper ul li[data-category=app]").click(function(){ o.appWindow({ title : $(this).find("a").attr("href"), @@ -532,13 +522,7 @@ var orbitDesktop = function(dom){ .delay(1500) .addClass('op00', 500); - var $sdm = $('.sdm'); - if( !$sdm.children('.sdm_o') ){ - return; - } else { - $sdm.hover(function(){$(this).addClass('thmc2');}, function(){$(this).removeClass('thmc2');}); - } }; var loadApps = function(){ // this loads apps from db to in each sections $.getJSON("/desktop/getapplist",{desktopid:o.desktopId},function(appss){ @@ -673,40 +657,6 @@ var orbitDesktop = function(dom){ } }); }); - // single select - $('.ssl .ssl_item').each(function(){ - var $des = $(this).find('.ssl_des'); - - $(this).on({ - click: function(){ - $(this).switchClass('','thmc1 active',0); - $(this).siblings('.thmc1').switchClass('thmc1 active','',0); - - if( $des.length > 0 ){ - $(this).parents('.ssl').find('.ssl_des').removeClass('thmtxt'); - $des.addClass('thmtxt'); - } - }, - mouseenter: function(){ - if( !$(this).hasClass('active') ){ - $(this).addClass('thmc1'); - - if( $des.length > 0 ){ - $des.addClass('thmtxt'); - } - } - }, - mouseleave: function(){ - if( !$(this).hasClass('active') ){ - $(this).removeClass('thmc1'); - - if( $des.length > 0 ){ - $des.removeClass('thmtxt'); - } - } - } - }); - }); $('.tinycanvas').each(function(){ var h = $(this).parent().height(), @@ -719,21 +669,8 @@ var orbitDesktop = function(dom){ .addClass('op00', 500); }); - // tab - var $anchor = $('.s_tab a[href*=#]'), - $tabcontent = $('.st_c'); - - $anchor.each(function(){ - $(this).click(function(){ - var target = $(this).attr('href'); - $anchor.removeClass('thmc2 thmtxt admtxt admbg').addClass('admtxt admbg'); - $(this).toggleClass('thmc2 thmtxt admtxt admbg'); - $tabcontent.hide(); - $(target).show(); - $('.tinycanvas').tinyscrollbar_update(); - return false; - }); - }); + o.single_select(); + o.simple_tab(); $('.color-picker').miniColors({ change:function(hex){ @@ -1545,6 +1482,25 @@ var orbitDesktop = function(dom){ o.notify("Wallpaper saving failed!!","imp",2); }) }; + this.tinyscrollbar_ext = function(fill,tinysettings){ + tinysettings = ( typeof tinysettings == 'undefined' ) ? {} : tinysettings ; + + var count,baseWidth; + + if( typeof fill == 'object' ){ + count = fill.length; + baseWidth = fill.eq(1).outerWidth(true); + } + + fill.parents('.overview').width( baseWidth * count ); + + $(this) + .css({'height': tinysettings.height }) + .tinyscrollbar( tinysettings ) + .find('.scrollbar') + .delay(1500) + .addClass('op00', 500); + }; this.simple_drop_down = function(){ // simple dropdown menu if( !$('.sdm').children('.sdm_o').length > 0 ){ @@ -1561,6 +1517,61 @@ var orbitDesktop = function(dom){ $(this).stop(1,1).toggleClass('thmc2 thmtxt'); }); } + }; + this.simple_tab = function(){ + // tab + var $anchor = $('.s_tab a[href*=#]'), + $tabcontent = $('.st_c'); + + $anchor.each(function(){ + $(this).click(function(){ + var target = $(this).attr('href'); + $anchor.removeClass('thmc2 thmtxt admtxt admbg').addClass('admtxt admbg'); + $(this).toggleClass('thmc2 thmtxt admtxt admbg'); + $tabcontent.hide(); + $(target).show(); + if( $('.tinycanvas').length > 0 ){ + $('.tinycanvas').tinyscrollbar_update(); + } + return false; + }); + }); + }; + this.single_select = function(){ + // single select + $('.ssl .ssl_item').each(function(){ + var $des = $(this).find('.ssl_des'); + + $(this).on({ + click: function(){ + $(this).switchClass('','thmc1 active',0); + $(this).siblings('.thmc1').switchClass('thmc1 active','',0); + + if( $des.length > 0 ){ + $(this).parents('.ssl').find('.ssl_des').removeClass('thmtxt'); + $des.addClass('thmtxt'); + } + }, + mouseenter: function(){ + if( !$(this).hasClass('active') ){ + $(this).addClass('thmc1'); + + if( $des.length > 0 ){ + $des.addClass('thmtxt'); + } + } + }, + mouseleave: function(){ + if( !$(this).hasClass('active') ){ + $(this).removeClass('thmc1'); + + if( $des.length > 0 ){ + $des.removeClass('thmtxt'); + } + } + } + }); + }); } o.initialize(); }