UI modifications

This commit is contained in:
Harry Bomrah 2012-08-06 17:01:53 +08:00
parent 6159c04da6
commit 47408f4467
7 changed files with 104 additions and 91 deletions

View File

@ -47,7 +47,7 @@ function myFileBrowser(field_name, url, type, win) {
var cmsURL = window.location.toString(); var cmsURL = window.location.toString();
cmsURL = cmsURL.split("/"); cmsURL = cmsURL.split("/");
cmsURL = "<%= Rails.application.routes.url_helpers.file_upload_admin_assets_path %>"; cmsURL = "<%= Rails.application.routes.url_helpers.file_upload_admin_assets_path %>";
console.log(cmsURL);
// script URL - use an absolute path! // script URL - use an absolute path!
if (cmsURL.indexOf("?") < 0) { if (cmsURL.indexOf("?") < 0) {
//add the type as the only query parameter //add the type as the only query parameter

View File

@ -67,14 +67,15 @@
<% end -%> <% end -%>
<% 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 %> <%= 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.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_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('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) %> <%= 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 -%>
<% end %> <% end %>

View File

@ -24,57 +24,26 @@ var galleryAPI = function(){
} }
}) })
var bindHandlers = function(){ var bindHandlers = function(){
$("#gallery_panel a.btn").click(function(){ $("#filter .filter_btns a").click(function(){
switch ($(this).attr("href")){ if(!$(this).hasClass("active")){
case "categories": $(this).addClass("active");
g.initializeCategories(); if(typeof g.urlVars['cat'] == "undefined")
break; window.location = "orbit_gallery?" + $(this).attr("href");
} else
}); window.location = window.location.href +"&"+ $(this).attr("href");
$("select#category_filter").change(function(){ }else{
var val = $(this).val(); $(this).removeClass("active");
window.location = "orbit_gallery?cat="+val; var loc = window.location.href;
}) var url = loc.replace($(this).attr("href")+"&","");
} if(url == loc)
} url = loc.replace($(this).attr("href"),"");
this.initializeCategories = function(){ if(url.charAt(url.length-1)=="&" || url.charAt(url.length-1)=="?")
var deleteCategory = function(a){ url = url.substr(0,url.length-1);
var cid = a.attr("href"); window.location = url;
$.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 = $("<li class='hide'>"+lang.en+" <a href='"+response.id+"' class='btn delete' onclick='return false;'>Delete</a></li>");
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(){ this.makeNewAlbum = function(){
$.get("add_album",function(html){ $.get("add_album",function(html){
@ -121,14 +90,28 @@ var galleryAPI = function(){
g.albumArea.find("#imgholder").empty(); g.albumArea.find("#imgholder").empty();
var $addsign = $('<div class="rgalbum"><a id="global_add" class="rgui bt-addnew" href="add" onclick="return false;">Add Album</a></div>'); var $addsign = $('<div class="rgalbum"><a id="global_add" class="rgui bt-addnew" href="add" onclick="return false;">Add Album</a></div>');
$addsign.find("a").click(function(){g.makeNewAlbum();}) $addsign.find("a").click(function(){g.makeNewAlbum();})
$.getJSON("get_albums",{cid:id},function(albums){ if(id!="all"){
$.each(albums,function(i,album){ 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") if(album.cover == "default")
var $img = $("<div class='rgalbum'><a title='"+album.description+"' href='?album="+album._id+"'><img src='../../../assets/gallery/default.jpg' width='120px' height='90px'/></a><span class='albumname'>"+album.name+"</span></div>"); var $img = $("<div class='rgalbum'><a title='"+album.description+"' href='?album="+album._id+"'><img src='../../../assets/gallery/default.jpg' width='120px' height='90px'/></a><span class='albumname'>"+album.name+"</span></div>");
else else
var $img = $("<div class='rgalbum'><a title='"+album.description+"' href='?album="+album._id+"'><img src='"+album.cover_path+"' width='120px' height='90px'/></a><span class='albumname'>"+album.name+"</span></div>"); var $img = $("<div class='rgalbum'><a title='"+album.description+"' href='?album="+album._id+"'><img src='"+album.cover_path+"' width='120px' height='90px'/></a><span class='albumname'>"+album.name+"</span></div>");
g.albumArea.find("#imgholder").append($img); g.albumArea.find("#imgholder").append($img);
}) })
})
g.albumArea.find("#imgholder").append($addsign); g.albumArea.find("#imgholder").append($addsign);
}) })
} }
@ -166,6 +149,8 @@ var galleryAPI = function(){
g.albumArea.find(".rghead .rgfn").append(uploadpanel); g.albumArea.find(".rghead .rgfn").append(uploadpanel);
g.albumArea.find("#imgholder").empty(); g.albumArea.find("#imgholder").empty();
$("#filter").remove();
g.albumArea.css("margin-top","");
var $addsign = $('<div class="rgalbum"><a id="global_add" class="rgui bt-addnew" href="add" onclick="return false;">Add Album</a></div>'); var $addsign = $('<div class="rgalbum"><a id="global_add" class="rgui bt-addnew" href="add" onclick="return false;">Add Album</a></div>');
$addsign.find("a").click(function(){showUploadPanel();}) $addsign.find("a").click(function(){showUploadPanel();})
$.getJSON("get_images",{aid:id},function(images){ $.getJSON("get_images",{aid:id},function(images){
@ -332,12 +317,14 @@ var galleryAPI = function(){
$(this).text("<%= I18n.t('gallery.pic_not_found') %>."); $(this).text("<%= I18n.t('gallery.pic_not_found') %>.");
return false; return false;
} }
$("#filter").remove();
g.albumArea.css("margin-top","");
var albumid = $(theater).find("#main_pic").attr("data-content"); var albumid = $(theater).find("#main_pic").attr("data-content");
head.attr("href","orbit_gallery?album="+albumid); head.attr("href","orbit_gallery?album="+albumid);
head1.attr("href","orbit_gallery?edit="+albumid); head1.attr("href","orbit_gallery?edit="+albumid);
g.albumArea.find(".rghead .rgfn").html(head); g.albumArea.find(".rghead .rgfn").html(head);
g.albumArea.find(".rghead .rgfn").append(head1); 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); preparestage(albumid);
}) })
} }
@ -399,10 +386,13 @@ var galleryAPI = function(){
} }
}) })
} }
$("#filter").remove();
g.albumArea.css("margin-top","");
var head ='<a href="orbit_gallery?album='+id+'" class="rgui bt-back rgbt" title="<%= I18n.t("gallery.back_to_photos") %>"><span id="album_name_span"><%= I18n.t("gallery.back_to_photos") %></span></a></div>'; var head ='<a href="orbit_gallery?album='+id+'" class="rgui bt-back rgbt" title="<%= I18n.t("gallery.back_to_photos") %>"><span id="album_name_span"><%= I18n.t("gallery.back_to_photos") %></span></a></div>';
head+='<a class="rgui bt-del bt-delete rgbt" onclick="return false;" style="display:none;" title="<%= I18n.t("gallery.delete_selected") %>" href=""><span><%= I18n.t("gallery.delete_selected") %></span></a>'; head+='<a class="rgui bt-del bt-delete rgbt" onclick="return false;" style="display:none;" title="<%= I18n.t("gallery.delete_selected") %>" href=""><span><%= I18n.t("gallery.delete_selected") %></span></a>';
head+='<a class="rgui bt-save rgbt" onclick="return false;" style="display:none;" title="Save" href=""><span>Save</span>'; head+='<a class="rgui bt-save rgbt" onclick="return false;" style="display:none;" title="Save" href=""><span>Save</span>';
g.albumArea.find(".rghead .rgfn").html(head); g.albumArea.find(".rghead .rgfn").html(head);
rcom.bindDomToHead($(".rghead")); rcom.bindDomToHead($(".rghead"));
g.albumArea.find("#imgholder").load("edit_album?aid="+id,function(data,response,xhr){ g.albumArea.find("#imgholder").load("edit_album?aid="+id,function(data,response,xhr){
if(xhr.status == 404){ if(xhr.status == 404){

View File

@ -18,7 +18,7 @@ class Panel::Gallery::BackEnd::OrbitGalleriesController < OrbitBackendController
def categorylist def categorylist
@categorylist = GalleryCategory.all @categorylist = GalleryCategory.all
render :layout => false #render :layout => false
end end
def gallery_category_delete def gallery_category_delete
@ -49,12 +49,15 @@ class Panel::Gallery::BackEnd::OrbitGalleriesController < OrbitBackendController
end end
def get_albums def get_albums
@categoryid = params["cid"] @categoryids = params["cid"]
if @categoryid == "all" @albums = Array.new
@albums = GalleryAlbum.all if @categoryids == "all"
@albums << GalleryAlbum.all
else else
category = GalleryCategory.find(@categoryid) @categoryids.each do |id|
@albums = category.gallery_albums.all category = GalleryCategory.find(id)
@albums << category.gallery_albums.all
end
end end
render :json=>@albums.to_json render :json=>@albums.to_json
end end

View File

@ -2,7 +2,7 @@ class Panel::Gallery::BackEnd::TagsController < Admin::TagsController
def initialize def initialize
super super
@app_title = 'orbit_gallery' @app_title = 'gallery'
end end
end end

View File

@ -12,7 +12,40 @@
<div class="modal-footer"> <div class="modal-footer">
<%= t("gallery.new_category")+"["+ t("gallery.english")+"]" %> : <input type="text" id="category_name_en"></text><br /> <%= t("gallery.new_category")+"["+ t("gallery.english")+"]" %> : <input type="text" id="category_name_en"></text><br />
<%= t("gallery.new_category") +"["+ t("gallery.chinese")+"]" %> : <input type="text" id="category_name_zh_tw"></text><br /> <%= t("gallery.new_category") +"["+ t("gallery.chinese")+"]" %> : <input type="text" id="category_name_zh_tw"></text><br />
<a href="#" class="btn" data-dismiss="modal" id="category_close_btn" onclick="return false;"><%= t("gallery.close") %></a>
<a href="#" class="btn btn-primary" id="category_save_btn" onclick="return false;"><%= t("gallery.save_changes") %></a> <a href="#" class="btn btn-primary" id="category_save_btn" onclick="return false;"><%= t("gallery.save_changes") %></a>
</div> </div>
</div> </div>
<script type="text/javascript">
$(document).ready(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){
$("ul#category_list a.delete").click(function(){
var a = $(this);
deleteCategory(a);
})
$("#category_save_btn").click(function(){
var lang = {
"en" : $("#category_name_en").val(),
"zh_tw" : $("#category_name_zh_tw").val()
};
$.post("gallery_category_save",{"category":lang},function(response){
if(response.success){
var $li = $("<li class='hide'>"+lang.en+" <a href='"+response.id+"' class='btn delete' onclick='return false;'>Delete</a></li>");
$("ul#category_list").append($li);
$li.show('slide');
$li.find("a.delete").click(function(){
deleteCategory($(this));
})
$("input[type=text]").val("");
}
})
})
})
})
</script>

View File

@ -13,14 +13,16 @@
</ul> </ul>
<div class="filters"> <div class="filters">
<div class="accordion-body collapse" id="collapse-categories"> <div class="accordion-body collapse" id="collapse-categories">
<div class="accordion-inner" data-toggle="buttons-checkbox"> <div class="accordion-inner filter_btns" data-toggle="buttons-checkbox">
<a href="#" class="btn js_history">album categories</a> <% @categorylist.each do |category| %>
<a href="cat=<%= category.id %>" class="btn" onclick="return false;"><%= category.name %></a>
<% end %>
</div> </div>
<div class="filter-clear"> <div class="filter-clear">
<a href="panel/gallery/back_end/orbit_gallery" class="btn js_history"><i class="icons-brush-large"></i>清除</a> <a href="panel/gallery/back_end/orbit_gallery" class="btn js_history"><i class="icons-brush-large"></i>清除</a>
</div> </div>
</div> </div>
<div class="table-label"> <!-- <div class="table-label">
<table class="table main-list"> <table class="table main-list">
<thead> <thead>
<tr> <tr>
@ -34,10 +36,10 @@
</tr> </tr>
</thead> </thead>
</table> </table>
</div> -->
</div> </div>
</div> </div>
</div> <!-- <table id="gallery_list" class="table main-list">
<table id="gallery_list" class="table main-list">
<thead> <thead>
<tr> <tr>
<th class="span1"></th> <th class="span1"></th>
@ -54,23 +56,7 @@
<td></td> <td></td>
</tr> </tr>
</tbody> </tbody>
</table> </table> -->
<div id="gallery_panel">
<a class="btn" href="categories" onclick="return false;" ><%= t('gallery.manage_categories') %></a>
<select id="category_filter">
<option value=""><%= t("gallery.select_category") %></option>
<option value="all"><%= t("gallery.all") %></option>
<% @categorylist.each do |category| %>
<% if @cid == category.id.to_s %>
<option value='<%= category.id %>' selected><%= category.name %></option>
<% else %>
<option value='<%= category.id %>'><%= category.name %></option>
<% end %>
<% end %>
</select>
</div>
<div id="orbit_gallery" class="rg"> <div id="orbit_gallery" class="rg">
<div class="rghead"> <div class="rghead">
<div class="rgfn"> <div class="rgfn">