Skip to content

Commit 61fc120

Browse files
committed
Merge commit '93bedb4404597ab74426141aa3aec27ef6134dd1'
2 parents 205df5d + 93bedb4 commit 61fc120

File tree

11 files changed

+186
-10
lines changed

11 files changed

+186
-10
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
bower_components
3-
coverage
3+
coverage
4+
*.log

.travis.yml

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,35 @@
11
language: node_js
22

3+
node_js:
4+
- "5.7.0"
5+
6+
env:
7+
- CXX=g++-4.8
8+
9+
addons:
10+
apt:
11+
sources:
12+
- ubuntu-toolchain-r-test
13+
packages:
14+
- g++-4.8
15+
16+
before_install:
17+
- npm install -g protractor
18+
19+
install:
20+
- npm install -g npm@2
21+
- npm install -g grunt-cli
22+
- npm install -g bower
23+
- bower install
24+
- npm install
25+
- ./node_modules/protractor/bin/webdriver-manager update --standalone
26+
327
before_script:
4-
- npm install -g grunt-cli
5-
- npm install -g bower
6-
- bower install
7-
- npm install
28+
- export CHROME_BIN=chromium-browser
29+
- export DISPLAY=:99.0
30+
- sh -e /etc/init.d/xvfb start
831

932
script:
10-
- npm run build
11-
- npm test
33+
- npm run build
34+
- npm test
35+
- grunt e2e-test

Gruntfile.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
12
module.exports = function(grunt) {
23
grunt.loadNpmTasks('grunt-sass');
34
grunt.loadNpmTasks('grunt-contrib-cssmin');
@@ -7,6 +8,9 @@ module.exports = function(grunt) {
78
grunt.loadNpmTasks('grunt-contrib-jshint');
89
grunt.loadNpmTasks('grunt-jscs');
910
grunt.loadNpmTasks('grunt-contrib-watch');
11+
grunt.loadNpmTasks('grunt-protractor-runner');
12+
grunt.loadNpmTasks('grunt-contrib-connect');
13+
grunt.loadNpmTasks('grunt-protractor-webdriver');
1014

1115
grunt.initConfig({
1216
sass: {
@@ -95,7 +99,33 @@ module.exports = function(grunt) {
9599
},
96100
},
97101
},
102+
103+
protractor: {
104+
options: {
105+
configFile: 'protractor.conf.js',
106+
},
107+
all: {}
108+
},
109+
110+
connect: {
111+
all: {
112+
options: {
113+
port: 8080,
114+
hostname: 'localhost',
115+
base: '.',
116+
},
117+
},
118+
},
119+
120+
protractor_webdriver: {
121+
all: {
122+
options: {
123+
command: 'webdriver-manager start',
124+
}
125+
}
126+
}
98127
});
99128

100129
grunt.registerTask('default', ['sass', 'cssmin', 'jshint', 'jscs', 'copy', 'uglify', 'doctoc']);
130+
grunt.registerTask('e2e-test', ['connect', 'protractor_webdriver', 'protractor']);
101131
};

dist/gridstack.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,10 @@
367367
return $.extend({}, n);
368368
}));
369369

370+
if (typeof clonedNode === 'undefined') {
371+
return true;
372+
}
373+
370374
clone.moveNode(clonedNode, x, y, width, height);
371375

372376
var res = true;

dist/gridstack.min.js

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.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.

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,27 @@
3030
"lodash": "^4.5.1"
3131
},
3232
"devDependencies": {
33+
"connect": "^3.4.1",
3334
"coveralls": "^2.11.6",
3435
"grunt": "^0.4.5",
36+
"grunt-contrib-connect": "^0.11.2",
3537
"grunt-contrib-copy": "^0.8.2",
3638
"grunt-contrib-cssmin": "^0.14.0",
3739
"grunt-contrib-jshint": "^1.0.0",
3840
"grunt-contrib-uglify": "^0.11.1",
3941
"grunt-contrib-watch": "^0.6.1",
4042
"grunt-doctoc": "^0.1.1",
4143
"grunt-jscs": "^2.7.0",
44+
"grunt-protractor-runner": "^3.0.0",
45+
"grunt-protractor-webdriver": "^0.2.5",
4246
"grunt-sass": "^1.1.0",
4347
"jasmine-core": "^2.4.1",
4448
"karma": "^0.13.21",
4549
"karma-coverage": "^0.5.3",
4650
"karma-coveralls": "^1.1.2",
4751
"karma-jasmine": "^0.3.7",
4852
"karma-phantomjs-launcher": "^1.0.0",
49-
"phantomjs": "^2.1.3"
53+
"phantomjs-prebuilt": "^2.1.4",
54+
"serve-static": "^1.10.2"
5055
}
5156
}

