Add frontend assets and plugin bundles

Add the legacy frontend themes, scripts, and plugin assets required by the main SPOTA interfaces.
This commit is contained in:
Power BI Dev
2026-05-02 10:09:32 +07:00
parent efdb11db3f
commit a52c2a8462
2061 changed files with 513282 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
; EditorConfig is awesome: http://EditorConfig.org
; top-most EditorConfig file
root = true
; Tab indentation (no size specified)
[*.js]
indent_style = tab
indent_size = 4
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true

View File

@@ -0,0 +1,5 @@
*.DS_Store
*.esproj
*.swp
.idea/
*.iml

View File

@@ -0,0 +1,8 @@
{
"globals": {
"ActiveXObject": false,
"console": false
},
"browser": true,
"jquery": true
}

View File

@@ -0,0 +1,19 @@
## 2012-05-30
* Updated to version 1.5.2
* Added support for jQuery 1.8, 1.9, 2.0
* TODO: Update this file with all changes since previous version
## 2011-03-25 Jonathan Sharp (http://jdsharp.com)
* Updating jQuery 1.5rc1 to 1.5.1
* Adding TestSwarm support
## 2011-02-03 Jonathan Sharp (http://jdsharp.com)
* Added log setting to intercept or disable logging messages
* Added proxyType setting to force request type when proxying a mock
* Added 29 unit tests for jQuery 1.3 through 1.5
* Fixed issue #4 - Compatibility with jQuery 1.3
* Fixed issue #10 - Undefined contents
* Fixed issue #15 - proxy setting request type
* Fixed issue #16 - proxy setting request type
* Fixed issue #17 - jsonp request handling
* Fixed issue #18 - Unit test fail with jQuery 1.5

View File

