From 26ff2af078113fb54e4516d63c8748f07f9b22f4 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Thu, 23 Aug 2012 21:30:37 +0800 Subject: [PATCH] View only update --- .../app/assets/javascripts/galleryAPI.js.erb | 43 +++++++++++++------ .../javascripts/galleryAPI_frontend.js.erb | 4 +- .../back_end/orbit_galleries_controller.rb | 11 +++-- 3 files changed, 39 insertions(+), 19 deletions(-) diff --git a/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI.js.erb b/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI.js.erb index 18943b95..1c6e0950 100644 --- a/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI.js.erb +++ b/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI.js.erb @@ -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,9 +297,23 @@ var galleryAPI = function(){ }); var updatePhotoTag = function(){ var tags = imageArray[imagecount].tag_ids; - g.tagList.find("input").attr("checked",false); - for(tag in tags){ - g.tagList.find("li[data-content="+tags[tag]+"] input").attr("checked",true); + if(tags.length > 0 && g.tagList.find("li").length == 0){ + var tagnames = imageArray[imagecount].tag_names; + g.tagList.empty(); + for(i in tagnames){ + $li = $("
  • "+tagnames[i]+"
  • "); + 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){ @@ -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(); } diff --git a/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI_frontend.js.erb b/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI_frontend.js.erb index f95a8b9b..21fff4af 100644 --- a/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI_frontend.js.erb +++ b/vendor/built_in_modules/gallery/app/assets/javascripts/galleryAPI_frontend.js.erb @@ -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()); diff --git a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/orbit_galleries_controller.rb b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/orbit_galleries_controller.rb index d1bbcaf0..2adc9bf5 100644 --- a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/orbit_galleries_controller.rb +++ b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/orbit_galleries_controller.rb @@ -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 - @authenticated = false + 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