!function ($) { $.fn.checkListLength = function (param){ _defaultSettings = { onlyOne: null, }; _set = $.extend(_defaultSettings, param); $this = this; $li = this.children('li'); $dropzone = $('#dropzone'); if(($li.length - _set.onlyOne) == 0) { $('#dropzone').fadeIn(300); } else { $('#dropzone').fadeOut(300); }; $('#file-list').nanoScroller({ scrollTop: 0, iOSNativeScrolling: true }); } }(window.jQuery); $(function() { var $container = $('.gallery'), $containerData = $container.data(); $container.imagesLoaded( function(){ var $albumname = $('.albumname'), $img = $('.rgalbum img'); $img.muImageResize({width: 200, height:200}); if($containerData.galleryId == 'gallery') { $container.masonry({ itemSelector : '.rgalbum', isAnimated: true, }); $albumname.each(function(i) { var $imgH = $(this).prevAll($img).height(), $H = $(this).height()+20, $fontSize = parseInt($(this).css('font-size')); $lineHeight = parseInt($(this).css('line-height')); if($H > $imgH) { $(this).css({ 'bottom': "auto", 'top': 0, }); $(this).hover(function() { $(this).stop(true, true).delay(500).animate({ 'top': '-='+($H-$imgH), },($H-$imgH)*10) },function() { $(this).stop(true, true); $(this).css({ 'bottom': "auto", 'top': 0, }); }); }; }); $('#orbit_gallery').delegate('.icons-tag','click',function(){ $(this).parents('.gallery_info').nextAll('.albumtag').slideToggle(300, function() { $container.masonry({ itemSelector : '.rgalbum', isAnimated: true, }); }); }); }; }); $('.add-imgs').on({ click: function() { $('#fileupload').slideToggle(300, function() { if(!$(this).is(':hidden')) { $('.add-imgs').html(' Close panel'); $('.rgbody').stop(true, false).animate({'padding-bottom': 280}, 300); } else { $('.add-imgs').html(' Add Image'); $('.files').empty() $('#file-list').checkListLength(); $('.rgbody').stop(true, false).animate({'padding-bottom': 0}, 300); fetchNewImages(); }; }); return false; } }); var fetchNewImages = function(){ var lastid = $("li.rgalbum:last").data("image-id"), albumid = $("#fileupload_aid").val(); $.ajax({ url : "/panel/gallery/back_end/new_images", data : {"last_image_id" : lastid, "album_id" : albumid}, success : function(data){ var $e = $(data); $imgs = $e.find("img"); $imgs.muImageResize({width: 200, height:200}); $("#imgholder").append($e); } }) } });