Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
open-source
gridstack.js
Commits
57c65116
Commit
57c65116
authored
Sep 19, 2017
by
radiolips
Committed by
GitHub
Sep 19, 2017
Browse files
Merge pull request #786 from adumesny/develop
fixed cellHeight() check for no-op return
parents
10e141ed
b00f8160
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
15 deletions
+47
-15
spec/gridstack-spec.js
spec/gridstack-spec.js
+46
-14
src/gridstack.js
src/gridstack.js
+1
-1
No files found.
spec/gridstack-spec.js
View file @
57c65116
...
...
@@ -5,16 +5,16 @@ describe('gridstack', function() {
var
w
;
var
gridstackHTML
=
'
<div class="grid-stack">
'
+
'
<div class="grid-stack-item"
'
+
'
data-gs-x="0" data-gs-y="0"
'
+
'
data-gs-width="4" data-gs-height="2">
'
+
'
<div class="grid-stack-item-content"></div>
'
+
'
</div>
'
+
'
<div class="grid-stack-item"
'
+
'
data-gs-x="
0
" data-gs-y="0"
'
+
'
data-gs-width="4" data-gs-height="
2
">
'
+
'
<div class="grid-stack-item-content"></div>
'
+
'
data-gs-x="
4
" data-gs-y="0"
'
+
'
data-gs-width="4" data-gs-height="
4
">
'
+
'
<div class="grid-stack-item-content"></div>
'
+
'
</div>
'
+
'
<div class="grid-stack-item"
'
+
'
data-gs-x="4" data-gs-y="0"
'
+
'
data-gs-width="4" data-gs-height="4">
'
+
'
<div class="grid-stack-item-content"></div>
'
+
'
</div>
'
+
'
</div>
'
;
beforeEach
(
function
()
{
...
...
@@ -244,6 +244,38 @@ describe('gridstack', function() {
});
});
describe
(
'
grid.cellHeight
'
,
function
()
{
beforeEach
(
function
()
{
document
.
body
.
insertAdjacentHTML
(
'
afterbegin
'
,
gridstackHTML
);
});
afterEach
(
function
()
{
document
.
body
.
removeChild
(
document
.
getElementsByClassName
(
'
grid-stack
'
)[
0
]);
});
it
(
'
should have no changes
'
,
function
()
{
var
options
=
{
cellHeight
:
80
,
verticalMargin
:
10
,
width
:
12
};
$
(
'
.grid-stack
'
).
gridstack
(
options
);
var
grid
=
$
(
'
.grid-stack
'
).
data
(
'
gridstack
'
);
grid
.
cellHeight
(
grid
.
cellHeight
()
);
expect
(
grid
.
cellHeight
()).
toBe
(
80
);
});
it
(
'
should change cellHeight to 120
'
,
function
()
{
var
options
=
{
cellHeight
:
80
,
verticalMargin
:
10
,
width
:
10
};
$
(
'
.grid-stack
'
).
gridstack
(
options
);
var
grid
=
$
(
'
.grid-stack
'
).
data
(
'
gridstack
'
);
grid
.
cellHeight
(
120
);
expect
(
grid
.
cellHeight
()).
toBe
(
120
);
});
});
describe
(
'
grid.minWidth
'
,
function
()
{
beforeEach
(
function
()
{
document
.
body
.
insertAdjacentHTML
(
...
...
@@ -838,9 +870,9 @@ describe('gridstack', function() {
$
(
'
.grid-stack
'
).
gridstack
(
options
);
var
grid
=
$
(
'
.grid-stack
'
).
data
(
'
gridstack
'
);
var
widgetHTML
=
'
<div class="grid-stack-item">
'
+
'
<div class="grid-stack-item-content"></div>
'
+
'
</div>
'
;
'
<div class="grid-stack-item">
'
+
'
<div class="grid-stack-item-content"></div>
'
+
'
</div>
'
;
var
widget
=
grid
.
addWidget
(
widgetHTML
,
6
,
7
,
2
,
3
,
false
,
1
,
4
,
2
,
5
,
'
coolWidget
'
);
var
$widget
=
$
(
widget
);
expect
(
parseInt
(
$widget
.
attr
(
'
data-gs-x
'
),
10
)).
toBe
(
6
);
...
...
@@ -872,9 +904,9 @@ describe('gridstack', function() {
$
(
'
.grid-stack
'
).
gridstack
(
options
);
var
grid
=
$
(
'
.grid-stack
'
).
data
(
'
gridstack
'
);
var
widgetHTML
=
'
<div class="grid-stack-item">
'
+
'
<div class="grid-stack-item-content"></div>
'
+
'
</div>
'
;
'
<div class="grid-stack-item">
'
+
'
<div class="grid-stack-item-content"></div>
'
+
'
</div>
'
;
var
widget
=
grid
.
addWidget
(
widgetHTML
,
9
,
7
,
2
,
3
,
true
);
var
$widget
=
$
(
widget
);
expect
(
parseInt
(
$widget
.
attr
(
'
data-gs-x
'
),
10
)).
not
.
toBe
(
6
);
...
...
src/gridstack.js
View file @
57c65116
...
...
@@ -1610,7 +1610,7 @@
}
var
heightData
=
Utils
.
parseHeight
(
val
);
if
(
this
.
opts
.
cellHeightUnit
===
heightData
.
heightU
nit
&&
this
.
opts
.
h
eight
===
heightData
.
height
)
{
if
(
this
.
opts
.
cellHeightUnit
===
heightData
.
u
nit
&&
this
.
opts
.
cellH
eight
===
heightData
.
height
)
{
return
;
}
this
.
opts
.
cellHeightUnit
=
heightData
.
unit
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment