All graphic styles have a /js/main.js file, which configures the Shop class and creates its instance. All the code is shut down in term
if($chk(window.Shop)
)
{
....
}
This allows you to avoid mistakes in the absence of a Shop.
selectorFunctions
Shop.
implement({
selectorFunctions
:
{
gotourl
:
{
selector
:
'.gotourl',
domready
:
function(el)
{
el.
removeEvents('change').addEvent
(
'change',
function(e)
{
new
Event
(e).stop();
if
(this.value.length)
window.
location.href
=
this.value;
});
}
},
bottest
:
{
....
}
});
Functions performed on the certain elements of the DOM.
-
gotourl - <select> with class gotourl, event onChange This takes you to the address of the value
-
bottest - remove all elements with this class, it is one of the tests that allows you to filter bots throwing spam in forms (they do not support JavaScript)
-
clickhide - the disappearance of the item in the event onClick, protection against double clicking an order
-
titlealert -s how message with the content contained in the title in the event onClick, link Add a comment to a product when the user is not logged in
-
titlequestion - go to the address of the link before obtaining prior confirmation questions of title, delete entries from the address book the user
-
nojs - giving all input[name=nojs] value equal to 0, and cross-Variant used in the products passes an application whether the variant selection was limited only to existing, using JavaScript
-
box_producers_select - setting the selected manufacturer's <select> module manufacturers, on the basis of the current address party; the current selection is not made on the side of the PHP/tpl in order to speed up page
-
resetsubmit - clears all inputs around in form and sending it, click on filter cleaning products
-
reset - Clears all inputs around the
-
flashmessageclose - destroy the message, eg. to add to the shopping cart using link „ close ”
-
popupsmall - open link in new window has supplied sizes
-
popup - open link in new tab window
-
basketsubmit - to verify that input[name^=stock_id] in the add to Cart button is set, otherwise the alert of the need to select product option
-
boxslider - support for horizontal scroll in all modules with class slider
-
comment - hide the form add a comment at the start of the
-
addcomment - the unveiling of the form to add a comment and scroll the page to the link „Add opinion”
-
minigalleryhover -change the main product images when you hover on a small photo below it, the address must be in the altsmaller photos
-
foldenbox - collapse modules with class folden, used in the filter products (search)
-
productimg - If img.productimg has the class gallery_ID This means that the product has a gallery of more than one photo; because the main picture is a duplicate (for the top and in the gallery), the first instance cannot be closed <a rel=„milkbox:gall”> - It would also his duplication in Milkbox; Therefore, it receives an event onClick, that is submitted to a #prodimgID simulating a click on the first picture from the Gallery
perBrowserFix
Shop.
implement({
perBrowserFix
:
{
chrome
:
function()
{
$$
('.centercol input',
'.centercol button').each(function
(
el
)
{
if(el.get('value'
)
.
length
>
0
&&
el.
get('name').match
(
/(mail|pass|login)/))
{
el.
focus();
el.
blur();
}
});
},
ie67
:
function()
{
....
}
});
Functions performed certain browsers.
-
chrome - attempt to remove the yellow background with <input> fields, login by giving focus
-
ie6 and ie7 - the necessary corrections to an improperly operating browsers
in-class.
skinPreviewBox
Shop.
skinPreviewBox.condition
=
function()
{
return
!!('string'
==
typeOf(Cookie.read('skinpreview'
)
)
&&
Cookie.
read('skinpreview').length
)
;
}
Closing style preview should appear only when there is a cake called skinpreview.
imageSlider
Shop.
imageSlider.condition
=
function()
{
var
div
=
$$
('#box_productfull .productimg .smallgallery')[0
]
;
if($chk(div))
{
Shop.
imageSlider.options
=
{
container
:
div
,
left_arrow_img
:
this.url('images/so_left.png',
true
),
right_arrow_img
:
this.url('images/so_right.png',
true
)
};
return
true;
}
else
{
return
false;
};
}
Scroll page works only when there is a container with class smallgallery of card products.
imageZoom
Shop.
imageZoom.condition
=
function()
{
var
img
=
$$
('img.innerzoom')[0]
;
if(!$chk(img))
img
=
$$
('img.outerzoom')[0]
;
if($chk(img))
{
Shop.
imageZoom.options
=
{
img
:
img
,
inner
:
img.
hasClass('innerzoom')
};
return
true;
}
else
{
return
false;
};
}
Enlarge the image product works only when its <img> a given class innerzoom or outerzoom.
basketHandler
Shop.
basketHandler.condition
=
function()
{
if($chk($('box_basketlist'
)
))
{
Shop.
basketHandler.options
=
{
step
:
1,
containers
:
{
step1
:
$$
('#box_basketlist table.productlist tfoot').pop
(
)
},
selectors
:
{
deliveryrow
:
'tr.delivery',
paymentrow
:
'tr.payment',
deliverychangelink
:
'tr.deliveryhead em.fold a',
paymentchangelink
:
'tr.paymenthead em.fold a',
paymentheadlabel
:
'tr.paymenthead td.desc em.color',
paymentrlabel
:
'td.name label',
paymentradios
:
'tr.payment input[type=radio]',
deliveryradios
:
'tr.delivery input[type=radio]',
deliveryheadlabel
:
'tr.deliveryhead td.desc em.color',
deliveryheadvalue
:
'tr.deliveryhead td.value em.color',
deliverytrlabel
:
'td.name label',
deliverytrvalue
:
'td.value',
trradio
:
'input[type=radio]',
countrytr
:
'tr.deliverycountry',
trcountryselect
:
'select'
},
ordersumfield
:
$$
('#box_basketlist table.productlist tfoot tr.sum td.value').pop
(
)
};
return
true;
}
if($chk($('box_basketaddress'
)
))
{
Shop.
basketHandler.options
=
{
step
:
2,
containers
:
{
step2
:
$
('box_basketaddress')
},
selectors
:
{
trdifferentaddress
:
'tr.different',
differentaddress
:
'input[name=different]',
personaladdress
:
'#address_type1',
companyaddress
:
'#address_type2',
formcompanyname
:
'input[name=coname]',
formtaxid
:
'input[name=nip]',
formcompanyname2
:
'input[name=coname2]',
formtaxid2
:
'input[name=nip2]',
countryselect
:
'select[name=country]',
addresstyperadios
:
'input[type=radio][name^=address_type]',
addressselectsubmit
:
'*[type=submit][name^=address_submit]',
addressselect
:
'select[name^=address]',
addressinput
:
'*[name={name}]'
},
getaddressurl
:
'panel/getaddress/id/{id}'
};
return
true;
}
return
false;
}
Shopping cart support Depending on the presence of the module #box_basketlist (step one) or #box_basketaddress (step 2, type the address).
productVoter
Shop.
productVoter.condition
=
function()
{
var
span
=
$$
('span.votestars')[0]
;
return
!!($chk(span)
&&
span.
get('id'));
}
Voting for the product only when there is span.votestars and has a given id.
fadingText
Shop.
fadingText.condition
=
Function.from(true);
Since the dynamic text fields <input> works only for those selected Selector no need to restrict it further condition.
stockDownloader
Shop.
stockDownloader.condition
=
Function.from(true);
Shop.
stockDownloader.options
=
{
getstockurl
:
'product/getstock/stock/{sid}/imgwidth/{imgwidth}/imgheight/{imgheight}',
selectors
:
{
stockid
:
'#box_productfull form.basket input[name^=stock_id]',
productimg
:
'#box_productfull td.productimg img.productimg',
ddavailability
:
'#box_productfull td.availability dd.availability',
dddelivery
:
'#box_productfull td.availability dd.delivery',
dtdelivery
:
'#box_productfull td.availability dt.delivery',
price
:
'#box_productfull table.maininfo div.price',
nettoprice
:
'#box_productfull table.maininfo div.nettoprice',
addtofav
:
'#box_productfull .additionalinfo a.addtofav',
basketform
:
'#box_productfull form.basket fieldset',
unit
:
'#box_productfull form.basket span.unit',
smallgallery
:
'#box_productfull .smallgallery a img'
}
}
Since the download options Product is only produced by service options, it is not necessary condition for the next operation.
stockHandler
Shop.
stockHandler.condition
=
function()
{
if($chk(Shop.values.OptionsConfiguration
)
)
{
Shop.
stockHandler.options
=
{
selectstockselector
:
'div.stocks select',
inputselector
:
'#box_productfull form.basket input[name^=stock_id]'
};
return
true;
}
else
{
return
false;
}
}
inclusion service options only when defined is same map variants.
Options
Shop.
useroptions.slider
=
{
fadearrows
:
false
}
-
fadearrows - hide the arrow keys left/right in the modules with a scrollable list of products until invade the area list
Call Shop
At the end of the file is the code that creates an instance of the Shop class in the event of domready.
window.
addEvent('domready',
function
()
{
window.
ShopInstance
=
new
Shop
();
});