Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Dialog {
- export abstract class DialogBase extends SL_Base implements ISL_Object<any> {
- protected settings: DialogBaseSettings;
- protected invoker: ISL_Object<any>;
- protected objectType: SL_ObjectType;
- protected baseUI: { body: JQuery, titlebar: JQuery,content: JQuery } = { body: null,titlebar:null,content:null };
- public GetParent(): ISL_Object<any> {
- return this.invoker;
- }
- public OnDialogClose = $.Callbacks();
- public OnDialogOpen = $.Callbacks();
- public OnDialogOpening = $.Callbacks();
- public OnDialogSave = $.Callbacks();
- protected init() {
- this.baseUI.body = $('<div>');
- this.baseUI.body.addClass('test');
- $('body').append(this.baseUI.body);
- this.baseUI.body.dialog({
- title: this.settings.title,
- modal: true,
- resizable: false,
- width: this.calculateWidth(),
- height: this.calculateHeight(),
- autoOpen: false,
- closeOnEscape: false,
- minHeight: 10,
- show: {
- effect: "clip",
- duration: 250
- },
- hide: {
- effect: "clip",
- duration: 250
- },
- close: () =>{
- $(this.baseUI.body).remove();
- this.OnDialogClose.fire();
- this.OnDialogClose.empty();
- },
- focus: () => {
- this.OnDialogOpen.fire();
- },
- open: () => {
- this.OnDialogOpening.fire();
- }
- });
- $(".ui-dialog").css("padding", 0);
- $(".ui-dialog-titlebar").css("padding", 0);
- $(".ui-dialog-titlebar-close").remove();
- this.baseUI.body.dialog('open');
- DevExpress.ui.dxOverlay.baseZIndex(2002);
- this.baseUI.content = this.baseUI.body.parent().find('.ui-dialog-content');
- this.baseUI.titlebar = this.baseUI.body.parent().find('.ui-dialog-titlebar');
- }
- private calculateHeight(): number {
- if ($(window).height() < this.settings.height) {
- return $(window).height();
- }
- else {
- return this.settings.height;
- }
- }
- private calculateWidth(): number {
- if ($(window).width() < this.settings.width) {
- return $(window).width();
- } else {
- return this.settings.width;
- }
- }
- public GetObjectType(): SL_ObjectType {
- return this.objectType;
- }
- public Close = ()=> {
- this.baseUI.body.dialog('close');
- }
- public GetSize(): ISize {
- return { width: this.settings.width, height: this.settings.height };
- }
- }
- export class DialogBaseSettings {
- public width: number;
- public height: number;
- public title: string;
- public content: string;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement