All Downloads are FREE. Search and download functionalities are using the official Maven repository.

static.swagger.lib.backbone-min.js Maven / Gradle / Ivy

There is a newer version: 3.7.33
Show newest version
// Backbone.js 1.1.2

(function (t, e) {
    if (typeof define === "function" && define.amd) {
        define(["underscore", "jquery", "exports"], function (i, r, s) {
            t.Backbone = e(t, s, i, r)
        })
    } else if (typeof exports !== "undefined") {
        var i = require("underscore");
        e(t, exports, i)
    } else {
        t.Backbone = e(t, {}, t._, t.jQuery || t.Zepto || t.ender || t.$)
    }
})(this, function (t, e, i, r) {
    var s = t.Backbone;
    var n = [];
    var a = n.push;
    var o = n.slice;
    var h = n.splice;
    e.VERSION = "1.1.2";
    e.$ = r;
    e.noConflict = function () {
        t.Backbone = s;
        return this
    };
    e.emulateHTTP = false;
    e.emulateJSON = false;
    var u = e.Events = {
        on: function (t, e, i) {
            if (!c(this, "on", t, [e, i]) || !e)return this;
            this._events || (this._events = {});
            var r = this._events[t] || (this._events[t] = []);
            r.push({callback: e, context: i, ctx: i || this});
            return this
        }, once: function (t, e, r) {
            if (!c(this, "once", t, [e, r]) || !e)return this;
            var s = this;
            var n = i.once(function () {
                s.off(t, n);
                e.apply(this, arguments)
            });
            n._callback = e;
            return this.on(t, n, r)
        }, off: function (t, e, r) {
            var s, n, a, o, h, u, l, f;
            if (!this._events || !c(this, "off", t, [e, r]))return this;
            if (!t && !e && !r) {
                this._events = void 0;
                return this
            }
            o = t ? [t] : i.keys(this._events);
            for (h = 0, u = o.length; h < u; h++) {
                t = o[h];
                if (a = this._events[t]) {
                    this._events[t] = s = [];
                    if (e || r) {
                        for (l = 0, f = a.length; l < f; l++) {
                            n = a[l];
                            if (e && e !== n.callback && e !== n.callback._callback || r && r !== n.context) {
                                s.push(n)
                            }
                        }
                    }
                    if (!s.length)delete this._events[t]
                }
            }
            return this
        }, trigger: function (t) {
            if (!this._events)return this;
            var e = o.call(arguments, 1);
            if (!c(this, "trigger", t, e))return this;
            var i = this._events[t];
            var r = this._events.all;
            if (i)f(i, e);
            if (r)f(r, arguments);
            return this
        }, stopListening: function (t, e, r) {
            var s = this._listeningTo;
            if (!s)return this;
            var n = !e && !r;
            if (!r && typeof e === "object")r = this;
            if (t)(s = {})[t._listenId] = t;
            for (var a in s) {
                t = s[a];
                t.off(e, r, this);
                if (n || i.isEmpty(t._events))delete this._listeningTo[a]
            }
            return this
        }
    };
    var l = /\s+/;
    var c = function (t, e, i, r) {
        if (!i)return true;
        if (typeof i === "object") {
            for (var s in i) {
                t[e].apply(t, [s, i[s]].concat(r))
            }
            return false
        }
        if (l.test(i)) {
            var n = i.split(l);
            for (var a = 0, o = n.length; a < o; a++) {
                t[e].apply(t, [n[a]].concat(r))
            }
            return false
        }
        return true
    };
    var f = function (t, e) {
        var i, r = -1, s = t.length, n = e[0], a = e[1], o = e[2];
        switch (e.length) {
            case 0:
                while (++r < s)(i = t[r]).callback.call(i.ctx);
                return;
            case 1:
                while (++r < s)(i = t[r]).callback.call(i.ctx, n);
                return;
            case 2:
                while (++r < s)(i = t[r]).callback.call(i.ctx, n, a);
                return;
            case 3:
                while (++r < s)(i = t[r]).callback.call(i.ctx, n, a, o);
                return;
            default:
                while (++r < s)(i = t[r]).callback.apply(i.ctx, e);
                return
        }
    };
    var d = {listenTo: "on", listenToOnce: "once"};
    i.each(d, function (t, e) {
        u[e] = function (e, r, s) {
            var n = this._listeningTo || (this._listeningTo = {});
            var a = e._listenId || (e._listenId = i.uniqueId("l"));
            n[a] = e;
            if (!s && typeof r === "object")s = this;
            e[t](r, s, this);
            return this
        }
    });
    u.bind = u.on;
    u.unbind = u.off;
    i.extend(e, u);
    var p = e.Model = function (t, e) {
        var r = t || {};
        e || (e = {});
        this.cid = i.uniqueId("c");
        this.attributes = {};
        if (e.collection)this.collection = e.collection;
        if (e.parse)r = this.parse(r, e) || {};
        r = i.defaults({}, r, i.result(this, "defaults"));
        this.set(r, e);
        this.changed = {};
        this.initialize.apply(this, arguments)
    };
    i.extend(p.prototype, u, {
        changed: null, validationError: null, idAttribute: "id", initialize: function () {
        }, toJSON: function (t) {
            return i.clone(this.attributes)
        }, sync: function () {
            return e.sync.apply(this, arguments)
        }, get: function (t) {
            return this.attributes[t]
        }, escape: function (t) {
            return i.escape(this.get(t))
        }, has: function (t) {
            return this.get(t) != null
        }, set: function (t, e, r) {
            var s, n, a, o, h, u, l, c;
            if (t == null)return this;
            if (typeof t === "object") {
                n = t;
                r = e
            } else {
                (n = {})[t] = e
            }
            r || (r = {});
            if (!this._validate(n, r))return false;
            a = r.unset;
            h = r.silent;
            o = [];
            u = this._changing;
            this._changing = true;
            if (!u) {
                this._previousAttributes = i.clone(this.attributes);
                this.changed = {}
            }
            c = this.attributes, l = this._previousAttributes;
            if (this.idAttribute in n)this.id = n[this.idAttribute];
            for (s in n) {
                e = n[s];
                if (!i.isEqual(c[s], e))o.push(s);
                if (!i.isEqual(l[s], e)) {
                    this.changed[s] = e
                } else {
                    delete this.changed[s]
                }
                a ? delete c[s] : c[s] = e
            }
            if (!h) {
                if (o.length)this._pending = r;
                for (var f = 0, d = o.length; f < d; f++) {
                    this.trigger("change:" + o[f], this, c[o[f]], r)
                }
            }
            if (u)return this;
            if (!h) {
                while (this._pending) {
                    r = this._pending;
                    this._pending = false;
                    this.trigger("change", this, r)
                }
            }
            this._pending = false;
            this._changing = false;
            return this
        }, unset: function (t, e) {
            return this.set(t, void 0, i.extend({}, e, {unset: true}))
        }, clear: function (t) {
            var e = {};
            for (var r in this.attributes)e[r] = void 0;
            return this.set(e, i.extend({}, t, {unset: true}))
        }, hasChanged: function (t) {
            if (t == null)return !i.isEmpty(this.changed);
            return i.has(this.changed, t)
        }, changedAttributes: function (t) {
            if (!t)return this.hasChanged() ? i.clone(this.changed) : false;
            var e, r = false;
            var s = this._changing ? this._previousAttributes : this.attributes;
            for (var n in t) {
                if (i.isEqual(s[n], e = t[n]))continue;
                (r || (r = {}))[n] = e
            }
            return r
        }, previous: function (t) {
            if (t == null || !this._previousAttributes)return null;
            return this._previousAttributes[t]
        }, previousAttributes: function () {
            return i.clone(this._previousAttributes)
        }, fetch: function (t) {
            t = t ? i.clone(t) : {};
            if (t.parse === void 0)t.parse = true;
            var e = this;
            var r = t.success;
            t.success = function (i) {
                if (!e.set(e.parse(i, t), t))return false;
                if (r)r(e, i, t);
                e.trigger("sync", e, i, t)
            };
            q(this, t);
            return this.sync("read", this, t)
        }, save: function (t, e, r) {
            var s, n, a, o = this.attributes;
            if (t == null || typeof t === "object") {
                s = t;
                r = e
            } else {
                (s = {})[t] = e
            }
            r = i.extend({validate: true}, r);
            if (s && !r.wait) {
                if (!this.set(s, r))return false
            } else {
                if (!this._validate(s, r))return false
            }
            if (s && r.wait) {
                this.attributes = i.extend({}, o, s)
            }
            if (r.parse === void 0)r.parse = true;
            var h = this;
            var u = r.success;
            r.success = function (t) {
                h.attributes = o;
                var e = h.parse(t, r);
                if (r.wait)e = i.extend(s || {}, e);
                if (i.isObject(e) && !h.set(e, r)) {
                    return false
                }
                if (u)u(h, t, r);
                h.trigger("sync", h, t, r)
            };
            q(this, r);
            n = this.isNew() ? "create" : r.patch ? "patch" : "update";
            if (n === "patch")r.attrs = s;
            a = this.sync(n, this, r);
            if (s && r.wait)this.attributes = o;
            return a
        }, destroy: function (t) {
            t = t ? i.clone(t) : {};
            var e = this;
            var r = t.success;
            var s = function () {
                e.trigger("destroy", e, e.collection, t)
            };
            t.success = function (i) {
                if (t.wait || e.isNew())s();
                if (r)r(e, i, t);
                if (!e.isNew())e.trigger("sync", e, i, t)
            };
            if (this.isNew()) {
                t.success();
                return false
            }
            q(this, t);
            var n = this.sync("delete", this, t);
            if (!t.wait)s();
            return n
        }, url: function () {
            var t = i.result(this, "urlRoot") || i.result(this.collection, "url") || M();
            if (this.isNew())return t;
            return t.replace(/([^\/])$/, "$1/") + encodeURIComponent(this.id)
        }, parse: function (t, e) {
            return t
        }, clone: function () {
            return new this.constructor(this.attributes)
        }, isNew: function () {
            return !this.has(this.idAttribute)
        }, isValid: function (t) {
            return this._validate({}, i.extend(t || {}, {validate: true}))
        }, _validate: function (t, e) {
            if (!e.validate || !this.validate)return true;
            t = i.extend({}, this.attributes, t);
            var r = this.validationError = this.validate(t, e) || null;
            if (!r)return true;
            this.trigger("invalid", this, r, i.extend(e, {validationError: r}));
            return false
        }
    });
    var v = ["keys", "values", "pairs", "invert", "pick", "omit"];
    i.each(v, function (t) {
        p.prototype[t] = function () {
            var e = o.call(arguments);
            e.unshift(this.attributes);
            return i[t].apply(i, e)
        }
    });
    var g = e.Collection = function (t, e) {
        e || (e = {});
        if (e.model)this.model = e.model;
        if (e.comparator !== void 0)this.comparator = e.comparator;
        this._reset();
        this.initialize.apply(this, arguments);
        if (t)this.reset(t, i.extend({silent: true}, e))
    };
    var m = {add: true, remove: true, merge: true};
    var y = {add: true, remove: false};
    i.extend(g.prototype, u, {
        model: p, initialize: function () {
        }, toJSON: function (t) {
            return this.map(function (e) {
                return e.toJSON(t)
            })
        }, sync: function () {
            return e.sync.apply(this, arguments)
        }, add: function (t, e) {
            return this.set(t, i.extend({merge: false}, e, y))
        }, remove: function (t, e) {
            var r = !i.isArray(t);
            t = r ? [t] : i.clone(t);
            e || (e = {});
            var s, n, a, o;
            for (s = 0, n = t.length; s < n; s++) {
                o = t[s] = this.get(t[s]);
                if (!o)continue;
                delete this._byId[o.id];
                delete this._byId[o.cid];
                a = this.indexOf(o);
                this.models.splice(a, 1);
                this.length--;
                if (!e.silent) {
                    e.index = a;
                    o.trigger("remove", o, this, e)
                }
                this._removeReference(o, e)
            }
            return r ? t[0] : t
        }, set: function (t, e) {
            e = i.defaults({}, e, m);
            if (e.parse)t = this.parse(t, e);
            var r = !i.isArray(t);
            t = r ? t ? [t] : [] : i.clone(t);
            var s, n, a, o, h, u, l;
            var c = e.at;
            var f = this.model;
            var d = this.comparator && c == null && e.sort !== false;
            var v = i.isString(this.comparator) ? this.comparator : null;
            var g = [], y = [], _ = {};
            var b = e.add, w = e.merge, x = e.remove;
            var E = !d && b && x ? [] : false;
            for (s = 0, n = t.length; s < n; s++) {
                h = t[s] || {};
                if (h instanceof p) {
                    a = o = h
                } else {
                    a = h[f.prototype.idAttribute || "id"]
                }
                if (u = this.get(a)) {
                    if (x)_[u.cid] = true;
                    if (w) {
                        h = h === o ? o.attributes : h;
                        if (e.parse)h = u.parse(h, e);
                        u.set(h, e);
                        if (d && !l && u.hasChanged(v))l = true
                    }
                    t[s] = u
                } else if (b) {
                    o = t[s] = this._prepareModel(h, e);
                    if (!o)continue;
                    g.push(o);
                    this._addReference(o, e)
                }
                o = u || o;
                if (E && (o.isNew() || !_[o.id]))E.push(o);
                _[o.id] = true
            }
            if (x) {
                for (s = 0, n = this.length; s < n; ++s) {
                    if (!_[(o = this.models[s]).cid])y.push(o)
                }
                if (y.length)this.remove(y, e)
            }
            if (g.length || E && E.length) {
                if (d)l = true;
                this.length += g.length;
                if (c != null) {
                    for (s = 0, n = g.length; s < n; s++) {
                        this.models.splice(c + s, 0, g[s])
                    }
                } else {
                    if (E)this.models.length = 0;
                    var k = E || g;
                    for (s = 0, n = k.length; s < n; s++) {
                        this.models.push(k[s])
                    }
                }
            }
            if (l)this.sort({silent: true});
            if (!e.silent) {
                for (s = 0, n = g.length; s < n; s++) {
                    (o = g[s]).trigger("add", o, this, e)
                }
                if (l || E && E.length)this.trigger("sort", this, e)
            }
            return r ? t[0] : t
        }, reset: function (t, e) {
            e || (e = {});
            for (var r = 0, s = this.models.length; r < s; r++) {
                this._removeReference(this.models[r], e)
            }
            e.previousModels = this.models;
            this._reset();
            t = this.add(t, i.extend({silent: true}, e));
            if (!e.silent)this.trigger("reset", this, e);
            return t
        }, push: function (t, e) {
            return this.add(t, i.extend({at: this.length}, e))
        }, pop: function (t) {
            var e = this.at(this.length - 1);
            this.remove(e, t);
            return e
        }, unshift: function (t, e) {
            return this.add(t, i.extend({at: 0}, e))
        }, shift: function (t) {
            var e = this.at(0);
            this.remove(e, t);
            return e
        }, slice: function () {
            return o.apply(this.models, arguments)
        }, get: function (t) {
            if (t == null)return void 0;
            return this._byId[t] || this._byId[t.id] || this._byId[t.cid]
        }, at: function (t) {
            return this.models[t]
        }, where: function (t, e) {
            if (i.isEmpty(t))return e ? void 0 : [];
            return this[e ? "find" : "filter"](function (e) {
                for (var i in t) {
                    if (t[i] !== e.get(i))return false
                }
                return true
            })
        }, findWhere: function (t) {
            return this.where(t, true)
        }, sort: function (t) {
            if (!this.comparator)throw new Error("Cannot sort a set without a comparator");
            t || (t = {});
            if (i.isString(this.comparator) || this.comparator.length === 1) {
                this.models = this.sortBy(this.comparator, this)
            } else {
                this.models.sort(i.bind(this.comparator, this))
            }
            if (!t.silent)this.trigger("sort", this, t);
            return this
        }, pluck: function (t) {
            return i.invoke(this.models, "get", t)
        }, fetch: function (t) {
            t = t ? i.clone(t) : {};
            if (t.parse === void 0)t.parse = true;
            var e = t.success;
            var r = this;
            t.success = function (i) {
                var s = t.reset ? "reset" : "set";
                r[s](i, t);
                if (e)e(r, i, t);
                r.trigger("sync", r, i, t)
            };
            q(this, t);
            return this.sync("read", this, t)
        }, create: function (t, e) {
            e = e ? i.clone(e) : {};
            if (!(t = this._prepareModel(t, e)))return false;
            if (!e.wait)this.add(t, e);
            var r = this;
            var s = e.success;
            e.success = function (t, i) {
                if (e.wait)r.add(t, e);
                if (s)s(t, i, e)
            };
            t.save(null, e);
            return t
        }, parse: function (t, e) {
            return t
        }, clone: function () {
            return new this.constructor(this.models)
        }, _reset: function () {
            this.length = 0;
            this.models = [];
            this._byId = {}
        }, _prepareModel: function (t, e) {
            if (t instanceof p)return t;
            e = e ? i.clone(e) : {};
            e.collection = this;
            var r = new this.model(t, e);
            if (!r.validationError)return r;
            this.trigger("invalid", this, r.validationError, e);
            return false
        }, _addReference: function (t, e) {
            this._byId[t.cid] = t;
            if (t.id != null)this._byId[t.id] = t;
            if (!t.collection)t.collection = this;
            t.on("all", this._onModelEvent, this)
        }, _removeReference: function (t, e) {
            if (this === t.collection)delete t.collection;
            t.off("all", this._onModelEvent, this)
        }, _onModelEvent: function (t, e, i, r) {
            if ((t === "add" || t === "remove") && i !== this)return;
            if (t === "destroy")this.remove(e, r);
            if (e && t === "change:" + e.idAttribute) {
                delete this._byId[e.previous(e.idAttribute)];
                if (e.id != null)this._byId[e.id] = e
            }
            this.trigger.apply(this, arguments)
        }
    });
    var _ = ["forEach", "each", "map", "collect", "reduce", "foldl", "inject", "reduceRight", "foldr", "find", "detect", "filter", "select", "reject", "every", "all", "some", "any", "include", "contains", "invoke", "max", "min", "toArray", "size", "first", "head", "take", "initial", "rest", "tail", "drop", "last", "without", "difference", "indexOf", "shuffle", "lastIndexOf", "isEmpty", "chain", "sample"];
    i.each(_, function (t) {
        g.prototype[t] = function () {
            var e = o.call(arguments);
            e.unshift(this.models);
            return i[t].apply(i, e)
        }
    });
    var b = ["groupBy", "countBy", "sortBy", "indexBy"];
    i.each(b, function (t) {
        g.prototype[t] = function (e, r) {
            var s = i.isFunction(e) ? e : function (t) {
                return t.get(e)
            };
            return i[t](this.models, s, r)
        }
    });
    var w = e.View = function (t) {
        this.cid = i.uniqueId("view");
        t || (t = {});
        i.extend(this, i.pick(t, E));
        this._ensureElement();
        this.initialize.apply(this, arguments);
        this.delegateEvents()
    };
    var x = /^(\S+)\s*(.*)$/;
    var E = ["model", "collection", "el", "id", "attributes", "className", "tagName", "events"];
    i.extend(w.prototype, u, {
        tagName: "div", $: function (t) {
            return this.$el.find(t)
        }, initialize: function () {
        }, render: function () {
            return this
        }, remove: function () {
            this.$el.remove();
            this.stopListening();
            return this
        }, setElement: function (t, i) {
            if (this.$el)this.undelegateEvents();
            this.$el = t instanceof e.$ ? t : e.$(t);
            this.el = this.$el[0];
            if (i !== false)this.delegateEvents();
            return this
        }, delegateEvents: function (t) {
            if (!(t || (t = i.result(this, "events"))))return this;
            this.undelegateEvents();
            for (var e in t) {
                var r = t[e];
                if (!i.isFunction(r))r = this[t[e]];
                if (!r)continue;
                var s = e.match(x);
                var n = s[1], a = s[2];
                r = i.bind(r, this);
                n += ".delegateEvents" + this.cid;
                if (a === "") {
                    this.$el.on(n, r)
                } else {
                    this.$el.on(n, a, r)
                }
            }
            return this
        }, undelegateEvents: function () {
            this.$el.off(".delegateEvents" + this.cid);
            return this
        }, _ensureElement: function () {
            if (!this.el) {
                var t = i.extend({}, i.result(this, "attributes"));
                if (this.id)t.id = i.result(this, "id");
                if (this.className)t["class"] = i.result(this, "className");
                var r = e.$("<" + i.result(this, "tagName") + ">").attr(t);
                this.setElement(r, false)
            } else {
                this.setElement(i.result(this, "el"), false)
            }
        }
    });
    e.sync = function (t, r, s) {
        var n = T[t];
        i.defaults(s || (s = {}), {emulateHTTP: e.emulateHTTP, emulateJSON: e.emulateJSON});
        var a = {type: n, dataType: "json"};
        if (!s.url) {
            a.url = i.result(r, "url") || M()
        }
        if (s.data == null && r && (t === "create" || t === "update" || t === "patch")) {
            a.contentType = "application/json";
            a.data = JSON.stringify(s.attrs || r.toJSON(s))
        }
        if (s.emulateJSON) {
            a.contentType = "application/x-www-form-urlencoded";
            a.data = a.data ? {model: a.data} : {}
        }
        if (s.emulateHTTP && (n === "PUT" || n === "DELETE" || n === "PATCH")) {
            a.type = "POST";
            if (s.emulateJSON)a.data._method = n;
            var o = s.beforeSend;
            s.beforeSend = function (t) {
                t.setRequestHeader("X-HTTP-Method-Override", n);
                if (o)return o.apply(this, arguments)
            }
        }
        if (a.type !== "GET" && !s.emulateJSON) {
            a.processData = false
        }
        if (a.type === "PATCH" && k) {
            a.xhr = function () {
                return new ActiveXObject("Microsoft.XMLHTTP")
            }
        }
        var h = s.xhr = e.ajax(i.extend(a, s));
        r.trigger("request", r, h, s);
        return h
    };
    var k = typeof window !== "undefined" && !!window.ActiveXObject && !(window.XMLHttpRequest && (new XMLHttpRequest).dispatchEvent);
    var T = {create: "POST", update: "PUT", patch: "PATCH", "delete": "DELETE", read: "GET"};
    e.ajax = function () {
        return e.$.ajax.apply(e.$, arguments)
    };
    var $ = e.Router = function (t) {
        t || (t = {});
        if (t.routes)this.routes = t.routes;
        this._bindRoutes();
        this.initialize.apply(this, arguments)
    };
    var S = /\((.*?)\)/g;
    var H = /(\(\?)?:\w+/g;
    var A = /\*\w+/g;
    var I = /[\-{}\[\]+?.,\\\^$|#\s]/g;
    i.extend($.prototype, u, {
        initialize: function () {
        }, route: function (t, r, s) {
            if (!i.isRegExp(t))t = this._routeToRegExp(t);
            if (i.isFunction(r)) {
                s = r;
                r = ""
            }
            if (!s)s = this[r];
            var n = this;
            e.history.route(t, function (i) {
                var a = n._extractParameters(t, i);
                n.execute(s, a);
                n.trigger.apply(n, ["route:" + r].concat(a));
                n.trigger("route", r, a);
                e.history.trigger("route", n, r, a)
            });
            return this
        }, execute: function (t, e) {
            if (t)t.apply(this, e)
        }, navigate: function (t, i) {
            e.history.navigate(t, i);
            return this
        }, _bindRoutes: function () {
            if (!this.routes)return;
            this.routes = i.result(this, "routes");
            var t, e = i.keys(this.routes);
            while ((t = e.pop()) != null) {
                this.route(t, this.routes[t])
            }
        }, _routeToRegExp: function (t) {
            t = t.replace(I, "\\$&").replace(S, "(?:$1)?").replace(H, function (t, e) {
                return e ? t : "([^/?]+)"
            }).replace(A, "([^?]*?)");
            return new RegExp("^" + t + "(?:\\?([\\s\\S]*))?$")
        }, _extractParameters: function (t, e) {
            var r = t.exec(e).slice(1);
            return i.map(r, function (t, e) {
                if (e === r.length - 1)return t || null;
                return t ? decodeURIComponent(t) : null
            })
        }
    });
    var N = e.History = function () {
        this.handlers = [];
        i.bindAll(this, "checkUrl");
        if (typeof window !== "undefined") {
            this.location = window.location;
            this.history = window.history
        }
    };
    var R = /^[#\/]|\s+$/g;
    var O = /^\/+|\/+$/g;
    var P = /msie [\w.]+/;
    var C = /\/$/;
    var j = /#.*$/;
    N.started = false;
    i.extend(N.prototype, u, {
        interval: 50, atRoot: function () {
            return this.location.pathname.replace(/[^\/]$/, "$&/") === this.root
        }, getHash: function (t) {
            var e = (t || this).location.href.match(/#(.*)$/);
            return e ? e[1] : ""
        }, getFragment: function (t, e) {
            if (t == null) {
                if (this._hasPushState || !this._wantsHashChange || e) {
                    t = decodeURI(this.location.pathname + this.location.search);
                    var i = this.root.replace(C, "");
                    if (!t.indexOf(i))t = t.slice(i.length)
                } else {
                    t = this.getHash()
                }
            }
            return t.replace(R, "")
        }, start: function (t) {
            if (N.started)throw new Error("Backbone.history has already been started");
            N.started = true;
            this.options = i.extend({root: "/"}, this.options, t);
            this.root = this.options.root;
            this._wantsHashChange = this.options.hashChange !== false;
            this._wantsPushState = !!this.options.pushState;
            this._hasPushState = !!(this.options.pushState && this.history && this.history.pushState);
            var r = this.getFragment();
            var s = document.documentMode;
            var n = P.exec(navigator.userAgent.toLowerCase()) && (!s || s <= 7);
            this.root = ("/" + this.root + "/").replace(O, "/");
            if (n && this._wantsHashChange) {
                var a = e.$('