From c4db6e5830fe885f251f0bbb30c224553ac78fce Mon Sep 17 00:00:00 2001 From: devin chen Date: Thu, 6 Jun 2013 14:11:55 +0800 Subject: [PATCH] simple component update minor update --- app/assets/javascripts/orbitdesktop.js | 97 +++++++++++-------- .../stylesheets/desktop/desktop-component.css | 2 - .../desktop/desktop-component.scss | 4 - app/views/desktop/settings/themes.html.erb | 4 +- 4 files changed, 60 insertions(+), 47 deletions(-) diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js index 8ce9835ac..5635980e1 100755 --- a/app/assets/javascripts/orbitdesktop.js +++ b/app/assets/javascripts/orbitdesktop.js @@ -1072,7 +1072,7 @@ var orbitDesktop = function(dom){ var $app; count++; elementSettingsData[app.id] = {"sections" : app.sections}; - $app = $('

'+app.title+'

'); + $app = $('

'+app.title+'

'); if( count > 4 ){ count = 1, colindex+=1; $('#app_list').append('
'); @@ -1286,8 +1286,6 @@ var orbitDesktop = function(dom){ } }); }); - o.single_select(); - o.simple_tab(); $('.color-picker').miniColors({ change:function(hex){ @@ -1338,7 +1336,10 @@ var orbitDesktop = function(dom){ $(".stock_wallpaper .ssl_item").click(function(){ var wallpapername = $(this).find("img").attr("alt"); o.changeWallpaper(wallpapername); - }) + }); + + o.single_select(); + o.simple_tab(); } var loadthmc = function(){ // a general function to load the themecolor in color selector $('.color-picker').each(function(){ @@ -1361,19 +1362,19 @@ var orbitDesktop = function(dom){ color = $('#theme_preview_area .'+cc).css(hex); $(this).miniColors("value", o.rgb2hex(color)); }); - } + }; $.getJSON("/desktop/get_desktop_settings",{"get":"theme","desktopid":o.desktopId},function(theme){ + $('#st1 .theme_list [id='+theme+']') - .addClass("thmc1 active", 300) - .find("span") - .addClass("thmtxt"); - - bindHandlers(); - loadthmc(); - }) + .addClass("thmc1 active", 300) + .find("span") + .addClass("thmtxt"); + bindHandlers(); + loadthmc(); + }); } this.initializeSettings.connection = function(){ @@ -1612,7 +1613,6 @@ var orbitDesktop = function(dom){ } else { $("#thmbackground").css("background-image","url("+o.wallpaperPath+wallpaper+")"); } - console.log('loaded'); }; this.loadIconCache = function(){ // this function load or refresh icon cache for the theme @@ -1707,6 +1707,7 @@ var orbitDesktop = function(dom){ // ** not sure to update canvas here ( $.tinyscrollbar_update() ) var sw = 0, $simple_layout = $('#content .overview[content-layout=simple]'); + if($simple_layout.find(".s_column").length > 0){ $simple_layout.each(function(){ $(this).find(".s_column").filter(":visible").each(function(){ @@ -1733,46 +1734,64 @@ var orbitDesktop = function(dom){ }; this.simple_tab = function(){ // tab - var $anchor = $('.s_tab a[href*=#]'), - $tabcontent = $('.st_c'); + var active = 'thmc2 thmtxt', + normal = 'admtxt admbg'; - $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; + $('.s_tab').each(function(){ + var $anchor = $(this).find('a[href*=#]'), + $current_tab = $anchor.filter('[data-active="true"]'); + + // initialize + $current_tab.switchClass(normal,active,300); + $($current_tab.attr('href')).show(); + + $anchor.each(function(){ + $(this).click(function(){ + var target = $(this).attr('href'); + $anchor.switchClass(active,normal,200); + $(this) + .switchClass(normal,active,200) + .parents('.s_tab') + .find('a[href*=#]').not('a[href*='+target+']') + .switchClass(active,normal,200); + $(target) + .siblings('.st_c') + .hide() + .end() + .show(); + if( $(target).parents('.tinycanvas').length > 0 ){ + $(target).parents('.tinycanvas').tinyscrollbar_update(); + } + return false; + }); }); }); }; this.simple_switch = function(func){ $('.s_switch').each(function(){ - var $switcher = $(this).find('.s_switch_switcher'), - $checkbox = $(this).find('input[type=checkbox]'), - $status = $(this).find('.s_switch_status'), + var switcher = $(this).find('.s_switch_switcher'), + checkbox = $(this).find('input[type=checkbox]'), + status = $(this).find('.s_switch_status'), toggle = '', - status_on = $status.attr('status-on'), - status_off = $status.attr('status-off'), + text_on = status.attr('status-on'), + text_off = status.attr('status-off'), + status_on = 'thmc2', + status_off = 'admbg2', ini, set; - ini = ($switcher.hasClass('admbg2')) ? null : $switcher.addClass('admbg2'); - ini = ($switcher.find('.s_switch_toggle').length < 1) ? $checkbox.after(toggle) : null; - set = ($checkbox.is(':checked')) ? $status.text(status_on) : $status.text(status_off); - $checkbox.unbind().change(function(){ + ini = switcher.hasClass(status_off) ? null : switcher.addClass(status_off); + ini = switcher.find('.s_switch_toggle').length < 1 ? checkbox.after(toggle) : null; + set = checkbox.is(':checked') ? status.text(text_on) : status.text(text_off); + checkbox.unbind().change(function(){ var v = $(this).attr('checked'); switch (v) { case 'checked': - $switcher.switchClass('admbg2','thmc2'); - $status.text(status_on); + switcher.switchClass(status_off,status_on); + status.text(text_on); break; case undefined: - $switcher.switchClass('thmc2','admbg2'); - $status.text(status_off); + switcher.switchClass(status_on,status_off); + status.text(text_off); break; } if(typeof func == "function"){ diff --git a/app/assets/stylesheets/desktop/desktop-component.css b/app/assets/stylesheets/desktop/desktop-component.css index 86fdc7b7d..fe94e756e 100644 --- a/app/assets/stylesheets/desktop/desktop-component.css +++ b/app/assets/stylesheets/desktop/desktop-component.css @@ -157,8 +157,6 @@ .st_c { display: none; } - .st_c:first-child { - display: block; } /* simple form */ .s_form { diff --git a/app/assets/stylesheets/desktop/desktop-component.scss b/app/assets/stylesheets/desktop/desktop-component.scss index ea6ccd147..6fb577338 100644 --- a/app/assets/stylesheets/desktop/desktop-component.scss +++ b/app/assets/stylesheets/desktop/desktop-component.scss @@ -127,10 +127,6 @@ .stb_v {} .st_c { display: none; - - &:first-child { - display: block; - } } /* simple form */ diff --git a/app/views/desktop/settings/themes.html.erb b/app/views/desktop/settings/themes.html.erb index c7bbc7971..62a4a04b9 100644 --- a/app/views/desktop/settings/themes.html.erb +++ b/app/views/desktop/settings/themes.html.erb @@ -1,12 +1,12 @@ -
+
<% @themes.each do |theme| %>