protractor.conf.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
exports.config = {
2+
seleniumAddress: 'http://localhost:4444/wd/hub',
3+
specs: ['spec/e2e/*-spec.js'],
4+
capabilities: {
5+
browserName: 'firefox',
6+
version: '',
7+
platform: 'ANY',
8+
loggingPrefs: {
9+
browser: 'SEVERE'
10+
}
11+
},
12+
};

spec/e2e/gridstack-spec.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
describe('gridstack.js with height', function() {
2+
beforeAll(function() {
3+
browser.ignoreSynchronization = true;
4+
});
5+
6+
beforeEach(function() {
7+
browser.get('http://localhost:8080/spec/e2e/html/gridstack-with-height.html');
8+
});
9+
10+
it('shouldn\'t throw exeption when dragging widget outside the grid', function() {
11+
var widget = element(by.id('item-1'));
12+
var gridContainer = element(by.id('grid'));
13+
14+
browser.actions()
15+
.mouseDown(widget, {x: 20, y: 20})
16+
.mouseMove(gridContainer, {x: 300, y: 20})
17+
.mouseUp()
18+
.perform();
19+
20+
browser.manage().logs().get('browser').then(function(browserLog) {
21+
expect(browserLog.length).toEqual(0);
22+
});
23+
});
24+
});
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<!--[if lt IE 9]>
5+
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
6+
<![endif]-->
7+
8+
<meta charset="utf-8">
9+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
10+
<meta name="viewport" content="width=device-width, initial-scale=1">
11+
<title>gridstack.js tests</title>
12+
13+
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
14+
<link rel="stylesheet" href="../../../dist/gridstack.css"/>
15+
16+
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
17+
<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.0/jquery-ui.js"></script>
18+
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
19+
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/3.5.0/lodash.min.js"></script>
20+
<script src="../../../dist/gridstack.js"></script>
21+
22+
<style type="text/css">
23+
.grid-stack {
24+
background: lightgoldenrodyellow;
25+
}
26+
27+
.grid-stack-item-content {
28+
color: #2c3e50;
29+
text-align: center;
30+
background-color: #18bc9c;
31+
}
32+
</style>
33+
</head>
34+
<body>
35+
<div class="container-fluid">
36+
<h1>gridstack.js tests</h1>
37+
38+
<br/>
39+
40+
<div class="grid-stack" id="grid">
41+
</div>
42+
</div>
43+
44+
45+
<script type="text/javascript">
46+
$(function() {
47+
var options = {
48+
height: 5
49+
};
50+
$('.grid-stack').gridstack(options);
51+
52+
new function() {
53+
var items = [
54+
{x: 0, y: 0, width: 2, height: 2},
55+
{x: 2, y: 5, width: 1, height: 1}
56+
];
57+
58+
this.grid = $('.grid-stack').data('gridstack');
59+
this.grid.removeAll();
60+
items = GridStackUI.Utils.sort(items);
61+
var id = 0;
62+
_.each(items, function(node) {
63+
var w = $('<div><div class="grid-stack-item-content" /><div/>');
64+
w.attr('id', 'item-' + (++id));
65+
this.grid.addWidget(w,
66+
node.x, node.y, node.width, node.height);
67+
}, this);
68+
};
69+
});
70+
</script>
71+
</body>
72+
</html>

0 commit comments

Comments
 (0)