Skip to content

Commit

Permalink
Merge pull request #79 from AnastasiaBuniakEPAM/JS-323
Browse files Browse the repository at this point in the history
JS-337: [Configurable.JS] Preload all needed images
  • Loading branch information
uharbachou1 committed Dec 22, 2015
2 parents e8b7b00 + 2d7afe6 commit 39aa50f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ define([
'jquery',
'underscore',
'mage/template',
'mage/gallery/preloadImages',
'priceUtils',
'priceBox',
'jquery/ui',
'jquery/jquery.parsequery'
], function ($, _, mageTemplate, preloadImages) {
], function ($, _, mageTemplate) {
'use strict';

$.widget('mage.configurable', {
Expand Down Expand Up @@ -40,10 +39,6 @@ define([
// Initial setting of various option values
this._initializeOptions();

//Preload all gallery images
this._preloadImages();
this._preloadOptionalImages();

// Override defaults with URL query parameters and/or inputs values
this._overrideDefaults();

Expand Down Expand Up @@ -93,43 +88,6 @@ define([
});
},

/**
* Preloads default configuration images.
* @private
*/
_preloadImages: function () {
var options = this.options,
fullImagesList = [],
imagesList = [];

_.each(options.mediaGalleryInitial, function (item) {
imagesList.push(item.img);
fullImagesList.push(item.full);
});
preloadImages(imagesList);
preloadImages(fullImagesList);
},

/**
* Preloads optional configuration images.
* @private
*/
_preloadOptionalImages: function () {
var options = this.options;

_.each(options.spConfig.images, function (array) {
var fullImagesList = [],
imagesList = [];

_.each(array, function (item) {
imagesList.push(item.img);
fullImagesList.push(item.full);
});
preloadImages(imagesList);
preloadImages(fullImagesList);
});
},

/**
* Override default options values settings with either URL query parameters or
* initialized inputs values.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
define([
'jquery',
'underscore',
'mage/gallery/preloadImages',
'jquery/ui'
], function ($, _, preloadImages) {
], function ($, _) {
'use strict';

/**
Expand Down Expand Up @@ -272,24 +271,6 @@ define([
'img': $main.find('.product-image-photo').attr('src')
}];
}
this._preloadSwatchesImages();
},

/**
* Preloads optional configuration images.
* @private
*/
_preloadSwatchesImages: function () {
var options = this.options;

_.each(options.jsonConfig.images, function (array) {
var imagesList = [];

_.each(array, function (item) {
imagesList.push(item.img);
});
preloadImages(imagesList);
});
},

/**
Expand Down
48 changes: 0 additions & 48 deletions lib/web/mage/gallery/preloadImages.js

This file was deleted.

0 comments on commit 39aa50f

Please sign in to comment.