widget code for gallery rewritten for new_ui
This commit is contained in:
parent
8456a91968
commit
d532ded8e4
|
@ -19,6 +19,7 @@
|
||||||
$(function () {
|
$(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
// Initialize the jQuery File Upload widget:
|
// Initialize the jQuery File Upload widget:
|
||||||
|
if($('#fileupload').length){
|
||||||
$('#fileupload').fileupload({
|
$('#fileupload').fileupload({
|
||||||
maxFileSize: 5000000,
|
maxFileSize: 5000000,
|
||||||
acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
|
acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
|
||||||
|
@ -27,6 +28,7 @@ $(function () {
|
||||||
'X-CSRF-Token': $('meta[name="csrf-token"]').attr("content")
|
'X-CSRF-Token': $('meta[name="csrf-token"]').attr("content")
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
|
@ -9,17 +9,40 @@ class Panel::Gallery::Widget::AlbumsController < OrbitWidgetController
|
||||||
@album = GalleryAlbum.find(@part.widget_options['album_id']) rescue nil
|
@album = GalleryAlbum.find(@part.widget_options['album_id']) rescue nil
|
||||||
@album_images = @album.gallery_images if @album
|
@album_images = @album.gallery_images if @album
|
||||||
|
|
||||||
|
|
||||||
@settings = {"vertical"=>vertical,"horizontal"=>horizontal} #[note] horizontal has it's limitation from 2 to 6
|
@settings = {"vertical"=>vertical,"horizontal"=>horizontal} #[note] horizontal has it's limitation from 2 to 6
|
||||||
@class = "c" + @settings["horizontal"].to_s
|
@class = "c" + @settings["horizontal"].to_s
|
||||||
@total = @settings["vertical"] * @settings["horizontal"]
|
@total = @settings["vertical"] * @settings["horizontal"]
|
||||||
@rnd = Random.new
|
@rnd = Random.new
|
||||||
@images = []
|
@images = []
|
||||||
for i in 0..@total-1
|
|
||||||
image = @album_images[@rnd.rand(0...@album_images.count)]
|
if @album_images.count > @total
|
||||||
|
@randoms = []
|
||||||
|
until @randoms.count == @total do
|
||||||
|
r = @rnd.rand(0...@album_images.count)
|
||||||
|
if !@randoms.include?r
|
||||||
|
@randoms << r
|
||||||
|
image = @album_images[r]
|
||||||
values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url}
|
values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url}
|
||||||
@images << values
|
@images << values
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
elsif @album_images.count == @total
|
||||||
|
@album_images.each do |image|
|
||||||
|
values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url}
|
||||||
|
@images << values
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@album_images.each do |image|
|
||||||
|
values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url}
|
||||||
|
@images << values
|
||||||
|
end
|
||||||
|
until @images.count == @total do
|
||||||
|
values = {"show_link"=>"javascript:void(0);","thumb"=>"assets/gallery/default.jpg"}
|
||||||
|
@images << values
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def widget2
|
def widget2
|
||||||
|
|
||||||
|
|
Reference in New Issue