1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2026-02-10 16:01:33 +00:00

remove dojo uncompressed files

This commit is contained in:
Andrew Dolgov
2013-04-02 20:06:16 +04:00
parent 7caa48fe6a
commit 870334be3f
806 changed files with 0 additions and 156901 deletions
@@ -1,32 +0,0 @@
define("dojo/request/default", [
'exports',
'require',
'../has'
], function(exports, require, has){
var defId = has('config-requestProvider'),
platformId;
if( 1 ){
platformId = './xhr';
}else if( 0 ){
platformId = './node';
/* TODO:
}else if( 0 ){
platformId = './rhino';
*/
}
if(!defId){
defId = platformId;
}
exports.getPlatformDefaultId = function(){
return platformId;
};
exports.load = function(id, parentRequire, loaded, config){
require([id == 'platform' ? platformId : defId], function(provider){
loaded(provider);
});
};
});
@@ -1,62 +0,0 @@
define("dojo/request/handlers", [
'../json',
'../_base/kernel',
'../_base/array',
'../has'
], function(JSON, kernel, array, has){
has.add('activex', typeof ActiveXObject !== 'undefined');
var handleXML;
if(has('activex')){
// GUIDs obtained from http://msdn.microsoft.com/en-us/library/ms757837(VS.85).aspx
var dp = [
'Msxml2.DOMDocument.6.0',
'Msxml2.DOMDocument.4.0',
'MSXML2.DOMDocument.3.0',
'MSXML.DOMDocument' // 2.0
];
handleXML = function(response){
var result = response.data;
if(!result || !result.documentElement){
var text = response.text;
array.some(dp, function(p){
try{
var dom = new ActiveXObject(p);
dom.async = false;
dom.loadXML(text);
result = dom;
}catch(e){ return false; }
return true;
});
}
return result;
};
}
var handlers = {
'javascript': function(response){
return kernel.eval(response.text || '');
},
'json': function(response){
return JSON.parse(response.text || null);
},
'xml': handleXML
};
function handle(response){
var handler = handlers[response.options.handleAs];
response.data = handler ? handler(response) : (response.data || response.text);
return response;
}
handle.register = function(name, handler){
handlers[name] = handler;
};
return handle;
});
-430
View File
@@ -1,430 +0,0 @@
define("dojo/request/iframe", [
'module',
'require',
'./watch',
'./util',
'./handlers',
'../_base/lang',
'../io-query',
'../query',
'../has',
'../dom',
'../dom-construct',
'../_base/window'/*=====,
'../request',
'../_base/declare' =====*/
], function(module, require, watch, util, handlers, lang, ioQuery, query, has, dom, domConstruct, win/*=====, request, declare =====*/){
var mid = module.id.replace(/[\/\.\-]/g, '_'),
onload = mid + '_onload';
if(!win.global[onload]){
win.global[onload] = function(){
var dfd = iframe._currentDfd;
if(!dfd){
iframe._fireNextRequest();
return;
}
var response = dfd.response,
options = response.options,
formNode = dom.byId(options.form) || dfd._tmpForm;
if(formNode){
// remove all the hidden content inputs
var toClean = dfd._contentToClean;
for(var i=0; i<toClean.length; i++){
var key = toClean[i];
//Need to cycle over all nodes since we may have added
//an array value which means that more than one node could
//have the same .name value.
for(var j=0; j<formNode.childNodes.length; j++){
var childNode = formNode.childNodes[j];
if(childNode.name === key){
domConstruct.destroy(childNode);
break;
}
}
}
// restore original action + target
dfd._originalAction && formNode.setAttribute('action', dfd._originalAction);
if(dfd._originalMethod){
formNode.setAttribute('method', dfd._originalMethod);
formNode.method = dfd._originalMethod;
}
if(dfd._originalTarget){
formNode.setAttribute('target', dfd._originalTarget);
formNode.target = dfd._originalTarget;
}
}
if(dfd._tmpForm){
domConstruct.destroy(dfd._tmpForm);
delete dfd._tmpForm;
}
dfd._finished = true;
};
}
function create(name, onloadstr, uri){
if(win.global[name]){
return win.global[name];
}
if(win.global.frames[name]){
return win.global.frames[name];
}
if(!uri){
if(has('config-useXDomain') && !has('config-dojoBlankHtmlUrl')){
console.warn('dojo/request/iframe: When using cross-domain Dojo builds,' +
' please save dojo/resources/blank.html to your domain and set dojoConfig.dojoBlankHtmlUrl' +
' to the path on your domain to blank.html');
}
uri = (has('config-dojoBlankHtmlUrl')||require.toUrl('dojo/resources/blank.html'));
}
var frame = domConstruct.place(
'<iframe id="'+name+'" name="'+name+'" src="'+uri+'" onload="'+onloadstr+
'" style="position: absolute; left: 1px; top: 1px; height: 1px; width: 1px; visibility: hidden">',
win.body());
win.global[name] = frame;
return frame;
}
function setSrc(_iframe, src, replace){
var frame = win.global.frames[_iframe.name];
if(frame.contentWindow){
// We have an iframe node instead of the window
frame = frame.contentWindow;
}
try{
if(!replace){
frame.location = src;
}else{
frame.location.replace(src);
}
}catch(e){
console.log('dojo/request/iframe.setSrc: ', e);
}
}
function doc(iframeNode){
if(iframeNode.contentDocument){
return iframeNode.contentDocument;
}
var name = iframeNode.name;
if(name){
var iframes = win.doc.getElementsByTagName('iframe');
if(iframeNode.document && iframes[name].contentWindow && iframes[name].contentWindow.document){
return iframes[name].contentWindow.document;
}else if(win.doc.frames[name] && win.doc.frames[name].document){
return win.doc.frames[name].document;
}
}
return null;
}
function createForm(){
return domConstruct.create('form', {
name: mid + '_form',
style: {
position: 'absolute',
top: '-1000px',
left: '-1000px'
}
}, win.body());
}
function fireNextRequest(){
// summary:
// Internal method used to fire the next request in the queue.
var dfd;
try{
if(iframe._currentDfd || !iframe._dfdQueue.length){
return;
}
do{
dfd = iframe._currentDfd = iframe._dfdQueue.shift();
}while(dfd && (dfd.canceled || (dfd.isCanceled && dfd.isCanceled())) && iframe._dfdQueue.length);
if(!dfd || dfd.canceled || (dfd.isCanceled && dfd.isCanceled())){
iframe._currentDfd = null;
return;
}
var response = dfd.response,
options = response.options,
c2c = dfd._contentToClean = [],
formNode = dom.byId(options.form),
notify = util.notify,
data = options.data || null,
queryStr;
if(!dfd._legacy && options.method === 'POST' && !formNode){
formNode = dfd._tmpForm = createForm();
}else if(options.method === 'GET' && formNode && response.url.indexOf('?') > -1){
queryStr = response.url.slice(response.url.indexOf('?') + 1);
data = lang.mixin(ioQuery.queryToObject(queryStr), data);
}
if(formNode){
if(!dfd._legacy){
var parentNode = formNode;
do{
parentNode = parentNode.parentNode;
}while(parentNode !== win.doc.documentElement);
// Append the form node or some browsers won't work
if(!parentNode){
formNode.style.position = 'absolute';
formNode.style.left = '-1000px';
formNode.style.top = '-1000px';
win.body().appendChild(formNode);
}
if(!formNode.name){
formNode.name = mid + '_form';
}
}
// if we have things in data, we need to add them to the form
// before submission
if(data){
var createInput = function(name, value){
domConstruct.create('input', {
type: 'hidden',
name: name,
value: value
}, formNode);
c2c.push(name);
};
for(var x in data){
var val = data[x];
if(lang.isArray(val) && val.length > 1){
for(var i=0; i<val.length; i++){
createInput(x, val[i]);
}
}else{
if(!formNode[x]){
createInput(x, val);
}else{
formNode[x].value = val;
}
}
}
}
//IE requires going through getAttributeNode instead of just getAttribute in some form cases,
//so use it for all. See #2844
var actionNode = formNode.getAttributeNode('action'),
methodNode = formNode.getAttributeNode('method'),
targetNode = formNode.getAttributeNode('target');
if(response.url){
dfd._originalAction = actionNode ? actionNode.value : null;
if(actionNode){
actionNode.value = response.url;
}else{
formNode.setAttribute('action', response.url);
}
}
if(!dfd._legacy){
dfd._originalMethod = methodNode ? methodNode.value : null;
if(methodNode){
methodNode.value = options.method;
}else{
formNode.setAttribute('method', options.method);
}
}else{
if(!methodNode || !methodNode.value){
if(mthdNode){
mthdNode.value = options.method;
}else{
fn.setAttribute("method", options.method);
}
}
}
dfd._originalTarget = targetNode ? targetNode.value : null;
if(targetNode){
targetNode.value = iframe._iframeName;
}else{
formNode.setAttribute('target', iframe._iframeName);
}
formNode.target = iframe._iframeName;
notify && notify.emit('send', response, dfd.promise.cancel);
iframe._notifyStart(response);
formNode.submit();
}else{
// otherwise we post a GET string by changing URL location for the
// iframe
var extra = '';
if(response.options.data){
extra = response.options.data;
if(typeof extra !== 'string'){
extra = ioQuery.objectToQuery(extra);
}
}
var tmpUrl = response.url + (response.url.indexOf('?') > -1 ? '&' : '?') + extra;
notify && notify.emit('send', response, dfd.promise.cancel);
iframe._notifyStart(response);
iframe.setSrc(iframe._frame, tmpUrl, true);
}
}catch(e){
dfd.reject(e);
}
}
// dojo/request/watch handlers
function isValid(response){
return !this.isFulfilled();
}
function isReady(response){
return !!this._finished;
}
function handleResponse(response, error){
if(!error){
try{
var options = response.options,
doc = iframe.doc(iframe._frame),
handleAs = options.handleAs;
if(handleAs !== 'html'){
if(handleAs === 'xml'){
// IE6-8 have to parse the XML manually. See http://bugs.dojotoolkit.org/ticket/6334
if(doc.documentElement.tagName.toLowerCase() === 'html'){
query('a', doc.documentElement).orphan();
var xmlText = doc.documentElement.innerText;
xmlText = xmlText.replace(/>\s+</g, '><');
response.text = lang.trim(xmlText);
}else{
response.data = doc;
}
}else{
// 'json' and 'javascript' and 'text'
response.text = doc.getElementsByTagName('textarea')[0].value; // text
}
handlers(response);
}else{
response.data = doc;
}
}catch(e){
error = e;
}
}
if(error){
this.reject(error);
}else if(this._finished){
this.resolve(response);
}else{
this.reject(new Error('Invalid dojo/request/iframe request state'));
}
}
function last(response){
this._callNext();
}
var defaultOptions = {
method: 'POST'
};
function iframe(url, options, returnDeferred){
var response = util.parseArgs(url, util.deepCreate(defaultOptions, options), true);
url = response.url;
options = response.options;
if(options.method !== 'GET' && options.method !== 'POST'){
throw new Error(options.method + ' not supported by dojo/request/iframe');
}
if(!iframe._frame){
iframe._frame = iframe.create(iframe._iframeName, onload + '();');
}
var dfd = util.deferred(response, null, isValid, isReady, handleResponse, last);
dfd._callNext = function(){
if(!this._calledNext){
this._calledNext = true;
iframe._currentDfd = null;
iframe._fireNextRequest();
}
};
dfd._legacy = returnDeferred;
iframe._dfdQueue.push(dfd);
iframe._fireNextRequest();
watch(dfd);
return returnDeferred ? dfd : dfd.promise;
}
/*=====
iframe = function(url, options){
// summary:
// Sends a request using an iframe element with the given URL and options.
// url: String
// URL to request
// options: dojo/request/iframe.__Options?
// Options for the request.
// returns: dojo/request.__Promise
};
iframe.__BaseOptions = declare(request.__BaseOptions, {
// form: DOMNode?
// A form node to use to submit data to the server.
// data: String|Object?
// Data to transfer. When making a GET request, this will
// be converted to key=value parameters and appended to the
// URL.
});
iframe.__MethodOptions = declare(null, {
// method: String?
// The HTTP method to use to make the request. Must be
// uppercase. Only `"GET"` and `"POST"` are accepted.
// Default is `"POST"`.
});
iframe.__Options = declare([iframe.__BaseOptions, iframe.__MethodOptions]);
iframe.get = function(url, options){
// summary:
// Send an HTTP GET request using an iframe element with the given URL and options.
// url: String
// URL to request
// options: dojo/request/iframe.__BaseOptions?
// Options for the request.
// returns: dojo/request.__Promise
};
iframe.post = function(url, options){
// summary:
// Send an HTTP POST request using an iframe element with the given URL and options.
// url: String
// URL to request
// options: dojo/request/iframe.__BaseOptions?
// Options for the request.
// returns: dojo/request.__Promise
};
=====*/
iframe.create = create;
iframe.doc = doc;
iframe.setSrc = setSrc;
// TODO: Make these truly private in 2.0
iframe._iframeName = mid + '_IoIframe';
iframe._notifyStart = function(){};
iframe._dfdQueue = [];
iframe._currentDfd = null;
iframe._fireNextRequest = fireNextRequest;
util.addCommonMethods(iframe, ['GET', 'POST']);
return iframe;
});
-191
View File
@@ -1,191 +0,0 @@
define("dojo/request/node", [
'require',
'./util',
'./handlers',
'../errors/RequestTimeoutError',
'../node!http',
'../node!https',
'../node!url',
'../node!stream'/*=====,
'../request',
'../_base/declare' =====*/
], function(require, util, handlers, RequestTimeoutError, http, https, URL, stream/*=====, request, declare =====*/){
var Stream = stream.Stream,
undefined;
var defaultOptions = {
method: 'GET',
query: null,
data: undefined,
headers: {}
};
function node(url, options){
var response = util.parseArgs(url, util.deepCreate(defaultOptions, options), options && options.data instanceof Stream);
url = response.url;
options = response.options;
var def = util.deferred(
response,
function(dfd, response){
response.clientRequest.abort();
}
);
url = URL.parse(url);
var reqOptions = response.requestOptions = {
hostname: url.hostname,
port: url.port,
socketPath: options.socketPath,
method: options.method,
headers: options.headers,
agent: options.agent,
pfx: options.pfx,
key: options.key,
passphrase: options.passphrase,
cert: options.cert,
ca: options.ca,
ciphers: options.ciphers,
rejectUnauthorized: options.rejectUnauthorized === false ? false : true
};
if(url.path){
reqOptions.path = url.path;
}
if(options.user || options.password){
reqOptions.auth = (options.user||'') + ':' + (options.password||'');
}
var req = response.clientRequest = (url.protocol === 'https:' ? https : http).request(reqOptions);
if(options.socketOptions){
if('timeout' in options.socketOptions){
req.setTimeout(options.socketOptions.timeout);
}
if('noDelay' in options.socketOptions){
req.setNoDelay(options.socketOptions.noDelay);
}
if('keepAlive' in options.socketOptions){
var initialDelay = options.socketOptions.keepAlive;
req.setKeepAlive(initialDelay >= 0, initialDelay || 0);
}
}
req.on('socket', function(){
response.hasSocket = true;
def.progress(response);
});
req.on('response', function(clientResponse){
response.clientResponse = clientResponse;
response.status = clientResponse.statusCode;
response.getHeader = function(headerName){
return clientResponse.headers[headerName.toLowerCase()] || null;
};
var body = [];
clientResponse.on('data', function(chunk){
body.push(chunk);
// TODO: progress updates via the deferred
});
clientResponse.on('end', function(){
if(timeout){
clearTimeout(timeout);
}
response.text = body.join('');
handlers(response);
def.resolve(response);
});
});
req.on('error', def.reject);
if(options.data){
if(typeof options.data === "string"){
req.end(options.data);
}else{
options.data.pipe(req);
}
}else{
req.end();
}
if(options.timeout){
var timeout = setTimeout(function(){
def.cancel(new RequestTimeoutError(response));
}, options.timeout);
}
return def.promise;
}
/*=====
node = function(url, options){
// summary:
// Sends a request using the included http or https interface from node.js
// with the given URL and options.
// url: String
// URL to request
// options: dojo/request/node.__Options?
// Options for the request.
// returns: dojo/request.__Promise
};
node.__BaseOptions = declare(request.__BaseOptions, {
// data: String|Object|Stream?
// Data to transfer. This is ignored for GET and DELETE
// requests.
// headers: Object?
// Headers to use for the request.
// user: String?
// Username to use during the request.
// password: String?
// Password to use during the request.
});
node.__MethodOptions = declare(null, {
// method: String?
// The HTTP method to use to make the request. Must be
// uppercase. Default is `"GET"`.
});
node.__Options = declare([node.__BaseOptions, node.__MethodOptions]);
node.get = function(url, options){
// summary:
// Send an HTTP GET request using XMLHttpRequest with the given URL and options.
// url: String
// URL to request
// options: dojo/request/node.__BaseOptions?
// Options for the request.
// returns: dojo/request.__Promise
};
node.post = function(url, options){
// summary:
// Send an HTTP POST request using XMLHttpRequest with the given URL and options.
// url: String
// URL to request
// options: dojo/request/node.__BaseOptions?
// Options for the request.
// returns: dojo/request.__Promise
};
node.put = function(url, options){
// summary:
// Send an HTTP PUT request using XMLHttpRequest with the given URL and options.
// url: String
// URL to request
// options: dojo/request/node.__BaseOptions?
// Options for the request.
// returns: dojo/request.__Promise
};
node.del = function(url, options){
// summary:
// Send an HTTP DELETE request using XMLHttpRequest with the given URL and options.
// url: String
// URL to request
// options: dojo/request/node.__BaseOptions?
// Options for the request.
// returns: dojo/request.__Promise
};
=====*/
util.addCommonMethods(node);
return node;
});
@@ -1,74 +0,0 @@
define("dojo/request/notify", ['../Evented', '../_base/lang', './util'], function(Evented, lang, util){
// module:
// dojo/request/notify
// summary:
// Global notification API for dojo/request. Notifications will
// only be emitted if this module is required.
//
// | require('dojo/request', 'dojo/request/notify',
// | function(request, notify){
// | notify('load', function(response){
// | if(response.url === 'someUrl.html'){
// | console.log('Loaded!');
// | }
// | });
// | request.get('someUrl.html');
// | }
// | );
var pubCount = 0,
slice = [].slice;
var hub = lang.mixin(new Evented, {
onsend: function(data){
if(!pubCount){
this.emit('start');
}
pubCount++;
},
_onload: function(data){
this.emit('done', data);
},
_onerror: function(data){
this.emit('done', data);
},
_ondone: function(data){
if(--pubCount <= 0){
pubCount = 0;
this.emit('stop');
}
},
emit: function(type, event){
var result = Evented.prototype.emit.apply(this, arguments);
// After all event handlers have run, run _on* handler
if(this['_on' + type]){
this['_on' + type].apply(this, slice.call(arguments, 1));
}
return result;
}
});
function notify(type, listener){
// summary:
// Register a listener to be notified when an event
// in dojo/request happens.
// type: String?
// The event to listen for. Events emitted: "start", "send",
// "load", "error", "done", "stop".
// listener: Function?
// A callback to be run when an event happens.
// returns:
// A signal object that can be used to cancel the listener.
// If remove() is called on this signal object, it will
// stop the listener from being executed.
return hub.on(type, listener);
}
notify.emit = function(type, event, cancel){
return hub.emit(type, event, cancel);
};
// Attach notify to dojo/request/util to avoid
// try{ require('./notify'); }catch(e){}
return util.notify = notify;
});
@@ -1,85 +0,0 @@
define("dojo/request/registry", [
'require',
'../_base/array',
'./default!platform',
'./util'
], function(require, array, fallbackProvider, util){
var providers = [];
function request(url, options){
var matchers = providers.slice(0),
i = 0,
matcher;
while(matcher=matchers[i++]){
if(matcher(url, options)){
return matcher.request.call(null, url, options);
}
}
return fallbackProvider.apply(null, arguments);
}
function createMatcher(match, provider){
var matcher;
if(provider){
if(match.test){
// RegExp
matcher = function(url){
return match.test(url);
};
}else if(match.apply && match.call){
matcher = function(){
return match.apply(null, arguments);
};
}else{
matcher = function(url){
return url === match;
};
}
matcher.request = provider;
}else{
// If only one argument was passed, assume it is a provider function
// to apply unconditionally to all URLs
matcher = function(){
return true;
};
matcher.request = match;
}
return matcher;
}
request.register = function(url, provider, first){
var matcher = createMatcher(url, provider);
providers[(first ? 'unshift' : 'push')](matcher);
return {
remove: function(){
var idx;
if(~(idx = array.indexOf(providers, matcher))){
providers.splice(idx, 1);
}
}
};
};
request.load = function(id, parentRequire, loaded, config){
if(id){
// if there's an id, load and set the fallback provider
require([id], function(fallback){
fallbackProvider = fallback;
loaded(request);
});
}else{
loaded(request);
}
};
util.addCommonMethods(request);
return request;
});
-218
View File
@@ -1,218 +0,0 @@
define("dojo/request/script", [
'module',
'./watch',
'./util',
'../_base/array',
'../_base/lang',
'../on',
'../dom',
'../dom-construct',
'../has',
'../_base/window'/*=====,
'../request',
'../_base/declare' =====*/
], function(module, watch, util, array, lang, on, dom, domConstruct, has, win/*=====, request, declare =====*/){
has.add('script-readystatechange', function(global, document){
var script = document.createElement('script');
return typeof script['onreadystatechange'] !== 'undefined' &&
(typeof global['opera'] === 'undefined' || global['opera'].toString() !== '[object Opera]');
});
var mid = module.id.replace(/[\/\.\-]/g, '_'),
counter = 0,
loadEvent = has('script-readystatechange') ? 'readystatechange' : 'load',
readyRegExp = /complete|loaded/,
callbacks = this[mid + '_callbacks'] = {},
deadScripts = [];
function attach(id, url, frameDoc){
var doc = (frameDoc || win.doc),
element = doc.createElement('script');
element.type = 'text/javascript';
element.src = url;
element.id = id;
element.async = true;
element.charset = 'utf-8';
return doc.getElementsByTagName('head')[0].appendChild(element);
}
function remove(id, frameDoc, cleanup){
domConstruct.destroy(dom.byId(id, frameDoc));
if(callbacks[id]){
if(cleanup){
// set callback to a function that deletes itself so requests that
// are in-flight don't error out when returning and also
// clean up after themselves
callbacks[id] = function(){
delete callbacks[id];
};
}else{
delete callbacks[id];
}
}
}
function _addDeadScript(dfd){
// Be sure to check ioArgs because it can dynamically change in the dojox/io plugins.
// See http://bugs.dojotoolkit.org/ticket/15890.
var options = dfd.response.options,
frameDoc = options.ioArgs ? options.ioArgs.frameDoc : options.frameDoc;
deadScripts.push({ id: dfd.id, frameDoc: frameDoc });
if(options.ioArgs){
options.ioArgs.frameDoc = null;
}
options.frameDoc = null;
}
function canceler(dfd, response){
if(dfd.canDelete){
//For timeouts and cancels, remove the script element immediately to
//avoid a response from it coming back later and causing trouble.
script._remove(dfd.id, response.options.frameDoc, true);
}
}
function isValid(response){
//Do script cleanup here. We wait for one inflight pass
//to make sure we don't get any weird things by trying to remove a script
//tag that is part of the call chain (IE 6 has been known to
//crash in that case).
if(deadScripts && deadScripts.length){
array.forEach(deadScripts, function(_script){
script._remove(_script.id, _script.frameDoc);
_script.frameDoc = null;
});
deadScripts = [];
}
return response.options.jsonp ? !response.data : true;
}
function isReadyScript(response){
return !!this.scriptLoaded;
}
function isReadyCheckString(response){
var checkString = response.options.checkString;
return checkString && eval('typeof(' + checkString + ') !== "undefined"');
}
function handleResponse(response, error){
if(this.canDelete){
_addDeadScript(this);
}
if(error){
this.reject(error);
}else{
this.resolve(response);
}
}
function script(url, options, returnDeferred){
var response = util.parseArgs(url, util.deepCopy({}, options));
url = response.url;
options = response.options;
var dfd = util.deferred(
response,
canceler,
isValid,
options.jsonp ? null : (options.checkString ? isReadyCheckString : isReadyScript),
handleResponse
);
lang.mixin(dfd, {
id: mid + (counter++),
canDelete: false
});
if(options.jsonp){
var queryParameter = new RegExp('[?&]' + options.jsonp + '=');
if(!queryParameter.test(url)){
url += queryParameter +
(options.frameDoc ? 'parent.' : '') +
mid + '_callbacks.' + dfd.id;
}
dfd.canDelete = true;
callbacks[dfd.id] = function(json){
response.data = json;
dfd.handleResponse(response);
};
}
if(util.notify){
util.notify.emit('send', response, dfd.promise.cancel);
}
if(!options.canAttach || options.canAttach(dfd)){
var node = script._attach(dfd.id, url, options.frameDoc);
if(!options.jsonp && !options.checkString){
var handle = on(node, loadEvent, function(evt){
if(evt.type === 'load' || readyRegExp.test(node.readyState)){
handle.remove();
dfd.scriptLoaded = evt;
}
});
}
}
watch(dfd);
return returnDeferred ? dfd : dfd.promise;
}
script.get = script;
/*=====
script = function(url, options){
// summary:
// Sends a request using a script element with the given URL and options.
// url: String
// URL to request
// options: dojo/request/script.__Options?
// Options for the request.
// returns: dojo/request.__Promise
};
script.__BaseOptions = declare(request.__BaseOptions, {
// jsonp: String?
// The URL parameter name that indicates the JSONP callback string.
// For instance, when using Yahoo JSONP calls it is normally,
// jsonp: "callback". For AOL JSONP calls it is normally
// jsonp: "c".
// checkString: String?
// A string of JavaScript that when evaluated like so:
// "typeof(" + checkString + ") != 'undefined'"
// being true means that the script fetched has been loaded.
// Do not use this if doing a JSONP type of call (use `jsonp` instead).
// frameDoc: Document?
// The Document object of a child iframe. If this is passed in, the script
// will be attached to that document. This can be helpful in some comet long-polling
// scenarios with Firefox and Opera.
});
script.__MethodOptions = declare(null, {
// method: String?
// This option is ignored. All requests using this transport are
// GET requests.
});
script.__Options = declare([script.__BaseOptions, script.__MethodOptions]);
script.get = function(url, options){
// summary:
// Send an HTTP GET request using a script element with the given URL and options.
// url: String
// URL to request
// options: dojo/request/script.__BaseOptions?
// Options for the request.
// returns: dojo/request.__Promise
};
=====*/
// TODO: Remove in 2.0
script._attach = attach;
script._remove = remove;
script._callbacksProperty = mid + '_callbacks';
return script;
});
-145
View File
@@ -1,145 +0,0 @@
define("dojo/request/util", [
'exports',
'../errors/RequestError',
'../errors/CancelError',
'../Deferred',
'../io-query',
'../_base/array',
'../_base/lang'
], function(exports, RequestError, CancelError, Deferred, ioQuery, array, lang){
exports.deepCopy = function deepCopy(target, source){
for(var name in source){
var tval = target[name],
sval = source[name];
if(tval !== sval){
if(tval && typeof tval === 'object' && sval && typeof sval === 'object'){
exports.deepCopy(tval, sval);
}else{
target[name] = sval;
}
}
}
return target;
};
exports.deepCreate = function deepCreate(source, properties){
properties = properties || {};
var target = lang.delegate(source),
name, value;
for(name in source){
value = source[name];
if(value && typeof value === 'object'){
target[name] = exports.deepCreate(value, properties[name]);
}
}
return exports.deepCopy(target, properties);
};
var freeze = Object.freeze || function(obj){ return obj; };
function okHandler(response){
return freeze(response);
}
exports.deferred = function deferred(response, cancel, isValid, isReady, handleResponse, last){
var def = new Deferred(function(reason){
cancel && cancel(def, response);
if(!reason || !(reason instanceof RequestError) && !(reason instanceof CancelError)){
return new CancelError('Request canceled', response);
}
return reason;
});
def.response = response;
def.isValid = isValid;
def.isReady = isReady;
def.handleResponse = handleResponse;
function errHandler(error){
error.response = response;
throw error;
}
var responsePromise = def.then(okHandler).otherwise(errHandler);
if(exports.notify){
responsePromise.then(
lang.hitch(exports.notify, 'emit', 'load'),
lang.hitch(exports.notify, 'emit', 'error')
);
}
var dataPromise = responsePromise.then(function(response){
return response.data || response.text;
});
var promise = freeze(lang.delegate(dataPromise, {
response: responsePromise
}));
if(last){
def.then(function(response){
last.call(def, response);
}, function(error){
last.call(def, response, error);
});
}
def.promise = promise;
def.then = promise.then;
return def;
};
exports.addCommonMethods = function addCommonMethods(provider, methods){
array.forEach(methods||['GET', 'POST', 'PUT', 'DELETE'], function(method){
provider[(method === 'DELETE' ? 'DEL' : method).toLowerCase()] = function(url, options){
options = lang.delegate(options||{});
options.method = method;
return provider(url, options);
};
});
};
exports.parseArgs = function parseArgs(url, options, skipData){
var data = options.data,
query = options.query;
if(data && !skipData){
if(typeof data === 'object'){
options.data = ioQuery.objectToQuery(data);
}
}
if(query){
if(typeof query === 'object'){
query = ioQuery.objectToQuery(query);
}
if(options.preventCache){
query += (query ? '&' : '') + 'request.preventCache=' + (+(new Date));
}
}else if(options.preventCache){
query = 'request.preventCache=' + (+(new Date));
}
if(url && query){
url += (~url.indexOf('?') ? '&' : '?') + query;
}
return {
url: url,
options: options,
getHeader: function(headerName){ return null; }
};
};
exports.checkStatus = function(stat){
stat = stat || 0;
return (stat >= 200 && stat < 300) || // allow any 2XX response code
stat === 304 || // or, get it out of the cache
stat === 1223 || // or, Internet Explorer mangled the status code
!stat; // or, we're Titanium/browser chrome/chrome extension requesting a local file
};
});
-109
View File
@@ -1,109 +0,0 @@
define("dojo/request/watch", [
'./util',
'../errors/RequestTimeoutError',
'../errors/CancelError',
'../_base/array',
'../_base/window',
'../has!host-browser?dom-addeventlistener?:../on:'
], function(util, RequestTimeoutError, CancelError, array, win, on){
// avoid setting a timer per request. It degrades performance on IE
// something fierece if we don't use unified loops.
var _inFlightIntvl = null,
_inFlight = [];
function watchInFlight(){
// summary:
// internal method that checks each inflight XMLHttpRequest to see
// if it has completed or if the timeout situation applies.
var now = +(new Date);
// we need manual loop because we often modify _inFlight (and therefore 'i') while iterating
for(var i = 0, dfd; i < _inFlight.length && (dfd = _inFlight[i]); i++){
var response = dfd.response,
options = response.options;
if((dfd.isCanceled && dfd.isCanceled()) || (dfd.isValid && !dfd.isValid(response))){
_inFlight.splice(i--, 1);
watch._onAction && watch._onAction();
}else if(dfd.isReady && dfd.isReady(response)){
_inFlight.splice(i--, 1);
dfd.handleResponse(response);
watch._onAction && watch._onAction();
}else if(dfd.startTime){
// did we timeout?
if(dfd.startTime + (options.timeout || 0) < now){
_inFlight.splice(i--, 1);
// Cancel the request so the io module can do appropriate cleanup.
dfd.cancel(new RequestTimeoutError('Timeout exceeded', response));
watch._onAction && watch._onAction();
}
}
}
watch._onInFlight && watch._onInFlight(dfd);
if(!_inFlight.length){
clearInterval(_inFlightIntvl);
_inFlightIntvl = null;
}
}
function watch(dfd){
// summary:
// Watches the io request represented by dfd to see if it completes.
// dfd: Deferred
// The Deferred object to watch.
// response: Object
// The object used as the value of the request promise.
// validCheck: Function
// Function used to check if the IO request is still valid. Gets the dfd
// object as its only argument.
// ioCheck: Function
// Function used to check if basic IO call worked. Gets the dfd
// object as its only argument.
// resHandle: Function
// Function used to process response. Gets the dfd
// object as its only argument.
if(dfd.response.options.timeout){
dfd.startTime = +(new Date);
}
if(dfd.isFulfilled()){
// bail out if the deferred is already fulfilled
return;
}
_inFlight.push(dfd);
if(!_inFlightIntvl){
_inFlightIntvl = setInterval(watchInFlight, 50);
}
// handle sync requests separately from async:
// http://bugs.dojotoolkit.org/ticket/8467
if(dfd.response.options.sync){
watchInFlight();
}
}
watch.cancelAll = function cancelAll(){
// summary:
// Cancels all pending IO requests, regardless of IO type
try{
array.forEach(_inFlight, function(dfd){
try{
dfd.cancel(new CancelError('All requests canceled.'));
}catch(e){}
});
}catch(e){}
};
if(win && on && win.doc.attachEvent){
// Automatically call cancel all io calls on unload in IE
// http://bugs.dojotoolkit.org/ticket/2357
on(win.global, 'unload', function(){
watch.cancelAll();
});
}
return watch;
});
-316
View File
@@ -1,316 +0,0 @@
define("dojo/request/xhr", [
'../errors/RequestError',
'./watch',
'./handlers',
'./util',
'../has'/*=====,
'../request',
'../_base/declare' =====*/
], function(RequestError, watch, handlers, util, has/*=====, request, declare =====*/){
has.add('native-xhr', function(){
// if true, the environment has a native XHR implementation
return typeof XMLHttpRequest !== 'undefined';
});
has.add('dojo-force-activex-xhr', function(){
return has('activex') && !document.addEventListener && window.location.protocol === 'file:';
});
has.add('native-xhr2', function(){
if(!has('native-xhr')){ return; }
var x = new XMLHttpRequest();
return typeof x['addEventListener'] !== 'undefined' &&
(typeof opera === 'undefined' || typeof x['upload'] !== 'undefined');
});
has.add('native-formdata', function(){
// if true, the environment has a native FormData implementation
return typeof FormData === 'function';
});
function handleResponse(response, error){
var _xhr = response.xhr;
response.status = response.xhr.status;
response.text = _xhr.responseText;
if(response.options.handleAs === 'xml'){
response.data = _xhr.responseXML;
}
if(!error){
try{
handlers(response);
}catch(e){
error = e;
}
}
if(error){
this.reject(error);
}else if(util.checkStatus(_xhr.status)){
this.resolve(response);
}else{
error = new RequestError('Unable to load ' + response.url + ' status: ' + _xhr.status, response);
this.reject(error);
}
}
var isValid, isReady, addListeners, cancel;
if(has('native-xhr2')){
// Any platform with XHR2 will only use the watch mechanism for timeout.
isValid = function(response){
// summary:
// Check to see if the request should be taken out of the watch queue
return !this.isFulfilled();
};
cancel = function(dfd, response){
// summary:
// Canceler for deferred
response.xhr.abort();
};
addListeners = function(_xhr, dfd, response){
// summary:
// Adds event listeners to the XMLHttpRequest object
function onLoad(evt){
dfd.handleResponse(response);
}
function onError(evt){
var _xhr = evt.target;
var error = new RequestError('Unable to load ' + response.url + ' status: ' + _xhr.status, response);
dfd.handleResponse(response, error);
}
function onProgress(evt){
if(evt.lengthComputable){
response.loaded = evt.loaded;
response.total = evt.total;
dfd.progress(response);
}
}
_xhr.addEventListener('load', onLoad, false);
_xhr.addEventListener('error', onError, false);
_xhr.addEventListener('progress', onProgress, false);
return function(){
_xhr.removeEventListener('load', onLoad, false);
_xhr.removeEventListener('error', onError, false);
_xhr.removeEventListener('progress', onProgress, false);
};
};
}else{
isValid = function(response){
return response.xhr.readyState; //boolean
};
isReady = function(response){
return 4 === response.xhr.readyState; //boolean
};
cancel = function(dfd, response){
// summary:
// canceller function for util.deferred call.
var xhr = response.xhr;
var _at = typeof xhr.abort;
if(_at === 'function' || _at === 'object' || _at === 'unknown'){
xhr.abort();
}
};
}
var undefined,
defaultOptions = {
data: null,
query: null,
sync: false,
method: 'GET',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
};
function xhr(url, options, returnDeferred){
var response = util.parseArgs(
url,
util.deepCreate(defaultOptions, options),
has('native-formdata') && options && options.data && options.data instanceof FormData
);
url = response.url;
options = response.options;
var remover,
last = function(){
remover && remover();
};
//Make the Deferred object for this xhr request.
var dfd = util.deferred(
response,
cancel,
isValid,
isReady,
handleResponse,
last
);
var _xhr = response.xhr = xhr._create();
if(!_xhr){
// If XHR factory somehow returns nothings,
// cancel the deferred.
dfd.cancel(new RequestError('XHR was not created'));
return returnDeferred ? dfd : dfd.promise;
}
response.getHeader = function(headerName){
return this.xhr.getResponseHeader(headerName);
};
if(addListeners){
remover = addListeners(_xhr, dfd, response);
}
var data = options.data,
async = !options.sync,
method = options.method;
try{
// IE6 won't let you call apply() on the native function.
_xhr.open(method, url, async, options.user || undefined, options.password || undefined);
if(options.withCredentials){
_xhr.withCredentials = options.withCredentials;
}
var headers = options.headers,
contentType;
if(headers){
for(var hdr in headers){
if(hdr.toLowerCase() === 'content-type'){
contentType = headers[hdr];
}else if(headers[hdr]){
//Only add header if it has a value. This allows for instance, skipping
//insertion of X-Requested-With by specifying empty value.
_xhr.setRequestHeader(hdr, headers[hdr]);
}
}
}
if(contentType && contentType !== false){
_xhr.setRequestHeader('Content-Type', contentType);
}
if(!headers || !('X-Requested-With' in headers)){
_xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
}
if(util.notify){
util.notify.emit('send', response, dfd.promise.cancel);
}
_xhr.send(data);
}catch(e){
dfd.reject(e);
}
watch(dfd);
_xhr = null;
return returnDeferred ? dfd : dfd.promise;
}
/*=====
xhr = function(url, options){
// summary:
// Sends a request using XMLHttpRequest with the given URL and options.
// url: String
// URL to request
// options: dojo/request/xhr.__Options?
// Options for the request.
// returns: dojo/request.__Promise
};
xhr.__BaseOptions = declare(request.__BaseOptions, {
// sync: Boolean?
// Whether to make a synchronous request or not. Default
// is `false` (asynchronous).
// data: String|Object|FormData?
// Data to transfer. This is ignored for GET and DELETE
// requests.
// headers: Object?
// Headers to use for the request.
// user: String?
// Username to use during the request.
// password: String?
// Password to use during the request.
// withCredentials: Boolean?
// For cross-site requests, whether to send credentials
// or not.
});
xhr.__MethodOptions = declare(null, {
// method: String?
// The HTTP method to use to make the request. Must be
// uppercase. Default is `"GET"`.
});
xhr.__Options = declare([xhr.__BaseOptions, xhr.__MethodOptions]);
xhr.get = function(url, options){
// summary:
// Send an HTTP GET request using XMLHttpRequest with the given URL and options.
// url: String
// URL to request
// options: dojo/request/xhr.__BaseOptions?
// Options for the request.
// returns: dojo/request.__Promise
};
xhr.post = function(url, options){
// summary:
// Send an HTTP POST request using XMLHttpRequest with the given URL and options.
// url: String
// URL to request
// options: dojo/request/xhr.__BaseOptions?
// Options for the request.
// returns: dojo/request.__Promise
};
xhr.put = function(url, options){
// summary:
// Send an HTTP PUT request using XMLHttpRequest with the given URL and options.
// url: String
// URL to request
// options: dojo/request/xhr.__BaseOptions?
// Options for the request.
// returns: dojo/request.__Promise
};
xhr.del = function(url, options){
// summary:
// Send an HTTP DELETE request using XMLHttpRequest with the given URL and options.
// url: String
// URL to request
// options: dojo/request/xhr.__BaseOptions?
// Options for the request.
// returns: dojo/request.__Promise
};
=====*/
xhr._create = function(){
// summary:
// does the work of portably generating a new XMLHTTPRequest object.
throw new Error('XMLHTTP not available');
};
if(has('native-xhr') && !has('dojo-force-activex-xhr')){
xhr._create = function(){
return new XMLHttpRequest();
};
}else if(has('activex')){
try{
new ActiveXObject('Msxml2.XMLHTTP');
xhr._create = function(){
return new ActiveXObject('Msxml2.XMLHTTP');
};
}catch(e){
try{
new ActiveXObject('Microsoft.XMLHTTP');
xhr._create = function(){
return new ActiveXObject('Microsoft.XMLHTTP');
};
}catch(e){}
}
}
util.addCommonMethods(xhr);
return xhr;
});