src/cm/media/js/lib/yui/yui_3.10.3/build/querystring-stringify-simple/querystring-stringify-simple-debug.js
changeset 525 89ef5ed3c48b
equal deleted inserted replaced
524:322d0feea350 525:89ef5ed3c48b
       
     1 /*
       
     2 YUI 3.10.3 (build 2fb5187)
       
     3 Copyright 2013 Yahoo! Inc. All rights reserved.
       
     4 Licensed under the BSD License.
       
     5 http://yuilibrary.com/license/
       
     6 */
       
     7 
       
     8 YUI.add('querystring-stringify-simple', function (Y, NAME) {
       
     9 
       
    10 /*global Y */
       
    11 /**
       
    12  * <p>Provides Y.QueryString.stringify method for converting objects to Query Strings.
       
    13  * This is a subset implementation of the full querystring-stringify.</p>
       
    14  * <p>This module provides the bare minimum functionality (encoding a hash of simple values),
       
    15  * without the additional support for nested data structures.  Every key-value pair is
       
    16  * encoded by encodeURIComponent.</p>
       
    17  * <p>This module provides a minimalistic way for io to handle  single-level objects
       
    18  * as transaction data.</p>
       
    19  *
       
    20  * @module querystring
       
    21  * @submodule querystring-stringify-simple
       
    22  */
       
    23 
       
    24 var QueryString = Y.namespace("QueryString"),
       
    25     EUC = encodeURIComponent;
       
    26 
       
    27 
       
    28 QueryString.stringify = function (obj, c) {
       
    29     var qs = [],
       
    30         // Default behavior is false; standard key notation.
       
    31         s = c && c.arrayKey ? true : false,
       
    32         key, i, l;
       
    33 
       
    34     for (key in obj) {
       
    35         if (obj.hasOwnProperty(key)) {
       
    36             if (Y.Lang.isArray(obj[key])) {
       
    37                 for (i = 0, l = obj[key].length; i < l; i++) {
       
    38                     qs.push(EUC(s ? key + '[]' : key) + '=' + EUC(obj[key][i]));
       
    39                 }
       
    40             }
       
    41             else {
       
    42                 qs.push(EUC(key) + '=' + EUC(obj[key]));
       
    43             }
       
    44         }
       
    45     }
       
    46 
       
    47     return qs.join('&');
       
    48 };
       
    49 
       
    50 
       
    51 }, '3.10.3', {"requires": ["yui-base"]});