~ubuntu-branches/ubuntu/trusty/moodle/trusty-proposed

« back to all changes in this revision

Viewing changes to lib/yui/3.4.1/build/yql/yql-debug.js

  • Committer: Package Import Robot
  • Author(s): Thijs Kinkhorst
  • Date: 2013-07-19 08:52:46 UTC
  • mfrom: (1.1.10)
  • Revision ID: package-import@ubuntu.com-20130719085246-yebwditc2exoap2r
Tags: 2.5.1-1
* New upstream version: 2.5.1.
  - Fixes security issues:
    CVE-2013-2242 CVE-2013-2243 CVE-2013-2244 CVE-2013-2245
    CVE-2013-2246
* Depend on apache2 instead of obsolete apache2-mpm-prefork.
* Use packaged libphp-phpmailer (closes: #429339), adodb,
  HTMLPurifier, PclZip.
* Update debconf translations, thanks Salvatore Merone, Pietro Tollot,
  Joe Hansen, Yuri Kozlov, Holger Wansing, Américo Monteiro,
  Adriano Rafael Gomes, victory, Michał Kułach.
  (closes: #716972, #716986, #717080, #717108, #717278)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
YUI 3.4.1 (build 4118)
3
 
Copyright 2011 Yahoo! Inc. All rights reserved.
4
 
Licensed under the BSD License.
5
 
http://yuilibrary.com/license/
6
 
*/
7
 
YUI.add('yql', function(Y) {
8
 
 
9
 
    /**
10
 
     * This class adds a sugar class to allow access to YQL (http://developer.yahoo.com/yql/).
11
 
     * @module yql
12
 
     */     
13
 
    /**
14
 
     * Utility Class used under the hood my the YQL class
15
 
     * @class YQLRequest
16
 
     * @constructor
17
 
     * @param {String} sql The SQL statement to execute
18
 
     * @param {Function/Object} callback The callback to execute after the query (Falls through to JSONP).
19
 
     * @param {Object} params An object literal of extra parameters to pass along (optional).
20
 
     * @param {Object} opts An object literal of configuration options (optional): proto (http|https), base (url)
21
 
     */
22
 
    var YQLRequest = function (sql, callback, params, opts) {
23
 
        
24
 
        if (!params) {
25
 
            params = {};
26
 
        }
27
 
        params.q = sql;
28
 
        //Allow format override.. JSON-P-X
29
 
        if (!params.format) {
30
 
            params.format = Y.YQLRequest.FORMAT;
31
 
        }
32
 
        if (!params.env) {
33
 
            params.env = Y.YQLRequest.ENV;
34
 
        }
35
 
        
36
 
        this._params = params;
37
 
        this._opts = opts;
38
 
        this._callback = callback;
39
 
 
40
 
    };
41
 
    
42
 
    YQLRequest.prototype = {
43
 
        /**
44
 
        * @private
45
 
        * @property _jsonp
46
 
        * @description Reference to the JSONP instance used to make the queries
47
 
        */
48
 
        _jsonp: null,
49
 
        /**
50
 
        * @private
51
 
        * @property _opts
52
 
        * @description Holder for the opts argument
53
 
        */
54
 
        _opts: null,
55
 
        /**
56
 
        * @private
57
 
        * @property _callback
58
 
        * @description Holder for the callback argument
59
 
        */
60
 
        _callback: null,
61
 
        /**
62
 
        * @private
63
 
        * @property _params
64
 
        * @description Holder for the params argument
65
 
        */
66
 
        _params: null,
67
 
        /**
68
 
        * @method send
69
 
        * @description The method that executes the YQL Request.
70
 
        * @chainable
71
 
        * @returns {YQLRequest}
72
 
        */
73
 
        send: function() {
74
 
            var qs = [], url = ((this._opts && this._opts.proto) ? this._opts.proto : Y.YQLRequest.PROTO);
75
 
 
76
 
            Y.each(this._params, function(v, k) {
77
 
                qs.push(k + '=' + encodeURIComponent(v));
78
 
            });
79
 
 
80
 
            qs = qs.join('&');
81
 
            
82
 
            url += ((this._opts && this._opts.base) ? this._opts.base : Y.YQLRequest.BASE_URL) + qs;
83
 
            
84
 
            var o = (!Y.Lang.isFunction(this._callback)) ? this._callback : { on: { success: this._callback } };
85
 
            if (o.allowCache !== false) {
86
 
                o.allowCache = true;
87
 
            }
88
 
            Y.log('URL: ' + url, 'info', 'yql');
89
 
            
90
 
            if (!this._jsonp) {
91
 
                this._jsonp = Y.jsonp(url, o);
92
 
            } else {
93
 
                this._jsonp.url = url;
94
 
                if (o.on && o.on.success) {
95
 
                    this._jsonp._config.on.success = o.on.success;
96
 
                }
97
 
                this._jsonp.send();
98
 
            }
99
 
            return this;
100
 
        }
101
 
    };
102
 
 
103
 
    /**
104
 
    * @static
105
 
    * @property FORMAT
106
 
    * @description Default format to use: json
107
 
    */
108
 
    YQLRequest.FORMAT = 'json';
109
 
    /**
110
 
    * @static
111
 
    * @property PROTO
112
 
    * @description Default protocol to use: http
113
 
    */
114
 
    YQLRequest.PROTO = 'http';
115
 
    /**
116
 
    * @static
117
 
    * @property BASE_URL
118
 
    * @description The base URL to query: query.yahooapis.com/v1/public/yql?
119
 
    */
120
 
    YQLRequest.BASE_URL = ':/'+'/query.yahooapis.com/v1/public/yql?';
121
 
    /**
122
 
    * @static
123
 
    * @property ENV
124
 
    * @description The environment file to load: http://datatables.org/alltables.env
125
 
    */
126
 
    YQLRequest.ENV = 'http:/'+'/datatables.org/alltables.env';
127
 
    
128
 
    Y.YQLRequest = YQLRequest;
129
 
        
130
 
    /**
131
 
     * This class adds a sugar class to allow access to YQL (http://developer.yahoo.com/yql/).
132
 
     * @class YQL
133
 
     * @constructor
134
 
     * @param {String} sql The SQL statement to execute
135
 
     * @param {Function} callback The callback to execute after the query (optional).
136
 
     * @param {Object} params An object literal of extra parameters to pass along (optional).
137
 
     * @param {Object} opts An object literal of configuration options (optional): proto (http|https), base (url)
138
 
     */
139
 
        Y.YQL = function(sql, callback, params, opts) {
140
 
        return new Y.YQLRequest(sql, callback, params, opts).send();
141
 
    };
142
 
 
143
 
 
144
 
 
145
 
}, '3.4.1' ,{requires:['jsonp', 'jsonp-url']});