~canonical-sysadmins/wordpress/4.7.4

« back to all changes in this revision

Viewing changes to wp-includes/js/jquery/jquery.serialize-object.js

  • Committer: Jacek Nykis
  • Date: 2015-01-05 16:17:05 UTC
  • Revision ID: jacek.nykis@canonical.com-20150105161705-w544l1h5mcg7u4w9
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*!
 
2
 * jQuery serializeObject - v0.2 - 1/20/2010
 
3
 * http://benalman.com/projects/jquery-misc-plugins/
 
4
 * 
 
5
 * Copyright (c) 2010 "Cowboy" Ben Alman
 
6
 * Dual licensed under the MIT and GPL licenses.
 
7
 * http://benalman.com/about/license/
 
8
 */
 
9
 
 
10
// Whereas .serializeArray() serializes a form into an array, .serializeObject()
 
11
// serializes a form into an (arguably more useful) object.
 
12
 
 
13
(function($,undefined){
 
14
  '$:nomunge'; // Used by YUI compressor.
 
15
  
 
16
  $.fn.serializeObject = function(){
 
17
    var obj = {};
 
18
    
 
19
    $.each( this.serializeArray(), function(i,o){
 
20
      var n = o.name,
 
21
        v = o.value;
 
22
        
 
23
        obj[n] = obj[n] === undefined ? v
 
24
          : $.isArray( obj[n] ) ? obj[n].concat( v )
 
25
          : [ obj[n], v ];
 
26
    });
 
27
    
 
28
    return obj;
 
29
  };
 
30
  
 
31
})(jQuery);