mirror of
https://github.com/nasa/openmct.git
synced 2024-12-20 05:37:53 +00:00
[API] Title dialog
This commit is contained in:
parent
13920d8802
commit
dbe6a4efc1
@ -85,8 +85,8 @@ define([
|
||||
});
|
||||
};
|
||||
|
||||
MCT.prototype.dialog = function (view) {
|
||||
return new Dialog(view).show();
|
||||
MCT.prototype.dialog = function (view, title) {
|
||||
return new Dialog(view, title).show();
|
||||
};
|
||||
|
||||
MCT.prototype.start = function () {
|
||||
|
@ -1,25 +1,30 @@
|
||||
define(['text!./dialog.html', 'zepto'], function (overlayTemplate, $) {
|
||||
function Dialog(view) {
|
||||
define(['text!./dialog.html', 'zepto'], function (dialogTemplate, $) {
|
||||
function Dialog(view, title) {
|
||||
this.view = view;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
Dialog.prototype.show = function () {
|
||||
var $body = $('body');
|
||||
var $overlay = $(overlayTemplate);
|
||||
var $contents = $overlay.find('.contents .editor');
|
||||
var $close = $overlay.find('.close');
|
||||
var $dialog = $(dialogTemplate);
|
||||
var $contents = $dialog.find('.contents .editor');
|
||||
var $close = $dialog.find('.close');
|
||||
|
||||
var $ok = $overlay.find('.ok');
|
||||
var $cancel = $overlay.find('.cancel');
|
||||
var $ok = $dialog.find('.ok');
|
||||
var $cancel = $dialog.find('.cancel');
|
||||
|
||||
var view = this.view;
|
||||
|
||||
function dismiss() {
|
||||
$overlay.remove();
|
||||
$dialog.remove();
|
||||
view.destroy();
|
||||
}
|
||||
|
||||
$body.append($overlay);
|
||||
if (this.title) {
|
||||
$dialog.find('.title').text(this.title);
|
||||
}
|
||||
|
||||
$body.append($dialog);
|
||||
this.view.show($contents[0]);
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
|
@ -115,14 +115,16 @@ define([
|
||||
$(container).append($els);
|
||||
|
||||
$add.on('click', function () {
|
||||
mct.dialog({
|
||||
var view = {
|
||||
show: function (container) {
|
||||
$(container).append($('<span>Dialog!</span>'));
|
||||
},
|
||||
destroy: function () {
|
||||
|
||||
}
|
||||
}).then(
|
||||
};
|
||||
|
||||
mct.dialog(view, "Add a Task").then(
|
||||
window.alert.bind(window, 'resolve'),
|
||||
window.alert.bind(window, 'reject')
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user