/* Тут будем переопределять методы jQuery */

//#region jQuery.browser - ported from kendo.web and modified
jQuery.uaMatch = function (ua) {
    ua = ua.toLowerCase();
    var browser = false, match = [],
                browserRxs = {
                    mobile: /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i,
                    edge: /(edge)[ \/]([\w.]+)/i,
                    msie: /(msie\s|trident.*? rv:)([\w.]+)/i,
                    opera: /(opera|opr)(?:.*version|)[ \/]([\w.]+)/i,
                    yandex: /(yabrowser)[ \/]([\w.]+)/i,
                    chrome: /(chrome)[ \/]([\w.]+)/i,
                    safari: /(webkit)[ \/]([\w.]+)/i,
                    mozilla: /(mozilla)(?:.*? rv:([\w.]+)|)/i
                };

    for (var agent in browserRxs) {
        if (browserRxs.hasOwnProperty(agent)) {
            match = ua.match(browserRxs[agent]);
            if (match) {
                browser = {};
                browser[agent] = true;
                browser.version = parseInt(match[2], 10);
                break;
            }
        }
    }
    return browser;
};

browser = jQuery.uaMatch(navigator.userAgent);

if (browser.chrome || browser.opera || browser.safari) {
    browser.webkit = true;
}

jQuery.browser = browser;
//#endregion

//#region trim
jQuery.fn.trim = function(str) {
    if (str)
        return str.replace(/(^\s*)|(\s*)$/g, '');
    return str;
};

String.prototype.trim = function () {
    return this.replace(/^\s+|\s+$/g, '');
};
//#endregion
