Guest User

Untitled

a guest
Jun 20th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function dialogHandler() {
  2.     this.dialogOptions = {
  3.         autoOpen: false,
  4.         height: 300,
  5.         width: 400,
  6.         modal: true
  7.     };
  8.  
  9.     this.load = {}; //empty object for functions
  10. }
  11.  
  12.  
  13. dialogHandler.prototype.prepareDialog = function( divId, buttonType, userDialogOptions) {
  14.     var dialogOptions = jQuery.extend(this.dialogOptions, userDialogOptions);
  15.    
  16.     $('#'+divId).dialog( dialogOptions );
  17.    
  18.     this.assignButtonType( divId, buttonType );
  19.     this.assignLoadFunction( divId );
  20. };
  21.  
  22.  
  23. dialogHandler.prototype.assignButtonType = function( divId, buttonType ) {
  24.     switch(buttonType) {
  25.     case 'cancel':
  26.         $('#'+divId).dialog( "option", "buttons", {
  27.             'zamknij': function() {
  28.                 $(this).dialog("close");  
  29.             }
  30.         });
  31.     break;
  32.    
  33.     case 'next':
  34.         $('#'+divId).dialog( "option", "buttons", {
  35.             'dalej': function() {
  36.                 //$('#form_'+divId).submit();
  37.                 $(this).dialog("close");  
  38.             },
  39.             'anuluj': function() {
  40.                 $(this).dialog("close");  
  41.             }
  42.         });
  43.     break;
  44.     case 'form':
  45.         $('#'+divId).dialog( "option", "buttons", {
  46.             'zapisz': function() {
  47.                 $('#form_'+divId).submit();
  48.                 $(this).dialog("close");  
  49.             },
  50.             'anuluj': function() {
  51.                 $(this).dialog("close");  
  52.             }
  53.         });
  54.     break;
  55.    
  56.     default:
  57.         $('#'+divId).dialog( "option", "buttons", {
  58.             'zamknij': function() {
  59.                 $(this).dialog("close");  
  60.             }
  61.         });
  62.     }  
  63. };
  64.  
  65.  
  66.  
  67. dialogHandler.prototype.assignLoadFunction = function( divId ) {
  68.     this.load[divId] = function( data ) {
  69.         //$('#'+divId).html( Math.random() ).dialog('open');
  70.         $('#'+divId).load('dialog.php?sub='+divId, data).dialog('open');
  71.     };
  72. };
  73.  
  74.  
  75.  
  76.  
  77. /*
  78.  * dialog handle and alias
  79.  */
  80. window.dlgHandler = new dialogHandler();
  81. window.dhl = {};
  82. window.dhl = window.dlgHandler.load;
Add Comment
Please, Sign In to add comment