/** * Magento * * NOTICE OF LICENSE * * This source file is subject to the Academic Free License (AFL 3.0) * that is bundled with this package in the file LICENSE_AFL.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/afl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@magento.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magento.com for more information. * * @category design * @package rwd_default * @copyright Copyright (c) 2006-2014 X.commerce, Inc. (http://www.magento.com) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ var windowLoaded = false; Event.observe(window, 'load', function() { windowLoaded = true; }); // rewrite the fillselect method from /js/varien/configurable.js Product.Config.prototype.fillSelect = function (element) { return; }; // rewrite the resetChildren method from /js/varien/configurable.js; it would reset the third attribute when selecting a swatch in the first attribute Product.Config.prototype.resetChildren = function (element) { return; }; // rewrite the configureForValues method from /js/varien/configurable.js; it tries to select the options when a product has been selected (e.g. editing product from cart page), but we have our own method for that // @see: Product.ConfigurableSwatches.run() Product.Config.prototype.configureForValues = function(){ return; }; Product.Config.prototype.origInitialize = Product.Config.prototype.initialize; Product.Config.prototype.initialize = function(config) { this.origInitialize(config); this.configureObservers = []; this.loadOptions(); }; Product.Config.prototype.handleSelectChange = function(element) { this.configureElement(element); this.configureObservers.each(function(funct) { funct(element); }); }; Product.Config.prototype.origConfigure = Product.Config.prototype.configure; Product.Config.prototype.configure = function(event) { this.origConfigure(event); var element = Event.element(event); this.configureObservers.each(function(funct) { funct(element); }); }; Product.Config.prototype.configureSubscribe = function(funct) { this.configureObservers.push(funct); }; /** * * Load ALL the options into the selects * Uses global var spConfig declared in template/configurableswatches/catalog/product/view/type/configurable.phtml **/ Product.Config.prototype.loadOptions = function() { this.settings.each(function(element){ element.disabled = false; element.options[0] = new Option(this.config.chooseText, ''); var attributeId = element.id.replace(/[a-z]*/, ''); var options = this.getAttributeOptions(attributeId); if(options) { var index = 1; for(var i=0;i