Fix backend gallery show page go_back issue and theater exit fullscreen

This commit is contained in:
manson 2014-07-21 16:28:09 +08:00
parent 6f2ca20be3
commit 1825842ad0
6 changed files with 47 additions and 19 deletions

View File

@ -145,16 +145,12 @@ $(function() {
} }
} }
var photosData = null;
if($("#imgholder").length){ if($("#imgholder").length){
$.getJSON(window.location.pathname, function(json, textStatus) {
photosData = json;
$('.open').pageslide({ $('.open').pageslide({
loadComplete: function(instance,elem) { loadComplete: function(instance,elem) {
bindEvent(instance,elem); bindEvent(instance,elem);
} }
}) })
});
} }
@ -242,7 +238,7 @@ $(function() {
var lastid = ( $("li.rgalbum:last").length ? $("li.rgalbum:last").data("image-id") : null), var lastid = ( $("li.rgalbum:last").length ? $("li.rgalbum:last").data("image-id") : null),
albumid = $("#fileupload_aid").val(); albumid = $("#fileupload_aid").val();
$.getJSON(window.location.pathname, function(json, textStatus) { $.getJSON('/admin/galleries/get_photoData_json?id='+albumid, function(json, textStatus) {
photosData = json; photosData = json;
}); });

View File

@ -12,6 +12,8 @@ var galleryAPI = function(){
this.tagList = $("ul#gallery_tag_list"); this.tagList = $("ul#gallery_tag_list");
this.loading = $("#loading"); this.loading = $("#loading");
this.fullscreen_mode = false;
this.loadTheater = function(id){ this.loadTheater = function(id){
g.loadstart(); g.loadstart();
@ -139,9 +141,17 @@ var galleryAPI = function(){
} }
}); });
var browserFullScreen = function(){ var browserFullScreen = function(){
if(g.fullscreen_mode==false){
var el = document.documentElement, var el = document.documentElement,
rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen; rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen;
rfs.call(el); rfs.call(el);
g.fullscreen_mode = true;
}else{
var el = document,
rfs = el.exitFullscreen || el.msExitFullscreen || el.webkitExitFullscreen || el.mozCancelFullScreen;
rfs.call(el);
g.fullscreen_mode = false;
}
} }
$(window).resize(function(){ $(window).resize(function(){
if(window.innerWidth == screen.width && window.innerHeight == screen.height) { if(window.innerWidth == screen.width && window.innerHeight == screen.height) {

View File

@ -11,6 +11,7 @@ var galleryAPI = function(){
this.loadArea = "theater"; this.loadArea = "theater";
this.tagList = $(".taglist ul"); this.tagList = $(".taglist ul");
this.loading = $("#loading"); this.loading = $("#loading");
this.fullscreen_mode = false;
// this.authenticated = false; // this.authenticated = false;
this.initialize = function(callbackFn){ this.initialize = function(callbackFn){
if(g.loadArea == "theater"){ if(g.loadArea == "theater"){
@ -109,9 +110,17 @@ var galleryAPI = function(){
} }
}); });
var browserFullScreen = function(){ var browserFullScreen = function(){
if(g.fullscreen_mode==false){
var el = document.documentElement, var el = document.documentElement,
rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen; rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen;
rfs.call(el); rfs.call(el);
g.fullscreen_mode = true;
}else{
var el = document,
rfs = el.exitFullscreen || el.msExitFullscreen || el.webkitExitFullscreen || el.mozCancelFullScreen;
rfs.call(el);
g.fullscreen_mode = false;
}
} }
$(window).resize(function(){ $(window).resize(function(){
if(window.innerWidth == screen.width && window.innerHeight == screen.height) { if(window.innerWidth == screen.width && window.innerHeight == screen.height) {

View File

@ -10,15 +10,12 @@ class Admin::GalleriesController < ApplicationController
def show def show
@album = Album.find(params[:id]) @album = Album.find(params[:id])
@images = @album.album_images @images = @album.album_images
@image_content = [] image_content = []
@images.each do |image| @images.each do |image|
@image_content << {"id" => image.id.to_s, "description" => image.description_translations,"tags" => image.tags.collect{|t| t.id.to_s}} image_content << {"id" => image.id.to_s, "description" => image.description_translations,"tags" => image.tags.collect{|t| t.id.to_s}}
end end
@tags = @module_app.tags @tags = @module_app.tags
respond_to do |h| @photos_data = {"galleries" => image_content}.to_json
h.html
h.json {render json: @image_content}
end
end end
def new def new
@ -61,6 +58,16 @@ class Admin::GalleriesController < ApplicationController
render :json =>{"success"=>true}.to_json render :json =>{"success"=>true}.to_json
end end
def get_photoData_json
@album = Album.find(params[:id])
@images = @album.album_images
image_content = []
@images.each do |image|
image_content << {"id" => image.id.to_s, "description" => image.description_translations,"tags" => image.tags.collect{|t| t.id.to_s}}
end
render :json=>{"galleries" => image_content}.to_json
end
def get_album_json def get_album_json
albums = Album.all albums = Album.all
output = Array.new output = Array.new

View File

@ -162,6 +162,10 @@
</div> </div>
</div> </div>
<script type="text/javascript">
var photosData = <%= @photos_data.html_safe %>;
</script>
<% content_for :page_specific_javascript do %> <% content_for :page_specific_javascript do %>
<%= javascript_include_tag "jquery.masonry.min.js" %> <%= javascript_include_tag "jquery.masonry.min.js" %>
<%= javascript_include_tag "jquery.lite.image.resize.js" %> <%= javascript_include_tag "jquery.lite.image.resize.js" %>

View File

@ -4,6 +4,8 @@ Rails.application.routes.draw do
scope "(:locale)", locale: Regexp.new(locales.join("|")) do scope "(:locale)", locale: Regexp.new(locales.join("|")) do
namespace :admin do namespace :admin do
get "galleries/get_photoData_json" => "galleries#get_photoData_json"
resources :galleries do resources :galleries do
get "imgs" => "galleries#imgs" get "imgs" => "galleries#imgs"
end end