Project

General

Profile

1
$.fn.serializeObject = function () {
2
    var o = {};
3
    var a = this.serializeArray();
4
    $.each(a, function () {
5
        if (o[this.name] !== undefined) {
6
            if (!o[this.name].push) {
7
                o[this.name] = [o[this.name]];
8
            }
9
            o[this.name].push(this.value || '');
10
        } else {
11
            o[this.name] = this.value || '';
12
        }
13
    });
14
    return o;
15
};
16

    
17
/*
18
 Enhancement to $.unique, to work on non-domelements as well.
19
 From http://paulirish.com/2010/duck-punching-with-jquery/
20
 */
21
(function ($) {
22

    
23
    var _old = $.unique;
24

    
25
    $.unique = function (arr) {
26

    
27
        // do the default behavior only if we got an array of elements
28
        if (!!arr[0].nodeType) {
29
            return _old.apply(this, arguments);
30
        } else {
31
            // reduce the array to contain no dupes via grep/inArray
32
            return $.grep(arr, function (v, k) {
33
                return $.inArray(v, arr) === k;
34
            });
35
        }
36
    };
37
})(jQuery);
(6-6/12)