if (app.griddder instanceof Function) {
    if (selection.length) {

        // dialog window
            var window = new Window('dialog','Calendarik', undefined),
                panel = window.add('panel'),

                // panel title
                    panelTitle = panel.add('statictext', [0, 0, 55, 15], '阵列复制'),

                // rows & columns
                    // rows & columns titles
                        groupFieldTitles = panel.add('group'),
                        titleColumns = groupFieldTitles.add('statictext', [0, 0, 60, 15], '行数:'),
                        titleRows = groupFieldTitles.add('statictext', [0, 0, 60, 15], '列数:'),

                    // rows & columns inputs
                        groupFieldInputs = panel.add('group'),
                        inputColumns = groupFieldInputs.add('edittext', [0, 0, 60, 30], '2'),
                        inputRows = groupFieldInputs.add('edittext', [0, 0, 60, 30], '2'),

                // gutter rows & columns
                    // gutter rows & columns titles
                        groupGutterTitles = panel.add('group'),
						titleRows = groupGutterTitles.add('statictext', [0, 0, 60, 15], '行间距:'),
                        titleColumns = groupGutterTitles.add('statictext', [0, 0, 60, 15], '列间距:'),

                    // gutter rows & columns inputs
                        groupGutterInputs = panel.add('group'),
                        inputGutterColumns = groupGutterInputs.add('edittext', [0, 0, 60, 30], '0'),
                        inputGutterRows = groupGutterInputs.add('edittext', [0, 0, 60, 30], '0'),

                // buttons
                    buttonsGroup = window.add('group'),
                    applyButton = buttonsGroup.add('button', [0, 0, 100, 30], '应用', { name: 'OK' } ),
                    closeButton = buttonsGroup.add('button', [0, 0, 100, 30], '取消', { name: 'Cancel' } );

                // year events
                    function numberInputKeydownHandler (e, item) {
                        var val = false;
                        if (e.keyName === 'Down') val = -1;
                        if (e.keyName === 'Up') val = 1;
                        if (val) item.text = (parseInt(item.text) + val) || new Date().getFullYear();
                    }
                    inputColumns.addEventListener('keydown', function (e) {
                        numberInputKeydownHandler(e, this);
                    });
                    inputRows.addEventListener('keydown', function (e) {
                        numberInputKeydownHandler(e, this);
                    });
                    inputGutterColumns.addEventListener('keydown', function (e) {
                        numberInputKeydownHandler(e, this);
                    });
                    inputGutterRows.addEventListener('keydown', function (e) {
                        numberInputKeydownHandler(e, this);
                    });

                // run
                    applyButton.onClick = function () {
                        selection.griddder({
                            rows:    parseInt(inputRows.text),
                            columns: parseInt(inputColumns.text),
                            gutter:{
                                rows:    parseInt(inputGutterRows.text),
                                columns: parseInt(inputGutterColumns.text),
                            }
                        });

                        window.hide();
                    };

                // close window
                    closeButton.onClick = function () {
                        window.hide();
                    };

            // auto show
                window.show();
    }
        else {
            alert('请先选择对象！');
        }
}
    else {
        alert('请开启支持库 - "AI_PS_library.js"');
    }