Skip to content

Commit

Permalink
Merge pull request rlamana#22 from macqm/closing-fix
Browse files Browse the repository at this point in the history
Added fix for closed window state and tests
  • Loading branch information
rlamana committed Feb 10, 2015
2 parents 0e3c38d + 14ba32c commit 2d26489
Show file tree
Hide file tree
Showing 11 changed files with 11,491 additions and 49 deletions.
65 changes: 33 additions & 32 deletions dist/ventus.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/*!
* Ventus 0.2
* Copyright © 2015 Ramón Lamana
* http://www.rlamana.com
*/
(function (root, factory) {
if (typeof define === 'function' && define.amd) { // AMD.
define(['$'], factory);
} else { // Browser globals
root.Ventus = factory(root.$);
}
}(this, function ($) {

/*!
* Ventus 0.2
* Copyright © 2015 Ramón Lamana
* http://www.rlamana.com
*/
(function (root, factory) {
if (typeof define === 'function' && define.amd) { // AMD.
define(['$'], factory);
} else { // Browser globals
root.Ventus = factory(root.$);
}
}(this, function ($) {

var requirejs, require, define;
(function (undef) {
var defined = {}, waiting = {}, config = {}, defining = {}, aps = [].slice, main, req;
Expand Down Expand Up @@ -1131,11 +1131,11 @@ define('ventus/tpl/window', ['handlebars'], function (Handlebars) {
'name': 'classname',
'hash': {},
'data': data
}) : helper)) + '">\n\t<div class="wm-window-box">\n\t\t<header class="wm-window-title" unselectable="on">\n\t\t\t<h1 unselectable="on">' + escapeExpression((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : helperMissing, typeof helper === functionType ? helper.call(depth0, {
}) : helper)) + '">\r\n\t<div class="wm-window-box">\r\n\t\t<header class="wm-window-title" unselectable="on">\r\n\t\t\t<h1 unselectable="on">' + escapeExpression((helper = (helper = helpers.title || (depth0 != null ? depth0.title : depth0)) != null ? helper : helperMissing, typeof helper === functionType ? helper.call(depth0, {
'name': 'title',
'hash': {},
'data': data
}) : helper)) + '</h1>\n\t\t\t<div class="wm-button-group">\n\t\t\t\t<button class="wm-minimize">&nbsp;</button>\n\t\t\t\t<button class="wm-maximize">&nbsp;</button>\n\t\t\t\t<button class="wm-close">&nbsp;</button>\n\t\t\t</div>\n\t\t</header>\n\n\t\t<section class="wm-content"></section>\n\n\t\t<button class="wm-resize">&nbsp;</button>\n\t</div>\n\t<div class="wm-window-overlay"></div>\n</div>\n';
}) : helper)) + '</h1>\r\n\t\t\t<div class="wm-button-group">\r\n\t\t\t\t<button class="wm-minimize">&nbsp;</button>\r\n\t\t\t\t<button class="wm-maximize">&nbsp;</button>\r\n\t\t\t\t<button class="wm-close">&nbsp;</button>\r\n\t\t\t</div>\r\n\t\t</header>\r\n\r\n\t\t<section class="wm-content"></section>\r\n\r\n\t\t<button class="wm-resize">&nbsp;</button>\r\n\t</div>\r\n\t<div class="wm-window-overlay"></div>\r\n</div>\r\n';
},
'useData': true
});
Expand Down Expand Up @@ -1190,7 +1190,7 @@ define('ventus/wm/window', [
this.active = false;
this.maximized = false;
this.minimized = false;
this._closed = false;
this._closed = true;
this._destroyed = false;
this.widget = false;
this.movable = true;
Expand Down Expand Up @@ -1452,7 +1452,7 @@ define('ventus/wm/window', [
this.el.removeClass('opening');
promise.done();
}, this);
this.closed = false;
this._closed = false;
return promise;
},
close: function () {
Expand All @@ -1466,7 +1466,7 @@ define('ventus/wm/window', [
this.signals.emit('closed', this);
promise.done();
}, this);
this.closed = true;
this._closed = true;
return promise;
},
destroy: function () {
Expand Down Expand Up @@ -2506,17 +2506,18 @@ define('src/main', [
'handlebars',
'ventus'
], function () {
});

// Register in the values from the outer closure for common dependencies
// as local almond modules
define('$', function () {
return $;
});

define('underscore', function () {
return _;
});

return require('ventus');
}));
});

