2
* buildModal creates a jQuery UI modal dialog window.
4
* @param element A DOM element, most likely a div, that will display content inside the
6
* @param title The title for the modal window.
7
* @return $dialog A configured modal dialog.
9
* @todo Add more params for greater configurability.
11
function buildModal(element, title) {
12
var $dialog = $(element)
1
$(document).ready(function() {
2
var $dialog = $('<div id="modalContent"></div>')
26
* This unnamed function catches the click of an element with .modalTrigger class. It calls
27
* buildModal and then loads and opens the modal dialog.
29
* @return false Return false is used here to prevent the clicked link from returning and sending
30
* the user forward in the browser.
32
$(document).ready(function() {
33
12
$('.modalTrigger').live('click', function() {
34
var $dialog = buildModal('<div id="modalContent"></div>', $(this).attr('title'));
13
$dialog.dialog("option", "title", $(this).attr('title'));
35
14
$dialog.load($(this).attr('href'), function() {$dialog.dialog('open')});
41
* This unnamed function catches the click event on an element (most likely a form submit) with the
42
* .modalSubmit class. The complete function of the .ajax call makes a call to showFeedback, which
43
* handles user feedback and the loading of any other data that may be necessary.
45
* @return false The click on .modalSubmit returns false to prevent the clicked link from retunring
46
* and sending the user forward in the browser.
49
21
$(document).ready(function() {
50
22
$('.modalSubmit').live('click',function(){
51
var $submitter = $(this);
23
var ble = $(this).parent().attr('name') + ' :input';
24
var blere = '#' + $(this).parent().attr('id') + ' :input';
54
url: $(this).parent().attr('action'),
56
data: $('#' + $(this).parent().attr('id') + ' :input'),
59
showFeedBack(data, $(this), processReturn);
26
url: $(this).parent().attr('action'),
28
data: $('#' + $(this).parent().attr('id') + ' :input'),
31
var boo = data.responseText;
32
$('#modalContent').append('<h2 class="overlay">Status Changed</h2>');
33
$('.overlay').fadeIn(1200, function() {
34
$('.overlay').fadeOut(1200, function() {
35
$('.overlay').remove();
36
// pattern = /event\/[a-zA-Z_0-9\+\%\-]*\/facilitygroups/;
37
pattern = /event\/[a-zA-Z_0-9\+\%\-]*\/facilityresource\/[a-zA-Z_0-9\+\%\-]*/;
38
var theer = pattern.exec(data.responseText);
39
if(data.responseText == pattern.exec(data.responseText)) {
40
var $fgroupDialog = $('<div id="#modalFgroup"></div>')
49
$fgroupDialog.dialog("option", "title", "yeah");
50
// Get the name in there somehow.
51
$.post('facilityresource/FF11EC', function(data) {
52
$fgroupDialog.html(data);
53
$fgroupDialog.dialog('open');
56
$('#modalContent').load($(this).parent().attr('action'));
64
$('#modalContent').bind('dialogclose', function() {
65
$('#tableContainer').load(window.location.pathname + ' .singleTable');
70
* showFeedBack is used to confirm to the user that a modal form has successfully submitted to the
71
* server. It simply appends a new <h2>, fades it in, then out, then drops it, and calls a callback
72
* function, if necessary.
74
* @param data The data created by a call to .ajax.
75
* @param callBackFunc A function to call after completion of the feedback animation.
77
* @todo Abstract and parametize this function.
79
function showFeedBack(data, $submitter, callBackFunc) {
80
$('#modalContent').append('<h2 class="overlay">Status Changed</h2>');
81
$('.overlay').fadeIn(1200, function() {
82
$('.overlay').fadeOut(1200, function() {
83
$('.overlay').remove();
84
if($.isFunction(callBackFunc)) {
85
callBackFunc.call($submitter, data);
92
* returnContent handles the data returned to the browser by an .ajax call. It is used to launch a
93
* second modal dialog, should the returned data dictate so.
95
* @param data The returned data from a call to .ajax.
97
function returnContent(data) {
98
var $dialog = buildModal('<div id="#modalFgroup"></div>', 'Set Facility Resource Activation Time');
99
$.post(data, function(data) {
101
$dialog.dialog('open');
106
* @todo refactor so we can pass pattern to this. JSON stuff, probably.
108
function processReturn(data) {
109
pattern = /facilityresource\/[\w\d+%-]*/
110
if(data == $(this).attr('id')) {
111
appendContent($(this), data);
112
// returnContent(data);
116
function appendContent($submitter, data) {
117
$('#modalAppend').load(($submitter).attr('id'), function() {
118
$('#modalAppend').slideDown(1000);
b'\\ No newline at end of file'
64
$('#modalContent').bind('dialogclose', function() {
65
$('#tableContainer').load(window.location.pathname + ' .singleTable');
b'\\ No newline at end of file'