PluginProbe
Datafeedr API / 1.0.3
Datafeedr API v1.0.3
1.4.3 1.4.2 1.0.125 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 1.0.25 1.0.26 1.0.27 1.0.28 1.0.29 1.0.3 1.0.30 1.0.31 1.0.32 All 182 releases
datafeedr-api / js / merchants.js

merchants.js in Datafeedr API 1.0.3, at js/merchants.js

149 lines 4.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 jQuery(function($) {
2
3 $.fn.sort = function(opts) {
4
5 return $(this).each(function() {
6 var box = $(this), ls = [];
7
8 box.children().each(function() {
9 var p = opts.by ? $(this).find(opts.by) : this;
10 var t = $(p).text();
11 if(!opts.case)
12 t = t.toUpperCase();
13 ls.push([t, this]);
14 });
15 ls.sort(function(a, b) {
16 var n = a[0] > b[0] ? 1 : a[0] < b[0] ? -1 : 0;
17 return opts.reverse ? -n : n;
18 });
19 $.each(ls, function() {
20 box.append(this[1]);
21 });
22 return this;
23 });
24
25 };
26
27 // Networks Settings Page
28 $("#dfrapi_networks .group").click(function (e) {
29 $(".networks", this).toggle(500);
30 e.preventDefault();
31 });
32
33 $("#dfrapi_networks .group .networks").click(function(e) {
34 e.stopPropagation();
35 });
36
37 $("#dfrapi_networks .group .networks .network .check_network").change(function(e) {
38 var parent = $(this).parent('td').parent('tr');
39 var id = parent.attr('id');
40 var nid = parent.attr('nid');
41 var key = parent.attr('key');
42 var aid = parent.attr('aid');
43 var tid = parent.attr('tid');
44 if ($(this).prop('checked')) {
45 $("#" + id + " .aid_input").children().show();
46 } else {
47 $("#" + id + " .aid_input").children().hide();
48 }
49 }).change();
50
51 // Merchants Settings Page
52 var refreshSearch = function(e) {
53 $(e).closest(".network").find(".merchant_actions input").change();
54 }
55
56 $("#dfrapi_merchants .network .meta").click(function () {
57 $(this).parent().find(".merchants").slideToggle(500);
58 });
59
60 $("#dfrapi_merchants .hide_empty_merchants").click(function () {
61 var n = $(this).closest(".network");
62 n.find(".no_products").addClass("hidden");
63 n.find(".show_empty_merchants").show();
64 $(this).hide();
65 refreshSearch(this);
66 return false;
67 });
68
69 $("#dfrapi_merchants .show_empty_merchants").click(function () {
70 var n = $(this).closest(".network");
71 n.find(".no_products").removeClass("hidden");
72 n.find(".hide_empty_merchants").show();
73 $(this).hide();
74 refreshSearch(this);
75 return false;
76 });
77
78 var selMerchant = function(elem, select, merchant) {
79 var left = $(elem).closest(".network").find(".dfrapi_pane_left .dfrapi_pane_content");
80 var right = $(elem).closest(".network").find(".dfrapi_pane_right .dfrapi_pane_content");
81
82 var src = select ? left : right;
83 var dst = select ? right : left;
84
85 var m = merchant ? $(merchant)[0] : null;
86
87 src.find(".merchant:visible").each(function() {
88 if(!m || this == m) {
89 dst.append(this);
90 }
91 });
92 dst.sort({by: '.merchant_name'});
93 refreshSearch(elem);
94
95 var ids = [];
96 $(".dfrapi_pane_right .merchant").each(function() {
97 ids.push(this.id.split("_").pop());
98 });
99 $("#ids").val(ids.sort().join(","));
100 };
101
102 $('#dfrapi_merchants .add_all').click(function () {
103 selMerchant(this, true, null);
104 return false;
105 });
106
107 $('#dfrapi_merchants .remove_all').click(function () {
108 selMerchant(this, false, null);
109 return false;
110 });
111
112 $("#dfrapi_merchants .merchant").click(function() {
113 var isLeft = $(this).closest(".dfrapi_pane_left").length;
114 selMerchant(this, isLeft, this);
115 return false;
116 });
117
118
119 $("#dfrapi_merchants .merchant_actions input").each(function() {
120 $(this).searchFilter({
121 element: function() { return $(this).closest(".network").find(".merchant") },
122 subject: ".merchant_name",
123 highlight: "<span style='background: yellow'>",
124 after: function() { $(this).parent().find(".hidden").removeAttr("style") }
125 });
126 });
127
128 $("#dfrapi_merchants .merchant_actions .reset_search").click(function() {
129 $(this).parent().find("input").val("").change();
130 return false;
131 });
132
133
134 if($("#dfrapi_networks").length || $("#dfrapi_merchants").length) {
135 var initState = $("form").serialize();
136 window.onbeforeunload = function() {
137 var currState = $("form").serialize();
138 if(currState != initState)
139 return $("#dfr_unload_message").text();
140 };
141 $("form").on('submit', function() {
142 window.onbeforeunload = null;
143 })
144 }
145
146 });
147
148
149