// Register in the values from the outer closure for common dependencies
// as local almond modules
define('$', function () {
return $;
});

define('underscore', function () {
return _;
});

return require('ventus');
}));

4 changes: 2 additions & 2 deletions dist/ventus.min.js

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ var gulp = require('gulp'),
handlebars = require('gulp-handlebars'),
declare = require('gulp-declare'),
defineModule = require('gulp-define-module'),
clean = require('gulp-clean');
clean = require('gulp-clean'),
mochaPhantomJS = require('gulp-mocha-phantomjs');

var paths = {
build: 'dist',
Expand Down Expand Up @@ -88,5 +89,9 @@ gulp.task('clean', function () {
.pipe(clean());
});

gulp.task('test', ['compile'], function() {
gulp.src('test/run.html')
.pipe(mochaPhantomJS());
});

gulp.task('default', ['less', 'templates', 'compile']);
22 changes: 13 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@
"private": true,
"dependencies": {},
"devDependencies": {
"gulp-uglify": "~1.0.2",
"gulp": "~3.8.10",
"jshint": "~2.5.11",
"gulp-jshint": "~1.9.0",
"amd-optimize": "~0.4.3",
"gulp-concat": "~2.4.3",
"gulp-wrap": "~0.9.0",
"gulp": "~3.8.10",
"gulp-autoprefixer": "~2.1.0",
"gulp-less": "~2.0.1",
"gulp-clean": "~0.3.1",
"gulp-concat": "~2.4.3",
"gulp-declare": "~0.3.0",
"gulp-handlebars": "~3.0.1",
"gulp-define-module": "~0.1.1",
"gulp-clean": "~0.3.1"
"gulp-handlebars": "~3.0.1",
"gulp-jshint": "~1.9.0",
"gulp-less": "~2.0.1",
"gulp-mocha-phantomjs": "^0.5.3",
"gulp-uglify": "~1.0.2",
"gulp-wrap": "~0.9.0",
"jshint": "~2.5.11"
},
"scripts": {
"test": "gulp test"
}
}
4 changes: 2 additions & 2 deletions src/ventus/tpl/window.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/ventus/wm/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function(Emitter, Promise, View, WindowTemplate) {
this.maximized = false;
this.minimized = false;

this._closed = false;
this._closed = true;
this._destroyed = false;

// Properties
Expand Down Expand Up @@ -439,7 +439,7 @@ function(Emitter, Promise, View, WindowTemplate) {
promise.done();
}, this);

this.closed = false;
this._closed = false;
return promise;
},

Expand All @@ -457,7 +457,7 @@ function(Emitter, Promise, View, WindowTemplate) {
promise.done();
}, this);

this.closed = true;
this._closed = true;
return promise;
},

Expand Down
36 changes: 36 additions & 0 deletions test/run.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Window tests</title>
<link rel="stylesheet" media="all" href="../vendor/mocha.css">
</head>
<body>
<div id="mocha"><p><a href=".">Index</a></p></div>
<div id="messages"></div>
<div id="fixtures"></div>
<!-- Require test libraries -->
<script src="../vendor/mocha.js"></script>
<script src="../vendor/chai.js"></script>

<!-- Require Ventus with dependencies -->
<script src="../vendor/jquery.js"></script>
<script src="../vendor/handlebars.js"></script><
<script src="../dist/Ventus.js"></script>

<!-- Set up mocha -->
<script>mocha.setup('bdd')</script>

<!-- Require the test -->
<script src="window.test.js"></script>

<!-- Run mocha -->
<script>
if (window.mochaPhantomJS) {
mochaPhantomJS.run();
} else {
mocha.run();
}
</script>
</body>
</html>
28 changes: 28 additions & 0 deletions test/window.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
var expect = chai.expect;

describe("Window", function() {

var wm;
var testWindow;

beforeEach(function() {
wm = new Ventus.WindowManager();
testWindow = wm.createWindow({title: "test"});
});

it("new window should be in closed state", function() {
expect(testWindow.closed).to.equal(true);
});

it("sets is initialized with opened state", function() {
testWindow.open();
expect(testWindow.closed).to.equal(false);
});

it("sets closed state to true when closed", function() {
testWindow.open();
testWindow.close();
expect(testWindow.closed).to.equal(true);
});

});
Loading

0 comments on commit 2d26489

Please sign in to comment.