PluginProbe
Datafeedr API / 1.0.125
Datafeedr API v1.0.125
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.125, at js/merchants.js

152 lines 4.7 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").on("click", function (e) {
29 $(".networks", this).toggle(500);
30 e.preventDefault();
31 });
32
33 $("#dfrapi_networks .group .networks").on("click", function (e) {
34 e.stopPropagation();
35 });
36
37 $("#dfrapi_networks .group .networks .network .check_network").on("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 $("#" + id + " .tid_input").children().show();
47 } else {
48 $("#" + id + " .aid_input").children().hide();
49 $("#" + id + " .tid_input").children().hide();
50 }
51 }).trigger( "change" );
52
53 // Merchants Settings Page
54 var refreshSearch = function(e) {
55 $(e).closest(".network").find(".merchant_actions input").change();
56 }
57
58 $("#dfrapi_merchants .network .meta").on("click", function () {
59 $(this).parent().find(".merchants").slideToggle(500);
60 });
61
62 $("#dfrapi_merchants .hide_empty_merchants").on("click", function () {
63 var n = $(this).closest(".network");
64 n.find(".no_products").addClass("hidden");
65 n.find(".show_empty_merchants").show();
66 $(this).hide();
67 refreshSearch(this);
68 return false;
69 });
70
71 $("#dfrapi_merchants .show_empty_merchants").on("click",function () {
72 var n = $(this).closest(".network");
73 n.find(".no_products").removeClass("hidden");
74 n.find(".hide_empty_merchants").show();
75 $(this).hide();
76 refreshSearch(this);
77 return false;
78 });
79
80 var selMerchant = function(elem, select, merchant) {
81 var left = $(elem).closest(".network").find(".dfrapi_pane_left .dfrapi_pane_content");
82 var right = $(elem).closest(".network").find(".dfrapi_pane_right .dfrapi_pane_content");
83
84 var src = select ? left : right;
85 var dst = select ? right : left;
86
87 var m = merchant ? $(merchant)[0] : null;
88
89 src.find(".merchant:visible").each(function() {
90 if(!m || this == m) {
91 dst.append(this);
92 }
93 });
94 dst.sort({by: '.merchant_name'});
95 refreshSearch(elem);
96
97 var ids = [];
98 $(".dfrapi_pane_right .merchant").each(function() {
99 ids.push(this.id.split("_").pop());
100 });
101 $("#ids").val(ids.sort().join(","));
102 };
103
104 $('#dfrapi_merchants .add_all').on("click", function () {
105 selMerchant(this, true, null);
106 return false;
107 });
108
109 $('#dfrapi_merchants .remove_all').on("click", function () {
110 selMerchant(this, false, null);
111 return false;
112 });
113
114 $("#dfrapi_merchants .merchant").on("click", function() {
115 var isLeft = $(this).closest(".dfrapi_pane_left").length;
116 selMerchant(this, isLeft, this);
117 return false;
118 });
119
120
121 $("#dfrapi_merchants .merchant_actions input").each(function() {
122 $(this).searchFilter({
123 element: function() { return $(this).closest(".network").find(".merchant") },
124 subject: ".merchant_name",
125 highlight: "<span style='background: yellow'>",
126 stepSize: 100,
127 after: function() { $(this).parent().find(".hidden").removeAttr("style") }
128 });
129 });
130
131 $("#dfrapi_merchants .merchant_actions .reset_search").on("click", function() {
132 $(this).parent().find("input").val("").change();
133 return false;
134 });
135
136
137 if($("#dfrapi_networks").length || $("#dfrapi_merchants").length) {
138 var initState = $("form").serialize();
139 window.onbeforeunload = function() {
140 var currState = $("form").serialize();
141 if(currState != initState)
142 return $("#dfr_unload_message").text();
143 };
144 $("form").on('submit', function() {
145 window.onbeforeunload = null;
146 })
147 }
148
149 });
150
151
152