Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Example UsageArgumentsReturn Value
api dialog = ds.openDialog(id, opts);id - a unique DOM identifier
opts - options for the dialog (see below) 
an API to configure the dialog. See below.

Both the id and opts arguments are passed through to the createPanel() function of the PanelService.

The opts object is angular.extended with the default options, shown below:

Code Block
languagejs
var defaultSettings = {
        width: 300,
        edge: 'left'
    };

If a cssCls property is defined on the options object, it's value is used as a CSS class that is applied to the dialog element.

 

closeDialog

Closes the dialog panel. This function is idempotent.

...

Creates a detached <div> element, returning a D3 selection. Optionally, a CSS class may be specified to be applied to the element. 

Example UsageArgumentsReturn Value
content = ds.createDiv('my-class');
content.append('p').text('Some text');
cssCls - optional CSS class to apply to the div element.D3 selection of a detached div element.

This is a convenience function to help in the construction of content for the dialog. See below for a more complete example.

Dialog API

The API returned from openDialog() provides methods to set the title, add content, and add buttons.

Example UsageArgumentsReturn Value
dialog.setTitle(title);title - the text to set as the titledialog API
dialog.addContent(content);content - a D3 selection to be appended to the content section of the dialogdialog API
dialog.addButton(text, cb);text - the text to display on the button
cb - the callback function to be invoked when the button is pressed 
dialog API


The following dialog box might have code structured as listed below:

Image Added

 

Code Block
languagejs
linenumberstrue
collapsetrue
// ds is a reference to the DialogService.
 
function createConfirmationText(action, itemId) {
    var content = ds.createDiv();

...


    content.append('p').text(action + ' ' + itemId);
    return content;
}

function confirmAction(action) {
    var itemId = $scope.selId,
    spar = $scope.sortParams;

    function dOk() {
        $log.debug('Initiating', action, 'of', itemId);
        wss.sendEvent(appMgmtReq, {
            action: action,
            name: sid,
            sortCol: spar.sortCol,
            sortDir: spar.sortDir
        });
    }

    function dCancel() {
        $log.debug(

...

'Canceling', action, 'of', itemId);
    }

    ds.openDialog(dialogId, dialogOpts)
        .setTitle('Confirm Action')
        .addContent(createConfirmationText(action, itemId))
        .addButton('OK', dOk)
        .addButton('Cancel', dCancel);
}


 

 

 

 

...