Revisions

gist: 201983 Download_button fork
public
Public Clone URL: git://gist.github.com/201983.git
Embed All Files: show embed
JavaScript #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* Make getters return full set if first arg === true */
$.each(
    [
        'html', 'val', 'text', 'width', 'height', 'scrollTop',
        'scrollLeft', 'hasClass', 'css', 'attr', 'offset',
        'position', 'outerHeight', 'outerWidth'
    ],
    function(){
        
        var _method = $.fn[this];
        
        if (!_method) {
            return true;
        }
        
        $.fn[this] = function() {
            
            var args = Array.prototype.slice.call(arguments);
            
            if (args.shift() === true) {
                return this.map(function(){
                    return _method.apply($(this), args);
                });
            }
            
            return _method.apply(this, arguments);
        
        };
        
    }
);