some refactoring...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-12-26 05:50:29 +03:00
parent f4ad8d562a
commit 26129e8efc

View File

@ -425,6 +425,9 @@ module.uiDialog = function(func){
// NOTE: arguments after the constructor will be passed to the container. // NOTE: arguments after the constructor will be passed to the container.
// //
// XXX do we need a means to reuse containers, e.g. ??? // XXX do we need a means to reuse containers, e.g. ???
// XXX need to revise this API as passing a container title ONLY works
// for actions explicitly created with makeUIDialog(..) and not
// extended/overloaded...
var makeUIDialog = var makeUIDialog =
module.makeUIDialog = function(a, b){ module.makeUIDialog = function(a, b){
var args = [].slice.call(arguments) var args = [].slice.call(arguments)
@ -441,7 +444,6 @@ module.makeUIDialog = function(a, b){
return uiDialog(function(){ return uiDialog(function(){
var args = [].slice.call(arguments) var args = [].slice.call(arguments)
// see if the first arg is a container spec... // see if the first arg is a container spec...
var container = !(args[0] instanceof Array) && this.isUIContainer(args[0]) ? var container = !(args[0] instanceof Array) && this.isUIContainer(args[0]) ?
args.shift() args.shift()
@ -645,25 +647,34 @@ var DialogsActions = actions.Actions({
// testers... // testers...
// //
// XXX should these test only the root action or the whole tree??? // ui elements...
isUIContainer: ['- Interface/', isUIContainer: ['- Interface/',
function(action){ function(action){
return !!this.getActionAttr(action, '__container__') }], return !!this.getActionAttr(action, '__container__') }],
//actions.doWithRootAction(function(action){
// return action != null
// && action.__container__ == true })],
isUIDialog: ['- Interface/', isUIDialog: ['- Interface/',
function(action){ function(action){
return !!this.getActionAttr(action, '__dialog__') }], return !!this.getActionAttr(action, '__dialog__') }],
//actions.doWithRootAction(function(action){
// return action != null
// && action.__dialog__ == true })],
isUIElement: ['- Interface/', isUIElement: ['- Interface/',
function(action){ function(action){
return this.isUIDialog(action) || this.isUIContainer(action) }], return this.isUIDialog(action) || this.isUIContainer(action) }],
//actions.doWithRootAction(function(action){ // extended ui elements
// return action != null // ...first defined as a non-ui action and extended to a ui element.
// && (action.__dialog__ == true || action.__container__ == true) })], isUIExtendedContainer: ['- Interface/',
actions.doWithRootAction(function(action, name){
return action != null
&& !action.__container__
&& this.isUIContainer(name) })],
isUIExtendedDialog: ['- Interface/',
actions.doWithRootAction(function(action, name){
return action != null
&& !action.__dialog__
&& this.isUIDialog(name) })],
isUIExtendedElement: ['- Interface/',
actions.doWithRootAction(function(action, name){
return action != null
&& !action.__dialog__
&& !action.__container__
&& this.isUIElement(name) })],
// container constructors... // container constructors...
@ -708,7 +719,7 @@ var DialogsActions = actions.Actions({
.appendTo(this.dom) .appendTo(this.dom)
.draggable(), .draggable(),
close: function(func){ close: function(func){
if(func){ if(func instanceof Function){
this.dom.on('close', func) this.dom.on('close', func)
} else { } else {
this.dom.trigger('close', 'reject') this.dom.trigger('close', 'reject')
@ -716,6 +727,8 @@ var DialogsActions = actions.Actions({
} }
return this return this
}, },
focus: function(){
},
} }
dialog.on('blur', function(){ dialog.on('blur', function(){