examples/HTML StarterKit/lib/durandal/js/plugins/dialog.js
function(obj, activationData, context) {
            var that = this;
            var dialogContext = contexts[context || 'default'];

            return system.defer(function(dfd) {
                ensureDialogInstance(obj).then(function(instance) {
                    var dialogActivator = activator.create();

                    dialogActivator.activateItem(instance, activationData).then(function (success) {
                        if (success) {
                            var theDialog = instance.__dialog__ = {
                                owner: instance,
                                context: dialogContext,
                                activator: dialogActivator,
                                close: function () {
                                    var args = arguments;
                                    dialogActivator.deactivateItem(instance, true).then(function (closeSuccess) {
                                        if (closeSuccess) {
                                            dialogCount--;
                                            dialogContext.removeHost(theDialog);
                                            delete instance.__dialog__;

                                            if (args.length === 0) {
                                                dfd.resolve();
                                            } else if (args.length === 1) {
                                                dfd.resolve(args[0]);
                                            } else {
                                                dfd.resolve.apply(dfd, args);
                                            }
                                        }
                                    });
                                }
                            };

                            theDialog.settings = that.createCompositionSettings(instance, dialogContext);
                            dialogContext.addHost(theDialog);

                            dialogCount++;
                            composition.compose(theDialog.host, theDialog.settings);
                        } else {
                            dfd.resolve(false);
                        }
                    });
                });
            }).promise();
        }
function(obj, activationData, context) {
            var that = this;
            var dialogContext = contexts[context || 'default'];

            return system.defer(function(dfd) {
                ensureDialogInstance(obj).then(function(instance) {
                    var dialogActivator = activator.create();

                    dialogActivator.activateItem(instance, activationData).then(function (success) {
                        if (success) {
                            var theDialog = instance.__dialog__ = {
                                owner: instance,
                                context: dialogContext,
                                activator: dialogActivator,
                                close: function () {
                                    var args = arguments;
                                    dialogActivator.deactivateItem(instance, true).then(function (closeSuccess) {
                                        if (closeSuccess) {
                                            dialogCount--;
                                            dialogContext.removeHost(theDialog);
                                            delete instance.__dialog__;

                                            if (args.length === 0) {
                                                dfd.resolve();
                                            } else if (args.length === 1) {
                                                dfd.resolve(args[0]);
                                            } else {
                                                dfd.resolve.apply(dfd, args);
                                            }
                                        }
                                    });
                                }
                            };

                            theDialog.settings = that.createCompositionSettings(instance, dialogContext);
                            dialogContext.addHost(theDialog);

                            dialogCount++;
                            composition.compose(theDialog.host, theDialog.settings);
                        } else {
                            dfd.resolve(false);
                        }
                    });
                });
            }).promise();
        }
function ( obj , activationData , context ) { var that = this ; var dialogContext = contexts [ context || 'default' ] ; return system . defer ( function ( dfd ) { ensureDialogInstance ( obj ) . then ( function ( instance ) { var dialogActivator = activator . create ( ) ; dialogActivator . activateItem ( instance , activationData ) . then ( function ( success ) { if ( success ) { var theDialog = instance . __dialog__ = { owner : instance , context : dialogContext , activator : dialogActivator , close : function ( ) { var args = arguments ; dialogActivator . deactivateItem ( instance , true ) . then ( function ( closeSuccess ) { if ( closeSuccess ) { dialogCount -- ; dialogContext . removeHost ( theDialog ) ; delete instance . __dialog__ ; if ( args . length === 0 ) { dfd . resolve ( ) ; } else if ( args . length === 1 ) { dfd . resolve ( args [ 0 ] ) ; } else { dfd . resolve . apply ( dfd , args ) ; } } } ) ; } } ; theDialog . settings = that . createCompositionSettings ( instance , dialogContext ) ; dialogContext . addHost ( theDialog ) ; dialogCount ++ ; composition . compose ( theDialog . host , theDialog . settings ) ; } else { dfd . resolve ( false ) ; } } ) ; } ) ; } ) . promise ( ) ; }
Shows a dialog.
@method show
@param {object|string} obj The object (or moduleId) to display as a dialog.
@param {object} [activationData] The data that should be passed to the object upon activation.
@param {string} [context] The name of the dialog context to use. Uses the default context if none is specified.
@return {Promise} A promise that resolves when the dialog is closed and returns any data passed at the time of closing.
Shows a dialog .