jegtheme

jeglio.js

Feb 23rd, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 44.99 KB | None | 0 0
  1. jQuery(document).ready(function($) {
  2. $.Isotope.prototype._getCenteredMasonryColumns = function() {
  3. this.width = this.element.width();
  4.  
  5. var parentWidth = this.element.parent().width();
  6.  
  7. // i.e. options.masonry && options.masonry.columnWidth
  8. var colW = this.options.masonry && this.options.masonry.columnWidth ||
  9. // or use the size of the first item
  10. this.$filteredAtoms.outerWidth(true) ||
  11. // if there's no items, use size of container
  12. parentWidth;
  13.  
  14. var cols = Math.floor( parentWidth / colW );
  15. cols = Math.max( cols, 1 );
  16.  
  17. // i.e. this.masonry.cols = ....
  18. this.masonry.cols = cols;
  19. // i.e. this.masonry.columnWidth = ...
  20. this.masonry.columnWidth = colW;
  21. };
  22.  
  23. $.Isotope.prototype._masonryReset = function() {
  24. // layout-specific props
  25. this.masonry = {};
  26. // FIXME shouldn't have to call this again
  27. this._getCenteredMasonryColumns();
  28. var i = this.masonry.cols;
  29. this.masonry.colYs = [];
  30. while (i--) {
  31. this.masonry.colYs.push( 0 );
  32. }
  33. };
  34.  
  35. $.Isotope.prototype._masonryResizeChanged = function() {
  36. var prevColCount = this.masonry.cols;
  37. // get updated colCount
  38. this._getCenteredMasonryColumns();
  39. return ( this.masonry.cols !== prevColCount );
  40. };
  41.  
  42. $.Isotope.prototype._masonryGetContainerSize = function() {
  43. var unusedCols = 0,
  44. i = this.masonry.cols;
  45. // count unused columns
  46. while ( --i ) {
  47. if ( this.masonry.colYs[i] !== 0 ) {
  48. break;
  49. }
  50. unusedCols++;
  51. }
  52.  
  53. return {
  54. height : Math.max.apply( Math, this.masonry.colYs ),
  55. // fit container to columns that have been used;
  56. width : ((this.masonry.cols - unusedCols) * this.masonry.columnWidth) + 5
  57. };
  58. };
  59. });
  60. /** jeglio v1 **/
  61.  
  62. (function($) {
  63. $.fn.jeglio = function( options )
  64. {
  65. // item mode : 0 = normal, 1 = masonry
  66. var settings = {
  67. itemWidth : 180,
  68. itemHeight : 210,
  69. itemMode : 0,
  70. itemHeightWide : 550,
  71. galleryDim : 3,
  72. descDim : 1,
  73. theatherMode : false,
  74. scrolltop : 50,
  75. flexDelay : 7000,
  76. zoomDelay : 7000,
  77. direction_nav : 0,
  78. control_nav : 1,
  79. portfolio_caption : 0,
  80. themes_schema : "light",
  81. loadAnimation : 'sequpfade' // normal | fade | seqfade | upfade | sequpfade | randomfade | randomupfade
  82. };
  83.  
  84. if (options) {
  85. var options = $.extend(settings, options);
  86. } else {
  87. var options = $.extend(settings);
  88. }
  89.  
  90. var $container = $(this);
  91. var lastclicked = undefined;
  92. var layoutmode = undefined;
  93. var itemWidth = undefined;
  94. var itemHeight = undefined;
  95. var itemGalleryWidth = undefined;
  96. var itemDescriptionWidth = undefined;
  97. var touch = false;
  98. var photoswipe = undefined;
  99. var iw = undefined;
  100. var ih = undefined;
  101. var doctitle = document.title;
  102. var iphonewidth = 150;
  103. var firstloaded = true;
  104. var itemTopPos = undefined;
  105. var itemLeftPos = undefined;
  106.  
  107. if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
  108. touch = true;
  109. }
  110.  
  111. var galleryDim = parseInt(options.galleryDim);
  112. var descDim = parseInt(options.descDim);
  113. var lockClick = false;
  114.  
  115. var hovered = function(e)
  116. {
  117. var $this = $(e.currentTarget);
  118. var th = $this.height();
  119.  
  120. /** show type of item **/
  121. var i = $this.find('i');
  122. $(i.get(0)).addClass('display-inline-table');
  123.  
  124. $this.find('.shadow').stop().animate({
  125. height : th
  126. }, 'fast');
  127.  
  128. var descholder = $this.find('.desc-holder');
  129. var dh = ( th - descholder.height() ) / 2;
  130. $this.find('.desc-holder').stop().animate({
  131. bottom : dh
  132. }, 'fast', function(){
  133. if(touch) {
  134. link = $($this.find('a').get(0)).attr('href');
  135. window.location = link;
  136. }
  137. });
  138. };
  139.  
  140. var unhovered = function(e)
  141. {
  142. var $this = $(e.currentTarget);
  143. var th = $this.height();
  144.  
  145. // show type of item
  146. var i = $this.find('i');
  147. $(i.get(0)).removeClass('display-inline-table');
  148.  
  149. $this.find('.shadow').stop().animate({
  150. height : 0
  151. }, 'fast');
  152. $this.find('.desc-holder').stop().animate({
  153. bottom : 0
  154. }, 'fast');
  155. };
  156.  
  157. var type_video = function(ele)
  158. {
  159. var w = $(ele.itemGallery).css('width');
  160. var h = $(ele.itemGallery).css('height');
  161.  
  162. $('video', ele.itemGallery).attr('width', w).attr('height', h);
  163. $('img', ele.itemGallery).css('width', w).css('height', h);
  164. $('video', ele.itemGallery).mediaelementplayer({});
  165. };
  166.  
  167. /** vimeo & youtube **/
  168. var youtube_parser = function (url)
  169. {
  170. var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
  171. var match = url.match(regExp);
  172.  
  173. if ( match && match[7].length == 11 ) {
  174. return match[7];
  175. } else {
  176. alert("Url Incorrect");
  177. }
  178. };
  179.  
  180. var vimeo_parser = function (url)
  181. {
  182. var regExp = /http:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/;
  183. var match = url.match(regExp);
  184.  
  185. if (match){
  186. return match[2];
  187. }else{
  188. alert("not a vimeo url");
  189. }
  190. };
  191.  
  192. var type_video_youtube = function(ele)
  193. {
  194. var w = $(ele.itemGallery).css('width');
  195. var h = $(ele.itemGallery).css('height');
  196.  
  197. var youtube_id = youtube_parser($('.video-youtube-container', ele.itemGallery).attr('src'));
  198. var iframe = '<iframe width="' + w + '" height="' + h + '" src="http://www.youtube.com/embed/' + youtube_id + '?showinfo=0&theme=light&autohide=1&rel=0&wmode=opaque" frameborder="0" allowfullscreen></iframe>';
  199. $('.video-youtube-container', ele.itemGallery).append(iframe);
  200. };
  201.  
  202. var type_video_vimeo = function(ele)
  203. {
  204. var w = $(ele.itemGallery).css('width');
  205. var h = $(ele.itemGallery).css('height');
  206.  
  207. var vimeo_id = vimeo_parser($('.video-vimeo-container', ele.itemGallery).attr('src'));
  208. var iframe = '<iframe src="http://player.vimeo.com/video/' + vimeo_id + '?title=0&byline=0&portrait=0" width="' + w + '" height="' + h + '" frameborder="0"></iframe>';
  209. $('.video-vimeo-container', ele.itemGallery).append(iframe);
  210. };
  211.  
  212.  
  213. var type_audio = function(ele)
  214. {
  215. var w = $(ele.itemGallery).css('width');
  216. var h = 30;
  217. $('audio', ele.itemGallery).attr('width', w).attr('height', h);
  218. $('audio', ele.itemGallery).mediaelementplayer({
  219. pluginPath: template_css + "mediaelement/"
  220. });
  221. };
  222.  
  223. var type_gallery = function(ele)
  224. {
  225. var loadotherimage = function(sel) {
  226. var datasrc = $('img',sel).attr('data-src');
  227. if(datasrc != undefined) {
  228. var img = new Image();
  229. $(img).css("opacity" , 0);
  230. $('a', sel).html('').append(img);
  231. $(img).load(function(){
  232. $('img', sel).stop().animate({"opacity" : 1}, "fast");
  233. }).attr('src', datasrc);
  234. }
  235. };
  236.  
  237. var loadnextprev = function(slider) {
  238. // load next slide
  239. var next = $('.flex-active-slide', slider).next();
  240. loadotherimage(next);
  241.  
  242. // load prev slide
  243. var prev = $('.flex-active-slide', slider).prev();
  244. loadotherimage(prev);
  245. };
  246.  
  247. var lazyloadflex = function(slider) {
  248. var datasrc = $('.flex-active-slide img', slider).attr('data-src');
  249. if(datasrc != undefined){
  250. var img = new Image();
  251. $(img).css("opacity" , 0);
  252. $('.flex-active-slide a', slider).html('').append(img);
  253.  
  254. $(img).load(function(){
  255. $('.flex-active-slide img', slider).stop().animate({"opacity" : 1}, "fast");
  256. loadnextprev(slider);
  257. }).attr('src', datasrc);
  258. } else {
  259. if($('.flex-active-slide img', slider).css('opacity') == 0) {
  260. $('.flex-active-slide img', slider).animate({"opacity" : 1}, "fast");
  261. }
  262. loadnextprev(slider);
  263. }
  264. };
  265.  
  266. var showdescription = function(slider) {
  267. if(options.portfolio_caption == 1) {
  268. var slidertitle = $('.flex-active-slide a', slider).attr("data-title");
  269. $(".item-description-wrapper").text(slidertitle);
  270. }
  271. };
  272.  
  273. type_image(ele);
  274.  
  275. $(ele.itemGallery).flexslider({
  276. animation: "slide",
  277. slideDirection: "horizontal",
  278. slideshow: true,
  279. animationDuration: 300,
  280. slideshowSpeed: options.flexDelay,
  281. directionNav: options.direction_nav,
  282. controlNav: options.control_nav,
  283. keyboardNav: true,
  284. mousewheel: false,
  285. prevText: "Previous",
  286. nextText: "Next",
  287. pausePlay: false,
  288. pauseText: 'Pause',
  289. playText: 'Play',
  290. randomize: false,
  291. slideToStart: 0,
  292. animationLoop: true,
  293. pauseOnAction: true,
  294. pauseOnHover: false,
  295. controlsContainer: "",
  296. manualControls: "",
  297. start: function(slider) {
  298. lazyloadflex(slider);
  299. showdescription(slider);
  300. },
  301. end: function(slider){},
  302. before: function(slider){},
  303. after: function(slider){
  304. lazyloadflex(slider);
  305. showdescription(slider);
  306. }
  307. });
  308. };
  309.  
  310. var type_image = function(ele)
  311. {
  312. /*
  313. if(!touch) {
  314. $(ele.itemGallery).find('.item-gallery-image').jtooltip({});
  315. }
  316.  
  317. (function(PhotoSwipe){
  318. photoswipe = $(ele.itemGallery).find('.item-gallery-image').photoSwipe({
  319. backButtonHideEnabled : false,
  320. captionAndToolbarAutoHideDelay : 0,
  321. slideshowDelay : options.zoomDelay,
  322. slideSpeed : 500,
  323. imageScaleMethod : 'fitNoUpscale',
  324. allowUserZoom : false,
  325. getImageSource : function(obj){ return $(obj).attr('data'); },
  326. getImageCaption : function(obj){ return $(obj).attr('data-title'); }
  327. });
  328. photoswipe.addEventHandler(PhotoSwipe.EventTypes.onHide, function(e){
  329. $container.isotope("reLayout");
  330. });
  331. }(window.Code.PhotoSwipe));
  332. */
  333.  
  334. $('.item-gallery-image').click(function(){
  335. return false;
  336. });
  337. };
  338.  
  339. var bindlovethis = function (i) {
  340. $(".love-this", i).each(function(){
  341. $(this).click(function(){
  342. if(!$(this).hasClass("voted")) {
  343. var $this = $(this);
  344. $this.addClass("locked");
  345. var lovecounter = $this.find('.love-counter');
  346. $(lovecounter).text('Loading ...').addClass('italic');
  347.  
  348. $.ajax({
  349. url: admin_url,
  350. type : "post",
  351. dataType : "json",
  352. data : {
  353. postid : $(this).attr('data-id'),
  354. action : 'vote_post'
  355. },
  356. success: function(data) {
  357. $(lovecounter).text(data.msg);
  358.  
  359. setTimeout(function(){
  360. if(data.id == 3) {
  361. $this.attr('data-counter', data.total);
  362. $(lovecounter).removeClass('italic');
  363. $this.addClass('voted');
  364. }
  365.  
  366. $this.removeClass("locked");
  367. $(lovecounter).text($this.attr('data-counter')).removeClass('italic');
  368. }, 1500);
  369. }
  370. });
  371. } else {
  372. var votedtext = $(this).attr('data-voted');
  373. }
  374. }).hover(function(){
  375. if($(this).hasClass("voted")) {
  376. var votedtext = $(this).attr('data-voted');
  377. var lovecounter = $(this).find('.love-counter');
  378. lovecounter.text(votedtext);
  379. } else {
  380. if(!$(this).hasClass("locked")) {
  381. var votedtext = $(this).attr('data-vote');
  382. var lovecounter = $(this).find('.love-counter');
  383. lovecounter.text(votedtext);
  384. }
  385. }
  386. }, function(){
  387. if(!$(this).hasClass("locked")) {
  388. var countertext = $(this).attr('data-counter');
  389. var lovecounter = $(this).find('.love-counter');
  390. lovecounter.text(countertext);
  391. }
  392. });
  393. });
  394. };
  395.  
  396. var show_next_prev_popup = function (i) {
  397. $(i).find('.item-prev, .item-next').tipTip({maxWidth: "auto", edgeOffset: 10, defaultPosition: "top", delay : 100});
  398. };
  399.  
  400. var theatherClose = function(i, id, changeLocation)
  401. {
  402. closePrev(changeLocation);
  403.  
  404. if(lastclicked) {
  405. $(lastclicked.i).find('.love-this').replaceWith(function(){
  406. return $('<div>').append($(i).find('.love-this').clone()).html();
  407. });
  408. bindlovethis(lastclicked.i);
  409. }
  410.  
  411. // stop music & video
  412. $('video, audio', id).each(function() {
  413. $(this)[0].pause();
  414. });
  415.  
  416. $(i).fadeOut("fast", function(){
  417. $(id).remove();
  418. $("html").css("overflow-y", "auto");
  419. $container.css({'max-height' : '100%'});
  420. });
  421. };
  422.  
  423. // $this => clicked item
  424. var contentTheater = function($this, title, type, love, voted){
  425. var i = $("#item-theater-overlay");
  426. var itd = $("#item-theater-detail", i);
  427. var id = $(".item-detail", i);
  428. var ele = itemDetailElement(id);
  429. var openprev = false;
  430. var flagTheater = 0;
  431.  
  432. /** close previous opened section **/
  433. if(lastclicked != undefined) {
  434. closePrev(false);
  435. }
  436.  
  437. $("html, body").animate({
  438. scrollTop: 0
  439. }, function(){
  440. setTimeout(function(){
  441. if(!flagTheater) {
  442. showTheater();
  443. flagTheater++;
  444. }
  445. }, 500);
  446. });
  447.  
  448. var showTheater = function() {
  449. // hack for ipad
  450. if(touch) {
  451. var wh = $(window).height();
  452. var ofh = $container.offset();
  453. var mbtm = parseInt($container.css('margin-bottom'), 10);
  454. ch = wh - ofh.top - mbtm;
  455. $container.css({'max-height' : ch});
  456. } else {
  457. $("html").css("overflow-y", "hidden");
  458. }
  459.  
  460. /*** show item detail & set opacity ***/
  461. $(id).show().css({"opacity" : 1});
  462. $(itd).css({"display" : "block"});
  463. $(i).fadeIn("fast", function(){
  464.  
  465. $(itd).css({
  466. 'width' : itemWidth,
  467. 'height' : itemHeight,
  468. 'top' : itemTopPos,
  469. 'left' : itemLeftPos,
  470. 'position' : 'absolute'
  471. });
  472.  
  473. /** title **/
  474. document.title = title.unescapeHtml() + " - " + doctitle.unescapeHtml();
  475.  
  476. $(ele.itemGallery).css('width', itemGalleryWidth).css('height', itemHeight);
  477. $(ele.itemDescription).css('width', itemDescriptionWidth);
  478.  
  479. // set next & prev
  480. var nextprev = get_next_prev($this);
  481. $(i).find('.item-prev').parent().attr('href' , nextprev.prev);
  482. $(i).find('.item-next').parent().attr('href' , nextprev.next);
  483.  
  484. // love counter
  485. $(i).find('.love-this').replaceWith(function(){
  486. return $('<div>').append($this.find('.love-this').clone()).html();
  487. });
  488.  
  489. bindlovethis(i);
  490.  
  491. // bug waktu back button
  492. var dww = itemDescriptionWidth - parseInt(ele.descWrapper.css('margin-left'), 10) - parseInt(ele.descWrapper.css('margin-right'), 10);
  493.  
  494. $(ele.descWrapper).css({
  495. height : (itemHeight - 50),
  496. width : dww
  497. }).jScrollPane();
  498.  
  499. switch(type) {
  500. case "gallery" :
  501. type_gallery(ele);
  502. break;
  503. case "image" :
  504. type_image(ele);
  505. break;
  506. case "video" :
  507. type_video(ele);
  508. break;
  509. case "youtube" :
  510. type_video_youtube(ele);
  511. break;
  512. case "vimeo" :
  513. type_video_vimeo(ele);
  514. break;
  515. case "audio" :
  516. type_audio(ele);
  517. break;
  518. default :
  519. break;
  520. };
  521.  
  522. // release lock
  523. lockClick = false;
  524.  
  525. // save last click element
  526. lastclicked = {
  527. i : $this,
  528. t : type
  529. };
  530.  
  531. setTimeout(function()
  532. {
  533. var hash = location.hash.replace("#/", "");
  534. var hashres = hash.split(':');
  535. var openlarge = hashres[1];
  536.  
  537. if(openlarge != undefined) {
  538. (function(PhotoSwipe){
  539. $(PhotoSwipe.instances[0].originalImages[openlarge]).trigger('click');
  540. }(window.Code.PhotoSwipe));
  541. }
  542. }, 500);
  543.  
  544. /** close when background clicked **/
  545. $(i).click(function(ev){
  546. if (ev.target == this){
  547. theatherClose(i, id, true);
  548. }
  549. });
  550.  
  551. /** bind close me button **/
  552. $(".closeme", itd).show().bind("click", function(){
  553. theatherClose(i, id, true);
  554. });
  555. });
  556. };
  557.  
  558. };
  559.  
  560. var get_next_prev = function($this)
  561. {
  562. /** bind prev & next **/
  563. var prevlink = undefined;
  564. var nextlink = undefined;
  565.  
  566. /** find prev link end **/
  567. var eleprev = $this;
  568. while(eleprev = $(eleprev).prev()){
  569. if(!eleprev.hasClass('isotope-hidden')) {
  570. break;
  571. }
  572. }
  573.  
  574. var elenext = $this;
  575. while(elenext = $(elenext).next()){
  576. if(!elenext.hasClass('isotope-hidden')) {
  577. break;
  578. }
  579. }
  580.  
  581. prevlink = $($(eleprev).find('a').get(0)).attr('href');
  582. nextlink = $($(elenext).find('a').get(0)).attr('href');
  583.  
  584. if(prevlink === undefined) {
  585. eleprev = $('.item:last-child', $container);
  586. while(eleprev){
  587. if(!eleprev.hasClass('isotope-hidden')) {
  588. break;
  589. }
  590. eleprev = $(eleprev).prev();
  591. }
  592. prevlink = $($(eleprev).find('a').get(0)).attr('href');
  593. }
  594.  
  595. if(nextlink === undefined) {
  596. elenext = $('.item:first-child', $container);
  597. while(elenext){
  598. if(!elenext.hasClass('isotope-hidden')) {
  599. break;
  600. }
  601. elenext = $(elenext).next();
  602. }
  603. nextlink = $($(elenext).find('a').get(0)).attr('href');
  604. }
  605.  
  606. $this.find('.item-prev').parent().attr('href' , prevlink);
  607. $this.find('.item-next').parent().attr('href' , nextlink);
  608.  
  609. show_next_prev_popup($this);
  610.  
  611. return {
  612. next : nextlink,
  613. prev : prevlink
  614. };
  615. /** find prev link end **/
  616. };
  617.  
  618. // this clicked item
  619. var contentLoaded = function($this, firstLoaded, title, type)
  620. {
  621. var ele = itemDetailElement($this);
  622.  
  623. /** close previous opened section **/
  624. if(lastclicked != undefined) {
  625. closePrev(false);
  626. }
  627.  
  628. $this.animate({
  629. width: itemWidth,
  630. height: itemHeight
  631. }, 400, function () {
  632. /** hide item wrapper **/
  633. $(ele.itemWrapper).hide();
  634.  
  635. /** bind close me button **/
  636. $(ele.closeme).show().bind("click", function(){
  637. closePrev(true);
  638. });
  639.  
  640. /** add class unfolded **/
  641. $this.addClass("unfolded");
  642.  
  643. /** find prev link start **/
  644. var nextprev = get_next_prev($this);
  645. $this.find('.item-prev').parent().attr('href' , nextprev.prev);
  646. $this.find('.item-next').parent().attr('href' , nextprev.next);
  647. /** find prev link end **/
  648.  
  649. var builditemdetail = function () {
  650.  
  651. /** item gallery & description width & height **/
  652. $(ele.itemGallery).css('width', itemGalleryWidth).css('height', itemHeight);
  653. $(ele.itemDescription).css('width', itemDescriptionWidth);
  654.  
  655. /** show item detail **/
  656. $(ele.itemDetail).show().animate({opacity : '1' });
  657.  
  658. if(firstLoaded)
  659. {
  660. /** set title & type **/
  661. $this.attr('data-title' , title);
  662. $this.attr('data-type' , type);
  663.  
  664. /** assign scroll pane **/
  665. var width = ele.descWrapper.css('width');
  666.  
  667. // bug waktu back button
  668. var dww = itemDescriptionWidth - parseInt(ele.descWrapper.css('margin-left'), 10) - parseInt(ele.descWrapper.css('margin-right'), 10);
  669.  
  670. $(ele.descWrapper).css({
  671. height : (itemHeight - 50),
  672. width : dww
  673. }).jScrollPane();
  674.  
  675. switch(type) {
  676. case "gallery" :
  677. setTimeout(function(){
  678. type_gallery(ele);
  679. }, 1000);
  680. break;
  681. case "image" :
  682. type_image(ele);
  683. break;
  684. case "video" :
  685. type_video(ele);
  686. break;
  687. case "youtube" :
  688. type_video_youtube(ele);
  689. break;
  690. case "vimeo" :
  691. type_video_vimeo(ele);
  692. break;
  693. case "audio" :
  694. type_audio(ele);
  695. break;
  696. default :
  697. break;
  698. }
  699. }
  700.  
  701. /** title **/
  702. document.title = title.unescapeHtml() + " - " + doctitle.unescapeHtml() ;
  703.  
  704. // relase lock
  705. lockClick = false;
  706.  
  707. /** animate item to scroll **/
  708. setTimeout(function(){
  709. $("html, body").animate({
  710. scrollTop: $this.offset().top - options.scrolltop
  711. }, 500, function(){
  712. // cache last clicked object
  713. lastclicked = {
  714. i : $this,
  715. t : type
  716. };
  717.  
  718. setTimeout(function()
  719. {
  720. var hash = location.hash.replace("#/", "");
  721. var hashres = hash.split(':');
  722. var openlarge = hashres[1];
  723.  
  724. if(openlarge != undefined) {
  725. (function(PhotoSwipe){
  726. $(PhotoSwipe.instances[0].originalImages[openlarge]).trigger('click');
  727. }(window.Code.PhotoSwipe));
  728. }
  729. }, 500);
  730.  
  731. });
  732. }, 500);
  733. };
  734.  
  735. /** relayout isotope **/
  736. $container.isotope("reLayout", function (e) {
  737. builditemdetail();
  738. });
  739. });
  740. };
  741.  
  742. var itemDetailElement = function($this)
  743. {
  744. return {
  745. me : $this,
  746. shadow : $this.find('.shadow'),
  747. itemWrapper : $this.find('.item-wrapper'),
  748. closeme : $this.find('.closeme'),
  749. itemDetail : $this.find('.item-detail'),
  750. itemGallery : $this.find('.item-gallery'),
  751. itemDescription : $this.find('.item-description'),
  752. descWrapper : $this.find('.item-desc-wrapper')
  753. };
  754. };
  755.  
  756. var closePrev = function (changeLocation)
  757. {
  758. /* revert title */
  759. document.title = doctitle.unescapeHtml();
  760.  
  761. if(lastclicked === undefined) {
  762. return false;
  763. }
  764.  
  765. var i = lastclicked.i;
  766.  
  767. $(i).find('.item-detail').animate({ // hide item detail
  768. opacity : 0
  769. }, 100).hide();
  770.  
  771. var wh = {
  772. width : $(i).attr('data-width') ,
  773. height : $(i).attr('data-height')
  774. };
  775.  
  776. $(i).animate(wh, 'fast', function(){
  777. $(i).find('.closeme').hide(); // hide close me button
  778. $(i).find('.item-wrapper').show('fast'); // show item wrapper (summary)
  779. $(i).removeClass('unfolded'); // remove class unfolded
  780. $(i).find('.item-detail').remove(); // destroy item detail, we really need this to simplify code & prevent lag when many item loaded
  781.  
  782. // normalize item
  783. $(i).find('.desc-holder').css({'bottom' : 0}).find('i').removeClass('display-inline-table');
  784. $(i).find('.shadow').removeClass("shadowload").height('0'); // remove white shadow on item
  785.  
  786. lastclicked = undefined;
  787. $container.isotope("reLayout");
  788. });
  789.  
  790. if(changeLocation) {
  791. window.location = "#/";
  792. }
  793. };
  794.  
  795. var show_loader = function($this)
  796. {
  797. // @todo : show small-loader
  798. var loader = $this.find('.small-loader');
  799. var loaderWidth = $(loader).width();
  800. var loaderHeight = $(loader).height();
  801. var thisWidth = $this.width();
  802. var thisHeight = $this.height();
  803. var postX = ( thisWidth / 2 ) - (loaderWidth / 2);
  804. var postY = ( thisHeight / 2 ) - (loaderHeight / 2);
  805.  
  806. $this.find('.small-loader').show().css('margin-left', postX).css('margin-top', postY);
  807. };
  808.  
  809. var hide_loader = function($this)
  810. {
  811. $this.find('.small-loader').hide();
  812. };
  813.  
  814. var clicked = function($this)
  815. {
  816. if(lockClick) {
  817. return ;
  818. }
  819. else {
  820. lockClick = true; // lock click
  821.  
  822. /** show shadow load **/
  823. $this.find('.shadow').addClass('shadowload');
  824.  
  825. /** save current width & height **/
  826. $this.attr('data-width', $this.width());
  827. $this.attr('data-height', $this.height());
  828.  
  829. /** if item not exist yet, then we should call ajax and append content **/
  830. if($this.find('.item-detail').length <= 0) {
  831.  
  832. /** show loader **/
  833. show_loader($this);
  834.  
  835. var ajaxdata = {
  836. id : $this.attr('data-id'),
  837. width : itemGalleryWidth,
  838. height : Math.floor(itemHeight),
  839. theater : options.theatherMode,
  840. action : 'get_portfolio_item'
  841. };
  842.  
  843. if(options.theatherMode) {
  844. if(lastclicked != undefined) {
  845. var i = $("#item-theater-overlay");
  846. var id = $(".item-detail", i);
  847. theatherClose(i, id, false);
  848. }
  849. }
  850.  
  851. var showPasswordForm = function (status) {
  852. if(!$(".portopwd").length) {
  853. // create password form
  854. var pwdtxt = '<div class="portopwd">' +
  855. '<div class="portopwd-wrapper">' +
  856. '<h2>' + options.lang.portfoliotitle + ' </h2> ' +
  857. '<div>' +
  858. '<input type="password" class="pwdtxt" placeholder="' + options.lang.passwordplaceholder + '"/>' +
  859. '<button href="#" class="btn btn-inverse pwdbtn">' + options.lang.submit + '</button>' +
  860. '</div>' +
  861. '<div class="pwderr"></div>' +
  862. '<div alt="Close" class="pwdcls" style="display: block;">' +
  863. '<div class="icon-remove icon-white"></div>' +
  864. '</div>' +
  865. '</div>' +
  866. '</div>';
  867. $('body').append(pwdtxt);
  868. }
  869.  
  870. $(".pwdcls").click(function(){
  871. $this.find('.small-loader').hide();
  872. $(".portopwd").remove();
  873. window.location = "#/";
  874. lockClick = false;
  875. $this.find('.shadow').removeClass("shadowload");
  876. });
  877.  
  878. var submitpwdform = function () {
  879. ajaxdata.password = $(".pwdtxt").val();
  880. $(".portopwd").remove();
  881. loadData();
  882. };
  883.  
  884. $(".pwdtxt").keypress(function(e){
  885. if(e.which == 13){
  886. submitpwdform();
  887. }
  888. });
  889.  
  890. $(".pwdbtn").click(function(){
  891. submitpwdform();
  892. });
  893. };
  894.  
  895. var attach_social = function ()
  896. {
  897. var imageurl;
  898.  
  899. if(options.theatherMode) {
  900. imageurl = $("#item-theater-overlay").find('.item-detail').attr('data-cover');
  901. } else {
  902. imageurl = $this.find('.item-detail').attr('data-cover');
  903. }
  904.  
  905. $('#twitter').sharrre({
  906. share: {
  907. twitter: true
  908. },
  909. template: '<div class="box" href="#"><div class="count" href="#">{total}</div><div class="share"><span class="social-twitter"></span></div></div>',
  910. enableHover: false,
  911. enableTracking: true,
  912. buttons: { twitter: {}},
  913. click: function(api, options){
  914. api.simulateClick();
  915. api.openPopup('twitter');
  916. }
  917. });
  918. $('#facebook').sharrre({
  919. share: {
  920. facebook: true
  921. },
  922. template: '<div class="box" href="#"><div class="count" href="#">{total}</div><div class="share"><span class="social-facebook"></span></div></div>',
  923. enableHover: false,
  924. enableTracking: true,
  925. click: function(api, options){
  926. api.simulateClick();
  927. api.openPopup('facebook');
  928. }
  929. });
  930. $('#googleplus').sharrre({
  931. share: {
  932. googlePlus: true
  933. },
  934. template: '<div class="box" href="#"><div class="count" href="#">{total}</div><div class="share"><span class="social-gplust"></span></div></div>',
  935. enableHover: false,
  936. enableTracking: true,
  937. urlCurl: '',
  938. click: function(api, options){
  939. api.simulateClick();
  940. api.openPopup('googlePlus');
  941. }
  942. });
  943. $('#pinterest').sharrre({
  944. share: {
  945. pinterest: true
  946. },
  947. template: '<div class="box" href="#" rel="nofollow"><div class="count" href="#">{total}</div><div class="share"><span class="social-pinterest"></span></div></div>',
  948. enableHover: false,
  949. enableTracking: true,
  950. buttons: {
  951. pinterest: {
  952. media : imageurl
  953. }
  954. },
  955. click: function(api, options){
  956. api.simulateClick();
  957. api.openPopup('pinterest');
  958. }
  959. });
  960. };
  961.  
  962. var showData = function (data) {
  963. $this.find('.small-loader').hide();
  964.  
  965. // mute player when selected content is music / video
  966. if(data.type == "video" || data.type == "youtube" ||
  967. data.type == "vimeo" || data.type == "audio") {
  968. muteplayer();
  969. } else {
  970. unmuteplayer();
  971. }
  972.  
  973. if(options.theatherMode) {
  974. $("#item-theater-detail").append(data.content);
  975. contentTheater($this, data.title, data.type, data.love, data.voted);
  976. } else {
  977. $this.append(data.content);
  978. contentLoaded($this, true, data.title, data.type);
  979. }
  980.  
  981. /** now we attach social like **/
  982. attach_social();
  983.  
  984. /** hide loader **/
  985. hide_loader($this);
  986. };
  987.  
  988. var loadData = function() {
  989. $.ajax({
  990. url: admin_url,
  991. type : "post",
  992. dataType : "json",
  993. data : ajaxdata,
  994. success: function(data) {
  995. if(data.status == 1) {
  996. // data loaded successfully
  997. showData(data);
  998. } else if (data.status == 2) {
  999. // need password
  1000. showPasswordForm(0);
  1001. } else if (data.status == 3) {
  1002. // invalid password
  1003. showPasswordForm(1);
  1004. } else if (data.status == 4) {
  1005. // wrong post format
  1006. }
  1007.  
  1008. }
  1009. });
  1010. };
  1011.  
  1012. /** load data from admin **/
  1013. loadData();
  1014.  
  1015. } else {
  1016. // untuk sementara waktu ga bakal pernah dipake
  1017. // contentLoaded($this, false, $this.attr('data-title'), $this.attr('data-type'));
  1018. }
  1019. }
  1020. };
  1021.  
  1022. /** use css instead js positioning **/
  1023. var rearrange_filter = function() {};
  1024. var rearange_media_query = function () {};
  1025.  
  1026. var loadmorefunction = function(loadhash, showloadingbutton)
  1027. {
  1028. var loading = $(".load-more-button").attr('data-loading');
  1029. var loadmore = $(".load-more-button").attr('data-more');
  1030. var category = $(".load-more-button").attr('data-category');
  1031. filterunlocked = false;
  1032.  
  1033. if(loadhash == false) {
  1034. window.location = "#/";
  1035. }
  1036.  
  1037. if(showloadingbutton) {
  1038. $(".load-more-button").text(loading).addClass('load-active').fadeIn();
  1039. } else {
  1040. $(".load-more-button").fadeOut();
  1041. }
  1042.  
  1043. var ajaxdata = {
  1044. id : options.postid,
  1045. page : $(".load-more-button").attr('data-page'),
  1046. cat : category,
  1047. action : 'portfolio_load_more'
  1048. };
  1049.  
  1050. $.ajax({
  1051. url: admin_url,
  1052. type : "post",
  1053. dataType : "json",
  1054. data : ajaxdata,
  1055. success: function(data) {
  1056. var $newEls = $(data.html);
  1057.  
  1058. // override visiable style nya disini
  1059.  
  1060. /*
  1061. $container.isotope({
  1062. visibleStyle : { opacity : 0 }
  1063. });
  1064. */
  1065.  
  1066. $container.append( $newEls );
  1067.  
  1068. $container.imagesLoaded(function(){
  1069. $('.lio-loader').fadeOut('fast');
  1070.  
  1071. $container.isotope( 'appended', $newEls, function(){
  1072. animload("seqfade");
  1073. });
  1074.  
  1075. if(data.totalpage >= data.pagenext) {
  1076. var morepage = ( data.totalpage - data.pagenext ) + 1;
  1077. $(".load-more-button").text( morepage + loadmore).removeClass('load-active').attr('data-page', data.pagenext).fadeIn();
  1078. } else {
  1079. $(".load-more-button").fadeOut("slow");
  1080. }
  1081.  
  1082. if(loadhash == true && data.totalpage >= ( data.pagenext - 1 )) {
  1083. // on last page we need to check if item is exist
  1084. if(data.totalpage < data.pagenext ) {
  1085. var hash = location.hash.replace("#/", "");
  1086. var element = findElement(hash);
  1087.  
  1088. if(element != undefined) {
  1089. winhash();
  1090. }
  1091. } else {
  1092. winhash("loadmorefunction");
  1093. }
  1094. }
  1095. filterunlocked = true;
  1096. }, function(){});
  1097. }
  1098. });
  1099. };
  1100.  
  1101. $container.imagesLoaded( function($images, $proper, $broken)
  1102. {
  1103. // close loader & show filter
  1104. $('.lio-loader').fadeOut('fast');
  1105.  
  1106. // build isotope
  1107. $container.isotope({
  1108. animationEngine: "jquery",
  1109. itemSelector: ".item",
  1110. masonry: {
  1111. columnWidth: 1
  1112. }
  1113. });
  1114.  
  1115. bindlovethis($container);
  1116.  
  1117. /** run window resize when image loaded to prevent bug **/
  1118. jWindowResize(false);
  1119.  
  1120. /** then show image **/
  1121. animload(options.loadAnimation);
  1122.  
  1123. setTimeout(function(){
  1124. $(window).hashchange();
  1125. }, 500);
  1126. });
  1127.  
  1128. var executeFirstTimer = 0;
  1129.  
  1130. // normal | fade | seqfade | upfade | sequpfade | randomfade | randomupfade
  1131. var animload = function(animation){
  1132.  
  1133. var exebinwait = 200;
  1134. var loadfilter = 200;
  1135.  
  1136. // perlu begini nih biar ga keluar bug di firefox
  1137. $container.find('.item.notloaded').each(function(){
  1138. $(this).css({"opacity" : 0});
  1139. });
  1140.  
  1141. if(animation == "normal") {
  1142. $container.find('.item.notloaded').each(function(){
  1143. $(this).css({"opacity": 1}).removeClass('notloaded');
  1144. });
  1145. } else if(animation == "fade"){
  1146.  
  1147. $container.find('.item.notloaded').each(function(){
  1148. $(this).stop().animate({
  1149. "opacity" : 1
  1150. }, "fast").removeClass('notloaded');
  1151. });
  1152.  
  1153. loadfilter = "slow";
  1154.  
  1155. } else if(animation == "seqfade"){
  1156.  
  1157. $container.find('.item.notloaded').each(function(i){
  1158. var element = $(this);
  1159. setTimeout(function() {
  1160. $(element).show().stop().animate({
  1161. "opacity" : 1
  1162. }, "fast").removeClass('notloaded');
  1163. }, 100 + i * 100);
  1164. });
  1165.  
  1166. loadfilter = 1000;
  1167. exebinwait = 400 + $container.find('.item').length * 100;
  1168.  
  1169. } else if(animation == "upfade"){
  1170.  
  1171. // setup item
  1172. setuptop();
  1173.  
  1174. $container.find('.item.notloaded').each(function(i){
  1175. var element = $(this);
  1176. $(element).stop().animate({
  1177. top : parseInt($(element).css('top'),10)- ( $(element).height() / 2),
  1178. opacity : 1
  1179. }, 1000).removeClass('notloaded');
  1180. });
  1181.  
  1182. loadfilter = 2000;
  1183. exebinwait = 1200;
  1184.  
  1185. } else if(animation == "sequpfade"){
  1186.  
  1187. // setup item
  1188. setuptop();
  1189.  
  1190. $container.find('.item.notloaded').each(function(i){
  1191. var element = $(this);
  1192. setTimeout(function() {
  1193. $(element).stop().animate({
  1194. top : parseInt($(element).css('top'),10)- ( $(element).height() / 2),
  1195. opacity : 1
  1196. }, 300).removeClass("notloaded");
  1197. }, 100 + i * 100);
  1198. });
  1199.  
  1200. loadfilter = 2000;
  1201. exebinwait = 400 + $container.find('.item').length * 100;
  1202.  
  1203. } else if(animation == "randomfade"){
  1204.  
  1205. var shufflearray = shuffleitem();
  1206.  
  1207. for(var i = 0; i < shufflearray.length ; i++){
  1208. setTimeout(function() {
  1209. var element = shufflearray.pop();
  1210. $(element).stop().animate({
  1211. "opacity" : 1
  1212. }, 200).removeClass('notloaded');
  1213. }, 75 + i * 75);
  1214. }
  1215.  
  1216. loadfilter = 2000;
  1217. exebinwait = 100 + $container.find('.item').length * 100;
  1218.  
  1219. } else if(animation == "randomupfade"){
  1220.  
  1221. var shufflearray = shuffleitem();
  1222. setuptop();
  1223.  
  1224. for(var i = 0; i < shufflearray.length ; i++){
  1225. setTimeout(function() {
  1226. var element = shufflearray.pop();
  1227. $(element).stop().animate({
  1228. top : parseInt($(element).css('top'),10)- ( $(element).height() / 2),
  1229. opacity : 1
  1230. }, 300).removeClass('notloaded');
  1231. }, 75 + i * 75);
  1232. }
  1233.  
  1234. loadfilter = 2000;
  1235. exebinwait = 100 + $container.find('.item').length * 100;
  1236.  
  1237. }
  1238.  
  1239. // load filter & load more button
  1240. if(executeFirstTimer == 0) {
  1241. $('#liofilter').fadeIn(loadfilter);
  1242.  
  1243. if(!$('.load-more-button').hasClass("nofirstload")) {
  1244. $('.load-more-button').fadeIn(loadfilter);
  1245. }
  1246.  
  1247. // than execute bin hash
  1248. setTimeout(function(){
  1249. executeBindHash();
  1250. }, exebinwait);
  1251.  
  1252. executeFirstTimer ++;
  1253. }
  1254.  
  1255. setTimeout(function(){
  1256. $container.isotope("reLayout");
  1257. }, ( exebinwait + 1000 ));
  1258.  
  1259. $container.find('.item').each(function(){
  1260. $(this).hover(hovered,unhovered);
  1261. });
  1262. };
  1263.  
  1264. var executeBindHash = function(){
  1265. // execute bind hash cuman sampe 1x doang ya
  1266. setTimeout(function(){
  1267. bindhashchange();
  1268. winhash("executeBindHash");
  1269. }, 300);
  1270. };
  1271.  
  1272. var setuptop = function () {
  1273. // setup item
  1274. $container.find('.item.notloaded').each(function(i){
  1275. var $item = $(this),
  1276. t = parseInt($item.css('top'),10) + ( $item.height() / 2);
  1277. $item.css({
  1278. top : t + 'px',
  1279. opacity : 0
  1280. });
  1281. });
  1282. };
  1283.  
  1284. var shuffleitem = function() {
  1285. var shufflearray = new Array();
  1286. $container.find('.item.notloaded').each(function(i){ shufflearray[i] = $(this); });
  1287. shufflearray.sort(function(){return Math.round(Math.random());});
  1288. return shufflearray;
  1289. };
  1290.  
  1291. var calc_theather = function (){
  1292. var ww = $(window).width() - 50;
  1293. var wh = $(window).height() - $("header").height() - $("footer").height() - 50;
  1294.  
  1295. var theatherdim = {};
  1296.  
  1297. if($(window).width() > $(window).height()) {
  1298. var ratio = 11 / 5;
  1299. } else {
  1300. var ratio = 6/5;
  1301. }
  1302.  
  1303. if( ( ww / ratio ) < wh ) {
  1304. // use ww as base
  1305. theatherdim.w = ww;
  1306. theatherdim.h = ww / ratio;
  1307. } else {
  1308. // use wh as base
  1309. theatherdim.h = wh;
  1310. theatherdim.w = wh * ratio;
  1311. }
  1312.  
  1313. theatherdim.topPos = ( $(window).height() - $("header").height() - $("footer").height() - theatherdim.h ) / 2 + $("header").height();
  1314. theatherdim.leftPos = ( $(window).width() - theatherdim.w ) / 2;
  1315.  
  1316. theatherdim.descriptionWidth = theatherdim.w * 0.2;
  1317. theatherdim.descriptionWidth = ( theatherdim.descriptionWidth < 200 ) ? 200 : theatherdim.descriptionWidth;
  1318. theatherdim.galleryWidth = theatherdim.w - theatherdim.descriptionWidth;
  1319.  
  1320. if(options.descDim == 0) {
  1321. theatherdim.galleryWidth = theatherdim.w;
  1322. theatherdim.descriptionWidth = 0;
  1323. }
  1324.  
  1325. return theatherdim;
  1326. };
  1327.  
  1328.  
  1329. // detect only window width change
  1330. var winwidth = $(window).width(), winheight = $(window).height();
  1331. $(window).resize(function() {
  1332. if(this.resizeTo) clearTimeout(this.resizeTo);
  1333. this.resizeTo = setTimeout(function() {
  1334. if(winwidth != $(window).width()) {
  1335. winwidth = $(window).width();
  1336. $(this).trigger("windowWidthResize");
  1337. }
  1338.  
  1339. if(winheight != $(window).height()) {
  1340. $(this).trigger("windowHeightResize");
  1341. }
  1342. }, 250);
  1343. });
  1344.  
  1345.  
  1346. var windowWidthChange = function ()
  1347. {
  1348. if(options.theatherMode) {
  1349.  
  1350. if(lastclicked != undefined) {
  1351. var cachelastClick = lastclicked;
  1352.  
  1353. var i = $("#item-theater-overlay");
  1354. var id = $(".item-detail", i);
  1355. theatherClose(i, id, true);
  1356.  
  1357. // than reopen last clicked item
  1358. //console.log(cachelastClick);
  1359. // clicked(cachelastClick.i);
  1360. }
  1361. }
  1362. };
  1363.  
  1364. var windowHeightChange = function ()
  1365. {
  1366.  
  1367. };
  1368.  
  1369. /** then when image resize, we do this! **/
  1370. var jWindowResize = function(relayout)
  1371. {
  1372. var windowWidth = $(window).width();
  1373.  
  1374. var item = $container.find('.item').get(0);
  1375. var imb = parseInt($(item).css('margin-bottom'), 10);
  1376. var iml = parseInt($(item).css('margin-left'), 10);
  1377.  
  1378. iw = options.itemWidth;
  1379.  
  1380. if(options.theatherMode) {
  1381. var theaterdim = calc_theather();
  1382.  
  1383. itemWidth = theaterdim.w;
  1384. itemHeight = theaterdim.h;
  1385.  
  1386. itemDescriptionWidth = theaterdim.descriptionWidth;
  1387. itemGalleryWidth = theaterdim.galleryWidth;
  1388.  
  1389. itemTopPos = theaterdim.topPos;
  1390. itemLeftPos = theaterdim.leftPos;
  1391. } else {
  1392.  
  1393. if(options.themes_schema == "light") {
  1394. itemGalleryWidth = ( iw * galleryDim ) + iml * (galleryDim - 1);
  1395. itemDescriptionWidth = ( iw * descDim ) + ( iml * descDim );
  1396. } else {
  1397. itemGalleryWidth = ( iw * galleryDim ) + iml * (galleryDim - 1) + ( 6 * galleryDim ) - 3;
  1398. itemDescriptionWidth = ( iw * descDim ) + ( iml * descDim ) + ( 6 * descDim ) - 3;
  1399. }
  1400.  
  1401. for(var i = (galleryDim + descDim); i > 1 ; i--) {
  1402. if(options.themes_schema == "light") {
  1403. var tempWidth = ( iw * i ) + ( iml * i ) - iml;
  1404. } else {
  1405. var tempWidth = ( iw * i ) + ( iml * i ) - iml + (6 * (i - 1 )) ;
  1406. }
  1407. if(tempWidth + 10 <= windowWidth){
  1408. itemWidth = tempWidth;
  1409. itemHeight = options.itemHeightWide ;
  1410. break;
  1411. }
  1412. }
  1413. }
  1414.  
  1415. if(relayout) {
  1416. // console.log("Execute window resize with relayout");
  1417. $container.isotope("reLayout");
  1418. } else {
  1419. // console.log("Execute window resize without relayout");
  1420. }
  1421. };
  1422.  
  1423. var closeAllMode = function () {
  1424. if(options.theatherMode) {
  1425. var i = $("#item-theater-overlay");
  1426. var id = $(".item-detail", i);
  1427. theatherClose(i, id, false);
  1428. } else {
  1429. closePrev();
  1430. }
  1431. };
  1432.  
  1433. var findElement = function(hash)
  1434. {
  1435. for(var i = 0; i < $('.item').length ; i++) {
  1436. var item = $('.item').get(i);
  1437. if(hash == $(item).attr('data-url')) {
  1438. return $(item);
  1439. }
  1440. }
  1441. };
  1442.  
  1443. var hidePhotoswipe = function()
  1444. {
  1445. if(window.Code.PhotoSwipe.activeInstances[0] == undefined) {
  1446. // console.log("photoswipe is undefined");
  1447. } else {
  1448. window.Code.PhotoSwipe.activeInstances[0].instance.hide(0);
  1449. }
  1450. };
  1451.  
  1452. var winhash = function(echome){
  1453. var hash = location.hash.replace("#/", "");
  1454. var hashres = hash.split(':');
  1455. hash = hashres[0];
  1456.  
  1457. if(hash === "" || hash == "#") {
  1458. closeAllMode();
  1459. unmuteplayer();
  1460. } else {
  1461. var element = findElement(hash);
  1462.  
  1463. if(element == undefined && options.use_pagging == 1) {
  1464. setTimeout(function(){
  1465. loadmorefunctionhub(true, true);
  1466. }, 500);
  1467. } else {
  1468. if(scw(mediaquerywidth)) {
  1469. if(element) {
  1470. setTimeout(function(){
  1471. if(!options.theatherMode) {
  1472. setTimeout(function(){
  1473. $("html, body").animate({
  1474. scrollTop: $(element).offset().top - options.scrolltop
  1475. });
  1476. }, 500);
  1477. }
  1478. clicked(element);
  1479. }, 200);
  1480. }
  1481. } else {
  1482. // buka page baru
  1483. var url = element.attr('data-src');
  1484. tourl(url, true);
  1485. }
  1486. hidePhotoswipe();
  1487. }
  1488. }
  1489. };
  1490.  
  1491. var filterunlocked = true;
  1492.  
  1493. /** filter **/
  1494. $("#liofilter .apply-filter").click(function(){
  1495. if(filterunlocked) {
  1496. $("#liofilter .apply-filter").removeClass("filter-select");
  1497. var selector = $(this).attr("data-filter");
  1498. $(this).addClass("filter-select");
  1499.  
  1500. if(options.use_pagging == 0) {
  1501. closePrev(true);
  1502. $container.isotope({filter : selector});
  1503. } else {
  1504. var category = $(this).attr('data-filter').replace(".", "").replace("*", "");
  1505. $(".load-more-button").attr('data-category', category ).attr('data-page',1);
  1506. var $el = $("#jeglio > .item").get().reverse();
  1507.  
  1508. $($el).animate({
  1509. opacity : 0
  1510. }, 200, function(){
  1511. $container.isotope( 'remove', $(this));
  1512. $(this).remove();
  1513. });
  1514. $('.lio-loader').fadeIn('fast');
  1515. loadmorefunctionhub(false, false);
  1516. }
  1517. }
  1518. return false;
  1519. });
  1520.  
  1521. /** show loader **/
  1522. $('.lio-loader').fadeIn('fast');
  1523.  
  1524. /** bind hash change & resize **/
  1525. var bindhashchange = function() {
  1526. $(window).bind('hashchange', function(){ winhash("bindhashchange"); });
  1527. };
  1528.  
  1529. $(window).bind('resize', function(){
  1530. if(!firstloaded) {
  1531. jWindowResize(true);
  1532. } else {
  1533. jWindowResize(false);
  1534. }
  1535. firstloaded = false;
  1536. });
  1537.  
  1538. $(window).bind('windowWidthResize', function(){ windowWidthChange(); });
  1539. $(window).bind('windowHeightResize', function(){ windowHeightChange(); });
  1540.  
  1541. var loadmorefunctionhub = function (loadhash, showloadingbutton) {
  1542. if(filterunlocked) {
  1543. loadmorefunction(loadhash, showloadingbutton);
  1544. }
  1545. };
  1546.  
  1547. $(".load-more-button").click(function(){
  1548. loadmorefunctionhub(false, true);
  1549. });
  1550.  
  1551.  
  1552. /** unbind window resize sama hashchange saat #main ke destroy **/
  1553. $(window).bind("jmainremove", function(){
  1554. $(window).unbind('hashchange');
  1555. $(window).unbind('resize');
  1556. $("html").css("overflow-y", "auto");
  1557. delete $.fn.jeglio;
  1558. });
  1559. };
  1560. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment