Advertisement
Guest User

Untitled

a guest
Nov 24th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. namespace Dialog {
  2.     export abstract class DialogBase extends SL_Base implements ISL_Object<any> {
  3.         protected settings: DialogBaseSettings;
  4.         protected invoker: ISL_Object<any>;
  5.         protected objectType: SL_ObjectType;
  6.         protected baseUI: { body: JQuery, titlebar: JQuery,content: JQuery } = { body: null,titlebar:null,content:null };
  7.         public GetParent(): ISL_Object<any> {
  8.             return this.invoker;
  9.         }
  10.         public OnDialogClose = $.Callbacks();
  11.         public OnDialogOpen = $.Callbacks();
  12.         public OnDialogOpening = $.Callbacks();
  13.         public OnDialogSave = $.Callbacks();
  14.        
  15.         protected init() {
  16.             this.baseUI.body = $('<div>');
  17.            
  18.             this.baseUI.body.addClass('test');
  19.             $('body').append(this.baseUI.body);
  20.  
  21.  
  22.             this.baseUI.body.dialog({
  23.                
  24.                 title: this.settings.title,
  25.                 modal: true,
  26.                 resizable: false,
  27.                 width: this.calculateWidth(),
  28.                 height: this.calculateHeight(),
  29.                 autoOpen: false,
  30.                 closeOnEscape: false,
  31.                 minHeight: 10,
  32.                 show: {
  33.                     effect: "clip",
  34.                     duration: 250
  35.                 },
  36.                 hide: {
  37.                     effect: "clip",
  38.                     duration: 250
  39.                 },
  40.                 close:  () =>{
  41.                     $(this.baseUI.body).remove();
  42.                     this.OnDialogClose.fire();
  43.                     this.OnDialogClose.empty();
  44.                 },
  45.                 focus: () => {
  46.                     this.OnDialogOpen.fire();
  47.                 },
  48.                 open: () => {
  49.                     this.OnDialogOpening.fire();
  50.                    
  51.                 }
  52.             });
  53.            
  54.             $(".ui-dialog").css("padding", 0);
  55.             $(".ui-dialog-titlebar").css("padding", 0);
  56.             $(".ui-dialog-titlebar-close").remove();
  57.          
  58.             this.baseUI.body.dialog('open');
  59.             DevExpress.ui.dxOverlay.baseZIndex(2002);
  60.             this.baseUI.content = this.baseUI.body.parent().find('.ui-dialog-content');
  61.             this.baseUI.titlebar = this.baseUI.body.parent().find('.ui-dialog-titlebar');
  62.         }
  63.         private calculateHeight(): number {
  64.             if ($(window).height() < this.settings.height) {
  65.                 return $(window).height();
  66.             }
  67.             else {
  68.                 return this.settings.height;
  69.             }
  70.         }
  71.         private calculateWidth(): number {
  72.             if ($(window).width() < this.settings.width) {
  73.                 return $(window).width();
  74.             } else {
  75.                 return this.settings.width;
  76.             }
  77.         }
  78.         public GetObjectType(): SL_ObjectType {
  79.             return this.objectType;
  80.         }
  81.         public Close = ()=> {
  82.             this.baseUI.body.dialog('close');
  83.         }
  84.         public GetSize(): ISize {
  85.             return { width: this.settings.width, height: this.settings.height };
  86.         }
  87.     }
  88.     export class DialogBaseSettings {
  89.         public width: number;
  90.         public height: number;
  91.         public title: string;
  92.         public content: string;
  93.        
  94.     }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement