Skip to content

Commit

Permalink
Clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
haitv282 committed May 27, 2020
1 parent d0ccdec commit b33b3fa
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 159 deletions.
1 change: 1 addition & 0 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Data extends AbstractData
{
const CONFIG_MODULE_PATH = 'sharecart';
const BUSINESS_CONFIG_PATH = 'business_information';

/**
* @var PriceCurrencyInterface
*/
Expand Down
2 changes: 1 addition & 1 deletion Helper/PrintProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
use Magento\Framework\Exception\FileSystemException;
use Magento\Framework\Filesystem;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Framework\Stdlib\DateTime\DateTime;
use Magento\Framework\Stdlib\DateTime\TimeZone;
use Magento\Quote\Model\Quote;
use Magento\Store\Model\StoreManagerInterface;
use Mageplaza\ShareCart\Model\Template\Processor;
use Mpdf\Mpdf;
use Mpdf\MpdfException;
use Magento\Framework\Pricing\PriceCurrencyInterface;

/**
* Class PrintProcess
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"mageplaza/module-core": "^1.4.5",
"mpdf/mpdf": "^7.1.0"
},
"version": "1.1.0",
"version": "1.1.1",
"license": "proprietary",
"authors": [
{
Expand Down
102 changes: 51 additions & 51 deletions view/frontend/layout/default.xml
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
<?xml version="1.0"?>
<!--
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_ShareCart
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Mageplaza_ShareCart::css/style.css"/>
</head>
<body>
<referenceBlock name="minicart">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="minicart_content" xsi:type="array">
<item name="children" xsi:type="array">
<item name="extra_info" xsi:type="array">
<item name="children" xsi:type="array">
<item name="mp_sharecart" xsi:type="array">
<item name="component" xsi:type="string">Mageplaza_ShareCart/js/view/minicart</item>
<item name="config" xsi:type="array">
<item name="componentDisabled" xsi:type="helper" helper="Mageplaza\ShareCart\Helper\Data::isDisabled"/>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</argument>
</arguments>
</referenceBlock>
</body>
</page>
<?xml version="1.0"?>
<!--
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_ShareCart
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Mageplaza_ShareCart::css/style.css"/>
</head>
<body>
<referenceBlock name="minicart">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="minicart_content" xsi:type="array">
<item name="children" xsi:type="array">
<item name="extra_info" xsi:type="array">
<item name="children" xsi:type="array">
<item name="mp_sharecart" xsi:type="array">
<item name="component" xsi:type="string">Mageplaza_ShareCart/js/view/minicart</item>
<item name="config" xsi:type="array">
<item name="componentDisabled" xsi:type="helper" helper="Mageplaza\ShareCart\Helper\Data::isDisabled"/>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</argument>
</arguments>
</referenceBlock>
</body>
</page>
154 changes: 77 additions & 77 deletions view/frontend/web/js/view/minicart.js
Original file line number Diff line number Diff line change
@@ -1,77 +1,77 @@
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_ShareCart
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/
define([
'jquery',
'uiComponent',
'Magento_Customer/js/customer-data',
'mage/translate'
], function ($, Component, customerData, $t) {
'use strict';

var isReload = true;

return Component.extend({
defaults: {
template: 'Mageplaza_ShareCart/minicart'
},

initialize: function () {
this._super();

if (isReload) {
customerData.reload(['cart'], false);
isReload = false;
}
this.customer = customerData.get('cart');
},

moveShareCart: function(){
$(document).ready(function () {
$('.secondary.sharecart').appendTo($('.action.viewcart').parent());
});
},

getQuoteId: function () {
return customerData.get('cart')().quote_url;
},

copyQuote: function (object, e) {
var quoteUrl = document.createElement('textarea');

quoteUrl.value = customerData.get('cart')().quote_url;
document.body.appendChild(quoteUrl);
quoteUrl.select();
document.execCommand('copy');
document.body.removeChild(quoteUrl);

e.currentTarget.setAttribute('class', 'mp-tooltipped');
e.currentTarget.setAttribute('aria-label', $t('Copied!'));
},

leaveQuote: function (object, e) {
e.currentTarget.removeAttribute('class');
e.currentTarget.removeAttribute('aria-label');
},

isDisplay: function () {
return customerData.get('cart')().summary_count;
}
});
});
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_ShareCart
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/
define([
'jquery',
'uiComponent',
'Magento_Customer/js/customer-data',
'mage/translate'
], function ($, Component, customerData, $t) {
'use strict';

var isReload = true;

return Component.extend({
defaults: {
template: 'Mageplaza_ShareCart/minicart'
},

initialize: function () {
this._super();

if (isReload) {
customerData.reload(['cart'], false);
isReload = false;
}
this.customer = customerData.get('cart');
},

moveShareCart: function(){
$(document).ready(function () {
$('.secondary.sharecart').appendTo($('.action.viewcart').parent());
});
},

getQuoteId: function () {
return customerData.get('cart')().quote_url;
},

copyQuote: function (object, e) {
var quoteUrl = document.createElement('textarea');

quoteUrl.value = customerData.get('cart')().quote_url;
document.body.appendChild(quoteUrl);
quoteUrl.select();
document.execCommand('copy');
document.body.removeChild(quoteUrl);

e.currentTarget.setAttribute('class', 'mp-tooltipped');
e.currentTarget.setAttribute('aria-label', $t('Copied!'));
},

leaveQuote: function (object, e) {
e.currentTarget.removeAttribute('class');
e.currentTarget.removeAttribute('aria-label');
},

isDisplay: function () {
return customerData.get('cart')().summary_count;
}
});
});
58 changes: 29 additions & 29 deletions view/frontend/web/template/minicart.html
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
<!--
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_ShareCart
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/
-->
<!--ko if: isDisplay() -->
<div class="secondary sharecart" style="text-align: center" afterRender="moveShareCart()">
<a class="action sharecart mp-sharecart-minicart" data-bind="click: copyQuote, event: {mouseleave: leaveQuote}"
style="cursor: pointer">
<span data-bind="i18n: 'Share Cart'"></span>
</a>
</div>
<!-- /ko -->
<!--
/**
* Mageplaza
*
* NOTICE OF LICENSE
*
* This source file is subject to the Mageplaza.com license that is
* available through the world-wide-web at this URL:
* https://www.mageplaza.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this extension to newer
* version in the future.
*
* @category Mageplaza
* @package Mageplaza_ShareCart
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/)
* @license https://www.mageplaza.com/LICENSE.txt
*/
-->
<!--ko if: isDisplay() -->
<div class="secondary sharecart" style="text-align: center" afterRender="moveShareCart()">
<a class="action sharecart mp-sharecart-minicart" data-bind="click: copyQuote, event: {mouseleave: leaveQuote}"
style="cursor: pointer">
<span data-bind="i18n: 'Share Cart'"></span>
</a>
</div>
<!-- /ko -->

0 comments on commit b33b3fa

Please sign in to comment.