Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var initializedDialogs = new Array();
- function ShowDialog(dialogElementId, contentUrl, buttons, width, height,
- onButtonClickJavaScriptFunctions, onLoadJavaScriptFunction, dialogContent)
- {
- if (width == null || width == 0)
- width = 300;
- if (height == null || height == 0)
- height = 300;
- var buttonArray = buttons.split(',');
- InitializeDialog(dialogElementId, buttonArray, width, height, onButtonClickJavaScriptFunctions);
- var dialogElement = $('#' + dialogElementId)
- if (onLoadJavaScriptFunction != null && onLoadJavaScriptFunction.length > 0)
- {
- window[onLoadJavaScriptFunction]();
- }
- else if (contentUrl != null && contentUrl.length > 0)
- {
- $.ajax(
- {
- type: 'POST',
- url: contentUrl,
- data: '',
- success: function(msg)
- {
- ShowDialogContent(dialogElement, msg);
- }
- });
- }
- else if (dialogContent != null && dialogContent.length > 0)
- {
- ShowDialogContent(dialogElement, dialogContent);
- }
- else
- {
- dialogElement.dialog('open');
- }
- }
- function InitializeDialog(dialogElementId, buttonNames, width, height, onButtonClickJavaScriptFunctions)
- {
- if (initializedDialogs.contains(dialogElementId))
- return;
- initializedDialogs.push(dialogElementId);
- var buttons = new Object();
- for (var i = buttonNames.length - 1; i >= 0; i--)
- {
- var buttonName = buttonNames[i];
- buttons[buttonName] = (function(buttonName, onButtonClickJavaScriptFunctions)
- {
- return function()
- {
- if (onButtonClickJavaScriptFunctions[buttonName] != undefined)
- {
- var saveFunctionResult = window[onButtonClickJavaScriptFunctions[buttonName]]($(this));
- if (saveFunctionResult == false)
- return;
- }
- $(this).dialog('close');
- }
- })(buttonName, onButtonClickJavaScriptFunctions);
- }
- $("#" + dialogElementId).dialog(
- {
- bgiframe: true,
- autoOpen: false,
- width: width,
- height: height,
- modal: true,
- buttons: buttons
- });
- }
- function ShowDialogContent(dialogElement, content)
- {
- dialogElement.html('<div id="' + dialogElement.attr('id') + '_Content">' + content + '</div>');
- dialogElement.dialog('open');
- // hack - jqGrid pager cells aren't set to the correct width when the
- // grid is in a dialog. This will fix that.
- dialogElement.find('div[id$="Pager"]').each(function(pager)
- {
- SetPagerWidth($(this).attr('id'));
- });
- }
Add Comment
Please, Sign In to add comment