gallery translation supported

This commit is contained in:
Harry Bomrah 2012-07-31 21:15:42 +08:00
parent 19b60a2ddb
commit 7accbed1a0
13 changed files with 124 additions and 55 deletions

View File

@ -436,20 +436,18 @@ modalWindow : function(settings,callbackFn){
closebtn='<a href="" style="display:block; width:20px; height:20px; line-height:19px; text-align:center; position:absolute; right:-10px; top: -10px; font-family:Tahoma; font-weight:bold; border:solid 1px #000; border-radius: 10px;text-shadow:0px 1px 0 #DDD; background-color:#CCC; font-size:10px; text-decoration:none; color:#666; padding-left:1px; box-shadow: 0 0 5px #000000;" id="close_modal">X</a>';
$rss("#rgWindow").animate({"width":tempwidth+"px","height":tempheight+"px",top:rgWTop+"px", left:rgWLeft+"px"},500,function(){$rss("#rgWindow").html(closebtn+"<div id='rgContent' style='padding:5px; overflow:auto; overflow-x:none; height:"+tempheight+"px;'>"+dhtml+"</div>");
$rss("#close_modal").mouseover(function(){$rss(this).css("color","#999");}).mouseout(function(){$rss(this).css("color","#666");})
$rss("#close_modal").click(function(){
$rss("#rgWindow").empty();
var x = (rgmaskHeight-20)/2;
var y = (rgmaskWidth-20)/2;
$rss("#rgWindow").animate({top:x+"px", left:y+"px","width":"50px","height":"50px"},300,function(){$rss(this).fadeOut(100).remove();$rss("#rgsheath").fadeOut(500).remove();});
return false;
})
$rss("#close_modal").click(function(){rcom.modalWindowClose(); return false;})
if(envClose)
$rss("#rgsheath").click(function(){
$rss("#rgWindow").empty();
var x = (rgmaskHeight-20)/2;
var y = (rgmaskWidth-20)/2;
$rss("#rgWindow").animate({top:x+"px", left:y+"px","width":"50px","height":"50px"},300,function(){$rss(this).fadeOut(100).remove();$rss("#rgsheath").fadeOut(500).remove();});})
rcom.modalWindowClose();
})
$rss(document).one("keydown",function(e){
if (e.keyCode == 27){
rcom.modalWindowClose();
return false;
}
})
if(typeof callbackFn=="function")
callbackFn.call(this,$rss("#rgWindow"));
});

View File

