PluginProbe
WP Directory Kit / 1.2.7
WP Directory Kit v1.2.7
1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 1.4.0 1.4.1 All 35 releases
wpdirectorykit / elementor-elements / assets / js / wdk-main.js

wdk-main.js in WP Directory Kit 1.2.7, at elementor-elements/assets/js/wdk-main.js

117 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function( $ ) {
2 'use strict';
3
4 /**
5 * All of the code for your public-facing JavaScript source
6 * should reside in this file.
7 *
8 * Note: It has been assumed you will write jQuery code here, so the
9 * $ function reference has been prepared for usage within the scope
10 * of this function.
11 *
12 * This enables you to define handlers, for when the DOM is ready:
13 *
14 * $(function() {
15 *
16 * });
17 *
18 * When the window is loaded:
19 *
20 * $( window ).load(function() {
21 *
22 * });
23 *
24 * ...and/or other possibilities.
25 *
26 * Ideally, it is not considered best practise to attach more than a
27 * single DOM-ready or window-load handler for a particular page.
28 * Although scripts in the WordPress core, Plugins and Themes may be
29 * practising this, we should strive to set a better example in our own work.
30 */
31
32 $('.wdk-order').on('change', function(){
33 var curr_url = wdk_removeParam('order_by', document.location.toString());
34 if (curr_url.indexOf('#') == -1) {
35 // Fine
36 } else {
37 // Remove this part related
38 curr_url = curr_url.substr(0, curr_url.indexOf('#'));
39 }
40
41 var del_char = '&';
42 if (curr_url.indexOf('?') == -1)
43 del_char = '?';
44
45 document.location = curr_url + del_char + 'order_by=' + $(this).val()+'#results';
46 })
47
48 $('.wmvc-view-type a').on('click', function (e) {
49 e.preventDefault();
50 var curr_url = wdk_removeParam('wmvc_view_type', document.location.toString());
51 if (curr_url.indexOf('#') == -1) {
52 // Fine
53 } else {
54 // Remove this part related
55 curr_url = curr_url.substr(0, curr_url.indexOf('#'));
56 }
57
58 var del_char = '&';
59 if (curr_url.indexOf('?') == -1)
60 del_char = '?';
61
62 document.location = curr_url + del_char + 'wmvc_view_type=' + $(this).attr('data-id')+'#results';
63 })
64
65 $('.wdk-categories-tree a.btn-more').on('click', function (e) {
66 e.preventDefault();
67 $(this).closest('.wdk-categories-tree').find('.category-block').removeClass('wdk-hidden');
68 $(this).closest('.wdk-col').remove();
69 })
70
71 $('.wdk-categories-tree .wdk-categories .wdk-item.wdk-item-toggle').each(function(){
72 $(this).closest('.wdk-categories').append($(this).detach());
73 });
74
75 $('.wdk-categories-tree .wdk-categories a.wdk-link-show-more').off().on('click', function (e) {
76 e.preventDefault();
77 var btn = $(this).closest('.wdk-item-toggle');
78 btn.siblings('.wdk-item.more-sub').toggle();
79 })
80
81
82 })(jQuery);
83
84 function wdk_removeParam(key, sourceURL) {
85 var rtn = sourceURL.split("?")[0],
86 param,
87 params_arr = [],
88 queryString = (sourceURL.indexOf("?") !== -1) ? sourceURL.split("?")[1] : "";
89 if (queryString !== "") {
90 params_arr = queryString.split("&");
91 for (var i = params_arr.length - 1; i >= 0; i -= 1) {
92 param = params_arr[i].split("=")[0];
93 if (param === key) {
94 params_arr.splice(i, 1);
95 }
96 }
97 if (params_arr.length) rtn = rtn + "?" + params_arr.join("&");
98 }
99 return rtn;
100 }
101
102 function wdk_splitUrl() {
103 var vars = [],
104 hash;
105 var url = document.URL.split('?')[0];
106 var p = document.URL.split('?')[1];
107 if (p != undefined) {
108 p = p.split('&');
109 for (var i = 0; i < p.length; i++) {
110 hash = p[i].split('=');
111 vars.push(hash[1]);
112 vars[hash[0]] = hash[1];
113 }
114 }
115 vars['url'] = url;
116 return vars;
117 };