PluginProbe ʕ •ᴥ•ʔ
The Post Grid – Shortcode, Gutenberg Blocks and Elementor Addon for Post Grid / 7.0.2
The Post Grid – Shortcode, Gutenberg Blocks and Elementor Addon for Post Grid v7.0.2
7.9.3 7.9.2 trunk 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.1.5 4.2.0 4.2.1 4.2.2 4.2.3 5.0.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 6.0.0 7.0.0 7.0.1 7.0.2 7.1.0 7.2.0 7.2.1 7.2.10 7.2.11 7.2.2 7.2.3 7.2.4 7.2.5 7.2.6 7.2.7 7.2.8 7.2.9 7.3.0 7.3.1 7.4.0 7.4.1 7.4.2 7.4.3 7.5.0 7.6.0 7.6.1 7.7.0 7.7.1 7.7.10 7.7.11 7.7.12 7.7.13 7.7.14 7.7.15 7.7.16 7.7.17 7.7.18 7.7.19 7.7.2 7.7.20 7.7.21 7.7.22 7.7.3 7.7.4 7.7.5 7.7.6 7.7.7 7.7.8 7.7.9 7.8.0 7.8.1 7.8.2 7.8.3 7.8.4 7.8.5 7.8.6 7.8.7 7.8.8 7.8.9 7.9.0 7.9.1
the-post-grid / assets / js / admin-preview.js
the-post-grid / assets / js Last commit date
admin-preview.js 3 years ago admin.js 3 years ago blocks-placeholder.js 3 years ago editor-el.js 3 years ago mce-button.js 3 years ago post-grid-blocks.js 3 years ago rttpg.js 3 years ago tpg-el-editor.js 3 years ago
admin-preview.js
824 lines
1 (function ($) {
2 'use strict';
3
4 $(window).resize(function () {
5 overlayIconResizeTpg();
6 });
7 $(window).on('load', function () {
8 overlayIconResizeTpg();
9 });
10 $("#tpg-preview-container").on('click', 'a.tpg-zoom', function (e) {
11 e.preventDefault();
12 return false;
13 });
14
15 $(document).on({
16 mouseenter: function () {
17 var $this = $(this);
18 var $title = $this.attr('title');
19 $tooltip = '<div class="rt-tooltip" id="rt-tooltip">' +
20 '<div class="rt-tooltip-content">' + $title + '</div>' +
21 '<div class="rt-tooltip-bottom"></div>' +
22 '</div>';
23 $('body').append($tooltip);
24 var $tooltip = $('body > .rt-tooltip');
25 var tHeight = $tooltip.outerHeight();
26 var tBottomHeight = $tooltip.find('.rt-tooltip-bottom').outerHeight();
27 var tWidth = $tooltip.outerWidth();
28 var tHolderWidth = $this.outerWidth();
29 var top = $this.offset().top - (tHeight + tBottomHeight) + 14;
30 var left = $this.offset().left;
31 $tooltip.css('top', top + 'px');
32 $tooltip.css('left', left + 'px');
33 $tooltip.css('opacity', 1);
34 $tooltip.show();
35 if (tWidth <= tHolderWidth) {
36 var itemLeft = (tHolderWidth - tWidth) / 2;
37 left = left + itemLeft;
38 $tooltip.css('left', left + 'px');
39 } else {
40 var itemLeft = (tWidth - tHolderWidth) / 2;
41 left = left - itemLeft;
42 if (left < 0) {
43 left = 0;
44 }
45 $tooltip.css('left', left + 'px');
46 }
47 },
48 mouseleave: function () {
49 $('body > .rt-tooltip').remove();
50 }
51 }, '.rt-tpg-social-share a');
52
53 $("span.rtAddImage").on("click", function (e) {
54 var file_frame, image_data;
55 var $this = $(this).parents('.rt-image-holder');
56 if (undefined !== file_frame) {
57 file_frame.open();
58 return;
59 }
60 file_frame = wp.media.frames.file_frame = wp.media({
61 title: 'Select or Upload Media For your profile gallery',
62 button: {
63 text: 'Use this media'
64 },
65 multiple: false
66 });
67 file_frame.on('select', function () {
68 var attachment = file_frame.state().get('selection').first().toJSON();
69 var imgId = attachment.id;
70 var imgUrl = (typeof attachment.sizes.thumbnail === "undefined") ? attachment.url : attachment.sizes.thumbnail.url;
71 $this.find('.hidden-image-id').val(imgId);
72 $this.find('.rtRemoveImage').show();
73 $this.find('img').remove();
74 $this.find('.rt-image-preview').append("<img src='" + imgUrl + "' />");
75 renderTpgPreview();
76 });
77 // Now display the actual file_frame
78 file_frame.open();
79 });
80
81 $("span.rtRemoveImage").on("click", function (e) {
82 e.preventDefault();
83 if (confirm("Are you sure?")) {
84 var $this = $(this).parents('.rt-image-holder');
85 $this.find('.hidden-image-id').val('');
86 $this.find('.rtRemoveImage').hide();
87 $this.find('img').remove();
88 renderTpgPreview();
89 }
90 });
91
92 $("#rttpg_meta").on('change', 'select,input', function () {
93 renderTpgPreview();
94 });
95
96 $("#rttpg_meta").on("input propertychange", function () {
97 renderTpgPreview();
98 });
99 renderTpgPreview();
100
101 function IsotopeNCarouselRender() {
102 $('.rt-tpg-container').each(function () {
103 var container = $(this),
104 str = $(this).attr("data-layout"),
105 id = $.trim(container.attr('id')),
106 scID = $.trim(container.attr("data-sc-id")),
107 $default_order_by = $('.rt-order-by-action .order-by-default', container),
108 $default_order = $('.rt-sort-order-action .rt-sort-order-action-arrow', container),
109 $taxonomy_filter = $('.rt-filter-item-wrap.rt-tax-filter', container),
110 $pagination_wrap = $('.rt-pagination-wrap', container),
111 $loadmore = $('.rt-loadmore-action', container),
112 $infinite = $('.rt-infinite-action', container),
113 $page_prev_next = $('.rt-cb-page-prev-next', container),
114 $page_numbers = $('.rt-page-numbers', container),
115 html_loading = '<div class="rt-loading-overlay"></div><div class="rt-loading rt-ball-clip-rotate"><div></div></div>',
116 preLoader = container.find('.tpg-pre-loader'),
117 loader = container.find(".rt-content-loader"),
118 contentLoader = container.children(".rt-row.rt-content-loader"),
119 search_wrap = container.find(".rt-search-filter-wrap"),
120 tpg_order = '',
121 tpg_order_by = '',
122 tpg_taxonomy = '',
123 tpg_term = '',
124 tpg_search = '',
125 tpg_paged = 1,
126 temp_total_pages = parseInt($pagination_wrap.attr('data-total-pages'), 10),
127 tpg_total_pages = typeof (temp_total_pages) != 'undefined' && temp_total_pages != '' ? temp_total_pages : 1,
128 temp_posts_per_page = parseInt($pagination_wrap.attr('data-posts-per-page'), 10),
129 tpg_posta_per_page = typeof (temp_posts_per_page) != 'undefined' && temp_posts_per_page != '' ? temp_posts_per_page : 3,
130 infinite_status = 0,
131 paramsRequest = {},
132 mIsotopWrap = '',
133 IsotopeWrap = '',
134 isMasonary = $('.rt-row.rt-content-loader.tpg-masonry', container),
135 isIsotop = $(".rt-tpg-isotope", container),
136 IsoButton = $(".rt-tpg-isotope-buttons", container),
137 IsoDropdownFilter = $("select.isotope-dropdown-filter", container),
138 isCarousel = $('.rt-swiper-holder', container),
139 placeholder_loading = function () {
140 if (loader.find('.rt-loading-overlay').length == 0) {
141 loader.addClass('tpg-pre-loader');
142 loader.append(html_loading);
143 }
144 },
145 remove_placeholder_loading = function () {
146 loader.find('.rt-loading-overlay, .rt-loading').remove();
147 loader.removeClass('tpg-pre-loader');
148 $loadmore.removeClass('rt-lm-loading');
149 $page_numbers.removeClass('rt-lm-loading');
150 $infinite.removeClass('rt-active-elm');
151 search_wrap.find('input').prop("disabled", false);
152 },
153 check_query = function () {
154 if ($taxonomy_filter.length > 0) {
155 tpg_taxonomy = $taxonomy_filter.attr('data-taxonomy');
156 var term;
157 if ($taxonomy_filter.hasClass('rt-filter-button-wrap')) {
158 term = $taxonomy_filter.find('.rt-filter-button-item.selected').attr('data-term');
159 } else {
160 term = $taxonomy_filter.find('.term-default').attr('data-term');
161 }
162 if (typeof (term) != 'undefined' && term != '') {
163 tpg_term = term;
164 }
165 }
166 if ($default_order_by.length > 0) {
167 var order_by_param = $default_order_by.attr('data-order-by');
168 if (typeof (order_by_param) != 'undefined' && order_by_param != '' && (order_by_param.toLowerCase())) {
169 tpg_order_by = order_by_param;
170 }
171 }
172 if ($default_order_by.length > 0) {
173 var order_param = $default_order.attr('data-sort-order');
174 if (typeof (order_param) != 'undefined' && order_param != '' && (order_param == 'DESC' || order_param == 'ASC')) {
175 tpg_order = order_param;
176 }
177 }
178 if (search_wrap.length > 0) {
179 tpg_search = $.trim(search_wrap.find('input').val());
180 }
181 paramsRequest = {
182 'scID': scID,
183 'order': tpg_order,
184 'order_by': tpg_order_by,
185 'taxonomy': tpg_taxonomy,
186 'term': tpg_term,
187 'paged': tpg_paged,
188 'action': 'tpgLayoutAjaxAction',
189 'search': tpg_search,
190 'rttpg_nonce': rttpg.nonce
191 };
192 },
193 infinite_scroll = function () {
194 if (infinite_status == 1 || $infinite.hasClass('rt-hidden-elm') || $pagination_wrap.length == 0) {
195 return;
196 }
197 var ajaxVisible = $pagination_wrap.offset().top,
198 ajaxScrollTop = $(window).scrollTop() + $(window).height();
199
200 if (ajaxVisible <= (ajaxScrollTop) && (ajaxVisible + $(window).height()) > ajaxScrollTop) {
201 infinite_status = 1; //stop inifite scroll
202 tpg_paged = tpg_paged + 1;
203 $infinite.addClass('rt-active-elm');
204 ajax_action(true, true);
205 }
206 },
207 generateData = function (number) {
208 var result = [];
209 for (var i = 1; i < number + 1; i++) {
210 result.push(i);
211 }
212 return result;
213 },
214 setPostCount = function () {
215 if ($taxonomy_filter.length > 0 && $taxonomy_filter.hasClass('has-post-count')) {
216 if ($taxonomy_filter.hasClass('rt-filter-button-wrap')) {
217 var total = 0;
218 $taxonomy_filter.find('span').each(function () {
219 var self = $(this),
220 target = self.find('span.rt-post-count');
221 if (target.length > 0) {
222 total = total + parseInt($.trim(target.html()), 10);
223 }
224 });
225 $taxonomy_filter.find('span[data-term="all"]').append(" (<span class='rt-post-count'>" + total + "</span>)");
226 } else if ($taxonomy_filter.hasClass('rt-filter-dropdown-wrap')) {
227 var total = 0;
228 $taxonomy_filter.find('.term-dropdown.rt-filter-dropdown .rt-filter-dropdown-item').each(function () {
229 var self = $(this),
230 target = self.find('span.rt-post-count');
231 if (target.length > 0) {
232 total = total + parseInt($.trim(target.html()), 10);
233 }
234 });
235 if ($taxonomy_filter.find('span.rt-filter-dropdown-default').attr("data-term") == "all") {
236 $taxonomy_filter.find('span.rt-filter-dropdown-default .rt-text').append(" (<span class='rt-post-count'>" + total + "</span>)");
237 } else if ($taxonomy_filter.find('.term-dropdown.rt-filter-dropdown').find('.term-dropdown-item[data-term="all"]').length) {
238 var dd = $taxonomy_filter.find('.term-default.rt-filter-dropdown-default').find('span.rt-post-count').html();
239 total = total + parseInt($.trim(dd), 10);
240 $taxonomy_filter.find('.term-dropdown.rt-filter-dropdown').find('.term-dropdown-item[data-term="all"]').append(" (<span class='rt-post-count'>" + total + "</span>)");
241 }
242
243 }
244 }
245 },
246 createPagination = function () {
247 if ($page_numbers.length > 0) {
248 $page_numbers.pagination({
249 dataSource: generateData(tpg_total_pages * parseFloat(tpg_posta_per_page)),
250 pageSize: parseFloat(tpg_posta_per_page),
251 autoHidePrevious: true,
252 autoHideNext: true,
253 prevText: '<i class="fa fa-angle-double-left" aria-hidden="true"></i>',
254 nextText: '<i class="fa fa-angle-double-right" aria-hidden="true"></i>'
255 });
256 $page_numbers.addHook('beforePaging', function (pagination) {
257 infinite_status = 1;
258 tpg_paged = pagination;
259 $page_numbers.addClass('rt-lm-loading');
260 $page_numbers.pagination('disable');
261 ajax_action(true, false);
262 });
263 if (tpg_total_pages <= 1) {
264 $page_numbers.addClass('rt-hidden-elm');
265 } else {
266 $page_numbers.removeClass('rt-hidden-elm');
267 }
268 }
269 },
270 load_gallery_image_popup = function () {
271 container.find('.rt-row.layout17').each(function () {
272 var self = $(this);
273 self.magnificPopup({
274 delegate: 'a.tpg-zoom',
275 type: 'image',
276 gallery: {
277 enabled: true
278 }
279 });
280 });
281
282 },
283 ajax_action = function (page_request, append) {
284 page_request = page_request || false;
285 append = append || false;
286 if (!page_request) {
287 tpg_paged = 1;
288 }
289 check_query();
290 if (page_request == true && tpg_total_pages > 1 && paramsRequest.paged > tpg_total_pages) {
291 remove_placeholder_loading();
292 return;
293 }
294 $.ajax({
295 url: rttpg.ajaxurl,
296 type: 'POST',
297 data: paramsRequest,
298 cache: false,
299 beforeSend: function () {
300 placeholder_loading();
301 },
302 success: function (data) {
303 if (!data.error) {
304 tpg_paged = data.paged;
305 tpg_total_pages = data.total_pages;
306 if (data.paged >= tpg_total_pages) {
307 if ($loadmore.length) {
308 $loadmore.addClass('rt-hidden-elm');
309 }
310 if ($infinite.length) {
311 infinite_status = 1;
312 $infinite.addClass('rt-hidden-elm');
313 }
314 if ($page_prev_next.length) {
315 if (!page_request) {
316 $page_prev_next.addClass('rt-hidden-elm');
317 } else {
318 $page_prev_next.find('.rt-cb-prev-btn').removeClass('rt-disabled');
319 $page_prev_next.find('.rt-cb-next-btn').addClass('rt-disabled');
320 }
321 }
322 } else {
323 if ($loadmore.length) {
324 $loadmore.removeClass('rt-hidden-elm');
325 }
326 if ($infinite.length) {
327 infinite_status = 0;
328 $infinite.removeClass('rt-hidden-elm');
329 }
330 if ($page_prev_next.length) {
331 if (!page_request) {
332 $page_prev_next.removeClass('rt-hidden-elm');
333 } else {
334 if (data.paged == 1) {
335 $page_prev_next.find('.rt-cb-prev-btn').addClass('rt-disabled');
336 $page_prev_next.find('.rt-cb-next-btn').removeClass('rt-disabled');
337 } else {
338 $page_prev_next.find('.rt-cb-prev-btn').removeClass('rt-disabled');
339 $page_prev_next.find('.rt-cb-next-btn').removeClass('rt-disabled');
340 }
341 }
342 }
343 }
344 if (append) {
345 if (isIsotop.length) {
346 IsotopeWrap.append(data.data)
347 .isotope('appended', data.data)
348 .isotope('reloadItems')
349 .isotope('updateSortData')
350 .isotope();
351 IsotopeWrap.imagesLoaded(function () {
352 preFunction();
353 IsotopeWrap.isotope();
354 });
355 if (IsoButton.attr('data-count')) {
356 isoFilterCounter(container, IsotopeWrap);
357 }
358 } else if (isMasonary.length) {
359 mIsotopWrap.append(data.data).isotope('appended', data.data).isotope('updateSortData').isotope('reloadItems');
360 mIsotopWrap.imagesLoaded(function () {
361 mIsotopWrap.isotope();
362 });
363 } else {
364 contentLoader.append(data.data);
365 }
366 } else {
367 contentLoader.html(data.data);
368 }
369 contentLoader.imagesLoaded(function () {
370 preFunction();
371 remove_placeholder_loading();
372 load_gallery_image_popup();
373 });
374 if (!page_request) {
375 createPagination();
376 }
377 } else {
378 remove_placeholder_loading();
379 }
380 },
381 error: function (error) {
382 remove_placeholder_loading();
383 }
384 });
385 if ($('.paginationjs-pages .paginationjs-page', $page_numbers).length > 0) {
386 $page_numbers.pagination('enable');
387 }
388 };
389
390 switch ($pagination_wrap.attr('data-type')) {
391 case 'load_more':
392 $loadmore.on('click', function () {
393 $(this).addClass('rt-lm-loading');
394 tpg_paged = tpg_paged + 1;
395 ajax_action(true, true);
396 });
397 break;
398 case 'pagination_ajax':
399 createPagination();
400 break;
401 case 'pagination':
402 break;
403 case 'load_on_scroll':
404 $(window).on('scroll load', function () {
405 infinite_scroll();
406 });
407 break;
408 case 'page_prev_next':
409 if (tpg_paged == 1) {
410 $page_prev_next.find('.rt-cb-prev-btn').addClass('rt-disabled');
411 }
412 if (tpg_paged == tpg_total_pages) {
413 $page_prev_next.find('.rt-cb-next-btn').addClass('rt-disabled');
414 }
415 if (tpg_total_pages == 1) {
416 $page_prev_next.addClass('rt-hidden-elm');
417 }
418 break;
419 }
420
421 if (str) {
422 var qsRegex,
423 buttonFilter;
424 if (preLoader.find('.rt-loading-overlay').length == 0) {
425 preLoader.append(html_loading);
426 }
427
428 if (isCarousel.length) {
429 isCarousel.imagesLoaded(function () {
430 $(".rt-swiper-holder").each(function () {
431
432 var rtSwiperSlider = $(this).get(0),
433 prevButton = $(this).parent().children().find(".swiper-button-prev").get(0),
434 nextButton = $(this).parent().children().find(".swiper-button-next").get(0),
435 dotPagination = $(this).parent().children().find(".swiper-pagination").get(0),
436 dItem = parseInt(container.attr('data-desktop-col'), 10),
437 tItem = parseInt(container.attr('data-tab-col'), 10),
438 mItem = parseInt(container.attr('data-mobile-col'), 10),
439 options = isCarousel.data('rtowl-options'),
440 rtSwiperData = {
441 slidesPerView: mItem ? mItem : 1,
442 spaceBetween: 24,
443 loop: options.loop,
444 slideToClickedSlide: true,
445 speed: options.speed,
446 autoHeight: options.autoHeight,
447 breakpoints: {
448 0: {
449 slidesPerView: mItem ? mItem : 1,
450 },
451 768: {
452 slidesPerView: tItem ? tItem : 2,
453 },
454 992: {
455 slidesPerView: dItem ? dItem : 3,
456 },
457 }
458 };
459
460 if (options.autoPlay) {
461 Object.assign(rtSwiperData, {
462 autoplay: {
463 delay: options.autoPlayTimeOut,
464 }
465 });
466 }
467 if (options.nav) {
468 Object.assign(rtSwiperData, {
469 navigation: {
470 nextEl: nextButton,
471 prevEl: prevButton,
472 }
473 });
474 }
475 if (options.dots) {
476 Object.assign(rtSwiperData, {
477 pagination: {
478 el: dotPagination,
479 clickable: true,
480 dynamicBullets: true,
481 }
482 });
483 }
484
485 new Swiper(rtSwiperSlider, rtSwiperData);
486 remove_placeholder_loading();
487 });
488 });
489 } else if (isIsotop.length) {
490 var IsoURL = IsoButton.attr('data-url'),
491 IsoCount = IsoButton.attr('data-count');
492 if (!buttonFilter) {
493 if (IsoButton.length) {
494 buttonFilter = IsoButton.find('button.selected').data('filter');
495 } else if (IsoDropdownFilter.length) {
496 buttonFilter = IsoDropdownFilter.val();
497 }
498 }
499 IsotopeWrap = isIsotop.imagesLoaded(function () {
500 preFunction();
501 IsotopeWrap.isotope({
502 itemSelector: '.isotope-item',
503 masonry: {columnWidth: '.isotope-item'},
504 filter: function () {
505 var $this = $(this);
506 var searchResult = qsRegex ? $this.text().match(qsRegex) : true;
507 var buttonResult = buttonFilter ? $this.is(buttonFilter) : true;
508 return searchResult && buttonResult;
509 }
510 });
511 setTimeout(function () {
512 IsotopeWrap.isotope();
513 remove_placeholder_loading();
514 }, 100);
515 });
516 // use value of search field to filter
517 var $quicksearch = container.find('.iso-search-input').keyup(debounce(function () {
518 qsRegex = new RegExp($quicksearch.val(), 'gi');
519 IsotopeWrap.isotope();
520 }));
521
522 IsoButton.on('click', 'button', function (e) {
523 e.preventDefault();
524 buttonFilter = $(this).attr('data-filter');
525 if (IsoURL) {
526 location.hash = "filter=" + encodeURIComponent(buttonFilter);
527 } else {
528 IsotopeWrap.isotope();
529 $(this).parent().find('.selected').removeClass('selected');
530 $(this).addClass('selected');
531 }
532 });
533 if (IsoURL) {
534 windowHashChange(IsotopeWrap, IsoButton);
535 $(window).on("hashchange", function () {
536 windowHashChange(IsotopeWrap, IsoButton);
537 });
538 }
539 if (IsoCount) {
540 isoFilterCounter(container, IsotopeWrap);
541 }
542 IsoDropdownFilter.on('change', function (e) {
543 e.preventDefault();
544 buttonFilter = $(this).val();
545 IsotopeWrap.isotope();
546 });
547
548 } else if (container.find('.rt-row.rt-content-loader.tpg-masonry').length) {
549 var masonryTarget = $('.rt-row.rt-content-loader.tpg-masonry', container);
550 mIsotopWrap = masonryTarget.imagesLoaded(function () {
551 preFunction();
552 mIsotopWrap.isotope({
553 itemSelector: '.masonry-grid-item',
554 masonry: {columnWidth: '.masonry-grid-item'}
555 });
556 remove_placeholder_loading();
557 });
558 }
559 }
560
561 $('#' + id).on('click', '.rt-search-filter-wrap .rt-action', function (e) {
562 search_wrap.find('input').prop("disabled", true);
563 ajax_action();
564 });
565 $('#' + id).on('keypress', '.rt-search-filter-wrap .rt-search-input', function (e) {
566 if (e.which == 13) {
567 search_wrap.find('input').prop("disabled", true);
568 ajax_action();
569 }
570 });
571 $('#' + id).on('click', '.rt-filter-dropdown-wrap', function (event) {
572 var self = $(this);
573 self.toggleClass('active-dropdown');
574 });// Dropdown click
575 $('#' + id).on('click', '.term-dropdown-item', function (event) {
576 $loadmore.addClass('rt-lm-loading');
577 var $this_item = $(this),
578 default_target = $taxonomy_filter.find('.rt-filter-dropdown-default'),
579 old_param = default_target.attr('data-term'),
580 old_text = default_target.find('.rt-text').html();
581 $this_item.parents('.rt-filter-dropdown-wrap').removeClass('active-dropdown');
582 $this_item.parents('.rt-filter-dropdown-wrap').toggleClass('active-dropdown');
583 default_target.attr('data-term', $this_item.attr('data-term'));
584 default_target.find('.rt-text').html($this_item.html());
585 $this_item.attr('data-term', old_param);
586 $this_item.html(old_text);
587 ajax_action();
588 });//term
589 $('#' + id).on('click', '.order-by-dropdown-item', function (event) {
590 $loadmore.addClass('rt-lm-loading');
591 var $this_item = $(this),
592 old_param = $default_order_by.attr('data-order-by'),
593 old_text = $default_order_by.find('.rt-text-order-by').html();
594
595 $this_item.parents('.rt-order-by-action').removeClass('active-dropdown');
596 $this_item.parents('.rt-order-by-action').toggleClass('active-dropdown');
597 $default_order_by.attr('data-order-by', $this_item.attr('data-order-by'));
598 $default_order_by.find('.rt-text-order-by').html($this_item.html());
599 $this_item.attr('data-order-by', old_param);
600 $this_item.html(old_text);
601 ajax_action();
602 });//Order By
603
604 //Sort Order
605 $('#' + id).on('click', '.rt-sort-order-action', function (event) {
606 $loadmore.addClass('rt-lm-loading');
607 var $this_item = $(this),
608 $sort_order_elm = $('.rt-sort-order-action-arrow', $this_item),
609 sort_order_param = $sort_order_elm.attr('data-sort-order');
610 if (typeof (sort_order_param) != 'undefined' && sort_order_param.toLowerCase() == 'desc') {
611 $default_order.attr('data-sort-order', 'ASC');
612 } else {
613 $default_order.attr('data-sort-order', 'DESC');
614 }
615 ajax_action();
616 });//Sort Order
617
618 $taxonomy_filter.on('click', '.rt-filter-button-item', function () {
619 var self = $(this);
620 self.parents('.rt-filter-button-wrap').find('.rt-filter-button-item').removeClass('selected');
621 self.addClass('selected');
622 ajax_action();
623 });
624
625 $page_prev_next.on('click', '.rt-cb-prev-btn', function (event) {
626 if (tpg_paged <= 1) {
627 return;
628 }
629 tpg_paged = tpg_paged - 1;
630 ajax_action(true, false);
631 });
632 $page_prev_next.on('click', '.rt-cb-next-btn', function (event) {
633 if (tpg_paged >= tpg_total_pages) {
634 return;
635 }
636 tpg_paged = tpg_paged + 1;
637 ajax_action(true, false);
638 });
639 setPostCount();
640 load_gallery_image_popup();
641
642 });
643
644 $(".rt-tpg-container a.disabled").each(function () {
645 $(this).prop("disabled", true);
646 $(this).removeAttr("href");
647 });
648 }
649
650 function preFunction() {
651 overlayIconResizeTpg();
652 }
653
654
655 // debounce so filtering doesn't happen every millisecond
656 function debounce(fn, threshold) {
657 var timeout;
658 return function debounced() {
659 if (timeout) {
660 clearTimeout(timeout);
661 }
662
663 function delayed() {
664 fn();
665 timeout = null;
666 }
667
668 setTimeout(delayed, threshold || 100);
669 };
670 }
671
672 if ($("#rttpg_meta .rt-color").length) {
673 var cOptions = {
674 defaultColor: false,
675 change: function (event, ui) {
676 setTimeout(function () {
677 renderTpgPreview();
678 }, 1);
679 },
680 clear: function () {
681 renderTpgPreview();
682 },
683 hide: true,
684 palettes: true
685 };
686 $("#rttpg_meta .rt-color").wpColorPicker(cOptions);
687 }
688
689 function renderTpgPreview() {
690 if ($("#rttpg_meta").length) {
691 var data = $("#rttpg_meta").find('input[name],select[name],textarea[name]').serialize(),
692 container = $("#rttpg_meta").find('.rt-tpg-container'),
693 loader = container.find(".rt-content-loader");
694 data = data + '&' + $.param({'sc_id': $('#post_ID').val() || 0});
695 $(".rt-loading").remove();
696 $(".rt-response").addClass('loading');
697 $(".rt-response").html('<span>Loading...</span>');
698 tpgAjaxCall(null, 'tpgPreviewAjaxCall', data, function (data) {
699 if (!data.error) {
700 $("#tpg-preview-container").html(data.data);
701 preFunction();
702 IsotopeNCarouselRender();
703 loader.find('.rt-loading-overlay, .rt-loading').remove();
704 loader.removeClass('tpg-pre-loader');
705 }
706 $(".rt-response").removeClass('loading');
707 $(".rt-response").html('');
708 });
709 }
710 }
711
712
713 function tpgPreviewAjaxCall(element, action, arg, handle) {
714 var data;
715 if (action) data = "action=" + action;
716 if (arg) data = arg + "&action=" + action;
717 if (arg && !action) data = arg;
718
719 var n = data.search(rttpg.nonceID);
720 if (n < 0) {
721 data = data + "&" + rttpg.nonceID + "=" + rttpg.nonce;
722 }
723 $.ajax({
724 type: "post",
725 url: wls.ajaxurl,
726 data: data,
727 beforeSend: function () {
728 $("<span class='rt-loading'></span>").insertAfter(element);
729 },
730 success: function (data) {
731 $(".rt-loading").remove();
732 handle(data);
733 }
734 });
735 }
736
737
738 function overlayIconResizeTpg() {
739 jQuery('.overlay').each(function () {
740 var holder_height = jQuery(this).height();
741 var target = jQuery(this).children('.link-holder');
742 var targetd = jQuery(this).children('.view-details');
743 var a_height = target.height();
744 var ad_height = targetd.height();
745 var h = (holder_height - a_height) / 2;
746 var hd = (holder_height - ad_height) / 2;
747 target.css('top', h + 'px');
748 targetd.css('margin-top', hd + 'px');
749 });
750 }
751
752 if ($(".rt-row.rt-content-loader.layout4").length) {
753 equalHeight4Layout4();
754 }
755
756 function equalHeight4Layout4() {
757 var $maxH = $(".rt-row.layout4 .layout4item").height();
758 $(".rt-row.layout4 .layout4item .layoutInner .rt-img-holder img,.rt-row.layout4 .layout4item .layoutInner.layoutInner-content").height($maxH + "px");
759 }
760
761 function windowHashChange(isotope, IsoButton) {
762 var $hashFilter = decodeHash() || '';
763 if (!$hashFilter) {
764 $hashFilter = IsoButton.find('button.selected').attr('data-filter') || '';
765 $hashFilter = $hashFilter ? $hashFilter : '*';
766 }
767 $hashFilter = $hashFilter || '*';
768 isotope.isotope({
769 filter: $hashFilter
770 });
771 IsoButton.find("button").removeClass("selected");
772 IsoButton.find('button[data-filter="' + $hashFilter + '"]').addClass("selected");
773 }
774
775 function isoFilterCounter(container, isotope) {
776 var total = 0;
777 container.find('.rt-tpg-isotope-buttons button').each(function () {
778 var self = $(this),
779 filter = self.attr("data-filter"),
780 itemTotal = isotope.find(filter).length;
781 if (filter != "*") {
782 self.find('span').remove();
783 self.append("<span> (" + itemTotal + ") </span>");
784 total = total + itemTotal;
785 }
786 });
787 container.find('.rt-tpg-isotope-buttons button[data-filter="*"]').find('span').remove();
788 container.find('.rt-tpg-isotope-buttons button[data-filter="*"]').append("<span> (" + total + ") </span>");
789 }
790
791 function decodeHash() {
792 var $matches = location.hash.match(/filter=([^&]+)/i);
793 var $hashFilter = $matches && $matches[1];
794 return $hashFilter && decodeURIComponent($hashFilter);
795 }
796
797 function tpgAjaxCall(element, action, arg, handle) {
798 var data;
799 if (action) data = "action=" + action;
800 if (arg) data = arg + "&action=" + action;
801 if (arg && !action) data = arg;
802
803 var n = data.search(rttpg.nonceID);
804 if (n < 0) {
805 data = data + "&rttpg_nonce=" + rttpg.nonce;
806 }
807 $.ajax({
808 type: "post",
809 url: rttpg.ajaxurl,
810 data: data,
811 beforeSend: function () {
812 if (element) {
813 $("<span class='rt-loading'></span>").insertAfter(element);
814 }
815 },
816 success: function (data) {
817 if (element) {
818 element.next(".rt-loading").remove();
819 }
820 handle(data);
821 }
822 });
823 }
824 })(jQuery);