PageSourceSearch

https://ravitzfamilymarkets.com/wp-content/plugins/post-timeline/public/js/post-timeline.js?ver=2.1.9

js ravitzfamilymarkets.com collected 2026-10-10 02:16:39 UTC 42,071 bytes, 1,131 lines download raw bytes

vendor: 4,371 bytes, lines 1-7
1/*!
2 * imagesLoaded PACKAGED v4.1.4
3 * JavaScript is all like "You images are done yet or what?"
4 * MIT License
5 */
6
7!function(e,t){"function"==typeof define&&define.amd?define("ev-emitter/ev-emitter",t):"object"==typeof module&&module.exports?module.exports=t():e.EvEmitter=t()}("undefined"!=typeof window?window:this,function(){function e(){}var t=e.prototype;return t.on=function(e,t){if(e&&t){var i=this._events=this._events||{},n=i[e]=i[e]||[];return n.indexOf(t)==-1&&n.push(t),this}},t.once=function(e,t){if(e&&t){this.on(e,t);var i=this._onceEvents=this._onceEvents||{},n=i[e]=i[e]||{};return n[t]=!0,this}},t.off=function(e,t){var i=this._events&&this._events[e];if(i&&i.length){var n=i.indexOf(t);return n!=-1&&i.splice(n,1),this}},t.emitEvent=function(e,t){var i=this._events&&this._events[e];if(i&&i.length){i=i.slice(0),t=t||[];for(var n=this._onceEvents&&this._onceEvents[e],o=0;o<i.length;o++){var r=i[o],s=n&&n[r];s&&(this.off(e,r),delete n[r]),r.apply(this,t)}return this}},t.allOff=function(){delete this._events,delete this._onceEvents},e}),function(e,t){"use strict";"function"==typeof define&&define.amd?define(["ev-emitter/ev-emitter"],function(i){return t(e,i)}):"object"==typeof module&&module.exports?module.exports=t(e,require("ev-emitter")):e.imagesLoaded=t(e,e.EvEmitter)}("undefined"!=typeof window?window:this,function(e,t){function i(e,t){for(var i in t)e[i]=t[i];return e}function n(e){if(Array.isArray(e))return e;var t="object"==typeof e&&"number"==typeof e.length;return t?d.call(e):[e]}function o(e,t,r){if(!(this instanceof o))return new o(e,t,r);var s=e;return"string"==typeof e&&(s=document.querySelectorAll(e)),s?(this.elements=n(s),this.options=i({},this.options),"function"==typeof t?r=t:i(this.options,t),r&&this.on("always",r),this.getImages(),h&&(this.jqDeferred=new h.Deferred),void setTimeout(this.check.bind(this))):void a.error("Bad element for imagesLoaded "+(s||e))}function r(e){this.img=e}function s(e,t){this.url=e,this.element=t,this.img=new Image}var h=e.jQuery,a=e.console,d=Array.prototype.slice;o.prototype=Object.create(t.prototype),o.prototype.options={},o.prototype.getImages=function(){this.images=[],this.elements.forEach(this.addElementImages,this)},o.prototype.addElementImages=function(e){"IMG"==e.nodeName&&this.addImage(e),this.options.background===!0&&this.addElementBackgroundImages(e);var t=e.nodeType;if(t&&u[t]){for(var i=e.querySelectorAll("img"),n=0;n<i.length;n++){var o=i[n];this.addImage(o)}if("string"==typeof this.options.background){var r=e.querySelectorAll(this.options.background);for(n=0;n<r.length;n++){var s=r[n];this.addElementBackgroundImages(s)}}}};var u={1:!0,9:!0,11:!0};return o.prototype.addElementBackgroundImages=function(e){var t=getComputedStyle(e);if(t)for(var i=/url\((['"])?(.*?)\1\)/gi,n=i.exec(t.backgroundImage);null!==n;){var o=n&&n[2];o&&this.addBackground(o,e),n=i.exec(t.backgroundImage)}},o.prototype.addImage=function(e){var t=new r(e);this.images.push(t)},o.prototype.addBackground=function(e,t){var i=new s(e,t);this.images.push(i)},o.prototype.check=function(){function e(e,i,n){setTimeout(function(){t.progress(e,i,n)})}var t=this;return this.progressedCount=0,this.hasAnyBroken=!1,this.images.length?void this.images.forEach(function(t){t.once("progress",e),t.check()}):void this.complete()},o.prototype.progress=function(e,t,i){this.progressedCount++,this.hasAnyBroken=this.hasAnyBroken||!e.isLoaded,this.emitEvent("progress",[this,e,t]),this.jqDeferred&&this.jqDeferred.notify&&this.jqDeferred.notify(this,e),this.progressedCount==this.images.length&&this.complete(),this.options.debug&&a&&a.log("progress: "+i,e,t)},o.prototype.complete=function(){var e=this.hasAnyBroken?"fail":"done";if(this.isComplete=!0,this.emitEvent(e,[this]),this.emitEvent("always",[this]),this.jqDeferred){var t=this.hasAnyBroken?"reject":"resolve";this.jqDeferred[t](this)}},r.prototype=Object.create(t.prototype),r.prototype.check=function(){var e=this.getIsImageComplete();return e?void this.confirm(0!==this.img.naturalWidth,"naturalWidth"):(this.proxyImage=new Image,this.proxyImage.addEventListener("load",this),this.proxyImage.addEventListener("error",this),this.img.addEventListener("load",this),this.img.addEventListener("error",this),void(this.proxyImage.src=this.img.src))},r.prototype.getIsImageComplete=function(){return this.img.complete&&this.img.naturalWi
7dth},r.prototype.confirm=function(e,t){this.isLoaded=e,this.emitEvent("progress",[this,this.img,t])},r.prototype.handleEvent=function(e){var t="on"+e.type;this[t]&&this[t](e)},r.prototype.onload=function(){this.confirm(!0,"onload"),this.unbindEvents()},r.prototype.onerror=function(){this.confirm(!1,"onerror"),this.unbindEvents()},r.prototype.unbindEvents=function(){this.proxyImage.removeEventListener("load",this),this.proxyImage.removeEventListener("error",this),this.img.removeEventListener("load",this),this.img.removeEventListener("error",this)},s.prototype=Object.create(r.prototype),s.prototype.check=function(){this.img.addEventListener("load",this),this.img.addEventListener("error",this),this.img.src=this.url;var e=this.getIsImageComplete();e&&(this.confirm(0!==this.img.naturalWidth,"naturalWidth"),this.unbindEvents())},s.prototype.unbindEvents=function(){this.img.removeEventListener("load",this),this.img.removeEventListener("error",this)},s.prototype.confirm=function(e,t){this.isLoaded=e,this.emitEvent("progress",[this,this.element,t])},o.makeJQueryPlugin=function(t){t=t||e.jQuery,t&&(h=t,h.fn.imagesLoaded=function(e,t){var i=new o(this,e,t);return i.jqDeferred.promise(h(this))})},o.makeJQueryPlugin(),o});
8
9
10(function( $ ) {
11
12  function getKeyByIndex(obj, index) {
13    var i = 0;
14
15    if(obj)
16      for (var attr in obj) {
17
18        if(obj.hasOwnProperty(atfhtr)) {
19
20            if (index === i){
21              return attr;
22            }
23            i++;
24        }
25      }
26    
27    return null;
28  };
29
30
31  $.fn.post_timeline = function(_options) {
32
33    var options = $.extend({},_options);
34
35
36    /////////////////////////
37    ///// Vertical Methods //
38    /////////////////////////
39    var ptl_navigation_vertical = {
40        initialize: function($_container) {
41
42            this.$cont = $_container;
43
44
45            var max_li = (_options.nav_max && !isNaN(_options.nav_max))?parseInt(_options.nav_max):6,
46                $cont  = $_container.find('.yr_list');
47
48            //set limit
49            if(max_li <= 2 || max_li > 15) {
50              max_li = 6;
51            }
52
53
54            var $cont_inner = $cont.find('.yr_list-inner'),
55                $cont_view  = $cont.find('.yr_list-view');
56
57            this.$cont_inner = $cont_inner;
58            var cin_height   = $cont_inner.height();
59            var $c_li        = $cont.find('.yr_list-inner li');
60            this.li_count    = $c_li.length; 
61
62            this.li_width        = cin_height / this.li_count; //pad
63            this.iterate_width   = this.li_width * max_li;
64            this.total_iterate   = Math.ceil(cin_height / this.iterate_width) - 1;
65            this.current_iterate = 0;
66
67            //NOT FOR PTL ADMIN
68            if(window['ptl_admin_pan'])
69              return;
70
71            //the iteration wrapper
72            var c_iterate = 0,
73                n_iterate = 0;
74            for(var i = 0; i <= this.total_iterate; i++) {
75
76              c_iterate  = i * max_li;
77              n_iterate += max_li;
78              var $temp_div = $c_li.slice(c_iterate,n_iterate).wrapAll('<div class="ptl-yr-list"/>');
79              if(i == 0) {
80                $temp_div.parent().addClass('ptl-active');
81              }
82            }
83
84            this.in_wrap_height = $('.ptl-yr-list.ptl-active').outerHeight();
85            this.iterate_width  = this.in_wrap_height;
86
87
88            this.btn_top     = $cont.find('.btn-top'),
89            this.btn_bottom  = $cont.find('.btn-bottom');
90            
91            if(this.li_count <= max_li) {
92
93                this.btn_top.hide();
94                this.btn_bottom.hide();
95            }
96            else{
97
98              this.btn_top.show();
99              this.btn_bottom.show();
100              $(this.btn_top).addClass('ptl-disabled');
101            }
102
103
104            var padding = 0;
105            $cont_view.height(((this.in_wrap_height) + padding)+ 'px');
106            //$cont_view.height(((max_li * this.li_width) + padding)+ 'px');
107            this.btn_top.unbind().bind('click',$.proxy(this.topArrow,this));
108            this.btn_bottom.unbind().bind('click',$.proxy(this.bottomArrow,this));
109        },
110        topArrow: function(e) {
111
112            var that = this;
113            if(this.current_iterate > 0) {
114
115                this.current_iterate--;
116
117                this.$cont_inner.find('.ptl-yr-list').eq(this.current_iterate).addClass('ptl-active');
118
119                //add disable
120                if(this.current_iterate == 0) {
121                    $(this.btn_top).addClass('ptl-disabled');
122                }
123                $(this.btn_bottom).removeClass('ptl-disabled');
124
125                var to_top =  -(this.current_iterate * this.iterate_width);
126
127                //console.log(this.current_iterate,'   ',to_left);
128                that.$cont_inner.find('.ptl-yr-list').eq(that.current_iterate + 1).removeClass('ptl-active');
129                this.$cont_inner.animate({'top':to_top+'px'},500,'swing',function(e) {
130
131                    //that.$cont_inner.find('.ptl-yr-list').eq(that.current_iterate + 1).removeClass('ptl-active');
132                    //console.log('===> post-timeline-public-display-12-h.php ===> 165 complete');
133                });
134            }
135        },
136        bottomArrow: function(e) {
137
138            var that = this;
139            if(this.current_iterate < this.total_iterate) {
140
141                this.current_iterate++;
142
143                this.$cont_inner.find('.ptl-yr-list').eq(this.current_iterate).addClass('ptl-active');
144
145                if(this.current_iterate == this.total_iterate) {
146                    $(this.btn_bottom).addClass('ptl-disabled');
147                }
148            
149                $(this.btn_top).removeClass('ptl-disabled');
150                  
151                var to_top =  -(this.current_iterate * this.iterate_width);
152
153                //console.log(this.current_iterate,'   ',to_left);
154                that.$cont_inner.find('.ptl-yr-list').eq(that.current_iterate - 1).removeClass('ptl-active');
155                this.$cont_inner.animate({'top':to_top+'px'},500,'swing',function(e) {
156                    //console.log('===> post-timeline-public-display-12-h.php ===> 165 complete');
157                    //that.$cont_inner.find('.ptl-yr-list').eq(that.current_iterate - 1).removeClass('ptl-active');
158                    //that.$cont_inner.find('.ptl-yr-list').eq(that.current_iterate - 1).removeClass('ptl-active');
159                });
160            }
161        },
162        //vertical
163        goTo: function(_iterate) {
164
165            var that = this;
166
167            var prev_iterate     = that.current_iterate;
168            that.current_iterate = _iterate;
169
170            //same iteration return
171            if(prev_iterate == that.current_iterate)return;
172
173
174            that.$cont_inner.find('.ptl-yr-list').eq(that.current_iterate).addClass('ptl-active');
175            that.$cont_inner.find('.ptl-yr-list').eq(prev_iterate).removeClass('ptl-active');
176            //that.$cont_inner.find('.ptl-yr-list').eq(prev_iterate).addClass('ptl-rem');
177
178            //add Disable
179            $(this.btn_top).removeClass('ptl-disabled');
180            $(this.btn_bottom).removeClass('ptl-disabled');
181
182            if(this.current_iterate == 0) {
183                $(this.btn_top).addClass('ptl-disabled');
184            }
185
186            if(this.current_iterate == this.total_iterate) {
187                $(this.btn_bottom).addClass('ptl-disabled');
188            }
189
190            var to_top = -(this.current_iterate * this.iterate_width);
191
192            //console.log('Goto Index: ',_iterate,' prev_iterate: '+prev_iterate,'current_iterate: '+this.current_iterate);
193
194
195            this.$cont_inner.animate({'top':to_top+'px'},500,'swing',function(e) {
196
197                //that.$cont_inner.find('.ptl-yr-list').eq(prev_iterate).removeClass('ptl-active');
198            });
199        },
200        //Update tags List
201        update_tags: function(_tag_list) {
202
203          var that  = this,
204              count = 0;
205
206          for(var y in _tag_list) {
207
208              if(_tag_list.hasOwnProperty(y)) {
209                
210                if(that.$cont_inner.find('li[data-tag="'+y+'"]').length == 0) {
211                  count++;
212                  that.$cont_inner.append('<li data-tag="'+y+'"><a data-scroll data-options=\'{ "easing": "Quart" }\'  data-href="#ptl-tag-'+y+'"><span>'+_tag_list[y]+'</span></a></li>');
213                }
214              }
215          }
216
217          //fix the tag list
218          if(count > 0) {
219
220              var _iterate = ptl_navigation_vertical.current_iterate;
221              that.$cont_inner.find('.ptl-yr-list li').unwrap();
222              ptl_navigation_vertical.initialize(ptl_navigation_vertical.$cont);
223
224              //make current iteration
225              ptl_navigation_vertical.current_iterate = _iterate;
226
227          }
228        }
229    };
230
231
232    var ptl_masonry_inst = null;
233
234    /**
235     * [add_masonry Add Masonry]
236     * @param {[type]} $container [description]
237     * @param {[type]} _options   [description]
238     */
239    var add_masonry = function($container,_options) {
240
241        //Add Masonry for limited templates
242        if(["3","7"].indexOf(_options.template) != -1) {
243
244          $container.find('.ptl-preloder').addClass('hide');
245          return;
246        }
247
248
249        var _callback = function() {
250          
251            $container.find('.timeline-box').removeClass('hide');
252
253            var params = {
254                childrenClass: 'timeline-box', // default is a div
255                //childrenClass: 'div:not(.ptl-h-box) > .timeline-box', // default is a div
256                columnClasses: 'padding', //add classes to items
257                breakpoints: {
258                  lg: 6, 
259                  md: 6, 
260                  sm: 12,
261                  xs: 12
262                },
263                distributeBy: { order: false, height: true , attr: 'data-order', attrOrder: 'asc' }, //default distribute by order, options => order: true/false, height: true/false, attr => 'data-order', attrOrder=> 'asc'/'desc'
264                onload: function (items) {
265                  //make somthing with items
266                } 
267            };
268            
269            if(_options.grid) {
270              params.breakpoints = _options.grid;
271            }
272
273            
274            ptl_masonry_inst = $container.find(".timeline-section:not(.ptl-mp-class)").ptlmansory(params);
275            ptl_masonry_inst.addClass('ptl-mp-class');
276
277            $container.find('.ptl-preloder').addClass('hide');
278        };
279
280        //Pre-load the Images
281        _callback();
282        /*
283        $container.imagesLoaded()
284        .always(_callback)
285        .done( function( instance ) {
286          console.log('all images successfully loaded');
287        })
288        .fail( function() {
289          console.log('all images loaded, at least one is broken');
290        });
291        */
292    };
293
294
295    /**
296     * [debounce description]
297     * @param  {[type]} func      [description]
298     * @param  {[type]} wait      [description]
299     * @param  {[type]} immediate [description]
300     * @return {[type]}           [description]
301     */
302    function debounce(func, wait, immediate) {
303      var timeout;
304      return function() {
305        var context = this, args = arguments;
306        var later = function() {
307          timeout = null;
308          if (!immediate) func.apply(context, args);
309        };
310        var callNow = immediate && !timeout;
311        clearTimeout(timeout);
312        timeout = setTimeout(later, wait);
313        if (callNow) func.apply(context, args);
314      };
315    };
316
317    /**
318     * [add_animation Add Animation]
319     * @param {[type]} _options [description]
320     * @param {[type]} $cont    [description]
321     */
322    var add_animation  = function(_options, $cont) {
323
324      _options.offset = _options.offset || 0;
325
326      //activate first li 
327      $cont.find('.yr_list li:first-child a').addClass('active');
328      var active_node = null;
329      
330      _options.scroller = _options.scroller || null;
331
332      var panim = new PTLAnim({
333          boxClass:     'panim', 
334          animateClass: 'animated',
335          scrollContainer: (window['ptl_admin_pan'])?'.modaal-wrapper':_options.scroller,
336          //scrollContainer: null,
337          offset:       _options.offset,
338          callbackloop: debounce(function(box) {
339
340            var _tag = $(box).data('tag');
341            
342
343            //console.log('===> post-timeline.js ===> 254',_tag);
344            if(_options.scrolling)return;
345
346            if(!active_node || _tag != active_node.data('tag')) {
347            
348              var $node = $cont.find('.yr_list li[data-tag="'+_tag+'"]');
349              active_node = $node;
350              $cont.find('.yr_list li a.active').removeClass('active');
351              $node.children(0).addClass('active');
352
353              //goto navigation
354              var _nav_index = $cont.find('.ptl-yr-list.ptl-active').index();
355              var _index = $node.parent().index();
356
357              
358              //console.log('_tag',_tag,'_nav_ind',_nav_index,'_index',_index);
359              
360              if(_nav_index != _index) {
361
362                ptl_navigation_vertical.goTo(_index);
363              }
364            }
365          }, 100)
366      });
367      window['panim'] = panim;  
368        
369      panim.init();
370      //console.log(panim.stop());
371    };
372
373
374    /**
375     * [add_more_buttom Add Load More]
376     * @param {[type]} $cont    [description]
377     * @param {[type]} _options [description]
378     */
379    var add_more_buttom = function($cont,_options) {
380
381      //Load More Button
382      $cont.find('.ptl-more-btn').bind('click', function (e) {
383
384          e.preventDefault();
385
386          var $that  = $(this),
387            page_url = PTL_REMOTE.ajax_url,
388            nextPage = parseInt($that.attr('data-page'), 10) + 1,
389            maxPages = parseInt($that.attr('data-max-pages'), 10);
390
391          $that.addClass('ptl-loading');
392
393          var last_index = $cont.find('.timeline-box:last-child').data('row');
394
395
396          var _params = _options;
397
398          /*
399          var _params = { 'paged':nextPage,'action':'ptl_load_posts','template':_options.template,
400                          'paginate':_options['ptl_post_load'],'per_page':_options['ptl-post-per-page'],
401                          'last': last_index
402                        };
403                        */
404
405          _params['paged']    = nextPage;
406          _params['last']     = last_index;
407          _params['action']   = 'ptl_load_posts';
408          _params['paginate'] = _options['ptl_post_load'];
409          _params['per_page'] = _options['ptl-post-per-page'];
410
411          //ajax request
412          $.get(page_url,_params,function(_response) {
413
414            $that.removeClass('ptl-loading');
415
416            var $new_resp = $('<output>').append($.parseHTML(_response.html));
417            
418            //new response
419            //var $new_resp = $.parseHTML(_response.html);
420            //var $new_resp = $(_response.html);
421
422            
423            //GET the Previous tag
424            var prev_tag = $cont.find('.ptl-posts-cont > .ptl-last-tag .tag > span').data('tag');
425
426            if(_options.template == '1') {
427
428                //var tag_key  = getKeyByIndex(_response.tags,0);
429                var tag_key  = $new_resp.find('.timeline-box:first').data('tag');
430
431
432                //remove it from existing nodes
433                $cont.find('.ptl-posts-cont > .ptl-last-tag:last').remove();
434
435                //same tag :: remove it
436                //if(prev_tag == _response.tags[0]) {
437                if(prev_tag == tag_key) {
438
439                  //remove it from new nodes
440                  $new_resp.find('#ptl-tag-'+prev_tag).parent().empty().remove();
441                }
442            }
443
444            ///for template 2 only  : : //2,5,6,7,8
445            if(_options.template == '2') {
446
447              var last_tag = $cont.find('.timeline:last').data('tag'),
448                  //new_tag  = $new_resp.find('.timeline:first-child').data('tag');
449                  new_tag  = $new_resp.find('.timeline:first').data('tag');
450
451
452              //when tags matches
453              if(last_tag == new_tag) {
454
455                var $ptl_mp = $cont.find('.timeline:last .ptl-mp-class');
456                $ptl_mp.find('.ptl-h-box > div').unwrap();
457                $ptl_mp.find('.ptl-h-box').remove();
458                $ptl_mp.removeClass('ptl-mp-class');
459
460                var $new_boxes = $new_resp.find('.timeline:first .timeline-box');
461                $new_boxes.appendTo($ptl_mp);
462                $new_resp.find('.timeline:first').remove();  
463              }
464            }
465
466            else if(_options.template == '5' || _options.template == '6' || _options.template == '8') {
467              
468              var last_tag = $cont.find('.timeline-section:last').data('tag'),
469                  new_tag  = $new_resp.find('.timeline-section:first').data('tag');
470
471              
472
473              //when tags matches
474              if(last_tag == new_tag) {
475
476                var $ptl_mp = $cont.find('.timeline-section:last');
477                $ptl_mp.find('.ptl-h-box > div').unwrap();
478                $ptl_mp.find('.ptl-h-box').remove();
479                $ptl_mp.removeClass('ptl-mp-class');
480
481                var $new_boxes = $new_resp.find('.timeline-section:first .timeline-box');
482                $new_boxes.appendTo($ptl_mp);
483                $new_resp.find('.timeline-section:first').remove();
484              }
485            }
486            //big number
487            else if(_options.template == '7') {
488              
489              var last_tag = $cont.find('.timeline-section:last').data('tag'),
490                  new_tag  = $new_resp.find('.timeline-section:first').data('tag');
491
492              //console.log(last_tag,'   ',new_tag);
493              //when tags matches
494              if(last_tag == new_tag) {
495
496                var $ptl_mp     = $cont.find('.timeline-section:last');
497                var $new_boxes = $new_resp.find('.timeline-section:first .timeline-box');
498
499                $new_boxes.appendTo($ptl_mp);
500                $new_resp.find('.timeline-section:first').remove();
501              }
502            }
503
504            ///append the new data
505            $cont.find('.ptl-posts-cont').append($new_resp.html());
506
507
508            //change text of last node IF Exist
509            if(_response.range && _response.range[1]) {
510
511              $cont.find('.ptl-sec-yr.ptl-last').text(_response.range[1]);
512            }
513
514            //reset masonry
515            add_masonry($cont,_options);
516
517            //Update tag list
518            ptl_navigation_vertical.update_tags(_response.tags);
519
520            ( nextPage == maxPages )?$that.remove():$that.attr('data-page', nextPage);
521
522          },'json');
523      });
524    };
525
526
527    
528    //////////////////////////
529    //// Horizontal Methods //
530    //////////////////////////
531    
532    // Navigation
533    var ptl_navigation = {
534      initialize: function($container) {
535
536        var max_li     = (_options.nav_max && !isNaN(_options.nav_max))?parseInt(_options.nav_max):6,
537                $cont  = $container.find('.yr_box');
538
539        //set limit
540        if(max_li <= 2 || max_li > 15) {
541          max_li = 6;
542        }       
543
544        this.$cont = $cont;
545
546        var $cont_inner = $cont.find('.yr_list-inner'),
547            $cont_view  = $cont.find('.yr_list-view');
548
549        this.max_li      = max_li; 
550        this.$cont_inner = $cont_inner;
551        var cin_width    = $cont_inner.width();
552        var $c_li        = $cont.find('.yr_list-inner li');
553        this.li_count    = $cont.find('.yr_list-inner li').length; 
554        this.li_width    = cin_width / this.li_count;//pad
555        
556
557        //Validate if that max_li count is possible
558        
559        if((this.li_width * max_li) > $cont.width()) {
560          
561          max_li = Math.floor($cont.width() / this.li_width);
562          this.max_li = max_li;
563        }
564
565
566
567        this.iterate_width   = this.li_width * max_li;
568        this.total_iterate   = Math.ceil(cin_width / this.iterate_width) - 1;
569        this.current_iterate = 0;
570
571        //the iteration wrapper
572        var c_iterate = 0,
573            n_iterate = 0;
574
575        for(var i = 0; i <= this.total_iterate; i++) {
576
577          c_iterate  = i * max_li;
578          n_iterate += max_li;
579          var $temp_div = $c_li.slice(c_iterate,n_iterate).wrapAll('<div class="ptl-yr-list"/>');
580          if(i == 0) {
581            $temp_div.parent().addClass('ptl-active');
582          }
583        }
584
585        this.in_wrap_width  = $('.ptl-yr-list.ptl-active').outerWidth();
586        this.iterate_width  = this.in_wrap_width;
587        
588        this.li_width    = cin_width / this.li_count;//pad
589        this.btn_left    = $cont.find('.btn-left'),
590        this.btn_right   = $cont.find('.btn-right');
591        
592        if(this.li_count <= this.max_li) {
593
594            max_li = this.li_count;
595            this.btn_left.hide();
596            this.btn_right.hide();
597        }
598        else {
599          this.btn_left.show();
600          this.btn_right.show();
601          $(this.btn_left).addClass('ptl-disabled');
602        }
603
604        var padding = 0;
605        $cont_view.width((this.in_wrap_width + padding)+ 'px');
606        //$cont_view.width((max_li * this.li_width)+ 'px');
607        this.btn_left.bind('click', $.proxy(this.leftArrow,this));
608        this.btn_right.bind('click',$.proxy(this.rightArrow,this));
609      },
610      /**
611       * [resize Resize Window Horizontal Navigation]
612       * @param  {[type]} $container [description]
613       * @return {[type]}            [description]
614       */
615      resize: function($container) {
616
617        var max_li      = (_options.nav_max && !isNaN(_options.nav_max))?parseInt(_options.nav_max):6,
618            $cont       = $container.find('.yr_box');
619
620        //set limit
621        if(max_li <= 2 || max_li > 15) {
622          max_li = 6;
623        }            
624
625
626        this.$cont = $cont;
627
628        var $cont_inner = $cont.find('.yr_list-inner'),
629            $cont_view  = $cont.find('.yr_list-view');
630
631        this.max_li      = max_li; 
632        this.$cont_inner = $cont_inner;
633        var cin_width    = $cont_inner.width();
634        var $c_li        = $cont.find('.yr_list-inner li');
635        this.li_count    = $cont.find('.yr_list-inner li').length; 
636        this.li_width    = cin_width / this.li_count;//pad
637        
638
639        //Validate if that max_li count is possible
640        
641        
642        if((this.li_width * max_li) > $cont.width()) {
643          
644          max_li = Math.floor($cont.width() / this.li_width);
645          this.max_li = max_li;
646        }
647
648        this.iterate_width   = this.li_width * max_li;
649        this.total_iterate   = Math.ceil(cin_width / this.iterate_width) - 1;
650        this.current_iterate = 0;
651
652        //RESET
653        $cont.find('.yr_list-inner .ptl-yr-list').children().unwrap();
654
655        //the iteration wrapper
656        var c_iterate = 0,
657            n_iterate = 0;
658        for(var i = 0; i <= this.total_iterate; i++) {
659
660          c_iterate  = i * max_li;
661          n_iterate += max_li;
662          var $temp_div = $c_li.slice(c_iterate,n_iterate).wrapAll('<div class="ptl-yr-list"/>');
663          if(i == 0) {
664            $temp_div.parent().addClass('ptl-active');
665          }
666        }
667        
668       
669        this.in_wrap_width  = $('.ptl-yr-list.ptl-active').outerWidth();
670        this.iterate_width  = this.in_wrap_width;
671        
672        //this.li_width   = $cont.find('li').eq(0).outerWidth() + 28;//pad
673        this.li_width    = cin_width / this.li_count;//pad
674        
675        if(this.li_count <= this.max_li) {
676
677            max_li = this.li_count;
678            this.btn_left.hide();
679            this.btn_right.hide();
680        }
681        else {
682          this.btn_left.show();
683          this.btn_right.show();
684          $(this.btn_left).addClass('ptl-disabled');
685        }
686
687        var padding = 0;
688        $cont_view.width((this.in_wrap_width + padding)+ 'px');
689      },
690      /**
691       * [leftArrow Left Arrow Horizontal Navigation]
692       * @param  {[type]} e [description]
693       * @return {[type]}   [description]
694       */
695      leftArrow: function(e) {
696
697        var that = this;
698
699        if(this.current_iterate > 0) {
700
701            this.current_iterate--;
702
703            this.$cont_inner.find('.ptl-yr-list').eq(this.current_iterate).addClass('ptl-active');
704
705            // Add disable
706            if(this.current_iterate == 0) {
707                $(this.btn_left).addClass('ptl-disabled');
708            }
709
710            $(this.btn_right).removeClass('ptl-disabled');
711
712            var to_left =  -(this.current_iterate * this.iterate_width);
713
714            //console.log(this.current_iterate,'   ',to_left);
715            that.$cont_inner.find('.ptl-yr-list').eq(that.current_iterate + 1).removeClass('ptl-active');
716            that.$cont_inner.animate({'left':to_left+'px'},500,'swing',function(e) {
717
718                that.get_first();
719            });
720        }
721      },
722      /**
723       * [rightArrow Right Arrow Horizontal Navigation]
724       * @param  {[type]} e [description]
725       * @return {[type]}   [description]
726       */
727      rightArrow: function(e) {
728
729        var that = this;
730
731        if(this.current_iterate < this.total_iterate) {
732
733            this.current_iterate++;
734
735            this.$cont_inner.find('.ptl-yr-list').eq(this.current_iterate).addClass('ptl-active');
736
737            if(this.current_iterate == this.total_iterate) {
738                $(this.btn_right).addClass('ptl-disabled');
739            }
740
741            $(this.btn_left).removeClass('ptl-disabled');
742                
743
744            var to_left =  -(this.current_iterate * this.iterate_width);
745
746            //console.log(this.current_iterate,'   ',to_left);
747            that.$cont_inner.find('.ptl-yr-list').eq(that.current_iterate - 1).removeClass('ptl-active');
748            that.$cont_inner.animate({'left':to_left+'px'},500,'swing',function(e) {
749                
750                that.get_first();
751
752            });
753        }
754      },
755
756      
757      /**
758       * [get_first Horizontal Navigation, Get First Post of the Tag]
759       * @param  {[type]} _no_trigger [description]
760       * @return {[type]}             [description]
761       */
762      get_first: function(_no_trigger) {
763
764        var that    = this;
765        var p_index = (that.max_li * that.current_iterate);
766
767        //console.log(p_index);
768        
769        //show the current
770        if(!_no_trigger)
771          this.$cont_inner.find('li').eq(p_index).trigger('click');
772      },
773      /**
774       * [load_tag Load Tags Horizontal Navigation]
775       * @param  {[type]} _tag  [description]
776       * @param  {[type]} $cont [description]
777       * @return {[type]}       [description]
778       */
779      load_tag: function(_tag, $cont) {
780
781        var that = this;
782
783        $cont.find('li.active').removeClass('active');
784        
785        var $tag_li   = $cont.find('li[data-tag="'+_tag+'"]'),
786            $p_tag    = $tag_li.parent(),
787            tag_index = ($tag_li.index() + (this.max_li * $p_tag.index()));
788
789        //tag_index = ($tag_li.index() + (this.max_li * that.current_iterate));
790        //console.log('_tag',_tag,'   ',$tag_li,' that.current_iterate:',that.current_iterate,'    tag_index:',tag_index,'   ',$p_tag.index());
791        
792        console.log('===> post-timeline.js ===> 792', tag_index);
793        $tag_li.addClass('active');
794
795        var iterate = Math.floor(tag_index / this.max_li);
796
797        console.log('iterate:',iterate,'this.current_iterate:',this.current_iterate);
798
799        //If iterate is not same
800        if(this.current_iterate != iterate) {
801
802          this.current_iterate = iterate;
803          
804          $(this.btn_left).removeClass('ptl-disabled');
805          $(this.btn_right).removeClass('ptl-disabled');
806          
807          //if Max
808          if(iterate == this.total_iterate) {
809              $(this.btn_right).addClass('ptl-disabled');
810          }
811
812          //If Below
813          if(this.current_iterate == 0) {
814              $(this.btn_left).addClass('ptl-disabled');
815          }
816
817          var to_left =  -(iterate * this.iterate_width);
818
819          console.log(this.$cont_inner[0], '===> post-timeline.js ===> 819', to_left);
820          //console.log(this.current_iterate,'   ',to_left);
821          this.$cont_inner.animate({'left':to_left+'px'}, 500,'swing',function(e) {
822              
823              that.get_first(true);//no trigger
824          });
825
826        }
827      }
828    };
829
830    /**
831     * [make_horz_navigation Make Horizontal Navigation]
832     * @param  {[type]} $cont      [description]
833     * @param  {[type]} slick_inst [description]
834     * @return {[type]}            [description]
835     */
836    function make_horz_navigation($cont, slick_inst) {
837
838
839      $cont.find('.yr_list li').eq(0).addClass('active');
840
841      window['slick_inst'] = slick_inst;
842
843
844      $cont.find('.yr_list li').bind('click',function(e) {
845
846          var _tag     = $(this).data('tag'); 
847
848          slick_inst[0].agile_slick.the_tag = _tag;
849
850          var $node   = $cont.find('.timeline-box[data-tag="'+_tag+'"]').parent();
851          var _index  = $node.not('.agile_slick-cloned').data('agile_slick-index');
852          
853          //reduce of next sibling is null
854          if(!$node[0].nextSibling && slick_inst[0].agile_slick.options.slidesToShow > 1) {
855            _index--;
856          }
857          
858          //console.log('_index to go:',_index,$cont.find('.timeline-box[data-tag="'+_tag+'"]').parent().not('.agile_slick-cloned'));
859
860          slick_inst[0].agile_slick.goTo(_index);
861      });
862
863
864      //initialize horizontal navigation
865      ptl_navigation.initialize($cont);
866
867      /**
868       * [On Slide Change]
869       * @param  {[type]} _e  [description]
870       * @param  {[type]} _s) {                               var $_slide [description]
871       * @return {[type]}     [description]
872       */
873      slick_inst.on('afterChange',function(_e,_s) {
874          
875          var $_slide = $(_s.$slides[_s.getCurrent()]),
876              _tag    = $_slide.find('.timeline-box').data('tag');
877              //_tag    = slick_inst[0].agile_slick.the_tag || $_slide.find('.timeline-box').data('tag');
878          console.log('===> post-timeline.js ===> 876');
879          ptl_navigation.load_tag(_tag, $cont);
880
881          the_tag = null;
882      });
883    };
884
885
886    /**
887     * [ptl_main Post Timeline Main method]
888     * @return {[type]} [description]
889     */
890    function ptl_main() {
891      
892      var $this = $(this);
893
894
895      var $section   = $this.find('.timeline-section');
896
897      
898      if(options.horiz) {
899
900        var slider_params = {
901          slidesToShow: (options.slides)? parseInt(options.slides): 2,
902          slidesToScroll: 1,
903          infinite: false
904        };
905
906        //set slick count
907        var _w = $section.width();
908
909        if(_w <= 768) {
910
911          slider_params.slidesToShow = 1;
912          //$section.attr('data-agile_slick','{"slidesToShow": 1, "slidesToScroll": 1}');
913        }
914        
915        //  Slider
916        var slick_inst = $section.agile_slick(slider_params);  
917
918
919        //Make Navigation
920        if(options['ptl-nav-status'])
921          make_horz_navigation($this, slick_inst);
922
923
924        //  Pre-scroll
925        if(window.location.hash) {
926
927          //  For Year Node
928          var ptl_hash  = window.location.hash;
929
930          var node_li   = $this.find('.yr_list li a[href="'+ptl_hash+'"]');
931
932          if(node_li.length) {
933
934            window.setTimeout(function(e) {
935              node_li.parent().trigger('click');
936            
937            }, 500);
938          }
939          /*
940          //  For Posts
941          var ptl_hash  = window.location.hash.replace('#','');
942          
943          var hash_node = $section.find('[data-href="'+ptl_hash+'"]');
944
945          if(hash_node && hash_node[0]) {
946
947            var hash_post = hash_node.parents('.ptl-post-div');
948
949            if(hash_post && hash_post[0]) {
950
951              var post_list  = Array.prototype.slice.call( hash_post[0].parentNode.children );
952
953              var post_index = post_list.indexOf( hash_post[0] );
954
955              if(post_index) {
956
957                slider_params.initialSlide = post_index;
958              }
959            }
960          }
961          */
962        }
963
964        /**
965         * [Resize Event]
966         * @param  {[type]} e)
967         * @return {[type]}    [description]
968         */
969        $(window).on('resize',function(e) {
970          
971           //set slick count
972          var _w = $section.width();
973
974          if(_w <= 768) {
975            
976            //$section.attr('data-agile_slick','{"slidesToShow": 1, "slidesToScroll": 1}');
977            slick_inst[0].agile_slick.options.slidesToShow = 1;
978          }
979          else {
980
981            var slides = (options.slides)? parseInt(options.slides): ((options.template == "3-h" || options.template == "7-h")?1:2);
982
983            //$section.attr('data-agile_slick','{"slidesToShow": 2, "slidesToScroll": 1}');
984            slick_inst[0].agile_slick.options.slidesToShow = slides;
985          }
986
987          slick_inst.agile_slick('resize');
988
989          //Reset the Navigation
990          ptl_navigation.resize($this);
991
992        });
993
994        $this.find('.ptl-preloder').addClass('hide');
995      }
996      else {
997          
998          options.scroller = _options.scroller || null;
999
1000          //console.log(options.nav_offset);
1001          //Add ptl scroll :: once
1002          $.fn.ptlScroller({
1003            //selector: '[data-scroll]',
1004            nav_offset: (options.nav_offset)?parseInt(options.nav_offset):null,
1005            selector: '[data-scroll]',
1006            doc: (window['ptl_admin_pan'])?'.modaal-wrapper':options.scroller,
1007            before: function(e){
1008
1009              options.scrolling = true;
1010              
1011            },
1012            after: function(e){
1013
1014              options.scrolling = false; 
1015            }
1016          });
1017          
1018          //Add Animation :: Once
1019          if(options['ptl-anim-status'])
1020            add_animation(options, $this);
1021
1022
1023          add_masonry($this, options);
1024
1025          add_more_buttom($this, options);
1026
1027          if(options['ptl-nav-status']) {
1028
1029            ptl_navigation_vertical.initialize($this);
1030
1031            //sticky navigation func
1032            function ptl_yrmenu(fixmeTop) {
1033
1034                var currentScroll = $(window).scrollTop();
1035
1036                if (currentScroll >= fixmeTop) {
1037                    
1038                    $this.addClass('nav-fixed');
1039                    
1040                    $this.find('.yr_list').css({                      
1041                        position: 'fixed'
1042                    });
1043                }
1044                else {
1045                    
1046                    $this.removeClass('nav-fixed');
1047                    $this.find('.yr_list').css({
1048                        position: 'absolute'
1049                    });
1050                }
1051            }
1052
1053            //sticky navigation
1054            var TopDistance = ($this.offset().top) + 50;
1055            ptl_yrmenu(TopDistance);
1056
1057            $(window).scroll(function() {
1058                
1059              ptl_yrmenu(TopDistance);
1060            });
1061          }     
1062      }
1063
1064      /////////////////
1065      //  Video Link //
1066      /////////////////
1067      var ptl_video_link;  
1068      var $agile_modal = $('#ptl-video-modal');
1069      $section.find('.ptl-video-btn').click(function() {
1070        
1071        ptl_video_link = $(this).data( "src" );
1072        ptl_video_link = ptl_video_link.replace('watch?v=', 'embed/');
1073        ptl_video_link = ptl_video_link.split('&')[0];
1074
1075        $("#ptl-video").attr('src', ptl_video_link + "?autoplay=1&amp;modestbranding=1&amp;showinfo=0" ); 
1076        
1077        $agile_modal.css('display', 'block');
1078        
1079        window.setTimeout(function() {
1080          $agile_modal.addClass('in');
1081        }, 300);
1082      });
1083
1084      ////////////////////////////
1085      //  Close the Video modal //
1086      ////////////////////////////
1087      $('.ptl-modal-backdrop-in').bind('click', function() {
1088
1089        $agile_modal.removeClass('in');
1090        window.setTimeout(function() {
1091          $agile_modal.css('display', 'none');
1092          $("#ptl-video").attr('src', '' ); 
1093        }, 300);
1094      });
1095
1096      $this.find('.ptl-preloder').addClass('hide');
1097    };
1098
1099    /*Useless loop for each*/
1100    
1101    var That = this;    
1102
1103    //for admin load ,set time out
1104    if(window['ptl_admin_pan']) {
1105
1106      window.setTimeout(function() {
1107        
1108        That.each(ptl_main);
1109
1110      },1000);
1111    }
1112    else
1113      That.each(ptl_main);
1114
1115    return this;
1116  };
1117
1118  //   Main Loop
1119  $('.p-tl-cont').each(function(e){
1120
1121      var ptl_config_id = $(this).attr('data-id'),
1122          ptl_config    = window['ptl_config_' + ptl_config_id];
1123
1124      if(ptl_config) {
1125        console.log('===> post-timeline.js init ===> ',ptl_config_id);
1126        $(this).post_timeline(ptl_config);
1127      }
1128  });
1129}( jQuery ));
1130
1131

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.