first commit
This commit is contained in:
173
modules/mailchimppro/views/js/ajaxq.js
Normal file
173
modules/mailchimppro/views/js/ajaxq.js
Normal file
@@ -0,0 +1,173 @@
|
||||
/**
|
||||
* PrestaChamps
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Commercial License
|
||||
* you can't distribute, modify or sell this code
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file
|
||||
* If you need help please contact leo@prestachamps.com
|
||||
*
|
||||
* @author Mailchimp
|
||||
* @copyright PrestaChamps
|
||||
* @license commercial
|
||||
*/
|
||||
|
||||
(function (factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(['jquery'], factory);
|
||||
} else if (typeof module === 'object' && module.exports) {
|
||||
// Node/CommonJS
|
||||
module.exports = factory(require('jquery'));
|
||||
} else {
|
||||
// Browser globals
|
||||
factory(jQuery);
|
||||
}
|
||||
}(function ($) {
|
||||
var queues = {};
|
||||
var activeReqs = {};
|
||||
|
||||
// Register an $.ajaxq function, which follows the $.ajax interface, but allows a queue name which will force only one request per queue to fire.
|
||||
// opts can be the regular $.ajax settings plainObject, or a callback returning the settings object, to be evaluated just prior to the actual call to $.ajax.
|
||||
$.ajaxq = function (qname, opts) {
|
||||
|
||||
if (typeof opts === "undefined") {
|
||||
throw ("AjaxQ: queue name is not provided");
|
||||
}
|
||||
|
||||
// Will return a Deferred promise object extended with success/error/callback, so that this function matches the interface of $.ajax
|
||||
var deferred = $.Deferred(),
|
||||
promise = deferred.promise();
|
||||
|
||||
promise.success = promise.done;
|
||||
promise.error = promise.fail;
|
||||
promise.complete = promise.always;
|
||||
|
||||
// Check whether options are to be evaluated at call time or not.
|
||||
var deferredOpts = typeof opts === 'function';
|
||||
// Create a deep copy of the arguments, and enqueue this request.
|
||||
var clonedOptions = !deferredOpts ? $.extend(true, {}, opts) : null;
|
||||
enqueue(function () {
|
||||
// Send off the ajax request now that the item has been removed from the queue
|
||||
var jqXHR = $.ajax.apply(window, [deferredOpts ? opts() : clonedOptions]);
|
||||
|
||||
// Notify the returned deferred object with the correct context when the jqXHR is done or fails
|
||||
// Note that 'always' will automatically be fired once one of these are called: http://api.jquery.com/category/deferred-object/.
|
||||
jqXHR.done(function () {
|
||||
deferred.resolve.apply(this, arguments);
|
||||
});
|
||||
jqXHR.fail(function () {
|
||||
deferred.reject.apply(this, arguments);
|
||||
});
|
||||
|
||||
jqXHR.always(dequeue); // make sure to dequeue the next request AFTER the done and fail callbacks are fired
|
||||
|
||||
return jqXHR;
|
||||
});
|
||||
|
||||
return promise;
|
||||
|
||||
|
||||
// If there is no queue, create an empty one and instantly process this item.
|
||||
// Otherwise, just add this item onto it for later processing.
|
||||
function enqueue(cb) {
|
||||
if (!queues[qname]) {
|
||||
queues[qname] = [];
|
||||
var xhr = cb();
|
||||
activeReqs[qname] = xhr;
|
||||
}
|
||||
else {
|
||||
queues[qname].push(cb);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the next callback from the queue and fire it off.
|
||||
// If the queue was empty (this was the last item), delete it from memory so the next one can be instantly processed.
|
||||
function dequeue() {
|
||||
if (!queues[qname]) {
|
||||
return;
|
||||
}
|
||||
var nextCallback = queues[qname].shift();
|
||||
if (nextCallback) {
|
||||
var xhr = nextCallback();
|
||||
activeReqs[qname] = xhr;
|
||||
}
|
||||
else {
|
||||
delete queues[qname];
|
||||
delete activeReqs[qname];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Register a $.postq and $.getq method to provide shortcuts for $.get and $.post
|
||||
// Copied from jQuery source to make sure the functions share the same defaults as $.get and $.post.
|
||||
$.each(["getq", "postq"], function (i, method) {
|
||||
$[method] = function (qname, url, data, callback, type) {
|
||||
|
||||
if ($.isFunction(data)) {
|
||||
type = type || callback;
|
||||
callback = data;
|
||||
data = undefined;
|
||||
}
|
||||
|
||||
return $.ajaxq(qname, {
|
||||
type: method === "postq" ? "post" : "get",
|
||||
url: url,
|
||||
data: data,
|
||||
success: callback,
|
||||
dataType: type
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
var isQueueRunning = function (qname) {
|
||||
return (queues.hasOwnProperty(qname) && queues[qname].length > 0);
|
||||
};
|
||||
|
||||
var isAnyQueueRunning = function () {
|
||||
for (var i in queues) {
|
||||
if (isQueueRunning(i)) return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
$.ajaxq.isRunning = function (qname) {
|
||||
if (qname) return isQueueRunning(qname);
|
||||
else return isAnyQueueRunning();
|
||||
};
|
||||
|
||||
$.ajaxq.getActiveRequest = function (qname) {
|
||||
if (!qname) throw ("AjaxQ: queue name is required");
|
||||
|
||||
return activeReqs[qname];
|
||||
};
|
||||
|
||||
$.ajaxq.abort = function (qname) {
|
||||
if (!qname) throw ("AjaxQ: queue name is required");
|
||||
|
||||
var current = $.ajaxq.getActiveRequest(qname);
|
||||
delete queues[qname];
|
||||
delete activeReqs[qname];
|
||||
if (current) current.abort();
|
||||
};
|
||||
|
||||
$.ajaxq.clear = function (qname) {
|
||||
if (!qname) {
|
||||
for (var i in queues) {
|
||||
if (queues.hasOwnProperty(i)) {
|
||||
queues[i] = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (queues[qname]) {
|
||||
queues[qname] = [];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}));
|
||||
29
modules/mailchimppro/views/js/array.chunk.js
Normal file
29
modules/mailchimppro/views/js/array.chunk.js
Normal file
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* PrestaChamps
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Commercial License
|
||||
* you can't distribute, modify or sell this code
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file
|
||||
* If you need help please contact leo@prestachamps.com
|
||||
*
|
||||
* @author Mailchimp
|
||||
* @copyright PrestaChamps
|
||||
* @license commercial
|
||||
*
|
||||
* @param chunk_size
|
||||
* @returns {Array}
|
||||
*/
|
||||
Array.prototype.chunk = function (chunk_size) {
|
||||
var temp = this.slice(0),
|
||||
results = [];
|
||||
|
||||
while (temp.length) {
|
||||
results.push(temp.splice(0, chunk_size));
|
||||
}
|
||||
return results;
|
||||
};
|
||||
34
modules/mailchimppro/views/js/index.php
Normal file
34
modules/mailchimppro/views/js/index.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2018 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2018 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
647
modules/mailchimppro/views/js/jquery.smartWizard.js
Normal file
647
modules/mailchimppro/views/js/jquery.smartWizard.js
Normal file
@@ -0,0 +1,647 @@
|
||||
/*!
|
||||
* SmartWizard v4.3.1
|
||||
* The awesome jQuery step wizard plugin with Bootstrap support
|
||||
* http://www.techlaboratory.net/smartwizard
|
||||
*
|
||||
* Created by Dipu Raj
|
||||
* http://dipuraj.me
|
||||
*
|
||||
* Licensed under the terms of the MIT License
|
||||
* https://github.com/techlab/SmartWizard/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
;(function ($, window, document, undefined) {
|
||||
"use strict";
|
||||
// Default options
|
||||
|
||||
var defaults = {
|
||||
selected: 0, // Initial selected step, 0 = first step
|
||||
keyNavigation: true, // Enable/Disable keyboard navigation(left and right keys are used if enabled)
|
||||
autoAdjustHeight: true, // Automatically adjust content height
|
||||
cycleSteps: false, // Allows to cycle the navigation of steps
|
||||
backButtonSupport: true, // Enable the back button support
|
||||
useURLhash: true, // Enable selection of the step based on url hash
|
||||
showStepURLhash: true, // Show url hash based on step
|
||||
lang: { // Language variables for button
|
||||
next: 'Next',
|
||||
previous: 'Previous'
|
||||
},
|
||||
toolbarSettings: {
|
||||
toolbarPosition: 'bottom', // none, top, bottom, both
|
||||
toolbarButtonPosition: 'end', // start, end
|
||||
showNextButton: true, // show/hide a Next button
|
||||
showPreviousButton: true, // show/hide a Previous button
|
||||
toolbarExtraButtons: [] // Extra buttons to show on toolbar, array of jQuery input/buttons elements
|
||||
},
|
||||
anchorSettings: {
|
||||
anchorClickable: true, // Enable/Disable anchor navigation
|
||||
enableAllAnchors: false, // Activates all anchors clickable all times
|
||||
markDoneStep: true, // Add done css
|
||||
markAllPreviousStepsAsDone: true, // When a step selected by url hash, all previous steps are marked done
|
||||
removeDoneStepOnNavigateBack: false, // While navigate back done step after active step will be cleared
|
||||
enableAnchorOnDoneStep: true // Enable/Disable the done steps navigation
|
||||
},
|
||||
contentURL: null, // content url, Enables Ajax content loading. Can also set as data data-content-url on anchor
|
||||
contentCache: true, // cache step contents, if false content is fetched always from ajax url
|
||||
ajaxSettings: {}, // Ajax extra settings
|
||||
disabledSteps: [], // Array Steps disabled
|
||||
errorSteps: [], // Highlight step with errors
|
||||
hiddenSteps: [], // Hidden steps
|
||||
theme: 'default', // theme for the wizard, related css need to include for other than default theme
|
||||
transitionEffect: 'none', // Effect on navigation, none/slide/fade
|
||||
transitionSpeed: '400'
|
||||
};
|
||||
|
||||
// The plugin constructor
|
||||
function SmartWizard(element, options) {
|
||||
// Merge user settings with default, recursively
|
||||
this.options = $.extend(true, {}, defaults, options);
|
||||
// Main container element
|
||||
this.main = $(element);
|
||||
// Navigation bar element
|
||||
this.nav = this.main.children('ul');
|
||||
// Step anchor elements
|
||||
this.steps = $("li > a", this.nav);
|
||||
// Content container
|
||||
this.container = this.main.children('div');
|
||||
// Content pages
|
||||
this.pages = this.container.children('div');
|
||||
// Active step index
|
||||
this.current_index = null;
|
||||
|
||||
// Backward compatibility
|
||||
this.options.toolbarSettings.toolbarButtonPosition = this.options.toolbarSettings.toolbarButtonPosition === 'right' ? 'end' : this.options.toolbarSettings.toolbarButtonPosition;
|
||||
this.options.toolbarSettings.toolbarButtonPosition = this.options.toolbarSettings.toolbarButtonPosition === 'left' ? 'start' : this.options.toolbarSettings.toolbarButtonPosition;
|
||||
|
||||
// Default fix
|
||||
this.options.theme = this.options.theme === null || this.options.theme === '' ? 'default' : this.options.theme;
|
||||
|
||||
// Call initial method
|
||||
this.init();
|
||||
}
|
||||
|
||||
$.extend(SmartWizard.prototype, {
|
||||
|
||||
init: function () {
|
||||
// Set the elements
|
||||
this._setElements();
|
||||
// Add toolbar
|
||||
this._setToolbar();
|
||||
// Assign plugin events
|
||||
this._setEvents();
|
||||
|
||||
var idx = this.options.selected;
|
||||
// Get selected step from the url
|
||||
if (this.options.useURLhash) {
|
||||
// Get step number from url hash if available
|
||||
var hash = window.location.hash;
|
||||
if (hash && hash.length > 0) {
|
||||
var elm = $("a[href*='" + hash + "']", this.nav);
|
||||
if (elm.length > 0) {
|
||||
var id = this.steps.index(elm);
|
||||
idx = id >= 0 ? id : idx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (idx > 0 && this.options.anchorSettings.markDoneStep && this.options.anchorSettings.markAllPreviousStepsAsDone) {
|
||||
// Mark previous steps of the active step as done
|
||||
this.steps.eq(idx).parent('li').prevAll().addClass("done");
|
||||
}
|
||||
|
||||
// Show the initial step
|
||||
this._showStep(idx);
|
||||
},
|
||||
|
||||
// PRIVATE FUNCTIONS
|
||||
|
||||
_setElements: function () {
|
||||
// Set the main element
|
||||
this.main.addClass('sw-main sw-theme-' + this.options.theme);
|
||||
// Set anchor elements
|
||||
this.nav.addClass('nav nav-tabs step-anchor').children('li').addClass('nav-item').children('a').addClass('nav-link'); // nav-justified nav-pills
|
||||
|
||||
// Make the anchor clickable
|
||||
if (this.options.anchorSettings.enableAllAnchors !== false && this.options.anchorSettings.anchorClickable !== false) {
|
||||
this.steps.parent('li').addClass('clickable');
|
||||
}
|
||||
// Set content container
|
||||
this.container.addClass('sw-container tab-content');
|
||||
// Set content pages
|
||||
this.pages.addClass('tab-pane step-content');
|
||||
|
||||
// Disabled steps
|
||||
var mi = this;
|
||||
if (this.options.disabledSteps && this.options.disabledSteps.length > 0) {
|
||||
$.each(this.options.disabledSteps, function (i, n) {
|
||||
mi.steps.eq(n).parent('li').addClass('disabled');
|
||||
});
|
||||
}
|
||||
// Error steps
|
||||
if (this.options.errorSteps && this.options.errorSteps.length > 0) {
|
||||
$.each(this.options.errorSteps, function (i, n) {
|
||||
mi.steps.eq(n).parent('li').addClass('danger');
|
||||
});
|
||||
}
|
||||
// Hidden steps
|
||||
if (this.options.hiddenSteps && this.options.hiddenSteps.length > 0) {
|
||||
$.each(this.options.hiddenSteps, function (i, n) {
|
||||
mi.steps.eq(n).parent('li').addClass('hidden');
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
_setToolbar: function () {
|
||||
// Skip right away if the toolbar is not enabled
|
||||
if (this.options.toolbarSettings.toolbarPosition === 'none') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Create the toolbar buttons
|
||||
var btnNext = this.options.toolbarSettings.showNextButton !== false ? $('<button></button>').text(this.options.lang.next).addClass('btn btn-secondary sw-btn-next').attr('type', 'button') : null;
|
||||
var btnPrevious = this.options.toolbarSettings.showPreviousButton !== false ? $('<button></button>').text(this.options.lang.previous).addClass('btn btn-secondary sw-btn-prev').attr('type', 'button') : null;
|
||||
var btnGroup = $('<div></div>').addClass('btn-group mr-2 sw-btn-group').attr('role', 'group').append(btnPrevious, btnNext);
|
||||
|
||||
// Add extra toolbar buttons
|
||||
var btnGroupExtra = null;
|
||||
|
||||
if (this.options.toolbarSettings.toolbarExtraButtons && this.options.toolbarSettings.toolbarExtraButtons.length > 0) {
|
||||
btnGroupExtra = $('<div></div>').addClass('btn-group mr-2 sw-btn-group-extra').attr('role', 'group');
|
||||
$.each(this.options.toolbarSettings.toolbarExtraButtons, function (i, n) {
|
||||
btnGroupExtra.append(n.clone(true));
|
||||
});
|
||||
}
|
||||
|
||||
var toolbarTop, toolbarBottom;
|
||||
// Append toolbar based on the position
|
||||
switch (this.options.toolbarSettings.toolbarPosition) {
|
||||
case 'top':
|
||||
toolbarTop = $('<div></div>').addClass('btn-toolbar sw-toolbar sw-toolbar-top justify-content-' + this.options.toolbarSettings.toolbarButtonPosition);
|
||||
toolbarTop.append(btnGroup);
|
||||
if (this.options.toolbarSettings.toolbarButtonPosition === 'start') {
|
||||
toolbarTop.prepend(btnGroupExtra);
|
||||
} else {
|
||||
toolbarTop.append(btnGroupExtra);
|
||||
}
|
||||
this.container.before(toolbarTop);
|
||||
break;
|
||||
case 'bottom':
|
||||
toolbarBottom = $('<div></div>').addClass('btn-toolbar sw-toolbar sw-toolbar-bottom justify-content-' + this.options.toolbarSettings.toolbarButtonPosition);
|
||||
toolbarBottom.append(btnGroup);
|
||||
if (this.options.toolbarSettings.toolbarButtonPosition === 'start') {
|
||||
toolbarBottom.prepend(btnGroupExtra);
|
||||
} else {
|
||||
toolbarBottom.append(btnGroupExtra);
|
||||
}
|
||||
this.container.after(toolbarBottom);
|
||||
break;
|
||||
case 'both':
|
||||
toolbarTop = $('<div></div>').addClass('btn-toolbar sw-toolbar sw-toolbar-top justify-content-' + this.options.toolbarSettings.toolbarButtonPosition);
|
||||
toolbarTop.append(btnGroup);
|
||||
if (this.options.toolbarSettings.toolbarButtonPosition === 'start') {
|
||||
toolbarTop.prepend(btnGroupExtra);
|
||||
} else {
|
||||
toolbarTop.append(btnGroupExtra);
|
||||
}
|
||||
this.container.before(toolbarTop);
|
||||
|
||||
toolbarBottom = $('<div></div>').addClass('btn-toolbar sw-toolbar sw-toolbar-bottom justify-content-' + this.options.toolbarSettings.toolbarButtonPosition);
|
||||
toolbarBottom.append(btnGroup.clone(true));
|
||||
|
||||
if (btnGroupExtra !== null) {
|
||||
if (this.options.toolbarSettings.toolbarButtonPosition === 'start') {
|
||||
toolbarBottom.prepend(btnGroupExtra.clone(true));
|
||||
} else {
|
||||
toolbarBottom.append(btnGroupExtra.clone(true));
|
||||
}
|
||||
}
|
||||
this.container.after(toolbarBottom);
|
||||
break;
|
||||
default:
|
||||
toolbarBottom = $('<div></div>').addClass('btn-toolbar sw-toolbar sw-toolbar-bottom justify-content-' + this.options.toolbarSettings.toolbarButtonPosition);
|
||||
toolbarBottom.append(btnGroup);
|
||||
if (this.options.toolbarSettings.toolbarButtonPosition === 'start') {
|
||||
toolbarBottom.append(btnGroupExtra);
|
||||
} else {
|
||||
toolbarBottom.append(btnGroupExtra);
|
||||
}
|
||||
this.container.after(toolbarBottom);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
_setEvents: function () {
|
||||
// Anchor click event
|
||||
var mi = this;
|
||||
$(this.steps).on("click", function (e) {
|
||||
e.preventDefault();
|
||||
if (mi.options.anchorSettings.anchorClickable === false) {
|
||||
return true;
|
||||
}
|
||||
var idx = mi.steps.index(this);
|
||||
if (mi.options.anchorSettings.enableAnchorOnDoneStep === false && mi.steps.eq(idx).parent('li').hasClass('done')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (idx !== mi.current_index) {
|
||||
if (mi.options.anchorSettings.enableAllAnchors !== false && mi.options.anchorSettings.anchorClickable !== false) {
|
||||
mi._showStep(idx);
|
||||
} else {
|
||||
if (mi.steps.eq(idx).parent('li').hasClass('done')) {
|
||||
mi._showStep(idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Next button event
|
||||
$('.sw-btn-next', this.main).on("click", function (e) {
|
||||
e.preventDefault();
|
||||
mi._showNext();
|
||||
});
|
||||
|
||||
// Previous button event
|
||||
$('.sw-btn-prev', this.main).on("click", function (e) {
|
||||
e.preventDefault();
|
||||
mi._showPrevious();
|
||||
});
|
||||
|
||||
// Keyboard navigation event
|
||||
if (this.options.keyNavigation) {
|
||||
$(document).keyup(function (e) {
|
||||
mi._keyNav(e);
|
||||
});
|
||||
}
|
||||
|
||||
// Back/forward browser button event
|
||||
if (this.options.backButtonSupport) {
|
||||
$(window).on('hashchange', function (e) {
|
||||
if (!mi.options.useURLhash) {
|
||||
return true;
|
||||
}
|
||||
if (window.location.hash) {
|
||||
var elm = $("a[href*='" + window.location.hash + "']", mi.nav);
|
||||
if (elm && elm.length > 0) {
|
||||
e.preventDefault();
|
||||
mi._showStep(mi.steps.index(elm));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
_showNext: function () {
|
||||
var si = this.current_index + 1;
|
||||
// Find the next not disabled step
|
||||
for (var i = si; i < this.steps.length; i++) {
|
||||
if (!this.steps.eq(i).parent('li').hasClass('disabled') && !this.steps.eq(i).parent('li').hasClass('hidden')) {
|
||||
si = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.steps.length <= si) {
|
||||
if (!this.options.cycleSteps) {
|
||||
return false;
|
||||
}
|
||||
si = 0;
|
||||
}
|
||||
this._showStep(si);
|
||||
return true;
|
||||
},
|
||||
_showPrevious: function () {
|
||||
var si = this.current_index - 1;
|
||||
// Find the previous not disabled step
|
||||
for (var i = si; i >= 0; i--) {
|
||||
if (!this.steps.eq(i).parent('li').hasClass('disabled') && !this.steps.eq(i).parent('li').hasClass('hidden')) {
|
||||
si = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (0 > si) {
|
||||
if (!this.options.cycleSteps) {
|
||||
return false;
|
||||
}
|
||||
si = this.steps.length - 1;
|
||||
}
|
||||
this._showStep(si);
|
||||
return true;
|
||||
},
|
||||
_showStep: function (idx) {
|
||||
// If step not found, skip
|
||||
if (!this.steps.eq(idx)) {
|
||||
return false;
|
||||
}
|
||||
// If current step is requested again, skip
|
||||
if (idx == this.current_index) {
|
||||
return false;
|
||||
}
|
||||
// If it is a disabled step, skip
|
||||
if (this.steps.eq(idx).parent('li').hasClass('disabled') || this.steps.eq(idx).parent('li').hasClass('hidden')) {
|
||||
return false;
|
||||
}
|
||||
// Load step content
|
||||
this._loadStepContent(idx);
|
||||
return true;
|
||||
},
|
||||
_loadStepContent: function (idx) {
|
||||
var mi = this;
|
||||
// Get current step elements
|
||||
var curTab = this.steps.eq(this.current_index);
|
||||
// Get the direction of step navigation
|
||||
var stepDirection = '';
|
||||
var elm = this.steps.eq(idx);
|
||||
var contentURL = elm.data('content-url') && elm.data('content-url').length > 0 ? elm.data('content-url') : this.options.contentURL;
|
||||
|
||||
if (this.current_index !== null && this.current_index !== idx) {
|
||||
stepDirection = this.current_index < idx ? "forward" : "backward";
|
||||
}
|
||||
|
||||
// Trigger "leaveStep" event
|
||||
if (this.current_index !== null && this._triggerEvent("leaveStep", [curTab, this.current_index, stepDirection]) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (contentURL && contentURL.length > 0 && (!elm.data('has-content') || !this.options.contentCache)) {
|
||||
// Get ajax content and then show step
|
||||
var selPage = elm.length > 0 ? $(elm.attr("href"), this.main) : null;
|
||||
|
||||
var ajaxSettings = $.extend(true, {}, {
|
||||
url: contentURL,
|
||||
type: "POST",
|
||||
data: { step_number: idx },
|
||||
dataType: "text",
|
||||
beforeSend: function () {
|
||||
mi._loader('show');
|
||||
},
|
||||
error: function (jqXHR, status, message) {
|
||||
mi._loader('hide');
|
||||
$.error(message);
|
||||
},
|
||||
success: function (res) {
|
||||
if (res && res.length > 0) {
|
||||
elm.data('has-content', true);
|
||||
selPage.html(res);
|
||||
}
|
||||
mi._loader('hide');
|
||||
mi._transitPage(idx);
|
||||
}
|
||||
}, this.options.ajaxSettings);
|
||||
|
||||
$.ajax(ajaxSettings);
|
||||
} else {
|
||||
// Show step
|
||||
this._transitPage(idx);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
_transitPage: function (idx) {
|
||||
var mi = this;
|
||||
// Get current step elements
|
||||
var curTab = this.steps.eq(this.current_index);
|
||||
var curPage = curTab.length > 0 ? $(curTab.attr("href"), this.main) : null;
|
||||
// Get step to show elements
|
||||
var selTab = this.steps.eq(idx);
|
||||
var selPage = selTab.length > 0 ? $(selTab.attr("href"), this.main) : null;
|
||||
// Get the direction of step navigation
|
||||
var stepDirection = '';
|
||||
if (this.current_index !== null && this.current_index !== idx) {
|
||||
stepDirection = this.current_index < idx ? "forward" : "backward";
|
||||
}
|
||||
|
||||
var stepPosition = 'middle';
|
||||
if (idx === 0) {
|
||||
stepPosition = 'first';
|
||||
} else if (idx === this.steps.length - 1) {
|
||||
stepPosition = 'final';
|
||||
}
|
||||
|
||||
this.options.transitionEffect = this.options.transitionEffect.toLowerCase();
|
||||
this.pages.finish();
|
||||
if (this.options.transitionEffect === 'slide') {
|
||||
// normal slide
|
||||
if (curPage && curPage.length > 0) {
|
||||
curPage.slideUp('fast', this.options.transitionEasing, function () {
|
||||
selPage.slideDown(mi.options.transitionSpeed, mi.options.transitionEasing);
|
||||
});
|
||||
} else {
|
||||
selPage.slideDown(this.options.transitionSpeed, this.options.transitionEasing);
|
||||
}
|
||||
} else if (this.options.transitionEffect === 'fade') {
|
||||
// normal fade
|
||||
if (curPage && curPage.length > 0) {
|
||||
curPage.fadeOut('fast', this.options.transitionEasing, function () {
|
||||
selPage.fadeIn('fast', mi.options.transitionEasing, function () {
|
||||
$(this).show();
|
||||
});
|
||||
});
|
||||
} else {
|
||||
selPage.fadeIn(this.options.transitionSpeed, this.options.transitionEasing, function () {
|
||||
$(this).show();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (curPage && curPage.length > 0) {
|
||||
curPage.hide();
|
||||
}
|
||||
selPage.show();
|
||||
}
|
||||
// Change the url hash to new step
|
||||
this._setURLHash(selTab.attr("href"));
|
||||
// Update controls
|
||||
this._setAnchor(idx);
|
||||
// Set the buttons based on the step
|
||||
this._setButtons(idx);
|
||||
// Fix height with content
|
||||
this._fixHeight(idx);
|
||||
// Update the current index
|
||||
this.current_index = idx;
|
||||
|
||||
// Trigger "showStep" event
|
||||
this._triggerEvent("showStep", [selTab, this.current_index, stepDirection, stepPosition]);
|
||||
return true;
|
||||
},
|
||||
_setAnchor: function (idx) {
|
||||
// Current step anchor > Remove other classes and add done class
|
||||
this.steps.eq(this.current_index).parent('li').removeClass("active");
|
||||
if (this.options.anchorSettings.markDoneStep !== false && this.current_index !== null) {
|
||||
this.steps.eq(this.current_index).parent('li').addClass("done");
|
||||
if (this.options.anchorSettings.removeDoneStepOnNavigateBack !== false) {
|
||||
this.steps.eq(idx).parent('li').nextAll().removeClass("done");
|
||||
}
|
||||
}
|
||||
|
||||
// Next step anchor > Remove other classes and add active class
|
||||
this.steps.eq(idx).parent('li').removeClass("done").addClass("active");
|
||||
return true;
|
||||
},
|
||||
_setButtons: function (idx) {
|
||||
// Previous/Next Button enable/disable based on step
|
||||
if (!this.options.cycleSteps) {
|
||||
if (0 >= idx) {
|
||||
$('.sw-btn-prev', this.main).addClass("disabled");
|
||||
} else {
|
||||
$('.sw-btn-prev', this.main).removeClass("disabled");
|
||||
}
|
||||
if (this.steps.length - 1 <= idx) {
|
||||
$('.sw-btn-next', this.main).addClass("disabled");
|
||||
} else {
|
||||
$('.sw-btn-next', this.main).removeClass("disabled");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
// HELPER FUNCTIONS
|
||||
|
||||
_keyNav: function (e) {
|
||||
var mi = this;
|
||||
// Keyboard navigation
|
||||
switch (e.which) {
|
||||
case 37:
|
||||
// left
|
||||
mi._showPrevious();
|
||||
e.preventDefault();
|
||||
break;
|
||||
case 39:
|
||||
// right
|
||||
mi._showNext();
|
||||
e.preventDefault();
|
||||
break;
|
||||
default:
|
||||
return; // exit this handler for other keys
|
||||
}
|
||||
},
|
||||
_fixHeight: function (idx) {
|
||||
// Auto adjust height of the container
|
||||
if (this.options.autoAdjustHeight) {
|
||||
var selPage = this.steps.eq(idx).length > 0 ? $(this.steps.eq(idx).attr("href"), this.main) : null;
|
||||
this.container.finish().animate({ minHeight: selPage.outerHeight() }, this.options.transitionSpeed, function () {});
|
||||
}
|
||||
return true;
|
||||
},
|
||||
_triggerEvent: function (name, params) {
|
||||
// Trigger an event
|
||||
var e = $.Event(name);
|
||||
this.main.trigger(e, params);
|
||||
if (e.isDefaultPrevented()) {
|
||||
return false;
|
||||
}
|
||||
return e.result;
|
||||
},
|
||||
_setURLHash: function (hash) {
|
||||
if (this.options.showStepURLhash && window.location.hash !== hash) {
|
||||
window.location.hash = hash;
|
||||
}
|
||||
},
|
||||
_loader: function (action) {
|
||||
switch (action) {
|
||||
case 'show':
|
||||
this.main.addClass('sw-loading');
|
||||
break;
|
||||
case 'hide':
|
||||
this.main.removeClass('sw-loading');
|
||||
break;
|
||||
default:
|
||||
this.main.toggleClass('sw-loading');
|
||||
}
|
||||
},
|
||||
|
||||
// PUBLIC FUNCTIONS
|
||||
|
||||
theme: function (v) {
|
||||
if (this.options.theme === v) {
|
||||
return false;
|
||||
}
|
||||
this.main.removeClass('sw-theme-' + this.options.theme);
|
||||
this.options.theme = v;
|
||||
this.main.addClass('sw-theme-' + this.options.theme);
|
||||
// Trigger "themeChanged" event
|
||||
this._triggerEvent("themeChanged", [this.options.theme]);
|
||||
},
|
||||
next: function () {
|
||||
this._showNext();
|
||||
},
|
||||
prev: function () {
|
||||
this._showPrevious();
|
||||
},
|
||||
reset: function () {
|
||||
// Trigger "beginReset" event
|
||||
if (this._triggerEvent("beginReset") === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reset all elements and classes
|
||||
this.container.stop(true);
|
||||
this.pages.stop(true);
|
||||
this.pages.hide();
|
||||
this.current_index = null;
|
||||
this._setURLHash(this.steps.eq(this.options.selected).attr("href"));
|
||||
$(".sw-toolbar", this.main).remove();
|
||||
this.steps.removeClass();
|
||||
this.steps.parents('li').removeClass();
|
||||
this.steps.data('has-content', false);
|
||||
this.init();
|
||||
|
||||
// Trigger "endReset" event
|
||||
this._triggerEvent("endReset");
|
||||
},
|
||||
stepState: function (stepArray, state) {
|
||||
var mi = this;
|
||||
stepArray = $.isArray(stepArray) ? stepArray : [stepArray];
|
||||
var selSteps = $.grep(this.steps, function (n, i) {
|
||||
return $.inArray(i, stepArray) !== -1; // && i !== mi.current_index
|
||||
});
|
||||
if (selSteps && selSteps.length > 0) {
|
||||
switch (state) {
|
||||
case 'disable':
|
||||
$(selSteps).parents('li').addClass('disabled');
|
||||
break;
|
||||
case 'enable':
|
||||
$(selSteps).parents('li').removeClass('disabled');
|
||||
break;
|
||||
case 'hide':
|
||||
$(selSteps).parents('li').addClass('hidden');
|
||||
break;
|
||||
case 'show':
|
||||
$(selSteps).parents('li').removeClass('hidden');
|
||||
break;
|
||||
case 'error-on':
|
||||
$(selSteps).parents('li').addClass('danger');
|
||||
break;
|
||||
case 'error-off':
|
||||
$(selSteps).parents('li').removeClass('danger');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Wrapper for the plugin
|
||||
$.fn.smartWizard = function (options) {
|
||||
var args = arguments;
|
||||
var instance;
|
||||
|
||||
if (options === undefined || typeof options === 'object') {
|
||||
return this.each(function () {
|
||||
if (!$.data(this, "smartWizard")) {
|
||||
$.data(this, "smartWizard", new SmartWizard(this, options));
|
||||
}
|
||||
});
|
||||
} else if (typeof options === 'string' && options[0] !== '_' && options !== 'init') {
|
||||
instance = $.data(this[0], 'smartWizard');
|
||||
|
||||
if (options === 'destroy') {
|
||||
$.data(this, 'smartWizard', null);
|
||||
}
|
||||
|
||||
if (instance instanceof SmartWizard && typeof instance[options] === 'function') {
|
||||
return instance[options].apply(instance, Array.prototype.slice.call(args, 1));
|
||||
} else {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
};
|
||||
})(jQuery, window, document);
|
||||
12
modules/mailchimppro/views/js/jquery.smartWizard.min.js
vendored
Normal file
12
modules/mailchimppro/views/js/jquery.smartWizard.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
25
modules/mailchimppro/views/js/main.js
Normal file
25
modules/mailchimppro/views/js/main.js
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* PrestaChamps
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Commercial License
|
||||
* you can't distribute, modify or sell this code
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file
|
||||
* If you need help please contact leo@prestachamps.com
|
||||
*
|
||||
* @author Mailchimp
|
||||
* @copyright PrestaChamps
|
||||
* @license commercial
|
||||
*/
|
||||
$(document).ready(function () {
|
||||
var x = $('#configuration_form_submit_btn').text();
|
||||
if(x.indexOf('Disconnect') !== -1) {
|
||||
$('#configuration_form').submit(function() {
|
||||
return confirm("This will disable your MailChimp store and break any existing automations, are you sure?");
|
||||
});
|
||||
}
|
||||
});
|
||||
484
modules/mailchimppro/views/js/setup-wizard.js
Normal file
484
modules/mailchimppro/views/js/setup-wizard.js
Normal file
@@ -0,0 +1,484 @@
|
||||
/**
|
||||
* PrestaChamps
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Commercial License
|
||||
* you can't distribute, modify or sell this code
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file
|
||||
* If you need help please contact leo@prestachamps.com
|
||||
*
|
||||
* @author Mailchimp
|
||||
* @copyright PrestaChamps
|
||||
* @license commercial
|
||||
*
|
||||
* @var {Object} toastr
|
||||
*
|
||||
* @var {String} statePending
|
||||
*
|
||||
* @var {String} stateRefundedSelect
|
||||
*
|
||||
* @var {String} stateCancelled
|
||||
*
|
||||
* @var {String} stateShipped
|
||||
*
|
||||
* @var {String} statePaid
|
||||
*
|
||||
* @var {String} itemsPerRequest
|
||||
*
|
||||
* @var {Array} productIds
|
||||
*/
|
||||
|
||||
var receiveMessage = function (event) {
|
||||
if (event.origin !== middlewareUrl) {
|
||||
return false;
|
||||
}
|
||||
if (event.data.hasOwnProperty('token') && event.data.hasOwnProperty('user')) {
|
||||
$("#api-key").val(event.data.token + "-" + event.data.user.dc);
|
||||
$("#logged-in-as-container").removeClass("hidden").find("b").text(event.data.user.login.login_name);
|
||||
$("#oauth2-start").addClass("hidden");
|
||||
toastr.success("Authentication was successful");
|
||||
}
|
||||
};
|
||||
window.addEventListener("message", receiveMessage, true);
|
||||
|
||||
$(document).ready(function () {
|
||||
var wizard = $('#setup-wizard');
|
||||
var apiKeyInput = $('#api-key');
|
||||
var listsInput = $('#list-select');
|
||||
var statePendingSelect = $('#module-mailchimpproconfig-statuses-for-pending');
|
||||
var stateRefundedSelect = $('#module-mailchimpproconfig-statuses-for-refunded');
|
||||
var stateCancelledSelect = $('#module-mailchimpproconfig-statuses-for-cancelled');
|
||||
var stateShippedSelect = $('#module-mailchimpproconfig-statuses-for-shipped');
|
||||
var statePaidSelect = $('#module-mailchimpproconfig-statuses-for-paid');
|
||||
wizard.smartWizard({
|
||||
useURLhash: false,
|
||||
showStepURLhash: false,
|
||||
backButtonSupport: false
|
||||
});
|
||||
|
||||
$('#oauth2-start').click(function (event) {
|
||||
event.preventDefault();
|
||||
var windowObjectReference;
|
||||
var strWindowFeatures = "height=500,width=500,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no, status=yes";
|
||||
windowObjectReference = window.open(
|
||||
middlewareUrl,
|
||||
"McAuthMiddleware",
|
||||
strWindowFeatures
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
wizard.on("leaveStep", function (e, anchorObject, stepNumber, stepDirection) {
|
||||
var success = false;
|
||||
if (stepNumber === 0) {
|
||||
function storeApiKey() {
|
||||
var stuff = false;
|
||||
$.ajax({
|
||||
url: wizardUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'apiKey',
|
||||
apiKey: apiKeyInput.val()
|
||||
},
|
||||
cache: false,
|
||||
async: false
|
||||
}).success(function () {
|
||||
toastr.success("API key saved");
|
||||
stuff = true;
|
||||
}).fail(function (xhr, status, error) {
|
||||
var response = JSON.parse(xhr.responseText);
|
||||
toastr.error(response.error);
|
||||
setTimeout(function () {
|
||||
|
||||
}, 5000);
|
||||
stuff = false;
|
||||
});
|
||||
|
||||
return stuff;
|
||||
}
|
||||
if (apiKeyInput.val().length < 3) {
|
||||
toastr.warning("Please authenticate first");
|
||||
return false;
|
||||
}
|
||||
return storeApiKey();
|
||||
}
|
||||
if (stepNumber === 1) {
|
||||
if (listsInput.val() === null) {
|
||||
toastr.error('Please select a list');
|
||||
success = false;
|
||||
} else {
|
||||
$.ajax({
|
||||
url: wizardUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'listSelect',
|
||||
listId: listsInput.val()
|
||||
},
|
||||
async: false
|
||||
}).success(function () {
|
||||
toastr.success("List ID saved");
|
||||
success = true;
|
||||
}).fail(function (xhr, status, error) {
|
||||
var response = JSON.parse(xhr.responseText);
|
||||
toastr.error(response.error);
|
||||
success = false;
|
||||
});
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
if (stepNumber === 2) {
|
||||
if (!statePendingSelect.val()) {
|
||||
toastr.error("Please select at least one status for pending");
|
||||
|
||||
return false;
|
||||
}
|
||||
if (!stateRefundedSelect.val()) {
|
||||
toastr.error("Please select at least one status for refunded");
|
||||
|
||||
return false;
|
||||
}
|
||||
if (!stateCancelledSelect.val()) {
|
||||
toastr.error("Please select at least one status for cancelled");
|
||||
|
||||
return false;
|
||||
}
|
||||
if (!stateShippedSelect.val()) {
|
||||
toastr.error("Please select at least one status for shipped");
|
||||
|
||||
return false;
|
||||
}
|
||||
if (!statePaidSelect.val()) {
|
||||
toastr.error("Please select at least one status for paid");
|
||||
|
||||
return false;
|
||||
}
|
||||
var statesData = {};
|
||||
statesData[statePending] = $(statePendingSelect).val();
|
||||
statesData[stateRefunded] = $(stateRefundedSelect).val();
|
||||
statesData[stateCancelled] = $(stateCancelledSelect).val();
|
||||
statesData[stateShipped] = $(stateShippedSelect).val();
|
||||
statesData[statePaid] = $(statePaidSelect).val();
|
||||
$.ajax({
|
||||
url: wizardUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'stateMapping',
|
||||
states: statesData
|
||||
},
|
||||
async: false
|
||||
}).success(function () {
|
||||
toastr.success("Order state mapping was saved");
|
||||
setStates();
|
||||
success = true;
|
||||
}).fail(function (xhr, status, error) {
|
||||
var response = JSON.parse(xhr.responseText);
|
||||
toastr.error(response.error);
|
||||
success = false;
|
||||
});
|
||||
|
||||
return success;
|
||||
}
|
||||
});
|
||||
|
||||
wizard.on("showStep", function (e, anchorObject, stepNumber, stepDirection) {
|
||||
if (stepNumber === 1) {
|
||||
loadLists();
|
||||
}
|
||||
if (stepNumber === 2) {
|
||||
loadStateMapping();
|
||||
}
|
||||
if (stepNumber === 3) {
|
||||
syncStores();
|
||||
}
|
||||
if (stepNumber === 4) {
|
||||
syncProducts();
|
||||
}
|
||||
if (stepNumber === 5) {
|
||||
syncCustomers();
|
||||
}
|
||||
if (stepNumber === 6) {
|
||||
syncPromoCodes();
|
||||
}
|
||||
if (stepNumber === 7) {
|
||||
syncOrders();
|
||||
}
|
||||
});
|
||||
|
||||
function setStates() {
|
||||
$.ajax({
|
||||
url: wizardUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'getStates'
|
||||
},
|
||||
}).success(function (response) {
|
||||
success = true;
|
||||
}).fail(function (xhr, status, error) {
|
||||
var response = JSON.parse(xhr.responseText);
|
||||
toastr.error(response.error);
|
||||
success = false;
|
||||
});
|
||||
}
|
||||
|
||||
function loadLists() {
|
||||
$.ajax({
|
||||
url: wizardUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'getLists'
|
||||
},
|
||||
}).success(function (response) {
|
||||
listsInput
|
||||
.find('option')
|
||||
.remove()
|
||||
.end();
|
||||
$.each(response.lists, function (i, item) {
|
||||
listsInput.append(new Option(item.name, item.id, null, (response.selectedList === item.id)));
|
||||
});
|
||||
|
||||
var container = $('.sw-container.tab-content');
|
||||
var spinner = $('#step-2 .spinner');
|
||||
spinner.addClass('hidden');
|
||||
$("#loading-lists-in-progress").addClass('hidden');
|
||||
$("#step-2 #input-container").removeClass('hidden');
|
||||
container.css('min-height', container.height() - spinner.height() - 250);
|
||||
|
||||
success = false;
|
||||
}).fail(function (xhr, status, error) {
|
||||
var response = JSON.parse(xhr.responseText);
|
||||
toastr.error(response.error);
|
||||
success = false;
|
||||
});
|
||||
}
|
||||
|
||||
function syncStores() {
|
||||
$.ajax({
|
||||
url: wizardUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'syncStores'
|
||||
},
|
||||
}).success(function (response) {
|
||||
if (response.result !== undefined) {
|
||||
for (var i = 0; i < response.result.length; i++) {
|
||||
var item = response.result[i];
|
||||
if (item.headers.http_code === 200) {
|
||||
var bodyJson = JSON.parse(item.body);
|
||||
toastr.success("Shop synced: " + bodyJson.name);
|
||||
} else {
|
||||
toastr.error("Oups! Something happened");
|
||||
console.log(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
var container = $('.sw-container.tab-content');
|
||||
var spinner = $('#step-4 .spinner');
|
||||
container.css('min-height', container.height() - spinner.height() - 200);
|
||||
$("#shop-sync-in-progress").addClass('hidden');
|
||||
$("#shop-sync-completed").removeClass('hidden');
|
||||
$("#shop-sync-error").addClass('hidden');
|
||||
spinner.addClass('hidden');
|
||||
success = true;
|
||||
|
||||
}).fail(function (xhr, status, error) {
|
||||
var response = JSON.parse(xhr.responseText);
|
||||
console.log(response);
|
||||
if (response.result !== undefined) {
|
||||
for (var i = 0; i < response.result.length; i++) {
|
||||
console.log(response.result[i]);
|
||||
}
|
||||
}
|
||||
toastr.error(response.error);
|
||||
success = false;
|
||||
});
|
||||
}
|
||||
|
||||
function syncProducts() {
|
||||
$("#step-4 .progress .progress-bar").css("width", "0%");
|
||||
var productBatch = productIds.chunk(itemsPerRequest);
|
||||
for (var i = 0; i < productBatch.length; i++) {
|
||||
let current = i;
|
||||
$.ajaxq("productSync", {
|
||||
url: wizardUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'syncProducts',
|
||||
items: productBatch[i]
|
||||
},
|
||||
}).success(function (response) {
|
||||
$("#step-5 #result").html(JSON.stringify(response, null, 2));
|
||||
var currentSuccess = parseInt(current + 1) * parseInt(itemsPerRequest);
|
||||
currentSuccess = (currentSuccess >= productIds.length) ? productIds.length : currentSuccess;
|
||||
toastr.success(currentSuccess + " / " + productIds.length + " completed");
|
||||
success = true;
|
||||
}).fail(function (xhr, status, error) {
|
||||
console.log(xhr);
|
||||
toastr.error("Error while launching product sync batch");
|
||||
success = false;
|
||||
}).done(function () {
|
||||
$("#step-5 .progress .progress-bar").css("width", (((current + 1) * parseInt(itemsPerRequest) * 100) / productIds.length) + "%");
|
||||
if (!$.ajaxq.isRunning("productSync")) {
|
||||
$("#product-sync-in-progress").hide();
|
||||
$("#product-sync-completed").removeClass('hidden');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function syncPromoCodes() {
|
||||
$("#step-7 .progress .progress-bar").css("width", "0%");
|
||||
var promoCodeBatch = promoCodeIds.chunk(itemsPerRequest);
|
||||
if (promoCodeBatch.length < 1) {
|
||||
$("#promo-code-sync-in-progress").hide();
|
||||
$("#promo-code-sync-completed").removeClass('hidden');
|
||||
}
|
||||
for (var i = 0; i < promoCodeBatch.length; i++) {
|
||||
let current = i;
|
||||
$.ajaxq("promoCodesSync", {
|
||||
url: wizardUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'syncPromoCodes',
|
||||
items: promoCodeBatch[i]
|
||||
},
|
||||
}).success(function (response) {
|
||||
$("#step-7 #result").html(JSON.stringify(response, null, 2));
|
||||
var currentSuccess = parseInt(current + 1) * parseInt(itemsPerRequest);
|
||||
currentSuccess = (currentSuccess >= promoCodeIds.length) ? promoCodeIds.length : currentSuccess;
|
||||
toastr.success(currentSuccess + " / " + promoCodeIds.length + " completed");
|
||||
success = true;
|
||||
}).fail(function (xhr, status, error) {
|
||||
console.log(xhr);
|
||||
toastr.error("Error while launching customer sync batch");
|
||||
success = false;
|
||||
}).done(function () {
|
||||
$("#step-7 .progress .progress-bar").css("width", (((current + 1) * parseInt(itemsPerRequest) * 100) / promoCodeIds.length) + "%");
|
||||
if (!$.ajaxq.isRunning("promoCodesSync")) {
|
||||
$("#promo-code-sync-in-progress").hide();
|
||||
$("#promo-code-sync-completed").removeClass('hidden');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function syncCustomers() {
|
||||
$("#step-6 .progress .progress-bar").css("width", "0%");
|
||||
var customerBatch = customerIds.chunk(itemsPerRequest);
|
||||
for (var i = 0; i < customerBatch.length; i++) {
|
||||
let current = i;
|
||||
$.ajaxq("customerSync", {
|
||||
url: wizardUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'syncCustomers',
|
||||
items: customerBatch[i]
|
||||
},
|
||||
}).success(function (response) {
|
||||
$("#step-6 #result").html(JSON.stringify(response, null, 2));
|
||||
var currentSuccess = parseInt(current + 1) * parseInt(itemsPerRequest);
|
||||
currentSuccess = (currentSuccess >= customerIds.length) ? customerIds.length : currentSuccess;
|
||||
toastr.success(currentSuccess + " / " + customerIds.length + " completed");
|
||||
success = true;
|
||||
}).fail(function (xhr, status, error) {
|
||||
console.log(xhr);
|
||||
toastr.error("Error while launching customer sync batch");
|
||||
success = false;
|
||||
}).done(function () {
|
||||
$("#step-6 .progress .progress-bar").css("width", (((current + 1) * parseInt(itemsPerRequest) * 100) / customerIds.length) + "%");
|
||||
if (!$.ajaxq.isRunning("customerSync")) {
|
||||
$("#customer-sync-in-progress").hide();
|
||||
$("#customer-sync-completed").removeClass('hidden');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function syncOrders() {
|
||||
$("#step-8 .progress .progress-bar").css("width", "0%");
|
||||
var ordersBatch = orderIds.chunk(itemsPerRequest);
|
||||
if (ordersBatch.length < 1) {
|
||||
$("#order-sync-in-progress").hide();
|
||||
$("#order-sync-completed").removeClass('hidden');
|
||||
}
|
||||
for (var i = 0; i < ordersBatch.length; i++) {
|
||||
let current = i;
|
||||
$.ajaxq("orderSync", {
|
||||
url: wizardUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'syncOrders',
|
||||
items: ordersBatch[i]
|
||||
},
|
||||
}).success(function (response) {
|
||||
$("#step-8 #result").html(JSON.stringify(response, null, 2));
|
||||
var currentSuccess = parseInt(current + 1) * parseInt(itemsPerRequest);
|
||||
currentSuccess = (currentSuccess >= orderIds.length) ? orderIds.length : currentSuccess;
|
||||
toastr.success(currentSuccess + " / " + orderIds.length + " completed");
|
||||
success = true;
|
||||
}).fail(function (xhr, status, error) {
|
||||
console.log(xhr);
|
||||
toastr.error("Error while launching order sync batch");
|
||||
success = false;
|
||||
}).done(function () {
|
||||
$("#step-8 .progress .progress-bar").css("width", (((current + 1) * parseInt(itemsPerRequest) * 100) / orderIds.length) + "%");
|
||||
if (!$.ajaxq.isRunning("orderSync")) {
|
||||
$("#order-sync-in-progress").hide();
|
||||
$("#order-sync-completed").removeClass('hidden');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function loadStateMapping() {
|
||||
$.ajax({
|
||||
url: wizardUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'getStates'
|
||||
},
|
||||
}).success(function (response) {
|
||||
var pending = JSON.parse(response.mapping[statePending]);
|
||||
var refunded = JSON.parse(response.mapping[stateRefunded]);
|
||||
var cancelled = JSON.parse(response.mapping[stateCancelled]);
|
||||
var shipped = JSON.parse(response.mapping[stateShipped]);
|
||||
var paid = JSON.parse(response.mapping[statePaid]);
|
||||
if (!pending) {pending = [];}
|
||||
if (!refunded) {refunded = [];}
|
||||
if (!cancelled) {cancelled = [];}
|
||||
if (!shipped) {shipped = [];}
|
||||
if (!paid) {paid = [];}
|
||||
$.each(response.states, function (i, item) {
|
||||
statePendingSelect.append(new Option(item.name, item.id_order_state, null, pending.includes(item.id_order_state)));
|
||||
stateRefundedSelect.append(new Option(item.name, item.id_order_state, null, refunded.includes(item.id_order_state)));
|
||||
stateCancelledSelect.append(new Option(item.name, item.id_order_state, null, cancelled.includes(item.id_order_state)));
|
||||
stateShippedSelect.append(new Option(item.name, item.id_order_state, null, shipped.includes(item.id_order_state)));
|
||||
statePaidSelect.append(new Option(item.name, item.id_order_state, null, paid.includes(item.id_order_state)));
|
||||
});
|
||||
|
||||
statePendingSelect.attr('size', response.states.length);
|
||||
stateRefundedSelect.attr('size', response.states.length);
|
||||
stateCancelledSelect.attr('size', response.states.length);
|
||||
stateShippedSelect.attr('size', response.states.length);
|
||||
statePaidSelect.attr('size', response.states.length);
|
||||
|
||||
var container = $('.sw-container.tab-content');
|
||||
var spinner = $('#step-3 .spinner');
|
||||
spinner.addClass('hidden');
|
||||
$("#loading-states-in-progress").addClass('hidden');
|
||||
$("#step-3 #status-inputs-container").removeClass('hidden');
|
||||
container.css('min-height', container.height() - spinner.height() - 250);
|
||||
|
||||
success = true;
|
||||
}).fail(function (xhr, status, error) {
|
||||
var response = JSON.parse(xhr.responseText);
|
||||
toastr.error(response.error);
|
||||
success = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
34
modules/mailchimppro/views/js/sync/index.php
Normal file
34
modules/mailchimppro/views/js/sync/index.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2018 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2018 PrestaShop SA
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
|
||||
|
||||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||||
header('Pragma: no-cache');
|
||||
|
||||
header('Location: ../');
|
||||
exit;
|
||||
47
modules/mailchimppro/views/js/sync/product.js
Normal file
47
modules/mailchimppro/views/js/sync/product.js
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* PrestaChamps
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Commercial License
|
||||
* you can't distribute, modify or sell this code
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file
|
||||
* If you need help please contact leo@prestachamps.com
|
||||
*
|
||||
* @author Mailchimp
|
||||
* @copyright PrestaChamps
|
||||
* @license commercial
|
||||
*/
|
||||
$(document).ready(function () {
|
||||
$("#product-sync .submit").click(function () {
|
||||
$("#product-sync").addClass("sync-is-running");
|
||||
$("#product-sync .progress").removeClass("hidden");
|
||||
$("#product-sync .progress .progress-bar").css("width", "0%");
|
||||
var productBatch = productIds.chunk(itemsPerRequest);
|
||||
for (var i = 0; i < productBatch.length; i++) {
|
||||
let current = i;
|
||||
$.ajaxq("productSync", {
|
||||
url: syncUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'productSync',
|
||||
method: $('#product-sync input[name=method]:checked').val(),
|
||||
syncMode: $('#product-sync input[name=syncMode]:checked').val(),
|
||||
items: productBatch[i]
|
||||
},
|
||||
}).success(function (response) {
|
||||
$("#product-sync #result").html(JSON.stringify(response, null, 2));
|
||||
toastr.success(parseInt(current + 1) * parseInt(itemsPerRequest) + " / " + productIds.length + " completed");
|
||||
}).fail(function (xhr, status, error) {
|
||||
console.log(xhr);
|
||||
toastr.error("Error while launching product sync batch");
|
||||
}).done(function () {
|
||||
$("#product-sync .progress .progress-bar").css("width", (((current + 1) * parseInt(itemsPerRequest) * 100) / productIds.length) + "%");
|
||||
});
|
||||
}
|
||||
$("#product-sync").removeClass("sync-is-running");
|
||||
});
|
||||
});
|
||||
19
modules/mailchimppro/views/js/toastr.min.js
vendored
Normal file
19
modules/mailchimppro/views/js/toastr.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user