MessageBox added keybindings
This commit is contained in:
parent
d3f924adf3
commit
a08b0f3d5e
@ -14,7 +14,7 @@
|
|||||||
max-width: 800px;
|
max-width: 800px;
|
||||||
max-height: 600px;
|
max-height: 600px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
background: #222;
|
background-color: rgba( 0, 0, 0, 0.8 );
|
||||||
|
|
||||||
-moz-box-shadow: 0 0 10px black;
|
-moz-box-shadow: 0 0 10px black;
|
||||||
-webkit-box-shadow: 0 0 10px black;
|
-webkit-box-shadow: 0 0 10px black;
|
||||||
@ -25,7 +25,7 @@
|
|||||||
font-size: 1.2em;
|
font-size: 1.2em;
|
||||||
padding: 0.35em;
|
padding: 0.35em;
|
||||||
color: white;
|
color: white;
|
||||||
background: #181818;
|
background-color: rgba( 0, 0, 0, 0.5 );
|
||||||
}
|
}
|
||||||
|
|
||||||
.mbox_content {
|
.mbox_content {
|
||||||
|
@ -5,11 +5,18 @@
|
|||||||
var Trigger = __import( "System.Cycle.Trigger" );
|
var Trigger = __import( "System.Cycle.Trigger" );
|
||||||
/** @type {Dandelion} */
|
/** @type {Dandelion} */
|
||||||
var Dand = __import( "Dandelion" );
|
var Dand = __import( "Dandelion" );
|
||||||
|
/** @type {Dandelion.IDOMObject} */
|
||||||
|
var IDOMObject = __import( "Dandelion.IDOMObject" );
|
||||||
|
/** @type {System.utils.EventKey} */
|
||||||
|
var EventKey = __import( "System.utils.EventKey" );
|
||||||
|
|
||||||
// __import( "Dandelion.CSSAnimations" ); CSS_RESERVATION
|
// __import( "Dandelion.CSSAnimations" ); CSS_RESERVATION
|
||||||
|
|
||||||
var MessageBox = function ( title, content, yes, no, handler )
|
var MessageBox = function ( title, content, yes, no, handler )
|
||||||
{
|
{
|
||||||
|
var _self = this;
|
||||||
|
var doc = IDOMObject( document );
|
||||||
|
|
||||||
var _yes = Dand.wrap(
|
var _yes = Dand.wrap(
|
||||||
"span", null
|
"span", null
|
||||||
, "mbox_button"
|
, "mbox_button"
|
||||||
@ -20,10 +27,10 @@
|
|||||||
_yes.onclick = function()
|
_yes.onclick = function()
|
||||||
{
|
{
|
||||||
// if handler is set
|
// if handler is set
|
||||||
if( this.clickHandler ) this.clickHandler( true );
|
if( _self.clickHandler ) _self.clickHandler( true );
|
||||||
document.body.removeChild( this.stage );
|
document.body.removeChild( _self.stage );
|
||||||
this.stage = null;
|
_self.stage = null;
|
||||||
}.bind( this );
|
};
|
||||||
|
|
||||||
if ( no )
|
if ( no )
|
||||||
{
|
{
|
||||||
@ -35,12 +42,33 @@
|
|||||||
|
|
||||||
_no.onclick = function()
|
_no.onclick = function()
|
||||||
{
|
{
|
||||||
if( this.clickHandler ) this.clickHandler( false );
|
if( _self.clickHandler ) _self.clickHandler( false );
|
||||||
document.body.removeChild( this.stage );
|
document.body.removeChild( _self.stage );
|
||||||
this.stage = null;
|
_self.stage = null;
|
||||||
}.bind( this );
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var keyBinding = new EventKey(
|
||||||
|
"KeyDown", function ( e )
|
||||||
|
{
|
||||||
|
e = e || window.event;
|
||||||
|
if ( e.keyCode ) code = e.keyCode;
|
||||||
|
else if ( e.which ) code = e.which;
|
||||||
|
|
||||||
|
if ( no && code == 27 )
|
||||||
|
{
|
||||||
|
_no.click();
|
||||||
|
doc.removeEventListener( keyBinding );
|
||||||
|
}
|
||||||
|
else if( code == 13 && ( e.ctrlKey || e.altKey ) )
|
||||||
|
{
|
||||||
|
_yes.click();
|
||||||
|
doc.removeEventListener( keyBinding );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
doc.addEventListener( keyBinding );
|
||||||
|
|
||||||
// set handler
|
// set handler
|
||||||
if ( handler ) this.clickHandler = handler;
|
if ( handler ) this.clickHandler = handler;
|
||||||
|
Loading…
Reference in New Issue
Block a user