Skip to content

Commit

Permalink
Enable or Disable the Modal responsiveness
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaMackert committed Apr 18, 2019
1 parent 3df4a37 commit e1719c2
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Block/Popup.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ public function hintedCountry()
'delayDuration' => (int)$this->config->getDelayDuration(),
'cookieLifetime' => (int)$this->config->getCookieDuration(),
'modalContent' => $this->getModalText($lang, $this->getShowForUnselected()),
'showModalOverlay' => $this->config->getShowModal()
'showModalOverlay' => $this->config->getShowModal(),
'responsiveModal' => $this->config->isResponsiveModal()
];
}

Expand Down
16 changes: 16 additions & 0 deletions Helper/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ class Config extends AbstractHelper
const SHOW_MODAL = 'countrypopup/general/show_modal';


/**
* config path for responsive modal setting
*/
const RESPONSIVE_MODAL = 'countrypopup/general/responsive_modal';


/**
* fallback detect string
*/
Expand Down Expand Up @@ -215,4 +221,14 @@ public function getShowModal($scope = ScopeInterface::SCOPE_STORE)
{
return $this->scopeConfig->isSetFlag(self::SHOW_MODAL, $scope);
}

/**
* return true if modal is responsive
* @param string $scope
* @return bool
*/
public function isResponsiveModal($scope = ScopeInterface::SCOPE_STORE)
{
return $this->scopeConfig->isSetFlag(self::RESPONSIVE_MODAL, $scope);
}
}
5 changes: 5 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,17 @@
<comment><![CDATA[If "Yes" is selected the default modaltext will be shown for all countries that are not selected <br /> If the detected country is equal the <strong>current store country</strong> no hint will be shown.]]></comment>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>

<field id="show_modal" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>Popup as modal dialog</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment><![CDATA[Show dialog modal with overlay]]></comment>
</field>
<field id="responsive_modal" translate="label" type="select" sortOrder="50" showInDefault="1" canRestore="1">
<label>Responsive Modal</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
</group>
<group id="popup_values" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>County Modal Properties</label>
Expand Down
1 change: 1 addition & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<general>
<cookie>0</cookie>
<show_modal>1</show_modal>
<responsive_modal>1</responsive_modal>
</general>
<popup_delay>
<delay_duration>1000</delay_duration>
Expand Down
3 changes: 2 additions & 1 deletion view/frontend/web/js/country_modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ define([
that.options.delay = (response.useDelay) ? response.delayDuration : 0;
that.options.cookie_lifetime = response.cookieLifetime;
that.options.show_modal_overlay = response.showModalOverlay;
that.options.modal_responsive = response.responsiveModal;
that.prepareModal(response);
}
});
Expand Down Expand Up @@ -74,7 +75,7 @@ define([
var that = this,
options = {
type: 'popup',
responsive: true,
responsive: this.options.modal_responsive,
innerScroll: true,
wrapperClass: 'hint-country-modal'
},
Expand Down

0 comments on commit e1719c2

Please sign in to comment.