Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/externals/javelin/lib/Workflow.js
Show First 20 Lines • Show All 398 Lines • ▼ Show 20 Lines | _onload : function(r) { | ||||
this.getHandler()(r); | this.getHandler()(r); | ||||
this._pop(); | this._pop(); | ||||
} else if (r) { | } else if (r) { | ||||
if (__DEV__) { | if (__DEV__) { | ||||
JX.$E('Response to workflow request went unhandled.'); | JX.$E('Response to workflow request went unhandled.'); | ||||
} | } | ||||
} | } | ||||
// Only when the response is a Dialog, check if the user | |||||
// is quitting with pending changes | |||||
if (this._root) { | |||||
var form = JX.DOM.scry(this._root, 'form', 'jx-dialog'); | var form = JX.DOM.scry(this._root, 'form', 'jx-dialog'); | ||||
if (form.length) { | if (form.length) { | ||||
JX.DOM.listen(form[0], 'keydown', null, function(e) { | JX.DOM.listen(form[0], 'keydown', null, function(e) { | ||||
if (e.getSpecialKey()) { | if (e.getSpecialKey()) { | ||||
return; | return; | ||||
} | } | ||||
JX.Stratcom.addSigil(form[0], 'dialog-keydown'); | JX.Stratcom.addSigil(form[0], 'dialog-keydown'); | ||||
}); | }); | ||||
} | } | ||||
} | |||||
}, | }, | ||||
_push : function() { | _push : function() { | ||||
if (!this._pushed) { | if (!this._pushed) { | ||||
this._pushed = true; | this._pushed = true; | ||||
JX.Workflow._push(this); | JX.Workflow._push(this); | ||||
} | } | ||||
}, | }, | ||||
_pop : function() { | _pop : function() { | ||||
▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | function close_dialog_when_user_presses_escape(e) { | ||||
} | } | ||||
} | } | ||||
if (!cancel) { | if (!cancel) { | ||||
// No 'Cancel' button. | // No 'Cancel' button. | ||||
return; | return; | ||||
} | } | ||||
// Only when the response is a Dialog, check if the user | |||||
// is quitting with pending changes | |||||
if (active._root) { | |||||
var form = JX.DOM.scry(active._root, 'form', 'jx-dialog'); | var form = JX.DOM.scry(active._root, 'form', 'jx-dialog'); | ||||
var confirmMsg = | |||||
'Form data may have changed. ' + | |||||
'Are you sure you want to close this dialog?'; | |||||
if ( | if ( | ||||
form.length && | form.length && | ||||
JX.Stratcom.hasSigil(form[0], 'dialog-keydown') && | JX.Stratcom.hasSigil(form[0], 'dialog-keydown') && | ||||
!confirm('Form data may have changed. Are you sure you want to close this dialog?') | !window.confirm(confirmMsg) | ||||
) { | ) { | ||||
return; | return; | ||||
} | } | ||||
} | |||||
JX.Workflow._pop(); | JX.Workflow._pop(); | ||||
e.prevent(); | e.prevent(); | ||||
} | } | ||||
JX.Stratcom.listen('keydown', null, close_dialog_when_user_presses_escape); | JX.Stratcom.listen('keydown', null, close_dialog_when_user_presses_escape); | ||||
JX.Stratcom.listen('mousemove', null, JX.Workflow._onmousemove); | JX.Stratcom.listen('mousemove', null, JX.Workflow._onmousemove); | ||||
JX.Stratcom.listen('mouseup', null, JX.Workflow._onmouseup); | JX.Stratcom.listen('mouseup', null, JX.Workflow._onmouseup); | ||||
} | } | ||||
}); | }); |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0