Skip to content

Commit

Permalink
Kiosk and Fullscreen API support
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislas Polu committed Oct 24, 2014
1 parent 7e5e645 commit d9d7c9c
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 19 deletions.
92 changes: 73 additions & 19 deletions lib/api.window.js
Expand Up @@ -36,24 +36,28 @@ var window = function(spec, my) {
//
// #### _public_
//
var show; /* show(cb_); */
var focus; /* focus(cb_); */
var maximize; /* maximize(cb_); */
var unmaximize; /* unmaximize(cb_); */
var minimize; /* minimize(cb_); */
var restore; /* restore(cb_); */
var close; /* close(cb_); */

var set_title; /* set_title(title, cb_); */
var move; /* move(x, y, cb_); */
var resize; /* resize(w, h, cb_); */

var is_closed; /* is_closed(cb_); */
var is_maximized; /* is_maximized(cb_); */
var is_minimized; /* is_minimized(cb_); */

var size; /* size(cb_); */
var position; /* position(cb_); */
var show; /* show(cb_); */
var focus; /* focus(cb_); */
var maximize; /* maximize(cb_); */
var unmaximize; /* unmaximize(cb_); */
var minimize; /* minimize(cb_); */
var restore; /* restore(cb_); */
var close; /* close(cb_); */

var set_title; /* set_title(title, cb_); */
var set_fullscreen; /* set_fullscreen(fullscreen, cb_); */
var set_kiosk; /* set_kiosk(kiosk, cb_); */
var move; /* move(x, y, cb_); */
var resize; /* resize(w, h, cb_); */

var is_closed; /* is_closed(cb_); */
var is_maximized; /* is_maximized(cb_); */
var is_minimized; /* is_minimized(cb_); */
var is_fullscreen; /* is_fullscreen(cb_); */
var is_kiosk; /* is_kiosk(cb_); */

var size; /* size(cb_); */
var position; /* position(cb_); */

//
// #### _protected_
Expand Down Expand Up @@ -163,6 +167,28 @@ var window = function(spec, my) {
that.call('set_title', { title: title }, cb_);
};

// ### set_fullscreen
//
// Sets the window fullscreen state
// ```
// @fullscreen {boolean} the window fullscreen state
// @cb_ {function(err)}
// ```
set_fullscreen = function(fullscreen, cb_) {
that.call('set_fullscreen', { fullscreen: fullscreen }, cb_);
};

// ### set_kiosk
//
// Sets the window kiosk state
// ```
// @kiosk {string} the window kiosk state
// @cb_ {function(err)}
// ```
set_kiosk = function(kiosk, cb_) {
that.call('set_kiosk', { kiosk: kiosk }, cb_);
};

// ### move
//
// Sets the window position
Expand Down Expand Up @@ -214,7 +240,7 @@ var window = function(spec, my) {

// ### is_minimized
//
// Gets the window maximization status
// Gets the window minimization status
// ```
// @cb_ {function(err, is_minimized)}
// ```
Expand All @@ -224,6 +250,30 @@ var window = function(spec, my) {
});
};

// ### is_fullscreen
//
// Gets the window fullscreen status
// ```
// @cb_ {function(err, is_fullscreen)}
// ```
is_fullscreen = function(cb_) {
that.call('is_fullscreen', {}, function(err, res) {
return cb_(err, res ? res.fullscreen : null);
});
};

// ### is_kiosk
//
// Gets the window kiosk status
// ```
// @cb_ {function(err, is_kiosk)}
// ```
is_kiosk = function(cb_) {
that.call('is_kiosk', {}, function(err, res) {
return cb_(err, res ? res.kiosk : null);
});
};



// ### size
Expand Down Expand Up @@ -261,12 +311,16 @@ var window = function(spec, my) {
common.method(that, 'close', close, _super);

common.method(that, 'set_title', set_title, _super);
common.method(that, 'set_fullscreen', set_fullscreen, _super);
common.method(that, 'set_kiosk', set_kiosk, _super);
common.method(that, 'move', move, _super);
common.method(that, 'resize', resize, _super);

common.method(that, 'is_closed', is_closed, _super);
common.method(that, 'is_maximized', is_maximized, _super);
common.method(that, 'is_minimized', is_minimized, _super);
common.method(that, 'is_fullscreen', is_fullscreen, _super);
common.method(that, 'is_kiosk', is_kiosk, _super);

common.method(that, 'size', size, _super);
common.method(that, 'position', position, _super);
Expand Down
35 changes: 35 additions & 0 deletions test/window_fullscreen.js
@@ -0,0 +1,35 @@
var async = require('async');
var common = require('../lib/common.js');

var _api = null;
var _window = null;

async.series([
function(cb_) {
require('./base.js')(function(err, api) {
_api = api;
return cb_(err);
});
},
function(cb_) {
_window = _api.window({
size: {
width: 1024,
height: 768
}
});
return cb_();
},
function(cb_) {
_window.show(cb_);
},
function(cb_) {
_window.set_fullscreen(true, cb_);
}
], function(err) {
if(err) {
common.log.out('FAILED');
common.log.error(err);
}
common.log.out('OK');
});
35 changes: 35 additions & 0 deletions test/window_kiosk.js
@@ -0,0 +1,35 @@
var async = require('async');
var common = require('../lib/common.js');

var _api = null;
var _window = null;

async.series([
function(cb_) {
require('./base.js')(function(err, api) {
_api = api;
return cb_(err);
});
},
function(cb_) {
_window = _api.window({
size: {
width: 1024,
height: 768
}
});
return cb_();
},
function(cb_) {
_window.show(cb_);
},
function(cb_) {
_window.set_kiosk(true, cb_);
}
], function(err) {
if(err) {
common.log.out('FAILED');
common.log.error(err);
}
common.log.out('OK');
});

0 comments on commit d9d7c9c

Please sign in to comment.