Skip to content

Commit

Permalink
Merge branch 'next' of github.com:Semantic-Org/Semantic-UI into hammy…
Browse files Browse the repository at this point in the history
…2899-fa5
  • Loading branch information
jlukic committed Feb 19, 2018
2 parents dab4223 + 95ae3bf commit 3588a66
Show file tree
Hide file tree
Showing 11 changed files with 244 additions and 128 deletions.
17 changes: 17 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
## RELEASE NOTES

### Version 2.3.0 - Feb 19, 2018

**Major Enhancements**
- **Search** - Category search can now work with local search by adding a `category` property to any result and specifying `type: 'category'`
- **Search** - Category results now has `exact` matching
- **Modal** - Modal has been rewritten to use `flexbox`. No need to call `refresh()` to recalculate vertical centering.
- **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.

**Enhancements**
- **Search** - Category results will now responsively adjust `title` row if titles are long instead of forcing a title width
- **Dimmer** - Dimmers now have centered content with a single wrapping `content` element.
- **Popup** - Popup will now align the center of the arrow (not the edge of the popup) when it would be reasonable (up to 2x arrow's offset from edge). [See this explanation](http://oi66.tinypic.com/2zr2ckk.jpg)
- **Popup** - Popup can now position elements correctly even when they have a different offset context than their activating element. Like in [this example](https://jsfiddle.net/g853mc03/)

**Bugs**
- **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`

### Version 2.2.14 - Jan 29, 2018

**Critical Bugs**
Expand Down
2 changes: 2 additions & 0 deletions src/definitions/modules/dimmer.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ $.fn.dimmer = function(parameters) {
}
$dimmer
.transition({
displayType : 'flex',
animation : settings.transition + ' in',
queue : false,
duration : module.get.duration(),
Expand Down Expand Up @@ -282,6 +283,7 @@ $.fn.dimmer = function(parameters) {
module.verbose('Hiding dimmer with css');
$dimmer
.transition({
displayType : 'flex',
animation : settings.transition + ' out',
queue : false,
duration : module.get.duration(),
Expand Down
29 changes: 21 additions & 8 deletions src/definitions/modules/dimmer.less
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

text-align: @textAlign;
vertical-align: @verticalAlign;
padding: @padding;

background-color: @backgroundColor;
opacity: @hiddenOpacity;
Expand All @@ -45,21 +46,18 @@
animation-duration: @duration;
transition: @transition;

flex-direction: column;
align-items: center;
justify-content: center;

user-select: none;
will-change: opacity;
z-index: @zIndex;
}

/* Dimmer Content */
.ui.dimmer > .content {
width: 100%;
height: 100%;
display: @contentDisplay;
user-select: text;
}
.ui.dimmer > .content > * {
display: @contentChildDisplay;
vertical-align: @verticalAlign;
color: @textColor;
}

Expand Down Expand Up @@ -90,27 +88,42 @@
States
*******************************/

/* Animating */
.animating.dimmable:not(body),
.dimmed.dimmable:not(body) {
overflow: @overflow;
}

/* Animating / Active / Visible */
.dimmed.dimmable > .ui.animating.dimmer,
.dimmed.dimmable > .ui.visible.dimmer,
.ui.active.dimmer {
display: block;
display: flex;
opacity: @visibleOpacity;
}

/* Disabled */
.ui.disabled.dimmer {
width: 0 !important;
height: 0 !important;
}


/*******************************
Variations
*******************************/

/*--------------
Alignment
---------------*/

.ui[class*="top aligned"].dimmer {
justify-content: flex-start;
}
.ui[class*="bottom aligned"].dimmer {
justify-content: flex-end;
}

/*--------------
Page
---------------*/
Expand Down
39 changes: 17 additions & 22 deletions src/definitions/modules/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ $.fn.modal = function(parameters) {
var
defaultSettings = {
debug : settings.debug,
variation : settings.centered
? ''
: 'top aligned'
,
dimmerName : 'modals'
},
dimmerSettings = $.extend(true, defaultSettings, settings.dimmerSettings)
Expand Down Expand Up @@ -165,7 +169,6 @@ $.fn.modal = function(parameters) {
module.cacheSizes();
module.set.screenHeight();
module.set.type();
module.set.position();
},

refreshModals: function() {
Expand Down Expand Up @@ -320,7 +323,6 @@ $.fn.modal = function(parameters) {

module.showDimmer();
module.cacheSizes();
module.set.position();
module.set.screenHeight();
module.set.type();
module.set.clickaway();
Expand Down Expand Up @@ -487,7 +489,13 @@ $.fn.modal = function(parameters) {

save: {
focus: function() {
$focusedElement = $(document.activeElement).blur();
var
$activeElement = $(document.activeElement),
inCurrentModal = $activeElement.closest($module).length > 0
;
if(!inCurrentModal) {
$focusedElement = $(document.activeElement).blur();
}
}
},

Expand Down Expand Up @@ -623,6 +631,10 @@ $.fn.modal = function(parameters) {
dimmerName : 'modals',
variation : false,
closable : 'auto',
variation : settings.centered
? ''
: 'top aligned'
,
duration : {
show : settings.duration,
hide : settings.duration
Expand Down Expand Up @@ -678,25 +690,6 @@ $.fn.modal = function(parameters) {
module.set.scrolling();
}
},
position: function() {
module.verbose('Centering modal on page', module.cache);
if(module.can.fit()) {
$module
.css({
top: '',
marginTop: module.cache.topOffset
})
;
}
else {
$module
.css({
marginTop : '',
top : $document.scrollTop()
})
;
}
},
undetached: function() {
$dimmable.addClass(className.undetached);
}
Expand Down Expand Up @@ -905,6 +898,8 @@ $.fn.modal.settings = {
inverted : false,
blurring : false,

centered : true,

dimmerSettings : {
closable : false,
useCSS : true
Expand Down
37 changes: 14 additions & 23 deletions src/definitions/modules/modal.less
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@

.ui.modal {
display: none;
position: fixed;
z-index: @zIndex;

top: 50%;
left: 50%;
text-align: left;

background: @background;
Expand Down Expand Up @@ -337,14 +333,26 @@
Variations
*******************************/

/*--------------
Top Aligned
---------------*/

/* Top Aligned Modal */
.modals.dimmer[class*="top aligned"] .modal {
margin: @topAlignedMargin auto;
}

/*--------------
Scrolling
---------------*/

/* A modal that cannot fit on the page */
/* Scrolling Dimmer */
.scrolling.dimmable.dimmed {
overflow: hidden;
}
.scrolling.dimmable > .dimmer {
justify-content: flex-start;
}
.scrolling.dimmable.dimmed > .dimmer {
overflow: auto;
-webkit-overflow-scrolling: touch;
Expand All @@ -353,13 +361,10 @@
position: fixed;
}
.modals.dimmer .ui.scrolling.modal {
position: relative !important;
left: auto !important;
top: auto !important;
margin: @scrollingMargin auto !important;
}

/* undetached scrolling */
/* Undetached Scrolling */
.scrolling.undetached.dimmable.dimmed {
overflow: auto;
-webkit-overflow-scrolling: touch;
Expand All @@ -373,26 +378,12 @@
margin-top: @scrollingMargin !important;
}

/* Coupling with Sidebar */
.undetached.dimmable.dimmed > .pusher {
z-index: auto;
}

@media only screen and (max-width : @largestTabletScreen) {
.modals.dimmer .ui.scrolling.modal {
margin-top: @mobileScrollingMargin !important;
margin-bottom: @mobileScrollingMargin !important;
}
}

/* Scrolling Content */

.ui.modal .scrolling.content {
max-height: @scrollingContentMaxHeight;
overflow: auto;
}


/*--------------
Full Screen
---------------*/
Expand Down
51 changes: 44 additions & 7 deletions src/definitions/modules/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,10 @@ $.fn.popup = function(parameters) {
},
calculations: function() {
var
targetElement = $target[0],
isWindow = ($boundary[0] == window),
targetPosition = (settings.inline || (settings.popup && settings.movePopup))
$popupOffsetParent = module.get.offsetParent($popup),
targetElement = $target[0],
isWindow = ($boundary[0] == window),
targetPosition = (settings.inline || (settings.popup && settings.movePopup))
? $target.position()
: $target.offset(),
screenPosition = (isWindow)
Expand Down Expand Up @@ -549,6 +550,17 @@ $.fn.popup = function(parameters) {
}
};

// if popup offset context is not same as target, then adjust calculations
if($popupOffsetParent.get(0) !== $offsetParent.get(0)) {
var
popupOffset = $popupOffsetParent.offset()
;
calculations.target.top -= popupOffset.top;
calculations.target.left -= popupOffset.left;
calculations.parent.width = $popupOffsetParent.outerWidth();
calculations.parent.height = $popupOffsetParent.outerHeight();
}

// add in container calcs if fluid
if( settings.setFluidWidth && module.is.fluid() ) {
calculations.container = {
Expand Down Expand Up @@ -637,14 +649,14 @@ $.fn.popup = function(parameters) {
var
is2D = ($node.css('transform') === 'none'),
isStatic = ($node.css('position') === 'static'),
isHTML = $node.is('html')
isBody = $node.is('body')
;
while(parentNode && !isHTML && isStatic && is2D) {
while(parentNode && !isBody && isStatic && is2D) {
parentNode = parentNode.parentNode;
$node = $(parentNode);
is2D = ($node.css('transform') === 'none');
isStatic = ($node.css('position') === 'static');
isHTML = $node.is('html');
isBody = $node.is('body');
}
}
return ($node && $node.length > 0)
Expand Down Expand Up @@ -753,6 +765,18 @@ $.fn.popup = function(parameters) {
popup = calculations.popup;
parent = calculations.parent;

if(module.should.centerArrow(calculations)) {
module.verbose('Adjusting offset to center arrow on small target element');
if(position == 'top left' || position == 'bottom left') {
offset += (target.width / 2)
offset -= settings.arrowPixelsFromEdge;
}
if(position == 'top right' || position == 'bottom right') {
offset -= (target.width / 2)
offset += settings.arrowPixelsFromEdge;
}
}

if(target.width === 0 && target.height === 0 && !module.is.svg(target.element)) {
module.debug('Popup target is hidden, no action taken');
return false;
Expand Down Expand Up @@ -1046,6 +1070,12 @@ $.fn.popup = function(parameters) {
}
},

should: {
centerArrow: function(calculations) {
return !module.is.basic() && calculations.target.width <= (settings.arrowPixelsFromEdge * 2);
}
},

is: {
offstage: function(distanceFromBoundary, position) {
var
Expand All @@ -1068,6 +1098,9 @@ $.fn.popup = function(parameters) {
svg: function(element) {
return module.supports.svg() && (element instanceof SVGGraphicsElement);
},
basic: function() {
return $module.hasClass(className.basic);
},
active: function() {
return $module.hasClass(className.active);
},
Expand Down Expand Up @@ -1380,8 +1413,11 @@ $.fn.popup.settings = {
// specify position to appear even if it doesn't fit
lastResort : false,

// number of pixels from edge of popup to pointing arrow center (used from centering)
arrowPixelsFromEdge: 20,

// delay used to prevent accidental refiring of animations due to user error
delay : {
delay : {
show : 50,
hide : 70
},
Expand Down Expand Up @@ -1425,6 +1461,7 @@ $.fn.popup.settings = {

className : {
active : 'active',
basic : 'basic',
animating : 'animating',
dropdown : 'dropdown',
fluid : 'fluid',
Expand Down
Loading

0 comments on commit 3588a66

Please sign in to comment.