From 587595f815368d80e52a585da70978d6095f22fe Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Tue, 31 Jul 2012 21:15:42 +0800 Subject: [PATCH] gallery translation supported --- app/assets/javascripts/rss.js | 22 +++++----- .../{galleryAPI.js => galleryAPI.js.erb} | 42 +++++++++++-------- .../back_end/orbit_galleries_controller.rb | 24 ++++++++--- .../gallery/app/models/gallery_album.rb | 5 ++- .../gallery/app/models/gallery_category.rb | 5 +-- .../gallery/app/models/gallery_image.rb | 2 + .../gallery/app/models/gallery_tag.rb | 6 +++ .../orbit_galleries/add_album.html.erb | 14 ++++--- .../orbit_galleries/categorylist.html.erb | 12 +++--- .../orbit_galleries/edit_album.html.erb | 2 +- .../back_end/orbit_galleries/index.html.erb | 6 +-- .../gallery/config/locales/en.yml | 25 +++++++++++ .../gallery/config/locales/zh_tw.yml | 14 +++++++ 13 files changed, 124 insertions(+), 55 deletions(-) rename vendor/built_in_modules/gallery/app/assets/javascripts/{galleryAPI.js => galleryAPI.js.erb} (86%) create mode 100644 vendor/built_in_modules/gallery/app/models/gallery_tag.rb create mode 100644 vendor/built_in_modules/gallery/config/locales/en.yml create mode 100644 vendor/built_in_modules/gallery/config/locales/zh_tw.yml diff --git a/app/assets/javascripts/rss.js b/app/assets/javascripts/rss.js index 7b132c0d..a82d86fa 100644 --- a/app/assets/javascripts/rss.js +++ b/app/assets/javascripts/rss.js @@ -436,20 +436,18 @@ modalWindow : function(settings,callbackFn){ closebtn='X'; $rss("#rgWindow").animate({"width":tempwidth+"px","height":tempheight+"px",top:rgWTop+"px", left:rgWLeft+"px"},500,function(){$rss("#rgWindow").html(closebtn+"
"+dhtml+"
"); $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")); }); diff --git a/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI.js b/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI.js.erb similarity index 86% rename from vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI.js rename to vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI.js.erb index c052ca17..1beb9e0b 100644 --- a/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI.js +++ b/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI.js.erb @@ -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 = $('Add Album'); + var headbtn = $('" href="albums" onclick="return false;"><%= I18n.t("gallery.add_album") %>'); 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){ //'); @@ -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 = $('Back to photos'); - var head1 = $('Edit'); + var head = $('"><%= I18n.t("gallery.back_to_photos") %>'); + var head1 = $('" href="" ><%= I18n.t("gallery.edit") %>'); 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 = 'Back to photos'; - head+=''; + var head ='"><%= I18n.t("gallery.back_to_photos") %>'; + head+=''; head+=' \ No newline at end of file diff --git a/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/orbit_galleries/categorylist.html.erb b/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/orbit_galleries/categorylist.html.erb index 7c4f5b10..476f5e89 100644 --- a/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/orbit_galleries/categorylist.html.erb +++ b/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/orbit_galleries/categorylist.html.erb @@ -1,18 +1,18 @@ \ No newline at end of file diff --git a/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/orbit_galleries/edit_album.html.erb b/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/orbit_galleries/edit_album.html.erb index 933b0827..fa4c9a1e 100644 --- a/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/orbit_galleries/edit_album.html.erb +++ b/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/orbit_galleries/edit_album.html.erb @@ -5,7 +5,7 @@
<% @images.each do |image| %>
- +
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 2030c313..6ac592bd 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 @@ -5,10 +5,10 @@ <%= stylesheet_link_tag "gallery" %>