From e3bed3fc3319659d86f23454554d260480f32b6f Mon Sep 17 00:00:00 2001 From: Oleksandr Miroshnichenko Date: Mon, 12 Dec 2016 12:55:03 +0200 Subject: [PATCH] MAGETWO-56849: Clean Up JS files code styles based on black list --- .../view/adminhtml/requirejs-config.js | 4 +- .../web/catalog/base-image-uploader.js | 44 +++--- .../adminhtml/web/catalog/category/edit.js | 103 +++++++------- .../adminhtml/web/catalog/category/form.js | 2 - .../web/catalog/product-attributes.js | 29 +++- .../view/adminhtml/web/catalog/product.js | 49 +++++-- .../catalog/product/composite/configure.js | 3 + .../view/adminhtml/web/js/category-tree.js | 118 +++++++++------- .../view/adminhtml/web/js/custom-options.js | 130 ++++++++++++------ .../adminhtml/web/js/new-category-dialog.js | 41 ++++-- .../view/adminhtml/web/js/product-gallery.js | 68 +++++---- .../view/base/web/js/price-option-date.js | 83 +++++------ .../view/base/web/js/price-option-file.js | 3 +- .../Catalog/view/base/web/js/price-options.js | 122 ++++++++-------- .../Catalog/view/base/web/js/price-utils.js | 68 ++++----- .../Catalog/view/frontend/requirejs-config.js | 2 +- .../frontend/web/js/catalog-add-to-cart.js | 71 +++++++--- .../Catalog/view/frontend/web/js/gallery.js | 27 ++-- .../Catalog/view/frontend/web/js/list.js | 31 +++-- .../frontend/web/js/product/list/toolbar.js | 53 +++++-- .../view/frontend/web/js/related-products.js | 61 ++++---- .../view/frontend/web/js/upsell-products.js | 37 +++-- .../view/frontend/web/js/view/image.js | 1 + .../Catalog/view/frontend/web/js/zoom.js | 94 ++++++++----- .../frontend/web/product/view/validation.js | 16 ++- .../view/frontend/requirejs-config.js | 4 +- .../Test/Js/_files/blacklist/magento.txt | 28 ---- 27 files changed, 780 insertions(+), 512 deletions(-) diff --git a/app/code/Magento/Catalog/view/adminhtml/requirejs-config.js b/app/code/Magento/Catalog/view/adminhtml/requirejs-config.js index d2e45cbfb42ee..1cd32558c93eb 100644 --- a/app/code/Magento/Catalog/view/adminhtml/requirejs-config.js +++ b/app/code/Magento/Catalog/view/adminhtml/requirejs-config.js @@ -3,7 +3,7 @@ * See COPYING.txt for license details. */ -var config = { +var config = {//eslint-disable-line no-unused-vars map: { '*': { categoryForm: 'Magento_Catalog/catalog/category/form', @@ -17,4 +17,4 @@ var config = { deps: [ 'Magento_Catalog/catalog/product' ] -}; \ No newline at end of file +}; diff --git a/app/code/Magento/Catalog/view/adminhtml/web/catalog/base-image-uploader.js b/app/code/Magento/Catalog/view/adminhtml/web/catalog/base-image-uploader.js index 9c0d986c7e9f2..af4ea728c560e 100644 --- a/app/code/Magento/Catalog/view/adminhtml/web/catalog/base-image-uploader.js +++ b/app/code/Magento/Catalog/view/adminhtml/web/catalog/base-image-uploader.js @@ -2,6 +2,7 @@ * Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details. */ + /*global alert:true*/ define([ 'jquery', @@ -20,8 +21,10 @@ define([ * @protected */ options: { - maxImageUploadCount : 10 + maxImageUploadCount: 10 }, + + /** @inheritdoc */ _create: function () { var $container = this.element, imageTmpl = mageTemplate(this.element.find('[data-template=image]').html()), @@ -30,22 +33,25 @@ define([ mainClass = 'base-image', maximumImageCount = 5, $fieldCheckBox = $container.closest('[data-attribute-code=image]').find(':checkbox'), - isDefaultChecked = $fieldCheckBox.is(':checked'); + isDefaultChecked = $fieldCheckBox.is(':checked'), + findElement, updateVisibility; if (isDefaultChecked) { $fieldCheckBox.trigger('click'); } - var findElement = function (data) { + findElement = function (data) {//jscs:ignore jsDoc return $container.find('.image:not(.image-placeholder)').filter(function () { if (!$(this).data('image')) { return false; } + return $(this).data('image').file === data.file; }).first(); }; - var updateVisibility = function () { + updateVisibility = function () {//jscs:ignore jsDoc var elementsList = $container.find('.image:not(.removed-item)'); + elementsList.each(function (index) { $(this)[index < maximumImageCount ? 'show' : 'hide'](); }); @@ -78,12 +84,13 @@ define([ }); $galleryContainer.on('moveElement', function (event, data) { - var $element = findElement(data.imageData); + var $element = findElement(data.imageData), + $after; if (data.position === 0) { $container.prepend($element); } else { - var $after = $container.find('.image').eq(data.position); + $after = $container.find('.image').eq(data.position); if (!$element.is($after)) { $element.insertAfter($after); @@ -93,8 +100,10 @@ define([ }); $container.on('click', '[data-role=make-base-button]', function (event) { + var data; + event.preventDefault(); - var data = $(event.target).closest('.image').data('image'); + data = $(event.target).closest('.image').data('image'); $galleryContainer.productGallery('setBase', data); }); @@ -108,7 +117,7 @@ define([ items: '.image:not(.image-placeholder)', distance: 8, tolerance: 'pointer', - stop: function (event, data) { + stop: function (event, data) {//jscs:ignore jsDoc $galleryContainer.trigger('setPosition', { imageData: data.item.data('image'), position: $container.find('.image').index(data.item) @@ -122,7 +131,7 @@ define([ dropZone: $dropPlaceholder.closest('[data-attribute-code]'), acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i, maxFileSize: this.element.data('maxFileSize'), - done: function (event, data) { + done: function (event, data) {//jscs:ignore jsDoc $dropPlaceholder.find('.progress-bar').text('').removeClass('in-progress'); if (!data.result) { @@ -137,13 +146,13 @@ define([ }); } }, - change: function(e, data) { + change: function (e, data) { if (data.files.length > this.options.maxImageUploadCount) { $('body').notification('clear').notification('add', { error: true, - message: $.mage.__('You can\'t upload more than ' + this.options.maxImageUploadCount - + ' images in one time'), - insertMethod: function(message) { + message: $.mage.__('You can\'t upload more than ' + this.options.maxImageUploadCount + + ' images in one time'), + insertMethod: function (message) {//jscs:ignore jsDoc $('.page-main-actions').after(message); } }); @@ -151,21 +160,22 @@ define([ return false; } }.bind(this), - add: function (event, data) { + add: function (event, data) {//jscs:ignore jsDoc $(this).fileupload('process', data).done(function () { data.submit(); }); }, - progress: function (e, data) { + progress: function (e, data) {//jscs:ignore jsDoc var progress = parseInt(data.loaded / data.total * 100, 10); + $dropPlaceholder.find('.progress-bar').addClass('in-progress').text(progress + '%'); }, - start: function (event) { + start: function (event) {//jscs:ignore jsDoc var uploaderContainer = $(event.target).closest('.image-placeholder'); uploaderContainer.addClass('loading'); }, - stop: function (event) { + stop: function (event) {//jscs:ignore jsDoc var uploaderContainer = $(event.target).closest('.image-placeholder'); uploaderContainer.removeClass('loading'); diff --git a/app/code/Magento/Catalog/view/adminhtml/web/catalog/category/edit.js b/app/code/Magento/Catalog/view/adminhtml/web/catalog/category/edit.js index 28bc0734ef033..148151baf882a 100644 --- a/app/code/Magento/Catalog/view/adminhtml/web/catalog/category/edit.js +++ b/app/code/Magento/Catalog/view/adminhtml/web/catalog/category/edit.js @@ -5,74 +5,81 @@ /** * Create/edit some category */ + +/* global tree */ define([ 'jquery', 'prototype' ], function (jQuery) { + 'use strict'; + + var categorySubmit = function () {//jscs:ignore jsDoc + var activeTab = $('active_tab_id'), + params = {}, + fields, i,categoryId, isCreating, path, parentId, currentNode, oldClass, newClass; - var categorySubmit = function (url, useAjax) { - var activeTab = $('active_tab_id'); - if (activeTab) { - if (activeTab.tabsJsObject && activeTab.tabsJsObject.tabs('activeAnchor')) { - activeTab.value = activeTab.tabsJsObject.tabs('activeAnchor').prop('id'); + if (activeTab) { + if (activeTab.tabsJsObject && activeTab.tabsJsObject.tabs('activeAnchor')) { + activeTab.value = activeTab.tabsJsObject.tabs('activeAnchor').prop('id'); + } } - } - var params = {}; - var fields = $('category_edit_form').getElementsBySelector('input', 'select'); - for (var i=0; i').modal({ - title: $.mage.__('New Attribute'), + title: $.mage.__('New Attribute'), type: 'slide', buttons: [], + + /** @inheritdoc */ opened: function () { $(this).parent().addClass('modal-content-new-attribute'); self.iframe = $('