first commit
This commit is contained in:
5
wp-content/plugins/woo-product-feed-pro/js/index.php
Normal file
5
wp-content/plugins/woo-product-feed-pro/js/index.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
/**
|
||||
* Nothing to see here.
|
||||
*/
|
||||
?>
|
||||
484
wp-content/plugins/woo-product-feed-pro/js/typeahead.js
Normal file
484
wp-content/plugins/woo-product-feed-pro/js/typeahead.js
Normal file
@@ -0,0 +1,484 @@
|
||||
/* =============================================================
|
||||
* bootstrap3-typeahead.js v3.1.0
|
||||
* https://github.com/bassjobsen/Bootstrap-3-Typeahead
|
||||
* =============================================================
|
||||
* Original written by @mdo and @fat
|
||||
* =============================================================
|
||||
* Copyright 2014 Bass Jobsen @bassjobsen
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the 'License');
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an 'AS IS' BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ============================================================ */
|
||||
|
||||
|
||||
(function (root, factory) {
|
||||
|
||||
'use strict';
|
||||
|
||||
// CommonJS module is defined
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
module.exports = factory(require('jquery'));
|
||||
}
|
||||
// AMD module is defined
|
||||
else if (typeof define === 'function' && define.amd) {
|
||||
define(['jquery'], function ($) {
|
||||
return factory ($);
|
||||
});
|
||||
} else {
|
||||
factory(root.jQuery);
|
||||
}
|
||||
|
||||
}(this, function ($) {
|
||||
|
||||
'use strict';
|
||||
// jshint laxcomma: true
|
||||
|
||||
|
||||
/* TYPEAHEAD PUBLIC CLASS DEFINITION
|
||||
* ================================= */
|
||||
|
||||
var Typeahead = function (element, options) {
|
||||
this.$element = $(element);
|
||||
this.options = $.extend({}, $.fn.typeahead.defaults, options);
|
||||
this.matcher = this.options.matcher || this.matcher;
|
||||
this.sorter = this.options.sorter || this.sorter;
|
||||
this.select = this.options.select || this.select;
|
||||
this.autoSelect = typeof this.options.autoSelect == 'boolean' ? this.options.autoSelect : true;
|
||||
this.highlighter = this.options.highlighter || this.highlighter;
|
||||
this.render = this.options.render || this.render;
|
||||
this.updater = this.options.updater || this.updater;
|
||||
this.displayText = this.options.displayText || this.displayText;
|
||||
this.source = this.options.source;
|
||||
this.delay = this.options.delay;
|
||||
this.$menu = $(this.options.menu);
|
||||
this.$appendTo = this.options.appendTo ? $(this.options.appendTo) : null;
|
||||
this.shown = false;
|
||||
this.listen();
|
||||
this.showHintOnFocus = typeof this.options.showHintOnFocus == 'boolean' ? this.options.showHintOnFocus : false;
|
||||
this.afterSelect = this.options.afterSelect;
|
||||
this.addItem = false;
|
||||
};
|
||||
|
||||
Typeahead.prototype = {
|
||||
|
||||
constructor: Typeahead,
|
||||
|
||||
select: function () {
|
||||
var val = this.$menu.find('.active').data('value');
|
||||
this.$element.data('active', val);
|
||||
if(this.autoSelect || val) {
|
||||
var newVal = this.updater(val);
|
||||
// Updater can be set to any random functions via "options" parameter in constructor above.
|
||||
// Add null check for cases when upadter returns void or undefined.
|
||||
if (!newVal) {
|
||||
newVal = "";
|
||||
}
|
||||
this.$element
|
||||
.val(this.displayText(newVal) || newVal)
|
||||
.change();
|
||||
this.afterSelect(newVal);
|
||||
}
|
||||
return this.hide();
|
||||
},
|
||||
|
||||
updater: function (item) {
|
||||
return item;
|
||||
},
|
||||
|
||||
setSource: function (source) {
|
||||
this.source = source;
|
||||
},
|
||||
|
||||
show: function () {
|
||||
var pos = $.extend({}, this.$element.position(), {
|
||||
height: this.$element[0].offsetHeight
|
||||
}), scrollHeight;
|
||||
|
||||
scrollHeight = typeof this.options.scrollHeight == 'function' ?
|
||||
this.options.scrollHeight.call() :
|
||||
this.options.scrollHeight;
|
||||
|
||||
var element;
|
||||
if (this.shown) {
|
||||
element = this.$menu;
|
||||
} else if (this.$appendTo) {
|
||||
element = this.$menu.appendTo(this.$appendTo);
|
||||
} else {
|
||||
element = this.$menu.insertAfter(this.$element);
|
||||
}
|
||||
element.css({
|
||||
top: pos.top + pos.height + scrollHeight
|
||||
, left: pos.left
|
||||
})
|
||||
.show();
|
||||
|
||||
this.shown = true;
|
||||
return this;
|
||||
},
|
||||
|
||||
hide: function () {
|
||||
this.$menu.hide();
|
||||
this.shown = false;
|
||||
return this;
|
||||
},
|
||||
|
||||
lookup: function (query) {
|
||||
var items;
|
||||
if (typeof(query) != 'undefined' && query !== null) {
|
||||
this.query = query;
|
||||
} else {
|
||||
this.query = this.$element.val() || '';
|
||||
}
|
||||
|
||||
if (this.query.length < this.options.minLength) {
|
||||
return this.shown ? this.hide() : this;
|
||||
}
|
||||
|
||||
var worker = $.proxy(function() {
|
||||
|
||||
if($.isFunction(this.source)) this.source(this.query, $.proxy(this.process, this));
|
||||
else if (this.source) {
|
||||
this.process(this.source);
|
||||
}
|
||||
}, this);
|
||||
|
||||
clearTimeout(this.lookupWorker);
|
||||
this.lookupWorker = setTimeout(worker, this.delay);
|
||||
},
|
||||
|
||||
process: function (items) {
|
||||
var that = this;
|
||||
|
||||
items = $.grep(items, function (item) {
|
||||
return that.matcher(item);
|
||||
});
|
||||
|
||||
items = this.sorter(items);
|
||||
|
||||
if (!items.length && !this.options.addItem) {
|
||||
return this.shown ? this.hide() : this;
|
||||
}
|
||||
|
||||
if (items.length > 0) {
|
||||
this.$element.data('active', items[0]);
|
||||
} else {
|
||||
this.$element.data('active', null);
|
||||
}
|
||||
|
||||
// Add item
|
||||
if (this.options.addItem){
|
||||
items.push(this.options.addItem);
|
||||
}
|
||||
|
||||
if (this.options.items == 'all') {
|
||||
return this.render(items).show();
|
||||
} else {
|
||||
return this.render(items.slice(0, this.options.items)).show();
|
||||
}
|
||||
},
|
||||
|
||||
matcher: function (item) {
|
||||
var it = this.displayText(item);
|
||||
return ~it.toLowerCase().indexOf(this.query.toLowerCase());
|
||||
},
|
||||
|
||||
sorter: function (items) {
|
||||
var beginswith = []
|
||||
, caseSensitive = []
|
||||
, caseInsensitive = []
|
||||
, item;
|
||||
|
||||
while ((item = items.shift())) {
|
||||
var it = this.displayText(item);
|
||||
if (!it.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item);
|
||||
else if (~it.indexOf(this.query)) caseSensitive.push(item);
|
||||
else caseInsensitive.push(item);
|
||||
}
|
||||
|
||||
return beginswith.concat(caseSensitive, caseInsensitive);
|
||||
},
|
||||
|
||||
highlighter: function (item) {
|
||||
var html = $('<div></div>');
|
||||
var query = this.query;
|
||||
var i = item.toLowerCase().indexOf(query.toLowerCase());
|
||||
var len, leftPart, middlePart, rightPart, strong;
|
||||
len = query.length;
|
||||
if(len === 0){
|
||||
return html.text(item).html();
|
||||
}
|
||||
while (i > -1) {
|
||||
leftPart = item.substr(0, i);
|
||||
middlePart = item.substr(i, len);
|
||||
rightPart = item.substr(i + len);
|
||||
strong = $('<strong></strong>').text(middlePart);
|
||||
html
|
||||
.append(document.createTextNode(leftPart))
|
||||
.append(strong);
|
||||
item = rightPart;
|
||||
i = item.toLowerCase().indexOf(query.toLowerCase());
|
||||
}
|
||||
return html.append(document.createTextNode(item)).html();
|
||||
},
|
||||
|
||||
render: function (items) {
|
||||
var that = this;
|
||||
var self = this;
|
||||
var activeFound = false;
|
||||
items = $(items).map(function (i, item) {
|
||||
var text = self.displayText(item);
|
||||
i = $(that.options.item).data('value', item);
|
||||
i.find('a').html(that.highlighter(text));
|
||||
if (text == self.$element.val()) {
|
||||
i.addClass('active');
|
||||
self.$element.data('active', item);
|
||||
activeFound = true;
|
||||
}
|
||||
return i[0];
|
||||
});
|
||||
|
||||
if (this.autoSelect && !activeFound) {
|
||||
items.first().addClass('active');
|
||||
this.$element.data('active', items.first().data('value'));
|
||||
}
|
||||
this.$menu.html(items);
|
||||
return this;
|
||||
},
|
||||
|
||||
displayText: function(item) {
|
||||
return typeof item !== 'undefined' && typeof item.name != 'undefined' && item.name || item;
|
||||
},
|
||||
|
||||
next: function (event) {
|
||||
var active = this.$menu.find('.active').removeClass('active')
|
||||
, next = active.next();
|
||||
|
||||
if (!next.length) {
|
||||
next = $(this.$menu.find('li')[0]);
|
||||
}
|
||||
|
||||
next.addClass('active');
|
||||
},
|
||||
|
||||
prev: function (event) {
|
||||
var active = this.$menu.find('.active').removeClass('active')
|
||||
, prev = active.prev();
|
||||
|
||||
if (!prev.length) {
|
||||
prev = this.$menu.find('li').last();
|
||||
}
|
||||
|
||||
prev.addClass('active');
|
||||
},
|
||||
|
||||
listen: function () {
|
||||
this.$element
|
||||
.on('focus', $.proxy(this.focus, this))
|
||||
.on('blur', $.proxy(this.blur, this))
|
||||
.on('keypress', $.proxy(this.keypress, this))
|
||||
.on('keyup', $.proxy(this.keyup, this));
|
||||
|
||||
if (this.eventSupported('keydown')) {
|
||||
this.$element.on('keydown', $.proxy(this.keydown, this));
|
||||
}
|
||||
|
||||
this.$menu
|
||||
.on('click', $.proxy(this.click, this))
|
||||
.on('mouseenter', 'li', $.proxy(this.mouseenter, this))
|
||||
.on('mouseleave', 'li', $.proxy(this.mouseleave, this));
|
||||
},
|
||||
|
||||
destroy : function () {
|
||||
this.$element.data('typeahead',null);
|
||||
this.$element.data('active',null);
|
||||
this.$element
|
||||
.off('focus')
|
||||
.off('blur')
|
||||
.off('keypress')
|
||||
.off('keyup');
|
||||
|
||||
if (this.eventSupported('keydown')) {
|
||||
this.$element.off('keydown');
|
||||
}
|
||||
|
||||
this.$menu.remove();
|
||||
},
|
||||
|
||||
eventSupported: function(eventName) {
|
||||
var isSupported = eventName in this.$element;
|
||||
if (!isSupported) {
|
||||
this.$element.setAttribute(eventName, 'return;');
|
||||
isSupported = typeof this.$element[eventName] === 'function';
|
||||
}
|
||||
return isSupported;
|
||||
},
|
||||
|
||||
move: function (e) {
|
||||
if (!this.shown) return;
|
||||
|
||||
switch(e.keyCode) {
|
||||
case 9: // tab
|
||||
case 13: // enter
|
||||
case 27: // escape
|
||||
e.preventDefault();
|
||||
break;
|
||||
|
||||
case 38: // up arrow
|
||||
// with the shiftKey (this is actually the left parenthesis)
|
||||
if (e.shiftKey) return;
|
||||
e.preventDefault();
|
||||
this.prev();
|
||||
break;
|
||||
|
||||
case 40: // down arrow
|
||||
// with the shiftKey (this is actually the right parenthesis)
|
||||
if (e.shiftKey) return;
|
||||
e.preventDefault();
|
||||
this.next();
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
keydown: function (e) {
|
||||
this.suppressKeyPressRepeat = ~$.inArray(e.keyCode, [40,38,9,13,27]);
|
||||
if (!this.shown && e.keyCode == 40) {
|
||||
this.lookup();
|
||||
} else {
|
||||
this.move(e);
|
||||
}
|
||||
},
|
||||
|
||||
keypress: function (e) {
|
||||
if (this.suppressKeyPressRepeat) return;
|
||||
this.move(e);
|
||||
},
|
||||
|
||||
keyup: function (e) {
|
||||
switch(e.keyCode) {
|
||||
case 40: // down arrow
|
||||
case 38: // up arrow
|
||||
case 16: // shift
|
||||
case 17: // ctrl
|
||||
case 18: // alt
|
||||
break;
|
||||
|
||||
case 9: // tab
|
||||
case 13: // enter
|
||||
if (!this.shown) return;
|
||||
this.select();
|
||||
break;
|
||||
|
||||
case 27: // escape
|
||||
if (!this.shown) return;
|
||||
this.hide();
|
||||
break;
|
||||
default:
|
||||
this.lookup();
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
},
|
||||
|
||||
focus: function (e) {
|
||||
if (!this.focused) {
|
||||
this.focused = true;
|
||||
if (this.options.showHintOnFocus) {
|
||||
this.lookup('');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
blur: function (e) {
|
||||
this.focused = false;
|
||||
if (!this.mousedover && this.shown) this.hide();
|
||||
},
|
||||
|
||||
click: function (e) {
|
||||
e.preventDefault();
|
||||
this.select();
|
||||
this.$element.focus();
|
||||
},
|
||||
|
||||
mouseenter: function (e) {
|
||||
this.mousedover = true;
|
||||
this.$menu.find('.active').removeClass('active');
|
||||
$(e.currentTarget).addClass('active');
|
||||
},
|
||||
|
||||
mouseleave: function (e) {
|
||||
this.mousedover = false;
|
||||
if (!this.focused && this.shown) this.hide();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* TYPEAHEAD PLUGIN DEFINITION
|
||||
* =========================== */
|
||||
|
||||
var old = $.fn.typeahead;
|
||||
|
||||
$.fn.typeahead = function (option) {
|
||||
var arg = arguments;
|
||||
if (typeof option == 'string' && option == 'getActive') {
|
||||
return this.data('active');
|
||||
}
|
||||
return this.each(function () {
|
||||
var $this = $(this)
|
||||
, data = $this.data('typeahead')
|
||||
, options = typeof option == 'object' && option;
|
||||
if (!data) $this.data('typeahead', (data = new Typeahead(this, options)));
|
||||
if (typeof option == 'string') {
|
||||
if (arg.length > 1) {
|
||||
data[option].apply(data, Array.prototype.slice.call(arg ,1));
|
||||
} else {
|
||||
data[option]();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$.fn.typeahead.defaults = {
|
||||
source: []
|
||||
, items: 8
|
||||
, menu: '<ul class="typeahead dropdown-menu" role="listbox"></ul>'
|
||||
, item: '<li><a class="dropdown-item" href="#" role="option"></a></li>'
|
||||
, minLength: 1
|
||||
, scrollHeight: 0
|
||||
, autoSelect: true
|
||||
, afterSelect: $.noop
|
||||
, addItem: false
|
||||
, delay: 0
|
||||
};
|
||||
|
||||
$.fn.typeahead.Constructor = Typeahead;
|
||||
|
||||
|
||||
/* TYPEAHEAD NO CONFLICT
|
||||
* =================== */
|
||||
|
||||
$.fn.typeahead.noConflict = function () {
|
||||
$.fn.typeahead = old;
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
/* TYPEAHEAD DATA-API
|
||||
* ================== */
|
||||
|
||||
$(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
|
||||
var $this = $(this);
|
||||
if ($this.data('typeahead')) return;
|
||||
$this.typeahead($this.data());
|
||||
});
|
||||
|
||||
}));
|
||||
@@ -0,0 +1,93 @@
|
||||
jQuery(document).ready(function($) {
|
||||
//localStorage.removeItem("attributes");
|
||||
$( "select" ).change(function() {
|
||||
|
||||
//localStorage.removeItem("attributes");
|
||||
var productId = $('input[name=product_id]').val();
|
||||
var selectedName = $(this).attr("name");
|
||||
var selectedValue = $(this).find('option:selected').text();
|
||||
var storedAttributes = JSON.parse(localStorage.getItem("attributes"));
|
||||
|
||||
// Already saved a selection in local storage
|
||||
if(storedAttributes){
|
||||
// Only add new selections to the local storage
|
||||
var len_value = selectedValue.length;
|
||||
if(len_value > 0){
|
||||
storedAttributes[selectedName] = selectedValue;
|
||||
localStorage.setItem("attributes", JSON.stringify(storedAttributes));
|
||||
}
|
||||
} else {
|
||||
var json_attributes = new Object();
|
||||
json_attributes.productId = productId;
|
||||
json_attributes[selectedName] = selectedValue;
|
||||
localStorage.setItem("attributes", JSON.stringify(json_attributes));
|
||||
}
|
||||
|
||||
var storedAttributes = JSON.parse(localStorage.getItem("attributes"));
|
||||
|
||||
// Now AJAX call to save in options
|
||||
var inputdata = {
|
||||
'action': 'woosea_storedattributes_details',
|
||||
'data_to_pass': productId,
|
||||
'storedAttributes': storedAttributes,
|
||||
}
|
||||
|
||||
$.post(frontEndAjax.ajaxurl, inputdata, function( response ) {
|
||||
}, 'json' );
|
||||
|
||||
console.log(storedAttributes);
|
||||
});
|
||||
|
||||
// For shop pages
|
||||
$(".add_to_cart_button").click(function(){
|
||||
var productId = $(this).attr('data-product_id');
|
||||
|
||||
console.log(productId);
|
||||
|
||||
// Ajax frontend
|
||||
var inputdata = {
|
||||
'action': 'woosea_addtocart_details',
|
||||
'data_to_pass': productId,
|
||||
}
|
||||
|
||||
$.post(frontEndAjax.ajaxurl, inputdata, function( response ) {
|
||||
fbq("track", "AddToCart", {
|
||||
content_ids: "['" + response.product_id + "']",
|
||||
content_name: response.product_name,
|
||||
content_category: response.product_cats,
|
||||
content_type: "product",
|
||||
value: response.product_price,
|
||||
currency: response.product_currency,
|
||||
});
|
||||
}, 'json' );
|
||||
});
|
||||
|
||||
// For product pages
|
||||
$(".single_add_to_cart_button").click(function(){
|
||||
var productId = $('input[name=product_id]').val();
|
||||
|
||||
if(!productId){
|
||||
productId = $(this).attr('value');
|
||||
}
|
||||
|
||||
console.log(productId);
|
||||
|
||||
// Ajax frontend
|
||||
var inputdata = {
|
||||
'action': 'woosea_addtocart_details',
|
||||
'data_to_pass': productId,
|
||||
}
|
||||
|
||||
$.post(frontEndAjax.ajaxurl, inputdata, function( response ) {
|
||||
|
||||
fbq("track", "AddToCart", {
|
||||
content_ids: "['" + response.product_id + "']",
|
||||
content_name: response.product_name,
|
||||
content_category: response.product_cats,
|
||||
content_type: "product",
|
||||
value: response.product_price,
|
||||
currency: response.product_currency,
|
||||
});
|
||||
}, 'json' );
|
||||
});
|
||||
});
|
||||
5786
wp-content/plugins/woo-product-feed-pro/js/woosea_autocomplete.js
Normal file
5786
wp-content/plugins/woo-product-feed-pro/js/woosea_autocomplete.js
Normal file
File diff suppressed because it is too large
Load Diff
180
wp-content/plugins/woo-product-feed-pro/js/woosea_channel.js
Normal file
180
wp-content/plugins/woo-product-feed-pro/js/woosea_channel.js
Normal file
@@ -0,0 +1,180 @@
|
||||
jQuery(document).ready(function($) {
|
||||
jQuery("#shipping_zone").on('click', function(){
|
||||
var variations = ( $( "#shipping_zone" ).is(':checked')) ? 1 : 0;
|
||||
if(variations == "1"){
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: { 'action': 'woosea_shipping_zones' }
|
||||
})
|
||||
.done(function( data ) {
|
||||
data = JSON.parse( data );
|
||||
$('#shipping_zones').after('<tr id="select_shipping_zone"><td><i>Select shipping zone:</i><br/>You have multiple shipping zones configured for your shop. Do you want to add all Shipping zones to your product feed or just a one?</td><td valign="top"><select name="zone" class="select-field">' + data.dropdown + '</select></td></tr>');
|
||||
})
|
||||
.fail(function( data ) {
|
||||
console.log('Failed AJAX Call :( /// Return Data: ' + data);
|
||||
});
|
||||
} else {
|
||||
$('#select_shipping_zone').remove();
|
||||
}
|
||||
});
|
||||
|
||||
jQuery("#channel_hash").on("change", function(){
|
||||
var channel_hash = $("#channel_hash").find('option:selected').text();
|
||||
if(channel_hash == 'Google Remarketing - DRM'){ // Ugly hack, should be configurable per channel
|
||||
$("#fileformat option[value='xml']").remove();
|
||||
$("#fileformat option[value='txt']").remove();
|
||||
$("#fileformat option[value='tsv']").remove();
|
||||
|
||||
$('#file').after('<tr id="delimiter"><td><span>Delimiter:</span></td><td><select name="delimiter" class="select-field"><option value=",">, comma</option><option value="|">| pipe</option><option value=";">;</option><option value="tab">tab</option><option value="#">#</option></select></td></tr>');
|
||||
} else if(channel_hash == 'Guenstiger.de'){ // Ugly hack, should be configurable per channel
|
||||
$("#fileformat option[value='xml']").remove();
|
||||
$("#fileformat option[value='txt']").remove();
|
||||
$("#fileformat option[value='tsv']").remove();
|
||||
|
||||
$('#file').after('<tr id="delimiter"><td><span>Delimiter:</span></td><td><select name="delimiter" class="select-field"><option value=",">, comma</option><option value="|">| pipe</option><option value=";">;</option><option value="tab">tab</option><option value="#">#</option></select></td></tr>');
|
||||
} else if(channel_hash == 'Google - DSA'){ // Ugly hack, should be configurable per channel
|
||||
$("#fileformat option[value='xml']").remove();
|
||||
$("#fileformat option[value='txt']").remove();
|
||||
$("#fileformat option[value='tsv']").remove();
|
||||
|
||||
$('#file').after('<tr id="delimiter"><td><span>Delimiter:</span></td><td><select name="delimiter" class="select-field"><option value=",">, comma</option><option value="|">| pipe</option><option value=";">;</option><option value="tab">tab</option><option value="#">#</option></select></td></tr>');
|
||||
} else if(channel_hash == 'Wish.com'){ // Ugly hack, should be configurable per channel
|
||||
$("#fileformat option[value='xml']").remove();
|
||||
$("#fileformat option[value='txt']").remove();
|
||||
$("#fileformat option[value='tsv']").remove();
|
||||
|
||||
$('#file').after('<tr id="delimiter"><td><span>Delimiter:</span></td><td><select name="delimiter" class="select-field"><option value=",">, comma</option><option value="|">| pipe</option><option value=";">;</option><option value="tab">tab</option><option value="#">#</option></select></td></tr>');
|
||||
} else if(channel_hash == 'Google Local Products Inventory'){ // Ugly hack, should be configurable per channel
|
||||
$("#fileformat option[value='csv']").remove();
|
||||
$("#fileformat option[value='tsv']").remove();
|
||||
|
||||
$('#file').after('<tr id="delimiter"><td><span>Delimiter:</span></td><td><select name="delimiter" class="select-field"><option value=",">, comma</option><option value="|">| pipe</option><option value=";">;</option><option value="tab">tab</option><option value="#">#</option></select></td></tr>');
|
||||
} else if(channel_hash == 'Google Shopping'){ // Ugly hack, should be configurable per channel
|
||||
$("#fileformat option[value='txt']").remove();
|
||||
$("#fileformat option[value='csv']").remove();
|
||||
$("#fileformat option[value='tsv']").remove();
|
||||
|
||||
$('#file').after('<tr id="delimiter"><td><span>Delimiter:</span></td><td><select name="delimiter" class="select-field"><option value=",">, comma</option><option value="|">| pipe</option><option value=";">;</option><option value="tab">tab</option><option value="#">#</option></select></td></tr>');
|
||||
} else if(channel_hash == 'Fashionchick.nl'){ // Ugly hack, should be configurable per channel
|
||||
$("#fileformat option[value='tsv']").remove();
|
||||
$("#fileformat option[value='xml']").remove();
|
||||
|
||||
$('#file').after('<tr id="delimiter"><td><span>Delimiter:</span></td><td><select name="delimiter" class="select-field"><option value=",">, comma</option><option value="|">| pipe</option><option value=";">;</option><option value="tab">tab</option><option value="#">#</option></select></td></tr>');
|
||||
} else if(channel_hash == 'Bol.com'){ // Ugly hack, should be configurable per channel
|
||||
$("#fileformat option[value='tsv']").remove();
|
||||
$("#fileformat option[value='xml']").remove();
|
||||
|
||||
$('#file').after('<tr id="delimiter"><td><span>Delimiter:</span></td><td><select name="delimiter" class="select-field"><option value=",">, comma</option><option value="|">| pipe</option><option value=";">;</option><option value="tab">tab</option><option value="#">#</option></select></td></tr>');
|
||||
} else if(channel_hash == 'Snapchat Product Catalog'){ // Ugly hack, should be configurable per channel
|
||||
$("#fileformat option[value='tsv']").remove();
|
||||
$("#fileformat option[value='xml']").remove();
|
||||
$("#fileformat option[value='txt']").remove();
|
||||
|
||||
$('#file').after('<tr id="delimiter"><td><span>Delimiter:</span></td><td><select name="delimiter" class="select-field"><option value=",">, comma</option><option value="|">| pipe</option><option value=";">;</option><option value="tab">tab</option><option value="#">#</option></select></td></tr>');
|
||||
} else {
|
||||
$("#fileformat")
|
||||
.empty()
|
||||
.append('<option value="xml">XML</option><option value="csv">CSV</option><option value="txt">TXT</option><option value="tsv">TSV</option>')
|
||||
;
|
||||
}
|
||||
});
|
||||
|
||||
// The Aelia currency has changed, make sure to warn the user to also change the currency prefix and/or suffix
|
||||
//$('.aelia_switch').change(function(){
|
||||
$('.aelia_switch').on('change', function(){
|
||||
var popup_dialog = alert("You have changed the Aelia currency, this will change pricing in your product feed. Make sure the currency prefix and/or suffix on the field mapping page is correct.");
|
||||
});
|
||||
|
||||
|
||||
jQuery("#countries").on("change", function(){
|
||||
var country = this.value;
|
||||
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: { 'action': 'woosea_channel', 'country': country }
|
||||
})
|
||||
|
||||
.done(function( data ) {
|
||||
data = JSON.parse( data );
|
||||
|
||||
var select = $('#channel_hash');
|
||||
select.empty();
|
||||
|
||||
$.each(data, function(index, val) {
|
||||
if(val.type == 'Custom Feed'){
|
||||
if($('optgroup[label="Custom Feed"]').length == 0){
|
||||
var optgroup_customfeed = $('<optgroup id="CustomFeed">');
|
||||
optgroup_customfeed.attr('label', val.type);
|
||||
$("#channel_hash").append(optgroup_customfeed);
|
||||
$("<option>").val(val.channel_hash).text(val.name).appendTo("#CustomFeed");
|
||||
} else {
|
||||
$("<option>").val(val.channel_hash).text(val.name).appendTo("#CustomFeed");
|
||||
}
|
||||
}
|
||||
|
||||
if(val.type == 'Advertising'){
|
||||
if($('optgroup[label="Advertising"]').length == 0){
|
||||
var optgroup_advertising = $('<optgroup id="Advertising">');
|
||||
optgroup_advertising.attr('label', val.type);
|
||||
$("#channel_hash").append(optgroup_advertising);
|
||||
$("<option>").val(val.channel_hash).text(val.name).appendTo("#Advertising");
|
||||
} else {
|
||||
$("<option>").val(val.channel_hash).text(val.name).appendTo("#Advertising");
|
||||
}
|
||||
}
|
||||
|
||||
if(val.type == 'Comparison shopping engine'){
|
||||
if($('optgroup[label="Comparison shopping engine"]').length == 0){
|
||||
var optgroup_shopping = $('<optgroup id="Shopping">');
|
||||
optgroup_shopping.attr('label', val.type);
|
||||
$("#channel_hash").append(optgroup_shopping);
|
||||
$("<option>").val(val.channel_hash).text(val.name).appendTo("#Shopping");
|
||||
} else {
|
||||
$("<option>").val(val.channel_hash).text(val.name).appendTo("#Shopping");
|
||||
}
|
||||
}
|
||||
|
||||
if(val.type == 'Marketplace'){
|
||||
if($('optgroup[label="Marketplace"]').length == 0){
|
||||
var optgroup_marketplace = $('<optgroup id="Marketplace">');
|
||||
optgroup_marketplace.attr('label', val.type);
|
||||
$("#channel_hash").append(optgroup_marketplace);
|
||||
$("<option>").val(val.channel_hash).text(val.name).appendTo("#Marketplace");
|
||||
} else {
|
||||
$("<option>").val(val.channel_hash).text(val.name).appendTo("#Marketplace");
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
.fail(function( data ) {
|
||||
console.log('Failed AJAX Call :( /// Return Data: ' + data);
|
||||
});
|
||||
});
|
||||
|
||||
jQuery("#fileformat").on("change", function(){
|
||||
var fileformat = this.value;
|
||||
|
||||
if (fileformat == "xml"){
|
||||
$('#delimiter').remove();
|
||||
} else {
|
||||
// Put delimiter dropdown back
|
||||
if($("#delimiter").length == 0){
|
||||
$('#file').after('<tr id="delimiter"><td><span>Delimiter:</span></td><td><select name="delimiter" class="select-field"><option value=",">, comma</option><option value="|">| pipe</option><option value=";">;</option><option value="tab">tab</option><option value="#">#</option></select></td></tr>');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var manage_fileformat = jQuery("#fileformat").val();
|
||||
var project_update = jQuery("#project_update").val();
|
||||
|
||||
if (manage_fileformat == "xml"){
|
||||
$('#delimiter').remove();
|
||||
}
|
||||
|
||||
if (project_update == "yes"){
|
||||
$('#goforit').attr('disabled',false);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,157 @@
|
||||
jQuery(document).ready(function($) {
|
||||
|
||||
// Dialog opener for information on mapping attributes
|
||||
jQuery( "#dialog" ).dialog({
|
||||
autoOpen: false,
|
||||
show: {
|
||||
effect: "blind",
|
||||
duration: 1000
|
||||
},
|
||||
hide: {
|
||||
effect: "explode",
|
||||
duration: 1000
|
||||
}
|
||||
});
|
||||
|
||||
// Add a mapping row to the table for field mappings
|
||||
jQuery(".add-field-mapping").on('click', function(){
|
||||
var nonce = $('#nonce_field_mapping').val();
|
||||
var channel_hash = $('#channel_hash').val();
|
||||
var prevRow = $("tr.rowCount:last input[type=hidden]").val();
|
||||
var addrow_value = $('#addrow').val();
|
||||
|
||||
// When user deletes all default fields
|
||||
if (prevRow === undefined){
|
||||
prevRow = 0;
|
||||
}
|
||||
|
||||
var rowCount = Number(prevRow) + Number(addrow_value);
|
||||
var newrow_value = Number(addrow_value) + Number(1);
|
||||
$('#addrow').val(newrow_value);
|
||||
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_fieldmapping_dropdown',
|
||||
'rowCount': rowCount,
|
||||
'security': nonce,
|
||||
'channel_hash': channel_hash
|
||||
}
|
||||
})
|
||||
.done(function( data ) {
|
||||
data = JSON.parse( data );
|
||||
|
||||
$( '#woosea-fieldmapping-table' ).append('<tr><td><input type="hidden" name="attributes[' + rowCount + '][rowCount]" value="' + rowCount + '"><input type="checkbox" name="record" class="checkbox-field"></td><td><select name="attributes[' + rowCount + '][attribute]" class="select-field">' + data.field_options + '</select></td><td><input type="text" name="attributes[' + rowCount + '][prefix]" class="input-field-medium"></td><td><select name="attributes[' + rowCount + '][mapfrom]" class="select-field">' + data.attribute_options + '</select></td><td><input type="text" name="attributes[' + rowCount + '][suffix]" class="input-field-medium"></td></tr>');
|
||||
|
||||
$('.select-field').on('change', function(){
|
||||
if ($(this).val() == "static_value") {
|
||||
var rownr = $(this).closest("tr").prevAll("tr").length;
|
||||
$(this).replaceWith('<input type="text" name="attributes[' + rowCount + '][mapfrom]" class="input-field-midsmall"><input type="hidden" name="attributes[' + rowCount + '][static_value]" value="true">');
|
||||
}
|
||||
});
|
||||
})
|
||||
.fail(function( data ) {
|
||||
console.log('Failed AJAX Call :( /// Return Data: ' + data);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// Add a mapping row to the table for own mappings
|
||||
jQuery(".add-own-mapping").on('click', function(){
|
||||
var nonce = $('#nonce_field_mapping').val();
|
||||
var channel_hash = $('#channel_hash').val();
|
||||
var prevRow = $("tr.rowCount:last input[type=hidden]").val();
|
||||
var addrow_value = $('#addrow').val();
|
||||
|
||||
// When user deletes all default fields
|
||||
if (prevRow === undefined){
|
||||
prevRow = 0;
|
||||
}
|
||||
|
||||
var rowCount = Number(prevRow) + Number(addrow_value);
|
||||
var newrow_value = Number(addrow_value) + Number(1);
|
||||
$('#addrow').val(newrow_value);
|
||||
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_fieldmapping_dropdown',
|
||||
'security': nonce,
|
||||
'rowCount': rowCount,
|
||||
'channel_hash': channel_hash
|
||||
}
|
||||
})
|
||||
.done(function( data ) {
|
||||
data = JSON.parse( data );
|
||||
$( '#woosea-fieldmapping-table' ).append('<tr><td><input type="hidden" name="attributes[' + rowCount + '][rowCount]" value="' + rowCount + '"><input type="checkbox" name="record" class="checkbox-field"></td><td><input name="attributes[' + rowCount + '][attribute]" id="own-input-field" class="input-field"></td><td><input type="text" name="attributes[' + rowCount + '][prefix]" class="input-field-medium"></td><td><select name="attributes[' + rowCount + '][mapfrom]" class="select-field">' + data.attribute_options + '</select></td><td><input type="text" name="attributes[' + rowCount + '][suffix]" class="input-field-medium"></td></tr>');
|
||||
|
||||
$('.select-field').on('change', function(){
|
||||
if ($(this).val() == "static_value") {
|
||||
var rownr = $(this).closest("tr").prevAll("tr").length;
|
||||
$(this).replaceWith('<input type="text" name="attributes[' + rowCount + '][mapfrom]" class="input-field-midsmall"><input type="hidden" name="attributes[' + rowCount + '][static_value]" value="true">');
|
||||
}
|
||||
});
|
||||
})
|
||||
.fail(function( data ) {
|
||||
console.log('Failed AJAX Call :( /// Return Data: ' + data);
|
||||
});
|
||||
});
|
||||
|
||||
jQuery("#savebutton").on('click', function(){
|
||||
|
||||
$("#own-input-field").each(function() {
|
||||
var input=$(this).val();
|
||||
var re = /^[a-zA-Zа-яА-Я_-]*$/;
|
||||
if (input.indexOf("PARAM_") >= 0){
|
||||
// For Yandex, Zbozi and Heureka also accept Cyrillic characters
|
||||
var re = /.*/;
|
||||
}
|
||||
var minLength = 2;
|
||||
var maxLength = 50;
|
||||
|
||||
var is_input=re.test(input);
|
||||
// Check for allowed characters
|
||||
if (!is_input){
|
||||
$('form').submit(function(){
|
||||
return false;
|
||||
});
|
||||
$('.notice').replaceWith("<div class='notice notice-error is-dismissible'><p>Sorry, when creating new custom fields only letters are allowed (so no white spaces, numbers or any other character are allowed).</p></div>");
|
||||
} else {
|
||||
// Check for length of fieldname
|
||||
if (input.length < minLength){
|
||||
$('form').submit(function(){
|
||||
return false;
|
||||
});
|
||||
$('.notice').replaceWith("<div class='notice notice-error is-dismissible'><p>Sorry, your custom field name needs to be at least 2 letters long.</p></div>");
|
||||
} else if (input.length > maxLength){
|
||||
$('form').submit(function(){
|
||||
return false;
|
||||
});
|
||||
$('.notice').replaceWith("<div class='notice notice-error is-dismissible'><p>Sorry, your custom field name cannot be over 20 letters long.</p></div>");
|
||||
} else {
|
||||
$("#fieldmapping")[0].submit();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
jQuery('.select-field').on('change', function(){
|
||||
if ($(this).val() == "static_value") {
|
||||
// var rownr = $(this).closest("tr").prevAll("tr").length;
|
||||
var rownr = $(this).closest('tr').attr("class").split(' ')[1];
|
||||
$(this).replaceWith('<input type="text" name="attributes[' + rownr + '][mapfrom]" class="input-field-midsmall"><input type="hidden" name="attributes[' + rownr + '][static_value]" value="true">');
|
||||
}
|
||||
});
|
||||
|
||||
// Find and remove selected table rows
|
||||
jQuery(".delete-field-mapping").on('click', function(){
|
||||
$("table tbody").find('input[name="record"]').each(function(){
|
||||
|
||||
if($(this).is(":checked")){
|
||||
$(this).parents("tr").remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
73
wp-content/plugins/woo-product-feed-pro/js/woosea_key.js
Normal file
73
wp-content/plugins/woo-product-feed-pro/js/woosea_key.js
Normal file
@@ -0,0 +1,73 @@
|
||||
jQuery(document).ready(function($) {
|
||||
jQuery("#deactivate_license").on('click', function(){
|
||||
//jQuery("#deactivate_license").click(function(){
|
||||
$('.notice').replaceWith("<div class='notice notice-info is-dismissible'><p>Your license has been deactivated.</p></div>");
|
||||
$('#license_email').val('');
|
||||
$('#license_key').val('');
|
||||
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: { 'action': 'woosea_deactivate_license' }
|
||||
})
|
||||
.done(function( data ) {
|
||||
data = JSON.parse( data );
|
||||
})
|
||||
.fail(function( data ) {
|
||||
console.log('Failed AJAX Call :( /// Return Data: ' + data);
|
||||
});
|
||||
});
|
||||
|
||||
jQuery("#checklicense").on('click', function(){
|
||||
//jQuery("#checklicense").click(function(){
|
||||
var temp = location.host.split('.').reverse();
|
||||
var root_domain = $(location).attr('hostname');
|
||||
var license_email = $('#license-email').val();
|
||||
var license_key = $('#license-key').val();
|
||||
|
||||
jQuery.ajax({
|
||||
url: 'https://www.adtribes.io/check/license.php?key=' + license_key + '&email=' + license_email + '&domain=' + root_domain + '&version=12.1.5',
|
||||
jsonp: 'callback',
|
||||
dataType: 'jsonp',
|
||||
type: 'GET',
|
||||
success: function( licenseData ) {
|
||||
|
||||
var license_valid = licenseData.valid;
|
||||
if (license_valid == "true"){
|
||||
$('.notice').replaceWith("<div class='notice notice-success is-dismissible'><p>Thank you for registering your Elite product, your license has been activated. Please do not hesitate to contact us whenever you have questions (support@adtribes.io).</p></div>");
|
||||
} else {
|
||||
$('.notice').replaceWith("<div class='notice notice-error is-dismissible'><p>Sorry, this does not seem to be a valid or active license key and email. Please feel free to contact us at support@adtribes.io whenever you have questions with regards to your license.</p></div>");
|
||||
}
|
||||
|
||||
var license_created = licenseData.created;
|
||||
var message = licenseData.message;
|
||||
var message_type = licenseData.message_type;
|
||||
var license_email = licenseData.license_email;
|
||||
var license_key = licenseData.license_key;
|
||||
var notice = licenseData.notice;
|
||||
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_register_license',
|
||||
'notice': notice,
|
||||
'message_type': message_type,
|
||||
'license_email': license_email,
|
||||
'license_key': license_key,
|
||||
'license_valid': license_valid,
|
||||
'license_created': license_created,
|
||||
'message': message
|
||||
}
|
||||
})
|
||||
.done(function( data ) {
|
||||
data = JSON.parse( data );
|
||||
})
|
||||
.fail(function( data ) {
|
||||
console.log('Failed AJAX Call :( /// Return Data: ' + data);
|
||||
});
|
||||
console.log( licenseData );
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
67
wp-content/plugins/woo-product-feed-pro/js/woosea_license.js
Normal file
67
wp-content/plugins/woo-product-feed-pro/js/woosea_license.js
Normal file
@@ -0,0 +1,67 @@
|
||||
jQuery(document).ready(function($) {
|
||||
|
||||
jQuery("#deactivate_license").click(function(){
|
||||
|
||||
$('.notice').replaceWith("<div class='notice notice-info is-dismissible'><p>Your license has been deactivated.</p></div>");
|
||||
$('#license_email').val('');
|
||||
$('#license_key').val('');
|
||||
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: { 'action': 'woosea_deactivate_license' }
|
||||
})
|
||||
.done(function( data ) {
|
||||
data = JSON.parse( data );
|
||||
})
|
||||
.fail(function( data ) {
|
||||
console.log('Failed AJAX Call :( /// Return Data: ' + data);
|
||||
});
|
||||
});
|
||||
|
||||
jQuery("#checklicense").click(function(){
|
||||
|
||||
var temp = location.host.split('.').reverse();
|
||||
var root_domain = $(location).attr('hostname');
|
||||
var license_email = $('#license-email').val();
|
||||
var license_key = $('#license-key').val();
|
||||
|
||||
jQuery.ajax({
|
||||
url: 'https://www.adtribes.io/check/license.php?key=' + license_key + '&email=' + license_email + '&domain=' + root_domain + '&version=3.1.5',
|
||||
jsonp: 'callback',
|
||||
dataType: 'jsonp',
|
||||
type: 'GET',
|
||||
success: function( licenseData ) {
|
||||
|
||||
var license_valid = licenseData.valid;
|
||||
if (license_valid == "true"){
|
||||
$('.notice').replaceWith("<div class='notice notice-success is-dismissible'><p>Thank you for registering your Elite product, your license has been activated. Please do not hesitate to contact us whenever you have questions (support@adtribes.io).</p></div>");
|
||||
} else {
|
||||
$('.notice').replaceWith("<div class='notice notice-error is-dismissible'><p>Sorry, this does not seem to be a valid or active license key and email. Please feel free to contact us at support@adtribes.io whenever you have questions with regards to your license.</p></div>");
|
||||
}
|
||||
|
||||
var license_created = licenseData.created;
|
||||
var message = licenseData.message;
|
||||
var message_type = licenseData.message_type;
|
||||
var license_email = licenseData.license_email;
|
||||
var license_key = licenseData.license_key;
|
||||
var notice = licenseData.notice;
|
||||
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: { 'action': 'woosea_register_license', 'notice': notice, 'message_type': message_type, 'license_email': license_email, 'license_key': license_key, 'license_valid': license_valid, 'license_created': license_created, 'message': message }
|
||||
})
|
||||
.done(function( data ) {
|
||||
data = JSON.parse( data );
|
||||
})
|
||||
.fail(function( data ) {
|
||||
console.log('Failed AJAX Call :( /// Return Data: ' + data);
|
||||
});
|
||||
console.log( licenseData );
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
// On succes this call will return yes/no in jsonp for the domain name check. It will also return the license key. This key needs to correlate with the one user entered.
|
||||
});
|
||||
791
wp-content/plugins/woo-product-feed-pro/js/woosea_manage.js
Normal file
791
wp-content/plugins/woo-product-feed-pro/js/woosea_manage.js
Normal file
@@ -0,0 +1,791 @@
|
||||
jQuery(function($) {
|
||||
|
||||
//jQuery(document).ready(function($) {
|
||||
var project_hash = null;
|
||||
var project_status = null;
|
||||
var get_value = null;
|
||||
var tab_value = null;
|
||||
|
||||
// make sure to only check the feed status on the woosea_manage_feed page
|
||||
url = new URL(window.location.href);
|
||||
if (url.searchParams.get('page')) {
|
||||
get_value = url.searchParams.get('page');
|
||||
}
|
||||
if (url.searchParams.get('tab')) {
|
||||
tab_value = url.searchParams.get('tab');
|
||||
}
|
||||
|
||||
if (get_value == 'woosea_manage_feed') {
|
||||
jQuery(function($) {
|
||||
//$(document).on('ready',function(){
|
||||
// Check if feed is processing
|
||||
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: { 'action': 'woosea_check_processing' }
|
||||
})
|
||||
.done(function( data ) {
|
||||
if(data.processing == "true"){
|
||||
myInterval = setInterval(woosea_check_perc,10000);
|
||||
} else {
|
||||
console.log("No refresh interval is needed, all feeds are ready");
|
||||
}
|
||||
})
|
||||
.fail(function( data ) {
|
||||
console.log('Failed AJAX Call :( /// Return Data: ' + data);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$(".dismiss-review-notification").on('click', function(){
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: { 'action': 'woosea_review_notification' }
|
||||
})
|
||||
|
||||
$(".review-notification").remove();
|
||||
|
||||
});
|
||||
|
||||
$(".get_elite").on('click', function(e){
|
||||
if(e.target.tagName === 'A') return; // clicking on links should not close the div notice
|
||||
|
||||
$(".get_elite").remove();
|
||||
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: { 'action': 'woosea_getelite_notification' }
|
||||
})
|
||||
});
|
||||
|
||||
$(".get_elite_activate").on('click', function(e){
|
||||
if(e.target.tagName === 'A') return; // clicking on links should not close the div notice
|
||||
|
||||
$(".get_elite_activate").remove();
|
||||
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: { 'action': 'woosea_getelite_active_notification' }
|
||||
})
|
||||
});
|
||||
|
||||
$("td[id=manage_inline]").find("div").parents("tr").hide();
|
||||
$('.checkbox-field').on('change', function(index, obj){
|
||||
var csrfToken = $('#csrfToken').val();
|
||||
|
||||
if(get_value == 'woosea_manage_settings' && tab_value == 'woosea_manage_attributes'){
|
||||
var attribute_value = $(this).val();
|
||||
var attribute_name = $(this).attr('name');
|
||||
var attribute_status = $(this).prop("checked");
|
||||
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_add_attributes',
|
||||
'security': csrfToken,
|
||||
'attribute_name': attribute_name,
|
||||
'attribute_value': attribute_value,
|
||||
'active': attribute_status
|
||||
}
|
||||
})
|
||||
} else if (get_value == 'woosea_manage_feed') {
|
||||
project_hash = $(this).val();
|
||||
project_status = $(this).prop("checked");
|
||||
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_project_status',
|
||||
'project_hash': project_hash,
|
||||
'active': project_status
|
||||
}
|
||||
})
|
||||
|
||||
$("table tbody").find('input[name="manage_record"]').each(function(){
|
||||
var hash = this.value;
|
||||
if(hash == project_hash){
|
||||
if (project_status == false){
|
||||
$(this).parents("tr").addClass('strikethrough');
|
||||
} else {
|
||||
$(this).parents("tr").removeClass('strikethrough');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Do nothing, waste of resources
|
||||
}
|
||||
});
|
||||
|
||||
// Check if user would like to use mother image for variations
|
||||
$('#add_mother_image').on('change', function(){ // on change of state
|
||||
var nonce = $('#_wpnonce').val();
|
||||
if(this.checked){
|
||||
// Checkbox is on
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_add_mother_image',
|
||||
'security': nonce,
|
||||
'status': "on"
|
||||
}
|
||||
})
|
||||
} else {
|
||||
// Checkbox is off
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_add_mother_image',
|
||||
'security': nonce,
|
||||
'status': "off"
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// Check if user would like to add all country shipping costs
|
||||
$('#add_all_shipping').on('change', function(){ // on change of state
|
||||
var nonce = $('#_wpnonce').val();
|
||||
if(this.checked){
|
||||
// Checkbox is on
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_add_all_shipping',
|
||||
'security': nonce,
|
||||
'status': "on"
|
||||
}
|
||||
})
|
||||
} else {
|
||||
// Checkbox is off
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_add_all_shipping',
|
||||
'security': nonce,
|
||||
'status': "off"
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// Check if user would like the plugin to respect free shipping class
|
||||
$('#free_shipping').on('change', function(){ // on change of state
|
||||
var nonce = $('#_wpnonce').val();
|
||||
if(this.checked){
|
||||
// Checkbox is on
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_free_shipping',
|
||||
'security': nonce,
|
||||
'status': "on"
|
||||
}
|
||||
})
|
||||
} else {
|
||||
// Checkbox is off
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_free_shipping',
|
||||
'security': nonce,
|
||||
'status': "off"
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// Check if user would like the plugin to respect free shipping class
|
||||
$('#local_pickup_shipping').on('change', function(){ // on change of state
|
||||
var nonce = $('#_wpnonce').val();
|
||||
if(this.checked){
|
||||
// Checkbox is on
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_local_pickup_shipping',
|
||||
'security': nonce,
|
||||
'status': "on"
|
||||
}
|
||||
})
|
||||
} else {
|
||||
// Checkbox is off
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_local_pickup_shipping',
|
||||
'security': nonce,
|
||||
'status': "off"
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// Check if user would like the plugin to remove the free shipping class
|
||||
$('#remove_free_shipping').on('change', function(){ // on change of state
|
||||
var nonce = $('#_wpnonce').val();
|
||||
if(this.checked){
|
||||
// Checkbox is on
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_remove_free_shipping',
|
||||
'security': nonce,
|
||||
'status': "on"
|
||||
}
|
||||
})
|
||||
} else {
|
||||
// Checkbox is off
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_remove_free_shipping',
|
||||
'security': nonce,
|
||||
'status': "off"
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// Check if user would like to enable debug logging
|
||||
$('#add_woosea_logging').on('change', function(){ // on change of state
|
||||
var nonce = $('#_wpnonce').val();
|
||||
if(this.checked){
|
||||
// Checkbox is on
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_add_woosea_logging',
|
||||
'security': nonce,
|
||||
'status': "on"
|
||||
}
|
||||
})
|
||||
} else {
|
||||
// Checkbox is off
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_add_woosea_logging',
|
||||
'security': nonce,
|
||||
'status': "off"
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// Check if user would like to enable only basis attributes in drop-downs
|
||||
$('#add_woosea_basic').on('change', function(){ // on change of state
|
||||
var nonce = $('#_wpnonce').val();
|
||||
if(this.checked){
|
||||
// Checkbox is on
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_add_woosea_basic',
|
||||
'security': nonce,
|
||||
'status': "on"
|
||||
}
|
||||
})
|
||||
} else {
|
||||
// Checkbox is off
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_add_woosea_basic',
|
||||
'security': nonce,
|
||||
'status': "off"
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// Check if user would like to enable addition of CDATA
|
||||
$('#add_woosea_cdata').on('change', function(){ // on change of state
|
||||
var nonce = $('#_wpnonce').val();
|
||||
if(this.checked){
|
||||
// Checkbox is on
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_add_woosea_cdata',
|
||||
'security': nonce,
|
||||
'status': "on"
|
||||
}
|
||||
})
|
||||
} else {
|
||||
// Checkbox is off
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_add_woosea_cdata',
|
||||
'security': nonce,
|
||||
'status': "off"
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// Check if user would like to add a Facebook Pixel to their website
|
||||
$('#woosea_content_ids').on('change', function(){ // on change of state
|
||||
var content_ids = $('#woosea_content_ids').val();
|
||||
if(content_ids){
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: { 'action': 'woosea_facebook_content_ids', 'content_ids': content_ids }
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// Check if user would like to add a Facebook Pixel to their website
|
||||
$('#add_facebook_pixel').on('change', function(){ // on change of state
|
||||
var nonce = $('#_wpnonce').val();
|
||||
if(this.checked){
|
||||
// Checkbox is on
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_add_facebook_pixel_setting',
|
||||
'security': nonce,
|
||||
'status': "on"
|
||||
}
|
||||
})
|
||||
.done(function( data ) {
|
||||
$('#facebook_pixel').after('<tr id="facebook_pixel_id"><td colspan="2"><span>Insert Facebook pixel ID:</span> <input type=\"hidden\" name=\"nonce_facebook_pixel_id\" id=\"nonce_facebook_pixel_id\" value=\"'+ nonce +'\"><input type="text" class="input-field-medium" id="fb_pixel_id" name="fb_pixel_id"> <input type="button" id="save_facebook_pixel_id" value="Save"></td></tr>');
|
||||
})
|
||||
.fail(function( data ) {
|
||||
console.log('Failed AJAX Call :( /// Return Data: ' + data);
|
||||
});
|
||||
} else {
|
||||
// Checkbox is off
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_add_facebook_pixel_setting',
|
||||
'security': nonce,
|
||||
'status': "off"
|
||||
}
|
||||
})
|
||||
.done(function( data ) {
|
||||
$('#facebook_pixel_id').remove();
|
||||
})
|
||||
.fail(function( data ) {
|
||||
console.log('Failed AJAX Call :( /// Return Data: ' + data);
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
// Check if user would like to enable the Facebook Conversion API
|
||||
$('#add_facebook_capi').on('change', function(){ // on change of state
|
||||
var nonce = $('#_wpnonce').val();
|
||||
if(this.checked){
|
||||
// Checkbox is on
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_add_facebook_capi_setting',
|
||||
'security': nonce,
|
||||
'status': "on"
|
||||
}
|
||||
})
|
||||
.done(function( data ) {
|
||||
$('#facebook_capi').after('<tr id="facebook_capi_token"><td colspan="2"><span>Insert your Facebook Conversion API token:</span><br/><br/><input type=\"hidden\" name=\"nonce_facebook_capi_id\" id=\"nonce_facebook_capi_id\" value=\"' + nonce +'\"><input type="textarea" class="textarea-field" id="fb_capi_token" name="fb_capi_token"><br/><br/><input type="button" id="save_facebook_capi_token" value="Save"></td></tr>');
|
||||
})
|
||||
.fail(function( data ) {
|
||||
console.log('Failed AJAX Call :( /// Return Data: ' + data);
|
||||
});
|
||||
} else {
|
||||
// Checkbox is off
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_add_facebook_capi_setting',
|
||||
'security': nonce,
|
||||
'status': "off"
|
||||
}
|
||||
})
|
||||
.done(function( data ) {
|
||||
$('#facebook_capi_token').remove();
|
||||
})
|
||||
.fail(function( data ) {
|
||||
console.log('Failed AJAX Call :( /// Return Data: ' + data);
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
// Check if user would like to change the batch size
|
||||
$('#add_batch').on('change', function(){ // on change of state
|
||||
if(this.checked){
|
||||
|
||||
var popup_dialog = confirm("Are you sure you want to change the batch size?\n\nChanging the batch size could seriously effect the performance of your website. We advise against changing the batch size if you are unsure about its effects!\n\nPlease reach out to support@adtribes.io when you would like to receive some help with this feature.");
|
||||
if (popup_dialog == true){
|
||||
// Checkbox is on
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: { 'action': 'woosea_add_batch', 'status': "on" }
|
||||
})
|
||||
.done(function( data ) {
|
||||
$('#batch').after('<tr id="woosea_batch_size"><td colspan="2"><span>Insert batch size:</span> <input type=\"hidden\" name=\"nonce_batch\" id=\"nonce_batch\" value=\"'+ nonce +'\"><input type="text" class="input-field-medium" id="batch_size" name="batch_size"> <input type="submit" id="save_batch_size" value="Save"></td></tr>');
|
||||
})
|
||||
.fail(function( data ) {
|
||||
console.log('Failed AJAX Call :( /// Return Data: ' + data);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Checkbox is off
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: { 'action': 'woosea_add_batch', 'status': "off" }
|
||||
})
|
||||
.done(function( data ) {
|
||||
$('#woosea_batch_size').remove();
|
||||
})
|
||||
.fail(function( data ) {
|
||||
console.log('Failed AJAX Call :( /// Return Data: ' + data);
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
// Save Batch Size
|
||||
jQuery("#save_batch_size").on('click',function(){
|
||||
var nonce = $('#_wpnonce').val();
|
||||
var batch_size = $('#batch_size').val();
|
||||
var re = /^[0-9]*$/;
|
||||
|
||||
var woosea_valid_batch_size=re.test(batch_size);
|
||||
// Check for allowed characters
|
||||
if (!woosea_valid_batch_size){
|
||||
$('.notice').replaceWith("<div class='notice notice-error woosea-notice-conversion is-dismissible'><p>Sorry, only numbers are allowed for your batch size number.</p></div>");
|
||||
// Disable submit button too
|
||||
$('#save_batch_size').attr('disabled',true);
|
||||
} else {
|
||||
$('.woosea-notice-conversion').remove();
|
||||
$('#save_batch_size').attr('disabled',false);
|
||||
|
||||
// Now we need to save the conversion ID so we can use it in the dynamic remarketing JS
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_save_batch_size',
|
||||
'security': nonce,
|
||||
'batch_size': batch_size
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// Check if user would like to enable Dynamic Remarketing
|
||||
$('#add_remarketing').on('change', function(){ // on change of state
|
||||
var nonce = $('#_wpnonce').val();
|
||||
if(this.checked){
|
||||
// Checkbox is on
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_add_remarketing',
|
||||
'security': nonce,
|
||||
'status': "on"
|
||||
}
|
||||
})
|
||||
.done(function( data ) {
|
||||
$('#remarketing').after('<tr id="adwords_conversion_id"><td colspan="2"><span>Insert your Dynamic Remarketing Conversion tracking ID:</span> <input type=\"hidden\" name=\"nonce_adwords_conversion_id\" id=\"nonce_adwords_conversion_id\" value=\"'+ nonce +'\"><input type="text" class="input-field-medium" id="adwords_conv_id" name="adwords_conv_id"> <input type="submit" id="save_conversion_id" value="Save"></td></tr>');
|
||||
})
|
||||
.fail(function( data ) {
|
||||
console.log('Failed AJAX Call :( /// Return Data: ' + data);
|
||||
});
|
||||
} else {
|
||||
// Checkbox is off
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_add_remarketing',
|
||||
'security': nonce,
|
||||
'status': "off"
|
||||
}
|
||||
})
|
||||
.done(function( data ) {
|
||||
$('#adwords_conversion_id').remove();
|
||||
})
|
||||
.fail(function( data ) {
|
||||
console.log('Failed AJAX Call :( /// Return Data: ' + data);
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
// Save Google Dynamic Remarketing pixel ID
|
||||
jQuery("#save_conversion_id").on('click',function(){
|
||||
var nonce = $('#_wpnonce').val();
|
||||
var adwords_conversion_id = $('#adwords_conv_id').val();
|
||||
var re = /^[0-9,-]*$/;
|
||||
|
||||
var woosea_valid_conversion_id=re.test(adwords_conversion_id);
|
||||
// Check for allowed characters
|
||||
if (!woosea_valid_conversion_id){
|
||||
$('.notice').replaceWith("<div class='notice notice-error woosea-notice-conversion is-dismissible'><p>Sorry, only numbers are allowed for your Dynamic Remarketing Conversion tracking ID.</p></div>");
|
||||
// Disable submit button too
|
||||
$('#save_conversion_id').attr('disabled',true);
|
||||
} else {
|
||||
$('.woosea-notice-conversion').remove();
|
||||
$('#save_conversion_id').attr('disabled',false);
|
||||
|
||||
// Now we need to save the conversion ID so we can use it in the dynamic remarketing JS
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_save_adwords_conversion_id',
|
||||
'security': nonce,
|
||||
'adwords_conversion_id': adwords_conversion_id
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// Save Facebook Pixel ID
|
||||
jQuery("#save_facebook_pixel_id").on('click',function(){
|
||||
var nonce = $('#_wpnonce').val();
|
||||
var facebook_pixel_id = $('#fb_pixel_id').val();
|
||||
var re = /^[0-9]*$/;
|
||||
var woosea_valid_facebook_pixel_id=re.test(facebook_pixel_id);
|
||||
|
||||
// Check for allowed characters
|
||||
if (!woosea_valid_facebook_pixel_id){
|
||||
$('.notice').replaceWith("<div class='notice notice-error woosea-notice-conversion is-dismissible'><p>Sorry, only numbers are allowed for your Facebook Pixel ID.</p></div>");
|
||||
// Disable submit button too
|
||||
$('#save_facebook_pixel_id').attr('disabled',true);
|
||||
} else {
|
||||
$('.woosea-notice-conversion').remove();
|
||||
$('#save_facebook_pixel_id').attr('disabled',false);
|
||||
|
||||
// Now we need to save the Facebook pixel ID so we can use it in the facebook pixel JS
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_save_facebook_pixel_id',
|
||||
'security': nonce,
|
||||
'facebook_pixel_id': facebook_pixel_id
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// Save Facebook Conversion API token
|
||||
jQuery("#save_facebook_capi_token").on('click',function(){
|
||||
var nonce = $('#_wpnonce').val();
|
||||
var facebook_capi_token = $('#fb_capi_token').val();
|
||||
var re = /^[0-9A-Za-z]*$/;
|
||||
var woosea_valid_facebook_capi_token=re.test(facebook_capi_token);
|
||||
|
||||
// Check for allowed characters
|
||||
if (!woosea_valid_facebook_capi_token){
|
||||
$('.notice').replaceWith("<div class='notice notice-error woosea-notice-conversion is-dismissible'><p>Sorry, this is not a valid Facebook Conversion API Token.</p></div>");
|
||||
// Disable submit button too
|
||||
$('#save_facebook_capi_token').attr('disabled',true);
|
||||
} else {
|
||||
$('.woosea-notice-conversion').remove();
|
||||
$('#save_facebook_capi_token').attr('disabled',false);
|
||||
|
||||
// Now we need to save the Facebook Conversion API Token
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_save_facebook_capi_token',
|
||||
'security': nonce,
|
||||
'facebook_capi_token': facebook_capi_token
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
$(".actions").on("click", "span", function() {
|
||||
var id=$(this).attr('id');
|
||||
var idsplit = id.split('_');
|
||||
var project_hash = idsplit[1];
|
||||
var action = idsplit[0];
|
||||
|
||||
if (action == "gear"){
|
||||
$("tr").not(':first').click(
|
||||
function(event) {
|
||||
var $target = $(event.target);
|
||||
$target.closest("tr").next().find("div").parents("tr").slideDown( "slow" );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (action == "copy"){
|
||||
|
||||
var popup_dialog = confirm("Are you sure you want to copy this feed?");
|
||||
if (popup_dialog == true){
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: { 'action': 'woosea_project_copy', 'project_hash': project_hash }
|
||||
})
|
||||
|
||||
.done(function( data ) {
|
||||
data = JSON.parse( data );
|
||||
$('#woosea_main_table').append('<tr class><td> </td><td colspan="5"><span>The plugin is creating a new product feed now: <b><i>"' + data.projectname + '"</i></b>. Please refresh your browser to manage the copied product feed project.</span></span></td></tr>');
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (action == "trash"){
|
||||
|
||||
var popup_dialog = confirm("Are you sure you want to delete this feed?");
|
||||
if (popup_dialog == true){
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: { 'action': 'woosea_project_delete', 'project_hash': project_hash }
|
||||
})
|
||||
|
||||
$("table tbody").find('input[name="manage_record"]').each(function(){
|
||||
var hash = this.value;
|
||||
if(hash == project_hash){
|
||||
$(this).parents("tr").remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if(action == "cancel"){
|
||||
|
||||
var popup_dialog = confirm("Are you sure you want to cancel processing the feed?");
|
||||
if (popup_dialog == true){
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: { 'action': 'woosea_project_cancel', 'project_hash': project_hash }
|
||||
})
|
||||
|
||||
// Replace status of project to stop processing
|
||||
$("table tbody").find('input[name="manage_record"]').each(function(){
|
||||
var hash = this.value;
|
||||
if(hash == project_hash){
|
||||
$(".woo-product-feed-pro-blink_"+hash).text(function () {
|
||||
$(this).addClass('woo-product-feed-pro-blink_me');
|
||||
return $(this).text().replace("ready", "stop processing");
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (action == "refresh"){
|
||||
|
||||
var popup_dialog = confirm("Are you sure you want to refresh the product feed?");
|
||||
if (popup_dialog == true){
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: { 'action': 'woosea_project_refresh', 'project_hash': project_hash }
|
||||
})
|
||||
|
||||
// Replace status of project to processing
|
||||
$("table tbody").find('input[name="manage_record"]').each(function(){
|
||||
var hash = this.value;
|
||||
if(hash == project_hash){
|
||||
$(".woo-product-feed-pro-blink_off_"+hash).text(function () {
|
||||
$(this).addClass('woo-product-feed-pro-blink_me');
|
||||
var status = $(".woo-product-feed-pro-blink_off_"+hash).text();
|
||||
myInterval = setInterval(woosea_check_perc,5000);
|
||||
if(status == "ready"){
|
||||
return $(this).text().replace("ready", "processing (0%)");
|
||||
} else if (status == "stopped"){
|
||||
return $(this).text().replace("stopped", "processing (0%)");
|
||||
} else if (status == "not run yet"){
|
||||
return $(this).text().replace("not run yet", "processing (0%)");
|
||||
} else {
|
||||
// it should not be coming here at all
|
||||
return $(this).text().replace("ready", "processing (0%)");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function woosea_check_perc(){
|
||||
// Check if we need to UP the processing percentage
|
||||
|
||||
$("table tbody").find('input[name="manage_record"]').each(function(){
|
||||
var hash = this.value;
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: { 'action': 'woosea_project_processing_status', 'project_hash': hash },
|
||||
success: function(data) {
|
||||
data = JSON.parse( data );
|
||||
|
||||
if(data.proc_perc < 100){
|
||||
if(data.running != "stopped"){
|
||||
$("#woosea_proc_"+hash).addClass('woo-product-feed-pro-blink_me');
|
||||
return $("#woosea_proc_"+hash).text("processing ("+data.proc_perc+"%)");
|
||||
}
|
||||
} else if(data.proc_perc == 100){
|
||||
// clearInterval(myInterval);
|
||||
$("#woosea_proc_"+hash).removeClass('woo-product-feed-pro-blink_me');
|
||||
return $("#woosea_proc_"+hash).text("ready");
|
||||
} else if(data.proc_perc == 999){
|
||||
// Do not do anything
|
||||
} else {
|
||||
// clearInterval(myInterval);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// Check if we can kill the refresh interval
|
||||
// Kill interval when all feeds are done processing
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: { 'action': 'woosea_check_processing' }
|
||||
})
|
||||
.done(function( data ) {
|
||||
data = JSON.parse( data );
|
||||
if(data.processing == "false"){
|
||||
clearInterval(myInterval);
|
||||
console.log("Kill interval, all feeds are ready");
|
||||
}
|
||||
})
|
||||
.fail(function( data ) {
|
||||
console.log('Failed AJAX Call :( /// Return Data: ' + data);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
227
wp-content/plugins/woo-product-feed-pro/js/woosea_rules.js
Normal file
227
wp-content/plugins/woo-product-feed-pro/js/woosea_rules.js
Normal file
@@ -0,0 +1,227 @@
|
||||
jQuery(document).ready(function($) {
|
||||
|
||||
// Add standard filters
|
||||
jQuery(".add-field-manipulation").on('click', function(){
|
||||
var nonce = $('#nonce_manipulation_mapping').val();
|
||||
var TrueRowCount = $('#woosea-ajax-table >tbody >tr').length-1;
|
||||
var rowCount = Math.round(new Date().getTime() + (Math.random() * 100));
|
||||
var plusCount = Math.round(new Date().getTime() + (Math.random() * 100));
|
||||
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_ajax',
|
||||
'security': nonce,
|
||||
'rowCount': rowCount
|
||||
}
|
||||
})
|
||||
|
||||
.done(function( data ) {
|
||||
data = JSON.parse( data );
|
||||
|
||||
if(TrueRowCount == 0){
|
||||
$( '#woosea-ajax-table' ).find('tbody:first').append('<tr><td valign="top"><input type="hidden" name="field_manipulation[' + data.rowCount + '][rowCount]" value="' + data.rowCount + '"><input type="checkbox" name="record" class="checkbox-field"></td><td valign="top"><select name="field_manipulation[' + data.rowCount + '][product_type]" class="select-field"><option value="all">Simple and variable</option><option value="simple">Simple</option><option value="variable">Variable</option></select></td></td><td valign="top"><select name="field_manipulation[' + data.rowCount + '][attribute]" id="field_manipulation_' + data.rowCount + '">' + data.dropdown + '</select></td><td class="becomes_fields_' + data.rowCount + '" valign="top"><select name="field_manipulation[' + data.rowCount + '][becomes][1][attribute]" id="field_manipulation_becomes_attribute_' + data.rowCount + '">' + data.dropdown + '</select></td><td><span class="dashicons dashicons-plus field_extra field_manipulation_extra_' + data.rowCount + '" style="display: inline-block;" title="Add an attribute to this field"></span></td></tr>');
|
||||
} else {
|
||||
|
||||
$('<tr><td valign="top"><input type="hidden" name="field_manipulation[' + data.rowCount + '][rowCount]" value="' + data.rowCount + '"><input type="checkbox" name="record" class="checkbox-field"></td><td valign="top"><select name="field_manipulation[' + data.rowCount + '][product_type]" class="select-field"><option value="all">Simple and variable</option><option value="simple">Simple</option><option value="variable">Variable</option></select></td></td><td valign="top"><select name="field_manipulation[' + data.rowCount + '][attribute]" id="field_manipulation_' + data.rowCount + '">' + data.dropdown + '</select></td><td class="becomes_fields_' + data.rowCount + '" valign="top"><select name="field_manipulation[' + data.rowCount + '][becomes][1][attribute]" id="field_manipulation_becomes_' + data.rowCount + '">' + data.dropdown + '</select><td><span class="dashicons dashicons-plus field_extra field_manipulation_extra_' + data.rowCount + '" style="display: inline-block;" title="Add an attribute to this field"></span></td></tr>').insertBefore(".rules-buttons");
|
||||
}
|
||||
|
||||
// Check if user selected a data manipulation condition
|
||||
jQuery(".field_manipulation_extra_" + rowCount).on("click", function(){
|
||||
plusCount = Math.round(new Date().getTime() + (Math.random() * 100));
|
||||
jQuery(".becomes_fields_" + rowCount).append('<br/><select name="field_manipulation[' + data.rowCount + '][becomes][' + plusCount + '][attribute]" id="field_manipulation_becomes_attribute_' + data.rowCount + '">' + data.dropdown + '</select>');
|
||||
});
|
||||
|
||||
})
|
||||
.fail(function( data ) {
|
||||
console.log('Failed AJAX Call :( /// Return Data: ' + data);
|
||||
});
|
||||
});
|
||||
|
||||
// Add extra fields to existing field manipulations
|
||||
jQuery(".field_extra").on('click', function(){
|
||||
var nonce = $('#nonce_manipulation_mapping').val();
|
||||
var className = $(this).attr("class").split(' ')[3];
|
||||
var rowCount = className.split("_")[3];
|
||||
var plusCount = Math.round(new Date().getTime() + (Math.random() * 100));
|
||||
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_ajax',
|
||||
'security': nonce,
|
||||
'rowCount': rowCount
|
||||
}
|
||||
})
|
||||
|
||||
.done(function( data ) {
|
||||
data = JSON.parse( data );
|
||||
jQuery(".becomes_fields_" + rowCount).append('<br/><select name="field_manipulation[' + rowCount + '][becomes][' + plusCount + '][attribute]" id="field_manipulation_becomes_attribute_' + rowCount + '">' + data.dropdown + '</select>');
|
||||
})
|
||||
.fail(function( data ) {
|
||||
console.log('Failed AJAX Call :( /// Return Data: ' + data);
|
||||
});
|
||||
});
|
||||
|
||||
// Add standard filters
|
||||
jQuery(".add-filter").on('click',function(){
|
||||
var nonce = $('#nonce_filters_mapping').val();
|
||||
// Count amount of rows, used to create the form array field and values
|
||||
var TrueRowCount = $('#woosea-ajax-table >tbody >tr').length-1;
|
||||
var rowCount = Math.round(new Date().getTime() + (Math.random() * 100));
|
||||
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_ajax',
|
||||
'security': nonce,
|
||||
'rowCount': rowCount
|
||||
}
|
||||
})
|
||||
.done(function( data ) {
|
||||
data = JSON.parse( data );
|
||||
|
||||
if(TrueRowCount == 0){
|
||||
$( '#woosea-ajax-table' ).find('tbody:first').append('<tr><td><input type="hidden" name="rules[' + data.rowCount + '][rowCount]" value="' + data.rowCount + '"><input type="checkbox" name="record" class="checkbox-field"></td><td><i>Filter:</i></td><td><select name="rules[' + data.rowCount + '][attribute]" id="rules_' + data.rowCount + '">' + data.dropdown + '</select></td><td><select name="rules[' + data.rowCount + '][condition]" class="select-field"><option value="contains">contains</option><option value="containsnot">does not contain</option><option value="=">is equal to</option><option value="!=">is not equal to</option><option value=">">is greater than</option><option value=">=">is greater or equal to</option><option value="<">is less than</option><option value="=<">is less or equal to</option><option value="empty">is empty</option><option value="notempty">is not empty</option></select></td><td><input type="text" name="rules[' + rowCount + '][criteria]" class="input-field-large" id="criteria_' + data.rowCount + '"></td><td><input type="checkbox" name="rules[' + rowCount + '][cs]" class="checkbox-field" alt="Case sensitive"></td><td><select name="rules[' + rowCount + '][than]" class="select-field"><optgroup label="Action">Action:<option value="exclude"> Exclude</option><option value="include_only">Include only</option></optgroup></select></td><td> </td></tr>');
|
||||
} else {
|
||||
$('<tr><td><input type="hidden" name="rules[' + data.rowCount + '][rowCount]" value="' + data.rowCount + '"><input type="checkbox" name="record" class="checkbox-field"></td><td><i>Filter:</i></td><td><select name="rules[' + data.rowCount + '][attribute]" id="rules_' + data.rowCount + '">' + data.dropdown + '</select></td><td><select name="rules[' + data.rowCount + '][condition]" class="select-field"><option value="contains">contains</option><option value="containsnot">does not contain</option><option value="=">is equal to</option><option value="!=">is not equal to</option><option value=">">is greater than</option><option value=">=">is greater or equal to</option><option value="<">is less than</option><option value="=<">is less or equal to</option><option value="empty">is empty</option><option value="notempty">is not empty</option></select></td><td><input type="text" name="rules[' + rowCount + '][criteria]" class="input-field-large" id="criteria_' + data.rowCount + '"></td><td><input type="checkbox" name="rules[' + rowCount + '][cs]" class="checkbox-field" alt="Case sensitive"></td><td><select name="rules[' + rowCount + '][than]" class="select-field"><optgroup label="Action">Action:<option value="exclude"> Exclude</option><option value="include_only">Include only</option></optgroup></select></td><td> </td></tr>').insertBefore( ".rules-buttons");
|
||||
}
|
||||
|
||||
// Check if user selected a data manipulation condition
|
||||
jQuery("#rules_" + rowCount).on("change", function(){
|
||||
if ($(this).val() == "categories") {
|
||||
var checkNumeric = $.isNumeric(rowCount);
|
||||
if(checkNumeric) {
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_categories_dropdown',
|
||||
'rowCount': rowCount
|
||||
}
|
||||
})
|
||||
|
||||
.done(function( data ) {
|
||||
data = JSON.parse( data );
|
||||
jQuery("#criteria_" + rowCount).replaceWith('' + data.dropdown + '');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
.fail(function( data ) {
|
||||
console.log('Failed AJAX Call :( /// Return Data: ' + data);
|
||||
});
|
||||
});
|
||||
|
||||
// Add rules
|
||||
jQuery(".add-rule").on('click',function(){
|
||||
var nonce = $('#nonce_filters_mapping').val();
|
||||
// Count amount of rows, used to create the form array field and values
|
||||
var TrueRowCount = $('#woosea-ajax-table >tbody >tr').length-1;
|
||||
var rowCount = Math.round(new Date().getTime() + (Math.random() * 100));
|
||||
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
'action': 'woosea_ajax',
|
||||
'security': nonce,
|
||||
'rowCount': rowCount
|
||||
}
|
||||
})
|
||||
.done(function( data ) {
|
||||
data = JSON.parse( data );
|
||||
|
||||
if(TrueRowCount == 0){
|
||||
$( '#woosea-ajax-table' ).find('tbody:first').append('<tr><td><input type="hidden" name="rules2[' + data.rowCount + '][rowCount]" value="' + data.rowCount + '"><input type="checkbox" name="record" class="checkbox-field"></td><td><i>Rule:</i></td><td><select name="rules2[' + data.rowCount + '][attribute]" class="select-field">' + data.dropdown + '</select></td><td><select name="rules2[' + data.rowCount + '][condition]" class="select-field" id="condition_' + data.rowCount + '""><option value="contains">contains</option><option value="containsnot">does not contain</option><option value="=">is equal to</option><option value="!=">is not equal to</option><option value=">">is greater than</option><option value=">=">is greater or equal to</option><option value="<">is less than</option><option value="=<">is less or equal to</option><option value="empty">is empty</option><option value="multiply">multiply</option><option value="divide">divide</option><option value="plus">plus</option><option value="minus">minus</option><option value="findreplace">find and replace</option></select></td><td><input type="text" name="rules2[' + rowCount + '][criteria]" class="input-field-large"></td><td><input type="checkbox" name="rules2[' + rowCount + '][cs]" class="checkbox-field" alt="Case sensitive" id="cs_' + data.rowCount + '"></td><td><select name="rules2[' + data.rowCount + '][than_attribute]" class="select-field" id="than_attribute_' + rowCount +'" style="width:150px;">' + data.dropdown + '</select> </td><td><input type="text" name="rules2[' + rowCount + '][newvalue]" class="input-field-large" id="is-field_' + rowCount +'"></td></tr>');
|
||||
} else {
|
||||
$('<tr><td><input type="hidden" name="rules2[' + data.rowCount + '][rowCount]" value="' + data.rowCount + '"><input type="checkbox" name="record" class="checkbox-field"></td><td><i>Rule:</i></td><td><select name="rules2[' + data.rowCount + '][attribute]" class="select-field">' + data.dropdown + '</select></td><td><select name="rules2[' + data.rowCount + '][condition]" class="select-field" id="condition_' + data.rowCount + '""><option value="contains">contains</option><option value="containsnot">does not contain</option><option value="=">is equal to</option><option value="!=">is not equal to</option><option value=">">is greater than</option><option value=">=">is greater or equal to</option><option value="<">is less than</option><option value="=<">is less or equal to</option><option value="empty">is empty</option><option value="multiply">multiply</option><option value="divide">divide</option><option value="plus">plus</option><option value="minus">minus</option><option value="findreplace">find and replace</option></select></td><td><input type="text" name="rules2[' + rowCount + '][criteria]" class="input-field-large"></td><td><input type="checkbox" name="rules2[' + rowCount + '][cs]" class="checkbox-field" alt="Case sensitive" id="cs_' + data.rowCount + '"></td><td><select name="rules2[' + data.rowCount + '][than_attribute]" class="select-field" id="than_attribute_' + rowCount +'" style="width:150px;">' + data.dropdown + '</select> </td><td><input type="text" name="rules2[' + rowCount + '][newvalue]" class="input-field-large" id="is-field_' + rowCount +'"></td></tr>').insertBefore( ".rules-buttons");
|
||||
}
|
||||
|
||||
// Check if user selected a data manipulation condition
|
||||
jQuery("#condition_" + rowCount).on("change", function(){
|
||||
|
||||
var manipulators = ['multiply', 'divide', 'plus', 'minus'];
|
||||
var cond = $(this).val();
|
||||
|
||||
// User selected a data manipulation value so remove some input fields
|
||||
if(jQuery.inArray(cond, manipulators) != -1){
|
||||
jQuery("#than_attribute_" + rowCount).remove();
|
||||
jQuery("#is-field_" + rowCount).remove();
|
||||
jQuery("#cs_" + rowCount).remove();
|
||||
}
|
||||
|
||||
// Replace pieces of string
|
||||
var modifiers = ['replace'];
|
||||
if(jQuery.inArray(cond, modifiers) != -1){
|
||||
jQuery("#than_attribute_" + rowCount).remove();
|
||||
jQuery("#cs_" + rowCount).remove();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Check if user created a Google category rule
|
||||
jQuery("#than_attribute_" + rowCount).on("change", function(){
|
||||
|
||||
if ($(this).val() == "google_category") {
|
||||
var rownr = $(this).closest("tr").prevAll("tr").length;
|
||||
|
||||
$("#is-field_" + rowCount).replaceWith('<input type="search" name="rules2[' + rowCount + '][newvalue]" class="input-field-large js-typeahead js-autosuggest autocomplete_' + rowCount + '">');
|
||||
|
||||
jQuery(".js-autosuggest").on('click', function(){
|
||||
var rowCount = $(this).closest("tr").prevAll("tr").length;
|
||||
|
||||
jQuery( ".autocomplete_" + rowCount ).typeahead({
|
||||
input: '.js-autosuggest',
|
||||
source: google_taxonomy,
|
||||
hint: true,
|
||||
loadingAnimation: true,
|
||||
items: 10,
|
||||
minLength: 2,
|
||||
alignWidth: false,
|
||||
debug: true
|
||||
});
|
||||
jQuery( ".autocomplete_" + rowCount ).focus();
|
||||
|
||||
jQuery(this).keyup(function (){
|
||||
var minimum = 5;
|
||||
var len = jQuery(this).val().length;
|
||||
if (len >= minimum){
|
||||
jQuery(this).closest("input").removeClass("input-field-large");
|
||||
jQuery(this).closest("input").addClass("input-field-large-active");
|
||||
} else {
|
||||
jQuery(this).closest("input").removeClass("input-field-large-active");
|
||||
jQuery(this).closest("input").addClass("input-field-large");
|
||||
}
|
||||
});
|
||||
|
||||
jQuery(this).click(function (){
|
||||
var len = jQuery(this).val().length;
|
||||
if (len < 1){
|
||||
jQuery(this).closest("input").removeClass("input-field-large-active");
|
||||
jQuery(this).closest("input").addClass("input-field-large");
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
.fail(function( data ) {
|
||||
console.log('Failed AJAX Call :( /// Return Data: ' + data);
|
||||
});
|
||||
});
|
||||
|
||||
// Find and remove selected table rows
|
||||
jQuery(".delete-row").on('click',function(){
|
||||
//$("table tbody").find('input[name="record"]').each(function(){
|
||||
$(".woo-product-feed-pro-body").find('input[name="record"]').each(function(){
|
||||
if($(this).is(":checked")){
|
||||
$(this).parents("tr").remove();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,58 @@
|
||||
jQuery(document).ready(function($) {
|
||||
$(function(){
|
||||
$( "#sortable1, #sortable2" ).sortable({
|
||||
cursor: 'move',
|
||||
connectWith: ".connectedSortable"
|
||||
}).disableSelection();
|
||||
} );
|
||||
|
||||
if ($( "#woosea-progress-table" ).hasClass( "progress-bar" )) {
|
||||
|
||||
$(function() {
|
||||
var progressbar = $( "#progressbar" ),
|
||||
progressLabel = $( ".progress-label" );
|
||||
|
||||
var project_hash = $("#project_hash").val();
|
||||
|
||||
progressbar.progressbar({
|
||||
value: false,
|
||||
change: function() {
|
||||
progressLabel.text( progressbar.progressbar( "value" ) + "%" );
|
||||
},
|
||||
|
||||
complete: function() {
|
||||
progressLabel.text( "100%, done!" );
|
||||
}
|
||||
});
|
||||
|
||||
function progress() {
|
||||
var val = progressbar.progressbar( "value" ) || 0;
|
||||
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: { 'action': 'woosea_progress_bar', 'project_hash': project_hash }
|
||||
})
|
||||
.done(function( data ) {
|
||||
data = JSON.parse( data );
|
||||
data = parseInt(data);
|
||||
|
||||
progressbar.progressbar( "value", data );
|
||||
|
||||
if ( data < 99 ) {
|
||||
setTimeout( progress, 80 );
|
||||
} else {
|
||||
$( '#woosea-progress-table').append('<tr><td colspan="2">Jippie gelukt</td></tr>');
|
||||
}
|
||||
})
|
||||
.fail(function( data ) {
|
||||
console.log('Failed AJAX Call :( /// Return Data: ' + data);
|
||||
});
|
||||
|
||||
}
|
||||
setTimeout( progress, 2000 );
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
jQuery(document).ready(function($) {
|
||||
var path = $(location).attr('href');
|
||||
var currentTime = new Date();
|
||||
|
||||
if (path.toLowerCase().indexOf("order-received") >= 0){
|
||||
if (window.localStorage) {
|
||||
|
||||
// Check if concerns in-session conversion
|
||||
var adTribesID = localStorage.getItem("adTribesID");
|
||||
var utm_source = localStorage.getItem("utm_source");
|
||||
var utm_campaign = localStorage.getItem("utm_campaign");
|
||||
var utm_medium = localStorage.getItem("utm_medium");
|
||||
var utm_term = localStorage.getItem("utm_term");
|
||||
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: { 'action': 'woosea_track_conversion', 'utm_source': utm_source, 'utm_campaign': utm_campaign, 'utm_medium': utm_medium, 'utm_term': utm_term, 'adTribesID': adTribesID }
|
||||
})
|
||||
.done(function( data ) {
|
||||
data = JSON.parse( data );
|
||||
|
||||
if (data.conversion_saved == "yes"){
|
||||
// Conversion has been saved so we can clear our local storage
|
||||
localStorage.removeItem("adTribesID");
|
||||
localStorage.removeItem("utm_source");
|
||||
localStorage.removeItem("utm_campaign");
|
||||
localStorage.removeItem("utm_medium");
|
||||
localStorage.removeItem("utm_term");
|
||||
}
|
||||
})
|
||||
.fail(function( data ) {
|
||||
console.log('Failed sending conversion data via AJAX Call :( /// Return Data: ' + data);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (path.toLowerCase().indexOf("adtribesid") >= 0){
|
||||
if (window.localStorage) {
|
||||
// First make sure older localstorage settings are empty
|
||||
localStorage.removeItem("adTribesID");
|
||||
localStorage.removeItem("utm_source");
|
||||
localStorage.removeItem("utm_campaign");
|
||||
localStorage.removeItem("utm_medium");
|
||||
localStorage.removeItem("utm_term");
|
||||
|
||||
var splitted_path = path.split('?');
|
||||
var parameter_parts = splitted_path[1].split('&');
|
||||
|
||||
for(i=0;i<parameter_parts.length;i++){
|
||||
// Save UTM's in local storage
|
||||
if (parameter_parts[i].toLowerCase().indexOf("utm_") >= 0){
|
||||
var utm_details = parameter_parts[i].split('=');
|
||||
var utm_key = utm_details[0];
|
||||
var utm_value = utm_details[1];
|
||||
var clean_value = utm_value.replace("%20", " ");
|
||||
|
||||
localStorage.setItem(utm_key, clean_value);
|
||||
} else if (parameter_parts[i].toLowerCase().indexOf("adtribesid") >= 0){
|
||||
var adtribes_details = parameter_parts[i].split('=');
|
||||
var adtribes_key = adtribes_details[0];
|
||||
var adtribes_value = adtribes_details[1];
|
||||
var clean_adtribes_value = adtribes_value.replace("%20", " ");
|
||||
|
||||
// Save AdTribesID in local storage
|
||||
localStorage.setItem(adtribes_key, clean_adtribes_value);
|
||||
|
||||
// Save AdTribesID in cookie too
|
||||
jQuery.ajax({
|
||||
method: "POST",
|
||||
url: ajaxurl,
|
||||
data: { 'action': 'woosea_set_cookie', 'adTribesID': clean_adtribes_value }
|
||||
})
|
||||
.done(function( data ) {
|
||||
data = JSON.parse( data );
|
||||
})
|
||||
.fail(function( data ) {
|
||||
console.log('Failed setting cookies via AJAX Call :( /// Return Data: ' + data);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
484
wp-content/plugins/woo-product-feed-pro/js/woosea_typeahead.js
Normal file
484
wp-content/plugins/woo-product-feed-pro/js/woosea_typeahead.js
Normal file
@@ -0,0 +1,484 @@
|
||||
/* =============================================================
|
||||
* bootstrap3-typeahead.js v3.1.0
|
||||
* https://github.com/bassjobsen/Bootstrap-3-Typeahead
|
||||
* =============================================================
|
||||
* Original written by @mdo and @fat
|
||||
* =============================================================
|
||||
* Copyright 2014 Bass Jobsen @bassjobsen
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the 'License');
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an 'AS IS' BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ============================================================ */
|
||||
|
||||
|
||||
(function (root, factory) {
|
||||
|
||||
'use strict';
|
||||
|
||||
// CommonJS module is defined
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
module.exports = factory(require('jquery'));
|
||||
}
|
||||
// AMD module is defined
|
||||
else if (typeof define === 'function' && define.amd) {
|
||||
define(['jquery'], function ($) {
|
||||
return factory ($);
|
||||
});
|
||||
} else {
|
||||
factory(root.jQuery);
|
||||
}
|
||||
|
||||
}(this, function ($) {
|
||||
|
||||
'use strict';
|
||||
// jshint laxcomma: true
|
||||
|
||||
|
||||
/* TYPEAHEAD PUBLIC CLASS DEFINITION
|
||||
* ================================= */
|
||||
|
||||
var Typeahead = function (element, options) {
|
||||
this.$element = $(element);
|
||||
this.options = $.extend({}, $.fn.typeahead.defaults, options);
|
||||
this.matcher = this.options.matcher || this.matcher;
|
||||
this.sorter = this.options.sorter || this.sorter;
|
||||
this.select = this.options.select || this.select;
|
||||
this.autoSelect = typeof this.options.autoSelect == 'boolean' ? this.options.autoSelect : true;
|
||||
this.highlighter = this.options.highlighter || this.highlighter;
|
||||
this.render = this.options.render || this.render;
|
||||
this.updater = this.options.updater || this.updater;
|
||||
this.displayText = this.options.displayText || this.displayText;
|
||||
this.source = this.options.source;
|
||||
this.delay = this.options.delay;
|
||||
this.$menu = $(this.options.menu);
|
||||
this.$appendTo = this.options.appendTo ? $(this.options.appendTo) : null;
|
||||
this.shown = false;
|
||||
this.listen();
|
||||
this.showHintOnFocus = typeof this.options.showHintOnFocus == 'boolean' ? this.options.showHintOnFocus : false;
|
||||
this.afterSelect = this.options.afterSelect;
|
||||
this.addItem = false;
|
||||
};
|
||||
|
||||
Typeahead.prototype = {
|
||||
|
||||
constructor: Typeahead,
|
||||
|
||||
select: function () {
|
||||
var val = this.$menu.find('.active').data('value');
|
||||
this.$element.data('active', val);
|
||||
if(this.autoSelect || val) {
|
||||
var newVal = this.updater(val);
|
||||
// Updater can be set to any random functions via "options" parameter in constructor above.
|
||||
// Add null check for cases when upadter returns void or undefined.
|
||||
if (!newVal) {
|
||||
newVal = "";
|
||||
}
|
||||
this.$element
|
||||
.val(this.displayText(newVal) || newVal)
|
||||
.change();
|
||||
this.afterSelect(newVal);
|
||||
}
|
||||
return this.hide();
|
||||
},
|
||||
|
||||
updater: function (item) {
|
||||
return item;
|
||||
},
|
||||
|
||||
setSource: function (source) {
|
||||
this.source = source;
|
||||
},
|
||||
|
||||
show: function () {
|
||||
var pos = $.extend({}, this.$element.position(), {
|
||||
height: this.$element[0].offsetHeight
|
||||
}), scrollHeight;
|
||||
|
||||
scrollHeight = typeof this.options.scrollHeight == 'function' ?
|
||||
this.options.scrollHeight.call() :
|
||||
this.options.scrollHeight;
|
||||
|
||||
var element;
|
||||
if (this.shown) {
|
||||
element = this.$menu;
|
||||
} else if (this.$appendTo) {
|
||||
element = this.$menu.appendTo(this.$appendTo);
|
||||
} else {
|
||||
element = this.$menu.insertAfter(this.$element);
|
||||
}
|
||||
element.css({
|
||||
top: pos.top + pos.height + scrollHeight
|
||||
, left: pos.left
|
||||
})
|
||||
.show();
|
||||
|
||||
this.shown = true;
|
||||
return this;
|
||||
},
|
||||
|
||||
hide: function () {
|
||||
this.$menu.hide();
|
||||
this.shown = false;
|
||||
return this;
|
||||
},
|
||||
|
||||
lookup: function (query) {
|
||||
var items;
|
||||
if (typeof(query) != 'undefined' && query !== null) {
|
||||
this.query = query;
|
||||
} else {
|
||||
this.query = this.$element.val() || '';
|
||||
}
|
||||
|
||||
if (this.query.length < this.options.minLength) {
|
||||
return this.shown ? this.hide() : this;
|
||||
}
|
||||
|
||||
var worker = $.proxy(function() {
|
||||
|
||||
if($.isFunction(this.source)) this.source(this.query, $.proxy(this.process, this));
|
||||
else if (this.source) {
|
||||
this.process(this.source);
|
||||
}
|
||||
}, this);
|
||||
|
||||
clearTimeout(this.lookupWorker);
|
||||
this.lookupWorker = setTimeout(worker, this.delay);
|
||||
},
|
||||
|
||||
process: function (items) {
|
||||
var that = this;
|
||||
|
||||
items = $.grep(items, function (item) {
|
||||
return that.matcher(item);
|
||||
});
|
||||
|
||||
items = this.sorter(items);
|
||||
|
||||
if (!items.length && !this.options.addItem) {
|
||||
return this.shown ? this.hide() : this;
|
||||
}
|
||||
|
||||
if (items.length > 0) {
|
||||
this.$element.data('active', items[0]);
|
||||
} else {
|
||||
this.$element.data('active', null);
|
||||
}
|
||||
|
||||
// Add item
|
||||
if (this.options.addItem){
|
||||
items.push(this.options.addItem);
|
||||
}
|
||||
|
||||
if (this.options.items == 'all') {
|
||||
return this.render(items).show();
|
||||
} else {
|
||||
return this.render(items.slice(0, this.options.items)).show();
|
||||
}
|
||||
},
|
||||
|
||||
matcher: function (item) {
|
||||
var it = this.displayText(item);
|
||||
return ~it.toLowerCase().indexOf(this.query.toLowerCase());
|
||||
},
|
||||
|
||||
sorter: function (items) {
|
||||
var beginswith = []
|
||||
, caseSensitive = []
|
||||
, caseInsensitive = []
|
||||
, item;
|
||||
|
||||
while ((item = items.shift())) {
|
||||
var it = this.displayText(item);
|
||||
if (!it.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item);
|
||||
else if (~it.indexOf(this.query)) caseSensitive.push(item);
|
||||
else caseInsensitive.push(item);
|
||||
}
|
||||
|
||||
return beginswith.concat(caseSensitive, caseInsensitive);
|
||||
},
|
||||
|
||||
highlighter: function (item) {
|
||||
var html = $('<div></div>');
|
||||
var query = this.query;
|
||||
var i = item.toLowerCase().indexOf(query.toLowerCase());
|
||||
var len, leftPart, middlePart, rightPart, strong;
|
||||
len = query.length;
|
||||
if(len === 0){
|
||||
return html.text(item).html();
|
||||
}
|
||||
while (i > -1) {
|
||||
leftPart = item.substr(0, i);
|
||||
middlePart = item.substr(i, len);
|
||||
rightPart = item.substr(i + len);
|
||||
strong = $('<strong></strong>').text(middlePart);
|
||||
html
|
||||
.append(document.createTextNode(leftPart))
|
||||
.append(strong);
|
||||
item = rightPart;
|
||||
i = item.toLowerCase().indexOf(query.toLowerCase());
|
||||
}
|
||||
return html.append(document.createTextNode(item)).html();
|
||||
},
|
||||
|
||||
render: function (items) {
|
||||
var that = this;
|
||||
var self = this;
|
||||
var activeFound = false;
|
||||
items = $(items).map(function (i, item) {
|
||||
var text = self.displayText(item);
|
||||
i = $(that.options.item).data('value', item);
|
||||
i.find('a').html(that.highlighter(text));
|
||||
if (text == self.$element.val()) {
|
||||
i.addClass('active');
|
||||
self.$element.data('active', item);
|
||||
activeFound = true;
|
||||
}
|
||||
return i[0];
|
||||
});
|
||||
|
||||
if (this.autoSelect && !activeFound) {
|
||||
items.first().addClass('active');
|
||||
this.$element.data('active', items.first().data('value'));
|
||||
}
|
||||
this.$menu.html(items);
|
||||
return this;
|
||||
},
|
||||
|
||||
displayText: function(item) {
|
||||
return typeof item !== 'undefined' && typeof item.name != 'undefined' && item.name || item;
|
||||
},
|
||||
|
||||
next: function (event) {
|
||||
var active = this.$menu.find('.active').removeClass('active')
|
||||
, next = active.next();
|
||||
|
||||
if (!next.length) {
|
||||
next = $(this.$menu.find('li')[0]);
|
||||
}
|
||||
|
||||
next.addClass('active');
|
||||
},
|
||||
|
||||
prev: function (event) {
|
||||
var active = this.$menu.find('.active').removeClass('active')
|
||||
, prev = active.prev();
|
||||
|
||||
if (!prev.length) {
|
||||
prev = this.$menu.find('li').last();
|
||||
}
|
||||
|
||||
prev.addClass('active');
|
||||
},
|
||||
|
||||
listen: function () {
|
||||
this.$element
|
||||
.on('focus', $.proxy(this.focus, this))
|
||||
.on('blur', $.proxy(this.blur, this))
|
||||
.on('keypress', $.proxy(this.keypress, this))
|
||||
.on('keyup', $.proxy(this.keyup, this));
|
||||
|
||||
if (this.eventSupported('keydown')) {
|
||||
this.$element.on('keydown', $.proxy(this.keydown, this));
|
||||
}
|
||||
|
||||
this.$menu
|
||||
.on('click', $.proxy(this.click, this))
|
||||
.on('mouseenter', 'li', $.proxy(this.mouseenter, this))
|
||||
.on('mouseleave', 'li', $.proxy(this.mouseleave, this));
|
||||
},
|
||||
|
||||
destroy : function () {
|
||||
this.$element.data('typeahead',null);
|
||||
this.$element.data('active',null);
|
||||
this.$element
|
||||
.off('focus')
|
||||
.off('blur')
|
||||
.off('keypress')
|
||||
.off('keyup');
|
||||
|
||||
if (this.eventSupported('keydown')) {
|
||||
this.$element.off('keydown');
|
||||
}
|
||||
|
||||
this.$menu.remove();
|
||||
},
|
||||
|
||||
eventSupported: function(eventName) {
|
||||
var isSupported = eventName in this.$element;
|
||||
if (!isSupported) {
|
||||
this.$element.setAttribute(eventName, 'return;');
|
||||
isSupported = typeof this.$element[eventName] === 'function';
|
||||
}
|
||||
return isSupported;
|
||||
},
|
||||
|
||||
move: function (e) {
|
||||
if (!this.shown) return;
|
||||
|
||||
switch(e.keyCode) {
|
||||
case 9: // tab
|
||||
case 13: // enter
|
||||
case 27: // escape
|
||||
e.preventDefault();
|
||||
break;
|
||||
|
||||
case 38: // up arrow
|
||||
// with the shiftKey (this is actually the left parenthesis)
|
||||
if (e.shiftKey) return;
|
||||
e.preventDefault();
|
||||
this.prev();
|
||||
break;
|
||||
|
||||
case 40: // down arrow
|
||||
// with the shiftKey (this is actually the right parenthesis)
|
||||
if (e.shiftKey) return;
|
||||
e.preventDefault();
|
||||
this.next();
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
keydown: function (e) {
|
||||
this.suppressKeyPressRepeat = ~$.inArray(e.keyCode, [40,38,9,13,27]);
|
||||
if (!this.shown && e.keyCode == 40) {
|
||||
this.lookup();
|
||||
} else {
|
||||
this.move(e);
|
||||
}
|
||||
},
|
||||
|
||||
keypress: function (e) {
|
||||
if (this.suppressKeyPressRepeat) return;
|
||||
this.move(e);
|
||||
},
|
||||
|
||||
keyup: function (e) {
|
||||
switch(e.keyCode) {
|
||||
case 40: // down arrow
|
||||
case 38: // up arrow
|
||||
case 16: // shift
|
||||
case 17: // ctrl
|
||||
case 18: // alt
|
||||
break;
|
||||
|
||||
case 9: // tab
|
||||
case 13: // enter
|
||||
if (!this.shown) return;
|
||||
this.select();
|
||||
break;
|
||||
|
||||
case 27: // escape
|
||||
if (!this.shown) return;
|
||||
this.hide();
|
||||
break;
|
||||
default:
|
||||
this.lookup();
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
},
|
||||
|
||||
focus: function (e) {
|
||||
if (!this.focused) {
|
||||
this.focused = true;
|
||||
if (this.options.showHintOnFocus) {
|
||||
this.lookup('');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
blur: function (e) {
|
||||
this.focused = false;
|
||||
if (!this.mousedover && this.shown) this.hide();
|
||||
},
|
||||
|
||||
click: function (e) {
|
||||
e.preventDefault();
|
||||
this.select();
|
||||
this.$element.focus();
|
||||
},
|
||||
|
||||
mouseenter: function (e) {
|
||||
this.mousedover = true;
|
||||
this.$menu.find('.active').removeClass('active');
|
||||
$(e.currentTarget).addClass('active');
|
||||
},
|
||||
|
||||
mouseleave: function (e) {
|
||||
this.mousedover = false;
|
||||
if (!this.focused && this.shown) this.hide();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* TYPEAHEAD PLUGIN DEFINITION
|
||||
* =========================== */
|
||||
|
||||
var old = $.fn.typeahead;
|
||||
|
||||
$.fn.typeahead = function (option) {
|
||||
var arg = arguments;
|
||||
if (typeof option == 'string' && option == 'getActive') {
|
||||
return this.data('active');
|
||||
}
|
||||
return this.each(function () {
|
||||
var $this = $(this)
|
||||
, data = $this.data('typeahead')
|
||||
, options = typeof option == 'object' && option;
|
||||
if (!data) $this.data('typeahead', (data = new Typeahead(this, options)));
|
||||
if (typeof option == 'string') {
|
||||
if (arg.length > 1) {
|
||||
data[option].apply(data, Array.prototype.slice.call(arg ,1));
|
||||
} else {
|
||||
data[option]();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$.fn.typeahead.defaults = {
|
||||
source: []
|
||||
, items: 8
|
||||
, menu: '<ul class="typeahead dropdown-menu" role="listbox"></ul>'
|
||||
, item: '<li><a class="dropdown-item" href="#" role="option"></a></li>'
|
||||
, minLength: 1
|
||||
, scrollHeight: 0
|
||||
, autoSelect: true
|
||||
, afterSelect: $.noop
|
||||
, addItem: false
|
||||
, delay: 0
|
||||
};
|
||||
|
||||
$.fn.typeahead.Constructor = Typeahead;
|
||||
|
||||
|
||||
/* TYPEAHEAD NO CONFLICT
|
||||
* =================== */
|
||||
|
||||
$.fn.typeahead.noConflict = function () {
|
||||
$.fn.typeahead = old;
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
/* TYPEAHEAD DATA-API
|
||||
* ================== */
|
||||
|
||||
$(document).on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
|
||||
var $this = $(this);
|
||||
if ($this.data('typeahead')) return;
|
||||
$this.typeahead($this.data());
|
||||
});
|
||||
|
||||
}));
|
||||
@@ -0,0 +1,60 @@
|
||||
jQuery(document).ready(function($) {
|
||||
|
||||
// Disable submit button, will only enable if all fields validate
|
||||
$('#goforit').attr('disabled',true);
|
||||
|
||||
// Validate project name
|
||||
$( "#projectname" ).on('blur', function() {
|
||||
var input=$(this);
|
||||
var re = /^[a-zA-Z0-9-_.àèìòùÀÈÌÒÙáéíóúýÁÉÍÓÚÝâêîôûÂÊÎÔÛãñõÃÑÕäëïöüÿÄËÏÖÜŸçÇߨøÅ寿œ ]*$/;
|
||||
var minLength = 3;
|
||||
var maxLength = 30;
|
||||
var is_projectname=re.test(input.val());
|
||||
// Check for allowed characters
|
||||
if (!is_projectname){
|
||||
$('.notice').replaceWith("<div class='notice notice-error is-dismissible'><p>Sorry, only letters, numbers, whitespaces, -, . and _ are allowed for the projectname</p></div>");
|
||||
// Disable submit button too
|
||||
$('#goforit').attr('disabled',true);
|
||||
} else {
|
||||
// Check for length of projectname
|
||||
var value = $(this).val();
|
||||
if (value.length < minLength){
|
||||
$('.notice').replaceWith("<div class='notice notice-error is-dismissible'><p>Sorry, your project name needs to be at least 3 characters long.</p></div>");
|
||||
// Disable submit button too
|
||||
$('#goforit').attr('disabled',true);
|
||||
} else if (value.length > maxLength){
|
||||
// Disable submit button too
|
||||
$('#goforit').attr('disabled',true);
|
||||
$('.notice').replaceWith("<div class='notice notice-error is-dismissible'><p>Sorry, your project name cannot be over 30 characters long.</p></div>");
|
||||
} else {
|
||||
$('.notice').replaceWith("<div class='notice notice-info is-dismissible'><p>Please select the country and channel for which you would like to create a new product feed. The channel drop-down will populate with relevant country channels once you selected a country. Filling in a project name is mandatory.</p></div>");
|
||||
//$('.notice').remove();
|
||||
// Enable submit button
|
||||
$('#goforit').attr('disabled',false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Validate ruling values
|
||||
$( "#rulevalue" ).on('blur', function(){
|
||||
//$( "#rulevalue" ).blur("input", function(){
|
||||
var input=$(this);
|
||||
var minLength = 1;
|
||||
var maxLength = 200;
|
||||
var value = $(this).val();
|
||||
|
||||
if (value.length < minLength){
|
||||
$('#rulevalueerror').append("<div id='woo-product-feed-pro-errormessage'>Sorry, minimum length is 1 charachter</div>");
|
||||
// Disable submit button too
|
||||
$('#goforit').attr('disabled',true);
|
||||
} else if (value.length > maxLength){
|
||||
// Disable submit button too
|
||||
$('#goforit').attr('disabled',true);
|
||||
$('#rulevalueerror').append("<div id='woo-product-feed-pro-errormessage'>Sorry, this value cannot be over 200 characters long.</div>");
|
||||
} else {
|
||||
$('#errormessage').remove();
|
||||
// Enable submit button
|
||||
$('#goforit').attr('disabled',false);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user