@ -82,8 +82,14 @@ var galleryAPI = function(){
dom.find("#album_name_save_btn").click(function(){
var options ={
cid : dom.find("select#category_list").val(),
albumname : dom.find("#name_en").val(),
albumdesc : dom.find("#desc_en").val()
albumname : {
"en" : dom.find("#name_en").val(),
"zh_tw" : dom.find("#name_zh_tw").val()
},
albumdesc : {
"en" : dom.find("#desc_en").val(),
"zh_tw" : dom.find("#desc_zh_tw").val()
}
}
if(options.cid){
$.post("create_album",options,function(response){
@ -101,7 +107,7 @@ var galleryAPI = function(){
})
}
this.deleteAlbum = function(id){
if(confirm("Delete this Album?")){
if(confirm("<%= I18n.t('gallery.del_album?') %>")){
$.post("delete_album",{aid:id},function(){
window.location = "orbit_gallery";
})
@ -109,7 +115,7 @@ var galleryAPI = function(){
}
this.loadAlbums = function(id){
var headbtn = $('<a class="rgui bt-add rgbt" title="Add Album" href="albums" onclick="return false;"><span>Add Album</span></a>');
var headbtn = $('<a class="rgui bt-add rgbt" title="<%= I18n.t("gallery.add_album") %>" href="albums" onclick="return false;"><span><%= I18n.t("gallery.add_album") %></span></a>');
headbtn.click(function(){g.makeNewAlbum();})
g.albumArea.find(".rghead .rgfn").html(headbtn);
g.albumArea.find("#imgholder").empty();
@ -129,10 +135,10 @@ var galleryAPI = function(){
this.loadImages = function(id){
//<iframe id="upload_panel" width="100%" scrolling="no" height="300" frameborder="0" src="upload_panel.html?id=16">
var headarea = '<a class="rgui bt-back rgbt" title="Back to Albums" href="orbit_gallery"><span>Back to Album</span></a> ';
headarea+='<a class="rgui bt-add rgbt" title="Add Images" href="images" onclick="return false;"><span>Add Images</span></a> ';
headarea+='<a class="rgui bt-del rgbt" title="Delete Album" href="delete" onclick="return false;"><span>Delete this album</span></a> ';
headarea+='<a class="rgui bt-edit rgbt" title="Edit Album" href="orbit_gallery?edit='+id+'" ><span>Edit</span></a>';
var headarea = '<a class="rgui bt-back rgbt" title="<%= I18n.t("gallery.back_to_albums") %>" href="orbit_gallery"><span><%= I18n.t("gallery.back_to_albums") %></span></a> ';
headarea+='<a class="rgui bt-add rgbt" title="<%= I18n.t("gallery.add_images") %>" href="images" onclick="return false;"><span><%= I18n.t("gallery.add_images") %></span></a> ';
headarea+='<a class="rgui bt-del rgbt" title="<%= I18n.t("gallery.del_album") %>" href="delete" onclick="return false;"><span><%= I18n.t("gallery.del_album") %></span></a> ';
headarea+='<a class="rgui bt-edit rgbt" title="<%= I18n.t("gallery.edit") %>" href="orbit_gallery?edit='+id+'" ><span><%= I18n.t("gallery.edit") %></span></a>';
headarea = $(headarea);
var uploadpanel = $('<div id="upload_panel_holder" style="display:none; margin: 16px 0 50px 0;"><div class="rgfn"><a class="rgui bt-cls rgbt" title="Close" href="" onclick="return false;"><span id="album_name_span">Close Panel</span></a></div></div>');
var frame = $('<iframe id="upload_panel" width="100%" scrolling="no" height="300" frameborder="0" src="upload_panel"></iframe>');
@ -260,7 +266,7 @@ var galleryAPI = function(){
$rslide.removeClass("fullscreen");
$(".slidectrl a.browserfullscreen").hide();
$img.css({"padding":""})
$("#main_pic").height(picHeight);
$("#main_pic").height(picHeight );
}else{
$("#main_pic").height(wHeight);
// $img.height("100%");
@ -285,7 +291,8 @@ var galleryAPI = function(){
}
// $(".slideinfo b.info").text(imageArray[imagecount].title);
$(".slideinfo span.info").text(imageArray[imagecount].description);
updateNavigation();
if(imageArray.length > 1)
updateNavigation();
})
}
var updateNavigation = function(){
@ -303,7 +310,8 @@ var galleryAPI = function(){
$("a.navN").attr({"href":"orbit_gallery?theater="+imageArray[next]._id,"data-content":imageArray[next].file.url});
$("a.navP").attr({"href":"orbit_gallery?theater="+imageArray[prev]._id,"data-content":imageArray[prev].file.url});
};
updateNavigation();
if(imageArray.length > 1)
updateNavigation();
}
var preparestage = function(albumid){
@ -317,11 +325,11 @@ var galleryAPI = function(){
})
}
var head = $('<a href="" class="rgui bt-back rgbt" title="Back"><span id="album_name_span">Back to photos</span></a></div>');
var head1 = $('<a class="rgui bt-edit rgbt" title="Edit Album" href="" ><span>Edit</span></a>');
var head = $('<a href="" 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 head1 = $('<a class="rgui bt-edit rgbt" title="<%= I18n.t("gallery.edit") %>" href="" ><span><%= I18n.t("gallery.edit") %></span></a>');
g.albumArea.find("#imgholder").load("theater?pic="+id,function(theater,response,xhr){
if(xhr.status == 404){
$(this).text("Pic not found.");
$(this).text("<%= I18n.t('gallery.pic_not_found') %>.");
return false;
}
var albumid = $(theater).find("#main_pic").attr("data-content");
@ -391,14 +399,14 @@ var galleryAPI = function(){
}
})
}
var head = '<a href="orbit_gallery?album='+id+'" class="rgui bt-back rgbt" title="Back"><span id="album_name_span">Back to photos</span></a></div>';
head+='<a class="rgui bt-del bt-delete rgbt" onclick="return false;" style="display:none;" title="Delete Selected" href=""><span>Delete Selected</span></a>';
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-save rgbt" onclick="return false;" style="display:none;" title="Save" href=""><span>Save</span>';
g.albumArea.find(".rghead .rgfn").html(head);
rcom.bindDomToHead($(".rghead"));
g.albumArea.find("#imgholder").load("edit_album?aid="+id,function(data,response,xhr){
if(xhr.status == 404){
$(this).text("Album not found.");
$(this).text("<%= I18n.t('gallery.album_not_found') %>");
return false;
}
bindHandlers();

View File

@ -7,8 +7,13 @@ class Panel::Gallery::BackEnd::OrbitGalleriesController < OrbitBackendController
def new_category
names = params['category']
cid = GalleryCategory.create(name: names['en'])
render :json=>{"success"=>true,"id"=>cid.id}.to_json
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 categorylist
@ -29,8 +34,18 @@ class Panel::Gallery::BackEnd::OrbitGalleriesController < OrbitBackendController
def create_album
category = GalleryCategory.find(params['cid'])
x = category.gallery_albums.create({name: params['albumname'],description: params['albumdesc']})
render :json=>{"success"=>true,"id"=>x.id}.to_json
albumnames = params["albumname"]
albumdescs = params["albumdesc"]
album = category.gallery_albums.new
I18n.locale = :en
album.name = albumnames["en"]
album.description = albumdescs["en"]
I18n.locale = :zh_tw
album.name = albumnames["zh_tw"]
album.description = albumdescs["zh_tw"]
album.save!
#x = category.gallery_albums.create({name: params['albumname'],description: params['albumdesc']})
render :json=>{"success"=>true,"id"=>album.id}.to_json
end
def get_albums
@ -108,7 +123,6 @@ class Panel::Gallery::BackEnd::OrbitGalleriesController < OrbitBackendController
img.delete
end
if params['delete_cover'] == "true"
debugger
album = GalleryAlbum.find(params['aid'])
album.update_attributes(:cover=>"default")
end

View File

@ -2,12 +2,13 @@ class GalleryAlbum
include Mongoid::Document
include Mongoid::Timestamps
field :name
field :description
field :name, localize: true
field :description, localize: true
field :cover, default: "default"
field :cover_path
belongs_to :gallery_category
has_and_belongs_to_many :tags, :class_name => "GalleryTag"
has_many :gallery_images, :autosave => true, :dependent => :destroy
end

View File

@ -2,8 +2,7 @@ class GalleryCategory
include Mongoid::Document
include Mongoid::Timestamps
field :name
field :name, localize: true
has_many :gallery_albums, :autosave => true, :dependent => :destroy
#has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
has_many :gallery_albums, :autosave => true, :dependent => :destroy
end

View File

@ -7,6 +7,8 @@ class GalleryImage
field :title
field :description
has_and_belongs_to_many :tags, :class_name => "GalleryTag"
belongs_to :gallery_album
end

View File

@ -0,0 +1,6 @@
class GalleryTag < Tag
has_and_belongs_to_many :gallery_albums
has_and_belongs_to_many :gallery_images
end

View File

@ -1,21 +1,23 @@
<div class="modal-window" id="categories">
<div class="modal-header">
<h3>Album Name</h3>
<h3><%= t("gallery.album_name") %></h3>
</div>
<div class="modal-body">
<p>Category:
<select id="category_list">
<option value="">--Select a category--</option>
<option value=""><%= t("gallery.select_category") %></option>
<% @categorylist.each do |category| %>
<option value='<%= category.id %>' ><%= category.name %></option>
<% end %>
</select>
</p>
<p>Album Name: <input type="text" id="name_en" /></p>
<p>Album Description: <input type="text" id="desc_en" /></p>
<p><%= t("gallery.album_name") %>[<%=t("gallery.english")%>]: <input type="text" id="name_en" /></p>
<p><%= t("gallery.album_name") %>[<%=t("gallery.chinese")%>]: <input type="text" id="name_zh_tw" /></p>
<p><%= t("gallery.album_desc") %>[<%=t("gallery.english")%>]: <input type="text" id="desc_en" /></p>
<p><%= t("gallery.album_desc") %>[<%=t("gallery.chinese")%>]: <input type="text" id="desc_zh_tw" /></p>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal" id="album_name_close_btn" onclick="return false;">Close</a>
<a href="#" class="btn btn-primary" id="album_name_save_btn" onclick="return false;">Save Changes</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>
</div>
</div>

View File

@ -1,18 +1,18 @@
<div class="modal-window" id="categories">
<div class="modal-header">
<h3>Categories</h3>
<h3><%= t("gallery.categories") %></h3>
</div>
<div class="modal-body">
<ul id="category_list">
<% @categorylist.each do |category| %>
<li><%= category.name %> <a href="<%= category.id %>" class='btn delete' onclick='return false;'>Delete</a> </li>
<li><%= category.name %> <a href="<%= category.id %>" class='btn delete' onclick='return false;'><%= t("gallery.delete") %></a> </li>
<% end %>
</ul>
</div>
<div class="modal-footer">
New Category[English] : <input type="text" id="category_name_en"></text><br />
New Category[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;">Close</a>
<a href="#" class="btn btn-primary" id="category_save_btn" onclick="return false;">Save Changes</a>
<%= 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 />
<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>
</div>
</div>

View File

@ -5,7 +5,7 @@
<div id='description_loader'>
<% @images.each do |image| %>
<div class="rgphoto_edit">
<a href="orbit_gallery?theater=<%= image.id %>"><img src="<%= image.file.url %>"></a>
<a href="orbit_gallery?theater=<%= image.id %>"><img src="<%= image.file.thumb.url %>"></a>
<div class="inputui rginput rgih98 w380">
<span>
<textarea name="description_box" class="txtchange" for="<%= image.id%>"><%= image.description %></textarea>

View File

@ -5,10 +5,10 @@
<%= stylesheet_link_tag "gallery" %>
<div id="gallery_panel">
<a class="btn" href="categories" onclick="return false;" >Manage Categories</a>
<a class="btn" href="categories" onclick="return false;" ><%= t('gallery.manage_categories') %></a>
<select id="category_filter">
<option value="">--Select a category--</option>
<option value="all">All</option>
<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>

View File

@ -0,0 +1,25 @@
en:
gallery:
album_name: Album Name
all: All
select_category: "--Select a category--"
manage_categories: Manage Categories
categories: Categories
new_category: New Category
save_changes: Save Changes
close: Close
delete: Delete
english: English
chinese: Chinese
album_desc: Album Desc
add_album: Add Album
back_to_photos: Back to Photos
back_to_albums: Back to Albums
add_images: Add Images
del_album: Delete Album
edit: Edit
delete_selected: Delete Selected
del_album?: "Delete this album?"
album_not_found: "Album not found"
pic_not_found: "Picture not found"

View File

@ -0,0 +1,14 @@
zh_tw:
gallery:
album_name: Album Name
all: All
select_category: "--Select a category--"
manage_categories: Manage Categories
categories: Categories
new_category: New Category
save_changes: Save Changes
close: Close
delete: Delete
english: English
chinese: Chinese
add_album: Add Album