妖精的口袋 - 春装新品上线,特价优惠中
}, dialog = this.dialog = new Element('div#mini_cart_dialog.popup-container.mini-cart-dialog',{
'html': $('popup_template').get('html').substitute(options),
display:'block',
zIndex: maxZindex('div', 1)
}).inject(document.body);
this.title = dialog.getElement('.popup-header h2');
this.close = dialog.getElements('.popup-btn-close');
this.content = dialog.getElement('.popup-content');
this.dialog.addEvent('click:relay(.popup-btn-close)',this.hide.bind(this));
var setSize = this.setSize = function(){
if(!dialog.isDisplayed())
dialog.setStyles({
top:target.getPosition().y+target.getSize().y,
left:target.getPosition().x.limit(0,window.getSize().x-dialog.getSize().x) + window.getScroll().x
setSize();
window.addEvent('resize',setSize);
'hide':function(){
this.dialog.destroy();
window.removeEvent('resize',this.setSize);
}catch(e){}
'load':function(options){
options = options || {};
options = Object.merge({
method: 'post',
onRequest: function(){
miniCart.show(options.target);
onSuccess: function(re){
this.title.innerHTML = '提醒';
this.content.innerHTML =
updateCartInfo();
if(document.getElement('.minicart_box')&&document.getElement('.minicart_box').get('show_gallery')){
document.getElement('.minicart_box').fireEvent('_show'); //迷你购物车
options.callback && options.callback(re);
}.bind(this),
onFailure: function(xhr){
this.title.innerHTML = '提醒';
this.content.innerHTML = '加入购物车失败。可能库存不足或提交信息不完整。';
}.bind(this)
},options||{});
if(!options.url)
new Request(options).send(options.data ? options.data.toQueryString() + '&mini_cart=true' : 'mini_cart=true');
init:function(target, url, data){
if(typeOf(target) == 'element') linktocart = target.getElements('[target=_dialog_minicart]');
else if(typeOf(target) == 'elements') linktocart =
else linktocart = $$('a[target=_dialog_minicart], button[target=_dialog_minicart]');
if(linktocart.length){
linktocart.addEvent('click',function(e){
e.preventDefault();
miniCart.load({url: url || this.href, data: data || this.getParent('.goods-item') || this.getParent('li'), target: this});
formToCart = function(container,target) {
container = $(container || document.body);
target = target || '.action-addtocart';
if(!container)
var formtocart = container.getElement('form[target=_dialog_minicart]') || container.getFirst().getParent('form[target=_dialog_minicart]');
if(formtocart) {
formtocart.addEvent('submit', function(e){
target = this.getElement(target) || this.getElement('*[type=submit]');
miniCart.load({
url:this.action,
method:this.method,
data:this,
target: target,
callback: function() {
target.removeClass('disabled');
}.bind(this)
window.addEvent('domready',function(){
miniCart.init();
formToCart();
Powered By