Guest User

Untitled

a guest
Jun 20th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. var initializedDialogs = new Array();
  2.  
  3. function ShowDialog(dialogElementId, contentUrl, buttons, width, height,
  4. onButtonClickJavaScriptFunctions, onLoadJavaScriptFunction, dialogContent)
  5. {
  6. if (width == null || width == 0)
  7. width = 300;
  8. if (height == null || height == 0)
  9. height = 300;
  10.  
  11. var buttonArray = buttons.split(',');
  12.  
  13. InitializeDialog(dialogElementId, buttonArray, width, height, onButtonClickJavaScriptFunctions);
  14.  
  15. var dialogElement = $('#' + dialogElementId)
  16. if (onLoadJavaScriptFunction != null && onLoadJavaScriptFunction.length > 0)
  17. {
  18. window[onLoadJavaScriptFunction]();
  19. }
  20. else if (contentUrl != null && contentUrl.length > 0)
  21. {
  22. $.ajax(
  23. {
  24. type: 'POST',
  25. url: contentUrl,
  26. data: '',
  27. success: function(msg)
  28. {
  29. ShowDialogContent(dialogElement, msg);
  30. }
  31. });
  32. }
  33. else if (dialogContent != null && dialogContent.length > 0)
  34. {
  35. ShowDialogContent(dialogElement, dialogContent);
  36. }
  37. else
  38. {
  39. dialogElement.dialog('open');
  40. }
  41. }
  42.  
  43. function InitializeDialog(dialogElementId, buttonNames, width, height, onButtonClickJavaScriptFunctions)
  44. {
  45. if (initializedDialogs.contains(dialogElementId))
  46. return;
  47.  
  48. initializedDialogs.push(dialogElementId);
  49.  
  50. var buttons = new Object();
  51. for (var i = buttonNames.length - 1; i >= 0; i--)
  52. {
  53. var buttonName = buttonNames[i];
  54. buttons[buttonName] = (function(buttonName, onButtonClickJavaScriptFunctions)
  55. {
  56. return function()
  57. {
  58. if (onButtonClickJavaScriptFunctions[buttonName] != undefined)
  59. {
  60. var saveFunctionResult = window[onButtonClickJavaScriptFunctions[buttonName]]($(this));
  61. if (saveFunctionResult == false)
  62. return;
  63. }
  64.  
  65. $(this).dialog('close');
  66. }
  67. })(buttonName, onButtonClickJavaScriptFunctions);
  68. }
  69.  
  70. $("#" + dialogElementId).dialog(
  71. {
  72. bgiframe: true,
  73. autoOpen: false,
  74. width: width,
  75. height: height,
  76. modal: true,
  77. buttons: buttons
  78. });
  79. }
  80.  
  81. function ShowDialogContent(dialogElement, content)
  82. {
  83. dialogElement.html('<div id="' + dialogElement.attr('id') + '_Content">' + content + '</div>');
  84. dialogElement.dialog('open');
  85.  
  86. // hack - jqGrid pager cells aren't set to the correct width when the
  87. // grid is in a dialog. This will fix that.
  88. dialogElement.find('div[id$="Pager"]').each(function(pager)
  89. {
  90. SetPagerWidth($(this).attr('id'));
  91. });
  92. }
Add Comment
Please, Sign In to add comment