@@ -0,0 +1,438 @@
# jQuery Mockjax: Ajax request mocking #
[http://github.com/appendto/jquery-mockjax/](http://github.com/appendto/jquery-mockjax/)
jQuery Mockjax provides request/response mocking for ajax requests with
jQuery and provides all standard behaviors in the request/response flow.
You may report any issues you may find [https://github.com/appendto/jquery-mockjax/issues](in the github issue tracking).
### jQuery Version Support ###
The current version of Mockjax has been tested with jQuery 1.3.2 through
1.7.0 with QUnit unit tests, residing in /test.
### Browsers Tested ###
Internet Explorer 6-9, Firefox 3.6 and stable, Safari 5.x, Chrome stable, Opera 9.6-latest.
### Release History ##
[CHANGELOG](https://github.com/appendto/jquery-mockjax/blob/master/CHANGELOG.md)
## License ##
Copyright (c) 2012 appendTo LLC.
Dual licensed under the MIT or GPL licenses.
[http://appendto.com/open-source-licenses](http://appendto.com/open-source-licenses)
## Documentation ##
Most backend developers are familiar with the concepts of [mocking
objects](http://en.wikipedia.org/wiki/Mock_object) or stubbing in
methods for unit testing. For those not familiar with mocking, its the
simulation of an interface or API for testing or integration development
purposes. Mocking with front-end development though is still quite new.
Much of the development that [appendTo](http://appendto.com) does
focuses on front-end development tied to
[RESTFUL](http://en.wikipedia.org/wiki/Representational_State_Transfer)
web services. **As such were able to spec out the service contract and
data format at the beginning of a project and develop the front-end
interface against mock data while the back end team builds the
production services.**
The plugin was originally developed by appendTo back in
March 2010 and the [team](http://twitter.com/appendto/team) has been
using it in all of its projects since.
### API
Mockjax consists of two methods, one to set up mocks, one to remove them.
You'll find plenty of examples below. If you're looking for a specific option,
checkout this list:
* `$.mockjax(options)`
* Sets up a mockjax handler.
* `options`: An object literal which defines the settings to use for the mocked request.
* `url`: A string or regular expression specifying the url of the request that the data should be mocked for. If the url is a string and contains any asterisks ( * ), they will be treated as a wildcard by translating to a regular expression. Any `*` will be replaced with `.+`. If you run into trouble with this shortcut, switch to using a full regular expression instead of a string and asterisk combination.
* `data`: In addition to the URL, match parameters.
* `type`: Specify what HTTP method to match, usually GET or POST. Case-insensitive, so `get` and `post` also work.
* `headers`: An object literal whose keys will be simulated as additional headers returned from the server for the request.
* `status`: An integer that specifies a valid server response code. This simulates a server response code.
* `statusText`: An string that specifies a valid server response code description. This simulates a server response code description.
* `responseTime`: An integer that specifies a simulated network and server latency (in milliseconds).
* `isTimeout`: A boolean value that determines whether or not the mock will force a timeout on the request.
* `contentType`: A string which specifies the content type for the response.
* `response`: `function(settings) {}`, A function that allows for the dynamic setting of responseText/responseXML upon each request.
* `responseText`: A string specifying the mocked text, or a mocked object literal, for the request.
* `responseXML`: A string specifying the mocked XML for the request.
* `proxy`: A string specifying a path to a file, from which the contents will be returned for the request.
* `lastModified`: A date string specifying the mocked last-modified time for the request. This is used by `$.ajax` to determine if the requested data is new since the last request.
* `etag`: A string specifying a unique identifier referencing a specific version of the requested data. This is used by `$.ajax` to determine if the requested data is new since the last request. (see [HTTP_ETag](http://en.wikipedia.org/wiki/HTTP_ETag))
* `$.mockjaxClear()`
* Removes all mockjax handlers.
* `$.mockjaxClear(id)`
* Remove a single mockjax handler.
* `id` is the string returned from `$.mockjax`.
* `$.mockjax.mockedAjaxCalls()`
* Returns all mocked ajax calls so you can e.g. check that expected data is sent to backend.
### Overview: Your First Mock
Our first example will be for a simple REST service for a fortune app
with the REST endpoint being `/restful/fortune` which returns the
following JSON message:
{
"status": "success",
"fortune" : "Are you a turtle?"
}
To pull the fortune into our page, wed use the following HTML & jQuery
code:
<!DOCTYPE html>
<html>
<head>
<title>Fortune App</title>
<script src="http://code.jquery.com/jquery-1.7.0.min.js"></script>
</head>
<body>
<div id="fortune"></div>
</body>
</html>
$.getJSON('/restful/fortune', function(response) {
if ( response.status == 'success') {
$('#fortune').html( 'Your fortune is: ' + response.fortune );
} else {
$('#fortune').html( 'Things do not look good, no fortune was told' );
}
});
At this point if we were to run this code it would fail since the REST
service has yet to be implemented. This is where the benefit of the
Mockjax Plugin starts to pay off. The first step in using Mockjax is to
include the plugin by just adding a regular script tag.
Once you have that included, you can start intercepting Ajax requests
and mocking the responses. So lets mock out the service by including
the following code:
$.mockjax({
url: '/restful/fortune',
responseTime: 750,
responseText: {
status: 'success',
fortune: 'Are you a turtle?'
}
});
**Defining a JSON string inline requires a `JSON.stringify` method to be
available. For some browsers you may need to include
[json2.js](http://json.org/json2.js), which is included in the `lib` folder**
**If you plan on mocking xml responses, you may also have to include
`jquery.xmldom.js`, which can also be found in the `lib` folder.**
What Mockjax does at this point is replace the `$.ajax` method with a
wrapper that transparently checks the URL being requested. If the URL
matches one defined by `$.mockjax()`, Mockjax intercepts the request
and sets up a mock `XMLHttpRequest` object before executing the
`jQuery.ajax` handler. Otherwise, the request is handed back to the
native `$.ajax` method for normal execution. One benefit in this
implementation detail is by simulating the `XMLHttpRequest` object, the
plugin continues to make use of jQuerys native ajax handling.
As you write code to mock responses, theres great value in the fact that there are no
modifications required to production code. The mocks can be
transparently inserted. This provides easy integration into most
frameworks by including the plugin and mock definitions through your
build framework. Its also possible to include it at run time by
listening for a flag query string flag and injecting the plugin and
definitions.
### Mockjax in Depth
Now lets look at the various approaches to defining mocks as offered by
the plugin. The sections below feature an extensive overview of the
flexibility in Mockjax and creating responses.
## Data Types Available for Mocking
jQuery is able to handle and parse `Text`, `HTML`, `JSON`, `JSONP`,
`Script` and `XML` data formats and Mockjax is able to mock any of those
formats. Two things to note, depending upon how you mock out `JSON` and
`JSONP` you may need to include [json2.js](http://json.org/json2.js) for
the `JSON.stringify()` method. Additionally if you mock XML inline,
youll need to include the
[`xmlDOM`](http://github.com/appendto/jquery-xmldom) plugin that
transforms a string of XML into a DOM object. If you use the proxy
approach outlined below, theres no need to include either the JSON or
XMLDOM plugins.
## Step 1. Define the URL
The first thing you need to do when mocking a request is define the URL
end-point to intercept and mock. As with our example above this can be a
simple string:
$.mockjax({
url: '/url/to/rest-service'
});
or contain a `*` as a wildcard:
$.mockjax({
// Matches /data/quote, /data/tweet etc.
url: '/data/*'
});
or a full regular expression:
$.mockjax({
// Matches /data/quote, /data/tweet but not /data/quotes
url: /^\/data\/(quote|tweet)$/i
});
You can also match against the data option in addition to url:
$.mockjax({
url: '/rest',
data: { action: "foo" },
responseText: { bar: "hello world" }
});
$.mockjax({
url: '/rest',
data: { action: "bar" },
responseText: { bar: "hello world 2" }
});
To capture URL parameters, use a capturing regular expression for the URL and a `urlParams` array to indicate, ordinally, the names of the paramters that will be captured.
```javascript
$.mockjax({
// matches /author/1234/isbn/1234-5678-9012-0
url: /^\/author\/([\d]+)\/isbn\/([\d\-]+)$/,
urlParams: ['authorID', 'isbnNumber'],
response: function (settings) {
var authorID = settings.urlParams.authorID;
var isbnNumber = settigns.urlParams.isbnNumber;
//etc.
}
});
```
### Step 2. Define the Response
The second step is to define the type of response. The two main
properties youll be dealing with are either `responseText` or
`responseXML`. These properties mirror the native `XMLHttpRequest`
object properties that are set during a live response. There are three
different patterns for specifying the responses: Inline, Proxy, and
Callback.
#### Inline Responses
A simple text response would be:
$.mockjax({
url: '/restful/api',
responseText: 'A text response from the server'
});
A simple XML response would be:
$.mockjax({
url: '/restful/api',
// Need to include the xmlDOM plugin to have this translated into a DOM
responseXML: '<document><quote>Hello world!</quote></document>'
});
As you can quickly see, if you have a significant amount of data being
mocked this becomes unwieldy. So that brings us to the next pattern,
proxying.
#### Proxy
In this example below, the Mockjax plugin will intercept requests for
`/restful/api` and redirect them to `/mocks/data.json`.
$.mockjax({
url: '/restful/api',
proxy: '/mocks/data.json'
});
#### Callback
In the final response pattern, we can define a callback on the
`response` property and have it set `responseText` or `responseXML` as
needed.
$.mockjax({
url: '/restful/api',
response: function() {
this.responseText = 'Hello world!';
}
});
### Advanced Mocking Techniques
At this point weve looked at a series of basic mocking techniques with
Mockjax and will now unpack some of the additional functionality
contained in the plugin.
#### Simulating Response Time and Latency
Simulating network and server latency for a mock is as simple as adding
a `responseTime` property to your mock definition:
$.mockjax({
url: '/restful/api',
// Simulate a network latency of 750ms
responseTime: 750,
responseText: 'A text response from the server'
});
#### Simulating HTTP Response Statuses
Its also possible to simulate response statuses other than 200 (default
for Mockjax) by simply adding a `status` property.
$.mockjax({
url: '/restful/api',
// Server 500 error occurred
status: 500,
responseTime: 750,
responseText: 'A text response from the server'
});
#### Setting the Content-Type
You can set the content type to associate with the mock response, in the
example below, were setting a json content type.
$.mockjax({
url: '/restful/api',
contentType: 'text/json',
responseText: {
hello: 'World!'
}
});
#### Setting Additional HTTP Response Headers
Additional HTTP Response Headers may be provided by setting a key in the
headers object literal:
$.mockjax({
url: '/restful/api',
contentType: 'text/json',
responseText: {
hello: 'World!'
},
headers: {
etag: 'xyz123'
}
});
#### Force Simulation of Server Timeouts
Because of the way Mockjax was implemented, it takes advantage of
jQuerys internal timeout handling for requests. But if youd like to
force a timeout for a request you can do so by setting the `isTimeout`
property to true:
$.mockjax({
url: '/restful/api',
isTimeout: true
});
#### Dynamically Generating Mock Definitions
In some situations, all of your REST calls are based upon a URL schema.
Mockjax has the ability for you to specify a callback function that is
handed the `$.ajax` request settings. The callback function may then
either return false to allow the request to be handled natively, or
return an object literal with relevant Mockjax parameters set. Below is
an example that rewrites all Ajax requests to proxy to static mocks:
$.mockjax(function(settings) {
// settings.url == '/restful/<service>'
var service = settings.url.match(/\/restful\/(.*)$/);
if ( service ) {
return {
proxy: '/mocks/' + service[1] + '.json'
};
}
return;
});
#### Dynamically Generating Mock Responses
Its also possible to dynamically generate the response text upon each
request by implementing a callback function on the `response` parameter:
$.mockjax({
url: '/restful/webservice',
dataType: 'json',
response: function(settings) {
this.responseText = { say: 'random ' + Math.random() };
}
});
#### Data types
The example above mocks a `json` response. You can also mock `xml`:
$.mockjax({
url: '/some/xml',
dataType: 'xml',
responseXML: '<document><say>Hello world XML</say></document>'
});
And `html`:
$.mockjax({
url: '/some/webservice',
dataType: 'html',
responseText: '<div>Hello there</div>'
});
#### Globally Defining Mockjax Settings
Its also possible to define the global defaults for all Mockjax
requests by overwriting the `$.mockjaxSettings` object. By default the
settings are as follows:
$.mockjaxSettings = {
status: 200,
statusText 'OK',
responseTime: 500,
isTimeout: false,
contentType: 'text/plain',
response: '',
responseText: '',
responseXML: '',
proxy: '',
lastModified: null,
etag: ''
};
To overwrite a particular settings such as the default content-type, you
would do the following:
$.mockjaxSettings.contentType = 'text/json';
#### Removing Mockjax Handlers
Remove all mockjax handlers:
$.mockjaxClear();
#### Remove Single Mockjax Handler
var id = $.mockjax({
...
});
$.mockjaxClear(id);

View File

@@ -0,0 +1,14 @@
{
"name": "jquery-mockjax",
"version": "1.5.2",
"main": ["jquery.mockjax.js"],
"ignore": [
".editorconfig",
".gitignore",
".jshintrc",
"*.md",
"*.json",
"lib",
"test"
]
}

View File

@@ -0,0 +1,587 @@
/*!
* MockJax - jQuery Plugin to Mock Ajax requests
*
* Version: 1.5.2
* Released:
* Home: http://github.com/appendto/jquery-mockjax
* Author: Jonathan Sharp (http://jdsharp.com)
* License: MIT,GPL
*
* Copyright (c) 2011 appendTo LLC.
* Dual licensed under the MIT or GPL licenses.
* http://appendto.com/open-source-licenses
*/
(function($) {
var _ajax = $.ajax,
mockHandlers = [],
mockedAjaxCalls = [],
CALLBACK_REGEX = /=\?(&|$)/,
jsc = (new Date()).getTime();
// Parse the given XML string.
function parseXML(xml) {
if ( window.DOMParser == undefined && window.ActiveXObject ) {
DOMParser = function() { };
DOMParser.prototype.parseFromString = function( xmlString ) {
var doc = new ActiveXObject('Microsoft.XMLDOM');
doc.async = 'false';
doc.loadXML( xmlString );
return doc;
};
}
try {
var xmlDoc = ( new DOMParser() ).parseFromString( xml, 'text/xml' );
if ( $.isXMLDoc( xmlDoc ) ) {
var err = $('parsererror', xmlDoc);
if ( err.length == 1 ) {
throw('Error: ' + $(xmlDoc).text() );
}
} else {
throw('Unable to parse XML');
}
return xmlDoc;
} catch( e ) {
var msg = ( e.name == undefined ? e : e.name + ': ' + e.message );
$(document).trigger('xmlParseError', [ msg ]);
return undefined;
}
}
// Trigger a jQuery event
function trigger(s, type, args) {
(s.context ? $(s.context) : $.event).trigger(type, args);
}
// Check if the data field on the mock handler and the request match. This
// can be used to restrict a mock handler to being used only when a certain
// set of data is passed to it.
function isMockDataEqual( mock, live ) {
var identical = true;
// Test for situations where the data is a querystring (not an object)
if (typeof live === 'string') {
// Querystring may be a regex
return $.isFunction( mock.test ) ? mock.test(live) : mock == live;
}
$.each(mock, function(k) {
if ( live[k] === undefined ) {
identical = false;
return identical;
} else {
// This will allow to compare Arrays
if ( typeof live[k] === 'object' && live[k] !== null ) {
identical = identical && isMockDataEqual(mock[k], live[k]);
} else {
if ( mock[k] && $.isFunction( mock[k].test ) ) {
identical = identical && mock[k].test(live[k]);
} else {
identical = identical && ( mock[k] == live[k] );
}
}
}
});
return identical;
}
// Check the given handler should mock the given request
function getMockForRequest( handler, requestSettings ) {
// If the mock was registered with a function, let the function decide if we
// want to mock this request
if ( $.isFunction(handler) ) {
return handler( requestSettings );
}
// Inspect the URL of the request and check if the mock handler's url
// matches the url for this ajax request
if ( $.isFunction(handler.url.test) ) {
// The user provided a regex for the url, test it
if ( !handler.url.test( requestSettings.url ) ) {
return null;
}
} else {
// Look for a simple wildcard '*' or a direct URL match
var star = handler.url.indexOf('*');
if (handler.url !== requestSettings.url && star === -1 ||
!new RegExp(handler.url.replace(/[-[\]{}()+?.,\\^$|#\s]/g, "\\$&").replace(/\*/g, '.+')).test(requestSettings.url)) {
return null;
}
}
// Inspect the data submitted in the request (either POST body or GET query string)
if ( handler.data && requestSettings.data ) {
if ( !isMockDataEqual(handler.data, requestSettings.data) ) {
// They're not identical, do not mock this request
return null;
}
}
// Inspect the request type
if ( handler && handler.type &&
handler.type.toLowerCase() != requestSettings.type.toLowerCase() ) {
// The request type doesn't match (GET vs. POST)
return null;
}
return handler;
}
// Process the xhr objects send operation
function _xhrSend(mockHandler, requestSettings, origSettings) {
// This is a substitute for < 1.4 which lacks $.proxy
var process = (function(that) {
return function() {
return (function() {
var onReady;
// The request has returned
this.status = mockHandler.status;
this.statusText = mockHandler.statusText;
this.readyState = 4;
// We have an executable function, call it to give
// the mock handler a chance to update it's data
if ( $.isFunction(mockHandler.response) ) {
mockHandler.response(origSettings);
}
// Copy over our mock to our xhr object before passing control back to
// jQuery's onreadystatechange callback
if ( requestSettings.dataType == 'json' && ( typeof mockHandler.responseText == 'object' ) ) {
this.responseText = JSON.stringify(mockHandler.responseText);
} else if ( requestSettings.dataType == 'xml' ) {
if ( typeof mockHandler.responseXML == 'string' ) {
this.responseXML = parseXML(mockHandler.responseXML);
//in jQuery 1.9.1+, responseXML is processed differently and relies on responseText
this.responseText = mockHandler.responseXML;
} else {
this.responseXML = mockHandler.responseXML;
}
} else {
this.responseText = mockHandler.responseText;
}
if( typeof mockHandler.status == 'number' || typeof mockHandler.status == 'string' ) {
this.status = mockHandler.status;
}
if( typeof mockHandler.statusText === "string") {
this.statusText = mockHandler.statusText;
}
// jQuery 2.0 renamed onreadystatechange to onload
onReady = this.onreadystatechange || this.onload;
// jQuery < 1.4 doesn't have onreadystate change for xhr
if ( $.isFunction( onReady ) ) {
if( mockHandler.isTimeout) {
this.status = -1;
}
onReady.call( this, mockHandler.isTimeout ? 'timeout' : undefined );
} else if ( mockHandler.isTimeout ) {
// Fix for 1.3.2 timeout to keep success from firing.
this.status = -1;
}
}).apply(that);
};
})(this);
if ( mockHandler.proxy ) {
// We're proxying this request and loading in an external file instead
_ajax({
global: false,
url: mockHandler.proxy,
type: mockHandler.proxyType,
data: mockHandler.data,
dataType: requestSettings.dataType === "script" ? "text/plain" : requestSettings.dataType,
complete: function(xhr) {
mockHandler.responseXML = xhr.responseXML;
mockHandler.responseText = xhr.responseText;
mockHandler.status = xhr.status;
mockHandler.statusText = xhr.statusText;
this.responseTimer = setTimeout(process, mockHandler.responseTime || 0);
}
});
} else {
// type == 'POST' || 'GET' || 'DELETE'
if ( requestSettings.async === false ) {
// TODO: Blocking delay
process();
} else {
this.responseTimer = setTimeout(process, mockHandler.responseTime || 50);
}
}
}
// Construct a mocked XHR Object
function xhr(mockHandler, requestSettings, origSettings, origHandler) {
// Extend with our default mockjax settings
mockHandler = $.extend(true, {}, $.mockjaxSettings, mockHandler);
if (typeof mockHandler.headers === 'undefined') {
mockHandler.headers = {};
}
if ( mockHandler.contentType ) {
mockHandler.headers['content-type'] = mockHandler.contentType;
}
return {
status: mockHandler.status,
statusText: mockHandler.statusText,
readyState: 1,
open: function() { },
send: function() {
origHandler.fired = true;
_xhrSend.call(this, mockHandler, requestSettings, origSettings);
},
abort: function() {
clearTimeout(this.responseTimer);
},
setRequestHeader: function(header, value) {
mockHandler.headers[header] = value;
},
getResponseHeader: function(header) {
// 'Last-modified', 'Etag', 'content-type' are all checked by jQuery
if ( mockHandler.headers && mockHandler.headers[header] ) {
// Return arbitrary headers
return mockHandler.headers[header];
} else if ( header.toLowerCase() == 'last-modified' ) {
return mockHandler.lastModified || (new Date()).toString();
} else if ( header.toLowerCase() == 'etag' ) {
return mockHandler.etag || '';
} else if ( header.toLowerCase() == 'content-type' ) {
return mockHandler.contentType || 'text/plain';
}
},
getAllResponseHeaders: function() {
var headers = '';
$.each(mockHandler.headers, function(k, v) {
headers += k + ': ' + v + "\n";
});
return headers;
}
};
}
// Process a JSONP mock request.
function processJsonpMock( requestSettings, mockHandler, origSettings ) {
// Handle JSONP Parameter Callbacks, we need to replicate some of the jQuery core here
// because there isn't an easy hook for the cross domain script tag of jsonp
processJsonpUrl( requestSettings );
requestSettings.dataType = "json";
if(requestSettings.data && CALLBACK_REGEX.test(requestSettings.data) || CALLBACK_REGEX.test(requestSettings.url)) {
createJsonpCallback(requestSettings, mockHandler, origSettings);
// We need to make sure
// that a JSONP style response is executed properly
var rurl = /^(\w+:)?\/\/([^\/?#]+)/,
parts = rurl.exec( requestSettings.url ),
remote = parts && (parts[1] && parts[1] !== location.protocol || parts[2] !== location.host);
requestSettings.dataType = "script";
if(requestSettings.type.toUpperCase() === "GET" && remote ) {
var newMockReturn = processJsonpRequest( requestSettings, mockHandler, origSettings );
// Check if we are supposed to return a Deferred back to the mock call, or just
// signal success
if(newMockReturn) {
return newMockReturn;
} else {
return true;
}
}
}
return null;
}
// Append the required callback parameter to the end of the request URL, for a JSONP request
function processJsonpUrl( requestSettings ) {
if ( requestSettings.type.toUpperCase() === "GET" ) {
if ( !CALLBACK_REGEX.test( requestSettings.url ) ) {
requestSettings.url += (/\?/.test( requestSettings.url ) ? "&" : "?") +
(requestSettings.jsonp || "callback") + "=?";
}
} else if ( !requestSettings.data || !CALLBACK_REGEX.test(requestSettings.data) ) {
requestSettings.data = (requestSettings.data ? requestSettings.data + "&" : "") + (requestSettings.jsonp || "callback") + "=?";
}
}
// Process a JSONP request by evaluating the mocked response text
function processJsonpRequest( requestSettings, mockHandler, origSettings ) {
// Synthesize the mock request for adding a script tag
var callbackContext = origSettings && origSettings.context || requestSettings,
newMock = null;
// If the response handler on the moock is a function, call it
if ( mockHandler.response && $.isFunction(mockHandler.response) ) {
mockHandler.response(origSettings);
} else {
// Evaluate the responseText javascript in a global context
if( typeof mockHandler.responseText === 'object' ) {
$.globalEval( '(' + JSON.stringify( mockHandler.responseText ) + ')');
} else {
$.globalEval( '(' + mockHandler.responseText + ')');
}
}
// Successful response
jsonpSuccess( requestSettings, callbackContext, mockHandler );
jsonpComplete( requestSettings, callbackContext, mockHandler );
// If we are running under jQuery 1.5+, return a deferred object
if($.Deferred){
newMock = new $.Deferred();
if(typeof mockHandler.responseText == "object"){
newMock.resolveWith( callbackContext, [mockHandler.responseText] );
}
else{
newMock.resolveWith( callbackContext, [$.parseJSON( mockHandler.responseText )] );
}
}
return newMock;
}
// Create the required JSONP callback function for the request
function createJsonpCallback( requestSettings, mockHandler, origSettings ) {
var callbackContext = origSettings && origSettings.context || requestSettings;
var jsonp = requestSettings.jsonpCallback || ("jsonp" + jsc++);
// Replace the =? sequence both in the query string and the data
if ( requestSettings.data ) {
requestSettings.data = (requestSettings.data + "").replace(CALLBACK_REGEX, "=" + jsonp + "$1");
}
requestSettings.url = requestSettings.url.replace(CALLBACK_REGEX, "=" + jsonp + "$1");
// Handle JSONP-style loading
window[ jsonp ] = window[ jsonp ] || function( tmp ) {
data = tmp;
jsonpSuccess( requestSettings, callbackContext, mockHandler );
jsonpComplete( requestSettings, callbackContext, mockHandler );
// Garbage collect
window[ jsonp ] = undefined;
try {
delete window[ jsonp ];
} catch(e) {}
if ( head ) {
head.removeChild( script );
}
};
}
// The JSONP request was successful
function jsonpSuccess(requestSettings, callbackContext, mockHandler) {
// If a local callback was specified, fire it and pass it the data
if ( requestSettings.success ) {
requestSettings.success.call( callbackContext, mockHandler.responseText || "", status, {} );
}
// Fire the global callback
if ( requestSettings.global ) {
trigger(requestSettings, "ajaxSuccess", [{}, requestSettings] );
}
}
// The JSONP request was completed
function jsonpComplete(requestSettings, callbackContext) {
// Process result
if ( requestSettings.complete ) {
requestSettings.complete.call( callbackContext, {} , status );
}
// The request was completed
if ( requestSettings.global ) {
trigger( "ajaxComplete", [{}, requestSettings] );
}
// Handle the global AJAX counter
if ( requestSettings.global && ! --$.active ) {
$.event.trigger( "ajaxStop" );
}
}
// The core $.ajax replacement.
function handleAjax( url, origSettings ) {
var mockRequest, requestSettings, mockHandler;
// If url is an object, simulate pre-1.5 signature
if ( typeof url === "object" ) {
origSettings = url;
url = undefined;
} else {
// work around to support 1.5 signature
origSettings.url = url;
}
// Extend the original settings for the request
requestSettings = $.extend(true, {}, $.ajaxSettings, origSettings);
// Iterate over our mock handlers (in registration order) until we find
// one that is willing to intercept the request
for(var k = 0; k < mockHandlers.length; k++) {
if ( !mockHandlers[k] ) {
continue;
}
mockHandler = getMockForRequest( mockHandlers[k], requestSettings );
if(!mockHandler) {
// No valid mock found for this request
continue;
}
mockedAjaxCalls.push(requestSettings);
// If logging is enabled, log the mock to the console
$.mockjaxSettings.log( mockHandler, requestSettings );
if ( requestSettings.dataType === "jsonp" ) {
if ((mockRequest = processJsonpMock( requestSettings, mockHandler, origSettings ))) {
// This mock will handle the JSONP request
return mockRequest;
}
}
// Removed to fix #54 - keep the mocking data object intact
//mockHandler.data = requestSettings.data;
mockHandler.cache = requestSettings.cache;
mockHandler.timeout = requestSettings.timeout;
mockHandler.global = requestSettings.global;
copyUrlParameters(mockHandler, origSettings);
(function(mockHandler, requestSettings, origSettings, origHandler) {
mockRequest = _ajax.call($, $.extend(true, {}, origSettings, {
// Mock the XHR object
xhr: function() { return xhr( mockHandler, requestSettings, origSettings, origHandler ); }
}));
})(mockHandler, requestSettings, origSettings, mockHandlers[k]);
return mockRequest;
}
// We don't have a mock request
if($.mockjaxSettings.throwUnmocked === true) {
throw('AJAX not mocked: ' + origSettings.url);
}
else { // trigger a normal request
return _ajax.apply($, [origSettings]);
}
}
/**
* Copies URL parameter values if they were captured by a regular expression
* @param {Object} mockHandler
* @param {Object} origSettings
*/
function copyUrlParameters(mockHandler, origSettings) {
//parameters aren't captured if the URL isn't a RegExp
if (!(mockHandler.url instanceof RegExp)) {
return;
}
//if no URL params were defined on the handler, don't attempt a capture
if (!mockHandler.hasOwnProperty('urlParams')) {
return;
}
var captures = mockHandler.url.exec(origSettings.url);
//the whole RegExp match is always the first value in the capture results
if (captures.length === 1) {
return;
}
captures.shift();
//use handler params as keys and capture resuts as values
var i = 0,
capturesLength = captures.length,
paramsLength = mockHandler.urlParams.length,
//in case the number of params specified is less than actual captures
maxIterations = Math.min(capturesLength, paramsLength),
paramValues = {};
for (i; i < maxIterations; i++) {
var key = mockHandler.urlParams[i];
paramValues[key] = captures[i];
}
origSettings.urlParams = paramValues;
}
// Public
$.extend({
ajax: handleAjax
});
$.mockjaxSettings = {
//url: null,
//type: 'GET',
log: function( mockHandler, requestSettings ) {
if ( mockHandler.logging === false ||
( typeof mockHandler.logging === 'undefined' && $.mockjaxSettings.logging === false ) ) {
return;
}
if ( window.console && console.log ) {
var message = 'MOCK ' + requestSettings.type.toUpperCase() + ': ' + requestSettings.url;
var request = $.extend({}, requestSettings);
if (typeof console.log === 'function') {
console.log(message, request);
} else {
try {
console.log( message + ' ' + JSON.stringify(request) );
} catch (e) {
console.log(message);
}
}
}
},
logging: true,
status: 200,
statusText: "OK",
responseTime: 500,
isTimeout: false,
throwUnmocked: false,
contentType: 'text/plain',
response: '',
responseText: '',
responseXML: '',
proxy: '',
proxyType: 'GET',
lastModified: null,
etag: '',
headers: {
etag: 'IJF@H#@923uf8023hFO@I#H#',
'content-type' : 'text/plain'
}
};
$.mockjax = function(settings) {
var i = mockHandlers.length;
mockHandlers[i] = settings;
return i;
};
$.mockjaxClear = function(i) {
if ( arguments.length == 1 ) {
mockHandlers[i] = null;
} else {
mockHandlers = [];
}
mockedAjaxCalls = [];
};
$.mockjax.handler = function(i) {
if ( arguments.length == 1 ) {
return mockHandlers[i];
}
};
$.mockjax.mockedAjaxCalls = function() {
return mockedAjaxCalls;
};
})(jQuery);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,46 @@
/*!
* jQuery xmlDOM Plugin v1.0
* http://outwestmedia.com/jquery-plugins/xmldom/
*
* Released: 2009-04-06
* Version: 1.0
*
* Copyright (c) 2009 Jonathan Sharp, Out West Media LLC.
* Dual licensed under the MIT and GPL licenses.
* http://docs.jquery.com/License
*/
(function($) {
// IE DOMParser wrapper
if ( window['DOMParser'] == undefined && window.ActiveXObject ) {
DOMParser = function() { };
DOMParser.prototype.parseFromString = function( xmlString ) {
var doc = new ActiveXObject('Microsoft.XMLDOM');
doc.async = 'false';
doc.loadXML( xmlString );
return doc;
};
}
$.xmlDOM = function(xml, onErrorFn) {
try {
var xmlDoc = ( new DOMParser() ).parseFromString( xml, 'text/xml' );
if ( $.isXMLDoc( xmlDoc ) ) {
var err = $('parsererror', xmlDoc);
if ( err.length == 1 ) {
throw('Error: ' + $(xmlDoc).text() );
}
} else {
throw('Unable to parse XML');
}
} catch( e ) {
var msg = ( e.name == undefined ? e : e.name + ': ' + e.message );
if ( $.isFunction( onErrorFn ) ) {
onErrorFn( msg );
} else {
$(document).trigger('xmlParseError', [ msg ]);
}
return $([]);
}
return $( xmlDoc );
};
})(jQuery);

View File

@@ -0,0 +1,483 @@
/*
http://www.JSON.org/json2.js
2010-03-20
Public Domain.
NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
See http://www.JSON.org/js.html
This code should be minified before deployment.
See http://javascript.crockford.com/jsmin.html
USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
NOT CONTROL.
This file creates a global JSON object containing two methods: stringify
and parse.
JSON.stringify(value, replacer, space)
value any JavaScript value, usually an object or array.
replacer an optional parameter that determines how object
values are stringified for objects. It can be a
function or an array of strings.
space an optional parameter that specifies the indentation
of nested structures. If it is omitted, the text will
be packed without extra whitespace. If it is a number,
it will specify the number of spaces to indent at each
level. If it is a string (such as '\t' or '&nbsp;'),
it contains the characters used to indent at each level.
This method produces a JSON text from a JavaScript value.
When an object value is found, if the object contains a toJSON
method, its toJSON method will be called and the result will be
stringified. A toJSON method does not serialize: it returns the
value represented by the name/value pair that should be serialized,
or undefined if nothing should be serialized. The toJSON method
will be passed the key associated with the value, and this will be
bound to the value
For example, this would serialize Dates as ISO strings.
Date.prototype.toJSON = function (key) {
function f(n) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}
return this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z';
};
You can provide an optional replacer method. It will be passed the
key and value of each member, with this bound to the containing
object. The value that is returned from your method will be
serialized. If your method returns undefined, then the member will
be excluded from the serialization.
If the replacer parameter is an array of strings, then it will be
used to select the members to be serialized. It filters the results
such that only members with keys listed in the replacer array are
stringified.
Values that do not have JSON representations, such as undefined or
functions, will not be serialized. Such values in objects will be
dropped; in arrays they will be replaced with null. You can use
a replacer function to replace those with JSON values.
JSON.stringify(undefined) returns undefined.
The optional space parameter produces a stringification of the
value that is filled with line breaks and indentation to make it
easier to read.
If the space parameter is a non-empty string, then that string will
be used for indentation. If the space parameter is a number, then
the indentation will be that many spaces.
Example:
text = JSON.stringify(['e', {pluribus: 'unum'}]);
// text is '["e",{"pluribus":"unum"}]'
text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
// text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
text = JSON.stringify([new Date()], function (key, value) {
return this[key] instanceof Date ?
'Date(' + this[key] + ')' : value;
});
// text is '["Date(---current time---)"]'
JSON.parse(text, reviver)
This method parses a JSON text to produce an object or array.
It can throw a SyntaxError exception.
The optional reviver parameter is a function that can filter and
transform the results. It receives each of the keys and values,
and its return value is used instead of the original value.
If it returns what it received, then the structure is not modified.
If it returns undefined then the member is deleted.
Example:
// Parse the text. Values that look like ISO date strings will
// be converted to Date objects.
myData = JSON.parse(text, function (key, value) {
var a;
if (typeof value === 'string') {
a =
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
if (a) {
return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
+a[5], +a[6]));
}
}
return value;
});
myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
var d;
if (typeof value === 'string' &&
value.slice(0, 5) === 'Date(' &&
value.slice(-1) === ')') {
d = new Date(value.slice(5, -1));
if (d) {
return d;
}
}
return value;
});
This is a reference implementation. You are free to copy, modify, or
redistribute.
*/
/*jslint evil: true, strict: false */
/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
lastIndex, length, parse, prototype, push, replace, slice, stringify,
test, toJSON, toString, valueOf
*/
// Create a JSON object only if one does not already exist. We create the
// methods in a closure to avoid creating global variables.
if (!this.JSON) {
this.JSON = {};
}
(function () {
function f(n) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}
if (typeof Date.prototype.toJSON !== 'function') {
Date.prototype.toJSON = function (key) {
return isFinite(this.valueOf()) ?
this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z' : null;
};
String.prototype.toJSON =
Number.prototype.toJSON =
Boolean.prototype.toJSON = function (key) {
return this.valueOf();
};
}
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
gap,
indent,
meta = { // table of character substitutions
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'"' : '\\"',
'\\': '\\\\'
},
rep;
function quote(string) {
// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe escape
// sequences.
escapable.lastIndex = 0;
return escapable.test(string) ?
'"' + string.replace(escapable, function (a) {
var c = meta[a];
return typeof c === 'string' ? c :
'\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
}) + '"' :
'"' + string + '"';
}
function str(key, holder) {
// Produce a string from holder[key].
var i, // The loop counter.
k, // The member key.
v, // The member value.
length,
mind = gap,
partial,
value = holder[key];
// If the value has a toJSON method, call it to obtain a replacement value.
if (value && typeof value === 'object' &&
typeof value.toJSON === 'function') {
value = value.toJSON(key);
}
// If we were called with a replacer function, then call the replacer to
// obtain a replacement value.
if (typeof rep === 'function') {
value = rep.call(holder, key, value);
}
// What happens next depends on the value's type.
switch (typeof value) {
case 'string':
return quote(value);
case 'number':
// JSON numbers must be finite. Encode non-finite numbers as null.
return isFinite(value) ? String(value) : 'null';
case 'boolean':
case 'null':
// If the value is a boolean or null, convert it to a string. Note:
// typeof null does not produce 'null'. The case is included here in
// the remote chance that this gets fixed someday.
return String(value);
// If the type is 'object', we might be dealing with an object or an array or
// null.
case 'object':
// Due to a specification blunder in ECMAScript, typeof null is 'object',
// so watch out for that case.
if (!value) {
return 'null';
}
// Make an array to hold the partial results of stringifying this object value.
gap += indent;
partial = [];
// Is the value an array?
if (Object.prototype.toString.apply(value) === '[object Array]') {
// The value is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.
length = value.length;
for (i = 0; i < length; i += 1) {
partial[i] = str(i, value) || 'null';
}
// Join all of the elements together, separated with commas, and wrap them in
// brackets.
v = partial.length === 0 ? '[]' :
gap ? '[\n' + gap +
partial.join(',\n' + gap) + '\n' +
mind + ']' :
'[' + partial.join(',') + ']';
gap = mind;
return v;
}
// If the replacer is an array, use it to select the members to be stringified.
if (rep && typeof rep === 'object') {
length = rep.length;
for (i = 0; i < length; i += 1) {
k = rep[i];
if (typeof k === 'string') {
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
} else {
// Otherwise, iterate through all of the keys in the object.
for (k in value) {
if (Object.hasOwnProperty.call(value, k)) {
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
}
// Join all of the member texts together, separated with commas,
// and wrap them in braces.
v = partial.length === 0 ? '{}' :
gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
mind + '}' : '{' + partial.join(',') + '}';
gap = mind;
return v;
}
}
// If the JSON object does not yet have a stringify method, give it one.
if (typeof JSON.stringify !== 'function') {
JSON.stringify = function (value, replacer, space) {
// The stringify method takes a value and an optional replacer, and an optional
// space parameter, and returns a JSON text. The replacer can be a function
// that can replace values, or an array of strings that will select the keys.
// A default replacer method can be provided. Use of the space parameter can
// produce text that is more easily readable.
var i;
gap = '';
indent = '';
// If the space parameter is a number, make an indent string containing that
// many spaces.
if (typeof space === 'number') {
for (i = 0; i < space; i += 1) {
indent += ' ';
}
// If the space parameter is a string, it will be used as the indent string.
} else if (typeof space === 'string') {
indent = space;
}
// If there is a replacer, it must be a function or an array.
// Otherwise, throw an error.
rep = replacer;
if (replacer && typeof replacer !== 'function' &&
(typeof replacer !== 'object' ||
typeof replacer.length !== 'number')) {
throw new Error('JSON.stringify');
}
// Make a fake root object containing our value under the key of ''.
// Return the result of stringifying the value.
return str('', {'': value});
};
}
// If the JSON object does not yet have a parse method, give it one.
if (typeof JSON.parse !== 'function') {
JSON.parse = function (text, reviver) {
// The parse method takes a text and an optional reviver function, and returns
// a JavaScript value if the text is a valid JSON text.
var j;
function walk(holder, key) {
// The walk method is used to recursively walk the resulting structure so
// that modifications can be made.
var k, v, value = holder[key];
if (value && typeof value === 'object') {
for (k in value) {
if (Object.hasOwnProperty.call(value, k)) {
v = walk(value, k);
if (v !== undefined) {
value[k] = v;
} else {
delete value[k];
}
}
}
}
return reviver.call(holder, key, value);
}
// Parsing happens in four stages. In the first stage, we replace certain
// Unicode characters with escape sequences. JavaScript handles many characters
// incorrectly, either silently deleting them, or treating them as line endings.
text = String(text);
cx.lastIndex = 0;
if (cx.test(text)) {
text = text.replace(cx, function (a) {
return '\\u' +
('0000' + a.charCodeAt(0).toString(16)).slice(-4);
});
}
// In the second stage, we run the text against regular expressions that look
// for non-JSON patterns. We are especially concerned with '()' and 'new'
// because they can cause invocation, and '=' because it can cause mutation.
// But just to be safe, we want to reject all unexpected forms.
// We split the second stage into 4 regexp operations in order to work around
// crippling inefficiencies in IE's and Safari's regexp engines. First we
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
// replace all simple value tokens with ']' characters. Third, we delete all
// open brackets that follow a colon or comma or that begin the text. Finally,
// we look to see that the remaining characters are only whitespace or ']' or
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
if (/^[\],:{}\s]*$/.
test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
// In the third stage we use the eval function to compile the text into a
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
// in JavaScript: it can begin a block or an object literal. We wrap the text
// in parens to eliminate the ambiguity.
j = eval('(' + text + ')');
// In the optional fourth stage, we recursively walk the new structure, passing
// each name/value pair to a reviver function for possible transformation.
return typeof reviver === 'function' ?
walk({'': j}, '') : j;
}
// If the text is not JSON parseable, then a SyntaxError is thrown.
throw new SyntaxError('JSON.parse');
};
}
}());

View File

@@ -0,0 +1,226 @@
/**
* QUnit 1.1.0 - A JavaScript Unit Testing Framework
*
* http://docs.jquery.com/QUnit
*
* Copyright (c) 2011 John Resig, Jörn Zaefferer
* Dual licensed under the MIT (MIT-LICENSE.txt)
* or GPL (GPL-LICENSE.txt) licenses.
*/
/** Font Family and Sizes */
#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
}
#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
#qunit-tests { font-size: smaller; }
/** Resets */
#qunit-tests, #qunit-tests ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult {
margin: 0;
padding: 0;
}
/** Header */
#qunit-header {
padding: 0.5em 0 0.5em 1em;
color: #8699a4;
background-color: #0d3349;
font-size: 1.5em;
line-height: 1em;
font-weight: normal;
border-radius: 15px 15px 0 0;
-moz-border-radius: 15px 15px 0 0;
-webkit-border-top-right-radius: 15px;
-webkit-border-top-left-radius: 15px;
}
#qunit-header a {
text-decoration: none;
color: #c2ccd1;
}
#qunit-header a:hover,
#qunit-header a:focus {
color: #fff;
}
#qunit-banner {
height: 5px;
}
#qunit-testrunner-toolbar {
padding: 0.5em 0 0.5em 2em;
color: #5E740B;
background-color: #eee;
}
#qunit-userAgent {
padding: 0.5em 0 0.5em 2.5em;
background-color: #2b81af;
color: #fff;
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
}
/** Tests: Pass/Fail */
#qunit-tests {
list-style-position: inside;
}
#qunit-tests li {
padding: 0.4em 0.5em 0.4em 2.5em;
border-bottom: 1px solid #fff;
list-style-position: inside;
}
#qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running {
display: none;
}
#qunit-tests li strong {
cursor: pointer;
}
#qunit-tests li a {
padding: 0.5em;
color: #c2ccd1;
text-decoration: none;
}
#qunit-tests li a:hover,
#qunit-tests li a:focus {
color: #000;
}
#qunit-tests ol {
margin-top: 0.5em;
padding: 0.5em;
background-color: #fff;
border-radius: 15px;
-moz-border-radius: 15px;
-webkit-border-radius: 15px;
box-shadow: inset 0px 2px 13px #999;
-moz-box-shadow: inset 0px 2px 13px #999;
-webkit-box-shadow: inset 0px 2px 13px #999;
}
#qunit-tests table {
border-collapse: collapse;
margin-top: .2em;
}
#qunit-tests th {
text-align: right;
vertical-align: top;
padding: 0 .5em 0 0;
}
#qunit-tests td {
vertical-align: top;
}
#qunit-tests pre {
margin: 0;
white-space: pre-wrap;
word-wrap: break-word;
}
#qunit-tests del {
background-color: #e0f2be;
color: #374e0c;
text-decoration: none;
}
#qunit-tests ins {
background-color: #ffcaca;
color: #500;
text-decoration: none;
}
/*** Test Counts */
#qunit-tests b.counts { color: black; }
#qunit-tests b.passed { color: #5E740B; }
#qunit-tests b.failed { color: #710909; }
#qunit-tests li li {
margin: 0.5em;
padding: 0.4em 0.5em 0.4em 0.5em;
background-color: #fff;
border-bottom: none;
list-style-position: inside;
}
/*** Passing Styles */
#qunit-tests li li.pass {
color: #5E740B;
background-color: #fff;
border-left: 26px solid #C6E746;
}
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
#qunit-tests .pass .test-name { color: #366097; }
#qunit-tests .pass .test-actual,
#qunit-tests .pass .test-expected { color: #999999; }
#qunit-banner.qunit-pass { background-color: #C6E746; }
/*** Failing Styles */
#qunit-tests li li.fail {
color: #710909;
background-color: #fff;
border-left: 26px solid #EE5757;
white-space: pre;
}
#qunit-tests > li:last-child {
border-radius: 0 0 15px 15px;
-moz-border-radius: 0 0 15px 15px;
-webkit-border-bottom-right-radius: 15px;
-webkit-border-bottom-left-radius: 15px;
}
#qunit-tests .fail { color: #000000; background-color: #EE5757; }
#qunit-tests .fail .test-name,
#qunit-tests .fail .module-name { color: #000000; }
#qunit-tests .fail .test-actual { color: #EE5757; }
#qunit-tests .fail .test-expected { color: green; }
#qunit-banner.qunit-fail { background-color: #EE5757; }
/** Result */
#qunit-testresult {
padding: 0.5em 0.5em 0.5em 2.5em;
color: #2b81af;
background-color: #D2E0E6;
border-bottom: 1px solid white;
}
/** Fixture */
#qunit-fixture {
position: absolute;
top: -10000px;
left: -10000px;
}

