fixed gallery frontend for category display
This commit is contained in:
		
							parent
							
								
									49217d4705
								
							
						
					
					
						commit
						8c532e7241
					
				| 
						 | 
				
			
			@ -41,32 +41,11 @@ var galleryAPI = function(){
 | 
			
		|||
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	this.loadAlbums = function(id){
 | 
			
		||||
	this.loadAlbums = function(cids){
 | 
			
		||||
		g.albumArea.find(".rghead .rgfn a").click(function(){g.makeNewAlbum($(this).attr("href"))});
 | 
			
		||||
		g.albumArea.addClass('o_gallery');
 | 
			
		||||
		g.albumArea.find("#imgholder").empty();
 | 
			
		||||
		if(id!="all"){
 | 
			
		||||
			var cids = [];
 | 
			
		||||
			var tids = [];
 | 
			
		||||
			var href = null;
 | 
			
		||||
		    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
 | 
			
		||||
		    for(var i = 0; i < hashes.length; i++){
 | 
			
		||||
		        hash = hashes[i].split('=');
 | 
			
		||||
		        if(hash[0]=="cat"){
 | 
			
		||||
		        	cids.push(hash[1]);
 | 
			
		||||
		        	href = "cat="+hash[1];
 | 
			
		||||
		    	}else if(hash[0]=="tag"){
 | 
			
		||||
		    		tids.push(hash[1]);
 | 
			
		||||
		    		href = "tag="+hash[1];
 | 
			
		||||
		    	}
 | 
			
		||||
		        $("#filter .filter_btns a[href='"+href+"']").addClass("active");
 | 
			
		||||
		    }
 | 
			
		||||
		    if(cids.length == 0)
 | 
			
		||||
		    		cids = "all";
 | 
			
		||||
		}else{
 | 
			
		||||
			var cids = "all";
 | 
			
		||||
		}
 | 
			
		||||
		$.getJSON("/panel/gallery/front_end/get_albums",{"cid":cids,"tid":tids,"inner":true},function(categories){
 | 
			
		||||
		$.getJSON("/panel/gallery/front_end/get_albums",{"cid":cids,"inner":true},function(categories){
 | 
			
		||||
			$.each(categories,function(x,category){
 | 
			
		||||
				$.each(category,function(i,album){
 | 
			
		||||
					album.description = (album.description?album.description:"<%= I18n.t('gallery.no_description') %>")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,6 @@
 | 
			
		|||
class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController
 | 
			
		||||
  def index
 | 
			
		||||
    @categories = params[:category_id]
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def show
 | 
			
		||||
| 
						 | 
				
			
			@ -9,36 +10,10 @@ class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController
 | 
			
		|||
 | 
			
		||||
  def get_albums
 | 
			
		||||
    @categoryids = params["cid"]
 | 
			
		||||
    @tags = params["tid"]
 | 
			
		||||
    @albums = Array.new
 | 
			
		||||
    if @categoryids == "all"
 | 
			
		||||
      if @tags
 | 
			
		||||
        if @tags.kind_of?(Array)
 | 
			
		||||
          @tags.each do |tag|
 | 
			
		||||
            @albums << GalleryAlbum.where(tagged_ids: tag)
 | 
			
		||||
          end
 | 
			
		||||
        else
 | 
			
		||||
          @albums <<  GalleryAlbum.where(tagged_ids: @tags)
 | 
			
		||||
        end
 | 
			
		||||
      else
 | 
			
		||||
        @albums << GalleryAlbum.all
 | 
			
		||||
      end
 | 
			
		||||
    else
 | 
			
		||||
      @categoryids.each do |id|
 | 
			
		||||
        category = Category.find(id)
 | 
			
		||||
        if @tags
 | 
			
		||||
          if @tags.kind_of?(Array)
 | 
			
		||||
            @tags.each do |tag|
 | 
			
		||||
              @albums << category.gallery_albums.where(tagged_ids: tag)
 | 
			
		||||
            end
 | 
			
		||||
          else
 | 
			
		||||
            @albums << category.gallery_albums.where(tagged_ids: @tags)
 | 
			
		||||
          end
 | 
			
		||||
        else
 | 
			
		||||
          @albums << category.gallery_albums.all
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    @albums << GalleryAlbum.where(:category_id.in => @categoryids)
 | 
			
		||||
 | 
			
		||||
   
 | 
			
		||||
    @output =  Array.new
 | 
			
		||||
    @albums.each do |album|
 | 
			
		||||
      @albs = Array.new
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,16 +27,9 @@
 | 
			
		|||
<script type="text/javascript">
 | 
			
		||||
  galleryAPI.prototype.locale = "<%= I18n.locale %>";
 | 
			
		||||
  var gallery = new galleryAPI();
 | 
			
		||||
  var categories = <%= @categories.to_json.html_safe %>;
 | 
			
		||||
  gallery.initialize();
 | 
			
		||||
  if(typeof gallery.urlVars['cat']!= "undefined"){
 | 
			
		||||
       gallery.loadArea = "albums";
 | 
			
		||||
       gallery.loadAlbums(gallery.urlVars['cat']);
 | 
			
		||||
    }else if(typeof gallery.urlVars['tag']!= "undefined"){
 | 
			
		||||
        gallery.loadArea = "albums";
 | 
			
		||||
        gallery.loadAlbums(gallery.urlVars['tag']);
 | 
			
		||||
    }else{
 | 
			
		||||
      gallery.loadArea = "albums";
 | 
			
		||||
      gallery.loadAlbums("all");
 | 
			
		||||
    }
 | 
			
		||||
  gallery.loadArea = "albums";
 | 
			
		||||
  gallery.loadAlbums(categories);
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,10 +18,7 @@
 | 
			
		|||
    </ul>
 | 
			
		||||
  </div>
 | 
			
		||||
  <!-- tag end -->
 | 
			
		||||
  <div class="form-actions form-fixed pagination-right rghead">
 | 
			
		||||
    <div class="rgfn">
 | 
			
		||||
   		<a class="bt-back rgbt" title="<%= I18n.t("gallery.back_to_albums") %>" href="<%= panel_gallery_front_end_albums_path %>"><i class="icon-arrow-left"></i> <%= I18n.t("gallery.back_to_albums") %></a>
 | 
			
		||||
  </div>
 | 
			
		||||
  <!--  -->
 | 
			
		||||
</div>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue