first commit
This commit is contained in:
@@ -0,0 +1,173 @@
|
||||
(function($) {
|
||||
$.fn.pkPopupFav = function(options) {
|
||||
|
||||
var defaults = {action: 'show', state: 'success', text: 'Success'},
|
||||
options = $.extend(defaults, options),
|
||||
mainclass = 'pk-infomessage',
|
||||
itemclass = 'pk-infomessage-item',
|
||||
closeclass = 'pk-close-popup',
|
||||
timerclass = 'pk-close-timer',
|
||||
closebutton = '<a href="#" class="'+closeclass+'"><svg class="svgic"><use xlink:href="#si-cross"></use></svg></a>',
|
||||
timetoclose = 5000,
|
||||
$parent = $('body'),
|
||||
$th = $(this);
|
||||
|
||||
$parent.on('click', '.'+closeclass, function() {
|
||||
hidePopup($(this));
|
||||
return false;
|
||||
});
|
||||
|
||||
if ($('.'+mainclass).length == 0 ) {
|
||||
$parent.append('<div class="'+mainclass+'"></div>');
|
||||
}
|
||||
|
||||
if (options.action == 'show') {
|
||||
showPopup($th);
|
||||
}
|
||||
|
||||
if (options.action == 'hide') {
|
||||
hidePopup($th);
|
||||
}
|
||||
|
||||
function showPopup($el) {
|
||||
var classes = itemclass+' relative state-'+options.state;
|
||||
$('.'+mainclass).append('<div class="'+classes+'"><div>'+options.text+'</div>'+closebutton+'<div class="'+timerclass+'"></div></div>');
|
||||
$('.'+timerclass).animate({
|
||||
width: "0"
|
||||
}, timetoclose, 'linear', function() {
|
||||
hidePopup($(this));
|
||||
});
|
||||
}
|
||||
|
||||
function hidePopup($el) {
|
||||
$el.parent().animate({
|
||||
height: "0"
|
||||
}, 300, function() {
|
||||
$(this).remove();
|
||||
});
|
||||
}
|
||||
};
|
||||
})(jQuery);
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
var fButton = 'favoritesButton',
|
||||
removeButton = 'remove-fav';
|
||||
|
||||
$('body').on('click', '.'+fButton, function(){
|
||||
|
||||
if ($(this).hasClass('addToFav')) {
|
||||
addToFavorites($(this), false);
|
||||
}
|
||||
|
||||
if ($(this).hasClass('removeFromFav')) {
|
||||
removeFromFavorites($(this), false);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
});
|
||||
|
||||
$('body').on('click', '.'+removeButton, function(){
|
||||
|
||||
removeFromFavorites($(this), true);
|
||||
return false;
|
||||
|
||||
});
|
||||
|
||||
// add remove button to favorites page
|
||||
if ( $('#favoriteproducts_block_account')[0] ) {
|
||||
$('#favoriteproducts_block_account .product-miniature').each(function (index, value) {
|
||||
$(this).append('<div class="'+removeButton+' btn"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg></div>');
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
function ToggleButtonState(button) {
|
||||
|
||||
button.toggleClass('removeFromFav').toggleClass('addToFav').toggleClass('icon_checked');
|
||||
|
||||
}
|
||||
|
||||
function hideProduct(item) {
|
||||
|
||||
item.closest('.product-miniature').slideUp();
|
||||
|
||||
}
|
||||
|
||||
function addToFavorites($th, icon_button) {
|
||||
|
||||
$.ajax({
|
||||
url: favorites.favorite_products_url_add + '&rand=' + new Date().getTime(),
|
||||
type: "POST",
|
||||
headers: { "cache-control": "no-cache" },
|
||||
data: {
|
||||
"id_product": $th.data('pid')
|
||||
},
|
||||
success: function(result){
|
||||
ToggleButtonState($th);
|
||||
$('body').pkPopupFav({state:"success", text: favorites.phrases.added});
|
||||
$th.find('span').text(favorites.phrases.remove);
|
||||
},
|
||||
error: function(){},
|
||||
beforeSend: function(){
|
||||
beforeSendCallback(icon_button, $th);
|
||||
},
|
||||
complete: function(){
|
||||
completeCallback(icon_button, $th);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function removeFromFavorites($th, icon_button) {
|
||||
|
||||
if (icon_button) {
|
||||
pid = $th.parent().data('id-product');
|
||||
} else {
|
||||
pid = $th.data('pid')
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: favorites.favorite_products_url_remove + '&rand=' + new Date().getTime(),
|
||||
type: "POST",
|
||||
headers: { "cache-control": "no-cache" },
|
||||
data: {
|
||||
"id_product": pid
|
||||
},
|
||||
success: function(result){
|
||||
if (icon_button) {
|
||||
hideProduct($th);
|
||||
} else {
|
||||
ToggleButtonState($th);
|
||||
}
|
||||
$('body').pkPopupFav({state:"info", text: favorites.phrases.removed});
|
||||
$th.find('span').text(favorites.phrases.add);
|
||||
},
|
||||
error: function(){},
|
||||
beforeSend: function(){
|
||||
beforeSendCallback(icon_button, $th);
|
||||
},
|
||||
complete: function(){
|
||||
completeCallback(icon_button, $th);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function completeCallback(icon_button, $th) {
|
||||
if (icon_button) {
|
||||
$th.removeClass('in_progress');
|
||||
} else {
|
||||
$th.find('svg').removeClass('in_progress');
|
||||
}
|
||||
}
|
||||
|
||||
function beforeSendCallback(icon_button, $th) {
|
||||
if (icon_button) {
|
||||
$th.addClass('in_progress');
|
||||
} else {
|
||||
$th.find('svg').addClass('in_progress');
|
||||
}
|
||||
}
|
||||
35
themes/ayon/modules/pk_favorites/views/assets/js/index.php
Normal file
35
themes/ayon/modules/pk_favorites/views/assets/js/index.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2014 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-2014 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;
|
||||
Reference in New Issue
Block a user