~ubuntu-branches/ubuntu/precise/whoopsie-daisy/precise-proposed

« back to all changes in this revision

Viewing changes to backend/stats/static/js/yui/build/node-load/node-load-debug.js

  • Committer: Package Import Robot
  • Author(s): Evan Dandrea
  • Date: 2012-04-18 13:04:36 UTC
  • Revision ID: package-import@ubuntu.com-20120418130436-vmt93p8fds516lws
Tags: 0.1.32
Fix failing tests on powerpc and ARM.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
YUI 3.5.0 (build 5089)
 
3
Copyright 2012 Yahoo! Inc. All rights reserved.
 
4
Licensed under the BSD License.
 
5
http://yuilibrary.com/license/
 
6
*/
 
7
YUI.add('node-load', function(Y) {
 
8
 
 
9
/**
 
10
 * Extended Node interface with a basic IO API.
 
11
 * @module node
 
12
 * @submodule node-load
 
13
 */
 
14
 
 
15
/**
 
16
 * The default IO complete handler.
 
17
 * @method _ioComplete
 
18
 * @protected
 
19
 * @for Node
 
20
 * @param {String} code The response code.
 
21
 * @param {Object} response The response object.
 
22
 * @param {Array} args An array containing the callback and selector
 
23
 */
 
24
 
 
25
Y.Node.prototype._ioComplete = function(code, response, args) {
 
26
    var selector = args[0],
 
27
        callback = args[1],
 
28
        tmp,
 
29
        content;
 
30
 
 
31
    if (response && response.responseText) {
 
32
        content = response.responseText;
 
33
        if (selector) {
 
34
            tmp = Y.DOM.create(content);
 
35
            content = Y.Selector.query(selector, tmp);
 
36
        }
 
37
        this.setContent(content);
 
38
    }
 
39
    if (callback) {
 
40
        callback.call(this, code, response);
 
41
    }
 
42
};
 
43
 
 
44
/**
 
45
 * Loads content from the given url and replaces the Node's
 
46
 * existing content with the remote content.
 
47
 * @method load
 
48
 * @param {String} url The URL to load via XMLHttpRequest.
 
49
 * @param {String} selector An optional selector representing a subset of an HTML document to load.
 
50
 * @param {Function} callback An optional function to run after the content has been loaded.
 
51
 * @chainable
 
52
 */
 
53
Y.Node.prototype.load = function(url, selector, callback) {
 
54
    if (typeof selector == 'function') {
 
55
        callback = selector;
 
56
        selector = null;
 
57
    }
 
58
    var config = {
 
59
        context: this,
 
60
        on: {
 
61
            complete: this._ioComplete
 
62
        },
 
63
        arguments: [selector, callback]
 
64
    };
 
65
 
 
66
    Y.io(url, config);
 
67
    return this;
 
68
}
 
69
 
 
70
 
 
71
}, '3.5.0' ,{requires:['node-base', 'io-base']});