1var $j = jQuery.noConflict(); 2 3$j.fn.extend({ 4 wait: function(time, type) { 5 time = time || 1000; 6 type = type || "fx"; 7 return this.queue(type, function() { 8 var self = this; 9 setTimeout(function() { 10 $j(self).dequeue(); 11 }, time); 12 }); 13 } 14}); 15 16/* 17 * Queued Ajax requests. 18 * A new Ajax request won't be started until the previous queued 19 * request has finished. 20 */ 21$j.ajaxQueue = function(o){ 22 $j.ajax( o ); 23}; 24 25 26/* 27 * Synced Ajax requests. 28 * The Ajax request will happen as soon as you call this method, but 29 * the callbacks (success/error/complete) won't fire until all previous 30 * synced requests have been completed. 31 */ 32$j.ajaxSync = function(o){ 33 var fn = $j.ajaxSync.fn, data = $j.ajaxSync.data, pos = fn.length; 34 35 fn[ pos ] = { 36 error: o.error, 37 success: o.success, 38 complete: o.complete, 39 done: false 40 }; 41 42 data[ pos ] = { 43 error: [], 44 success: [], 45 complete: [] 46 }; 47 48 o.error = function(){ data[ pos ].error = arguments; }; 49 o.success = function(){ data[ pos ].success = arguments; }; 50 o.complete = function(){ 51 data[ pos ].complete = arguments; 52 fn[ pos ].done = true; 53 54 if ( pos == 0 || !fn[ pos-1 ] ) 55 for ( var i = pos; i < fn.length && fn[i].done; i++ ) { 56 if ( fn[i].error ) fn[i].error.apply( $j, data[i].error ); 57 if ( fn[i].success ) fn[i].success.apply( $j, data[i].success ); 58 if ( fn[i].complete ) fn[i].complete.apply( $j, data[i].complete ); 59 60 fn[i] = null; 61 data[i] = null; 62 } 63 }; 64 65 return $j.ajax(o); 66}; 67 68$j.ajaxSync.fn = []; 69$j.ajaxSync.data = []; 70 71/////////////////////////////////////////////////// 72// The QCubed Object is used for everything in Qcodo 73/////////////////////////////////////////////////// 74 var qcubed = { 75 76 recordControlModification: function (strControlId, strProperty, strNewValue) { 77 if (!qcubed.controlModifications[strControlId]) 78 qcubed.controlModifications[strControlId] = new Object; 79 qcubed.controlModifications[strControlId][strProperty] = strNewValue; 80 }, 81 82 postBack: function(strForm, strControl, strEvent, strParameter) { 83 var strForm = $j("#Qform__FormId").attr("value"); 84 var objForm = $j('#' + strForm); 85 86 $j('#Qform__FormControl').attr("value", strControl); 87 $j('#Qform__FormEvent').attr("value", strEvent); 88 $j('#Qform__FormParameter').attr("value", strParameter); 89 $j('#Qform__FormCallType').attr("value", "Server"); 90 $j('#Qform__FormUpdates').attr("value", this.formUpdates()); 91 $j('#Qform__FormCheckableControls').attr("value", this.formCheckableControls(strForm, "Server")); 92 93 // have $j trigger the submit event (so it can catch all submit events) 94 objForm.trigger("submit"); 95 }, 96 97 formUpdates: function() { 98 var strToReturn = ""; 99 for (var strControlId in qcubed.controlModifications) 100 for (var strProperty in qcubed.controlModifications[strControlId]) 101 strToReturn += strControlId + " " + strProperty + " " + qcubed.controlModifications[strControlId][strProperty] + "\n"; 102 qcubed.controlModifications = new Object; 103 return strToReturn; 104 }, 105 106 formCheckableControls: function(strForm, strCallType) { 107 108 // Select the QCubed Form 109 var objFormElements = $j('#' + strForm + ' input,select,textarea'); 110 var strToReturn = ""; 111 112 objFormElements.each(function(i) { 113 if ((($j(this).attr("type") == "checkbox") || 114 ($j(this).attr("type") == "radio")) && 115 ((strCallType == "Ajax") || 116 (!$j(this).attr("disabled")))) { 117 118 var strControlId = $j(this).attr("id"); 119 120 // CheckBoxList 121 if (strControlId.indexOf('[') >= 0) { 122 if (strControlId.indexOf('[0]') >= 0) 123 strToReturn += " " + strControlId.substring(0, strControlId.length - 3); 124 // RadioButtonList 125 } else if (strControlId.indexOf('_') >= 0) { 126 if (strControlId.indexOf('_0') >= 0) 127 strToReturn += " " + strControlId.substring(0, strControlId.length - 2); 128 129 // Standard Radio or Checkbox 130 } else { 131 strToReturn += " " + strControlId; 132 } 133 } 134 }); 135 136 if (strToReturn.length > 0) 137 return strToReturn.substring(1); 138 else 139 return ""; 140 }, 141 142 postAjax: function(strForm, strControl, strEvent, strParameter, strWaitIconControlId) { 143 144 var strForm = strForm; 145 var strControl = strControl; 146 var strEvent = strEvent; 147 var strParameter = strParameter; 148 var strWaitIconControlId = strWaitIconControlId; 149 150 var objForm = $j('#' + strForm); 151 var strFormAction = objForm.attr("action"); 152 var objFormElements = $j('#' + strForm + ' input,#' + strForm + ' select,#' + strForm + ' textarea'); 153 154 $j('#Qform__FormControl').attr("value", strControl); 155 $j('#Qform__FormEvent').attr("value", strEvent); 156 $j('#Qform__FormParameter').attr("value", strParameter); 157 $j('#Qform__FormCallType').attr("value", "Ajax"); 158 $j('#Qform__FormUpdates').attr("value", this.formUpdates()); 159 $j('#Qform__FormCheckableControls').attr("value", this.formCheckableControls(strForm, "Ajax")); 160 161 var strPostData = ''; 162 163 objFormElements.each(function () { 164 var strType = $j(this).attr("type"); 165 var strControlId = $j(this).attr("id"); 166 switch (strType) { 167 case "checkbox": 168 case "radio": 169 if ($j(this).attr("checked")) { 170 var strTestName = $j(this).attr("name") + "_"; 171 if (strControlId.substring(0, strTestName.length) == strTestName) 172 strPostData += "&" + $j(this).attr("name") + "=" + strControlId.substring(strTestName.length); 173 else 174 strPostData += "&" + strControlId + "=" + $j(this).val(); 175 }; 176 break; 177 178 case "select-multiple": 179 var blnOneSelected = false;
180 $j(this).find(':selected').each (function (i) { 181 strPostData += "&" + $j(this).parents("select").attr("name") + "="; 182 strPostData += $j(this).val(); 183 }); 184 break; 185 186 default: 187 strPostData += "&" + strControlId + "="; 188 189 // For Internationalization -- we must escape the element's value properly 190 var strPostValue = $j(this).val(); 191 if (strPostValue) { 192 strPostValue = strPostValue.replace(/\%/g, "%25"); 193 strPostValue = strPostValue.replace(/&/g, escape('&')); 194 strPostValue = strPostValue.replace(/\+/g, "%2B"); 195 } 196 strPostData += strPostValue; 197 break; 198 } 199 }); 200 201 if (strWaitIconControlId) { 202 this.objAjaxWaitIcon = this.getWrapper(strWaitIconControlId); 203 if (this.objAjaxWaitIcon) 204 this.objAjaxWaitIcon.style.display = 'inline'; 205 }; 206 $j.ajaxQueue({ 207 url: strFormAction, 208 type: "POST", 209 data: strPostData, 210 error: function (XMLHttpRequest, textStatus, errorThrown) { 211 alert("An error occurred during AJAX Response parsing.\r\n\r\nThe error response will appear in a new popup."); 212 var objErrorWindow = window.open('about:blank', 'qcodo_error','menubar=no,toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes,width=1000,height=700,left=50,top=50'); 213 objErrorWindow.focus(); 214 objErrorWindow.document.write(XMLHttpRequest.responseText); 215 return; 216 }, 217 success: function (xml) { 218 $j(xml).find('control').each(function() { 219 var strControlId = '#' + $j(this).attr("id"); 220 var strControlHtml = $j(this).text(); 221 222 if (strControlId == "#Qform__FormState") { 223 $j(strControlId).val(strControlHtml); 224 } else { 225 $j(strControlId + "_ctl").html(strControlHtml); 226 } 227 }); 228 var strCommand = ''; 229 $j(xml).find('command').each(function() { 230 strCommand += $j(this).text(); 231 }); 232 eval(strCommand); 233 if (qcubed.objAjaxWaitIcon) 234 qcubed.objAjaxWaitIcon.style.display = 'none'; 235 } 236 }); 237 238 }, 239 240 initialize: function() { 241 242 243 244 //////////////////////////////// 245 // Browser-related functionality 246 //////////////////////////////// 247 248 this.loadJavaScriptFile = function(strScript, objCallback) { 249 strScript = qc.jsAssets + "/" + strScript; 250 $j.getScript(strScript, objCallback); 251 }; 252 253 this.loadStyleSheetFile = function(strStyleSheetFile, strMediaType) { 254 strStyleSheetFile = qc.cssAssets + "/" + strStyleSheetFile; 255 256 $j('head').append('<link rel="stylesheet" href="' + strStyleSheetFile + '" type="text/css" />'); 257 258 }; 259 260 261 262 263 ///////////////////////////// 264 // QForm-related functionality 265 ///////////////////////////// 266 267 this.wrappers = new Array(); 268 269 270 } 271 }; 272 273 /////////////////////////////// 274 // Timers-related functionality 275 /////////////////////////////// 276 277 qcubed._objTimers = new Object(); 278 279 qcubed.clearTimeout = function(strTimerId) { 280 if (qcubed._objTimers[strTimerId]) { 281 clearTimeout(qcubed._objTimers[strTimerId]); 282 qcubed._objTimers[strTimerId] = null; 283 }; 284 }; 285 286 qcubed.setTimeout = function(strTimerId, strAction, intDelay) { 287 qcubed.clearTimeout(strTimerId); 288 qcubed._objTimers[strTimerId] = setTimeout(strAction, intDelay); 289 }; 290 291 292 293 ///////////////////////////////////// 294 // Event Object-related functionality 295 ///////////////////////////////////// 296 297 298 qcubed.terminateEvent = function(objEvent) { 299 objEvent = qcubed.handleEvent(objEvent); 300 301 if (objEvent) { 302 // Stop Propogation 303 if (objEvent.preventDefault) 304 objEvent.preventDefault(); 305 if (objEvent.stopPropagation) 306 objEvent.stopPropagation(); 307 objEvent.cancelBubble = true; 308 objEvent.returnValue = false; 309 }; 310 311 return false; 312 }; 313 314 315//////////////////////////////// 316// Qcodo Shortcut and Initialize 317//////////////////////////////// 318 // Make sure we set $j.noConflict() to $j 319 320 var qc = qcubed; 321 qc.initialize(); 322 323 qc.pB = qcubed.postBack; 324 qc.pA = qcubed.postAjax; 325
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.