PageSourceSearch

https://www.bestbassgear.com/skin/frontend/base/default/js/msrp.js?q=051216

js bestbassgear.com collected 2026-10-02 17:58:37 UTC 13,233 bytes, 367 lines download raw bytes

1/**
2 * Magento
3 *
4 * NOTICE OF LICENSE
5 *
6 * This source file is subject to the Academic Free License (AFL 3.0)
7 * that is bundled with this package in the file LICENSE_AFL.txt.
8 * It is also available through the world-wide-web at this URL:
9 * http://opensource.org/licenses/afl-3.0.php
10 * If you did not receive a copy of the license and are unable to
11 * obtain it through the world-wide-web, please send an email
12 * to [email protected] so we can send you a copy immediately.
13 *
14 * DISCLAIMER
15 *
16 * Do not edit or add to this file if you wish to upgrade Magento to newer
17 * versions in the future. If you wish to customize Magento for your
18 * needs please refer to http://www.magento.com for more information.
19 *
20 * @category    design
21 * @package     base_default
22 * @copyright   Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
23 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
24 */
25if (!window.Catalog) {
26    window.Catalog = {};
27}
28
29Catalog.Map = {
30
31    helpLinks: [],
32
33    active: false,
34
35    addHelpLink: function(linkElement, title, actualPrice, msrpPrice, addToCartLink) {
36        if (typeof linkElement == 'string') {
37            linkElement = $$(linkElement)[0];
38        }
39
40        if (!linkElement) {
41            return;
42        }
43
44        var helpLink = {
45            'link': linkElement
46        };
47
48        var showPopup = false;
49
50        if (typeof title == 'string' && title) {
51            helpLink.title = title;
52            showPopup = true;
53        }
54
55        if (typeof actualPrice == 'string' && actualPrice || typeof actualPrice == 'object' && actualPrice) {
56            helpLink.price = actualPrice;
57            showPopup = true;
58        }
59
60        if (typeof msrpPrice == 'string' && msrpPrice) {
61            helpLink.msrp = msrpPrice;
62            showPopup = true;
63        }
64
65        if (typeof addToCartLink == 'string' && addToCartLink) {
66            helpLink.cartLink = addToCartLink;
67        } else if (addToCartLink && addToCartLink.url) {
68            helpLink.cartLink = addToCartLink.url;
69            if (addToCartLink.qty) {
70                helpLink.qty = addToCartLink.qty;
71            }
72            if (addToCartLink.notUseForm) {
73                helpLink.notUseForm = addToCartLink.notUseForm;
74            }
75        }
76
77        if (!showPopup) {
78            this.setGotoView(linkElement, addToCartLink);
79        } else {
80            var helpLinkIndex = this.helpLinks.push(helpLink) - 1;
81            Event.observe(linkElement, 'click', this.showHelp.bind(this.helpLinks[helpLinkIndex]));
82        }
83        return helpLink;
84    },
85
86    setGotoView: function(element, viewPageUrl) {
87        $(element).stopObserving('click');
88        element.href = viewPageUrl;
89        if(window.opener) {
90            Event.observe(element, 'click', function(event) {
91                setPLocation(this.href,true);
92                Catalog.Map.hideHelp();
93                event.stop();
94            });
95        } else {
96            Event.observe(element, 'click', function(event) {
97                setLocation(this.href);
98                Catalog.Map.hideHelp();
99                event.stop();
100            });
101        }
102    },
103
104    showSelects: function() {
105        var elements = document.getElementsByTagName("select");
106        for (i=0;i< elements.length;i++) {
107            elements[i].style.visibility='visible';
108        }
109    },
110
111    hideSelects: function() {
112        var elements = document.getElementsByTagName("select");
113        for (i=0;i< elements.length;i++) {
114            elements[i].style.visibility='hidden';
115        }
116    },
117
118    showHelp: function(event) {
119        var helpBox = $('map-popup'),
120            isIE6 = typeof document.body.style.maxHeight === "undefined";
121        if (!helpBox) {
122            return;
123        }
124
125        //Move help box to be right in body tag
126        var bodyNode = $$('body')[0];
127        if (helpBox.parentNode != bodyNode) {
128            helpBox.remove();
129            bodyNode.insert(helpBox);
130            // Fix for FF4-FF5 bug with missing alt text after DOM manipulations
131            var paypalImg = helpBox.select('.paypal-logo > a > img')[0];
132            if (paypalImg) paypalImg.src = paypalImg.src;
133        }
134
135        if (this != Catalog.Map && Catalog.Map.active != this.link) {
136            helpBox.style.display = 'none';
137            if (!helpBox.offsetPosition) {
138                helpBox.offsetPosition = {left:0, top: 0};
139            }
140
141            helpBox.removeClassName('map-popup-right');
142            helpBox.removeClassName('map-popup-left');
143            if (Element.getWidth(bodyNode) < event.pageX + Element.getWidth(helpBox)) {
144                helpBox.addClassName('map-popup-left');
145            } else if (event.pageX - Element.getWidth(helpBox) < 0) {
146                helpBox.addClassName('map-popup-right');
147            }
148
149            helpBox.style.left = event.pageX - (Element.getWidth(helpBox) / 2) + 'px';
150            helpBox.style.top = event.pageY + 10 + 'px';
151
152            //Title
153            var mapTitle = $('map-popup-heading');
154            if (typeof this.title != 'undefined') {
155                Element.update(mapTitle, this.title);
156                $(mapTitle).show();
157            } else {
158                $(mapTitle).hide();
159            }
160
161            //MSRP price
162            var mapMsrp = $('map-popup-msrp-box');
163            if (typeof this.msrp != 'undefined') {
164                Element.update($('map-popup-msrp'), this.msrp);
165                $(mapMsrp).show();
166            } else {
167                $(mapMsrp).hide();
168            }
169
170            //Actual price
171            var mapPrice = $('map-popup-price-box');
172            if (typeof this.price != 'undefined') {
173                var price = typeof this.price == 'object' ? this.price.innerHTML : this.price;
174                Element.update($('map-popup-price'), price);
175                $(mapPrice).show();
176            } else {
177                $(mapPrice).hide();
178            }
179
180            //`Add to cart` button
181            var cartButton = $('map-popup-button');
182            if (typeof this.cartLink != 'undefined') {
183                if (typeof productAddToCartForm == 'undefined' || this.notUseForm) {
184                    Catalog.Map.setGotoView(cartButton, this.cartLink);
185                    productAddToCartForm = $('product_addtocart_form_from_popup');
186                } else {
187                    if (this.qty) {
188                        productAddToCartForm.qty = this.qty;
189                    }
190                    cartButton.stopObserving('click');
191                    cartButton.href = this.cartLink;
192                    Event.observe(cartButton, 'click', function(event) {
193                        productAddToCartForm.action = this.href;
194                        productAddToCartForm.submit(this);
195                    });
196                }
197                productAddToCartForm.action = this.cartLink;
198                var productField = $('map-popup-product-id');
199                productField.value = this.product_id;
200                $(cartButton).show();
201                $$('.additional-addtocart-box').invoke('show');
202            } else {
203                $(cartButton).hide();
204                $$('.additional-addtocart-box').invoke('hide');
205            }
206
207            //Horizontal line
208            var mapText = $('map-popup-text'),
209                mapTextWhatThis = $('map-popup-text-what-this'),
210                mapContent = $('map-popup-content');
211            if (!mapMsrp.visible() && !mapPrice.visible() && !cartButton.visible()) {
212                //If just `What's this?` link
213                $(mapText).hide();
214                $(mapTextWhatThis).show();
215                $(mapTextWhatThis).removeClassName('map-popup-only-text');
216                $(mapContent).hide().setStyle({visibility: 'hidden'});
217                $('product_addtocart_form_from_popup').hide();
218            } else {
219                $(mapTextWhatThis).hide();
220                $(mapText).show();
221                $(mapText).addClassName('map-popup-only-text');
222                $(mapContent).show().setStyle({visibility: 'visible'});
223                $('product_addtocart_form_from_popup').show();
224            }
225
226            $(helpBox).show();
227            if (isIE6) {
228                Catalog.Map.hideSelects();
229            }
230            var closeButton = $('map-popup-close');
231            if (closeButton) {
232                $(closeButton).stopObserving('click');
233                Event.observe(closeButton, 'click', Catalog.Map.showHelp.bind(this));
234                Catalog.Map.active = this.link;
235            }
236        } else {
237            $(helpBox).hide();
238            if (isIE6) {
239                Catalog.Map.showSelects();
240            }
241            Catalog.Map.active = false;
242        }
243
244        Event.stop(event);
245    },
246
247    hideHelp: function(){
248        var helpBox = $('map-popup');
249        if (helpBox) {
250            var isIE6 = typeof document.body.style.maxHeight === "undefined";
251            $(helpBox).hide();
252            if (isIE6) {
253                Catalog.Map.showSelects();
254            }
255            Catalog.Map.active = false;
256        }
257    },
258
259    bindProductForm: function(){
260        if (('undefined' != typeof productAddToCartForm) && productAddToCartForm) {
261            productAddToCartFormOld = productAddToCartForm;
262            productAddToCartForm = new VarienForm('product_addtocart_form_from_popup');
263            productAddToCartForm.submitLight = productAddToCartFormOld.submitLight;
264        } else if(!$('product_addtocart_form_from_popup')) {
265            return false;
266        } else if ('undefined' == typeof productAddToCartForm) {
267            productAddToCartForm = new VarienForm('product_addtocart_form_from_popup');
268        }
269
270        productAddToCartForm.submit = function(button, url) {
271            if (('undefined' != typeof productAddToCartFormOld) && productAddToCartFormOld) {
272                if (Catalog.Map.active) {
273                    Catalog.Map.hideHelp();
274                }
275                if (productAddToCartForm.qty && $('qty')) {
276                    $('qty').value = productAddToCartForm.qty;
277                }
278                parentResult = productAddToCartFormOld.submit();
279                return false;
280            }
281            if(window.opener) {
282                var parentButton = button;
283                new Ajax.Request(this.form.action, {
284                    parameters: {isAjax: 1, method: 'GET'},
285                    onSuccess: function(transport) {
286                        window.opener.focus();
287                        if (parentButton && parentButton.href) {
288                            setPLocation(parentButton.href, true);
289                            Catalog.Map.hideHelp();
290                        }
291                    }
292                });
293                return;
294            }
295            if (this.validator.validate()) {
296                var form = this.form;
297                var oldUrl = form.action;
298
299                if (url) {
300                   form.action = url;
301                }
302                if (!form.getAttribute('action')) {
303                   form.action = productAddToCartForm.action;
304                }
305                try {
306                    this.form.submit();
307                } catch (e) {
308                    this.form.action = oldUrl;
309                    throw e;
310                }
311                this.form.action = oldUrl;
312
313                if (button && button != 'undefined') {
314                    button.disabled = true;
315                }
316            }
317        };
318    }
319};
320
321Event.observe(window, 'resize', function(event) {
322    if (Catalog.Map.active) {
323        Catalog.Map.showHelp(event);
324    }
325})
326
327$(document).observe('bundle:reload-price', function (event) { //reload price
328    var data = event.memo, bundle = data.bundle;
329    if (!Number(bundle.config.isMAPAppliedDirectly) && !Number(bundle.config.isFixedPrice)) {
330        var canApplyMAP = false;
331        try {
332            for (var option in bundle.config.selected) {
333                if (bundle.config.options[option] && bundle.config.options[option].selections) {
334                    var selections = bundle.config.options[option].selections;
335                    for (var i = 0, l = bundle.config.selected[option].length; i < l; i++) {
336                        var selectionId = bundle.config.selected[option][i];
337                        if (Number(selections[selectionId].canApplyMAP)) {
338                            canApplyMAP = true;
339                            break;
340                        }
341                    }
342                }
343                if (canApplyMAP) {
344                    break;
345                }
346            }
347        } catch (e) {
348            canApplyMAP = true;
349        }
350        if (canApplyMAP) {
351            $$('.full-product-price').each(function(e){
352                $(e).hide();
353            });
354            $$('.map-info').each(function(e){
355                $(e).show();
356            });
357            event.noReloadPrice = true;
358        } else {
359            $$('.full-product-price').each(function(e){
360                $(e).show();
361            });
362            $$('.map-info').each(function(e){
363                $(e).hide();
364            });
365        }
366    }
367});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.