ordering added to albums
This commit is contained in:
parent
7e432bd1ed
commit
8aead66ac5
|
@ -43,10 +43,10 @@ $(function() {
|
|||
$img = $('.rgalbum img');
|
||||
$('.rgalbum > a').rsImg();
|
||||
if($containerData.galleryId == 'gallery') {
|
||||
$container.masonry({
|
||||
itemSelector : '.rgalbum',
|
||||
isAnimated: true,
|
||||
});
|
||||
// $container.masonry({
|
||||
// itemSelector : '.rgalbum',
|
||||
// isAnimated: true,
|
||||
// });
|
||||
$albumname.each(function(i) {
|
||||
var $albumblock = $(this).closest('a').height(),
|
||||
$H = $(this).outerHeight(true);
|
||||
|
@ -69,12 +69,7 @@ $(function() {
|
|||
};
|
||||
});
|
||||
$('#orbit_gallery').delegate('.icons-tag', clickEvent, function(){
|
||||
$(this).parents('.gallery_info').nextAll('.albumtag').slideToggle(300, function() {
|
||||
$container.masonry({
|
||||
itemSelector : '.rgalbum',
|
||||
isAnimated: true,
|
||||
});
|
||||
});
|
||||
$(this).parents('.gallery_info').nextAll('.albumtag').slideToggle(300);
|
||||
});
|
||||
};
|
||||
});
|
||||
|
@ -229,11 +224,12 @@ $(function() {
|
|||
$container.data("order-edit","1");
|
||||
el.text("Save Order");
|
||||
}else{
|
||||
var temp = $container.sortable( "toArray", { attribute: "data-image-id" });
|
||||
var temp = $container.sortable( "toArray", { attribute: "data-image-id" }),
|
||||
type = $container.attr("id");
|
||||
if(images_order.toString() != temp.toString()){
|
||||
$.ajax({
|
||||
url : "/admin/galleries/order",
|
||||
data : {"imageids" : temp },
|
||||
data : {"imageids" : temp, "type" : type},
|
||||
type : "post",
|
||||
dataType : "json"
|
||||
})
|
||||
|
|
|
@ -4,10 +4,17 @@
|
|||
list-style: none;
|
||||
}
|
||||
#orbit_gallery .rgalbum {
|
||||
position: relative;
|
||||
float: left;
|
||||
margin: 5px;
|
||||
padding: 10px;
|
||||
padding: 5px;
|
||||
width: 200px;
|
||||
background: #FFFFFF;
|
||||
overflow: hidden;
|
||||
-webkit-box-shadow: 0px 0px 5px rgba(0, 0, 0, .1);
|
||||
-moz-box-shadow: 0px 0px 5px rgba(0, 0, 0, .1);
|
||||
box-shadow: 0px 0px 5px rgba(0, 0, 0, .1);
|
||||
-o-box-shadow: 0px 0px 5px rgba(0, 0, 0, .1);
|
||||
-webkit-transition-property: left, right, top;
|
||||
-moz-transition-property: left, right, top;
|
||||
-ms-transition-property: left, right, top;
|
||||
|
@ -522,6 +529,7 @@
|
|||
|
||||
.order-edit-notification{
|
||||
background-color: #ffffd5;
|
||||
z-index: 10;
|
||||
display: none;
|
||||
height: 25px;
|
||||
margin-left: 40%;
|
||||
|
|
|
@ -4,7 +4,7 @@ class Admin::GalleriesController < OrbitAdminController
|
|||
before_action :log_user_action
|
||||
layout "back_end"
|
||||
def index
|
||||
@albums = Album.all
|
||||
@albums = Album.all.asc(:order)
|
||||
@tags = @module_app.tags
|
||||
end
|
||||
|
||||
|
|
|
@ -8,12 +8,24 @@ class Admin::ImagesController < OrbitAdminController
|
|||
end
|
||||
|
||||
def changeorder
|
||||
images = params[:imageids]
|
||||
images.each_with_index do |image, i|
|
||||
img = AlbumImage.find(image) rescue nil
|
||||
if !img.nil?
|
||||
img.order = i
|
||||
img.save
|
||||
type = params[:type]
|
||||
if type == "imgholder"
|
||||
images = params[:imageids]
|
||||
images.each_with_index do |image, i|
|
||||
img = AlbumImage.find(image) rescue nil
|
||||
if !img.nil?
|
||||
img.order = i
|
||||
img.save
|
||||
end
|
||||
end
|
||||
elsif type == "orbit_gallery"
|
||||
albums = params[:imageids]
|
||||
albums.each_with_index do |albumid, i|
|
||||
album = Album.find(albumid) rescue nil
|
||||
if !album.nil?
|
||||
album.order = i
|
||||
album.save
|
||||
end
|
||||
end
|
||||
end
|
||||
render :json => {"success" => true}.to_json
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class GalleriesController < ApplicationController
|
||||
def index
|
||||
albums = Album.filter_by_categories
|
||||
albums = Album.filter_by_categories.asc(:order)
|
||||
galleries = albums.collect do |a|
|
||||
{
|
||||
"album-name" => a.name,
|
||||
|
|
|
@ -13,6 +13,7 @@ class Album
|
|||
field :tag_names
|
||||
field :uid, type: String
|
||||
field :rss2_id, type: String
|
||||
field :order, type: Integer, default: 0
|
||||
|
||||
# has_and_belongs_to_many :tags, :class_name => "GalleryTag"
|
||||
has_many :album_images, :autosave => true, :dependent => :destroy
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<li class="rgalbum">
|
||||
<li class="rgalbum" data-image-id="<%= album.id %>">
|
||||
<a href="<%= admin_gallery_path(album.id) %>">
|
||||
<% if album.cover == "default" %>
|
||||
<%= image_tag "gallery/default.jpg" %>
|
||||
|
|
|
@ -1,8 +1,19 @@
|
|||
<ul id="orbit_gallery" class="gallery" data-gallery-id="gallery">
|
||||
<% @albums.each do |album| %>
|
||||
<%= render :partial => "album", :object => album %>
|
||||
<% end %>
|
||||
</ul>
|
||||
<div class="order-edit-notification">Albums re-ordering enabled.</div>
|
||||
|
||||
<div class="rgbody">
|
||||
<ul id="orbit_gallery" class="gallery clearfix" data-gallery-id="gallery">
|
||||
<% @albums.each do |album| %>
|
||||
<%= render :partial => "album", :object => album %>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="bottomnav clearfix">
|
||||
<div class="action pull-right">
|
||||
<% if can_edit_or_delete?(nil) %>
|
||||
<a href="#" class="btn btn-small btn-info" id="edit-order-btn">Edit Order</a>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% content_for :page_specific_css do %>
|
||||
<%= stylesheet_link_tag "gallery" %>
|
||||
|
|
Loading…
Reference in New Issue