Skip to content

Commit 465f774

Browse files
Updated component to version 2.3.0
1 parent f30a894 commit 465f774

8 files changed

+132
-140
lines changed

RELEASE-NOTES.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1+
### Version 2.3.0 - Feb 19, 2018
2+
3+
- **Modal** - Modal has been rewritten to use `flexbox`. No need to call `refresh()` to recalculate vertical centering.
4+
- **Modal** - Modals now have a setting `centered` which can be used to disable vertical centering. This can be useful for modals with content that changes dynamically to prevent content from jumping in position.
5+
- **Modal** - You can now modify `closable` setting after init **Thanks @mdehoog** [#3396](https://github.com/Semantic-Org/Semantic-UI/issues/3396)
6+
- **Modal** - Modal `autofocus` setting now checks to see if currently focused element is in modal, avoiding issues where focus could be set in `onVisible` or `onShow`
7+
18
### Version 2.2.14 - Jan 29, 2018
29

3-
- **Modal** - Fixes issue where an oversized modal would appear behind an existing modal when using `allowMultiple: true` and a second modal that is larger than the sreen height. [#2423](https://github.com/Semantic-Org/Semantic-UI/issues/2423)
10+
- **Modal** - Fixes issue where an oversized modal would appear behind an existing modal when using `allowMultiple: true` and a second modal that is larger than the screen height. [#2423](https://github.com/Semantic-Org/Semantic-UI/issues/2423)
411

512
### Version 2.2.12 - Aug 07, 2017
613

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
"framework"
1616
],
1717
"license": "MIT",
18-
"version": "2.2.14"
18+
"version": "2.3.0"
1919
}

index.js

+35-43
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* # Semantic UI 2.2.14 - Modal
2+
* # Semantic UI 2.3.0 - Modal
33
* http://github.com/semantic-org/semantic-ui/
44
*
55
*
@@ -109,6 +109,10 @@ module.exports = function(parameters) {
109109
var
110110
defaultSettings = {
111111
debug : settings.debug,
112+
variation : settings.centered
113+
? false
114+
: 'top aligned'
115+
,
112116
dimmerName : 'modals'
113117
},
114118
dimmerSettings = $.extend(true, defaultSettings, settings.dimmerSettings)
@@ -166,7 +170,6 @@ module.exports = function(parameters) {
166170
module.cacheSizes();
167171
module.set.screenHeight();
168172
module.set.type();
169-
module.set.position();
170173
},
171174

172175
refreshModals: function() {
@@ -239,21 +242,23 @@ module.exports = function(parameters) {
239242
module.hide();
240243
},
241244
click: function(event) {
245+
if(!settings.closable) {
246+
module.verbose('Dimmer clicked but closable setting is disabled');
247+
return;
248+
}
242249
var
243250
$target = $(event.target),
244251
isInModal = ($target.closest(selector.modal).length > 0),
245252
isInDOM = $.contains(document.documentElement, event.target)
246253
;
247-
if(!isInModal && isInDOM) {
254+
if(!isInModal && isInDOM && module.is.active()) {
248255
module.debug('Dimmer clicked, hiding all modals');
249-
if( module.is.active() ) {
250-
module.remove.clickaway();
251-
if(settings.allowMultiple) {
252-
module.hide();
253-
}
254-
else {
255-
module.hideAll();
256-
}
256+
module.remove.clickaway();
257+
if(settings.allowMultiple) {
258+
module.hide();
259+
}
260+
else {
261+
module.hideAll();
257262
}
258263
}
259264
},
@@ -321,7 +326,6 @@ module.exports = function(parameters) {
321326

322327
module.showDimmer();
323328
module.cacheSizes();
324-
module.set.position();
325329
module.set.screenHeight();
326330
module.set.type();
327331
module.set.clickaway();
@@ -488,7 +492,13 @@ module.exports = function(parameters) {
488492

489493
save: {
490494
focus: function() {
491-
$focusedElement = $(document.activeElement).blur();
495+
var
496+
$activeElement = $(document.activeElement),
497+
inCurrentModal = $activeElement.closest($module).length > 0
498+
;
499+
if(!inCurrentModal) {
500+
$focusedElement = $(document.activeElement).blur();
501+
}
492502
}
493503
},
494504

@@ -505,11 +515,9 @@ module.exports = function(parameters) {
505515
$module.removeClass(className.active);
506516
},
507517
clickaway: function() {
508-
if(settings.closable) {
509-
$dimmer
510-
.off('click' + elementEventNamespace)
511-
;
512-
}
518+
$dimmer
519+
.off('click' + elementEventNamespace)
520+
;
513521
},
514522
bodyStyle: function() {
515523
if($body.attr('style') === '') {
@@ -607,11 +615,9 @@ module.exports = function(parameters) {
607615
}
608616
},
609617
clickaway: function() {
610-
if(settings.closable) {
611-
$dimmer
612-
.on('click' + elementEventNamespace, module.event.click)
613-
;
614-
}
618+
$dimmer
619+
.on('click' + elementEventNamespace, module.event.click)
620+
;
615621
},
616622
dimmerSettings: function() {
617623
if($.fn.dimmer === undefined) {
@@ -622,8 +628,11 @@ module.exports = function(parameters) {
622628
defaultSettings = {
623629
debug : settings.debug,
624630
dimmerName : 'modals',
625-
variation : false,
626631
closable : 'auto',
632+
variation : settings.centered
633+
? false
634+
: 'top aligned'
635+
,
627636
duration : {
628637
show : settings.duration,
629638
hide : settings.duration
@@ -679,25 +688,6 @@ module.exports = function(parameters) {
679688
module.set.scrolling();
680689
}
681690
},
682-
position: function() {
683-
module.verbose('Centering modal on page', module.cache);
684-
if(module.can.fit()) {
685-
$module
686-
.css({
687-
top: '',
688-
marginTop: module.cache.topOffset
689-
})
690-
;
691-
}
692-
else {
693-
$module
694-
.css({
695-
marginTop : '',
696-
top : $document.scrollTop()
697-
})
698-
;
699-
}
700-
},
701691
undetached: function() {
702692
$dimmable.addClass(className.undetached);
703693
}
@@ -906,6 +896,8 @@ _module.exports.settings = {
906896
inverted : false,
907897
blurring : false,
908898

899+
centered : true,
900+
909901
dimmerSettings : {
910902
closable : false,
911903
useCSS : true

0 commit comments

Comments
 (0)