[API] Show dialog from toolbar

This commit is contained in:
Victor Woeltjen
2016-06-17 13:51:15 -07:00
parent e4a4704baa
commit b6a8c514aa
4 changed files with 47 additions and 3 deletions

View File

@ -3,13 +3,15 @@ define([
'legacyRegistry', 'legacyRegistry',
'uuid', 'uuid',
'./api/api', './api/api',
'text!./adapter/templates/edit-object-replacement.html' 'text!./adapter/templates/edit-object-replacement.html',
'./ui/Dialog'
], function ( ], function (
EventEmitter, EventEmitter,
legacyRegistry, legacyRegistry,
uuid, uuid,
api, api,
editObjectTemplate editObjectTemplate,
Dialog
) { ) {
function MCT() { function MCT() {
EventEmitter.call(this); EventEmitter.call(this);
@ -83,6 +85,10 @@ define([
}); });
}; };
MCT.prototype.dialog = function (view) {
return new Dialog(view).show();
};
MCT.prototype.start = function () { MCT.prototype.start = function () {
legacyRegistry.register('adapter', this.legacyBundle); legacyRegistry.register('adapter', this.legacyBundle);
this.emit('start'); this.emit('start');

22
src/ui/Dialog.js Normal file
View File

@ -0,0 +1,22 @@
define(['text!./overlay.html', 'zepto'], function (overlayTemplate, $) {
function Dialog(view) {
this.view = view;
}
Dialog.prototype.show = function () {
var $body = $('body');
var $overlay = $(overlayTemplate);
var $contents = $overlay.find('.contents');
var $close = $overlay.find('.close');
$body.append($overlay);
$close.on('click', function () {
$overlay.remove();
this.view.destroy();
}.bind(this));
this.view.show($contents[0]);
};
return Dialog;
});

7
src/ui/overlay.html Normal file
View File

@ -0,0 +1,7 @@
<div class="abs overlay">
<div class="abs blocker"></div>
<div class="abs holder">
<a class="clk-icon icon ui-symbol close">x</a>
<div class="abs contents"></div>
</div>
</div>

View File

@ -114,7 +114,16 @@ define([
$(container).append($els); $(container).append($els);
$add.on('click', window.alert.bind(window, "Add!")); $add.on('click', function () {
mct.dialog({
show: function (container) {
$(container).append($('<span>Dialog!</span>'));
},
destroy: function () {
}
});
});
$remove.on('click', window.alert.bind(window, "Remove!")); $remove.on('click', window.alert.bind(window, "Remove!"));
}; };