View only update

This commit is contained in:
Harry Bomrah 2012-08-23 21:30:37 +08:00 committed by Christophe Vilayphiou
parent f62eba182e
commit 26ff2af078
3 changed files with 39 additions and 19 deletions

View File

@ -1,7 +1,3 @@
<%# encoding: utf-8 %>
// refresh the imagesArray
// viewonly tags
$.extend($.expr[':'], {
'containsi': function (elem, i, match, array) {
return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
@ -301,10 +297,24 @@ var galleryAPI = function(){
});
var updatePhotoTag = function(){
var tags = imageArray[imagecount].tag_ids;
if(tags.length > 0 && g.tagList.find("li").length == 0){
var tagnames = imageArray[imagecount].tag_names;
g.tagList.empty();
for(i in tagnames){
$li = $("<li><label>"+tagnames[i]+"</label><span style='display:none;'>"+tagnames[i]+"</span></li>");
g.tagList.append($li);
}
}else if(tags.length > 0 && g.tagList.find("li").length > 0) {
g.tagList.find("input").attr("checked",false);
for(tag in tags){
g.tagList.find("li[data-content="+tags[tag]+"] input").attr("checked",true);
}
}else if(tags.length == 0){
if(g.tagList.find("input").length == 0)
g.tagList.empty();
else
g.tagList.find("input").attr("checked",false);
}
}
g.albumArea.find("#tag_search_box").keyup(function(e){
sval = $(this).val();
@ -325,7 +335,12 @@ var galleryAPI = function(){
}
})
g.albumArea.find("#tag_panel .bt-save").click(function(){
g.saveTags(imageArray[imagecount]._id,g.loadArea);
g.saveTags(imageArray[imagecount]._id,g.loadArea)
var tagids = new Array();
g.tagList.find("li input:checked").each(function(){
tagids.push($(this).parent().attr("data-content"));
})
imageArray[imagecount].tag_ids = tagids;
})
$(".slidectrl a.togglelist").click(function(){
var rslide_h = $rslide.outerHeight();
@ -380,8 +395,14 @@ var galleryAPI = function(){
var el = document.documentElement,
rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen;
rfs.call(el);
$rslide.addClass('browserFullScreen');
}
$(window).resize(function(){
if(window.innerWidth == screen.width && window.innerHeight == screen.height) {
$rslide.addClass('browserFullScreen');
} else {
$rslide.removeClass('browserFullScreen');
}
})
var nextpic = function(dom){
if(imagecount == imageArray.length - 1)
imagecount = 0;
@ -521,11 +542,8 @@ var galleryAPI = function(){
// })
})
var tag_panel_hidden = true;
var last_clicked = null;
$('.bt-tag').click(function(){
$(this).toggleClass("active");
var $tag_panel = $('#tag_panel'),
tag_panel_position = 0;
if( $tag_panel.css('right') == '0px' ){
@ -556,7 +574,6 @@ var galleryAPI = function(){
}else{
$("#gallery_tag_list li span:not(:containsi("+sval+"))").parent().slideUp();
}
}else{
$("#gallery_tag_list li").slideDown();
}

View File

@ -460,8 +460,8 @@ var galleryAPI = function(){
g.loadFooterPanel(g.loadArea,id,function(head){
head = $(head);
g.albumArea.find(".rghead .rgfn").html(head);
g.albumArea.find(".bt-back").attr("href","orbit_gallery?album="+albumid);
g.albumArea.find(".bt-edit").attr("href","orbit_gallery?edit="+albumid);
g.albumArea.find(".bt-back").attr("href","gallery?album="+albumid);
})
g.albumArea.css("margin-bottom","0");
picHeight = $(window).height() - ($("#orbit-bar").outerHeight() + $("#orbit_gallery .form-actions").outerHeight());

View File

@ -1,9 +1,9 @@
class Panel::Gallery::BackEnd::OrbitGalleriesController < OrbitBackendController
include AdminHelper
@authenticated = false
def index
if is_manager? || is_admin? || is_sub_manager?
@authenticated = false #turn this value to false for view only
@authenticated = true #turn this value to false for view only
else
@authenticated = false
end
@ -135,10 +135,13 @@ include AdminHelper
values.tag_ids.each do |tag|
tags << GalleryTag.find(tag)[I18n.locale]
end
@output << {"_id"=>values.id,"description"=>values.description,"title"=>values.title,"file"=>values.file,"gallery_album_id"=>values.gallery_album_id,"tag_ids"=>values.tag_ids,"tag_names"=>tags}
end
if is_manager? || is_admin? || is_sub_manager?
@authenticated = true #turn this value to false for view only
else
@authenticated = false
end
if @authenticated
render :json=>{"images" => @output, "tags" => @album.tag_ids}.to_json
else