From fbbf911193322fb731bf418e42b89cae6ca040df Mon Sep 17 00:00:00 2001 From: chiu Date: Thu, 5 Mar 2020 23:28:13 +0800 Subject: [PATCH] fix css error and auto set album cover if it has album_image --- app/assets/javascripts/theater.js | 5 +++++ app/models/album.rb | 17 +++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/theater.js b/app/assets/javascripts/theater.js index 5085d84..f4574a5 100644 --- a/app/assets/javascripts/theater.js +++ b/app/assets/javascripts/theater.js @@ -1,4 +1,7 @@ var GalleryTheater = function(){ + var parent_divs = $('.gallery').parents('div'), + parent_div_z_index = parent_divs.eq(parent_divs.length-1).css('z-index') + parent_divs.eq(parent_divs.length-1).css('z-index','2000') var gt = this, currentPic = {}, windowHeight = 0, @@ -25,6 +28,7 @@ var GalleryTheater = function(){ gt.thumbStrip = null; gt.descriptionArea = null; gt.isTheaterInitialized = false; + var play_flag = false; var button_left_string = '', button_right_string = '', @@ -172,6 +176,7 @@ var GalleryTheater = function(){ } gt.destroyTheater = function(){ + parent_divs.eq(parent_divs.length-1).css('z-index',parent_div_z_index) gt.stage.hide(); $("body").removeClass("gallery-mode-on"); gt.imageContainer.empty() diff --git a/app/models/album.rb b/app/models/album.rb index 56e927e..325b4a6 100644 --- a/app/models/album.rb +++ b/app/models/album.rb @@ -4,7 +4,7 @@ class Album include OrbitCategory::Categorizable include OrbitTag::Taggable - include Slug + include Slug field :name, as: :slug_title, localize: true field :description, localize: true @@ -20,7 +20,6 @@ class Album has_many :album_colors, :autosave => true, :dependent => :destroy accepts_nested_attributes_for :album_images, :allow_destroy => true accepts_nested_attributes_for :album_colors, :allow_destroy => true - def self.find_by_param(input) self.find_by(uid: input) end @@ -49,4 +48,18 @@ class Album self.where(:id.in=>taggings) end end + def cover + tmp = self['cover'] + if tmp=='default' + tmp = (self.album_images.first.id.to_s rescue 'default') + end + tmp + end + def cover_path + tmp = self['cover_path'] + if tmp.nil? + tmp = (self.album_images.first.file.thumb.url rescue nil) + end + tmp + end end \ No newline at end of file