Index: trunk/phase3/resources/jquery/jquery.xmldom.js |
— | — | @@ -0,0 +1,46 @@ |
| 2 | +/*! |
| 3 | + * jQuery xmlDOM Plugin v1.0 |
| 4 | + * http://outwestmedia.com/jquery-plugins/xmldom/ |
| 5 | + * |
| 6 | + * Released: 2009-04-06 |
| 7 | + * Version: 1.0 |
| 8 | + * |
| 9 | + * Copyright (c) 2009 Jonathan Sharp, Out West Media LLC. |
| 10 | + * Dual licensed under the MIT and GPL licenses. |
| 11 | + * http://docs.jquery.com/License |
| 12 | + */ |
| 13 | +(function($) { |
| 14 | + // IE DOMParser wrapper |
| 15 | + if ( window['DOMParser'] == undefined && window.ActiveXObject ) { |
| 16 | + DOMParser = function() { }; |
| 17 | + DOMParser.prototype.parseFromString = function( xmlString ) { |
| 18 | + var doc = new ActiveXObject('Microsoft.XMLDOM'); |
| 19 | + doc.async = 'false'; |
| 20 | + doc.loadXML( xmlString ); |
| 21 | + return doc; |
| 22 | + }; |
| 23 | + } |
| 24 | + |
| 25 | + $.xmlDOM = function(xml, onErrorFn) { |
| 26 | + try { |
| 27 | + var xmlDoc = ( new DOMParser() ).parseFromString( xml, 'text/xml' ); |
| 28 | + if ( $.isXMLDoc( xmlDoc ) ) { |
| 29 | + var err = $('parsererror', xmlDoc); |
| 30 | + if ( err.length == 1 ) { |
| 31 | + throw('Error: ' + $(xmlDoc).text() ); |
| 32 | + } |
| 33 | + } else { |
| 34 | + throw('Unable to parse XML'); |
| 35 | + } |
| 36 | + } catch( e ) { |
| 37 | + var msg = ( e.name == undefined ? e : e.name + ': ' + e.message ); |
| 38 | + if ( $.isFunction( onErrorFn ) ) { |
| 39 | + onErrorFn( msg ); |
| 40 | + } else { |
| 41 | + $(document).trigger('xmlParseError', [ msg ]); |
| 42 | + } |
| 43 | + return $([]); |
| 44 | + } |
| 45 | + return $( xmlDoc ); |
| 46 | + }; |
| 47 | +})(jQuery); |
\ No newline at end of file |
Property changes on: trunk/phase3/resources/jquery/jquery.xmldom.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 48 | + native |
Index: trunk/phase3/resources/jquery/jquery.mockjax.js |
— | — | @@ -0,0 +1,382 @@ |
| 2 | +/*! |
| 3 | + * MockJax - jQuery Plugin to Mock Ajax requests |
| 4 | + * |
| 5 | + * Version: 1.4.0 |
| 6 | + * Released: 2011-02-04 |
| 7 | + * Source: http://github.com/appendto/jquery-mockjax |
| 8 | + * Docs: http://enterprisejquery.com/2010/07/mock-your-ajax-requests-with-mockjax-for-rapid-development |
| 9 | + * Plugin: mockjax |
| 10 | + * Author: Jonathan Sharp (http://jdsharp.com) |
| 11 | + * License: MIT,GPL |
| 12 | + * |
| 13 | + * Copyright (c) 2010 appendTo LLC. |
| 14 | + * Dual licensed under the MIT or GPL licenses. |
| 15 | + * http://appendto.com/open-source-licenses |
| 16 | + */ |
| 17 | +(function($) { |
| 18 | + var _ajax = $.ajax, |
| 19 | + mockHandlers = []; |
| 20 | + |
| 21 | + function parseXML(xml) { |
| 22 | + if ( window['DOMParser'] == undefined && window.ActiveXObject ) { |
| 23 | + DOMParser = function() { }; |
| 24 | + DOMParser.prototype.parseFromString = function( xmlString ) { |
| 25 | + var doc = new ActiveXObject('Microsoft.XMLDOM'); |
| 26 | + doc.async = 'false'; |
| 27 | + doc.loadXML( xmlString ); |
| 28 | + return doc; |
| 29 | + }; |
| 30 | + } |
| 31 | + |
| 32 | + try { |
| 33 | + var xmlDoc = ( new DOMParser() ).parseFromString( xml, 'text/xml' ); |
| 34 | + if ( $.isXMLDoc( xmlDoc ) ) { |
| 35 | + var err = $('parsererror', xmlDoc); |
| 36 | + if ( err.length == 1 ) { |
| 37 | + throw('Error: ' + $(xmlDoc).text() ); |
| 38 | + } |
| 39 | + } else { |
| 40 | + throw('Unable to parse XML'); |
| 41 | + } |
| 42 | + } catch( e ) { |
| 43 | + var msg = ( e.name == undefined ? e : e.name + ': ' + e.message ); |
| 44 | + $(document).trigger('xmlParseError', [ msg ]); |
| 45 | + return undefined; |
| 46 | + } |
| 47 | + return xmlDoc; |
| 48 | + } |
| 49 | + |
| 50 | + $.extend({ |
| 51 | + ajax: function(origSettings) { |
| 52 | + var s = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings), |
| 53 | + mock = false; |
| 54 | + // Iterate over our mock handlers (in registration order) until we find |
| 55 | + // one that is willing to intercept the request |
| 56 | + $.each(mockHandlers, function(k, v) { |
| 57 | + if ( !mockHandlers[k] ) { |
| 58 | + return; |
| 59 | + } |
| 60 | + var m = null; |
| 61 | + // If the mock was registered with a function, let the function decide if we |
| 62 | + // want to mock this request |
| 63 | + if ( $.isFunction(mockHandlers[k]) ) { |
| 64 | + m = mockHandlers[k](s); |
| 65 | + } else { |
| 66 | + m = mockHandlers[k]; |
| 67 | + // Inspect the URL of the request and check if the mock handler's url |
| 68 | + // matches the url for this ajax request |
| 69 | + if ( $.isFunction(m.url.test) ) { |
| 70 | + // The user provided a regex for the url, test it |
| 71 | + if ( !m.url.test( s.url ) ) { |
| 72 | + m = null; |
| 73 | + } |
| 74 | + } else { |
| 75 | + // Look for a simple wildcard '*' or a direct URL match |
| 76 | + var star = m.url.indexOf('*'); |
| 77 | + if ( ( m.url != '*' && m.url != s.url && star == -1 ) || |
| 78 | + ( star > -1 && m.url.substr(0, star) != s.url.substr(0, star) ) ) { |
| 79 | + // The url we tested did not match the wildcard * |
| 80 | + m = null; |
| 81 | + } |
| 82 | + } |
| 83 | + if ( m ) { |
| 84 | + // Inspect the data submitted in the request (either POST body or GET query string) |
| 85 | + if ( m.data && s.data ) { |
| 86 | + var identical = false; |
| 87 | + // Deep inspect the identity of the objects |
| 88 | + (function ident(mock, live) { |
| 89 | + // Test for situations where the data is a querystring (not an object) |
| 90 | + if (typeof live === 'string') { |
| 91 | + // Querystring may be a regex |
| 92 | + identical = $.isFunction( mock.test ) ? mock.test(live) : mock == live; |
| 93 | + return identical; |
| 94 | + } |
| 95 | + $.each(mock, function(k, v) { |
| 96 | + if ( live[k] === undefined ) { |
| 97 | + identical = false; |
| 98 | + return false; |
| 99 | + } else { |
| 100 | + identical = true; |
| 101 | + if ( typeof live[k] == 'object' ) { |
| 102 | + return ident(mock[k], live[k]); |
| 103 | + } else { |
| 104 | + if ( $.isFunction( mock[k].test ) ) { |
| 105 | + identical = mock[k].test(live[k]); |
| 106 | + } else { |
| 107 | + identical = ( mock[k] == live[k] ); |
| 108 | + } |
| 109 | + return identical; |
| 110 | + } |
| 111 | + } |
| 112 | + }); |
| 113 | + })(m.data, s.data); |
| 114 | + // They're not identical, do not mock this request |
| 115 | + if ( identical == false ) { |
| 116 | + m = null; |
| 117 | + } |
| 118 | + } |
| 119 | + // Inspect the request type |
| 120 | + if ( m && m.type && m.type != s.type ) { |
| 121 | + // The request type doesn't match (GET vs. POST) |
| 122 | + m = null; |
| 123 | + } |
| 124 | + } |
| 125 | + } |
| 126 | + if ( m ) { |
| 127 | + mock = true; |
| 128 | + |
| 129 | + // Handle console logging |
| 130 | + var c = $.extend({}, $.mockjaxSettings, m); |
| 131 | + if ( c.log && $.isFunction(c.log) ) { |
| 132 | + c.log('MOCK ' + s.type.toUpperCase() + ': ' + s.url, $.extend({}, s)); |
| 133 | + } |
| 134 | + |
| 135 | + var jsre = /=\?(&|$)/, jsc = (new Date()).getTime(); |
| 136 | + |
| 137 | + // Handle JSONP Parameter Callbacks, we need to replicate some of the jQuery core here |
| 138 | + // because there isn't an easy hook for the cross domain script tag of jsonp |
| 139 | + if ( s.dataType === "jsonp" ) { |
| 140 | + if ( s.type.toUpperCase() === "GET" ) { |
| 141 | + if ( !jsre.test( s.url ) ) { |
| 142 | + s.url += (rquery.test( s.url ) ? "&" : "?") + (s.jsonp || "callback") + "=?"; |
| 143 | + } |
| 144 | + } else if ( !s.data || !jsre.test(s.data) ) { |
| 145 | + s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?"; |
| 146 | + } |
| 147 | + s.dataType = "json"; |
| 148 | + } |
| 149 | + |
| 150 | + // Build temporary JSONP function |
| 151 | + if ( s.dataType === "json" && (s.data && jsre.test(s.data) || jsre.test(s.url)) ) { |
| 152 | + jsonp = s.jsonpCallback || ("jsonp" + jsc++); |
| 153 | + |
| 154 | + // Replace the =? sequence both in the query string and the data |
| 155 | + if ( s.data ) { |
| 156 | + s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1"); |
| 157 | + } |
| 158 | + |
| 159 | + s.url = s.url.replace(jsre, "=" + jsonp + "$1"); |
| 160 | + |
| 161 | + // We need to make sure |
| 162 | + // that a JSONP style response is executed properly |
| 163 | + s.dataType = "script"; |
| 164 | + |
| 165 | + // Handle JSONP-style loading |
| 166 | + window[ jsonp ] = window[ jsonp ] || function( tmp ) { |
| 167 | + data = tmp; |
| 168 | + success(); |
| 169 | + complete(); |
| 170 | + // Garbage collect |
| 171 | + window[ jsonp ] = undefined; |
| 172 | + |
| 173 | + try { |
| 174 | + delete window[ jsonp ]; |
| 175 | + } catch(e) {} |
| 176 | + |
| 177 | + if ( head ) { |
| 178 | + head.removeChild( script ); |
| 179 | + } |
| 180 | + }; |
| 181 | + } |
| 182 | + |
| 183 | + var rurl = /^(\w+:)?\/\/([^\/?#]+)/, |
| 184 | + parts = rurl.exec( s.url ), |
| 185 | + remote = parts && (parts[1] && parts[1] !== location.protocol || parts[2] !== location.host); |
| 186 | + |
| 187 | + // Test if we are going to create a script tag (if so, intercept & mock) |
| 188 | + if ( s.dataType === "script" && s.type.toUpperCase() === "GET" && remote ) { |
| 189 | + // Synthesize the mock request for adding a script tag |
| 190 | + var callbackContext = origSettings && origSettings.context || s; |
| 191 | + |
| 192 | + function success() { |
| 193 | + // If a local callback was specified, fire it and pass it the data |
| 194 | + if ( s.success ) { |
| 195 | + s.success.call( callbackContext, ( m.response ? m.response.toString() : m.responseText || ''), status, {} ); |
| 196 | + } |
| 197 | + |
| 198 | + // Fire the global callback |
| 199 | + if ( s.global ) { |
| 200 | + trigger( "ajaxSuccess", [{}, s] ); |
| 201 | + } |
| 202 | + } |
| 203 | + |
| 204 | + function complete() { |
| 205 | + // Process result |
| 206 | + if ( s.complete ) { |
| 207 | + s.complete.call( callbackContext, {} , status ); |
| 208 | + } |
| 209 | + |
| 210 | + // The request was completed |
| 211 | + if ( s.global ) { |
| 212 | + trigger( "ajaxComplete", [{}, s] ); |
| 213 | + } |
| 214 | + |
| 215 | + // Handle the global AJAX counter |
| 216 | + if ( s.global && ! --jQuery.active ) { |
| 217 | + jQuery.event.trigger( "ajaxStop" ); |
| 218 | + } |
| 219 | + } |
| 220 | + |
| 221 | + function trigger(type, args) { |
| 222 | + (s.context ? jQuery(s.context) : jQuery.event).trigger(type, args); |
| 223 | + } |
| 224 | + |
| 225 | + if ( m.response && $.isFunction(m.response) ) { |
| 226 | + m.response(origSettings); |
| 227 | + } else { |
| 228 | + $.globalEval(m.responseText); |
| 229 | + } |
| 230 | + success(); |
| 231 | + complete(); |
| 232 | + return false; |
| 233 | + } |
| 234 | + mock = _ajax.call($, $.extend(true, {}, origSettings, { |
| 235 | + // Mock the XHR object |
| 236 | + xhr: function() { |
| 237 | + // Extend with our default mockjax settings |
| 238 | + m = $.extend({}, $.mockjaxSettings, m); |
| 239 | + |
| 240 | + if ( m.contentType ) { |
| 241 | + m.headers['content-type'] = m.contentType; |
| 242 | + } |
| 243 | + |
| 244 | + // Return our mock xhr object |
| 245 | + return { |
| 246 | + status: m.status, |
| 247 | + readyState: 1, |
| 248 | + open: function() { }, |
| 249 | + send: function() { |
| 250 | + // This is a substitute for < 1.4 which lacks $.proxy |
| 251 | + var process = (function(that) { |
| 252 | + return function() { |
| 253 | + return (function() { |
| 254 | + // The request has returned |
| 255 | + this.status = m.status; |
| 256 | + this.readyState = 4; |
| 257 | + |
| 258 | + // We have an executable function, call it to give |
| 259 | + // the mock handler a chance to update it's data |
| 260 | + if ( $.isFunction(m.response) ) { |
| 261 | + m.response(origSettings); |
| 262 | + } |
| 263 | + // Copy over our mock to our xhr object before passing control back to |
| 264 | + // jQuery's onreadystatechange callback |
| 265 | + if ( s.dataType == 'json' && ( typeof m.responseText == 'object' ) ) { |
| 266 | + this.responseText = JSON.stringify(m.responseText); |
| 267 | + } else if ( s.dataType == 'xml' ) { |
| 268 | + if ( typeof m.responseXML == 'string' ) { |
| 269 | + this.responseXML = parseXML(m.responseXML); |
| 270 | + } else { |
| 271 | + this.responseXML = m.responseXML; |
| 272 | + } |
| 273 | + } else { |
| 274 | + this.responseText = m.responseText; |
| 275 | + } |
| 276 | + // jQuery < 1.4 doesn't have onreadystate change for xhr |
| 277 | + if ( $.isFunction(this.onreadystatechange) ) { |
| 278 | + this.onreadystatechange( m.isTimeout ? 'timeout' : undefined ); |
| 279 | + } |
| 280 | + }).apply(that); |
| 281 | + }; |
| 282 | + })(this); |
| 283 | + |
| 284 | + if ( m.proxy ) { |
| 285 | + // We're proxying this request and loading in an external file instead |
| 286 | + _ajax({ |
| 287 | + global: false, |
| 288 | + url: m.proxy, |
| 289 | + type: m.proxyType, |
| 290 | + data: m.data, |
| 291 | + dataType: s.dataType, |
| 292 | + complete: function(xhr, txt) { |
| 293 | + m.responseXML = xhr.responseXML; |
| 294 | + m.responseText = xhr.responseText; |
| 295 | + this.responseTimer = setTimeout(process, m.responseTime || 0); |
| 296 | + } |
| 297 | + }); |
| 298 | + } else { |
| 299 | + // type == 'POST' || 'GET' || 'DELETE' |
| 300 | + if ( s.async === false ) { |
| 301 | + // TODO: Blocking delay |
| 302 | + process(); |
| 303 | + } else { |
| 304 | + this.responseTimer = setTimeout(process, m.responseTime || 50); |
| 305 | + } |
| 306 | + } |
| 307 | + }, |
| 308 | + abort: function() { |
| 309 | + clearTimeout(this.responseTimer); |
| 310 | + }, |
| 311 | + setRequestHeader: function() { }, |
| 312 | + getResponseHeader: function(header) { |
| 313 | + // 'Last-modified', 'Etag', 'content-type' are all checked by jQuery |
| 314 | + if ( m.headers && m.headers[header] ) { |
| 315 | + // Return arbitrary headers |
| 316 | + return m.headers[header]; |
| 317 | + } else if ( header.toLowerCase() == 'last-modified' ) { |
| 318 | + return m.lastModified || (new Date()).toString(); |
| 319 | + } else if ( header.toLowerCase() == 'etag' ) { |
| 320 | + return m.etag || ''; |
| 321 | + } else if ( header.toLowerCase() == 'content-type' ) { |
| 322 | + return m.contentType || 'text/plain'; |
| 323 | + } |
| 324 | + }, |
| 325 | + getAllResponseHeaders: function() { |
| 326 | + var headers = ''; |
| 327 | + $.each(m.headers, function(k, v) { |
| 328 | + headers += k + ': ' + v + "\n"; |
| 329 | + }); |
| 330 | + return headers; |
| 331 | + } |
| 332 | + }; |
| 333 | + } |
| 334 | + })); |
| 335 | + return false; |
| 336 | + } |
| 337 | + }); |
| 338 | + // We don't have a mock request, trigger a normal request |
| 339 | + if ( !mock ) { |
| 340 | + return _ajax.apply($, arguments); |
| 341 | + } else { |
| 342 | + return mock; |
| 343 | + } |
| 344 | + } |
| 345 | + }); |
| 346 | + |
| 347 | + $.mockjaxSettings = { |
| 348 | + //url: null, |
| 349 | + //type: 'GET', |
| 350 | + log: function(msg) { |
| 351 | + window['console'] && window.console.log && window.console.log(msg); |
| 352 | + }, |
| 353 | + status: 200, |
| 354 | + responseTime: 500, |
| 355 | + isTimeout: false, |
| 356 | + contentType: 'text/plain', |
| 357 | + response: '', |
| 358 | + responseText: '', |
| 359 | + responseXML: '', |
| 360 | + proxy: '', |
| 361 | + proxyType: 'GET', |
| 362 | + |
| 363 | + lastModified: null, |
| 364 | + etag: '', |
| 365 | + headers: { |
| 366 | + etag: 'IJF@H#@923uf8023hFO@I#H#', |
| 367 | + 'content-type' : 'text/plain' |
| 368 | + } |
| 369 | + }; |
| 370 | + |
| 371 | + $.mockjax = function(settings) { |
| 372 | + var i = mockHandlers.length; |
| 373 | + mockHandlers[i] = settings; |
| 374 | + return i; |
| 375 | + }; |
| 376 | + $.mockjaxClear = function(i) { |
| 377 | + if ( arguments.length == 1 ) { |
| 378 | + mockHandlers[i] = null; |
| 379 | + } else { |
| 380 | + mockHandlers = []; |
| 381 | + } |
| 382 | + }; |
| 383 | +})(jQuery); |
Property changes on: trunk/phase3/resources/jquery/jquery.mockjax.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 384 | + native |