1585
assets/plugins/jquery-mockjax/lib/qunit.js vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,13 @@
// load testswarm agent
(function() {
var url = window.location.search;
url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) );
if ( !url || url.indexOf("http") !== 0 ) {
return;
}
// (Temporarily) Disable Ajax tests to reduce network strain
isLocal = QUnit.isLocal = true;
document.write("<scr" + "ipt src='http://swarm.amplifyjs.com/js/inject.js?" + (new Date).getTime() + "'></scr" + "ipt>");
})();

View File

@@ -0,0 +1,32 @@
{
"name": "jquery-mockjax",
"version": "1.5.2",
"description": "Mockjax. The jQuery Mockjax Plugin provides a simple and extremely flexible interface for mocking or simulating ajax requests and responses.",
"url": "http://code.appendto.com/plugins/jquery-mockjax/",
"keywords": [ "ajax", "mock", "unit" ],
"author": "Jonathan Sharp (http://jdsharp.com/)",
"homepage": "http://github.com/appendto/jquery-mockjax",
"repository": {
"type": "git",
"url": "https://github.com/appendto/jquery-mockjax.git"
},
"bugs": {
"web": "http://github.com/appendto/jquery-mockjax/issues"
},
"licenses": [
{
"type": "MIT",
"url": "http://appendto.com/open-source-licenses"
},
{
"type": "GPLv2",
"url": "http://appendto.com/open-source-licenses"
}
],
"repositories": [
{
"type": "git",
"url": "http://github.com/appendto/jquery-mockjax.git"
}
]
}

