Modifications in ruby
This commit is contained in:
parent
7ae1dcd8e0
commit
2a66b89d33
|
@ -56,26 +56,26 @@ var galleryAPI = function(){
|
||||||
this.makeNewAlbum = function(path){
|
this.makeNewAlbum = function(path){
|
||||||
$.get(path,function(html){
|
$.get(path,function(html){
|
||||||
rcom.modalWindow({loadHtml:html,width:400,height:320,"closeBtn":false},function(dom){
|
rcom.modalWindow({loadHtml:html,width:400,height:320,"closeBtn":false},function(dom){
|
||||||
dom.find("#album_name_save_btn").click(function(){
|
// dom.find("#album_name_save_btn").click(function(){
|
||||||
var options ={
|
// var options ={
|
||||||
cid : dom.find("select#category_list").val(),
|
// cid : dom.find("select#category_list").val(),
|
||||||
albumname : {
|
// albumname : {
|
||||||
"en" : dom.find("#name_en").val(),
|
// "en" : dom.find("#name_en").val(),
|
||||||
"zh_tw" : dom.find("#name_zh_tw").val()
|
// "zh_tw" : dom.find("#name_zh_tw").val()
|
||||||
},
|
// },
|
||||||
albumdesc : {
|
// albumdesc : {
|
||||||
"en" : dom.find("#desc_en").val(),
|
// "en" : dom.find("#desc_en").val(),
|
||||||
"zh_tw" : dom.find("#desc_zh_tw").val()
|
// "zh_tw" : dom.find("#desc_zh_tw").val()
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if(options.cid){
|
// if(options.cid){
|
||||||
$.post("albums/create",options,function(response){
|
// $.post("albums/create",options,function(response){
|
||||||
if(g.loadArea == "albums")
|
// if(g.loadArea == "albums")
|
||||||
g.loadAlbums("all");
|
// g.loadAlbums("all");
|
||||||
rcom.modalWindowClose();
|
// rcom.modalWindowClose();
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
dom.find("#album_name_close_btn").click(function(){
|
dom.find("#album_name_close_btn").click(function(){
|
||||||
rcom.modalWindowClose();
|
rcom.modalWindowClose();
|
||||||
})
|
})
|
||||||
|
@ -87,9 +87,9 @@ var galleryAPI = function(){
|
||||||
if(confirm("<%= I18n.t('gallery.del_album?') %>")){
|
if(confirm("<%= I18n.t('gallery.del_album?') %>")){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "DELETE",
|
type: "DELETE",
|
||||||
url : "albums/"+id,
|
url : id,
|
||||||
success : function(){
|
success : function(){
|
||||||
window.location = "albums";
|
window.location = "../albums";
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -200,8 +200,6 @@ var galleryAPI = function(){
|
||||||
g.albumArea.addClass('o_album');
|
g.albumArea.addClass('o_album');
|
||||||
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","");
|
|
||||||
$.getJSON(id+"/imgs",function(album){
|
$.getJSON(id+"/imgs",function(album){
|
||||||
$.each(album.images,function(i,image){
|
$.each(album.images,function(i,image){
|
||||||
var thumb = image.file.thumb.url;
|
var thumb = image.file.thumb.url;
|
||||||
|
@ -390,6 +388,7 @@ var galleryAPI = function(){
|
||||||
}
|
}
|
||||||
var changeImage = function(dom){
|
var changeImage = function(dom){
|
||||||
var pageurl = dom.attr('href');
|
var pageurl = dom.attr('href');
|
||||||
|
|
||||||
$img.fadeOut(200,function(){
|
$img.fadeOut(200,function(){
|
||||||
$img.attr({"src":dom.attr("data-content"),"height":picHeight+"px"});
|
$img.attr({"src":dom.attr("data-content"),"height":picHeight+"px"});
|
||||||
$img.fadeIn(200);
|
$img.fadeIn(200);
|
||||||
|
@ -398,9 +397,13 @@ var galleryAPI = function(){
|
||||||
}
|
}
|
||||||
$slidelist.stop().animate({'height':'0px'}, 300);
|
$slidelist.stop().animate({'height':'0px'}, 300);
|
||||||
$slidelist.find("ul").hide();
|
$slidelist.find("ul").hide();
|
||||||
if(pageurl!=window.location){
|
if(rcom.getInternetExplorerVersion() == -1){
|
||||||
window.history.pushState({path:pageurl},'',pageurl);
|
if(pageurl!=window.location){
|
||||||
}
|
window.history.pushState({path:pageurl},'',pageurl);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
window.location.hash = pageurl;
|
||||||
|
}
|
||||||
// $(".slideinfo b.info").text(imageArray[imagecount].title);
|
// $(".slideinfo b.info").text(imageArray[imagecount].title);
|
||||||
if($('.bt-tag').hasClass("active"))
|
if($('.bt-tag').hasClass("active"))
|
||||||
updatePhotoTag();
|
updatePhotoTag();
|
||||||
|
@ -439,7 +442,19 @@ var galleryAPI = function(){
|
||||||
bindHandlers();
|
bindHandlers();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
if(rcom.getInternetExplorerVersion()!=-1){
|
||||||
|
var url_constructor = window.location.href.split("/");
|
||||||
|
var url = "";
|
||||||
|
for(x=0;x<=url_constructor.length-1;x++){
|
||||||
|
if(x == url_constructor.length-1){
|
||||||
|
url+="#!/"+url_constructor[x];
|
||||||
|
}else{
|
||||||
|
url+=url_constructor[x]+"/";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.location.href = url;
|
||||||
|
}
|
||||||
|
|
||||||
var albumid = $("#main_pic").attr("data-content");
|
var albumid = $("#main_pic").attr("data-content");
|
||||||
g.albumArea.find(".bt-back").attr("href","../albums/"+albumid);
|
g.albumArea.find(".bt-back").attr("href","../albums/"+albumid);
|
||||||
|
@ -466,28 +481,23 @@ var galleryAPI = function(){
|
||||||
$(this)
|
$(this)
|
||||||
.toggleClass("setdelete btn-danger active")
|
.toggleClass("setdelete btn-danger active")
|
||||||
.find('span').toggleClass('icon-white');
|
.find('span').toggleClass('icon-white');
|
||||||
if($(".description_loader .edit_fn .setdelete").length > 0){
|
if($(".description_loader .edit_fn .setdelete").length > 0)
|
||||||
g.albumArea.find(".rghead .rgfn .bt-delete").show();
|
g.albumArea.find(".rghead .rgfn .bt-save").show();
|
||||||
|
|
||||||
|
if($(this).hasClass("active")){
|
||||||
|
$(this).parent().parent().find("input.del_field").val(true);
|
||||||
}else{
|
}else{
|
||||||
g.albumArea.find(".rghead .rgfn .bt-delete").hide();
|
$(this).parent().parent().find("input.del_field").val(false);
|
||||||
}
|
}
|
||||||
|
delete_cover();
|
||||||
})
|
})
|
||||||
g.albumArea.find(".rghead .rgfn .bt-save").click(function(){
|
var delete_cover = function(){
|
||||||
// var dataArray = Array();
|
if($(".description_loader .setcover").parent().find(".bt-dels").hasClass("active")){
|
||||||
// $(".description_loader .en .txtchange").each(function(){
|
$("input.del_cover").val(true);
|
||||||
// var thisid = $(this).attr("for");
|
}else{
|
||||||
// dataArray.push({"id":thisid,"text":{"en":$(this).val(),"zh_tw":$(".description_loader .zh_tw .txtchange[for="+thisid+"]").val()}});
|
$("input.del_cover").val(false);
|
||||||
// })
|
}
|
||||||
// var albumnm = Array();
|
}
|
||||||
// $(".albumname_edit .txtchange").each(function(){
|
|
||||||
// albumnm.push($(this).val())
|
|
||||||
// })
|
|
||||||
// var dataArray = $("form#edit_album").serialize();
|
|
||||||
// $.post("update_album",{"data":dataArray},function(){
|
|
||||||
|
|
||||||
// })
|
|
||||||
|
|
||||||
})
|
|
||||||
var current_element_for_tags = null;
|
var current_element_for_tags = null;
|
||||||
var current_element_no = null;
|
var current_element_no = null;
|
||||||
$('.bt-tag').click(function(){
|
$('.bt-tag').click(function(){
|
||||||
|
|
|
@ -28,22 +28,27 @@ include AdminHelper
|
||||||
elsif is_sub_manager?
|
elsif is_sub_manager?
|
||||||
@categorylist = GalleryCategory.authed_for_user(current_user,"new_album")
|
@categorylist = GalleryCategory.authed_for_user(current_user,"new_album")
|
||||||
end
|
end
|
||||||
|
@album = GalleryAlbum.new
|
||||||
render :layout => false
|
render :layout => false
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
category = GalleryCategory.find(params['cid'])
|
# category = GalleryCategory.find(params['cid'])
|
||||||
albumnames = params["albumname"]
|
# albumnames = params["albumname"]
|
||||||
albumdescs = params["albumdesc"]
|
# albumdescs = params["albumdesc"]
|
||||||
album = category.gallery_albums.new
|
# album = category.gallery_albums.new
|
||||||
I18n.locale = :en
|
# I18n.locale = :en
|
||||||
album.name = albumnames["en"]
|
# album.name = albumnames["en"]
|
||||||
album.description = albumdescs["en"]
|
# album.description = albumdescs["en"]
|
||||||
I18n.locale = :zh_tw
|
# I18n.locale = :zh_tw
|
||||||
album.name = albumnames["zh_tw"]
|
# album.name = albumnames["zh_tw"]
|
||||||
album.description = albumdescs["zh_tw"]
|
# album.description = albumdescs["zh_tw"]
|
||||||
|
album = GalleryAlbum.new(params[:gallery_album])
|
||||||
album.save!
|
album.save!
|
||||||
render :json=>{"success"=>true,"id"=>album.id}.to_json
|
# render :json=>{"success"=>true,"id"=>album.id}.to_json
|
||||||
|
respond_to do |h|
|
||||||
|
h.js
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_albums
|
def get_albums
|
||||||
|
@ -170,15 +175,16 @@ include AdminHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
debugger
|
|
||||||
@album = GalleryAlbum.find(params[:id])
|
@album = GalleryAlbum.find(params[:id])
|
||||||
#album.update_attributes(params[:gallery_album])
|
@album.update_attributes(params[:gallery_album])
|
||||||
if is_manager? || is_admin? || is_sub_manager?
|
if is_manager? || is_admin? || is_sub_manager?
|
||||||
@authenticated = true #turn this value to false for view only
|
@authenticated = true #turn this value to false for view only
|
||||||
else
|
else
|
||||||
@authenticated = false
|
@authenticated = false
|
||||||
end
|
end
|
||||||
|
if params['delete_cover'] == "true"
|
||||||
|
@album.update_attributes(:cover=>"default")
|
||||||
|
end
|
||||||
@tags = GalleryTag.all
|
@tags = GalleryTag.all
|
||||||
render :action => :show
|
render :action => :show
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,24 +2,32 @@ class Panel::Gallery::BackEnd::GalleryCategoriesController < OrbitBackendControl
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@categorylist = GalleryCategory.all
|
@categorylist = GalleryCategory.all
|
||||||
#render :layout => false
|
@new_category = GalleryCategory.new
|
||||||
|
end
|
||||||
|
def edit
|
||||||
|
@category = GalleryCategory.find(params[:id])
|
||||||
|
render :layout => false
|
||||||
|
end
|
||||||
|
def create
|
||||||
|
@category = GalleryCategory.new(params[:gallery_category])
|
||||||
|
@category.save!
|
||||||
|
respond_to do |h|
|
||||||
|
h.js
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def update
|
||||||
|
@category = GalleryCategory.find(params[:id])
|
||||||
|
@category.update_attributes(params[:gallery_category])
|
||||||
|
respond_to do |h|
|
||||||
|
h.js
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def destroy
|
||||||
names = params['category']
|
|
||||||
category = GalleryCategory.new
|
|
||||||
I18n.locale = :en
|
|
||||||
category.name = names['en']
|
|
||||||
I18n.locale = :zh_tw
|
|
||||||
category.name = names['zh_tw']
|
|
||||||
category.save!
|
|
||||||
render :json=>{"success"=>true,"id"=>category.id}.to_json
|
|
||||||
end
|
|
||||||
|
|
||||||
def delete
|
|
||||||
@category = GalleryCategory.find(params['id'])
|
@category = GalleryCategory.find(params['id'])
|
||||||
@category.delete
|
@category.delete
|
||||||
render :json=>{"success"=>"true"}.to_json
|
render :json=>{"success"=>"true"}.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -11,5 +11,6 @@ class GalleryAlbum
|
||||||
belongs_to :gallery_category
|
belongs_to :gallery_category
|
||||||
has_and_belongs_to_many :tags, :class_name => "GalleryTag"
|
has_and_belongs_to_many :tags, :class_name => "GalleryTag"
|
||||||
has_many :gallery_images, :autosave => true, :dependent => :destroy
|
has_many :gallery_images, :autosave => true, :dependent => :destroy
|
||||||
|
accepts_nested_attributes_for :gallery_images, :allow_destroy => true
|
||||||
|
|
||||||
end
|
end
|
|
@ -1,95 +0,0 @@
|
||||||
|
|
||||||
<%= stylesheet_link_tag "gallery" %>
|
|
||||||
|
|
||||||
<div id="orbit_gallery" class="rg">
|
|
||||||
<div class="rgbody">
|
|
||||||
<div id="imgholder">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- tag part -->
|
|
||||||
<div id="tag_panel" class="my_scroll">
|
|
||||||
<div class="scrollbar">
|
|
||||||
<div class="track">
|
|
||||||
<div class="thumb">
|
|
||||||
<div class="end"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<%
|
|
||||||
@locales = Array.new
|
|
||||||
@site_valid_locales.each do |locale|
|
|
||||||
@locales << locale
|
|
||||||
end
|
|
||||||
%>
|
|
||||||
<div class="viewport">
|
|
||||||
<div class="overview">
|
|
||||||
<ul class="tag_list" id="gallery_tag_list">
|
|
||||||
<% if @authenticated %>
|
|
||||||
<% @tags.each do |tag| %>
|
|
||||||
<li data-content="<%= tag.id %>"><input id="tag_<%= tag.id %>" type="checkbox"><label for="tag_<%= tag.id %>"><%= tag[I18n.locale] %></label><span style="display:none;"><%= tag[@locales[1]] %> <%= tag[@locales[0]] %></span></li>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<% if @authenticated %>
|
|
||||||
<div class="tag_search"><div class="icon-search"></div><input type="text" value="<%= t('gallery.search_tags') %>" onblur="if(this.value=='')this.value='<%= t('gallery.search_tags') %>';" onfocus="if(this.value=='<%= t("gallery.search_tags") %>')this.value='';" id="tag_search_box"> <div class="tag_save"><a class="btn bt-save"><i class="icon-ok"></i><%= I18n.t("gallery.save") %></a></div></div>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
var $tag_panel = $('#tag_panel');
|
|
||||||
orbit_bar_height = $('#orbit-bar').outerHeight();
|
|
||||||
action_panel_height = $('.form-actions').outerHeight();
|
|
||||||
window_height = $(window).height();
|
|
||||||
|
|
||||||
|
|
||||||
$tag_panel.height( window_height - orbit_bar_height - 90 );
|
|
||||||
$tag_panel.tinyscrollbar();
|
|
||||||
|
|
||||||
$(window).resize(function(){
|
|
||||||
$tag_panel.tinyscrollbar_update('relative');
|
|
||||||
$tag_panel.height( $(window).height() - orbit_bar_height - 90 );
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
|
||||||
<!-- tag end -->
|
|
||||||
<div class="form-actions form-fixed pagination-right rghead">
|
|
||||||
<div class="rgfn">
|
|
||||||
<% if params[:theater] %>
|
|
||||||
<a href="" class="bt-back btn pull-left" title="<%= I18n.t("gallery.back_to_photos") %>"><i class="icon-arrow-left icon-black"></i><%= I18n.t("gallery.back_to_photos") %></a>
|
|
||||||
<a class="bt-edit btn btn-primary pull-right" title="<%= I18n.t("gallery.edit") %>" href="" ><i class="icon-pencil icon-white"></i><%= I18n.t("gallery.edit") %></a>
|
|
||||||
<a class="bt-tag btn btn-primary pull-right" title="<%= I18n.t("gallery.photo_tag") %>" href="" ><i class="icon-tag icon-white"></i><%= I18n.t("gallery.photo_tag") %></a>
|
|
||||||
<% else %>
|
|
||||||
<a class="bt-back btn btn-primary pull-left" title="<%= I18n.t("gallery.back_to_albums") %>" href="albums"><i class="icon-arrow-left icon-white"></i><%= I18n.t("gallery.back_to_albums") %></a>
|
|
||||||
<a class="bt-tag btn btn-primary pull-right" title="<%= I18n.t("gallery.album_tag") %>" href="" ><i class="icon-tag icon-white"></i><%= I18n.t("gallery.album_tag") %></ a>
|
|
||||||
<% if @authenticated %>
|
|
||||||
<a class="bt-add btn btn-primary pull-right" title="<%= I18n.t("gallery.add_images") %>" href="images" onclick="return false;"><i class="icon-plus icon-white"></i><%= I18n.t("gallery.add_images") %></a>
|
|
||||||
<a class="bt-del btn btn-primary pull-right" title="<%= I18n.t("gallery.del_album") %>" href="delete" onclick="return false;"><i class="icon-trash icon-white"></i><%= I18n.t("gallery.del_album") %></a>
|
|
||||||
<a class="bt-edit btn btn-primary pull-right" title="<%= I18n.t("gallery.edit") %>" href="albums/<%= params[:album] %>/edit" ><i class="icon-pencil icon-white"></i><%= I18n.t("gallery.edit") %></a>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<% content_for :page_specific_javascript do %>
|
|
||||||
<%= javascript_include_tag "galleryAPI" %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
galleryAPI.prototype.locale = "<%= I18n.locale %>";
|
|
||||||
var gallery = new galleryAPI();
|
|
||||||
gallery.initialize();
|
|
||||||
//gallery.loadAlbums(gallery.urlVars['cat']);
|
|
||||||
gallery.loadArea = "images";
|
|
||||||
gallery.loadImages("<%= params[:id] %>");
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
<!-- <div class="rghead">
|
|
||||||
<div class="rgfn">
|
|
||||||
<a href="" class="rgui bt-back rgbt" title="Back" id='bakbtngallery'><span id='album_name_span'>Back to photos</span></a>
|
|
||||||
</div>
|
|
||||||
<div class="rgtitle">Gallery</div>
|
|
||||||
</div>
|
|
||||||
</div> -->
|
|
||||||
<div class="rslide" style="position:relative; width:100%;">
|
|
||||||
<div class="rslideinside"><div id="loading" style="display:none;"></div>
|
|
||||||
<div class="comp" id='main_pic' data-content='<%= @image.gallery_album_id %>'><a href="" id="nextpic" class="navN" title="下一張" onclick="return false;" ><img src="<%= @image.file.url %>" alt="" /></a></div>
|
|
||||||
<div class="rslidenav">
|
|
||||||
<a href="" class="navP" title="上一張" onclick="return false;">Prev</a>
|
|
||||||
<a href="" class="navN" title="下一張" onclick="return false;">Next</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="slidelist">
|
|
||||||
<ul id='galleryimagelist' style="display:none;">
|
|
||||||
<% i=0 %>
|
|
||||||
<% @images.each do |image| %>
|
|
||||||
<li for="<%= i %>"><a href="orbit_gallery?theater=<%= image.id %>" class="list_element" data-content="<%= image.file.url %>" onclick="return false;"><img src="<%= image.file.thumb.url %>" alt="" /></a></li>
|
|
||||||
<% i=i+1 %>
|
|
||||||
<% end %>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="slidectrl">
|
|
||||||
<a href="" class="togglescreen" title="切換全螢幕" onclick="return false;">Screen</a>
|
|
||||||
<a href="" class="togglelist" title="顯示照片清單" onclick="return false;">List</a>
|
|
||||||
<a href="" class="browserfullscreen" title="顯示照片清單" onclick="return false;">F</a>
|
|
||||||
<div class="slideinfo">
|
|
||||||
<!-- <b class="info"><%= @image.title %></b> -->
|
|
||||||
<span class="info"><%= @image.description %></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
3
vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/albums/create.js.erb
vendored
Normal file
3
vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/albums/create.js.erb
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
var gal = new galleryAPI();
|
||||||
|
gal.loadAlbums("all");
|
||||||
|
rcom.modalWindowClose();
|
|
@ -15,19 +15,20 @@
|
||||||
<!-- <form id="edit_album" action="update_album" method="post"> -->
|
<!-- <form id="edit_album" action="update_album" method="post"> -->
|
||||||
<%= form_for @album, :url => panel_gallery_back_end_album_path(@album), :html => {:class => 'clear'} do |f| %>
|
<%= form_for @album, :url => panel_gallery_back_end_album_path(@album), :html => {:class => 'clear'} do |f| %>
|
||||||
<div class="tab_content">
|
<div class="tab_content">
|
||||||
<% @site_valid_locales.each_with_index do |locale, i| %>
|
|
||||||
<% if i == 0 %>
|
|
||||||
<div class="<%= locale %> fade tab-pane in active">
|
|
||||||
<% else %>
|
|
||||||
<div class="<%= locale %> fade tab-pane" >
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<div class="albumname_edit">
|
<div class="albumname_edit">
|
||||||
<%= f.fields_for :name_translations do |name| %>
|
<%= f.fields_for :name_translations do |name| %>
|
||||||
<%= f.label t("gallery.album_name") %>
|
<%= f.label t("gallery.album_name") %>
|
||||||
<div class="inputui rginput rgih26 w380">
|
<div class="inputui rginput rgih26 w380">
|
||||||
|
<% @site_valid_locales.each_with_index do |locale, i| %>
|
||||||
|
<% if i == 0 %>
|
||||||
|
<div class="<%= locale %> fade tab-pane in active">
|
||||||
|
<% else %>
|
||||||
|
<div class="<%= locale %> fade tab-pane" >
|
||||||
|
<% end %>
|
||||||
<%= name.text_field locale, :value => (@album_name[locale]), :class => "txtchange" %>
|
<%= name.text_field locale, :value => (@album_name[locale]), :class => "txtchange" %>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -38,10 +39,19 @@
|
||||||
<img src="<%= image.file.thumb.url %>" />
|
<img src="<%= image.file.thumb.url %>" />
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="inputui rginput rgih98 w380">
|
<div class="inputui rginput rgih98 w380">
|
||||||
<%= f.fields_for :gallery_images do |j| %>
|
<%= f.fields_for :gallery_images, image do |j| %>
|
||||||
<%= j.hidden_field :id, :value => (image.id) %>
|
<%= j.hidden_field :id, :value => (image.id) %>
|
||||||
|
<%= j.hidden_field :_destroy, :value => false, :class => "del_field" %>
|
||||||
<%= j.fields_for :description_translations do |desc| %>
|
<%= j.fields_for :description_translations do |desc| %>
|
||||||
|
<% @site_valid_locales.each_with_index do |locale, i| %>
|
||||||
|
<% if i == 0 %>
|
||||||
|
<div class="<%= locale %> fade tab-pane in active">
|
||||||
|
<% else %>
|
||||||
|
<div class="<%= locale %> fade tab-pane" >
|
||||||
|
<% end %>
|
||||||
<%= desc.text_area locale, :value => (image.description_translations[locale] rescue nil), :class => "txtchange" %>
|
<%= desc.text_area locale, :value => (image.description_translations[locale] rescue nil), :class => "txtchange" %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
@ -57,12 +67,11 @@
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<% end %>
|
<input type="hidden" name="delete_cover" value="false" class="del_cover" />
|
||||||
<div class="form-actions form-fixed pagination-right rghead">
|
<div class="form-actions form-fixed pagination-right rghead">
|
||||||
<div class="rgfn">
|
<div class="rgfn">
|
||||||
<a href="<%= panel_gallery_back_end_album_path(@album) %>" class="bt-back btn pull-left" title="<%= I18n.t("gallery.back_to_photos") %>"><i class="icon-arrow-left icon-black"></i><%= I18n.t("gallery.back_to_photos") %></a>
|
<a href="<%= panel_gallery_back_end_album_path(@album) %>" class="bt-back btn pull-left" title="<%= I18n.t("gallery.back_to_photos") %>"><i class="icon-arrow-left icon-black"></i><%= I18n.t("gallery.back_to_photos") %></a>
|
||||||
<a class="bt-del bt-delete btn btn-primary pull-right" onclick="return false;" style="display:none;" title="<%= I18n.t("gallery.delete_selected") %>" href="<%= panel_gallery_back_end_album_images_path %>"><i class="icon-trash icon-white"></i><%= I18n.t("gallery.delete_selected") %></a>
|
|
||||||
<%= f.submit t('gallery.save'), :class=>'bt-save icon-ok btn btn-primary pull-right', :style=>"display:none;" %>
|
<%= f.submit t('gallery.save'), :class=>'bt-save icon-ok btn btn-primary pull-right', :style=>"display:none;" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,33 +2,50 @@
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h3><%= t("gallery.add_album") %></h3>
|
<h3><%= t("gallery.add_album") %></h3>
|
||||||
</div>
|
</div>
|
||||||
|
<%= form_for @album, :url => {:action => "create"}, :remote => true do |f| %>
|
||||||
<div class="modal-body add-album">
|
<div class="modal-body add-album">
|
||||||
<select id="category_list">
|
<%= f.select(:gallery_category_id, GalleryCategory.all.collect {|p| [ p.name, p.id ] },{:prompt => t("gallery.select_category")}) %>
|
||||||
<option value=""><%= t("gallery.select_category") %></option>
|
|
||||||
<% @categorylist.each do |category| %>
|
|
||||||
<option value='<%= category.id %>' ><%= category.name %></option>
|
|
||||||
<% end %>
|
|
||||||
</select>
|
|
||||||
<ul class="nav nav-tabs">
|
<ul class="nav nav-tabs">
|
||||||
<% @site_valid_locales.each_with_index do |locale, i| %>
|
<% @site_valid_locales.each_with_index do |locale, i| %>
|
||||||
<li <%= ( i == 0 ) ? " class='active'" : '' %>><a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li>
|
<li <%= ( i == 0 ) ? " class='active'" : '' %>><a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="tab_content form-horizontal">
|
<div class="tab_content form-horizontal">
|
||||||
<% @site_valid_locales.each_with_index do |locale, i| %>
|
<%= f.fields_for :name_translations do |name| %>
|
||||||
<% if i == 0 %>
|
<% @site_valid_locales.each_with_index do |locale, i| %>
|
||||||
<div class="<%= locale %> fade tab-pane in active">
|
<% if i == 0 %>
|
||||||
<% else %>
|
<div class="<%= locale %> fade tab-pane in active">
|
||||||
<div class="<%= locale %> fade tab-pane" >
|
<% else %>
|
||||||
<% end %>
|
<div class="<%= locale %> fade tab-pane" >
|
||||||
<p class="control-group"><label class="control-label"><%= t("gallery.album_name") %></label><input type="text" id="name_<%= locale %>" /></p>
|
<% end %>
|
||||||
<p class="control-group"><label class="control-label"><%= t("gallery.album_desc") %></label><input type="text" id="desc_<%= locale %>" /></p>
|
<p class="control-group">
|
||||||
</div>
|
<%= label_tag(locale, t("gallery.album_name")) %>
|
||||||
<% end %>
|
<%= name.text_field locale %>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<%= f.fields_for :description_translations do |desc| %>
|
||||||
|
<% @site_valid_locales.each_with_index do |locale, i| %>
|
||||||
|
<% if i == 0 %>
|
||||||
|
<div class="<%= locale %> fade tab-pane in active">
|
||||||
|
<% else %>
|
||||||
|
<div class="<%= locale %> fade tab-pane" >
|
||||||
|
<% end %>
|
||||||
|
<p class="control-group">
|
||||||
|
<%= label_tag(locale, t("gallery.album_desc")) %>
|
||||||
|
<%= desc.text_field locale %>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<a href="#" class="btn" data-dismiss="modal" id="album_name_close_btn" onclick="return false;"><%= t("gallery.close") %></a>
|
<a href="#" class="btn" data-dismiss="modal" id="album_name_close_btn" onclick="return false;"><%= t("gallery.close") %></a>
|
||||||
<a href="#" class="btn btn-primary" id="album_name_save_btn" onclick="return false;"><%= t("gallery.save_changes") %></a>
|
<!-- <a href="#" class="btn btn-primary" id="album_name_save_btn" onclick="return false;"><%#= t("gallery.save_changes") %></a> -->
|
||||||
|
<%= f.submit t("gallery.save"), :class=> "btn btn-primary" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
<div class="tag clear">
|
||||||
|
<div class="tagitem">
|
||||||
|
<i class="icon-folder-close"></i>
|
||||||
|
<% @site_valid_locales.each do |locale| %>
|
||||||
|
<span class="value" for="<%= locale %>"><%= category.name_translations[locale] rescue nil %> </span>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<div class="action">
|
||||||
|
<%= link_to(t("gallery.delete"), panel_gallery_back_end_gallery_category_path(category), :method => :delete, :confirm => t("gallery.sure?"), :remote => true, :class => "delete") %>
|
||||||
|
<%= link_to(t("gallery.edit"), edit_panel_gallery_back_end_gallery_category_path(category), :remote => true, :class => "edit") %>
|
||||||
|
<%= show_gallery_category_permission_link(category) %>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -0,0 +1,2 @@
|
||||||
|
var dom = $("<%= j render :partial => 'category', :object => @category %>");
|
||||||
|
$("div#tags").append(dom);
|
|
@ -0,0 +1,10 @@
|
||||||
|
<%= form_for @category, :url => panel_gallery_back_end_gallery_category_path(@category), :remote => true do |f| %>
|
||||||
|
<%= f.fields_for :name_translations do |name| %>
|
||||||
|
<% @site_valid_locales.each do |locale| %>
|
||||||
|
<%= label_tag(locale,t("gallery.new_category")+"["+I18nVariable.from_locale(locale)+"]") %>
|
||||||
|
<%= name.text_field locale, :value =>(@category.name_translations[locale]) %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<%= f.submit t("gallery.save"), :class=> "btn btn-primary temp_save_btn" %>
|
||||||
|
<a href="#" class="btn btn-primary" id="temp_cancel_btn" onclick="return false;"><%= I18n.t("gallery.cancel") %></a>
|
||||||
|
<% end %>
|
|
@ -1,89 +1,52 @@
|
||||||
<div id="tags" class="clear">
|
<div id="tags" class="clear">
|
||||||
<% @categorylist.each do |category| %>
|
<%= render :partial => 'category', :collection => @categorylist %>
|
||||||
<div class="tag clear">
|
|
||||||
<div class="tagitem">
|
|
||||||
<i class="icon-folder-close"></i>
|
|
||||||
<% @site_valid_locales.each do |locale| %>
|
|
||||||
<span class="value" for="<%= locale %>"><%= category.name_translations[locale] %> </span>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
<div class="action">
|
|
||||||
<a href="<%= category.id %>" class='delete' onclick='return false;'><%= t("gallery.delete") %></a>
|
|
||||||
<a href="<%= category.id %>" class='edit' onclick='return false;'><%= t("gallery.edit") %></a>
|
|
||||||
<%= show_gallery_category_permission_link(category) %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-actions form-fixed pagination-right">
|
<div class="form-actions form-fixed pagination-right">
|
||||||
<div style="margin:0;padding:0;display:inline">
|
<div style="margin:0;padding:0;display:inline">
|
||||||
<%= t("gallery.new_category")+"["+ t("gallery.english")+"]" %> : <input type="text" id="category_name_en" />
|
<%= form_for @new_category, :url => {:action => "create"}, :remote => true do |f| %>
|
||||||
<%= t("gallery.new_category") +"["+ t("gallery.chinese")+"]" %> : <input type="text" id="category_name_zh_tw" />
|
<%= f.fields_for :name_translations do |name| %>
|
||||||
<a href="#" class="btn btn-primary" id="category_save_btn" onclick="return false;"><%= t("gallery.save") %></a>
|
<% @site_valid_locales.each do |locale| %>
|
||||||
|
<%= label_tag(locale,t("gallery.new_category")+"["+I18nVariable.from_locale(locale)+"]") %>
|
||||||
|
<%= name.text_field locale %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<%= f.submit t("gallery.save"), :class=> "btn btn-primary" %>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var deleteCategory = function(a){
|
var deleteCategory = function(a){
|
||||||
var cid = a.attr("href");
|
|
||||||
var parent = a.parent().parent();
|
var parent = a.parent().parent();
|
||||||
$.post("gallery_category_delete",{id:cid},function(response){
|
parent.hide("slide",function(){parent.remove();})
|
||||||
if(response.success)
|
|
||||||
parent.hide("slide",function(){parent.remove();})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
var parent;
|
||||||
var editCategory = function(a){
|
var editCategory = function(a,data){
|
||||||
var cid = a.attr("href");
|
parent = a.parent().parent();
|
||||||
var parent = a.parent().parent();
|
var parenthtml = parent.html();
|
||||||
var parenthtml = parent.html();
|
var tempdom = $("<div class='tagitem'></div>");
|
||||||
var tempdom = $("<div class='tagitem'></div>");
|
tempdom.append(data);
|
||||||
parent.find("span.value").each(function(){
|
parent.html(tempdom);
|
||||||
var locale = $(this).attr("for");
|
tempdom.find("a#temp_cancel_btn").click(function(){
|
||||||
var lang = {
|
parent.html(parenthtml);
|
||||||
"en" : "English",
|
})
|
||||||
"zh_tw" : "Chinese"
|
|
||||||
}
|
|
||||||
tempdom.append("<label>"+lang[locale] + " :</label><input type='text' id='temp_name_"+locale+"' value='"+$(this).text()+"' />");
|
|
||||||
})
|
|
||||||
tempdom.append('<br /><a href="#" class="btn btn-primary" id="temp_save_btn" onclick="return false;"><%= I18n.t("gallery.save") %></a> <a href="#" class="btn btn-primary" id="temp_cancel_btn" onclick="return false;"><%= I18n.t("gallery.cancel") %></a>');
|
|
||||||
tempdom.find("a#temp_cancel_btn").click(function(){
|
|
||||||
parent.html(parenthtml);
|
|
||||||
parent.find("div.action a.delete").click(function(){
|
|
||||||
deleteCategory($(this));
|
|
||||||
})
|
|
||||||
parent.find(" div.action a.edit").click(function(){
|
|
||||||
editCategory($(this));
|
|
||||||
})
|
|
||||||
})
|
|
||||||
parent.html(tempdom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$("#tags div.action a.delete").click(function(){
|
$("#tags div.action a.delete").live('ajax:success', function(){
|
||||||
deleteCategory($(this));
|
deleteCategory($(this));
|
||||||
})
|
})
|
||||||
$("#tags div.action a.edit").click(function(){
|
$("#tags div.action a.edit").live('ajax:success',function(evt, data, status, xhr){
|
||||||
editCategory($(this));
|
editCategory($(this),data);
|
||||||
})
|
})
|
||||||
$("#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 $dom = $('<div class="tag clear hide"><div class="tagitem"><i class="icons-star"></i>'+lang.en+' '+lang.zh_tw+'</div> <div class="action"><a href="'+response.id+'" class="delete" onclick="return false;"><%= I18n.t("gallery.delete") %></a></div></div>');
|
|
||||||
$("div#tags").append($dom);
|
|
||||||
$dom.show('slide');
|
|
||||||
$dom.find("a.delete").click(function(){
|
|
||||||
deleteCategory($(this));
|
|
||||||
})
|
|
||||||
$("input[type=text]").val("");
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
var dom = $("<%= j render :partial => 'category', :object => @category %>");
|
||||||
|
parent.html(dom.html());
|
|
@ -30,3 +30,4 @@ en:
|
||||||
search_tags: Search Tags
|
search_tags: Search Tags
|
||||||
cover: Album Cover
|
cover: Album Cover
|
||||||
set_cover: Set as Album Cover
|
set_cover: Set as Album Cover
|
||||||
|
sure?: "Are you sure?"
|
||||||
|
|
|
@ -14,7 +14,11 @@ Rails.application.routes.draw do
|
||||||
match "images_tags" => "albums#images_tags"
|
match "images_tags" => "albums#images_tags"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
match "album_images/#!/:id" => "album_images#show"
|
||||||
|
|
||||||
resources :album_images
|
resources :album_images
|
||||||
|
|
||||||
|
|
||||||
resources :gallery_categories
|
resources :gallery_categories
|
||||||
resources :tags
|
resources :tags
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue