From 47408f4467a8a3f522c7d3fe0e3cba5a029844c1 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Mon, 6 Aug 2012 17:01:53 +0800 Subject: [PATCH] UI modifications --- app/assets/javascripts/tinymce_orbit.js.erb | 2 +- app/views/layouts/_side_bar.html.erb | 7 +- .../app/assets/javascripts/galleryAPI.js.erb | 102 ++++++++---------- .../back_end/orbit_galleries_controller.rb | 15 +-- .../panel/gallery/back_end/tags_controller.rb | 2 +- .../orbit_galleries/categorylist.html.erb | 37 ++++++- .../back_end/orbit_galleries/index.html.erb | 30 ++---- 7 files changed, 104 insertions(+), 91 deletions(-) diff --git a/app/assets/javascripts/tinymce_orbit.js.erb b/app/assets/javascripts/tinymce_orbit.js.erb index f12bfa3d..fda57e29 100644 --- a/app/assets/javascripts/tinymce_orbit.js.erb +++ b/app/assets/javascripts/tinymce_orbit.js.erb @@ -47,7 +47,7 @@ function myFileBrowser(field_name, url, type, win) { var cmsURL = window.location.toString(); cmsURL = cmsURL.split("/"); cmsURL = "<%= Rails.application.routes.url_helpers.file_upload_admin_assets_path %>"; - console.log(cmsURL); + // script URL - use an absolute path! if (cmsURL.indexOf("?") < 0) { //add the type as the only query parameter diff --git a/app/views/layouts/_side_bar.html.erb b/app/views/layouts/_side_bar.html.erb index 2d15e037..1c13c801 100644 --- a/app/views/layouts/_side_bar.html.erb +++ b/app/views/layouts/_side_bar.html.erb @@ -67,14 +67,15 @@ <% end -%> <% end -%> -<%= content_tag :li, :class => active_for_controllers('orbit_galleries','tags') do -%> +<%= content_tag :li, :class => active_for_controllers('orbit_galleries','/panel/gallery/back_end/tags') do -%> <%= link_to content_tag(:i, nil, :class => 'icons-link') + t('admin.orbit_gallery'), panel_gallery_back_end_orbit_gallery_path %> - <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('orbit_gallery') ) do -%> + <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('orbit_galleries') ) do -%> <%#= content_tag :li, link_to(t('admin.ad.all_banners'), admin_ad_banners_path), :class => active_for_action('ad_banners', 'index') %> <%#= content_tag :li, link_to(t('admin.ad.new_banner'), new_admin_ad_banner_path), :class => active_for_action('ad_banners', 'new') %> <%#= content_tag :li, link_to(t('admin.ad.new_image'), new_ad_image_admin_ad_banners_path), :class => active_for_action('ad_images', 'new') %> - <%= content_tag :li, link_to(t('gallery.tags'), panel_gallery_back_end_tags_path), :class => active_for_action('/panel/orbit_gallery/back_end/tags', 'index') %> + <%= content_tag :li, link_to(t('gallery.categories'), panel_gallery_back_end_categorylist_path), :class => active_for_action('/panel/gallery/back_end/categorylist','categorylist') %> + <%= content_tag :li, link_to(t('gallery.tags'), panel_gallery_back_end_tags_path), :class => active_for_action('/panel/gallery/back_end/tags', 'index') %> <%= content_tag :li, link_to(t('admin.module.authorization'),admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {title: "orbit_gallery"}))), :class => active_for_app_auth('orbit_gallery') if (is_admin? rescue nil) %> <% end -%> <% end %> diff --git a/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI.js.erb b/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI.js.erb index 24d79d51..98398497 100644 --- a/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI.js.erb +++ b/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI.js.erb @@ -24,58 +24,27 @@ var galleryAPI = function(){ } }) var bindHandlers = function(){ - $("#gallery_panel a.btn").click(function(){ - switch ($(this).attr("href")){ - case "categories": - g.initializeCategories(); - break; + $("#filter .filter_btns a").click(function(){ + if(!$(this).hasClass("active")){ + $(this).addClass("active"); + if(typeof g.urlVars['cat'] == "undefined") + window.location = "orbit_gallery?" + $(this).attr("href"); + else + window.location = window.location.href +"&"+ $(this).attr("href"); + }else{ + $(this).removeClass("active"); + var loc = window.location.href; + var url = loc.replace($(this).attr("href")+"&",""); + if(url == loc) + url = loc.replace($(this).attr("href"),""); + + if(url.charAt(url.length-1)=="&" || url.charAt(url.length-1)=="?") + url = url.substr(0,url.length-1); + window.location = url; } - }); - $("select#category_filter").change(function(){ - var val = $(this).val(); - window.location = "orbit_gallery?cat="+val; }) } } - - this.initializeCategories = function(){ - var deleteCategory = function(a){ - var cid = a.attr("href"); - $.post("gallery_category_delete",{id:cid},function(response){ - if(response.success) - a.parent().hide("slide",function(){a.parent().remove();}) - }) - } - - $.get("categorylist",function(html){ - rcom.modalWindow({loadHtml:html,width:"400","closeBtn":false},function(dom){ - dom.find("ul#category_list a.delete").click(function(){ - var a = $(this); - deleteCategory(a); - }) - dom.find("#category_save_btn").click(function(){ - var lang = { - "en" : dom.find("#category_name_en").val(), - "zh_tw" : dom.find("#category_name_zh_tw").val() - }; - $.post("gallery_category_save",{"category":lang},function(response){ - if(response.success){ - var $li = $("
  • "+lang.en+" Delete
  • "); - dom.find("ul#category_list").append($li); - $li.show('slide'); - $li.find("a.delete").click(function(){ - deleteCategory($(this)); - }) - dom.find("input[type=text]").val(""); - } - }) - }) - dom.find("#category_close_btn").click(function(){ - rcom.modalWindowClose(); - }) - }); - }) - } this.makeNewAlbum = function(){ $.get("add_album",function(html){ rcom.modalWindow({loadHtml:html,width:400,"closeBtn":false},function(dom){ @@ -121,13 +90,27 @@ var galleryAPI = function(){ g.albumArea.find("#imgholder").empty(); var $addsign = $('
    Add Album
    '); $addsign.find("a").click(function(){g.makeNewAlbum();}) - $.getJSON("get_albums",{cid:id},function(albums){ - $.each(albums,function(i,album){ - if(album.cover == "default") - var $img = $("
    "+album.name+"
    "); - else - var $img = $("
    "+album.name+"
    "); - g.albumArea.find("#imgholder").append($img); + if(id!="all"){ + var ids = []; + var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); + for(var i = 0; i < hashes.length; i++){ + hash = hashes[i].split('='); + ids.push(hash[1]); + var href = "cat="+hash[1]; + $("#filter .filter_btns a[href='"+href+"']").addClass("active"); + } + }else{ + var ids = "all"; + } + $.getJSON("get_albums",{cid:ids},function(categories){ + $.each(categories,function(x,category){ + $.each(category,function(i,album){ + if(album.cover == "default") + var $img = $("
    "+album.name+"
    "); + else + var $img = $("
    "+album.name+"
    "); + g.albumArea.find("#imgholder").append($img); + }) }) g.albumArea.find("#imgholder").append($addsign); }) @@ -166,6 +149,8 @@ var galleryAPI = function(){ g.albumArea.find(".rghead .rgfn").append(uploadpanel); g.albumArea.find("#imgholder").empty(); + $("#filter").remove(); + g.albumArea.css("margin-top",""); var $addsign = $('
    Add Album
    '); $addsign.find("a").click(function(){showUploadPanel();}) $.getJSON("get_images",{aid:id},function(images){ @@ -332,12 +317,14 @@ var galleryAPI = function(){ $(this).text("<%= I18n.t('gallery.pic_not_found') %>."); return false; } + $("#filter").remove(); + g.albumArea.css("margin-top",""); var albumid = $(theater).find("#main_pic").attr("data-content"); head.attr("href","orbit_gallery?album="+albumid); head1.attr("href","orbit_gallery?edit="+albumid); g.albumArea.find(".rghead .rgfn").html(head); g.albumArea.find(".rghead .rgfn").append(head1); - picHeight = $(window).height() - ($("#orbit-bar").outerHeight() + $("#gallery_panel").outerHeight() + $("#orbit_gallery .rghead").outerHeight()); + picHeight = $(window).height() - ($("#orbit-bar").outerHeight() + $("#orbit_gallery .rghead").outerHeight()); preparestage(albumid); }) } @@ -399,10 +386,13 @@ var galleryAPI = function(){ } }) } + $("#filter").remove(); + g.albumArea.css("margin-top",""); var head ='"><%= I18n.t("gallery.back_to_photos") %>'; head+=''; head+=' - \ No newline at end of file + + \ No newline at end of file diff --git a/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/orbit_galleries/index.html.erb b/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/orbit_galleries/index.html.erb index f728dd60..9aea5900 100644 --- a/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/orbit_galleries/index.html.erb +++ b/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/orbit_galleries/index.html.erb @@ -13,14 +13,16 @@
    -
    - album categories +
    + <% @categorylist.each do |category| %> + <%= category.name %> + <% end %>
    -
    +
    - +