code merged … ui updated

This commit is contained in:
Harry Bomrah 2012-08-21 20:15:17 +08:00
parent 94ee16ae01
commit 0799fb4f87
3 changed files with 63 additions and 40 deletions

View File

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

View File

@ -191,8 +191,24 @@ include AdminHelper
# end
# album = GalleryAlbum.find(aid)
# album.update_attributes(:name => album_name)
data = params['data']
album_names = params[:albumnm]
data = params[:data]
aid =params[:aid]
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
end

View File

@ -9,42 +9,44 @@
<li <%= ( i == 0 ) ? " class='active'" : '' %>><a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li>
<% end %>
</ul>
<form id="edit_album">
<div class="tab_content">
<% i = 0 %>
<% @site_valid_locales.each do |locale| %>
<% if i == 0 %>
<div class="<%= locale %> fade tab-pane in active">
<% else %>
<div class="<%= locale %> fade tab-pane" >
<% end %>
<% i = 1 %>
<div class="albumname_edit">
<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>
<div class='description_loader'>
<% @images.each do |image| %>
<div class="rgphoto_edit">
<a href="orbit_gallery?theater=<%= image.id %>"><img src="<%= image.file.thumb.url %>"></a>
<div class="inputui rginput rgih98 w380">
<textarea name="edit[description][<%= locale %>]" class="txtchange" for="<%= image.id%>"><%= image.description_translations[locale] %></textarea>
</div>
<div class="edit_fn">
<% if image.id.to_s == @cover %>
<a class="btn btn-primary rgbtsg bt-cover setcover active" onclick="return false;" title="Cover" href="<%= image.id %>"><span class="icon-star icon-white"></span></a>
<% else %>
<a class="btn rgbtsg bt-cover" onclick="return false;" title="Set Cover" href="<%= image.id %>"><span class="icon-star-empty"></span></a>
<% end %>
<a class="btn rgbtsg bt-tag" onclick="return false;" title="Tags" href="<%= image.id %>"><span class="icon-tags"></span></a>
<a class="btn rgbtsg bt-dels" onclick="return false;" title="Delete" href="<%= image.id %>"><span class="icon-trash"></span></a>
</div>
</div>
<form id="edit_album" action="update_album" method="post">
<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">
<label for=""><%= t("gallery.album_name") %></label>
<div class="inputui rginput rgih26 w380"><input type="text" name="gallery_album[name_translations][<%= locale %>]" value="<%= @album_name[locale] %>" class="txtchange" /></div>
</div>
<div class='description_loader'>
<% @images.each_with_index do |image,x| %>
<div class="rgphoto_edit <%= locale %>">
<a href="orbit_gallery?theater=<%= image.id %>"><img src="<%= image.file.thumb.url %>"></a>
<div class="inputui rginput rgih98 w380">
<textarea name="gallery_album_gallery_images_attributes[<%= x %>][description_translations][<%= locale %>]" class="txtchange" for="<%= image.id %>"><%= image.description_translations[locale] %></textarea>
</div>
<div class="edit_fn">
<% if image.id.to_s == @cover %>
<a class="btn btn-primary rgbtsg bt-cover setcover active" onclick="return false;" title="Cover" href="<%= image.id %>"><span class="icon-star icon-white"></span></a>
<% else %>
<a class="btn rgbtsg bt-cover" onclick="return false;" title="Set Cover" href="<%= image.id %>"><span class="icon-star-empty"></span></a>
<% end %>
<a class="btn rgbtsg bt-tag" onclick="return false;" title="Tags" href="<%= image.id %>"><span class="icon-tags"></span></a>
<a class="btn rgbtsg bt-dels" onclick="return false;" title="Delete" href="<%= image.id %>"><span class="icon-trash"></span></a>
</div>
</div>
<% end %>
</div>
</div>
</div>
</form>
<% end %>
<input type="submit" value="Submit" />
</form>
<!-- <div class="tab-pane in active">
<div class="albumname_edit">
<label for="">Album Name:</label>
@ -71,4 +73,3 @@
<% end %>
</div>
</div> -->
</div>