code merged … ui updated

This commit is contained in:
Harry Bomrah 2012-08-21 20:15:17 +08:00 committed by Christophe Vilayphiou
parent 04877b9945
commit 91d45b64da
3 changed files with 63 additions and 40 deletions

View File

@ -35,6 +35,9 @@ var galleryAPI = function(){
g.loadArea = "albums"; g.loadArea = "albums";
passid = g.urlVars['tag']; passid = g.urlVars['tag'];
g.loadAlbums(g.urlVars['tag']); g.loadAlbums(g.urlVars['tag']);
}else if(g.urlVars["locale"]){
g.loadArea = "albums";
g.loadAlbums("all");
}else if(g.urlVars.length == 0) { }else if(g.urlVars.length == 0) {
g.loadArea = "albums"; g.loadArea = "albums";
g.loadAlbums("all"); g.loadAlbums("all");
@ -493,15 +496,18 @@ var galleryAPI = function(){
}) })
g.albumArea.find(".rghead .rgfn .bt-save").click(function(){ g.albumArea.find(".rghead .rgfn .bt-save").click(function(){
// var dataArray = Array(); // var dataArray = Array();
// $(".description_loader .txtchange").each(function(){ // $(".description_loader .en .txtchange").each(function(){
// dataArray.push({"id":$(this).attr("for"),"text": $(this).val()}); // var thisid = $(this).attr("for");
// dataArray.push({"id":thisid,"text":{"en":$(this).val(),"zh_tw":$(".description_loader .zh_tw .txtchange[for="+thisid+"]").val()}});
// }) // })
// var albumnm = Array(); // var albumnm = Array();
// $(".albumname_edit .txtchange").each(function(){ // $(".albumname_edit .txtchange").each(function(){
// albumnm.push($(this).val()) // albumnm.push($(this).val())
// }) // })
var dataArray = $("form#edit_album").serialize(); // var dataArray = $("form#edit_album").serialize();
$.post("update_album",{"aid":id,"data":dataArray},function(){ // $.post("update_album",{"data":dataArray},function(){
// })
}) })
}) })

View File

@ -191,8 +191,24 @@ include AdminHelper
# end # end
# album = GalleryAlbum.find(aid) # album = GalleryAlbum.find(aid)
# album.update_attributes(:name => album_name) # album.update_attributes(:name => album_name)
data = params['data'] album_names = params[:albumnm]
data = params[:data]
aid =params[:aid]
debugger debugger
data.each do |d|
image = GalleryImage.find(d[1][:id])
@site_valid_locales.each do |locale|
image.description_translations[locale] = d[1][:text][locale]
end
image.save!
end
album = GalleryAlbum.find(aid)
@site_valid_locales.each_with_index do |locale,i|
album.name_translations[locale] = album_names[i]
end
album.save!
render :json =>{"success"=>true}.to_json render :json =>{"success"=>true}.to_json
end end

View File

@ -9,26 +9,26 @@
<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>
<form id="edit_album"> <form id="edit_album" action="update_album" method="post">
<div class="tab_content"> <div class="tab_content">
<% i = 0 %> <% @site_valid_locales.each_with_index do |locale, i| %>
<% @site_valid_locales.each do |locale| %>
<% if i == 0 %> <% if i == 0 %>
<div class="<%= locale %> fade tab-pane in active"> <div class="<%= locale %> fade tab-pane in active">
<% else %> <% else %>
<div class="<%= locale %> fade tab-pane" > <div class="<%= locale %> fade tab-pane" >
<% end %> <% end %>
<% i = 1 %>
<div class="albumname_edit"> <div class="albumname_edit">
<label for=""><%= t("gallery.album_name") %></label> <label for=""><%= t("gallery.album_name") %></label>
<div class="inputui rginput rgih26 w380"><input type="text" name="edit_album[name][<%= locale %>]" value="<%= @album_name[locale] %>" class="txtchange" /></div> <div class="inputui rginput rgih26 w380"><input type="text" name="gallery_album[name_translations][<%= locale %>]" value="<%= @album_name[locale] %>" class="txtchange" /></div>
</div> </div>
<div class='description_loader'> <div class='description_loader'>
<% @images.each do |image| %> <% @images.each_with_index do |image,x| %>
<div class="rgphoto_edit"> <div class="rgphoto_edit <%= locale %>">
<a href="orbit_gallery?theater=<%= image.id %>"><img src="<%= image.file.thumb.url %>"></a> <a href="orbit_gallery?theater=<%= image.id %>"><img src="<%= image.file.thumb.url %>"></a>
<div class="inputui rginput rgih98 w380"> <div class="inputui rginput rgih98 w380">
<textarea name="edit[description][<%= locale %>]" class="txtchange" for="<%= image.id%>"><%= image.description_translations[locale] %></textarea> <textarea name="gallery_album_gallery_images_attributes[<%= x %>][description_translations][<%= locale %>]" class="txtchange" for="<%= image.id %>"><%= image.description_translations[locale] %></textarea>
</div> </div>
<div class="edit_fn"> <div class="edit_fn">
<% if image.id.to_s == @cover %> <% if image.id.to_s == @cover %>
@ -43,8 +43,10 @@
<% end %> <% end %>
</div> </div>
</div> </div>
</form>
<% end %> <% end %>
<input type="submit" value="Submit" />
</form>
<!-- <div class="tab-pane in active"> <!-- <div class="tab-pane in active">
<div class="albumname_edit"> <div class="albumname_edit">
<label for="">Album Name:</label> <label for="">Album Name:</label>
@ -71,4 +73,3 @@
<% end %> <% end %>
</div> </div>
</div> --> </div> -->
</div>