PluginProbe
WP Directory Kit / 1.2.3
WP Directory Kit v1.2.3
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.3, at elementor-elements/assets/js/wdk-main.js

100 lines 3.0 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 })(jQuery);
66
67 function wdk_removeParam(key, sourceURL) {
68 var rtn = sourceURL.split("?")[0],
69 param,
70 params_arr = [],
71 queryString = (sourceURL.indexOf("?") !== -1) ? sourceURL.split("?")[1] : "";
72 if (queryString !== "") {
73 params_arr = queryString.split("&");
74 for (var i = params_arr.length - 1; i >= 0; i -= 1) {
75 param = params_arr[i].split("=")[0];
76 if (param === key) {
77 params_arr.splice(i, 1);
78 }
79 }
80 if (params_arr.length) rtn = rtn + "?" + params_arr.join("&");
81 }
82 return rtn;
83 }
84
85 function wdk_splitUrl() {
86 var vars = [],
87 hash;
88 var url = document.URL.split('?')[0];
89 var p = document.URL.split('?')[1];
90 if (p != undefined) {
91 p = p.split('&');
92 for (var i = 0; i < p.length; i++) {
93 hash = p[i].split('=');
94 vars.push(hash[1]);
95 vars[hash[0]] = hash[1];
96 }
97 }
98 vars['url'] = url;
99 return vars;
100 };