Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f1cdbe2

Browse files
authored
Merge pull request gridstack#512 from radiolips/bugfix/462
Bugfix/462
2 parents f8b56af + af0f2d2 commit f1cdbe2

File tree

9 files changed

+49
-39
lines changed

9 files changed

+49
-39
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,10 @@ Changes
479479

480480
#### v0.2.7-dev (Development Version)
481481

482+
- add oneColumnModeClass option to grid.
483+
- remove 768px CSS styles, moved to grid-stack-one-column-mode class.
484+
- add max-width override on grid-stck-one-column-mode ([#462](https://github.com/troolee/gridstack.js/issues/462)).
485+
482486
#### v0.2.6 (2016-08-17)
483487

484488
- update requirements to the latest versions of jQuery (v3.1.0+) and jquery-ui (v1.12.0+).

dist/gridstack.css

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -369,18 +369,19 @@
369369
transition: left 0s, top 0s, height 0s, width 0s;
370370
}
371371

372-
@media (max-width: 768px) {
373-
.grid-stack-item {
374-
position: relative !important;
375-
width: auto !important;
376-
left: 0 !important;
377-
top: auto !important;
378-
margin-bottom: 20px;
379-
}
380-
.grid-stack-item .ui-resizable-handle {
381-
display: none;
382-
}
383-
.grid-stack {
384-
height: auto !important;
385-
}
372+
.grid-stack.grid-stack-one-column-mode {
373+
height: auto !important;
374+
}
375+
376+
.grid-stack.grid-stack-one-column-mode > .grid-stack-item {
377+
position: relative !important;
378+
width: auto !important;
379+
left: 0 !important;
380+
top: auto !important;
381+
margin-bottom: 20px;
382+
max-width: none !important;
383+
}
384+
385+
.grid-stack.grid-stack-one-column-mode > .grid-stack-item > .ui-resizable-handle {
386+
display: none;
386387
}

dist/gridstack.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,8 @@
547547
removable: false,
548548
removeTimeout: 2000,
549549
verticalMarginUnit: 'px',
550-
cellHeightUnit: 'px'
550+
cellHeightUnit: 'px',
551+
oneColumnModeClass: opts.oneColumnModeClass || 'grid-stack-one-column-mode'
551552
});
552553

553554
if (this.opts.rtl === 'auto') {
@@ -635,7 +636,7 @@
635636
if (oneColumnMode) {
636637
return;
637638
}
638-
639+
self.container.addClass(self.opts.oneColumnModeClass);
639640
oneColumnMode = true;
640641

641642
self.grid._sortNodes();
@@ -659,6 +660,7 @@
659660
return;
660661
}
661662

663+
self.container.removeClass(self.opts.oneColumnModeClass);
662664
oneColumnMode = false;
663665

664666
if (self.opts.staticGrid) {

dist/gridstack.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/gridstack.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/gridstack.min.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ gridstack.js API
7676
- `height` - maximum rows amount. Default is `0` which means no maximum rows
7777
- `float` - enable floating widgets (default: `false`) See [example](http://troolee.github.io/gridstack.js/demo/float.html)
7878
- `itemClass` - widget class (default: `'grid-stack-item'`)
79-
- `minWidth` - minimal width. If window width is less, grid will be shown in one-column mode. You need also update your css file (`@media (max-width: 768px) {...}`) with corresponding value (default: `768`)
79+
- `minWidth` - minimal width. If window width is less, grid will be shown in one-column mode (default: `768`)
80+
- `oneColumnModeClass` - class set on grid when in one column mode (default: 'grid-stack-one-column-mode')
8081
- `placeholderClass` - class for placeholder (default: `'grid-stack-placeholder'`)
8182
- `placeholderText` - placeholder default content (default: `''`)
8283
- `resizable` - allows to override jQuery UI resizable options. (default: `{autoHide: true, handles: 'se'}`)

src/gridstack.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,8 @@
547547
removable: false,
548548
removeTimeout: 2000,
549549
verticalMarginUnit: 'px',
550-
cellHeightUnit: 'px'
550+
cellHeightUnit: 'px',
551+
oneColumnModeClass: opts.oneColumnModeClass || 'grid-stack-one-column-mode'
551552
});
552553

553554
if (this.opts.rtl === 'auto') {
@@ -635,7 +636,7 @@
635636
if (oneColumnMode) {
636637
return;
637638
}
638-
639+
self.container.addClass(self.opts.oneColumnModeClass);
639640
oneColumnMode = true;
640641

641642
self.grid._sortNodes();
@@ -659,6 +660,7 @@
659660
return;
660661
}
661662

663+
self.container.removeClass(self.opts.oneColumnModeClass);
662664
oneColumnMode = false;
663665

664666
if (self.opts.staticGrid) {

src/gridstack.scss

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,18 @@ $animation_speed: .3s !default;
123123
&.grid-stack-animate .grid-stack-item.grid-stack-placeholder{
124124
@include vendor(transition, left .0s, top .0s, height .0s, width .0s);
125125
}
126-
}
127-
128-
@media (max-width: 768px) {
129-
.grid-stack-item {
130-
position: relative !important;
131-
width: auto !important;
132-
left: 0 !important;
133-
top: auto !important;
134-
margin-bottom: $vertical_padding;
135-
136-
.ui-resizable-handle { display: none; }
137-
}
138-
139-
.grid-stack { height: auto !important; }
126+
127+
&.grid-stack-one-column-mode {
128+
height: auto !important;
129+
&> .grid-stack-item {
130+
position: relative !important;
131+
width: auto !important;
132+
left: 0 !important;
133+
top: auto !important;
134+
margin-bottom: $vertical_padding;
135+
max-width: none !important;
136+
137+
&> .ui-resizable-handle { display: none; }
138+
}
139+
}
140140
}

0 commit comments

Comments
 (0)