View File

@@ -0,0 +1,30 @@
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" href="../lib/qunit.css" type="text/css" media="screen" />
<script src="../lib/qunit.js"></script>
<script src="../lib/testswarm.js"></script>
<script src="jquery.js"></script>
<script src="../lib/json2.js"></script>
<script src="../jquery.mockjax.js"></script>
<script src="test.js"></script>
<title>MockJax Tests - </title>
</head>
<body>
<h1 id="qunit-header">
MockJax
<a href="?jquery=1.3.2">jQuery 1.3.2</a>
<a href="?jquery=1.4.4">jQuery 1.4.4</a>
<a href="?jquery=1.5.2">jQuery 1.5.2</a>
<a href="?jquery=1.6.4">jQuery 1.6.4</a>
<a href="?jquery=1.7.2">jQuery 1.7.2</a>
<a href="?jquery=1.8.3">jQuery 1.8.3</a>
<a href="?jquery=1.9.1">jQuery 1.9.1</a>
<a href="?jquery=2.0.0">jQuery 2.0.0</a>
<a href="?jquery=git">jQuery Latest (git)</a>
</h1>
<h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
</body>
</html>

View File

@@ -0,0 +1,25 @@
(function() {
var parts = document.location.search.slice( 1 ).split( "&" ),
length = parts.length,
i = 0,
current,
version = "1.3.2",
file = "http://code.jquery.com/jquery-git.js";
for ( ; i < length; i++ ) {
current = parts[ i ].split( "=" );
if ( current[ 0 ] === "jquery" ) {
version = current[ 1 ];
break;
}
}
if (version != "git") {
file = "../lib/jquery-" + version + ".js";
}
document.write( "<script src='" + file + "'></script>" );
})();

1228
assets/plugins/jquery-mockjax/test/test.js vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
{ "say" : "I'm a json file!" }

View File

@@ -0,0 +1 @@
abcdef123456({ "data" : "JSONP is cool" });

View File

@@ -0,0 +1 @@
{ "proxy" : true }

View File

@@ -0,0 +1 @@
TEST_SCRIPT_VAR = 1;

View File

@@ -0,0 +1,19 @@
{ "testswarm" : {
"name" : "jQuery Mockjax Commit <a href=\"http://github.com/appendto/jquery-mockjax/commit/{$REV_FULL$}\">#{$REV$}</a>",
"jobs" : [
{ "browsers" : "popular",
"suites" : {
"jquery-1.3" : "test/index.html?jquery=1.3.2"
}
},
{ "browsers" : "popularbetamobile",
"suites" : {
"jquery-1.4" : "test/index.html?jquery=1.4.4",
"jquery-1.5" : "test/index.html?jquery=1.5.2",
"jquery-1.6" : "test/index.html?jquery=1.6.4",
"jquery-1.7" : "test/index.html?jquery=1.7"
}
}
]
}
}