Skip to content

Commit

Permalink
#4368 - Dimmer will now reset settings before each modal show making …
Browse files Browse the repository at this point in the history
…it simpler to work with multiple modal types in same page
  • Loading branch information
jlukic committed Jul 2, 2017
1 parent 9ef8f0e commit 28bf34e
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 29 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- **Site** - Site now includes custom scrollbar styles for UI (not page) by default in WebKit/Chrome. You can disable this by setting `@useCustomScrollbars: false` in your `site.variables`

**Bugs**
- **Modal** - Using multiple modals with different `inverted` `blurring` or `closable` settings will no longer in some cases inherit the options of other modals #4368
- **Modal** - Fixed issue where modal `refresh` was being called on modals even if they are hidden. #5319 **Thanks @p2kmgcl**
- **Dropdown** - Fixed issue where using `down` key to re-open dropdown when using `search selection dropdown` would start at the top element instead of jumping to selected element
- **Dropdown** - Fix dropdown arrow being slightly off center due to em calculation being incorrect due to differences in relative em
Expand Down
13 changes: 6 additions & 7 deletions src/definitions/modules/dimmer.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,10 @@ $.fn.dimmer = function(parameters) {
module.set.pageDimmer();
}

if( module.is.closable() ) {
module.verbose('Adding dimmer close event', $dimmer);
$dimmable
.on(clickEvent + eventNamespace, selector.dimmer, module.event.click)
;
}
$dimmable
.on(clickEvent + eventNamespace, selector.dimmer, module.event.click)
;

}
},

Expand All @@ -153,7 +151,7 @@ $.fn.dimmer = function(parameters) {
event: {
click: function(event) {
module.verbose('Determining if event occured on dimmer', event);
if( $dimmer.find(event.target).length === 0 || $(event.target).is(selector.content) ) {
if( ($dimmer.find(event.target).length === 0 || $(event.target).is(selector.content)) && module.is.closable()) {
module.hide();
event.stopImmediatePropagation();
}
Expand Down Expand Up @@ -191,6 +189,7 @@ $.fn.dimmer = function(parameters) {
;
module.debug('Showing dimmer', $dimmer, settings);
if( (!module.is.dimmed() || module.is.animating()) && module.is.enabled() ) {
module.set.variation();
module.animate.show(callback);
settings.onShow.call(element);
settings.onChange.call(element);
Expand Down
62 changes: 40 additions & 22 deletions src/definitions/modules/modal.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -105,39 +105,19 @@ $.fn.modal = function(parameters) {

create: {
dimmer: function() {
var
defaultSettings = {
debug : settings.debug,
dimmerName : 'modals',
duration : {
show : settings.duration,
hide : settings.duration
}
},
dimmerSettings = $.extend(true, defaultSettings, settings.dimmerSettings)
;
if(settings.inverted) {
dimmerSettings.variation = (dimmerSettings.variation !== undefined)
? dimmerSettings.variation + ' inverted'
: 'inverted'
;
}
if($.fn.dimmer === undefined) {
module.error(error.dimmer);
return;
}
module.debug('Creating dimmer with settings', dimmerSettings);
$dimmable = $context.dimmer(dimmerSettings);
module.debug('Creating dimmer');
$dimmable = $context.dimmer({});
if(settings.detachable) {
module.verbose('Modal is detachable, moving content into dimmer');
$dimmable.dimmer('add content', $module);
}
else {
module.set.undetached();
}
if(settings.blurring) {
$dimmable.addClass(className.blurring);
}
$dimmer = $dimmable.dimmer('get dimmer');
},
id: function() {
Expand Down Expand Up @@ -311,6 +291,7 @@ $.fn.modal = function(parameters) {
: function(){}
;
module.refreshModals();
module.set.dimmerSettings();
module.showModal(callback);
},

Expand Down Expand Up @@ -604,6 +585,42 @@ $.fn.modal = function(parameters) {
;
}
},
dimmerSettings: function() {
if($.fn.dimmer === undefined) {
module.error(error.dimmer);
return;
}
var
defaultSettings = {
debug : settings.debug,
dimmerName : 'modals',
variation : false,
closable : 'auto',
duration : {
show : settings.duration,
hide : settings.duration
}
},
dimmerSettings = $.extend(true, defaultSettings, settings.dimmerSettings)
;
if(settings.inverted) {
dimmerSettings.variation = (dimmerSettings.variation !== undefined)
? dimmerSettings.variation + ' inverted'
: 'inverted'
;
$dimmer.addClass(className.inverted);
}
else {
$dimmer.removeClass(className.inverted);
}
if(settings.blurring) {
$dimmable.addClass(className.blurring);
}
else {
$dimmable.removeClass(className.blurring);
}
$context.dimmer('setting', dimmerSettings);
},
screenHeight: function() {
if( module.can.fit() ) {
$body.css('height', '');
Expand Down Expand Up @@ -912,6 +929,7 @@ $.fn.modal.settings = {
active : 'active',
animating : 'animating',
blurring : 'blurring',
inverted : 'inverted',
scrolling : 'scrolling',
undetached : 'undetached'
}
Expand Down

0 comments on commit 28bf34e

Please sign in to comment.