Spade
Mini Shell
index.html000064400000000054151171034350006540 0ustar00<html><body
bgcolor="#FFFFFF"></body></html>jquery.phocaattribute.js000064400000036421151171034350011444
0ustar00/*
* jQuery Phoca Attribute
* https://www.phoca.cz
*
* Copyright (C) 2016 Jan Pavelka www.phoca.cz
*
* Licensed under the MIT license
*/
/* SELECT BOXES */
/* Changes Selects to color or image attributes*/
function phChangeAttributeType(typeView) {
typeView = typeof typeView !== 'undefined' ? '.phj' +
typeView : '';
var phProductAttribute = typeView + '.phjProductAttribute';//
Find all select boxes which should be transformed to color or image
var phCleanAttribute = typeView + '.phjCleanAttribute';// Clean
previously transformed select boxes in case of ajax reload
jQuery(phCleanAttribute).remove();
jQuery(phProductAttribute).each(function() {
var phClass = '';
var phClassId = '';
var phSelectNameId = '#phItemAttribute' +
jQuery(this).data('attribute-id-name');
var phSelectNameIdT = '#phItemHiddenAttribute' +
jQuery(this).data('attribute-id-name');
var phSelectNameIdB = '#phItemBoxAttribute' +
jQuery(this).data('attribute-id-name');
var phType = jQuery(this).data('attribute-type');// Type of
attribute
var phTypeView = jQuery(this).data('type-view');// Type of
view, e.g. ItemQuickView is reloaded by ajax
var phTypeIcon = jQuery(this).data('type-icon');// Type of
used icon library
var phRequired = jQuery(this).data('required');// Type of
used icon library
if (phType == 3) {
phClass = 'phSelectBoxImage';// Image
} else if (phType == 2) {
phClass = 'phSelectBoxButton';// Color
}
// Transform only attributes which are select box image - 3 or select box
color - 2
if (phClass != '') {
phClassId = phSelectNameIdT + ' .' + phClass;
var phSelectName = jQuery(phSelectNameId).attr('name');
var phHiddenEl = jQuery('<input type="hidden"
name="'+ phSelectName +'">');
phHiddenEl.val(jQuery(phSelectNameId).val());
phHiddenEl.insertAfter(jQuery(phSelectNameId));
// ON START DISPLAY OR HIDE
// jQuery(phSelectNameId).hide();
// jQuery(phSelectNameIdB).hide();
// Cannot be hidden because of html5 required field and its message
// Hide select box even its chosen alternative
jQuery(phSelectNameIdT).css( "display", "block");
jQuery(phSelectNameIdB).css( {"display": "visible",
'position': 'absolute', 'clip':
'rect(0,0,0,0)' });
jQuery(phSelectNameIdB).addClass('phj' + phTypeView + '
phjCleanAttribute');
// ON START TRANSFORM
jQuery(phSelectNameId + ' option').each(function() {
/* Do not display default value (empty value), can be set by clicking
back from other value */
if (jQuery(this).val() != '') {
if (phType == 3) {
// Image
var phSBtn = jQuery('<div class="'+ phClass +'
'+ phTypeIcon +'" data-value="'+
jQuery(this).val() +'" data-value-alias="'+
jQuery(this).data('value-alias') +'"
title="'+ jQuery(this).text() +'"><img
src="'+ jQuery(this).data('image') +'"
alt="'+ jQuery(this).text() +'"
/></div>');
} else if (phType == 2) {
// Color
var phSBtn = jQuery('<div class="'+ phClass +'
'+ phTypeIcon +'" style="background-color:' +
jQuery(this).data('color') +'" data-value="'+
jQuery(this).val() +'" data-value-alias="'+
jQuery(this).data('value-alias') +'"
title="'+ jQuery(this).text() +'">'+
' ' +'</div>');
}
if(jQuery(this).is(':selected')) {
phSBtn.addClass('on');
}
jQuery(phSelectNameIdT).append(phSBtn);
}
});
// Change on Click event
jQuery(phClassId).on('click', function(e) {
e.preventDefault();// Bootstrap modal (close and open again duplicates
events)
var isActive = jQuery(this).hasClass('on');
if (isActive) {
if (phRequired == 1) {
e.preventDefault();// Active item cannot be unselected when the
select box is required
return false;
}
jQuery(this).removeClass('on');
jQuery('input[name="'+ phSelectName
+'"]').val('');
jQuery(phSelectNameId).val('').change();// Because of
required field
} else {
jQuery(phClassId).removeClass('on');//Remove when multiple
jQuery(this).addClass('on');
jQuery('input[name="'+ phSelectName
+'"]').val(jQuery(this).data('value'));
jQuery(phSelectNameId).val(jQuery(this).data('value')).change();//
Because of required field
}
})
}
})
}
function phAjaxChangeAttributeData(phProductId, phTypeView, phDataA1,
phDataA2){
var phParams = Joomla.getOptions('phParamsPC');
var phVars = Joomla.getOptions('phVarsPC');
var phUrl = phVars['urlCheckoutChangeData'];
var phOptions = [];
phOptions["id"] = phProductId;
phOptions["id_item_price"] = "#phItemPriceBox" +
phTypeView + phProductId;
phOptions["id_item_price_gift"] =
"#phItemPriceGiftBox" + phTypeView + phProductId;
phOptions["id_item_stock"] = "#phItemStockBox" +
phTypeView + phProductId;
phOptions["id_item_id"] = "#phItemIdBox" + phTypeView
+ phProductId;
phOptions["id_item_name"] = "V" + phTypeView +
'P' + phProductId;
phOptions["product_add_to_cart_item"] =
".phProductAddToCart" + phTypeView + phProductId;// display or
hide add to cart button
phOptions["product_add_to_cart_item_icon"] =
".phProductAddToCartIcon" + phTypeView + phProductId;// display
or hide add to cart icon
phOptions["view"] = phTypeView;
phOptions["method_price"] =
phParams['dynamicChangePrice'];
phOptions["method_stock"] =
phParams['dynamicChangeStock'];
phOptions["method_id"] = phParams['dynamicChangeId'];
phOptions["method_image"] =
phParams['dynamicChangeImage'];
phOptions["task"] = "change";
phOptions["type"] = "changedata";
if (phTypeView == 'ItemQuick' || phTypeView == 'Pos'
|| phTypeView == 'Item') {
phOptions["class"] ='ph-item-data-box';
} else {
phOptions["class"] ='ph-category-data-box';//
Category, Items
}
var phData = 'id='+ phOptions["id"]
+'&'+ phDataA1 +'&'+ phDataA2
+'&'+'class='+ phOptions["class"]
+'&'+'typeview='+ phOptions["view"];
phDoRequestMethods(phUrl, phData, phOptions);
}
function phSetAttributeUrl(phSetValueByUser) {
var phParams = Joomla.getOptions('phParamsPC');
var phVars = Joomla.getOptions('phVarsPC');
if (phParams['dynamicChangeUrlAttributes'] != 1) {
return false;
}
if(phVars['view'] != 'item') {
return false;
}
var phHash = jQuery(location).attr('hash');
phHash = phReplaceAll('#', '', phHash)
var phHashParams = jQuery.deparam(phHash);
var phProductAttribute = '.phjProductAttribute';
var phHashNew = '';
var phTypeView = '';
var phProductId = '';
// Change base64 return url - add attribute suffix to the URL so when
products will be added to cart without running ajax
// then it will be redirected back to the site with selected attribute
var attributeForm =
jQuery(phProductAttribute).closest("form");
var attributeFormReturn =
attributeForm.find("input[name=return]");
var attributeFormReturnValue = Base64.decode(attributeFormReturn.val());
// Find all attributes in Item View
jQuery(phProductAttribute).each(function() {
if (phHashNew != '') {
phHashNew = phHashNew + '&';
}
var attributeId = this.id;
var attributeAlias = jQuery(this).data('alias');
var valueAlias = '';// One value for selectbox
var valuesAlias = '';// One or more values for checkbox
var phSelectNameIdT = '#phItemHiddenAttribute' +
jQuery(this).data('attribute-id-name');
if (phSetValueByUser == 1) {
// 1) Set by user
// SELECTBOX
if
(jQuery(this).find(':selected').data('value-alias') !==
undefined) {
valueAlias =
jQuery(this).find(':selected').data('value-alias');
phHashNew = phHashNew + 'a[' +
jQuery(this).data('alias') + ']=' + valueAlias;
}
// CHECKBOX
if
(jQuery(this).find(':input:checked').data('value-alias')
!== undefined) {
jQuery.each(jQuery(this).find(':input:checked'), function(){
if (valuesAlias != '') {
valuesAlias = valuesAlias + ',';
}
valuesAlias = valuesAlias +
jQuery(this).data('value-alias');
});
if (valuesAlias != '') {
phHashNew = phHashNew + 'a[' +
jQuery(this).data('alias') + ']=' + valuesAlias;
}
}
} else {
// 2) Set on document load
if (phHashParams.a !== undefined && attributeAlias !== undefined
&& phHashParams.a[attributeAlias] !== undefined) {
// 2a) Set by the URL parameters - e.g. direct link - attributes will
be set on the site by the URL
phHashNew = phHashNew + 'a[' +
jQuery(this).data('alias') + ']=' +
phHashParams.a[attributeAlias];
var arrayValues = phHashParams.a[attributeAlias].split(",");
if (arrayValues !== undefined || arrayValues.length != 0) {
// clea all selected values first
jQuery("#" + attributeId + "
option").removeAttr("selected");// Select box
jQuery(phSelectNameIdT + "
div").removeClass('on'); // Select Color or Image
jQuery("#" + attributeId + "
input").removeAttr("checked");// Check box
jQuery(arrayValues).each(function() {
jQuery("#" + attributeId + "
option[data-value-alias='" + this +
"']").attr("selected","selected");//
Select box
jQuery(phSelectNameIdT + " div[data-value-alias='" +
this + "']").addClass('on'); // Select Color or
Image
jQuery("#" + attributeId + "
input[data-value-alias='" + this +
"']").attr("checked","checked");// Check
box
})
}
} else {
// 2b) Attribute not found in URL so change the URL be values set as
default (default value for attribute)
// SELECT BOX
if
(jQuery(this).find(':selected').data('value-alias') !==
undefined) {
valueAlias =
jQuery(this).find(':selected').data('value-alias');
phHashNew = phHashNew + 'a[' +
jQuery(this).data('alias') + ']=' + valueAlias;
}
// CHECKBOX
if
(jQuery(this).find(':input:checked').data('value-alias')
!== undefined) {
jQuery.each(jQuery(this).find(':input:checked'), function(){
if (valuesAlias != '') {
valuesAlias = valuesAlias + ',';
}
valuesAlias = valuesAlias +
jQuery(this).data('value-alias');
});
if (valuesAlias != '') {
phHashNew = phHashNew + 'a[' +
jQuery(this).data('alias') + ']=' + valuesAlias;
}
}
}
// Accessible in each parameter - will be used for ajax if set in
parameters
phTypeView = jQuery(this).data('type-view');
phProductId = jQuery(this).data('product-id');
}
})
// URL parameter (hash) can change the setting of attributes, if changed
then ajax which changes stock, price and ID (EAN, SKU), image needs to be
run
if (phParams['dynamicChangePrice'] == 0 &&
phParams['dynamicChangeStock'] == 0 &&
phParams['dynamicChangeId'] == 0 &&
(phParams['dynamicChangeImage'] == 0 ||
phParams['dynamicChangeImage'] == 1)) {
//Interactive change is disabled
} else {
var phProductGroup = '.phjAddToCartV' + phTypeView +
'P' + phProductId;
var phDataA1 =
jQuery(phProductGroup).find('select').serialize();// All Selects
var phDataA2 =
jQuery(phProductGroup).find(':checkbox').serialize();// All
Checkboxes
phAjaxChangeAttributeData(phProductId, phTypeView, phDataA1, phDataA2);
}
// Last character &
if (phHashNew.lastIndexOf('&') == (phHashNew.length - 1)) {
phHashNew = phHashNew.slice(0, -1);
}
// Update URL after #
if (phSetValueByUser == 0 && phHashNew != '') {
phHashNew = '#' + phHashNew;
// Update even form return value to be returned back with selected
attribute
if(attributeFormReturnValue != '') {
attributeFormReturn.val(Base64.encode(attributeFormReturnValue +
phHashNew));
}
window.history.pushState({},"", phHashNew);
} else if (phSetValueByUser == 1) {
phHashNew = '#' + phHashNew;
// Update even form return value to be returned back with selected
attribute
if(attributeFormReturnValue != '') {
attributeFormReturn.val(Base64.encode(attributeFormReturnValue +
phHashNew));
}
window.history.pushState({},"", phHashNew);
}
}
jQuery(document).ready(function() {
phChangeAttributeType();// Change select to color or image, change
checkbox to color or image
phSetAttributeUrl(0);// Change URL (# attributes) or change attributes by
URL at start
/* Interactive change - price, stock, ID (EAN, SKU, ...) */
var phSelectboxA = "select.phjProductAttribute";
var phSelectboxASelected = phSelectboxA + ":selected";
// Select box
jQuery(document).on('change', phSelectboxA, function(e){
var phParams = Joomla.getOptions('phParamsPC');
if (phParams['dynamicChangePrice'] == 0 &&
phParams['dynamicChangeStock'] == 0 &&
phParams['dynamicChangeId'] == 0 &&
(phParams['dynamicChangeImage'] == 0 ||
phParams['dynamicChangeImage'] == 1)) {
return false;// Interactive Change is disabled
}
//jQuery(this).off("change");';
var phTypeView = jQuery(this).data('type-view');
var phProductId = jQuery(this).data('product-id');
var phProductGroup = '.phjAddToCartV' + phTypeView +
'P' + phProductId;
var phDataA1 =
jQuery(phProductGroup).find('select').serialize();// All Selects
var phDataA2 =
jQuery(phProductGroup).find(':checkbox').serialize();// All
Checkboxes
phAjaxChangeAttributeData(phProductId, phTypeView, phDataA1, phDataA2);
phSetAttributeUrl(1);
})
var phCheckboxA =
".ph-checkbox-attribute.phjProductAttribute";
// var phCheckboxAInputChecked = phCheckboxA + "
input:checked";
// Checkbox
jQuery(document).on('click', phCheckboxA, function(e){
var phParams = Joomla.getOptions('phParamsPC');
if (phParams['dynamicChangePrice'] == 0 &&
phParams['dynamicChangeStock'] == 0 &&
phParams['dynamicChangeId'] == 0 &&
(phParams['dynamicChangeImage'] == 0 ||
phParams['dynamicChangeImage'] == 1)) {
return;// Interactive Change is disabled
}
if (e.target.tagName.toUpperCase() === "LABEL") { return;}//
Prevent from twice running
if (phParams['theme'] == 'bs4') {
if (e.target.tagName.toUpperCase() === "SPAN" ||
e.target.tagName.toUpperCase() === "IMG") { return;}// Prevent
from twice running
}
var phProductId = jQuery(this).data('product-id');
var phTypeView = jQuery(this).data('type-view');
var phProductGroup = '.phjAddToCartV' + phTypeView +
'P' + phProductId;
var phDataA1 =
jQuery(phProductGroup).find('select').serialize();// All Selects
var phDataA2 =
jQuery(phProductGroup).find(':checkbox').serialize();// All
Checkboxes
// If REQUIRED, don't allow to untick all checkboxes
var phRequired = jQuery(this).data("required");
var phCheckboxAInputChecked = "#" +
jQuery(this).attr("id") + " input:checked";
var phACheckedLength = jQuery(phCheckboxAInputChecked).length;
if (phACheckedLength == 0) {
var phThisLabel = jQuery(e.target).parent();// Bootstrap
checkboxes - colors, images
phThisLabel.addClass("active");// Bootstrap
checkboxes - colors, images
e.preventDefault();
return false;
}
phAjaxChangeAttributeData(phProductId, phTypeView, phDataA1, phDataA2);
phSetAttributeUrl(1);
})
// Gift coupon
jQuery('.phAOGift').on('input', function() {
var phAOType = '.' + jQuery(this).data('type');
if (phAOType == '.phAOGiftType') {
var title = jQuery(this).data('title');
jQuery('.phAOGiftTitle').text(title);
var image = jQuery(this).data('image');
jQuery('.phAOGiftImage').attr('src', image);
var date = jQuery(this).data('date');
jQuery('.phAOGiftDate').text(date);
var description = jQuery(this).data('description');
description = Base64.decode(description);
jQuery('.phAOGiftDescription').html(description);
var className = jQuery(this).data('class-name');
jQuery(phAOType).attr('class', 'phAOGiftType
ph-gift-voucher-box ' + className);
} else {
jQuery(phAOType).text(jQuery(this).val());
}
});
})
jquery.phocaattribute.min.js000064400000015345151171034350012230
0ustar00function phChangeAttributeType(e){var t=(e=void
0!==e?".phj"+e:"")+".phjProductAttribute";jQuery(e+".phjCleanAttribute").remove(),jQuery(t).each(function(){var
t,a,e,i="",r="#phItemAttribute"+jQuery(this).data("attribute-id-name"),u="#phItemHiddenAttribute"+jQuery(this).data("attribute-id-name"),d="#phItemBoxAttribute"+jQuery(this).data("attribute-id-name"),s=jQuery(this).data("attribute-type"),h=jQuery(this).data("type-view"),n=jQuery(this).data("type-icon"),c=jQuery(this).data("required");3==s?i="phSelectBoxImage":2==s&&(i="phSelectBoxButton"),""!=i&&(t=u+"
."+i,a=jQuery(r).attr("name"),(e=jQuery('<input
type="hidden"
name="'+a+'">')).val(jQuery(r).val()),e.insertAfter(jQuery(r)),jQuery(u).css("display","block"),jQuery(d).css({display:"visible",position:"absolute",clip:"rect(0,0,0,0)"}),jQuery(d).addClass("phj"+h+"
phjCleanAttribute"),jQuery(r+" option").each(function(){var
e;""!=jQuery(this).val()&&(3==s?e=jQuery('<div
class="'+i+" "+n+'"
data-value="'+jQuery(this).val()+'"
data-value-alias="'+jQuery(this).data("value-alias")+'"
title="'+jQuery(this).text()+'"><img
src="'+jQuery(this).data("image")+'"
alt="'+jQuery(this).text()+'"
/></div>'):2==s&&(e=jQuery('<div
class="'+i+" "+n+'"
style="background-color:'+jQuery(this).data("color")+'"
data-value="'+jQuery(this).val()+'"
data-value-alias="'+jQuery(this).data("value-alias")+'"
title="'+jQuery(this).text()+'"> </div>')),jQuery(this).is(":selected")&&e.addClass("on"),jQuery(u).append(e))}),jQuery(t).on("click",function(e){if(e.preventDefault(),jQuery(this).hasClass("on")){if(1==c)return
e.preventDefault(),!1;jQuery(this).removeClass("on"),jQuery('input[name="'+a+'"]').val(""),jQuery(r).val("").change()}else
jQuery(t).removeClass("on"),jQuery(this).addClass("on"),jQuery('input[name="'+a+'"]').val(jQuery(this).data("value")),jQuery(r).val(jQuery(this).data("value")).change()}))})}function
phAjaxChangeAttributeData(e,t,a,i){var
r=Joomla.getOptions("phParamsPC"),u=Joomla.getOptions("phVarsPC").urlCheckoutChangeData,d=[];d.id=e,d.id_item_price="#phItemPriceBox"+t+e,d.id_item_price_gift="#phItemPriceGiftBox"+t+e,d.id_item_stock="#phItemStockBox"+t+e,d.id_item_id="#phItemIdBox"+t+e,d.id_item_name="V"+t+"P"+e,d.product_add_to_cart_item=".phProductAddToCart"+t+e,d.product_add_to_cart_item_icon=".phProductAddToCartIcon"+t+e,d.view=t,d.method_price=r.dynamicChangePrice,d.method_stock=r.dynamicChangeStock,d.method_id=r.dynamicChangeId,d.method_image=r.dynamicChangeImage,d.task="change",d.type="changedata",d.class="ItemQuick"==t||"Pos"==t||"Item"==t?"ph-item-data-box":"ph-category-data-box";i="id="+d.id+"&"+a+"&"+i+"&class="+d.class+"&typeview="+d.view;phDoRequestMethods(u,i,d)}function
phSetAttributeUrl(u){var
e=Joomla.getOptions("phParamsPC"),t=Joomla.getOptions("phVarsPC");if(1!=e.dynamicChangeUrlAttributes)return!1;if("item"!=t.view)return!1;var
a=jQuery(location).attr("hash"),a=phReplaceAll("#","",a),d=jQuery.deparam(a),i=".phjProductAttribute",s="",h="",n="",t=jQuery(i).closest("form").find("input[name=return]"),a=Base64.decode(t.val());jQuery(i).each(function(){""!=s&&(s+="&");var
e=this.id,t=jQuery(this).data("alias"),a="",i="",r="#phItemHiddenAttribute"+jQuery(this).data("attribute-id-name");1==u?(void
0!==jQuery(this).find(":selected").data("value-alias")&&(a=jQuery(this).find(":selected").data("value-alias"),s=s+"a["+jQuery(this).data("alias")+"]="+a),void
0!==jQuery(this).find(":input:checked").data("value-alias")&&(jQuery.each(jQuery(this).find(":input:checked"),function(){""!=i&&(i+=","),i+=jQuery(this).data("value-alias")}),""!=i&&(s=s+"a["+jQuery(this).data("alias")+"]="+i))):(void
0!==d.a&&void 0!==t&&void
0!==d.a[t]?(s=s+"a["+jQuery(this).data("alias")+"]="+d.a[t],void
0===(t=d.a[t].split(","))&&0==t.length||(jQuery("#"+e+"
option").removeAttr("selected"),jQuery(r+"
div").removeClass("on"),jQuery("#"+e+"
input").removeAttr("checked"),jQuery(t).each(function(){jQuery("#"+e+"
option[data-value-alias='"+this+"']").attr("selected","selected"),jQuery(r+"
div[data-value-alias='"+this+"']").addClass("on"),jQuery("#"+e+"
input[data-value-alias='"+this+"']").attr("checked","checked")}))):(void
0!==jQuery(this).find(":selected").data("value-alias")&&(a=jQuery(this).find(":selected").data("value-alias"),s=s+"a["+jQuery(this).data("alias")+"]="+a),void
0!==jQuery(this).find(":input:checked").data("value-alias")&&(jQuery.each(jQuery(this).find(":input:checked"),function(){""!=i&&(i+=","),i+=jQuery(this).data("value-alias")}),""!=i&&(s=s+"a["+jQuery(this).data("alias")+"]="+i))),h=jQuery(this).data("type-view"),n=jQuery(this).data("product-id"))}),(0!=e.dynamicChangePrice||0!=e.dynamicChangeStock||0!=e.dynamicChangeId||0!=e.dynamicChangeImage&&1!=e.dynamicChangeImage)&&(i=".phjAddToCartV"+h+"P"+n,e=jQuery(i).find("select").serialize(),i=jQuery(i).find(":checkbox").serialize(),phAjaxChangeAttributeData(n,h,e,i)),s.lastIndexOf("&")==s.length-1&&(s=s.slice(0,-1)),(0==u&&""!=s||1==u)&&(s="#"+s,""!=a&&t.val(Base64.encode(a+s)),window.history.pushState({},"",s))}jQuery(document).ready(function(){phChangeAttributeType(),phSetAttributeUrl(0);var
e="select.phjProductAttribute";jQuery(document).on("change",e,function(e){var
t=Joomla.getOptions("phParamsPC");if(0==t.dynamicChangePrice&&0==t.dynamicChangeStock&&0==t.dynamicChangeId&&(0==t.dynamicChangeImage||1==t.dynamicChangeImage))return!1;var
a=jQuery(this).data("type-view"),i=jQuery(this).data("product-id"),t=".phjAddToCartV"+a+"P"+i;phAjaxChangeAttributeData(i,a,jQuery(t).find("select").serialize(),jQuery(t).find(":checkbox").serialize()),phSetAttributeUrl(1)});jQuery(document).on("click",".ph-checkbox-attribute.phjProductAttribute",function(e){var
t=Joomla.getOptions("phParamsPC");if((0!=t.dynamicChangePrice||0!=t.dynamicChangeStock||0!=t.dynamicChangeId||0!=t.dynamicChangeImage&&1!=t.dynamicChangeImage)&&"LABEL"!==e.target.tagName.toUpperCase()&&("bs4"!=t.theme||"SPAN"!==e.target.tagName.toUpperCase()&&"IMG"!==e.target.tagName.toUpperCase())){var
a=jQuery(this).data("product-id"),i=jQuery(this).data("type-view"),r=".phjAddToCartV"+i+"P"+a,u=jQuery(r).find("select").serialize(),t=jQuery(r).find(":checkbox").serialize(),r=(jQuery(this).data("required"),"#"+jQuery(this).attr("id")+"
input:checked"),r=jQuery(r).length;if(0==r)return
jQuery(e.target).parent().addClass("active"),e.preventDefault(),!1;phAjaxChangeAttributeData(a,i,u,t),phSetAttributeUrl(1)}}),jQuery(".phAOGift").on("input",function(){var
e,t="."+jQuery(this).data("type");".phAOGiftType"==t?(e=jQuery(this).data("title"),jQuery(".phAOGiftTitle").text(e),e=jQuery(this).data("image"),jQuery(".phAOGiftImage").attr("src",e),e=jQuery(this).data("date"),jQuery(".phAOGiftDate").text(e),e=jQuery(this).data("description"),e=Base64.decode(e),jQuery(".phAOGiftDescription").html(e),e=jQuery(this).data("class-name"),jQuery(t).attr("class","phAOGiftType
ph-gift-voucher-box
"+e)):jQuery(t).text(jQuery(this).val())})});jquery.phocaattributerequired.js000064400000006553151171034350013210
0ustar00/*
* jQuery Phoca Attribute Required
* https://www.phoca.cz
*
* Copyright (C) 2016 Jan Pavelka www.phoca.cz
*
* Licensed under the MIT license
*/
/* CHECKBOXES */
/* Check if attribute is required (non standard attribute: not select but
image checkboxes)
* Image checkboxes cannot be checked by HTML5
* The check must be done manually per javascript
* There are different functions for different views because views can be
in conflict - itemquick loaded in category
*/
jQuery(document).ready(function(){
jQuery(document).on('click', '.phjAddToCart.phjItem
button[type="submit"]', function() {
jQuery(this).closest("form").find('
.checkbox-group.required input:checkbox').each(function() {// 1
var phAttributeGroup =
jQuery(this).closest(".checkbox-group").attr('id');// 2
var phAttributeGroupItems = jQuery('.phjAddToCart.phjItem #' +
phAttributeGroup + ' input:checkbox');// 3
phAttributeGroupItems.prop('required', true);
if(phAttributeGroupItems.is(":checked")){
phAttributeGroupItems.prop('required', false);
}
})
});
})
jQuery(document).ready(function(){
jQuery(document).on('click', '.phjAddToCart.phjCategory
button[type="submit"]', function() {
jQuery(this).closest("form").find('
.checkbox-group.required input:checkbox').each(function() {// 1
var phAttributeGroup =
jQuery(this).closest(".checkbox-group").attr('id');// 2
var phAttributeGroupItems = jQuery('.phjAddToCart.phjCategory
#' + phAttributeGroup + ' input:checkbox');// 3
phAttributeGroupItems.prop('required', true);
if(phAttributeGroupItems.is(":checked")){
phAttributeGroupItems.prop('required', false);
}
})
});
})
jQuery(document).ready(function(){
jQuery(document).on('click', '.phjAddToCart.phjItems
button[type="submit"]', function() {
jQuery(this).closest("form").find('
.checkbox-group.required input:checkbox').each(function() {// 1
var phAttributeGroup =
jQuery(this).closest(".checkbox-group").attr('id');// 2
var phAttributeGroupItems = jQuery('.phjAddToCart.phjItems #'
+ phAttributeGroup + ' input:checkbox');// 3
phAttributeGroupItems.prop('required', true);
if(phAttributeGroupItems.is(":checked")){
phAttributeGroupItems.prop('required', false);
}
})
});
})
jQuery(document).ready(function(){
jQuery(document).on('click', '.phjAddToCart.phjItemQuick
button[type="submit"]', function() {
jQuery(this).closest("form").find('
.checkbox-group.required input:checkbox').each(function() {// 1
var phAttributeGroup =
jQuery(this).closest(".checkbox-group").attr('id');// 2
var phAttributeGroupItems = jQuery('.phjAddToCart.phjItemQuick
#' + phAttributeGroup + ' input:checkbox');// 3
phAttributeGroupItems.prop('required', true);
if(phAttributeGroupItems.is(":checked")){
phAttributeGroupItems.prop('required', false);
}
})
});
})
jQuery(document).ready(function(){
jQuery(document).on('click', '.phjAddToCart.phjPos
button[type="submit"]', function() {
jQuery(this).closest("form").find('
.checkbox-group.required input:checkbox').each(function() {// 1
var phAttributeGroup =
jQuery(this).closest(".checkbox-group").attr('id');// 2
var phAttributeGroupItems = jQuery('.phjAddToCart.phjPos #' +
phAttributeGroup + ' input:checkbox');// 3
phAttributeGroupItems.prop('required', true);
if(phAttributeGroupItems.is(":checked")){
phAttributeGroupItems.prop('required', false);
}
})
});
})
jquery.phocaattributerequired.min.js000064400000003704151171034350013765
0ustar00jQuery(document).ready(function(){jQuery(document).on("click",'.phjAddToCart.phjItem
button[type="submit"]',function(){jQuery(this).closest("form").find("
.checkbox-group.required input:checkbox").each(function(){var
e=jQuery(this).closest(".checkbox-group").attr("id"),e=jQuery(".phjAddToCart.phjItem
#"+e+"
input:checkbox");e.prop("required",!0),e.is(":checked")&&e.prop("required",!1)})})}),jQuery(document).ready(function(){jQuery(document).on("click",'.phjAddToCart.phjCategory
button[type="submit"]',function(){jQuery(this).closest("form").find("
.checkbox-group.required input:checkbox").each(function(){var
e=jQuery(this).closest(".checkbox-group").attr("id"),e=jQuery(".phjAddToCart.phjCategory
#"+e+"
input:checkbox");e.prop("required",!0),e.is(":checked")&&e.prop("required",!1)})})}),jQuery(document).ready(function(){jQuery(document).on("click",'.phjAddToCart.phjItems
button[type="submit"]',function(){jQuery(this).closest("form").find("
.checkbox-group.required input:checkbox").each(function(){var
e=jQuery(this).closest(".checkbox-group").attr("id"),e=jQuery(".phjAddToCart.phjItems
#"+e+"
input:checkbox");e.prop("required",!0),e.is(":checked")&&e.prop("required",!1)})})}),jQuery(document).ready(function(){jQuery(document).on("click",'.phjAddToCart.phjItemQuick
button[type="submit"]',function(){jQuery(this).closest("form").find("
.checkbox-group.required input:checkbox").each(function(){var
e=jQuery(this).closest(".checkbox-group").attr("id"),e=jQuery(".phjAddToCart.phjItemQuick
#"+e+"
input:checkbox");e.prop("required",!0),e.is(":checked")&&e.prop("required",!1)})})}),jQuery(document).ready(function(){jQuery(document).on("click",'.phjAddToCart.phjPos
button[type="submit"]',function(){jQuery(this).closest("form").find("
.checkbox-group.required input:checkbox").each(function(){var
e=jQuery(this).closest(".checkbox-group").attr("id"),e=jQuery(".phjAddToCart.phjPos
#"+e+"
input:checkbox");e.prop("required",!0),e.is(":checked")&&e.prop("required",!1)})})});jquery.phocaswapimage.js000064400000004331151171034350011411
0ustar00/*
* jQuery Phoca SwapImage
* https://www.phoca.cz
*
* Copyright (C) 2016 Jan Pavelka www.phoca.cz
*
* Licensed under the MIT license
*/
jQuery(document).ready(function() {
jQuery(document).on('change', '.phjProductAttribute',
function(){
var phProductIdName = jQuery(this).data('product-id-name');
var phProductImg = '.phjProductImage' + phProductIdName;
var phProductSource = '.phjProductSource' + phProductIdName;//
Webp source
var phProductHref = '.phjProductHref' + phProductIdName;
var phDefaultSrc = jQuery(phProductImg).data('image');// image
includes data-image attribute
var phDefaultHref = jQuery(phProductHref).data('href');//
image includes data-image attribute
var phNewSrc =
jQuery(this).find(':selected,:checked').data('image-option');//
Set image from current selectbox (selectbox which was changed)
var phSelectedSrc = false; // Find selected image from all attributes of
all select boxes in the form
/* jQuery(this).each(function( index ) {
var phFoundSrc =
jQuery(this).find(':selected,:checked').data('image-option');
if(phFoundSrc) {
phSelectedSrc = phFoundSrc;
}
}); */
jQuery(this).closest("form").find('.phjProductAttribute').each(function()
{
var phFoundSrc =
jQuery(this).find(':selected,:checked').data('image-option');
if(phFoundSrc) {
phSelectedSrc = phFoundSrc;
}
})
var phNewHref = phNewSrc;
var phSelectedHref = phSelectedSrc;
if (phNewSrc) {
// New image found - change to new image
jQuery(phProductHref).attr('href', phNewHref);
jQuery(phProductImg).attr('src', phNewSrc);
jQuery(phProductSource).attr('srcset', phNewSrc);//webp
} else if (!phNewSrc && phSelectedSrc) {
// New image not found but there is some selected image yet (e.g.
selected previously in other select box)
jQuery(phProductHref).attr('href', phSelectedHref);
jQuery(phProductImg).attr('src', phSelectedSrc);
jQuery(phProductSource).attr('srcset', phSelectedSrc);//webp
} else {
// Return back to default image (no new image, no selected image by
other select box)
jQuery(phProductHref).attr('href', phDefaultHref);
jQuery(phProductImg).attr('src', phDefaultSrc);
jQuery(phProductSource).attr('srcset', phDefaultSrc);//webp
}
})
})
jquery.phocaswapimage.min.js000064400000001342151171034350012172
0ustar00jQuery(document).ready(function(){jQuery(document).on("change",".phjProductAttribute",function(){var
t=jQuery(this).data("product-id-name"),r=".phjProductImage"+t,e=".phjProductSource"+t,u=".phjProductHref"+t,a=jQuery(r).data("image"),c=jQuery(u).data("href"),d=jQuery(this).find(":selected,:checked").data("image-option"),j=!1;jQuery(this).closest("form").find(".phjProductAttribute").each(function(){var
t=jQuery(this).find(":selected,:checked").data("image-option");t&&(j=t)});var
o=d,t=j;d?(jQuery(u).attr("href",o),jQuery(r).attr("src",d),jQuery(e).attr("srcset",d)):!d&&j?(jQuery(u).attr("href",t),jQuery(r).attr("src",j),jQuery(e).attr("srcset",j)):(jQuery(u).attr("href",c),jQuery(r).attr("src",a),jQuery(e).attr("srcset",a))})});jquery.phocawindowpopup.js000064400000000742151171034350012031
0ustar00/*
* jQuery Phoca WindowPopup
* https://www.phoca.cz
*
* Copyright (C) 2016 Jan Pavelka www.phoca.cz
*
* Licensed under the MIT license
*/
function phWindowPopup(url, name, rW, rH) {
var w = screen.width / rW;
var h = screen.height / rH;
var params = 'width='+w+', height='+h+',
resizable=yes, scrollbars=yes, menubar=no, status=no, location=no,
toolbar=no';
phWindow = window.open(url, name, params);
if(window.focus) {
phWindow.focus();
}
return false;
}
jquery.phocawindowpopup.min.js000064400000000355151171034350012613
0ustar00function
phWindowPopup(o,n,e,i){i="width="+screen.width/e+",
height="+screen.height/i+", resizable=yes, scrollbars=yes,
menubar=no, status=no, location=no, toolbar=no";return
phWindow=window.open(o,n,i),window.focus&&phWindow.focus(),!1}phocacart.js000064400000025014151171034350007050
0ustar00/*
* @package Phoca Cart
* @author Jan Pavelka - https://www.phoca.cz
* @copyright Copyright (C) Jan Pavelka https://www.phoca.cz
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 and later
* @cms Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
*/
function phRemoveUrlParameter(param, url) {
var rtn = url.split("?")[0],
param,
params_arr = [],
queryString = (url.indexOf("?") !== -1) ?
url.split("?")[1] : "";
if (queryString !== "") {
params_arr = queryString.split("&");
for (var i = params_arr.length - 1; i >= 0; i -= 1) {
paramV = params_arr[i].split("=")[0];
if (paramV === param) {
params_arr.splice(i, 1);
}
}
rtn = rtn + "?" + params_arr.join("&");
}
return rtn;
}
function startOverlay(outputDiv) {
var phOverlay = jQuery('<div
id="phOverlayDiv"><div id="phLoaderFull">
</div></div>');
phOverlay.appendTo(outputDiv);
jQuery("#phOverlayDiv").fadeIn().css("display","block");
}
function startFullOverlay(phA) {
if (phA == 2) {
} else {
var phOverlay = jQuery('<div id="phOverlay"><div
id="phLoaderFull"> </div></div>');
phOverlay.appendTo(document.body);
jQuery("#phOverlay").fadeIn().css("display","block");
}
}
function stopOverlay() {
jQuery("#phOverlay").fadeIn().css("display","none");
}
function phRemoveParamFromUrl(key, sourceURL) {
var rtn = sourceURL.split("?")[0],
param,
params_arr = [],
queryString = (sourceURL.indexOf("?") !== -1) ?
sourceURL.split("?")[1] : "";
if (queryString !== "") {
params_arr = queryString.split("&");
for (var i = params_arr.length - 1; i >= 0; i -= 1) {
param = params_arr[i].split("=")[0];
if (param === key) {
params_arr.splice(i, 1);
}
}
rtn = rtn + "?" + params_arr.join("&");
}
return rtn;
}
function phUpdatePageAndParts(url, source) {
var phVars = Joomla.getOptions('phVarsPC');
var phParamsS =
Joomla.getOptions('phParamsModPhocacartSearch');
var ds = '/';
if (phVars['basePath'] == 'undefined' ||
phVars['basePath'] == '') {
ds = '';
}
// Firefox problem
// FROM:
//window.history.pushState({},"", url);// update URL
// TO:
if (url == '') {
window.history.pushState({},"", location.pathname);// update
URL
} else {
window.history.pushState({},"", url);// update URL
}
if (url != '') {
// Remove format and set the raw
var urlMain = phRemoveParamFromUrl('format', url);
urlMain = url + '&format=raw';
} else {
var urlMain = '?format=raw';
}
// Remove possible conflict params in URL
var urlModule = phRemoveParamFromUrl('option', urlMain);
urlModule = phRemoveParamFromUrl('view', urlModule);
urlModule = phRemoveParamFromUrl('module', urlModule);
urlModule = urlModule.substring(urlModule.indexOf('?') + 1);
var urlSearchModule = phVars['basePath'] + ds +
'index.php?option=com_ajax&module=phocacart_search';
var urlFilterModule = phVars['basePath'] + ds +
'index.php?option=com_ajax&module=phocacart_filter';
if (urlModule.indexOf("?") == 0) {
urlSearchModule = urlSearchModule + '&'
+urlModule.substr(1);
urlFilterModule = urlFilterModule + '&'
+urlModule.substr(1);
} else if (urlModule.indexOf("&") == 0) {
urlSearchModule = urlSearchModule + urlModule;
urlFilterModule = urlFilterModule + urlModule;
} else {
urlSearchModule = urlSearchModule + '&' + urlModule;
urlFilterModule = urlFilterModule + '&' + urlModule;
}
if (typeof phParamsS != 'undefined' &&
phVars['mod_phocacart_search'] == 1 &&
phParamsS['displayActiveParameters'] == 1) {
// Update filter only when
phRenderPagePart({}, 'phSearchActiveTags', urlSearchModule);//
AJAX update search module
}
if (typeof phVars != 'undefined' &&
phVars['mod_phocacart_filter'] == 1 && source == 2) {
// Update filter only when source comes from search filter
phRenderPagePart({}, 'phFilterBox', urlFilterModule);// AJAX
update filter module
}
phRenderPage({},urlMain );// AJAX update main page
}
function phRenderPage(sFormData, phUrlJs) {
var phVars = Joomla.getOptions('phVarsPC');
var phParams = Joomla.getOptions('phParamsPC');
var outputDiv = '#' + phVars['renderPageOutput'];
var phUrl = phVars['renderPageUrl'];
var isPOS = phVars['isPOS'];
var loadChosen = phParams['loadChosen'];
startOverlay(outputDiv);
phUrl = typeof phUrlJs !== "undefined" ? phUrlJs : phUrl;
phRequest = jQuery.ajax({
type: "POST",
url: phUrl,
async: true,
cache: "false",
data: sFormData,
dataType:"HTML",
success: function(data){
jQuery(outputDiv).html(data);
if (isPOS == 1) {
phPosManagePage();
}
if (loadChosen == 1) {
jQuery('select').chosen('destroy').chosen({disable_search_threshold
: 10,allow_single_deselect : true});
}
if (typeof phChangeAttributeType === "function") {
phChangeAttributeType();// Recreate the select attribute (color, image)
after AJAX
}
if(typeof phLazyLoadInstance !== "undefined" &&
phLazyLoadInstance) {
phLazyLoadInstance.update();// Lazy load - reload if enabled
}
stopOverlay();
}
})
return false;
}
function phRenderPagePart(sFormData, outputDiv, phUrl) {
phRequest = jQuery.ajax({
type: "POST",
url: phUrl,
async: true,
cache: "false",
data: sFormData,
dataType:"HTML",
success: function(data){
outputDiv = '#'+ outputDiv;
jQuery(outputDiv).html(data);
}
})
}
function phDisableRequirement() {
var phParams = Joomla.getOptions('phParamsPC');
var loadChosen = phParams['loadChosen'];
var selectC = jQuery("#jform_country_phs");
var selectR = jQuery("#jform_region_phs");
var checked =
jQuery('#phCheckoutBillingSameAsShipping').prop('checked');
if (checked) {
jQuery(".phShippingFormFields").prop("readonly",
true);
selectC.attr("disabled", "disabled");
selectR.attr("disabled", "disabled");
jQuery(".phShippingFormFieldsRequired").removeAttr('aria-required');
jQuery(".phShippingFormFieldsRequired").removeAttr('required');
if (loadChosen > 0) {
jQuery(".phShippingFormFieldsRequired").trigger("chosen:updated");
jQuery(".phShippingFormFields").trigger("chosen:updated");
}
} else {
jQuery(".phShippingFormFieldsRequired").prop('aria-required',
'true');
jQuery(".phShippingFormFieldsRequired").prop('required',
'true');
jQuery(".phShippingFormFields").removeAttr('readonly');
selectC.removeAttr("disabled");
selectR.removeAttr("disabled");
if (loadChosen > 0) {
jQuery(".phShippingFormFieldsRequired").trigger("chosen:updated");
jQuery(".phShippingFormFields").trigger("chosen:updated");
}
}
}
function phRenderBillingAndShippingSame() {
phDisableRequirement();
jQuery("#phCheckoutBillingSameAsShipping").on('click',
function() {
phDisableRequirement();
})
}
// Events
function phEventChangeFormPagination(sForm, sItem) {
var phVars = Joomla.getOptions('phVarsPC');
var phParams = Joomla.getOptions('phParamsPC');
var phA = 1;// Full Overlay Yes
// If pagination changes on top (ordering or display num then the bottom
pagination is reloaded by ajax
// But if bottom pagination changes, the top pagination is not reloaded
// so we need to copy the bottom values from ordering and display num
selectbox
// and set it to top
// top id: itemorderingtop, limittop
// bottom id: itemordering, limit
var phSelectBoxVal = jQuery(sItem).val();
var phSelectBoxId = "#" + jQuery(sItem).attr("id") +
"top";
jQuery(phSelectBoxId).val(phSelectBoxVal);
var formName = jQuery(sForm).attr("name");
if (phParams['ajaxPaginationCategory'] == 1 ||
phVars['isPOS'] == 1) {
// Everything is AJAX - pagination top even pagination bottom
var phUrl = window.location.href;
phRenderPage(jQuery(sForm).serialize(), phUrl);
} else {
// Only top pagination is ajax, bottom pagination is not ajax start prev
1 2 3 next end
if (formName == "phitemstopboxform") {// AJAX - Top pagination
always ajax
var phUrl = window.location.href;
phRenderPage(jQuery(sForm).serialize(), phUrl);
} else {
sForm.submit();// STANDARD
startFullOverlay(phA);
}
}
}
function phNumberFormat (number, decimals, decPoint, thousandsSep) {
number = (number + '').replace(/[^0-9+\-Ee.]/g, '')
var n = !isFinite(+number) ? 0 : +number
var prec = !isFinite(+decimals) ? 0 : Math.abs(decimals)
var sep = (typeof thousandsSep === 'undefined') ? ','
: thousandsSep
var dec = (typeof decPoint === 'undefined') ? '.' :
decPoint
var s = ''
var toFixedFix = function (n, prec) {
var k = Math.pow(10, prec)
return '' + (Math.round(n * k) / k)
.toFixed(prec)
}
// @to do: for IE parseFloat(0.55).toFixed(0) = 0;
s = (prec ? toFixedFix(n, prec) : '' +
Math.round(n)).split('.')
if (s[0].length > 3) {
s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep)
}
if ((s[1] || '').length < prec) {
s[1] = s[1] || ''
s[1] += new Array(prec - s[1].length + 1).join('0')
}
return s.join(dec)
}
// ------
// Events
// ------
jQuery(document).ready(function(){
// ::EVENT (CLICK) Change Layout Type Clicking on Grid, Gridlist, List
jQuery(".phItemSwitchLayoutType").on('click', function
(e) {
var phDataL = jQuery(this).data("layouttype");// Get the right
button (list, grid, gridlist)
var sForm = jQuery(this).closest("form");// Find in which form
the right button was clicked
var sFormData = sForm.serialize() + "&layouttype=" +
phDataL;
jQuery(".phItemSwitchLayoutType").removeClass("active");
jQuery(".phItemSwitchLayoutType." +
phDataL).addClass("active");
var phUrl = window.location.href;
phRenderPage(sFormData, phUrl);
})
// ::EVENT (CLICK) Pagination - Clicking on Start Prev 1 2 3 Next End
jQuery(document).on('click', ".phPaginationBox .pagination
li a", function (e) {
var phVars = Joomla.getOptions('phVarsPC');
var phParams = Joomla.getOptions('phParamsPC');
if (phParams['ajaxPaginationCategory'] == 1 ||
phVars['isPOS'] == 1) {
var phUrl = jQuery(this).attr("href");
var sForm = jQuery(this).closest("form");// Find in which form
the right button was clicked
var sFormData = sForm.serialize();
phRenderPage(sFormData, phUrl);
// Don't set format for url bar (e.g. pagination uses ajax with raw
- such cannot be set in url bar)
// we use ajax and pagination for different views inside one view
(customers, products, orders) so we cannot set this parameter in url,
because of ajax
//if (phVars['isPOS'] == 1) {
phUrl = phRemoveUrlParameter("format", phUrl);
phUrl = phRemoveUrlParameter("start", phUrl);
//}
window.history.pushState("", "", phUrl);// change
url bar
e.preventDefault();
}
})
phRenderBillingAndShippingSame();
})phocacart.min.js000064400000012051151171034350007627 0ustar00function
phRemoveUrlParameter(e,a){var
r=a.split("?")[0],t=[],a=-1!==a.indexOf("?")?a.split("?")[1]:"";if(""!==a){for(var
i=(t=a.split("&")).length-1;0<=i;--i)paramV=t[i].split("=")[0],paramV===e&&t.splice(i,1);r=r+"?"+t.join("&")}return
r}function startOverlay(e){jQuery('<div
id="phOverlayDiv"><div id="phLoaderFull">
</div></div>').appendTo(e),jQuery("#phOverlayDiv").fadeIn().css("display","block")}function
startFullOverlay(e){2==e||(jQuery('<div
id="phOverlay"><div id="phLoaderFull">
</div></div>').appendTo(document.body),jQuery("#phOverlay").fadeIn().css("display","block"))}function
stopOverlay(){jQuery("#phOverlay").fadeIn().css("display","none")}function
phRemoveParamFromUrl(e,a){var
r=a.split("?")[0],t=[],a=-1!==a.indexOf("?")?a.split("?")[1]:"";if(""!==a){for(var
i=(t=a.split("&")).length-1;0<=i;--i)t[i].split("=")[0]===e&&t.splice(i,1);r=r+"?"+t.join("&")}return
r}function phUpdatePageAndParts(e,a){var
r,t=Joomla.getOptions("phVarsPC"),i=Joomla.getOptions("phParamsModPhocacartSearch"),o="/";"undefined"!=t.basePath&&""!=t.basePath||(o=""),""==e?window.history.pushState({},"",location.pathname):window.history.pushState({},"",e),r=""!=e?(r=phRemoveParamFromUrl("format",e),e+"&format=raw"):"?format=raw";var
n=phRemoveParamFromUrl("option",r),n=phRemoveParamFromUrl("view",n);n=(n=phRemoveParamFromUrl("module",n)).substring(n.indexOf("?")+1);e=t.basePath+o+"index.php?option=com_ajax&module=phocacart_search",o=t.basePath+o+"index.php?option=com_ajax&module=phocacart_filter";0==n.indexOf("?")?(e=e+"&"+n.substr(1),o=o+"&"+n.substr(1)):0==n.indexOf("&")?(e+=n,o+=n):(e=e+"&"+n,o=o+"&"+n),void
0!==i&&1==t.mod_phocacart_search&&1==i.displayActiveParameters&&phRenderPagePart({},"phSearchActiveTags",e),void
0!==t&&1==t.mod_phocacart_filter&&2==a&&phRenderPagePart({},"phFilterBox",o),phRenderPage({},r)}function
phRenderPage(e,a){var
r=Joomla.getOptions("phVarsPC"),t=Joomla.getOptions("phParamsPC"),i="#"+r.renderPageOutput,o=r.renderPageUrl,n=r.isPOS,p=t.loadChosen;return
startOverlay(i),o=void
0!==a?a:o,phRequest=jQuery.ajax({type:"POST",url:o,async:!0,cache:"false",data:e,dataType:"HTML",success:function(e){jQuery(i).html(e),1==n&&phPosManagePage(),1==p&&jQuery("select").chosen("destroy").chosen({disable_search_threshold:10,allow_single_deselect:!0}),"function"==typeof
phChangeAttributeType&&phChangeAttributeType(),"undefined"!=typeof
phLazyLoadInstance&&phLazyLoadInstance&&phLazyLoadInstance.update(),stopOverlay()}}),!1}function
phRenderPagePart(e,a,r){phRequest=jQuery.ajax({type:"POST",url:r,async:!0,cache:"false",data:e,dataType:"HTML",success:function(e){a="#"+a,jQuery(a).html(e)}})}function
phDisableRequirement(){var
e=Joomla.getOptions("phParamsPC").loadChosen,a=jQuery("#jform_country_phs"),r=jQuery("#jform_region_phs");jQuery("#phCheckoutBillingSameAsShipping").prop("checked")?(jQuery(".phShippingFormFields").prop("readonly",!0),a.attr("disabled","disabled"),r.attr("disabled","disabled"),jQuery(".phShippingFormFieldsRequired").removeAttr("aria-required"),jQuery(".phShippingFormFieldsRequired").removeAttr("required")):(jQuery(".phShippingFormFieldsRequired").prop("aria-required","true"),jQuery(".phShippingFormFieldsRequired").prop("required","true"),jQuery(".phShippingFormFields").removeAttr("readonly"),a.removeAttr("disabled"),r.removeAttr("disabled")),0<e&&(jQuery(".phShippingFormFieldsRequired").trigger("chosen:updated"),jQuery(".phShippingFormFields").trigger("chosen:updated"))}function
phRenderBillingAndShippingSame(){phDisableRequirement(),jQuery("#phCheckoutBillingSameAsShipping").on("click",function(){phDisableRequirement()})}function
phEventChangeFormPagination(e,a){var
r=Joomla.getOptions("phVarsPC"),t=Joomla.getOptions("phParamsPC"),i=jQuery(a).val(),a="#"+jQuery(a).attr("id")+"top";jQuery(a).val(i);i=jQuery(e).attr("name");1==t.ajaxPaginationCategory||1==r.isPOS||"phitemstopboxform"==i?(i=window.location.href,phRenderPage(jQuery(e).serialize(),i)):(e.submit(),startFullOverlay(1))}function
phNumberFormat(e,a,r,t){e=(e+"").replace(/[^0-9+\-Ee.]/g,"");var
i,o,n,p=isFinite(+e)?+e:0,e=isFinite(+a)?Math.abs(a):0,a=void
0===t?",":t,t=void 0===r?".":r,r="";return
3<(r=(e?(i=p,o=e,n=Math.pow(10,o),""+(Math.round(i*n)/n).toFixed(o)):""+Math.round(p)).split("."))[0].length&&(r[0]=r[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,a)),(r[1]||"").length<e&&(r[1]=r[1]||"",r[1]+=new
Array(e-r[1].length+1).join("0")),r.join(t)}jQuery(document).ready(function(){jQuery(".phItemSwitchLayoutType").on("click",function(e){var
a=jQuery(this).data("layouttype"),r=jQuery(this).closest("form").serialize()+"&layouttype="+a;jQuery(".phItemSwitchLayoutType").removeClass("active"),jQuery(".phItemSwitchLayoutType."+a).addClass("active"),phRenderPage(r,window.location.href)}),jQuery(document).on("click",".phPaginationBox
.pagination li a",function(e){var
a=Joomla.getOptions("phVarsPC");1!=Joomla.getOptions("phParamsPC").ajaxPaginationCategory&&1!=a.isPOS||(a=jQuery(this).attr("href"),phRenderPage(jQuery(this).closest("form").serialize(),a),a=phRemoveUrlParameter("format",a),a=phRemoveUrlParameter("start",a),window.history.pushState("","",a),e.preventDefault())}),phRenderBillingAndShippingSame()});phocafilter.js000064400000043215151171034350007407
0ustar00/* @package Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* @extension Phoca Extension
* @copyright Copyright (C) Jan Pavelka www.phoca.cz
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/
var phFilterNewUrlSet = '';
var phFilterNewUrlRemove = '';
var phFilterNewUrlSetPreviousParamWaiting = 0;
var phFilterNewUrlRemovePreviousParamWaiting = 0;
function phReplaceAll(find, replace, str) {
return str.replace(new RegExp(find, 'gi'), replace);
}
function phEscapeRegExp(string) {
return string.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,
"\\$1");
}
function phReplaceAll(find, replace, string) {
return string.replace(new RegExp(phEscapeRegExp(find), 'g'),
replace);
}
function phEncode(string) {
var s;
s = encodeURIComponent(string);
s = phReplaceAll('%5B', '[', s);
s = phReplaceAll('%5D', ']', s);
s = phReplaceAll('%2C', ',', s);
s = phReplaceAll('%3A', ':', s);
return s;
}
function phArrayToString(a) {
var s;
s = phReplaceAll('[', '(', a);
s = phReplaceAll(']', ')', s);
//s = phReplaceAll('%5B', '(', s);
//s = phReplaceAll('%5D', ')', s);
return s;
}
function phStringToArray(a) {
var s;
s = phReplaceAll('(', '[', a);
s = phReplaceAll(')', ']', s);
return s;
}
function phCleanArray(actual){
//var newArray = new Array();
var newArray = [];
for(var i = 0; i <actual.length; i++){
if (actual[i]){
newArray.push(actual[i]);
}
}
return newArray;
}
function phCleanEmptyParams(url) {
return url.replace(/&?[^&?]+=(?=(?:&|$))/g, '');
}
function phCleanAloneQuestionMark(url) {
if (url == '?&') {
url = '?';
}
if (url == '?') {
url = '';
}
return url;
}
function phFilterValue(value) {
var v;
v = phReplaceAll('<', '', value);
v = phReplaceAll('>', '', v);
return v;
}
/*
function phSetUrl(url) {
var urlItemsView= url;
var urlPathName = location.pathname;
var urlSearch = location.search;
var urlPage = urlPathName + urlSearch;
}
*/
function phRemoveFilter(param, value, isItemsView, urlItemsView,
filteredProductsOnly, uniqueValue, wait, source) {
var phParams = Joomla.getOptions('phParamsPC');
/*
* If there is empty phFilterNewUrlRemove, this means:
* a) there were no previous parameter which is waiting or
* b) there were previous parameter which is waiting but previous
parameter deleted the url
* so it looks like the previous parameter does not exists (but it
exists)
*/
/* Array -> String */
param = phArrayToString(param);
var queryString = jQuery.param.querystring();
queryString = phArrayToString(queryString);
var paramsAll;
if (phFilterNewUrlRemove !== '' ||
phFilterNewUrlRemovePreviousParamWaiting == 1) {
paramsAll = jQuery.deparam.querystring(phFilterNewUrlRemove);
} else {
paramsAll = jQuery.deparam.querystring(queryString);
}
var paramsTypeStringNew = {};
var mergeMode = 0;
/* Handle pagination - when changing filter, set pagination to zero - to
start */
if (typeof paramsAll['start'] !== 'undefined') {
paramsTypeStringNew['start'] = 0;
}
if (typeof paramsAll['limitstart'] !== 'undefined') {
paramsTypeStringNew['limitstart'] = 0;
}
if (uniqueValue == 1) {
delete paramsAll[param];
paramsTypeStringNew = paramsAll;
mergeMode = 2;
} else if (typeof paramsAll[param] !== 'undefined') {
var paramsTypeString = paramsAll[param];
var paramsTypeArray = paramsTypeString.split(',');
paramsTypeArray = phCleanArray(paramsTypeArray);
var findVal = paramsTypeArray.indexOf(value);
if ( findVal === -1 ){
// Value to remove is not there
} else {
// Value to remove is there
var index = paramsTypeArray.indexOf(value);
if (index > -1) {
paramsTypeArray.splice(index, 1);
}
paramsTypeString = paramsTypeArray.join();
if (paramsTypeString) {
paramsTypeStringNew[param] = paramsTypeString;
} else {
delete paramsAll[param];
paramsTypeStringNew = paramsAll;
mergeMode = 2;
}
}
} else {
delete paramsAll[param];
paramsTypeStringNew = paramsAll;
mergeMode = 2;
}
/*var url;
if (filteredProductsOnly == 1) {
url = location.search;
} else {
url = urlItemsView;// It is possible to deselect category in
category/item view
document.location = url;
return 1;
//return 2; // Not possible to deselect in other than items view
//return false;
}*/
/*
if ((isItemsView == 1 && filteredProductsOnly != 1) || isItemsView
!= 1) {
url = urlItemsView;// skip all parameters (a) search all products in
items view or b) no items view
} else {
url = location.search;// complete url with selected parameters
}*/
var url;
if ((isItemsView == 1 && filteredProductsOnly != 1) || isItemsView
!= 1) {
url = urlItemsView;// skip all parameters (a) search all products in
items view or b) no items view
document.location = url;
return 1;
} else {
url = location.search;// complete url with selected parameters
}
// Set new url or take the one from previous parameter
if (phFilterNewUrlRemove !== '' ||
phFilterNewUrlRemovePreviousParamWaiting == 1) {
url = phFilterNewUrlRemove;
}
/* Array -> String */
url = phArrayToString(url);
phFilterNewUrlRemove = jQuery.param.querystring( url,
paramsTypeStringNew, mergeMode);// one parameter only
phFilterNewUrlRemove = phReplaceAll('%2C', ',',
phFilterNewUrlRemove);
phFilterNewUrlRemove = phReplaceAll('%5B', '[',
phFilterNewUrlRemove);
phFilterNewUrlRemove = phReplaceAll('%5D', ']',
phFilterNewUrlRemove);
phFilterNewUrlRemove = phReplaceAll('%3A', ':',
phFilterNewUrlRemove);
/* String -> Array */
phFilterNewUrlRemove = phStringToArray(phFilterNewUrlRemove);
phFilterNewUrlRemove = phCleanAloneQuestionMark(phFilterNewUrlRemove);
// Wait for next parameter
if (wait == 1) {
// Don't reload, wait for other parameter
phFilterNewUrlRemovePreviousParamWaiting = 1;
if (isItemsView == 1 &&
phParams['ajaxSearchingFilteringItems'] == 1) {// and ajax
return 2;// don't run overlay
}
} else {
if (isItemsView == 1 &&
phParams['ajaxSearchingFilteringItems'] == 1) {
phUpdatePageAndParts(phFilterNewUrlRemove, source);// Update Main,
Search, Filter
phFilterNewUrlRemove = '';
phFilterNewUrlRemovePreviousParamWaiting = 0;
return 2;
} else {
//document.location = phFilterNewUrlSet;
document.location = phFilterNewUrlRemove;
}
phFilterNewUrlRemove = '';
}
return 1;
}
/*
* param: parameter name
* value: parameter value
* isItemsView: comes the request from itemsView (Ajax possible) or not
* urlItemsView: urlItemsView differently set by different parameters
* filteredProductsOnly: when searching - a) all products can be searched
or - b) only filtered products can be searched
a) c=1-category&search=search - c=1-category will be removed
from url to search all parameters
b) c=1-category&search=search - nothing will be removed from url
to search filtered parameters
* uniqueValue: c=1-category,c=2category is not unique value,
price_from=100 is unique value
* wait: wait for next parameter before reload and end the action (e.g.
price with two values)
* source: where the request comes, values: 1 filter, 2 search, 3 itemview
(specific case)
*/
function phSetFilter(param, value, isItemsView, urlItemsView,
filteredProductsOnly, uniqueValue, wait, source) {
var phParams = Joomla.getOptions('phParamsPC');
/*
* We need to differentiate:
* a) there is no parameter in the URL
* b) there is no parameter in the URL but it was here but we have removed
it previously
* as there is a wait function which handles e.g. two parameters at
once and if
* the first parameter will be removed we need to differentiate
between:
* a) url which was empty (no parameters) at the beginning
* b) url which had parameters but they were removed while working with
this function and waiting
*/
value = phFilterValue(value);
/* Array -> String */
param = phArrayToString(param);
var queryString = jQuery.param.querystring();
queryString = phArrayToString(queryString);
var paramsAll;
if (phFilterNewUrlSet !== '' ||
phFilterNewUrlSetPreviousParamWaiting == 1) {
phFilterNewUrlSet = phArrayToString(phFilterNewUrlSet);// wait back from
() to [] so it can be read by querystring
paramsAll = jQuery.deparam.querystring(phFilterNewUrlSet);
} else {
paramsAll = jQuery.deparam.querystring(queryString);
}
var paramsTypeStringNew = {};
var mergeMode = 0;
/* Handle pagination - when changing filter, set pagination to zero - to
start */
if (typeof paramsAll['start'] !== 'undefined') {
paramsTypeStringNew['start'] = 0;
}
if (typeof paramsAll['limitstart'] !== 'undefined') {
paramsTypeStringNew['limitstart'] = 0;
}
if (uniqueValue == 1) {
paramsTypeStringNew[param] = value;// { param:value};// unique value -
always overwrite old value
} else if (value === '') {
} else if (typeof paramsAll[param] !== 'undefined') {
var paramsTypeString = paramsAll[param];
var paramsTypeArray = paramsTypeString.split(',');
paramsTypeArray = phCleanArray(paramsTypeArray);
var findVal = paramsTypeArray.indexOf(value);
if ( findVal === -1 ){
// New value is not there - add it
paramsTypeArray.push(value);
paramsTypeString = paramsTypeArray.join();
paramsTypeStringNew[param] = paramsTypeString;//{
param:paramsTypeString};// Changed
} else {
// New value is there - don't change it
paramsTypeStringNew[param] = paramsTypeString;//{
param:paramsTypeString};// Unchanged
}
} else {
paramsTypeStringNew[param] = value;//{ param:value};
}
var url;
if ((isItemsView == 1 && filteredProductsOnly != 1) || isItemsView
!= 1) {
url = urlItemsView;// skip all parameters (a) search all products in
items view or b) no items view
} else {
url = location.search;// complete url with selected parameters
}
// Set new url or take the one from previous parameter
if (phFilterNewUrlSet !== '' ||
phFilterNewUrlSetPreviousParamWaiting == 1) {
url = phFilterNewUrlSet;
}
/* Array -> String */
url = phArrayToString(url);
phFilterNewUrlSet = jQuery.param.querystring( url, paramsTypeStringNew,
mergeMode);// one parameter only
phFilterNewUrlSet = phReplaceAll('%2C', ',',
phFilterNewUrlSet);
phFilterNewUrlSet = phReplaceAll('%2C', ',',
phFilterNewUrlSet);
phFilterNewUrlSet = phReplaceAll('%5B', '[',
phFilterNewUrlSet);
phFilterNewUrlSet = phReplaceAll('%5D', ']',
phFilterNewUrlSet);
phFilterNewUrlSet = phReplaceAll('%3A', ':',
phFilterNewUrlSet);
/* String -> Array */
phFilterNewUrlSet = phStringToArray(phFilterNewUrlSet);
phFilterNewUrlSet = phCleanEmptyParams(phFilterNewUrlSet);
phFilterNewUrlSet = phCleanAloneQuestionMark(phFilterNewUrlSet);
// Wait for next parameter
if (wait == 1) {
// Don't reload, wait for other parameter
phFilterNewUrlSetPreviousParamWaiting = 1;
if (isItemsView == 1 &&
phParams['ajaxSearchingFilteringItems'] == 1) {
return 2;// don't run overlay
}
} else {
if (isItemsView == 1 &&
phParams['ajaxSearchingFilteringItems'] == 1) {
phUpdatePageAndParts(phFilterNewUrlSet, source);// Update Main, Search,
Filter
phFilterNewUrlSet = '';
phFilterNewUrlSetPreviousParamWaiting = 0;
return 2;
} else {
document.location = phFilterNewUrlSet;
}
phFilterNewUrlSet = '';
}
return 1;
}
/* Function phChangeFilter */
function phChangeFilter(param, value, formAction, formType, uniqueValue,
wait, source) {
var phVars = Joomla.getOptions('phVarsModPhocacartFilter');
var phParams =
Joomla.getOptions('phParamsModPhocacartFilter');
var isItemsView = phVars['isItemsView'];
var isSef = phVars['isSef'];
var urlItemsView = phVars['urlItemsView'];
var urlItemsViewWithoutParams =
phVars['urlItemsViewWithoutParams'];
var phA = 1;
if (formType == 'itemview'){
// Specific case for item view (no filtering but setting unique url for
product with attributes)
if(value === undefined) {
value = '';
}
phA = phSetFilter(param, value, 1, 0, 1, uniqueValue, wait, source);
} else if (formType == "text") {
//value = phEncode(value);
if (formAction == 1) {
phA = phSetFilter(param, value, isItemsView, urlItemsView, 1,
uniqueValue, wait, source);
} else {
phA = phRemoveFilter(param, value, isItemsView, urlItemsView, 1,
uniqueValue, wait, source);
}
} else if (formType == "category") {
urlItemsView = urlItemsViewWithoutParams;
if (phParams['removeParametersCat'] == 1) {
document.location = urlItemsView;
} else {
var currentUrlParams = jQuery.param.querystring();
if (isItemsView == 1) {
if (isSef == 1) {
document.location = jQuery.param.querystring(urlItemsView,
currentUrlParams, 2);
} else {
phRemoveFilter(param, value, isItemsView, urlItemsView, 1,
uniqueValue, wait, source);
}
} else {
document.location = urlItemsView;
}
}
} else {
if (formAction.checked) {
phA = phSetFilter(param, value, isItemsView, urlItemsView, 1,
uniqueValue, wait, source);
} else {
phA = phRemoveFilter(param, value, isItemsView, urlItemsView, 1,
uniqueValue, wait, source);
}
}
startFullOverlay(phA);
}
/* Function phChangeSearch*/
function phChangeSearch(param, value, formAction) {
var phVars = Joomla.getOptions('phVarsModPhocacartSearch');
var phParams =
Joomla.getOptions('phParamsModPhocacartSearch');
var phVarsPC = Joomla.getOptions('phParamsPC');
var isItemsView = phVars['isItemsView'];
var urlItemsView = phVars['urlItemsView'];
var urlItemsViewWithoutParams =
phVars['urlItemsViewWithoutParams'];
var phA = 1;
var filteredProductsOnly = isItemsView;
if (formAction == 1) {
if (phParams['searchOptions'] == 1) {
//jQuery("#phSearchBoxSearchAllProducts:checked").val();
//jQuery("#phSearchBoxSearchAllProducts").attr("checked");
if(jQuery("#phSearchBoxSearchAllProducts:checked").length
> 0) {
urlItemsView = urlItemsViewWithoutParams;
filteredProductsOnly = 0; // When options are enabled and searching
is set to all - we search without filtering
}
} else {
filteredProductsOnly = 0;// When options are disabled we always search
without filtering
}
phA = phSetFilter(param, value, isItemsView, urlItemsView,
filteredProductsOnly, 1, 0, 2);
} else {
phA = phRemoveFilter(param, value, isItemsView, urlItemsView,
filteredProductsOnly, 1, 0, 2);
}
startFullOverlay(phA);
}
function phPriceFilterRange() {
var phVars = Joomla.getOptions('phParamsPC');
var phLang = Joomla.getOptions('phLangPC');
// Filter Range
if (typeof jQuery("#phPriceFilterRange").slider ===
"function") {
jQuery("#phPriceFilterRange").slider({
range: true,
min: phVars['filterPriceMin'],
max: phVars['filterPriceMax'],
values: [phVars['filterPriceFrom'],
phVars['filterPriceTo']],
slide: function( event, ui ) {
jQuery("#phPriceFromTopricefrom").val(ui.values[0]);
jQuery("#phPriceFromTopriceto").val(ui.values[1]);
jQuery("#phPriceFilterPrice").html("" +
phLang['COM_PHOCACART_PRICE'] + ": " +
phGetPriceFormat(ui.values[0]) + " - " +
phGetPriceFormat(ui.values[1]));
}
});
}
jQuery("#phPriceFilterPrice").html("" +
phLang['COM_PHOCACART_PRICE'] + ": " +
phGetPriceFormat(phVars['filterPriceFrom']) + " - " +
phGetPriceFormat(phVars['filterPriceTo']));
jQuery("#phPriceFromTopricefrom").on("change",
function (e) {
var from = jQuery("#phPriceFromTopricefrom").val();
var to = jQuery("#phPriceFromTopriceto").val();
if (to == '') { to = phVars['filterPriceMax'];}
if (from == '') { from = phVars['filterPriceMin'];}
if (Number(to) < Number(from)) {to =
from;jQuery("#phPriceFromTopriceto").val(to);}
if (typeof jQuery("#phPriceFilterRange").slider ===
"function") {
jQuery( "#phPriceFilterRange" ).slider({values: [from,to]});
}
jQuery("#phPriceFilterPrice").html("" +
phLang['COM_PHOCACART_PRICE'] + ": " +
phGetPriceFormat(from) + " - " + phGetPriceFormat(to));
})
jQuery("#phPriceFromTopriceto").on("change", function
(e) {
var from = jQuery("#phPriceFromTopricefrom").val();
var to = jQuery("#phPriceFromTopriceto").val();
if (to == '') { to = phVars['filterPriceMax'];}
if (from == '') { from = phVars['filterPriceMin'];}
if (Number(to) < Number(from)) {to =
from;jQuery("#phPriceFromTopriceto").val(to);}
if (typeof jQuery("#phPriceFilterRange").slider ===
"function") {
jQuery( "#phPriceFilterRange" ).slider({values: [from,to]});
}
jQuery("#phPriceFilterPrice").html("" +
phLang['COM_PHOCACART_PRICE'] + ": " +
phGetPriceFormat(from) + " - " + phGetPriceFormat(to));
})
}
function phClearField(field) {
jQuery(field).val('');
}
// ------
// Events
// ------
jQuery(document).ready(function () {
jQuery('.collapse')
.on('shown.bs.collapse', function() {
jQuery(this).parent().find(".glyphicon-triangle-right").removeClass("glyphicon-triangle-right").addClass("glyphicon-triangle-bottom");
jQuery(this).parent().find(".fa-caret-right").removeClass("fa-caret-right").addClass("fa-caret-down");
})
.on('hidden.bs.collapse', function() {
jQuery(this).parent().find(".glyphicon-triangle-bottom").removeClass("glyphicon-triangle-bottom").addClass("glyphicon-triangle-right");
jQuery(this).parent().find(".fa-caret-down").removeClass("fa-caret-down").addClass("fa-caret-right");
});
phPriceFilterRange ();
});
phocafilter.min.js000064400000016351151171034350010172 0ustar00var
phFilterNewUrlSet="",phFilterNewUrlRemove="",phFilterNewUrlSetPreviousParamWaiting=0,phFilterNewUrlRemovePreviousParamWaiting=0;function
phReplaceAll(e,r,t){return t.replace(new
RegExp(e,"gi"),r)}function phEscapeRegExp(e){return
e.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")}function
phReplaceAll(e,r,t){return t.replace(new
RegExp(phEscapeRegExp(e),"g"),r)}function
phEncode(e){e=encodeURIComponent(e);return
e=phReplaceAll("%5B","[",e),e=phReplaceAll("%5D","]",e),e=phReplaceAll("%2C",",",e),e=phReplaceAll("%3A",":",e)}function
phArrayToString(e){e=phReplaceAll("[","(",e);return
e=phReplaceAll("]",")",e)}function
phStringToArray(e){e=phReplaceAll("(","[",e);return
e=phReplaceAll(")","]",e)}function
phCleanArray(e){for(var
r=[],t=0;t<e.length;t++)e[t]&&r.push(e[t]);return r}function
phCleanEmptyParams(e){return
e.replace(/&?[^&?]+=(?=(?:&|$))/g,"")}function
phCleanAloneQuestionMark(e){return"?&"==e&&(e="?"),"?"==e&&(e=""),e}function
phFilterValue(e){e=phReplaceAll("<","",e);return
e=phReplaceAll(">","",e)}function
phRemoveFilter(e,r,t,i,l,a,p,o){var
n=Joomla.getOptions("phParamsPC");e=phArrayToString(e);var
h,c=phArrayToString(c=jQuery.param.querystring()),m=""!==phFilterNewUrlRemove||1==phFilterNewUrlRemovePreviousParamWaiting?jQuery.deparam.querystring(phFilterNewUrlRemove):jQuery.deparam.querystring(c),u={},s=0;if(void
0!==m.start&&(u.start=0),void
0!==m.limitstart&&(u.limitstart=0),1!=a&&void
0!==m[e]?-1===(a=phCleanArray(a=(c=m[e]).split(","))).indexOf(r)||(-1<(r=a.indexOf(r))&&a.splice(r,1),(c=a.join())?u[e]=c:(delete
m[e],u=m,s=2)):(delete m[e],u=m,s=2),1==t&&1!=l||1!=t)return
h=i,document.location=h,1;if(h=location.search,""===phFilterNewUrlRemove&&1!=phFilterNewUrlRemovePreviousParamWaiting||(h=phFilterNewUrlRemove),h=phArrayToString(h),phFilterNewUrlRemove=jQuery.param.querystring(h,u,s),phFilterNewUrlRemove=phReplaceAll("%2C",",",phFilterNewUrlRemove),phFilterNewUrlRemove=phReplaceAll("%5B","[",phFilterNewUrlRemove),phFilterNewUrlRemove=phReplaceAll("%5D","]",phFilterNewUrlRemove),phFilterNewUrlRemove=phCleanAloneQuestionMark(phFilterNewUrlRemove=phStringToArray(phFilterNewUrlRemove=phReplaceAll("%3A",":",phFilterNewUrlRemove))),1==p){if((phFilterNewUrlRemovePreviousParamWaiting=1)==t&&1==n.ajaxSearchingFilteringItems)return
2}else{if(1==t&&1==n.ajaxSearchingFilteringItems)return
phUpdatePageAndParts(phFilterNewUrlRemove,o),phFilterNewUrlRemove="",phFilterNewUrlRemovePreviousParamWaiting=0,2;document.location=phFilterNewUrlRemove,phFilterNewUrlRemove=""}return
1}function phSetFilter(e,r,t,i,l,a,p,o){var
n=Joomla.getOptions("phParamsPC");r=phFilterValue(r),e=phArrayToString(e);var
h=phArrayToString(h=jQuery.param.querystring()),c=""!==phFilterNewUrlSet||1==phFilterNewUrlSetPreviousParamWaiting?(phFilterNewUrlSet=phArrayToString(phFilterNewUrlSet),jQuery.deparam.querystring(phFilterNewUrlSet)):jQuery.deparam.querystring(h),h={};if(void
0!==c.start&&(h.start=0),void
0!==c.limitstart&&(h.limitstart=0),1==a?h[e]=r:""===r||(void
0!==c[e]?(-1===(c=phCleanArray(c=(a=c[e]).split(","))).indexOf(r)&&(c.push(r),a=c.join()),h[e]=a):h[e]=r),i=1==t&&1!=l||1!=t?i:location.search,""===phFilterNewUrlSet&&1!=phFilterNewUrlSetPreviousParamWaiting||(i=phFilterNewUrlSet),i=phArrayToString(i),phFilterNewUrlSet=jQuery.param.querystring(i,h,0),phFilterNewUrlSet=phReplaceAll("%2C",",",phFilterNewUrlSet),phFilterNewUrlSet=phReplaceAll("%2C",",",phFilterNewUrlSet),phFilterNewUrlSet=phReplaceAll("%5B","[",phFilterNewUrlSet),phFilterNewUrlSet=phReplaceAll("%5D","]",phFilterNewUrlSet),phFilterNewUrlSet=phCleanAloneQuestionMark(phFilterNewUrlSet=phCleanEmptyParams(phFilterNewUrlSet=phStringToArray(phFilterNewUrlSet=phReplaceAll("%3A",":",phFilterNewUrlSet)))),1==p){if((phFilterNewUrlSetPreviousParamWaiting=1)==t&&1==n.ajaxSearchingFilteringItems)return
2}else{if(1==t&&1==n.ajaxSearchingFilteringItems)return
phUpdatePageAndParts(phFilterNewUrlSet,o),phFilterNewUrlSet="",phFilterNewUrlSetPreviousParamWaiting=0,2;document.location=phFilterNewUrlSet,phFilterNewUrlSet=""}return
1}function phChangeFilter(e,r,t,i,l,a,p){var
o=Joomla.getOptions("phVarsModPhocacartFilter"),n=Joomla.getOptions("phParamsModPhocacartFilter"),h=o.isItemsView,c=o.isSef,m=o.urlItemsView,u=o.urlItemsViewWithoutParams,o=1;"itemview"==i?(void
0===r&&(r=""),o=phSetFilter(e,r,1,0,1,l,a,p)):"text"==i?o=(1==t?phSetFilter:phRemoveFilter)(e,r,h,m,1,l,a,p):"category"==i?(m=u,1==n.removeParametersCat?document.location=m:(n=jQuery.param.querystring(),1==h?1==c?document.location=jQuery.param.querystring(m,n,2):phRemoveFilter(e,r,h,m,1,l,a,p):document.location=m)):o=(t.checked?phSetFilter:phRemoveFilter)(e,r,h,m,1,l,a,p),startFullOverlay(o)}function
phChangeSearch(e,r,t){var
i=Joomla.getOptions("phVarsModPhocacartSearch"),l=Joomla.getOptions("phParamsModPhocacartSearch"),a=(Joomla.getOptions("phParamsPC"),i.isItemsView),p=i.urlItemsView,o=i.urlItemsViewWithoutParams,n=1,i=a,n=1==t?(1==l.searchOptions?0<jQuery("#phSearchBoxSearchAllProducts:checked").length&&(p=o,i=0):i=0,phSetFilter(e,r,a,p,i,1,0,2)):phRemoveFilter(e,r,a,p,i,1,0,2);startFullOverlay(n)}function
phPriceFilterRange(){var
i=Joomla.getOptions("phParamsPC"),l=Joomla.getOptions("phLangPC");"function"==typeof
jQuery("#phPriceFilterRange").slider&&jQuery("#phPriceFilterRange").slider({range:!0,min:i.filterPriceMin,max:i.filterPriceMax,values:[i.filterPriceFrom,i.filterPriceTo],slide:function(e,r){jQuery("#phPriceFromTopricefrom").val(r.values[0]),jQuery("#phPriceFromTopriceto").val(r.values[1]),jQuery("#phPriceFilterPrice").html(l.COM_PHOCACART_PRICE+":
"+phGetPriceFormat(r.values[0])+" -
"+phGetPriceFormat(r.values[1]))}}),jQuery("#phPriceFilterPrice").html(l.COM_PHOCACART_PRICE+":
"+phGetPriceFormat(i.filterPriceFrom)+" -
"+phGetPriceFormat(i.filterPriceTo)),jQuery("#phPriceFromTopricefrom").on("change",function(e){var
r=jQuery("#phPriceFromTopricefrom").val(),t=jQuery("#phPriceFromTopriceto").val();""==t&&(t=i.filterPriceMax),""==r&&(r=i.filterPriceMin),Number(t)<Number(r)&&(t=r,jQuery("#phPriceFromTopriceto").val(t)),"function"==typeof
jQuery("#phPriceFilterRange").slider&&jQuery("#phPriceFilterRange").slider({values:[r,t]}),jQuery("#phPriceFilterPrice").html(l.COM_PHOCACART_PRICE+":
"+phGetPriceFormat(r)+" -
"+phGetPriceFormat(t))}),jQuery("#phPriceFromTopriceto").on("change",function(e){var
r=jQuery("#phPriceFromTopricefrom").val(),t=jQuery("#phPriceFromTopriceto").val();""==t&&(t=i.filterPriceMax),""==r&&(r=i.filterPriceMin),Number(t)<Number(r)&&(t=r,jQuery("#phPriceFromTopriceto").val(t)),"function"==typeof
jQuery("#phPriceFilterRange").slider&&jQuery("#phPriceFilterRange").slider({values:[r,t]}),jQuery("#phPriceFilterPrice").html(l.COM_PHOCACART_PRICE+":
"+phGetPriceFormat(r)+" - "+phGetPriceFormat(t))})}function
phClearField(e){jQuery(e).val("")}jQuery(document).ready(function(){jQuery(".collapse").on("shown.bs.collapse",function(){jQuery(this).parent().find(".glyphicon-triangle-right").removeClass("glyphicon-triangle-right").addClass("glyphicon-triangle-bottom"),jQuery(this).parent().find(".fa-caret-right").removeClass("fa-caret-right").addClass("fa-caret-down")}).on("hidden.bs.collapse",function(){jQuery(this).parent().find(".glyphicon-triangle-bottom").removeClass("glyphicon-triangle-bottom").addClass("glyphicon-triangle-right"),jQuery(this).parent().find(".fa-caret-down").removeClass("fa-caret-down").addClass("fa-caret-right")}),phPriceFilterRange()});phocapos.js000064400000047057151171034350006733
0ustar00/*
* @package Phoca Cart
* @author Jan Pavelka - https://www.phoca.cz
* @copyright Copyright (C) Jan Pavelka https://www.phoca.cz
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 and later
* @cms Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
*/
/* Update parameter */
function phUpdateUrlParameter(param, value, urlChange) {
if (typeof urlChange !== "undefined") {
var url = urlChange;
var urlA = url.split("#");
var hash = ""
if(urlA.length > 1) { hash = urlA[1];}
} else {
var url = window.location.href;
var hash = location.hash;
}
url = url.replace(hash, '');
if (url.indexOf(param + "=") >= 0) {
var prefix = url.substring(0, url.indexOf(param));
var suffix = url.substring(url.indexOf(param));
suffix = suffix.substring(suffix.indexOf("=") + 1);
suffix = (suffix.indexOf("&") >= 0) ?
suffix.substring(suffix.indexOf("&")) : "";
url = prefix + param + "=" + value + suffix;
} else {
if (url.indexOf("?") < 0) {
url += "?" + param + "=" + value;
} else {
url += "&" + param + "=" + value;
}
}
url =
url.replace(/[^=&]+=(&|$)/g,"").replace(/&$/,"");//
remove all parameters with empty values
if (typeof urlChange !== "undefined") {
return (url + hash);
} else {
window.history.pushState(null, null, url + hash);
}
}
/* Update input box after change */
function phDoSubmitFormUpdateInputBox(sFormData, phUrlAjax) {
phRequest = jQuery.ajax({
type: "POST",
url: phUrlAjax,
async: true,
cache: "false",
data: sFormData,
dataType:"HTML",
success: function(data){
jQuery("#phPosInputBox").html(data);
}
})
return false;
}
/* Update categories box after change (users can have different access
rights for different categories, so when selecting user, categories must be
changed) */
function phDoSubmitFormUpdateCategoriesBox(sFormData, phUrlAjax) {
// Change categories only when customer changed
var page = jQuery("#phPosPaginationBox
input[name=page]").val();
if (page != "main.content.customers") {
return false;
}
phRequest = jQuery.ajax({
type: "POST",
url: phUrlAjax,
async: true,
cache: "false",
data: sFormData,
dataType:"HTML",
success: function(data){
jQuery("#phPosCategoriesBox").html(data);
}
})
return false;
}
/* Main content box can be variable: products/customers/payment/shippment
* Get info about current ticket id and page (page: products, customers,
payment, shipping)
*/
function phPosCurrentData(forcepage, format, id) {
var phVars = Joomla.getOptions('phVarsPC');
var phToken = phVars['token'];
if (typeof forcepage !== "undefined") {
var page = forcepage;
} else {
var page = jQuery("#phPosPaginationBox
input[name=page]").val();
}
if (typeof format !== "undefined") {
var formatSuffix = format;
} else {
var formatSuffix = "raw";
}
if (typeof id !== "undefined") {
var idSuffix = "&id="+id;
} else {
var idSuffix = "";
}
var ticketid = jQuery("#phPosPaginationBox
input[name=ticketid]").val();
var unitid = jQuery("#phPosPaginationBox
input[name=unitid]").val();
var sectionid = jQuery("#phPosPaginationBox
input[name=sectionid]").val();
var phData = "format=" + formatSuffix +
"&tmpl=component&page=" + page + idSuffix
+"&ticketid=" + ticketid + "&unitid=" + unitid
+ "§ionid=" + sectionid + "&" + phToken +
"=1";
return phData;
}
/*
* When chaning main page, clear all filters (e.g. going from product list
to customer list)
* Category - remove url parameters in url bar, then empty all checkboxes
* Search - remove url parameters in url bar, then empty search input field
*/
function phPosClearFilter() {
phUpdateUrlParameter("category", "");
jQuery("input.phPosCategoryCheckbox:checkbox:checked").prop("checked",
false);
jQuery("label.phCheckBoxCategory").removeClass("active");
phUpdateUrlParameter("search", "");
jQuery("#phPosSearch").val("");
}
/* Focus on form input if asked (sku, loyalty card, coupon, tendered
amount) */
function phPosManagePageFocus(page) {
var phParams = Joomla.getOptions('phParamsPC');
var posFocusInputFields = phParams['posFocusInputFields'];
if (posFocusInputFields == 1) {
if (page == "main.content.products") {
var hasFocusSearch =
jQuery("#phPosSearch").is(":focus");
if (!hasFocusSearch) {
jQuery("#phPosSku").focus();
}
} else if (page == "main.content.customers") {
var hasFocusSearch =
jQuery("#phPosSearch").is(":focus");
if (!hasFocusSearch) {
jQuery("#phPosCard").focus();
}
} else if (page == "main.content.paymentmethods") {
var hasFocusSearch =
jQuery("#phPosSearch").is(":focus");
if (!hasFocusSearch) {
jQuery("#phcoupon").focus();
}
} else if (page == "main.content.payment") {
jQuery("#phAmountTendered").focus();
}
} else {
return true;
}
}
/*
* Manage view after ajax request (hide or display different parts on site)
* 1) Hide categories for another views than products
* we use ajax and start parameter can be used for more items (products,
customers, orders) so we cannot leave it in url
* because if there are 100 products and 10 customers - switching to
customers per ajax will leave e.g. 50 which is will display zero results
* START IS SET ONLY WHEN CLICKING ON PAGINATION LINKS (see:
renderSubmitPaginationTopFor, it is removed directly by click)
*/
function phPosManagePage() {
var page = jQuery("#phPosPaginationBox input[name=page]").val();
if (page == "main.content.products") { // PRODUCTS
jQuery(".ph-pos-checkbox-box").show();
jQuery(".ph-pos-sku-product-box").show();
jQuery(".ph-pos-card-user-box").hide();
jQuery(".ph-pos-search-box").show();
jQuery(".ph-pos-date-order-box").hide();
phPosManagePageFocus(page);// Focus on start
} else if (page == "main.content.customers") { // CUSTOMERS
jQuery(".ph-pos-checkbox-box").hide();//categories
jQuery(".ph-pos-search-box").show();
jQuery(".ph-pos-card-user-box").show();
jQuery(".ph-pos-sku-product-box").hide();
jQuery(".ph-pos-date-order-box").hide();
phPosManagePageFocus(page);// Focus on start
} else if (page == "main.content.order") {// ORDER
jQuery(".ph-pos-checkbox-box").hide();//categories
jQuery(".ph-pos-search-box").hide();
jQuery(".ph-pos-card-user-box").hide();
jQuery(".ph-pos-sku-product-box").hide();
jQuery(".ph-pos-date-order-box").hide();
} else if (page == "main.content.orders") { // ORDERS
jQuery(".ph-pos-checkbox-box").hide();//categories
jQuery(".ph-pos-search-box").hide();
jQuery(".ph-pos-card-user-box").hide();
jQuery(".ph-pos-sku-product-box").hide();
jQuery(".ph-pos-date-order-box").show();
} else if (page == "main.content.paymentmethods") { // PAYMENT
METHODS
jQuery(".ph-pos-checkbox-box").hide();//categories
jQuery(".ph-pos-search-box").hide();
jQuery(".ph-pos-card-user-box").hide();
jQuery(".ph-pos-sku-product-box").hide();
jQuery(".ph-pos-date-order-box").hide();
phPosManagePageFocus(page);// Focus on start
} else if (page == "main.content.payment") { // PAYMENT
jQuery(".ph-pos-checkbox-box").hide();//categories
jQuery(".ph-pos-search-box").hide();
jQuery(".ph-pos-card-user-box").hide();
jQuery(".ph-pos-sku-product-box").hide();
jQuery(".ph-pos-date-order-box").hide();
phPosManagePageFocus(page);// Focus on start
} else {
jQuery(".ph-pos-checkbox-box").hide();//categories
jQuery(".ph-pos-search-box").hide();
jQuery(".ph-pos-card-user-box").hide();
jQuery(".ph-pos-sku-product-box").hide();
jQuery(".ph-pos-date-order-box").hide();
}
}
/* When adding new parameter to url bar, check if ? is there to set ? or
& */
function phAddSuffixToUrl(action, suffix) {
return action + (action.indexOf('?') != -1 ? '&' :
'?') + suffix;
}
/* Edit something in main view and then reload cart, main page, input page
*/
function phAjaxEditPos(sFormData, phUrlAjax, forcepageSuccess,
forcepageError) {
var phUrl = phAddSuffixToUrl(window.location.href,
'format=raw');
var phDataInput = phPosCurrentData("main.input");
var phDataCats = phPosCurrentData("main.categories");
var phDataCart = phPosCurrentData("main.cart",
"json");
phRequest = jQuery.ajax({
type: "POST",
url: phUrlAjax,
async: true,
cache: "false",
data: sFormData,
dataType:"JSON",
success: function(data){
if (data.status == 1){
if (data.id !== "undefined") {
var id = data.id;
} else {
var id = "";
}
var phDataMain = phPosCurrentData(forcepageSuccess, "raw",
id);
phDoSubmitFormUpdateCategoriesBox(phDataCats, phUrl);// refresh
categories box (when chaning users, users can have different access to
categories)
phRenderPage(phDataMain, phUrl);// reload main box to default (list of
products)
phDoSubmitFormUpdateInputBox(phDataInput, phUrl);// refresh input box
phDoSubmitFormUpdateCart(phDataCart);// reload updated cart
jQuery(".ph-pos-message-box").html(data.message);
} else if (data.status == 0){
var phDataMain = phPosCurrentData(forcepageError);
phRenderPage(phDataMain, phUrl);// reload main box to default (list of
products)
phDoSubmitFormUpdateInputBox(phDataInput, phUrl);// refresh input box
phDoSubmitFormUpdateCart(phDataCart);// reload updated cart
jQuery(".ph-pos-message-box").html(data.error);
}
}
})
return false;
}
/*
* Search by key type - typing of charcters into the search field FIND
MEMBER FUNCTION
*
* Must be loaded:
* renderSubmitPaginationTopForm()
* changeUrlParameter()
* editPos()
*/
function phFindMember(typeValue) {
var phData = "search=" + typeValue + "&" +
phPosCurrentData();
phUpdateUrlParameter("search", typeValue);
var phUrl = phAddSuffixToUrl(window.location.href,
'format=raw');//get the url after update
phRenderPage(phData, phUrl);
jQuery(".ph-pos-message-box").html("");// clear
message box
}
/* POS Scroll cart */
function phScrollPosCart(phPosCart) {
if (jQuery("#ph-msg-ns").length > 0){
phPosCart.animate({scrollTop: 0}, 1500 );
} else {
var phPosCartHeight = phPosCart[0].scrollHeight;
phPosCart.animate({scrollTop: phPosCartHeight}, 1500 );
}
}
function phConfirm(submitForm, dataPost, txt) {
//var phLang = Joomla.getOptions('phLangPC');
//var phLangOk = phLang['COM_PHOCACART_OK'];
//var phLangCancel = phLang['COM_PHOCACART_CANCEL'];
jQuery("#phDialogConfirm .modal-body" ).html( txt );
jQuery('#phDialogConfirm').modal();
jQuery('#phDialogConfirm').modal({ keyboard: false });
jQuery('#phDialogConfirm').modal('show') ;
jQuery("#phDialogConfirmSave").on("click",
function(e){
phPosCloseTicketFormConfirmed = true;
if (submitForm != "") {
jQuery(submitForm).submit();
} else if (typeof dataPost !== "undefined" && dataPost
!= "") {
//phDoRequest(dataPost);
}
return true;
});
return false;
}
// ------
// Events
// ------
jQuery(document).ready(function(){
/* Declare it on start (event associated to phPosManagePage function) */
phPosManagePage();
/*
* Clear form input after submit - for example, if vendor add products per
* bar scanner, after scanning the field must be empty for new product scan
* PRODUCTS, LOYALTY CARD
*/
jQuery(document).on("submit","#phPosSkuProductForm",function(){
setTimeout(function(){
jQuery("#phPosSku").val("");
}, 100);
});
jQuery(document).on("submit","#phPosCardUserForm",function(){
setTimeout(function(){
jQuery("#phPosCard").val("");
}, 100);
});
/* Test Bootstrap JS libraries */
var phLang = Joomla.getOptions('phLangPC');
var phScriptsLoaded = document.getElementsByTagName("script");
var bMinJs = "bootstrap.min.js";
var bJs = "bootstrap.js";
var bJsCount = 0;
jQuery.each(phScriptsLoaded, function (k, v) {
var s = v.src;
var n = s.indexOf("?")
s = s.substring(0, n != -1 ? n : s.length);
var filename =
s.split('\\\\').pop().split('/').pop();
if (filename == bMinJs || filename == bJs) {
bJsCount++;
}
})
if (bJsCount > 1){
jQuery("#phPosWarningMsgBox").text(phLang['COM_PHOCACART_WARNING_BOOTSTRAP_JS_LOADED_MORE_THAN_ONCE']);
jQuery("#phPosWarningMsgBox").show();
}
/* Load main content by links - e.g. in input box we call list of
customers, payment methods or shipping methods */
jQuery(document).on("click", ".loadMainContent",
function (e) {
phPosClearFilter();
var phUrl = phAddSuffixToUrl(window.location.href,
'format=raw');
var sForm = jQuery(this).closest("form");// Find in which
form the right button was clicked
var sFormData = sForm.serialize();
phRenderPage(sFormData, phUrl);
jQuery(".ph-pos-message-box").html("");// clean
message box
e.preventDefault();
});
/* Edit something in content area (e.g. customer list is loaded in main
content and we change it) */
jQuery(document).on("click", ".editMainContent",
function (e) {
phPosClearFilter();
var phUrl = phAddSuffixToUrl(window.location.href,
'format=json');
var sForm = jQuery(this).closest("form");// Find in which
form the right button was clicked
var sFormData = sForm.serialize();
var phRedirectSuccess =
sForm.find('input[name="redirectsuccess"]').val();
var phRedirectError =
sForm.find('input[name="redirecterror"]').val();
phAjaxEditPos(sFormData, phUrl, phRedirectSuccess, phRedirectError);
jQuery(".ph-pos-message-box").html("");// clean
message box
e.preventDefault();
});
/*
* Unfortunately we have form without buttons so we need to run the form
without click too
* to not submit more forms at once we will use ID :-(
*/
jQuery(document).on("submit", "#phPosCardUserForm",
function (e) {
phPosClearFilter();
var phUrl = phAddSuffixToUrl(window.location.href,
'format=json');
var sForm = jQuery("#phPosCardUserForm");
var sFormData = sForm.serialize();
phAjaxEditPos(sFormData, phUrl, "main.content.products",
"main.content.products");
jQuery(".ph-pos-message-box").html("");// clean
message box
e.preventDefault();
});
jQuery(document).on("submit", "#phPosDateOrdersForm",
function (e) {
phPosClearFilter();
var phUrl = phAddSuffixToUrl(window.location.href,
'format=raw');
var sForm = jQuery("#phPosDateOrdersForm");
var sFormData = sForm.serialize();
phRenderPage(sFormData, phUrl);// reload main box to default (list of
products)
jQuery(".ph-pos-message-box").html("");// clean
message box
e.preventDefault();
});
/* Display warning when closing a ticket */
phPosCloseTicketFormConfirmed = false;
jQuery(document).on("submit", "#phPosCloseTicketForm",
function (e) {
var txt = jQuery(this).data("txt");
if(!phPosCloseTicketFormConfirmed) {
phConfirm("#phPosCloseTicketForm", "", txt);
e.preventDefault();
return false;
} else {
phPosCloseTicketFormConfirmed = false;// set back the variable
return true;
}
});
/*
* Get all checkboxes of categories which are active and add them to url
bar and filter the categories
*
* Must be loaded:
* renderSubmitPaginationTopForm()
* changeUrlParameter()
* editPos()
*
* Test checkbox
* components\com_phocacart\views\pos\tmpl\default_main_categories.php
* data-toggle="buttons" - changes the standard checkbox to
graphical checkbox
*
*/
jQuery(document).on("change", "#phPosCategoriesBox
.phPosCategoryCheckbox", function() {
var phParams = Joomla.getOptions('phParamsPC');
var posFilterCategory = phParams['posFilterCategory'];
if (posFilterCategory == 2) {
// Multiple categories can be displayed - can be active
var phA = [];
jQuery("input.phPosCategoryCheckbox:checkbox:checked").each(function
() {
phA.push(jQuery(this).val());
})
var cValue = phA.join(",");
} else {
// Only one category can be displayed
// Deselect all checkboxed except the one selected - can be active
var cValue = jQuery(this).val();
jQuery("input.phPosCategoryCheckbox:checkbox:checked").each(function
() {
if (cValue != jQuery(this).val() ) {
jQuery(this).prop("checked", false);
jQuery("label.phCheckBoxCategory").removeClass("active");
}
})
// Current checkbox was deselected
if (jQuery(this).prop("checked") == false) {
cValue = "";
};
}
var phData = "category=" + cValue + "&" +
phPosCurrentData();
phUpdateUrlParameter("category", cValue);// update URL bar
var phUrl = phAddSuffixToUrl(window.location.href,
'format=raw');// get the link after update of url bar
phRenderPage(phData, phUrl);
jQuery(".ph-pos-message-box").html("");// clear
message box
});
/*
* Search by key type - typing of charcters into the search field FIND
MEMBER KEYUP
*
* Must be loaded:
* renderSubmitPaginationTopForm()
* changeUrlParameter()
* editPos()
*/
var phThread = null;
jQuery('#phPosSearch').keyup(function() {
clearTimeout(phThread);
var $this = jQuery(this);
phThread = setTimeout(function(){phFindMember($this.val())}, 800);
});
/* Print to POS printer */
jQuery("#phPosContentBox").on("click",
".phOrderPrintBtn", function (e) {
var phVars = Joomla.getOptions('phVarsPC');
var phParams = Joomla.getOptions('phParamsPC');
var posServerPrint = phParams['posServerPrint'];
var phUrlAjax = phVars['urlOrder'];
var phOrder = jQuery(this).data("order");
var phType = jQuery(this).data("type");
var phOrderCurrent =
jQuery("#phPosOrderPrintBox").attr("data-order");//
data("order"); not working
var phTypeCurrent =
jQuery("#phPosOrderPrintBox").attr("data-type");//
data("type"); not working
// PC PRINT
if (phType == "-1") {// -1 type is print (1 order, 2 invoice, 3
delivery note, 4 receipt)
if (posServerPrint == 2 || posServerPrint == 3) {
// - 1 AND 4 PC PRINT FOR ALL DOCUMENTS EXCEPT 4 (Receipt) - Receipt
will be printend by SERVER PRINT
if (phTypeCurrent == "4") {
var phUrlAjaxPrint = phAddSuffixToUrl(phUrlAjax, "id=" +
phOrder + "&type=" + phTypeCurrent +
"&pos=1&printserver=1");
phRequestPrint = jQuery.ajax({
type: "GET",
url: phUrlAjaxPrint,
async: true,
cache: "false",
dataType:"HTML",
success: function(data){
jQuery(".ph-pos-message-box").html('<div>'
+ data + '</div>');
// jQuery("#phPosOrderPrintBox").attr("class",
phClass);// Add class to box of document - to differentiate documents
loaded by ajax
//
jQuery("#phPosOrderPrintBox").attr("data-type",
phType);// Add data type to box of document - so it can be read by print
function
// jQuery("#phPosOrderPrintBox").html(data);// Add the
document itself to the site
}
})
e.preventDefault();
return false;
// -1 PC PRINT
} else {
window.print(); return false;// print with javascript for all
documents except receipt (receipt is ready for server POS printers)
}
} else {
window.print(); return false;// print with javascript for all document
(including receipt)
}
}
var phClass = "phType" + phType;
var phUrlAjax = phAddSuffixToUrl(phUrlAjax, "id=" + phOrder +
"&type=" + phType + "&pos=1");
phRequest = jQuery.ajax({
type: "GET",
url: phUrlAjax,
async: true,
cache: "false",
dataType:"HTML",
success: function(data){
jQuery("#phPosOrderPrintBox").attr("class",
phClass);// Add class to box of document - to differentiate documents
loaded by ajax
jQuery("#phPosOrderPrintBox").attr("data-type",
phType);// Add data type to box of document - so it can be read by print
function
jQuery("#phPosOrderPrintBox").html(data);// Add the document
itself to the site
}
})
e.preventDefault();
})
/* EVENT - POS Scroll cart */
var phPosCart = jQuery('#phPosCart');
phScrollPosCart(phPosCart);// On start
phPosCart.on("DOMSubtreeModified", function(){// On modified
if (phPosCart.text() != '') {// this event runs twice - first
when jquery empty the object, second when it fills it again
phScrollPosCart(phPosCart);// run only on second when it fills the
object
}
});
})
phocapos.min.js000064400000022000151171034350007472 0ustar00function
phUpdateUrlParameter(e,o,r){var t,a,n;if(void
0!==r?(a="",1<(n=(t=r).split("#")).length&&(a=n[1])):(t=window.location.href,a=location.hash),0<=(t=t.replace(a,"")).indexOf(e+"=")?t=t.substring(0,t.indexOf(e))+e+"="+o+(n=0<=(n=(n=t.substring(t.indexOf(e))).substring(n.indexOf("=")+1)).indexOf("&")?n.substring(n.indexOf("&")):""):t.indexOf("?")<0?t+="?"+e+"="+o:t+="&"+e+"="+o,t=t.replace(/[^=&]+=(&|$)/g,"").replace(/&$/,""),void
0!==r)return t+a;window.history.pushState(null,null,t+a)}function
phDoSubmitFormUpdateInputBox(e,o){return
phRequest=jQuery.ajax({type:"POST",url:o,async:!0,cache:"false",data:e,dataType:"HTML",success:function(e){jQuery("#phPosInputBox").html(e)}}),!1}function
phDoSubmitFormUpdateCategoriesBox(e,o){return"main.content.customers"!=jQuery("#phPosPaginationBox
input[name=page]").val()||(phRequest=jQuery.ajax({type:"POST",url:o,async:!0,cache:"false",data:e,dataType:"HTML",success:function(e){jQuery("#phPosCategoriesBox").html(e)}})),!1}function
phPosCurrentData(e,o,r){var
t=Joomla.getOptions("phVarsPC").token;return"format="+(void
0!==o?o:"raw")+"&tmpl=component&page="+(void
0!==e?e:jQuery("#phPosPaginationBox
input[name=page]").val())+(void
0!==r?"&id="+r:"")+"&ticketid="+jQuery("#phPosPaginationBox
input[name=ticketid]").val()+"&unitid="+jQuery("#phPosPaginationBox
input[name=unitid]").val()+"§ionid="+jQuery("#phPosPaginationBox
input[name=sectionid]").val()+"&"+t+"=1"}function
phPosClearFilter(){phUpdateUrlParameter("category",""),jQuery("input.phPosCategoryCheckbox:checkbox:checked").prop("checked",!1),jQuery("label.phCheckBoxCategory").removeClass("active"),phUpdateUrlParameter("search",""),jQuery("#phPosSearch").val("")}function
phPosManagePageFocus(e){if(1!=Joomla.getOptions("phParamsPC").posFocusInputFields)return!0;"main.content.products"==e?jQuery("#phPosSearch").is(":focus")||jQuery("#phPosSku").focus():"main.content.customers"==e?jQuery("#phPosSearch").is(":focus")||jQuery("#phPosCard").focus():"main.content.paymentmethods"==e?jQuery("#phPosSearch").is(":focus")||jQuery("#phcoupon").focus():"main.content.payment"==e&&jQuery("#phAmountTendered").focus()}function
phPosManagePage(){var e=jQuery("#phPosPaginationBox
input[name=page]").val();"main.content.products"==e?(jQuery(".ph-pos-checkbox-box").show(),jQuery(".ph-pos-sku-product-box").show(),jQuery(".ph-pos-card-user-box").hide(),jQuery(".ph-pos-search-box").show(),jQuery(".ph-pos-date-order-box").hide(),phPosManagePageFocus(e)):"main.content.customers"==e?(jQuery(".ph-pos-checkbox-box").hide(),jQuery(".ph-pos-search-box").show(),jQuery(".ph-pos-card-user-box").show(),jQuery(".ph-pos-sku-product-box").hide(),jQuery(".ph-pos-date-order-box").hide(),phPosManagePageFocus(e)):"main.content.order"==e?(jQuery(".ph-pos-checkbox-box").hide(),jQuery(".ph-pos-search-box").hide(),jQuery(".ph-pos-card-user-box").hide(),jQuery(".ph-pos-sku-product-box").hide(),jQuery(".ph-pos-date-order-box").hide()):"main.content.orders"==e?(jQuery(".ph-pos-checkbox-box").hide(),jQuery(".ph-pos-search-box").hide(),jQuery(".ph-pos-card-user-box").hide(),jQuery(".ph-pos-sku-product-box").hide(),jQuery(".ph-pos-date-order-box").show()):"main.content.paymentmethods"==e||"main.content.payment"==e?(jQuery(".ph-pos-checkbox-box").hide(),jQuery(".ph-pos-search-box").hide(),jQuery(".ph-pos-card-user-box").hide(),jQuery(".ph-pos-sku-product-box").hide(),jQuery(".ph-pos-date-order-box").hide(),phPosManagePageFocus(e)):(jQuery(".ph-pos-checkbox-box").hide(),jQuery(".ph-pos-search-box").hide(),jQuery(".ph-pos-card-user-box").hide(),jQuery(".ph-pos-sku-product-box").hide(),jQuery(".ph-pos-date-order-box").hide())}function
phAddSuffixToUrl(e,o){return
e+(-1!=e.indexOf("?")?"&":"?")+o}function
phAjaxEditPos(e,o,r,t){var
a=phAddSuffixToUrl(window.location.href,"format=raw"),n=phPosCurrentData("main.input"),s=phPosCurrentData("main.categories"),p=phPosCurrentData("main.cart","json");return
phRequest=jQuery.ajax({type:"POST",url:o,async:!0,cache:"false",data:e,dataType:"JSON",success:function(e){var
o;1==e.status?(o="undefined"!==e.id?e.id:"",o=phPosCurrentData(r,"raw",o),phDoSubmitFormUpdateCategoriesBox(s,a),phRenderPage(o,a),phDoSubmitFormUpdateInputBox(n,a),phDoSubmitFormUpdateCart(p),jQuery(".ph-pos-message-box").html(e.message)):0==e.status&&(o=phPosCurrentData(t),phRenderPage(o,a),phDoSubmitFormUpdateInputBox(n,a),phDoSubmitFormUpdateCart(p),jQuery(".ph-pos-message-box").html(e.error))}}),!1}function
phFindMember(e){var
o="search="+e+"&"+phPosCurrentData();phUpdateUrlParameter("search",e);e=phAddSuffixToUrl(window.location.href,"format=raw");phRenderPage(o,e),jQuery(".ph-pos-message-box").html("")}function
phScrollPosCart(e){var
o;0<jQuery("#ph-msg-ns").length?e.animate({scrollTop:0},1500):(o=e[0].scrollHeight,e.animate({scrollTop:o},1500))}function
phConfirm(o,e,r){return jQuery("#phDialogConfirm
.modal-body").html(r),jQuery("#phDialogConfirm").modal(),jQuery("#phDialogConfirm").modal({keyboard:!1}),jQuery("#phDialogConfirm").modal("show"),jQuery("#phDialogConfirmSave").on("click",function(e){return
phPosCloseTicketFormConfirmed=!0,""!=o&&jQuery(o).submit(),!0}),!1}jQuery(document).ready(function(){phPosManagePage(),jQuery(document).on("submit","#phPosSkuProductForm",function(){setTimeout(function(){jQuery("#phPosSku").val("")},100)}),jQuery(document).on("submit","#phPosCardUserForm",function(){setTimeout(function(){jQuery("#phPosCard").val("")},100)});var
e=Joomla.getOptions("phLangPC"),o=document.getElementsByTagName("script"),t=0;jQuery.each(o,function(e,o){var
r=o.src,o=r.indexOf("?"),r=(r=r.substring(0,-1!=o?o:r.length)).split("\\\\").pop().split("/").pop();"bootstrap.min.js"!=r&&"bootstrap.js"!=r||t++}),1<t&&(jQuery("#phPosWarningMsgBox").text(e.COM_PHOCACART_WARNING_BOOTSTRAP_JS_LOADED_MORE_THAN_ONCE),jQuery("#phPosWarningMsgBox").show()),jQuery(document).on("click",".loadMainContent",function(e){phPosClearFilter();var
o=phAddSuffixToUrl(window.location.href,"format=raw"),r=jQuery(this).closest("form").serialize();phRenderPage(r,o),jQuery(".ph-pos-message-box").html(""),e.preventDefault()}),jQuery(document).on("click",".editMainContent",function(e){phPosClearFilter();var
o=phAddSuffixToUrl(window.location.href,"format=json"),r=jQuery(this).closest("form");phAjaxEditPos(r.serialize(),o,r.find('input[name="redirectsuccess"]').val(),r.find('input[name="redirecterror"]').val()),jQuery(".ph-pos-message-box").html(""),e.preventDefault()}),jQuery(document).on("submit","#phPosCardUserForm",function(e){phPosClearFilter();var
o=phAddSuffixToUrl(window.location.href,"format=json");phAjaxEditPos(jQuery("#phPosCardUserForm").serialize(),o,"main.content.products","main.content.products"),jQuery(".ph-pos-message-box").html(""),e.preventDefault()}),jQuery(document).on("submit","#phPosDateOrdersForm",function(e){phPosClearFilter();var
o=phAddSuffixToUrl(window.location.href,"format=raw"),r=jQuery("#phPosDateOrdersForm").serialize();phRenderPage(r,o),jQuery(".ph-pos-message-box").html(""),e.preventDefault()}),phPosCloseTicketFormConfirmed=!1,jQuery(document).on("submit","#phPosCloseTicketForm",function(e){var
o=jQuery(this).data("txt");return
phPosCloseTicketFormConfirmed?!(phPosCloseTicketFormConfirmed=!1):(phConfirm("#phPosCloseTicketForm","",o),e.preventDefault(),!1)}),jQuery(document).on("change","#phPosCategoriesBox
.phPosCategoryCheckbox",function(){var
e,o;2==Joomla.getOptions("phParamsPC").posFilterCategory?(e=[],jQuery("input.phPosCategoryCheckbox:checkbox:checked").each(function(){e.push(jQuery(this).val())}),o=e.join(",")):(o=jQuery(this).val(),jQuery("input.phPosCategoryCheckbox:checkbox:checked").each(function(){o!=jQuery(this).val()&&(jQuery(this).prop("checked",!1),jQuery("label.phCheckBoxCategory").removeClass("active"))}),0==jQuery(this).prop("checked")&&(o=""));var
r="category="+o+"&"+phPosCurrentData();phUpdateUrlParameter("category",o);var
t=phAddSuffixToUrl(window.location.href,"format=raw");phRenderPage(r,t),jQuery(".ph-pos-message-box").html("")});var
r=null;jQuery("#phPosSearch").keyup(function(){clearTimeout(r);var
e=jQuery(this);r=setTimeout(function(){phFindMember(e.val())},800)}),jQuery("#phPosContentBox").on("click",".phOrderPrintBtn",function(e){var
o=Joomla.getOptions("phVarsPC"),r=Joomla.getOptions("phParamsPC").posServerPrint,t=o.urlOrder,a=jQuery(this).data("order"),n=jQuery(this).data("type"),o=(jQuery("#phPosOrderPrintBox").attr("data-order"),jQuery("#phPosOrderPrintBox").attr("data-type"));if("-1"==n){if(2!=r&&3!=r)return
window.print(),!1;if("4"!=o)return
window.print(),!1;o=phAddSuffixToUrl(t,"id="+a+"&type="+o+"&pos=1&printserver=1");return
phRequestPrint=jQuery.ajax({type:"GET",url:o,async:!0,cache:"false",dataType:"HTML",success:function(e){jQuery(".ph-pos-message-box").html("<div>"+e+"</div>")}}),e.preventDefault(),!1}var
s="phType"+n,t=phAddSuffixToUrl(t,"id="+a+"&type="+n+"&pos=1");phRequest=jQuery.ajax({type:"GET",url:t,async:!0,cache:"false",dataType:"HTML",success:function(e){jQuery("#phPosOrderPrintBox").attr("class",s),jQuery("#phPosOrderPrintBox").attr("data-type",n),jQuery("#phPosOrderPrintBox").html(e)}}),e.preventDefault()});var
a=jQuery("#phPosCart");phScrollPosCart(a),a.on("DOMSubtreeModified",function(){""!=a.text()&&phScrollPosCart(a)})});phocarequest.js000064400000022320151171034350007604
0ustar00/*
* @package Phoca Cart
* @author Jan Pavelka - https://www.phoca.cz
* @copyright Copyright (C) Jan Pavelka https://www.phoca.cz
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 and later
* @cms Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
*/
function phAppendContainerRequest() {
if (jQuery('#phContainerRequest').length === 0) {
jQuery("body").append('<div
id="phContainerRequest"></div>');
}
else {
// phContainerRequest exists
}
}
/* All popups can share one the same container but Quick View can be
displayed together with another popup
* so it must have own container
*/
function phAppendContainerRequestQickView() {
if (jQuery('#phContainerRequestQuickView').length === 0) {
jQuery("body").append('<div
id="phContainerRequestQuickView"></div>');
}
else {
// phContainerRequest exists
}
}
function phDoRequestSuccess(data, options) {
if (options['type'] == 'cart') {
/* Add to cart, update cart */
jQuery(options['class']).html(data.item);
jQuery(options['class'] + "Count").html(data.count);
jQuery(options['class'] + "Total").html(data.total);
if (options['pos'] == 1) {
var phUrlPos = phAddSuffixToUrl(window.location.href,
'format=raw');
var phDataInput = phPosCurrentData("main.input");
phDoSubmitFormUpdateInputBox(phDataInput, phUrlPos);// refresh input box
jQuery(".ph-pos-message-box").html(data.message);// clear
message box
phPosManagePage();
}
if (options['method'] == 2) {
phAppendContainerRequest();
jQuery("#phContainerRequest").html(data.popup);
jQuery("#phAddToCartPopup").modal();
}
if (options['method'] == 1) {
// If no popup is displayed we can reload the page when we are in
specific view. If popup, this will be done when clicking continue
if (options['view'] == 1) {
startFullOverlay(1);
setTimeout(function() {location.reload();}, 1);
}
}
} else if (options['type'] == 'compare') {
/* Comparison Add, Remove */
jQuery(".phItemCompareBox").html(data.item);
jQuery(".phItemCompareBoxCount").html(data.count);
if (options['method'] == 2) {
phAppendContainerRequest();
jQuery("#phContainerRequest").html(data.popup);
if (options['task'] == "add") {
jQuery("#phAddToComparePopup").modal();
} else if (options['task'] == "remove") {
jQuery("#phRemoveFromComparePopup").modal();
}
}
if (options['method'] == 1) {
// If no popup is displayed we can reload the page when we are in
specific view. If popup, this will be done when clicking continue
if (options['view'] == 1) {
startFullOverlay(1);
setTimeout(function() {location.reload();}, 1);
}
}
} else if (options['type'] == 'wishlist') {
/* Wishlist Add, Remove */
jQuery(".phItemWishListBox").html(data.item);
jQuery(".phItemWishListBoxCount").html(data.count);
if (options['method'] == 2) {
phAppendContainerRequest();
jQuery("#phContainerRequest").html(data.popup);
if (options['task'] == "add") {
jQuery("#phAddToWishListPopup").modal();
} else if (options['task'] == "remove") {
jQuery("#phRemoveFromWishListPopup").modal();
}
}
if (options['method'] == 1) {
// If no popup is displayed we can reload the page when we are in
specific view. If popup, this will be done when clicking continue
if (options['view'] == 1) {
startFullOverlay(1);
setTimeout(function() {location.reload();}, 1);
}
}
} else if (options['type'] == 'quickview') {
/* Quick View */
jQuery(".phjItemQuick.phjProductAttribute").remove();// Clear
attributes from dom when ajax reload
//jQuery("body").append(jQuery("#phContainer"));
phAppendContainerRequestQickView();
jQuery("#phContainerRequestQuickView").html(data.popup);
//jQuery("#phContainer").html(data.popup);
//jQuery("body").append(jQuery("#phQuickViewPopup"));
jQuery("#phQuickViewPopup").modal();
if (options['load_chosen'] > 0) {
jQuery('select').chosen('destroy').chosen({disable_search_threshold
: 10,allow_single_deselect : true});
}
phChangeAttributeType('ItemQuick');
if (options['quantity_input_spinner'] > 0) {
jQuery("input[name='quantity']:visible").TouchSpin({
verticalbuttons: true,
verticalup: options["icon_spinner_verticalup"],
verticaldown: options["icon_spinner_verticaldown"]
})
}
} else if (options['type'] == 'changedata') {
/* Change Image */
if( data.item.image !== undefined && data.item.image !==
'' ) {
if (options['method_image'] == 2) {
var phProductImg = '.phjProductImage' +
options["id_item_name"];
var phProductSource = '.phjProductSource' +
options["id_item_name"];// Webp source
var phProductHref = '.phjProductHref' +
options["id_item_name"];
// New image found - change to new image
jQuery(phProductHref).attr('href', data.item.image);
jQuery(phProductImg).attr('src', data.item.image);
jQuery(phProductSource).attr('srcset',
data.item.image);//webp
}
}
/* Change Price */
if( data.item.price !== undefined ) {
jQuery(options["id_item_price"]).html(data.item.price);
// Change also Gift voucher if displayed
jQuery(options["id_item_price_gift"]).html(data.item.priceitems.bruttoformat);
}
/* Change ID (SKU, EAN, ...) */
if( data.item.id !== undefined ) {
jQuery(options["id_item_id"]).html(data.item.id);
}
if( data.item.stock !== undefined ) {
if (options['method_stock'] == 1) {
//if (data.item.stockvalue < 1) {
if (data.item.hideaddtocart == 1) {
//jQuery(phProductAddToCart).hide();';
jQuery(options["product_add_to_cart_item"]).css('visibility',
'hidden');
jQuery(options["product_add_to_cart_item_icon"]).css('display',
'none');
} else {
//jQuery(phProductAddToCart).show();';
jQuery(options["product_add_to_cart_item"]).css('visibility',
'visible');
jQuery(options["product_add_to_cart_item_icon"]).css('display',
'block');
}
}
jQuery(options["id_item_stock"]).html(data.item.stock);
}
} /*else if (options['type'] == 'changeprice') {
/* Change Price *//*
jQuery(options["id_item"]).html(data.item);
} else if (options['type'] == 'changeid') {
/* Change ID (SKU, EAN, ...) *//*
jQuery(options["id_item"]).html(data.item);
} else if (options['type'] == 'changestock') {
/* Change Stock *//*
if (options['method'] == 1) {
if (data.stock < 1) {
//jQuery(phProductAddToCart).hide();';
jQuery(options["product_add_to_cart_item"]).css('visibility',
'hidden');
jQuery(options["product_add_to_cart_item_icon"]).css('display',
'none');
} else {
//jQuery(phProductAddToCart).show();';
jQuery(options["product_add_to_cart_item"]).css('visibility',
'visible');
jQuery(options["product_add_to_cart_item_icon"]).css('display',
'block');
}
}
jQuery(options["id_item"]).html(data.item);
}*/
}
function phDoRequestError(data, options) {
if (options['type'] == 'cart') {
/* Add to cart, update cart */
if (options['pos'] == 1) {
jQuery(".ph-pos-message-box").html(data.error);// clear
message box
phPosManagePage();
}
if (options['method'] != 2) {
jQuery(".phItemCartBox").html(data.error);
}
if (options['method'] == 2) {
phAppendContainerRequest();
jQuery("#phContainerRequest").html(data.popup);
jQuery("#phAddToCartPopup").modal();
}
if (options['method'] == 1) {
// If no popup is displayed we can reload the page when we are in
specific view. If popup, this will be done when clicking continue
if (options['view'] == 1) {
startFullOverlay(1);
setTimeout(function() {location.reload();}, 1);
}
}
}
}
/*
* type ... compare
* view ... is compare view or not
* task ... add/remove
* method ... popup method: no ajax, ajax without popup, ajax with popup
* url ... ajax url
* data ... ajax data
*/
function phDoRequestMethods(url, data, options) {
phRequest = jQuery.ajax({
type: "POST",
url: url,
async: "false",
cache: "false",
data: data,
dataType:"JSON",
success: function(data){
if (data.status == 1){
phDoRequestSuccess(data, options);
} else if (data.status == 0){
phDoRequestError(data, options);
} else {
// No change
}
}
})
return false;
}
// ------
// Events
// ------
jQuery(document).ready(function(){
/* Add to cart, update cart */
// :: EVENT (SUBMIT) Item View
//jQuery(".phItemCartBoxForm").on(\'submit\', function
(e) {// Not working when form is added by ajax
jQuery(document).on("submit",
"form.phItemCartBoxForm", function (e) { // Works with forms
added by ajax
if (typeof phDoSubmitFormAddToCart === "function") {
e.preventDefault();
var sFormData = jQuery(this).serialize();
phDoSubmitFormAddToCart(sFormData);
}
})
/* Update cart only in POS */
// ::EVENT (CLICK) Change Layout Type Clicking on Grid, Gridlist, List
jQuery(document).on("click", "#ph-pc-pos-site
form.phItemCartUpdateBoxForm button", function (e) {
if (typeof phDoSubmitFormAddToCart === "function") {
e.preventDefault();
var sForm = jQuery(this).closest("form");// Find in which
form the right button was clicked
var phAction= jQuery(this).val();
var sFormData = sForm.serialize() + "&action=" + phAction;
phDoSubmitFormUpdateCart(sFormData);
}
})
})
phocarequest.min.js000064400000010134151171034350010366 0ustar00function
phAppendContainerRequest(){0===jQuery("#phContainerRequest").length&&jQuery("body").append('<div
id="phContainerRequest"></div>')}function
phAppendContainerRequestQickView(){0===jQuery("#phContainerRequestQuickView").length&&jQuery("body").append('<div
id="phContainerRequestQuickView"></div>')}function
phDoRequestSuccess(e,t){var
o,i,r;"cart"==t.type?(jQuery(t.class).html(e.item),jQuery(t.class+"Count").html(e.count),jQuery(t.class+"Total").html(e.total),1==t.pos&&(r=phAddSuffixToUrl(window.location.href,"format=raw"),i=phPosCurrentData("main.input"),phDoSubmitFormUpdateInputBox(i,r),jQuery(".ph-pos-message-box").html(e.message),phPosManagePage()),2==t.method&&(phAppendContainerRequest(),jQuery("#phContainerRequest").html(e.popup),jQuery("#phAddToCartPopup").modal()),1==t.method&&1==t.view&&(startFullOverlay(1),setTimeout(function(){location.reload()},1))):"compare"==t.type?(jQuery(".phItemCompareBox").html(e.item),jQuery(".phItemCompareBoxCount").html(e.count),2==t.method&&(phAppendContainerRequest(),jQuery("#phContainerRequest").html(e.popup),"add"==t.task?jQuery("#phAddToComparePopup").modal():"remove"==t.task&&jQuery("#phRemoveFromComparePopup").modal()),1==t.method&&1==t.view&&(startFullOverlay(1),setTimeout(function(){location.reload()},1))):"wishlist"==t.type?(jQuery(".phItemWishListBox").html(e.item),jQuery(".phItemWishListBoxCount").html(e.count),2==t.method&&(phAppendContainerRequest(),jQuery("#phContainerRequest").html(e.popup),"add"==t.task?jQuery("#phAddToWishListPopup").modal():"remove"==t.task&&jQuery("#phRemoveFromWishListPopup").modal()),1==t.method&&1==t.view&&(startFullOverlay(1),setTimeout(function(){location.reload()},1))):"quickview"==t.type?(jQuery(".phjItemQuick.phjProductAttribute").remove(),phAppendContainerRequestQickView(),jQuery("#phContainerRequestQuickView").html(e.popup),jQuery("#phQuickViewPopup").modal(),0<t.load_chosen&&jQuery("select").chosen("destroy").chosen({disable_search_threshold:10,allow_single_deselect:!0}),phChangeAttributeType("ItemQuick"),0<t.quantity_input_spinner&&jQuery("input[name='quantity']:visible").TouchSpin({verticalbuttons:!0,verticalup:t.icon_spinner_verticalup,verticaldown:t.icon_spinner_verticaldown})):"changedata"==t.type&&(void
0!==e.item.image&&""!==e.item.image&&2==t.method_image&&(o=".phjProductImage"+t.id_item_name,i=".phjProductSource"+t.id_item_name,r=".phjProductHref"+t.id_item_name,jQuery(r).attr("href",e.item.image),jQuery(o).attr("src",e.item.image),jQuery(i).attr("srcset",e.item.image)),void
0!==e.item.price&&(jQuery(t.id_item_price).html(e.item.price),jQuery(t.id_item_price_gift).html(e.item.priceitems.bruttoformat)),void
0!==e.item.id&&jQuery(t.id_item_id).html(e.item.id),void
0!==e.item.stock&&(1==t.method_stock&&(1==e.item.hideaddtocart?(jQuery(t.product_add_to_cart_item).css("visibility","hidden"),jQuery(t.product_add_to_cart_item_icon).css("display","none")):(jQuery(t.product_add_to_cart_item).css("visibility","visible"),jQuery(t.product_add_to_cart_item_icon).css("display","block"))),jQuery(t.id_item_stock).html(e.item.stock)))}function
phDoRequestError(e,t){"cart"==t.type&&(1==t.pos&&(jQuery(".ph-pos-message-box").html(e.error),phPosManagePage()),2!=t.method&&jQuery(".phItemCartBox").html(e.error),2==t.method&&(phAppendContainerRequest(),jQuery("#phContainerRequest").html(e.popup),jQuery("#phAddToCartPopup").modal()),1==t.method&&1==t.view&&(startFullOverlay(1),setTimeout(function(){location.reload()},1)))}function
phDoRequestMethods(e,t,o){return
phRequest=jQuery.ajax({type:"POST",url:e,async:"false",cache:"false",data:t,dataType:"JSON",success:function(e){1==e.status?phDoRequestSuccess(e,o):0==e.status&&phDoRequestError(e,o)}}),!1}jQuery(document).ready(function(){jQuery(document).on("submit","form.phItemCartBoxForm",function(e){"function"==typeof
phDoSubmitFormAddToCart&&(e.preventDefault(),e=jQuery(this).serialize(),phDoSubmitFormAddToCart(e))}),jQuery(document).on("click","#ph-pc-pos-site
form.phItemCartUpdateBoxForm button",function(e){var
t;"function"==typeof
phDoSubmitFormAddToCart&&(e.preventDefault(),t=jQuery(this).closest("form"),e=jQuery(this).val(),e=t.serialize()+"&action="+e,phDoSubmitFormUpdateCart(e))})});