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

assets.js.GroupdocsViewer.all.min.js Maven / Gradle / Ivy

Go to download

GroupDocs.Viewer is an online document viewer that lets you read documents in your browser, regardless of whether you have the software that they were created in. You can view many types to word processing documents (DOC, DOCX, TXT, RTF, ODT), presentations (PPT, PPTX), spreadsheets (XLS, XLSX), portable files (PDF), and image files (JPG, BMP, GIF, TIFF). For each file, you get a high-fidelity rendering, showing the document just as it would if you opened it in the software it was created in. Layout and formatting is retained and you see an exact copy of the original. GroupDocs.Viewer lets you really read the document. You can search text documents, copy text and even embed the document РІР‚ GroupDocs.Viewer and all - in a web page. You can print or download the file from GroupDocs.Viewer if you need to work with it offline.

There is a newer version: 17.5.0
Show newest version
if (!window.jGroupdocs)window.jGroupdocs = {}; window.jGroupdocs.stringExtensions = { format: function (c) { var b = c, a = arguments.length; while (--a)b = b.replace(new RegExp("\\{" + (a - 1) + "\\}", "gm"), arguments[a]); return b }, trim: function (b, a) { var c = new RegExp("^[" + a + "]+|[" + a + "]+$", "g"); return b.replace(c, "") }, trimStart: function (a, b) { var c = new RegExp("^[" + b + "]+", "g"); return a.replace(c, "") }, trimEnd: function (a, b) { var c = new RegExp("[" + b + "]+$", "g"); return a.replace(c, "") }, getAccentInsensitiveRegexFromString: function (f) { for (var b = [["A", "ÀÁÂÃÄÅÆ"], ["C", "Ç"], ["E", "ÈÉÊËÆ"], ["I", "ÌÍÎÏ"], ["N", "Ñ"], ["O", "ÒÓÔÕÖØ"], ["S", "ß"], ["U", "ÙÚÛÜ"], ["Y", "Ÿ"], ["У", "Ў"], ["a", "àáâãäåæ"], ["c", "ç"], ["e", "èéêëæ"], ["i", "ìíîï"], ["n", "ñ"], ["o", "òóôõöø"], ["s", "ß"], ["u", "ùúûü"], ["y", "ÿ"], ["у", "ў"]], c = "", a = 0; a < b.length; a++)c += b[a][0]; var d = new RegExp("[" + c + "]", "g"); function e(c) { return c.replace(d, function (d) { var c = null; for (a = 0; a < b.length; a++)if (b[a][0] == d) { c = b[a][1]; break } if (c === null)c = ""; return "[" + d + c + "]" }) } return e(f) }, _padWithLeadingZeros: function (a) { return (new Array(5 - a.length)).join("0") + a }, _unicodeCharEscape: function (a) { return "\\u" + this._padWithLeadingZeros(a.toString(16)) }, unicodeEscape: function (a) { var b = this; return a.split("").map(function (a) { var c = a.charCodeAt(0); return c > 127 ? b._unicodeCharEscape(c) : a }).join("") } }; window.jGroupdocs.http = { splitUrl: function () { var a = new RegExp("(\\w+)://([^/]+)([^?]*)([?].+)?"); return function (e) { var b = e.match(a), d = b.length > 3 ? b[3] : null, c = b.length > 4 ? b[4] : null; return { schema: b[1], authority: b.length > 2 ? b[2] : null, path: d, query: c, queryDict: $.fn.q(c), pathAndQuery: c ? d + c : d } } }() }; JsInject = { Container: function () { this.serviceEntries = []; this.disposables = [] } }; JsInject.Container.prototype.Resolve = function (a, c, b, d, e, f, g, h, i, j) { return this.ResolveInternal(a, !0, c, b, d, e, f, g, h, i, j) }; JsInject.Container.prototype.TryResolve = function (a, c, b, d, e, f, g, h, i, j) { return this.ResolveInternal(a, !1, c, b, d, e, f, g, h, i, j) }; JsInject.Container.prototype.RegisterInternal = function (a, c, b, d) { if (this.RegisteredInternal(a))throw"Factory with name '" + a + "' alredy registered"; this.serviceEntries[a] = {factory: c, scope: b, owner: d, instance: null} }; JsInject.Container.prototype.Dispose = function () { for (var a in this.disposables)this.disposables[a].Dispose() }; JsInject.Container.prototype.ResolveInternal = function (a, k, b, c, d, e, f, g, h, i, j) { if (!this.RegisteredInternal(a))if (k)throw"Factory with name '" + a + "' is not registered"; else return null; a = this.serviceEntries[a]; if (a.scope === "container") { if (a.instance === null)a.instance = this.CreateInstanceInternal(a.factory, a.owner, b, c, d, e, f, g, h, i, j); return a.instance } return this.CreateInstanceInternal(a.factory, a.owner, b, c, d, e, f, g, h, i, j) }; JsInject.Container.prototype.CreateInstanceInternal = function (a, c, b, d, e, f, g, h, i, j, k) { a = a(this, b, d, e, f, g, h, i, j, k); c === "container" && typeof a.Dispose === "function" && this.disposables.push(a); return a }; JsInject.Container.prototype.RegisteredInternal = function (a) { return this.serviceEntries[a] !== void 0 }; JsInject.Registration = function (a, b) { this.name = a; this.factory = b; this.scope = "none"; this.owner = "consumer" }; JsInject.Registration.prototype.Reused = function () { this.scope = "container"; this.Owned(); return this }; JsInject.Registration.prototype.Owned = function () { this.owner = "container"; return this }; JsInject.ContainerBuilder = function () { this.registrations = [] }; JsInject.ContainerBuilder.prototype.Register = function (b, c) { var a = new JsInject.Registration(b, c); this.registrations.push(a); return a }; JsInject.ContainerBuilder.prototype.Create = function () { var b = new JsInject.Container, c; for (c in this.registrations) { var a = this.registrations[c]; b.RegisterInternal(a.name, a.factory, a.scope, a.owner) } return b }; JsInject.Container.prototype.Register = function (a, c, b) { a = new JsInject.Registration(a, c); b && a.Reused(); this.RegisterInternal(a.name, a.factory, a.scope, a.owner) }; if (!window.jSaaspose)window.jSaaspose = {}; if (!window.Container) { window.Container = new JsInject.Container; Container.Register("Cacher", function () { return $.jCacher }, true); Container.Register("Rx.Observable", function () { return Rx.Observable }, true); Container.Register("RequestObservable", function () { return $.ajaxAsObservable }, true); Container.Register("AsyncSubject", function () { return new Rx.AsyncSubject }, false); var host = window.location.hostname + (window.location.port ? ":" + window.location.port : ""), applicationPath = $.ui.groupdocsViewer.prototype.applicationPath; if (applicationPath == "/") { applicationPath = window.location.protocol + "//" + host + "/"; $.ui.groupdocsViewer.prototype.applicationPath = applicationPath } if (applicationPath != "/") { var slashPosition = applicationPath.indexOf("//"); if (slashPosition == -1) { var newApplicationPath = window.location.protocol + "//" + host + (applicationPath ? applicationPath : window.location.pathname); $.ui.groupdocsViewer.prototype.applicationPath = newApplicationPath } var hostNamePosition = slashPosition + 2; if (applicationPath.indexOf(host, hostNamePosition) != hostNamePosition)$.ui.groupdocsViewer.prototype.isWorkingCrossDomain = true } Container.Register("PortalService", function () { return new jSaaspose.PortalService($.ui.groupdocsViewer.prototype.applicationPath, $.ui.groupdocsViewer.prototype.useHttpHandlers, $.ui.groupdocsViewer.prototype.isWorkingCrossDomain) }, true); Container.Register("HttpProvider", function () { return { buildUrl: function (d, b, c) { var a = jGroupdocs.stringExtensions.trimEnd(d, "/"); if (b && b.length > 0)a += "/" + jGroupdocs.stringExtensions.trimStart(b, "/"); if (c)a += (a.indexOf("&") != -1 || a.indexOf("?") != -1 ? "&" : "?") + jQuery.param(c); return a }, signUrl: function () { return "" } } }, true) } (function (a) { a.fn.ellipsis = function (c) { var b = document.documentElement.style; return !("textOverflow"in b || "OTextOverflow"in b) ? this.each(function () { var b = a(this); if (b.css("overflow") == "hidden") { var f = b.html(), h = b.width(), e = a(this.cloneNode(true)).hide().css({ position: "absolute", width: "auto", overflow: "visible", "max-width": "inherit" }); b.after(e); var d = f; while (d.length > 0 && e.width() > b.width()) { d = d.substr(0, d.length - 1); e.html(d + "...") } b.html(e.html()); e.remove(); if (c == true) { var g = b.width(); setInterval(function () { if (b.width() != g) { g = b.width(); b.html(f); b.ellipsis() } }, 200) } } }) : this } })(jQuery); (function (a) { a.fn.innerTip = function (b) { return this.each(function () { var c = a(this); c.focusin(function () { if (c.hasClass("empty")) { c.val(""); c.removeClass("empty") } }); c.focusout(function () { if (c.val() == "") { c.val(b.text); c.addClass("empty") } }); c.bind("reset", function () { c.val(b.text); c.addClass("empty") }); c.val(b.text); c.addClass("empty") }) } })(jQuery); (function (a) { var b = {classes: []}; a.fn.corners = function (c) { return this.each(function () { var d = a(this); if (a.inArray(c.id, b.classes) === -1) { b.classes.push(c.id); a("body").append('") } d.css({position: "relative"}); d.prepend('
'); d.append('
') }) } })(jQuery); (function (a) { a.fn.hitch = function (c, d, a, b) { return this.bind(c, b, function () { return d.apply(a || this, Array.prototype.slice.call(arguments)) }) } })(jQuery); (function (a) { a.fn.q = function (b) { var c = {}; if (b) { var b = b.replace(/^\?/, "").replace(/\&$/, ""); a.each(b.split("&"), function () { var b = this.split("=")[0], a = this.split("=")[1]; if (/^[0-9.]+$/.test(a))a = parseFloat(a); if (a)c[b] = a }) } return c } })(jQuery); (function (a) { var c = function (a) { a.preventDefault() }, b = function (a) { a.click(c); a.is("input[type='submit'],input[type='button']") && a.attr("disabled", "disabled") }, d = function (d, e, f) { var c = d.data("clone"); if (!c) { c = d.clone(false); a.each(c[0].attributes, function (b, a) { a != null && a.name != "class" && c.attr(a.name, "") }); e != "" && c.addClass(e); b(c); d.data("clone", c); d.after(c) } c.attr("title", f); d.hide(); c.show() }, e = function (b) { var a = b.data("clone"); if (a) { b.show(); a.hide() } }; a.fn.activator = function (b) { return this.each(function () { var c = a(this); if (b.action == "enable") { e(c); return } b.action == "disable" && d(c, b.cl, b.tip) }) }; a.fn.isEnable = function () { var c = a(this), b = c.data("clone"); return b && b.is(":visible") ? false : true } })(jQuery); var ZeroClipboard = { version: "1.0.7", clients: {}, moviePath: "ZeroClipboard.swf", nextId: 1, $: function (a) { if (typeof a == "string")a = document.getElementById(a); if (!a.addClass) { a.hide = function () { this.style.display = "none" }; a.show = function () { this.style.display = "" }; a.addClass = function (a) { this.removeClass(a); this.className += " " + a }; a.removeClass = function (d) { for (var a = this.className.split(/\s+/), c = -1, b = 0; b < a.length; b++)if (a[b] == d) { c = b; b = a.length } if (c > -1) { a.splice(c, 1); this.className = a.join(" ") } return this }; a.hasClass = function (a) { return !!this.className.match(new RegExp("\\s*" + a + "\\s*")) } } return a }, setMoviePath: function (a) { this.moviePath = a }, dispatch: function (d, b, c) { var a = this.clients[d]; a && a.receiveEvent(b, c) }, register: function (b, a) { this.clients[b] = a }, getDOMObjectPosition: function (a) { return {left: 0, top: 0, width: a.width ? a.width : a.offsetWidth, height: a.height ? a.height : a.offsetHeight} }, Client: function (a) { this.handlers = {}; this.id = ZeroClipboard.nextId++; this.movieId = "ZeroClipboardMovie_" + this.id; ZeroClipboard.register(this.id, this); a && this.glue(a) } }; ZeroClipboard.Client.prototype = { id: 0, ready: false, movie: null, clipText: "", handCursorEnabled: true, cssEffects: true, handlers: null, glue: function (f, a, d) { this.domElement = ZeroClipboard.$(f); var e = 99; if (this.domElement.style.zIndex)e = parseInt(this.domElement.style.zIndex, 10) + 1; if (typeof a == "string")a = ZeroClipboard.$(a); else if (typeof a == "undefined")a = document.getElementsByTagName("body")[0]; var c = ZeroClipboard.getDOMObjectPosition(this.domElement, a); this.div = document.createElement("div"); var b = this.div.style; b.position = "absolute"; b.left = "" + c.left + "px"; b.top = "" + c.top + "px"; b.width = "" + c.width + "px"; b.height = "" + c.height * 2 + "px"; b.zIndex = e; if (typeof d == "object")for (addedStyle in d)b[addedStyle] = d[addedStyle]; a.appendChild(this.div); this.div.innerHTML = this.getHTML(c.width, c.height) }, getHTML: function (b, a) { var c = "", d = "id=" + this.id + "&width=" + b + "&height=" + a; if (navigator.userAgent.match(/MSIE/)) { var e = location.href.match(/^https/i) ? "https://" : "http://"; c += '' } else c += ''; return c }, hide: function () { if (this.div)this.div.style.left = "-2000px" }, show: function () { this.reposition() }, destroy: function () { if (this.domElement && this.div) { this.hide(); this.div.innerHTML = ""; var a = document.getElementsByTagName("body")[0]; try { a.removeChild(this.div) } catch (b) { } this.domElement = null; this.div = null } }, reposition: function (b) { if (b) { this.domElement = ZeroClipboard.$(b); !this.domElement && this.hide() } if (this.domElement && this.div) { var c = ZeroClipboard.getDOMObjectPosition(this.domElement), a = this.div.style; a.left = "" + c.left + "px"; a.top = "" + c.top + "px" } }, setText: function (a) { this.clipText = a; this.ready && this.movie.setText(a) }, addEventListener: function (a, b) { a = a.toString().toLowerCase().replace(/^on/, ""); if (!this.handlers[a])this.handlers[a] = []; this.handlers[a].push(b) }, setHandCursor: function (a) { this.handCursorEnabled = a; this.ready && this.movie.setHandCursor(a) }, setCSSEffects: function (a) { this.cssEffects = !!a }, receiveEvent: function (b, c) { b = b.toString().toLowerCase().replace(/^on/, ""); switch (b) { case"load": this.movie = document.getElementById(this.movieId); if (!this.movie) { var e = this; setTimeout(function () { e.receiveEvent("load", null) }, 1); return } if (!this.ready && navigator.userAgent.match(/Firefox/) && navigator.userAgent.match(/Windows/)) { var e = this; setTimeout(function () { e.receiveEvent("load", null) }, 100); this.ready = true; return } this.ready = true; this.movie.setText(this.clipText); this.movie.setHandCursor(this.handCursorEnabled); break; case"mouseover": if (this.domElement && this.cssEffects) { this.domElement.addClass("hover"); this.recoverActive && this.domElement.addClass("active") } break; case"mouseout": if (this.domElement && this.cssEffects) { this.recoverActive = false; if (this.domElement.hasClass("active")) { this.domElement.removeClass("active"); this.recoverActive = true } this.domElement.removeClass("hover") } break; case"mousedown": this.domElement && this.cssEffects && this.domElement.addClass("active"); break; case"mouseup": if (this.domElement && this.cssEffects) { this.domElement.removeClass("active"); this.recoverActive = false } } if (this.handlers[b])for (var d = 0, f = this.handlers[b].length; d < f; d++) { var a = this.handlers[b][d]; if (typeof a == "function")a(this, c); else if (typeof a == "object" && a.length == 2)a[0][a[1]](this, c); else typeof a == "string" && window[a](this, c) } } }; (function (a, b) { a.jCacher = new function () { var f = this, o = a(this); f.version = "1.0.0"; f.count = 0; var h, i, c, g = new e(false), l = function (b, a) { return new Date(b.getTime() + a) }, k = function (a, h) { var c = g.getCacheItem(a); if (a !== null && a !== b && c !== null) { f.count--; var e = g.getDependencyMappings(a); g.removeCacheItem(a); p(c, h); for (var d = 0; d < e.length; d++)k(e[d], "dependencyChanged") } return c !== b }, n = function () { for (var e = new Date, c = g.getCacheItems(), b = false, a = 0; a < c.length; a++) { var d = c[a]; if (d.expires <= e) { b = true; k(d.key, "expired") } } b && j() }, j = function (d) { if (d === b) { c = null; i = null; h && clearTimeout(h); for (var f = g.getCacheItems(), e = 0; e < f.length; e++) { var a = f[e]; if (c) { if (a.expires < c) { c = a.expires; i = a.key } } else { c = a.expires; i = a.key } } if (c)m(); else h = null } else if (c == b || c && d.expires < c) { h && clearTimeout(h); c = d.expires; m() } }, m = function () { if (c) { var b = new Date, a = c.getTime() - b.getTime() + 100; if (a > 0)h = setTimeout(n, a); else n() } }, p = function (b, a) { o.trigger("itemremoved", [b, a]) }; f.itemremoved = function (a) { o.bind("itemremoved", a) }; f.add = function (k, o, h, m, n) { if (o !== b) { if (a.inArray(k, g.getCacheKeys()) == -1)f.count++; var e; if (h || m)if (h)e = l(new Date, h * 1e3); else if (m)e = m; n && g.registerDependencies(k, n); var p = new d(k, o, e, h); g.addCacheItem(p); (e && (c === b || e < c) || (i == k || c === null)) && j(p) } }; f.get = function (b) { var a = g.getCacheItem(b); if (a) { var d = new Date; if (a.slidingExpiration) { a.expires = l(d, a.slidingExpiration * 1e3); if (b == i || c && a.expires < c)j(); else var e = true } return a.expires && a.expires < d ? null : a } return null }; f.remove = function (a) { if (a !== b && a !== null && a !== NaN && f.count > 0) { return k(a, "removed"); i == a && j() } }; f.clear = function () { if (f.count > 0) { f.count = 0; g.clear(); if (h !== null) { clearTimeout(h); h = null } } }; g.getCacheItems().length > 0 && j() }; function d(d, c, b, a) { this.key = d; this.value = c; this.expires = b; this.slidingExpiration = a } function c(b, a) { this.key = b; this.mappings = a } function e(f) { var d = [], b = [], e = []; (function () { if (f && window.localStorage) { if (!window.localStorage.jCacher)window.localStorage.jCacher = jQuery.toJSON({ items: [], dependencyMappings: [] }); else { for (var c = jQuery.parseJSON(window.localStorage.jCacher), a = 0; a < c.items.length; a++) { var g = c.items[a]; g.expires = new Date(g.expires); d.push(g) } e = c.dependencyMappings } for (var a = 0; a < d.length; a++)b.push(d[a].key) } })(); this.getCacheItem = function (e) { var c = a.inArray(e, b); return c > -1 ? d[c] : null }; this.getCacheItems = function () { return d }; this.removeCacheItem = function (h) { var c = a.inArray(h, b); if (f && window.localStorage) { var g = jQuery.parseJSON(window.localStorage.jCacher); g.dependencyMappings.splice(c, 1); g.items.splice(c, 1); window.localStorage.jCacher = jQuery.toJSON(g) } d.splice(c, 1); b.splice(c, 1); e.splice(c, 1) }; this.addCacheItem = function (g) { var i = a.inArray(g.key, b); if (i == -1) { var j = new c(g.key, []); d.push(g); b.push(g.key); e.push(j); if (f && window.localStorage) { var h = jQuery.parseJSON(window.localStorage.jCacher), k = function () { var a = {}; a.expires = g.expires.getTime(); a.key = g.key; a.value = g.value; a.slidingExpiration = g.slidingExpiration; return a }(); h.items.push(k); h.dependencyMappings.push(j); window.localStorage.jCacher = jQuery.toJSON(h) } } else { d[i] = g; if (f && window.localStorage) { var h = jQuery.parseJSON(window.localStorage.jCacher); h.items[i] = g; window.localStorage.jCacher = jQuery.toJSON(h) } } }; this.getCacheKeys = function () { return b }; this.registerDependencies = function (d, h) { for (var g = 0; g < h.length; g++) { var c = a.inArray(h[g], b); if (c != -1)if (a.inArray(d, e[c].mappings) == -1) { e[c].mappings.push(d); if (f && window.localStorage) { var i = jQuery.parseJSON(window.localStorage.jCacher); i.dependencyMappings[c].mappings.push(d); window.localStorage.jCacher = jQuery.toJSON(i) } } } }; this.getDependencyMappings = function (d) { var c = a.inArray(d, b); return c > -1 ? e[c].mappings : null }; this.clear = function () { window.localStorage && window.localStorage.removeItem("jCacher"); d = []; e = []; b = [] } } })(jQuery); ko.exportSymbol = function (d, e) { for (var a = d.split("."), c = window, b = 0; b < a.length - 1; b++)c = c[a[b]]; c[a[a.length - 1]] = e }; ko.exportProperty = function (a, c, b) { a[c] = b }; (function () { function n(c, b) { for (var a in b)b.hasOwnProperty(a) && b[a] && (c[a] && !(c[a]instanceof Array) ? n(c[a], b[a]) : (c[a] = b[a])) } function p(b, c) { var a = {}; n(a, b); n(a, c); return a } function c(a) { return a && typeof a === "object" && a.constructor == (new Date).constructor ? "date" : typeof a } function o(b, c) { b = b || {}; if (b.create instanceof Function || b.update instanceof Function || b.key instanceof Function || b.arrayChanged instanceof Function)b = {"": b}; if (c)b.ignore = d(c.ignore, b.ignore), b.include = d(c.include, b.include), b.copy = d(c.copy, b.copy); b.ignore = d(b.ignore, a.ignore); b.include = d(b.include, a.include); b.copy = d(b.copy, a.copy); b.mappedProperties = b.mappedProperties || {}; return b } function d(a, b) { a instanceof Array || (a = c(a) === "undefined" ? [] : [a]); b instanceof Array || (b = c(b) === "undefined" ? [] : [b]); return a.concat(b) } function u(a, c) { var b = ko.dependentObservable; ko.dependentObservable = function (b, e, c) { var c = c || {}, g = c.deferEvaluation; b && typeof b == "object" && (c = b); var d = !1, f = function (b) { var c = h({ read: function () { d || (ko.utils.arrayRemoveItem(a, b), d = !0); return b.apply(b, arguments) }, write: function (a) { return b(a) }, deferEvaluation: !0 }); c.__ko_proto__ = h; return c }; c.deferEvaluation = !0; b = new h(b, e, c); b.__ko_proto__ = h; g || (a.push(b), b = f(b)); return b }; var d = c(); ko.dependentObservable = b; return d } function j(a, d, h, m, F, A) { var E = ko.utils.unwrapObservable(d)instanceof Array, A = A || ""; if (ko.mapping.isMapped(a))var y = ko.utils.unwrapObservable(a)[b], h = p(y, h); var D = function () { return h[m] && h[m].create instanceof Function }, C = function (a) { return u(k, function () { return h[m].create({data: a || d, parent: F}) }) }, t = function () { return h[m] && h[m].update instanceof Function }, o = function (a, c) { var b = {data: c || d, parent: F, target: ko.utils.unwrapObservable(a)}; if (ko.isWriteableObservable(a))b.observable = a; return h[m].update(b) }; if (f.get(d))return a; m = m || ""; if (E) { var E = [], y = !1, i = function (a) { return a }; if (h[m] && h[m].key)i = h[m].key, y = !0; if (!ko.isObservable(a))a = ko.observableArray([]), a.mappedRemove = function (b) { var c = typeof b == "function" ? b : function (a) { return a === i(b) }; return a.remove(function (a) { return c(i(a)) }) }, a.mappedRemoveAll = function (b) { var c = e(b, i); return a.remove(function (a) { return ko.utils.arrayIndexOf(c, i(a)) != -1 }) }, a.mappedDestroy = function (b) { var c = typeof b == "function" ? b : function (a) { return a === i(b) }; return a.destroy(function (a) { return c(i(a)) }) }, a.mappedDestroyAll = function (b) { var c = e(b, i); return a.destroy(function (a) { return ko.utils.arrayIndexOf(c, i(a)) != -1 }) }, a.mappedIndexOf = function (b) { var c = e(a(), i), b = i(b); return ko.utils.arrayIndexOf(c, b) }, a.mappedCreate = function (b) { if (a.mappedIndexOf(b) !== -1)throw Error("There already is an object with the key that you specified."); var c = D() ? C(b) : b; t() && (b = o(c, b), ko.isWriteableObservable(c) ? c(b) : (c = b)); a.push(c); return c }; var n = e(ko.utils.unwrapObservable(a), i).sort(), x = e(d, i); y && x.sort(); for (var y = ko.utils.compareArrays(n, x), n = {}, x = [], B = 0, G = y.length; B < G; B++) { var w = y[B], v, s = A + "[" + B + "]"; switch (w.status) { case"added": var z = g(ko.utils.unwrapObservable(d), w.value, i); v = ko.utils.unwrapObservable(j(void 0, z, h, m, a, s)); s = q(ko.utils.unwrapObservable(d), z, n); x[s] = v; n[s] = !0; break; case"retained": z = g(ko.utils.unwrapObservable(d), w.value, i); v = g(a, w.value, i); j(v, z, h, m, a, s); s = q(ko.utils.unwrapObservable(d), z, n); x[s] = v; n[s] = !0; break; case"deleted": v = g(a, w.value, i) } E.push({event: w.status, item: v}) } a(x); h[m] && h[m].arrayChanged && ko.utils.arrayForEach(E, function (a) { h[m].arrayChanged(a.event, a.item) }) } else if (l(d)) { a = ko.utils.unwrapObservable(a); if (!a)if (D())return n = C(), t() && (n = o(n)), n; else { if (t())return o(n); a = {} } t() && (a = o(a)); f.save(d, a); r(d, function (b) { var c = A.length ? A + "." + b : b; if (ko.utils.arrayIndexOf(h.ignore, c) == -1)if (ko.utils.arrayIndexOf(h.copy, c) != -1)a[b] = d[b]; else { var e = f.get(d[b]) || j(a[b], d[b], h, b, a, c); if (ko.isWriteableObservable(a[b]))a[b](ko.utils.unwrapObservable(e)); else a[b] = e; h.mappedProperties[c] = !0 } }) } else switch (c(d)) { case"function": t() ? ko.isWriteableObservable(d) ? (d(o(d)), a = d) : (a = o(d)) : (a = d); break; default: ko.isWriteableObservable(a) ? t() ? a(o(a)) : a(ko.utils.unwrapObservable(d)) : (a = D() ? C() : ko.observable(ko.utils.unwrapObservable(d)), t() && a(o(a))) } return a } function q(b, d, c) { for (var a = 0, e = b.length; a < e; a++)if (c[a] !== !0 && b[a] === d)return a; return null } function s(b, d) { var a; d && (a = d(b)); c(a) === "undefined" && (a = b); return ko.utils.unwrapObservable(a) } function g(a, b, c) { a = ko.utils.arrayFilter(ko.utils.unwrapObservable(a), function (a) { return s(a, c) === b }); if (a.length == 0)throw Error("When calling ko.update*, the key '" + b + "' was not found!"); if (a.length > 1 && l(a[0]))throw Error("When calling ko.update*, the key '" + b + "' was not unique!"); return a[0] } function e(b, a) { return ko.utils.arrayMap(ko.utils.unwrapObservable(b), function (b) { return a ? s(b, a) : b }) } function r(b, c) { if (b instanceof Array)for (var a = 0; a < b.length; a++)c(a); else for (a in b)c(a) } function l(a) { var b = c(a); return b === "object" && a !== null && b !== "undefined" } function t() { var a = [], b = []; this.save = function (c, d) { var e = ko.utils.arrayIndexOf(a, c); e >= 0 ? (b[e] = d) : (a.push(c), b.push(d)) }; this.get = function (c) { c = ko.utils.arrayIndexOf(a, c); if (c >= 0)return b[c] } } ko.mapping = {}; var b = "__ko_mapping__", h = ko.dependentObservable, m = 0, k, f, i = { include: ["_destroy"], ignore: [], copy: [] }, a = i; ko.mapping.isMapped = function (a) { return (a = ko.utils.unwrapObservable(a)) && a[b] }; ko.mapping.fromJS = function (e) { if (arguments.length == 0)throw Error("When calling ko.fromJS, pass the object you want to convert."); window.setTimeout(function () { m = 0 }, 0); m++ || (k = [], f = new t); var a, c; arguments.length == 2 && (arguments[1][b] ? (c = arguments[1]) : (a = arguments[1])); arguments.length == 3 && (a = arguments[1], c = arguments[2]); c && (a = p(a, c[b])); a = o(a); var d = j(c, e, a); c && (d = c); --m || window.setTimeout(function () { ko.utils.arrayForEach(k, function (a) { a && a() }) }, 0); d[b] = p(d[b], a); return d }; ko.mapping.fromJSON = function (a) { var b = ko.utils.parseJson(a); arguments[0] = b; return ko.mapping.fromJS.apply(this, arguments) }; ko.mapping.updateFromJS = function () { throw Error("ko.mapping.updateFromJS, use ko.mapping.fromJS instead. Please note that the order of parameters is different!"); }; ko.mapping.updateFromJSON = function () { throw Error("ko.mapping.updateFromJSON, use ko.mapping.fromJSON instead. Please note that the order of parameters is different!"); }; ko.mapping.toJS = function (d, c) { a || ko.mapping.resetDefaultOptions(); if (arguments.length == 0)throw Error("When calling ko.mapping.toJS, pass the object you want to convert."); if (!(a.ignore instanceof Array))throw Error("ko.mapping.defaultOptions().ignore should be an array."); if (!(a.include instanceof Array))throw Error("ko.mapping.defaultOptions().include should be an array."); if (!(a.copy instanceof Array))throw Error("ko.mapping.defaultOptions().copy should be an array."); c = o(c, d[b]); return ko.mapping.visitModel(d, function (a) { return ko.utils.unwrapObservable(a) }, c) }; ko.mapping.toJSON = function (a, c) { var b = ko.mapping.toJS(a, c); return ko.utils.stringifyJson(b) }; ko.mapping.defaultOptions = function () { if (arguments.length > 0)a = arguments[0]; else return a }; ko.mapping.resetDefaultOptions = function () { a = {include: i.include.slice(0), ignore: i.ignore.slice(0), copy: i.copy.slice(0)} }; ko.mapping.visitModel = function (f, g, a) { a = a || {}; a.visitedObjects = a.visitedObjects || new t; a.parentName || (a = o(a)); var e, d = ko.utils.unwrapObservable(f); if (l(d))g(f, a.parentName), e = d instanceof Array ? [] : {}; else return g(f, a.parentName); a.visitedObjects.save(f, e); var h = a.parentName; r(d, function (f) { if (!(a.ignore && ko.utils.arrayIndexOf(a.ignore, f) != -1)) { var i = d[f], j = a, k = h || ""; d instanceof Array ? h && (k += "[" + f + "]") : (h && (k += "."), k += f); j.parentName = k; if (!(ko.utils.arrayIndexOf(a.copy, f) === -1 && ko.utils.arrayIndexOf(a.include, f) === -1 && d[b] && d[b].mappedProperties && !d[b].mappedProperties[f] && !(d instanceof Array)))switch (c(ko.utils.unwrapObservable(i))) { case"object": case"undefined": j = a.visitedObjects.get(i); e[f] = c(j) !== "undefined" ? j : ko.mapping.visitModel(i, g, a); break; default: e[f] = g(i, a.parentName) } } }); return e }; ko.exportSymbol("ko.mapping", ko.mapping); ko.exportSymbol("ko.mapping.fromJS", ko.mapping.fromJS); ko.exportSymbol("ko.mapping.fromJSON", ko.mapping.fromJSON); ko.exportSymbol("ko.mapping.isMapped", ko.mapping.isMapped); ko.exportSymbol("ko.mapping.defaultOptions", ko.mapping.defaultOptions); ko.exportSymbol("ko.mapping.toJS", ko.mapping.toJS); ko.exportSymbol("ko.mapping.toJSON", ko.mapping.toJSON); ko.exportSymbol("ko.mapping.updateFromJS", ko.mapping.updateFromJS); ko.exportSymbol("ko.mapping.updateFromJSON", ko.mapping.updateFromJSON); ko.exportSymbol("ko.mapping.visitModel", ko.mapping.visitModel) })(); (function () { var a, h, t = this, y = "Index out of range"; if (typeof ProvideCustomRxRootObject == "undefined")h = t.Rx = {}; else h = ProvideCustomRxRootObject(); var u = function () { }, z = function () { return (new Date).getTime() }, A = function (a, b) { return a === b }, x = function (a) { return a }, n = function (a) { return {Dispose: a} }, o = {Dispose: u}; h.Disposable = {Create: n, Empty: o}; var H = h.BooleanDisposable = function () { var a = false; this.GetIsDisposed = function () { return a }; this.Dispose = function () { a = true } }, S = function (a) { var b = false; a.a++; this.Dispose = function () { var b = false; if (!a.b)if (!this.c) { this.c = true; a.a--; if (a.a == 0 && a.d) { a.b = true; b = true } } b && a.e.Dispose() } }, T = h.RefCountDisposable = function (a) { this.d = false; this.b = false; this.e = a; this.a = 0; this.Dispose = function () { var a = false; if (!this.b)if (!this.d) { this.d = true; if (this.a == 0) { this.b = true; a = true } } a && this.e.Dispose() }; this.GetDisposable = function () { return this.b ? o : new S(this) } }, d = h.CompositeDisposable = function () { for (var a = new r, c = 0; c < arguments.length; c++)a.Add(arguments[c]); var b = false; this.GetCount = function () { return a.GetCount() }; this.Add = function (c) { if (!b)a.Add(c); else c.Dispose() }; this.Remove = function (c, d) { if (!b) { var e = a.Remove(c); !d & e && c.Dispose() } }; this.Dispose = function () { if (!b) { b = true; this.Clear() } }; this.Clear = function () { for (var b = 0; b < a.GetCount(); b++)a.GetItem(b).Dispose(); a.Clear() } }, e = h.MutableDisposable = function () { var c = false, b; this.Get = function () { return b }, this.Replace = function (d) { if (c && d !== a)d.Dispose(); else { b !== a && b.Dispose(); b = d } }; this.Dispose = function () { if (!c) { c = true; b !== a && b.Dispose() } } }, J = function (b) { for (var c = [], a = 0; a < b.length; a++)c.push(b[a]); return c }, r = h.List = function (d) { var c = [], b = 0, e = d !== a ? d : A; this.Add = function (a) { c[b] = a; b++ }; this.RemoveAt = function (a) { if (a < 0 || a >= b)throw y; if (a == 0) { c.shift(); b-- } else { c.splice(a, 1); b-- } }; this.IndexOf = function (d) { for (var a = 0; a < b; a++)if (e(d, c[a]))return a; return -1 }; this.Remove = function (b) { var a = this.IndexOf(b); if (a == -1)return false; this.RemoveAt(a); return true }; this.Clear = function () { c = []; b = 0 }; this.GetCount = function () { return b }; this.GetItem = function (a) { if (a < 0 || a >= b)throw y; return c[a] }; this.SetItem = function (a, d) { if (a < 0 || a >= b)throw y; c[a] = d }; this.ToArray = function () { for (var b = [], a = 0; a < this.GetCount(); a++)b.push(this.GetItem(a)); return b } }, k = function (a) { if (a === null)a = A; this.f = a; var b = 4; this.g = new Array(b); this.h = 0 }; k.prototype.i = function (a, b) { return this.f(this.g[a], this.g[b]) < 0 }; k.prototype.j = function (a) { if (a >= this.h || a < 0)return; var b = a - 1 >> 1; if (b < 0 || b == a)return; if (this.i(a, b)) { var c = this.g[a]; this.g[a] = this.g[b]; this.g[b] = c; this.j(b) } }; k.prototype.k = function (b) { if (b === a)b = 0; var d = 2 * b + 1, e = 2 * b + 2, c = b; if (d < this.h && this.i(d, c))c = d; if (e < this.h && this.i(e, c))c = e; if (c != b) { var f = this.g[b]; this.g[b] = this.g[c]; this.g[c] = f; this.k(c) } }; k.prototype.GetCount = function () { return this.h }; k.prototype.Peek = function () { if (this.h == 0)throw"Heap is empty."; return this.g[0] }; k.prototype.Dequeue = function () { var a = this.Peek(); this.g[0] = this.g[--this.h]; delete this.g[this.h]; this.k(); return a }; k.prototype.Enqueue = function (b) { var a = this.h++; this.g[a] = b; this.j(a) }; var s = h.Scheduler = function (a, b, c) { this.Schedule = a; this.ScheduleWithTime = b; this.Now = c; this.ScheduleRecursive = function (e) { var c = this, a = new d, b; b = function () { e(function () { var e = false, f = false, d; d = c.Schedule(function () { b(); if (e)a.Remove(d); else f = true }); if (!f) { a.Add(d); e = true } }) }; a.Add(c.Schedule(b)); return a }; this.ScheduleRecursiveWithTime = function (e, f) { var c = this, a = new d, b; b = function () { e(function (g) { var e = false, f = false, d; d = c.ScheduleWithTime(function () { b(); if (e)a.Remove(d); else f = true }, g); if (!f) { a.Add(d); e = true } }) }; a.Add(c.ScheduleWithTime(b, f)); return a } }, X = h.VirtualScheduler = function (b, c, d, e) { var a = new s(function (a) { return this.ScheduleWithTime(a, 0) }, function (a, b) { return this.ScheduleVirtual(a, e(b)) }, function () { return d(this.l) }); a.ScheduleVirtual = function (e, f) { var a = new H, g = c(this.l, f), b = function () { !a.IsDisposed && e() }, d = new L(b, g); this.m.Enqueue(d); return a }; a.Run = function () { while (this.m.GetCount() > 0) { var a = this.m.Dequeue(); this.l = a.n; a.o() } }; a.RunTo = function (b) { while (this.m.GetCount() > 0 && this.f(this.m.Peek().n, b) <= 0) { var a = this.m.Dequeue(); this.l = a.n; a.o() } }; a.GetTicks = function () { return this.l }; a.l = 0; a.m = new k(function (a, c) { return b(a.n, c.n) }); a.f = b; return a }, ob = h.TestScheduler = function () { return new X(function (a, b) { return a - b }, function (a, b) { return a + b }, function (a) { return new Date(a) }, function (a) { return a <= 0 ? 1 : a }) }, j = new s(function (a) { return this.ScheduleWithTime(a, 0) }, function (d, e) { var f = this.Now() + e, b = new L(d, f); if (this.m === a) { var c = new K; try { this.m.Enqueue(b); c.p() } finally { c.q() } } else this.m.Enqueue(b); return b.r() }, z); j.s = function (b) { if (this.m === a) { var c = new K; try { b(); c.p() } finally { c.q() } } else b() }; s.CurrentThread = j; var K = function () { j.m = new k(function (a, b) { try { return a.n - b.n } catch (c) { } }); this.q = function () { j.m = a }; this.p = function () { while (j.m.GetCount() > 0) { var a = j.m.Dequeue(); if (!a.t()) { while (a.n - j.Now() > 0); !a.t() && a.o() } } } }, Z = 0, L = function (a, b) { this.u = Z++; this.o = a; this.n = b; this.v = new H; this.t = function () { return this.v.GetIsDisposed() }; this.r = function () { return this.v } }, f = new s(function (a) { a(); return o }, function (a, b) { while (this.Now < b); a() }, z); s.Immediate = f; var i = new s(function (a) { var b = t.setTimeout(a, 0); return n(function () { t.clearTimeout(b) }) }, function (a, b) { var c = t.setTimeout(a, b); return n(function () { t.clearTimeout(c) }) }, z); s.Timeout = i; var g = h.Observer = function (b, c, d) { this.OnNext = b === a ? u : b; this.OnError = c === a ? function (a) { throw a; } : c; this.OnCompleted = d === a ? u : d; this.AsObserver = function () { var a = this; return new g(function (b) { a.OnNext(b) }, function (b) { a.OnError(b) }, function () { a.OnCompleted() }) } }, ib = g.Create = function (a, b, c) { return new g(a, b, c) }, c = h.Observable = function (a) { this.w = a }, b = c.CreateWithDisposable = function (a) { return new c(a) }, E = c.Create = function (a) { return b(function (b) { return n(a(b)) }) }, F = function () { return this.Select(function (a) { return a.Value }) }; c.prototype = { Subscribe: function (a, c, d) { var b; if (arguments.length == 0 || arguments.length > 1 || typeof a == "function")b = new g(a, c, d); else b = a; return this.x(b) }, x: function (c) { var a = false, b = new e, f = this; j.s(function () { var d = new g(function (b) { !a && c.OnNext(b) }, function (d) { if (!a) { a = true; b.Dispose(); c.OnError(d) } }, function () { if (!a) { a = true; b.Dispose(); c.OnCompleted() } }); b.Replace(f.w(d)) }); return new d(b, n(function () { a = true })) }, Select: function (a) { var c = this; return b(function (b) { var d = 0; return c.Subscribe(new g(function (e) { var c; try { c = a(e, d++) } catch (f) { b.OnError(f); return } b.OnNext(c) }, function (a) { b.OnError(a) }, function () { b.OnCompleted() })) }) }, Let: function (c, f) { if (f === a)return c(this); var g = this; return b(function (a) { var h = f(), i; try { i = c(h) } catch (l) { return I(l).Subscribe(a) } var j = new e, k = new e, b = new d(k, j); j.Replace(i.Subscribe(function (b) { a.OnNext(b) }, function (c) { a.OnError(c); b.Dispose() }, function () { a.OnCompleted(); b.Dispose() })); k.Replace(g.Subscribe(h)); return b }) }, MergeObservable: function () { var a = this; return b(function (c) { var f = false, b = new d, g = new e; b.Add(g); g.Replace(a.Subscribe(function (d) { var a = new e; b.Add(a); a.Replace(d.Subscribe(function (a) { c.OnNext(a) }, function (a) { c.OnError(a) }, function () { b.Remove(a); b.GetCount() == 1 && f && c.OnCompleted() })) }, function (a) { c.OnError(a) }, function () { f = true; b.GetCount() == 1 && c.OnCompleted() })); return b }) }, y: function (b, c) { var a = J(c); a.unshift(this); return b(a) }, Concat: function () { return this.y(G, arguments) }, Merge: function () { return this.y(Q, arguments) }, Catch: function () { return this.y(V, arguments) }, OnErrorResumeNext: function () { return this.y(Y, arguments) }, Zip: function (e, c) { var f = this; return b(function (b) { var m = false, h = [], i = [], j = false, k = false, g = new d, l = function (c) { g.Dispose(); h = a; i = a; b.OnError(c) }; g.Add(f.Subscribe(function (a) { if (k) { b.OnCompleted(); return } if (i.length > 0) { var e = i.shift(), d; try { d = c(a, e) } catch (f) { g.Dispose(); b.OnError(f); return } b.OnNext(d) } else h.push(a) }, l, function () { if (k) { b.OnCompleted(); return } j = true })); g.Add(e.Subscribe(function (a) { if (j) { b.OnCompleted(); return } if (h.length > 0) { var e = h.shift(), d; try { d = c(e, a) } catch (f) { g.Dispose(); b.OnError(f); return } b.OnNext(d) } else i.push(a) }, l, function () { if (j) { b.OnCompleted(); return } k = true })); return g }) }, CombineLatest: function (c, a) { var e = this; return b(function (b) { var n = false, j = false, k = false, l, m, g = false, h = false, f = new d, i = function (a) { f.Dispose(); b.OnError(a) }; f.Add(e.Subscribe(function (c) { if (h) { b.OnCompleted(); return } if (k) { var d; try { d = a(c, m) } catch (e) { f.Dispose(); b.OnError(e); return } b.OnNext(d) } l = c; j = true }, i, function () { if (h) { b.OnCompleted(); return } g = true })); f.Add(c.Subscribe(function (c) { if (g) { b.OnCompleted(); return } if (j) { var d; try { d = a(l, c) } catch (e) { f.Dispose(); b.OnError(e); return } b.OnNext(d) } m = c; k = true }, i, function () { if (g) { b.OnCompleted(); return } h = true })) }) }, Switch: function () { var c = this; return b(function (f) { var g = false, b = new e, h = new e; h.Replace(c.Subscribe(function (d) { if (!g) { var c = new e; c.Replace(d.Subscribe(function (a) { f.OnNext(a) }, function (a) { h.Dispose(); b.Dispose(); f.OnError(a) }, function () { b.Replace(a); g && f.OnCompleted() })); b.Replace(c) } }, function (a) { b.Dispose(); f.OnError(a) }, function () { g = true; b.Get() === a && f.OnCompleted() })); return new d(h, b) }) }, TakeUntil: function (a) { var c = this; return b(function (e) { var b = new d; b.Add(a.Subscribe(function () { e.OnCompleted(); b.Dispose() }, function (a) { e.OnError(a) }, function () { })); b.Add(c.Subscribe(e)); return b }) }, SkipUntil: function (a) { var c = this; return b(function (b) { var e = true, f = new d; f.Add(a.Subscribe(function () { e = false }, function (a) { b.OnError(a) }, u)); f.Add(c.Subscribe(new g(function (a) { !e && b.OnNext(a) }, function (a) { b.OnError(a) }, function () { !e && b.OnCompleted() }))); return f }) }, Scan1: function (a) { var b = this; return q(function () { var c, d = false; return b.Select(function (b) { if (d)c = a(c, b); else { c = b; d = true } return c }) }) }, Scan: function (b, a) { var c = this; return q(function () { var d, e = false; return c.Select(function (c) { if (e)d = a(d, c); else { d = a(b, c); e = true } return d }) }) }, Scan0: function (a, c) { var d = this; return b(function (b) { var e = a, f = true; return d.Subscribe(function (a) { if (f) { f = false; b.OnNext(e) } try { e = c(e, a) } catch (d) { b.OnError(d); return } b.OnNext(e) }, function (a) { f && b.OnNext(e); b.OnError(a) }, function () { f && b.OnNext(e); b.OnCompleted() }) }) }, Finally: function (a) { var b = this; return E(function (c) { var d = b.Subscribe(c); return function () { try { d.Dispose(); a() } catch (b) { a(); throw b; } } }) }, Do: function (d, e, f) { var c; if (arguments.length == 0 || arguments.length > 1 || typeof d == "function")c = new g(d, e !== a ? e : u, f); else c = d; var h = this; return b(function (b) { return h.Subscribe(new g(function (a) { try { c.OnNext(a) } catch (d) { b.OnError(d); return } b.OnNext(a) }, function (d) { if (e !== a)try { c.OnError(d) } catch (f) { b.OnError(f); return } b.OnError(d) }, function () { if (f !== a)try { c.OnCompleted() } catch (d) { b.OnError(d); return } b.OnCompleted() })) }) }, Where: function (a) { var c = this; return b(function (b) { var d = 0; return c.Subscribe(new g(function (c) { var e = false; try { e = a(c, d++) } catch (f) { b.OnError(f); return } e && b.OnNext(c) }, function (a) { b.OnError(a) }, function () { b.OnCompleted() })) }) }, Take: function (d, c) { if (c === a)c = f; var e = this; return b(function (a) { if (d <= 0) { e.Subscribe().Dispose(); return B(c).Subscribe(a) } var b = d; return e.Subscribe(new g(function (c) { if (b-- > 0) { a.OnNext(c); b == 0 && a.OnCompleted() } }, function (b) { a.OnError(b) }, function () { a.OnCompleted() })) }) }, GroupBy: function (c, f, g) { if (c === a)c = x; if (f === a)f = x; if (g === a)g = function (a) { return a.toString() }; var h = this; return b(function (j) { var i = {}, k = new e, l = new T(k); k.Replace(h.Subscribe(function (r) { var h; try { h = c(r) } catch (s) { for (var n in i)i[n].OnError(s); j.OnError(s); return } var o = false, e; try { var k = g(h); if (i[k] === a) { e = new m; i[k] = e; o = true } else e = i[k] } catch (s) { for (var n in i)i[n].OnError(s); j.OnError(s); return } if (o) { var p = b(function (a) { return new d(l.GetDisposable(), e.Subscribe(a)) }); p.Key = h; j.OnNext(p) } var q; try { q = f(r) } catch (s) { for (var n in i)i[n].OnError(s); j.OnError(s); return } e.OnNext(q) }, function (a) { for (var b in i)i[b].OnError(a); j.OnError(a) }, function () { for (var a in i)i[a].OnCompleted(); j.OnCompleted() })); return l }) }, TakeWhile: function (a) { var c = this; return b(function (b) { var d = true; return c.Subscribe(new g(function (c) { if (d) { try { d = a(c) } catch (e) { b.OnError(e); return } if (d)b.OnNext(c); else b.OnCompleted() } }, function (a) { b.OnError(a) }, function () { b.OnCompleted() })) }) }, SkipWhile: function (a) { var c = this; return b(function (b) { var d = false; return c.Subscribe(new g(function (c) { if (!d)try { d = !a(c) } catch (e) { b.OnError(e); return } d && b.OnNext(c) }, function (a) { b.OnError(a) }, function () { b.OnCompleted() })) }) }, Skip: function (a) { var c = this; return b(function (b) { var d = a; return c.Subscribe(new g(function (a) { d-- <= 0 && b.OnNext(a) }, function (a) { b.OnError(a) }, function () { b.OnCompleted() })) }) }, SelectMany: function (a) { return this.Select(a).MergeObservable() }, TimeInterval: function (b) { if (b === a)b = f; var c = this; return q(function () { var a = b.Now(); return c.Select(function (d) { var c = b.Now(), e = c - a; a = c; return {Interval: e, Value: d} }) }) }, RemoveInterval: F, Timestamp: function (b) { if (b === a)b = f; return this.Select(function (a) { return {Timestamp: b.Now(), Value: a} }) }, RemoveTimestamp: F, Materialize: function () { var a = this; return b(function (b) { return a.Subscribe(new g(function (a) { b.OnNext(new l("N", a)) }, function (a) { b.OnNext(new l("E", a)); b.OnCompleted() }, function () { b.OnNext(new l("C")); b.OnCompleted() })) }) }, Dematerialize: function () { return this.SelectMany(function (a) { return a }) }, AsObservable: function () { var a = this; return b(function (b) { return a.Subscribe(b) }) }, Delay: function (f, c) { if (c === a)c = i; var g = this; return b(function (j) { var b = [], h = false, i = new e, k = g.Materialize().Timestamp().Subscribe(function (d) { if (d.Value.Kind == "E") { j.OnError(d.Value.Value); b = []; h && i.Dispose(); return } b.push({Timestamp: c.Now() + f, Value: d.Value}); if (!h) { i.Replace(c.ScheduleRecursiveWithTime(function (e) { var d; do { d = a; if (b.length > 0 && b[0].Timestamp <= c.Now())d = b.shift().Value; d !== a && d.Accept(j) } while (d !== a); if (b.length > 0) { e(Math.max(0, b[0].Timestamp - c.Now())); h = true } else h = false }, f)); h = true } }); return new d(k, i) }) }, Throttle: function (f, c) { if (c === a)c = i; var g = this; return b(function (h) { var j, a = false, i = new e, b = 0, k = g.Subscribe(function (d) { a = true; j = d; b++; var e = b; i.Replace(c.ScheduleWithTime(function () { a && b == e && h.OnNext(j); a = false }, f)) }, function (c) { i.Dispose(); h.OnError(c); a = false; b++ }, function () { i.Dispose(); a && h.OnNext(j); h.OnCompleted(); a = false; b++ }); return new d(k, i) }) }, Timeout: function (g, f, c) { if (c === a)c = i; if (f === a)f = I("Timeout", c); var h = this; return b(function (i) { var j = new e, k = new e, b = 0, l = b, a = false; k.Replace(c.ScheduleWithTime(function () { a = b == l; a && j.Replace(f.Subscribe(i)) }, g)); j.Replace(h.Subscribe(function (e) { var d = 0; if (!a) { b++; d = b; i.OnNext(e); k.Replace(c.ScheduleWithTime(function () { a = b == d; a && j.Replace(f.Subscribe(i)) }, g)) } }, function (c) { if (!a) { b++; i.OnError(c) } }, function () { if (!a) { b++; i.OnCompleted() } })); return new d(j, k) }) }, Sample: function (e, c) { if (c === a)c = i; var f = this; return b(function (a) { var g = false, h, i = false, b = new d; b.Add(ab(e, c).Subscribe(function () { if (g) { a.OnNext(h); g = false } i && a.OnCompleted() }, function (b) { a.OnError(b) }, function () { a.OnCompleted() })); b.Add(f.Subscribe(function (a) { g = true; h = a }, function (c) { a.OnError(c); b.Dispose() }, function () { i = true })); return b }) }, Repeat: function (c, g) { var h = this; if (g === a)g = f; if (c === a)c = -1; return b(function (a) { var b = c, f = new e, i = new d(f), j = function (c) { f.Replace(h.Subscribe(function (b) { a.OnNext(b) }, function (b) { a.OnError(b) }, function () { if (b > 0) { b--; if (b == 0) { a.OnCompleted(); return } } c() })) }; i.Add(g.ScheduleRecursive(j)); return i }) }, Retry: function (c, g) { var h = this; if (g === a)g = f; if (c === a)c = -1; return b(function (a) { var b = c, f = new e, i = new d(f), j = function (c) { f.Replace(h.Subscribe(function (b) { a.OnNext(b) }, function (d) { if (b > 0) { b--; if (b == 0) { a.OnError(d); return } } c() }, function () { a.OnCompleted() })) }; i.Add(g.ScheduleRecursive(j)); return i }) }, BufferWithTime: function (f, e, c) { if (c === a)c = i; if (e === a)e = f; var g = this; return b(function (b) { var a = new r, k = c.Now(), l = function () { for (var c = [], b = 0; b < a.GetCount(); b++) { var d = a.GetItem(b); d.Timestamp - k >= 0 && c.push(d.Value) } return c }, h = new d, i = function (a) { b.OnError(a) }, j = function () { b.OnNext(l()); b.OnCompleted() }; h.Add(g.Subscribe(function (b) { a.Add({Value: b, Timestamp: c.Now()}) }, i, j)); h.Add(C(f, e, c).Subscribe(function () { var g = l(), d = c.Now() + e - f; while (a.GetCount() > 0 && a.GetItem(0).Timestamp - d <= 0)a.RemoveAt(0); b.OnNext(g); k = d }, i, j)); return h }) }, BufferWithTimeOrCount: function (f, g, c) { if (c === a)c = i; var h = this; return b(function (j) { var b = 0, a = new r, k = function () { j.OnNext(a.ToArray()); a.Clear(); b++ }, l = new e, i; i = function (a) { var d = c.ScheduleWithTime(function () { var c = false, d = 0; if (a == b) { k(); d = b; c = true } c && i(d) }, f); l.Replace(d) }; i(b); var m = h.Subscribe(function (e) { var c = false, d = 0; a.Add(e); if (a.GetCount() == g) { k(); d = b; c = true } c && i(d) }, function (b) { j.OnError(b); a.Clear() }, function () { j.OnNext(a.ToArray()); b++; j.OnCompleted(); a.Clear() }); return new d(m, l) }) }, BufferWithCount: function (d, c) { if (c === a)c = d; var e = this; return b(function (b) { var a = [], f = 0; return e.Subscribe(function (j) { if (f == 0)a.push(j); else f--; var g = a.length; if (g == d) { var h = a; a = []; for (var i = Math.min(c, g), e = i; e < g; e++)a.push(h[e]); f = Math.max(0, c - d); b.OnNext(h) } }, function (a) { b.OnError(a) }, function () { a.length > 0 && b.OnNext(a); b.OnCompleted() }) }) }, StartWith: function (c, e) { if (!(c instanceof Array))c = [c]; if (e === a)e = f; var g = this; return b(function (f) { var a = new d, b = 0; a.Add(e.ScheduleRecursive(function (d) { if (b < c.length) { f.OnNext(c[b]); b++; d() } else a.Add(g.Subscribe(f)) })); return a }) }, DistinctUntilChanged: function (c, d) { if (c === a)c = x; if (d === a)d = A; var e = this; return b(function (a) { var f, b = false; return e.Subscribe(function (g) { var e; try { e = c(g) } catch (i) { a.OnError(i); return } var h = false; if (b)try { h = d(f, e) } catch (i) { a.OnError(i); return } if (!b || !h) { b = true; f = e; a.OnNext(g) } }, function (b) { a.OnError(b) }, function () { a.OnCompleted() }) }) }, Publish: function (c) { if (c === a)return new p(this, new m); var e = this; return b(function () { var a = new p(e, new m); return new d(c(a).Subscribe(g), a.Connect()) }) }, Prune: function (e, c) { if (c === a)c = f; if (e === a)return new p(this, new v(c)); var h = this; return b(function () { var a = new p(h, new v(c)); return new d(e(a).Subscribe(g), a.Connect()) }) }, Replay: function (e, f, h, c) { if (c === a)c = j; if (e === a)return new p(this, new w(f, h, c)); var i = this; return b(function () { var a = new p(i, new w(f, h, c)); return new d(e(a).Subscribe(g), a.Connect()) }) }, SkipLast: function (a) { var c = this; return b(function (b) { var d = []; return c.Subscribe(function (c) { d.push(c); d.length > a && b.OnNext(d.shift()) }, function (a) { b.OnError(a) }, function () { b.OnCompleted() }) }) }, TakeLast: function (a) { var c = this; return b(function (d) { var b = []; return c.Subscribe(function (c) { b.push(c); b.length > a && b.shift() }, function (a) { d.OnError(a) }, function () { while (b.length > 0)d.OnNext(b.shift()); d.OnCompleted() }) }) } }; var Q = c.Merge = function (c, b) { if (b === a)b = f; return R(c, b).MergeObservable() }, G = c.Concat = function (g, c) { if (c === a)c = f; return b(function (a) { var f = new e, b = 0, h = c.ScheduleRecursive(function (d) { if (b < g.length) { var h = g[b]; b++; var c = new e; f.Replace(c); c.Replace(h.Subscribe(function (b) { a.OnNext(b) }, function (b) { a.OnError(b) }, d)) } else a.OnCompleted() }); return new d(f, h) }) }, R = c.FromArray = function (d, c) { if (c === a)c = f; return b(function (a) { var b = 0; return c.ScheduleRecursive(function (c) { if (b < d.length) { a.OnNext(d[b++]); c() } else a.OnCompleted() }) }) }, jb = c.Return = function (d, c) { if (c === a)c = f; return b(function (a) { return c.Schedule(function () { a.OnNext(d); a.OnCompleted() }) }) }, I = c.Throw = function (d, c) { if (c === a)c = f; return b(function (a) { return c.Schedule(function () { a.OnError(d) }) }) }, U = c.Never = function () { return b(function () { return o }) }, B = c.Empty = function (c) { if (c === a)c = f; return b(function (a) { return c.Schedule(function () { a.OnCompleted() }) }) }, q = c.Defer = function (a) { return b(function (b) { var c; try { c = a() } catch (d) { b.OnError(d); return o } return c.Subscribe(b) }) }, V = c.Catch = function (g, c) { if (c === a)c = f; return b(function (a) { var f = new e, b = 0, h = c.ScheduleRecursive(function (d) { var h = g[b]; b++; var c = new e; f.Replace(c); c.Replace(h.Subscribe(function (b) { a.OnNext(b) }, function (c) { if (b < g.length)d(); else a.OnError(c) }, function () { a.OnCompleted() })) }); return new d(f, h) }) }, kb = c.Using = function (c, e) { return b(function (g) { var h, b = o; try { var f = c(); if (f !== a)b = f; h = e(f) } catch (i) { return new d(Throw(i).Subscribe(g), b) } return new d(h.Subscribe(g), b) }) }, lb = c.Range = function (c, d, b) { if (b === a)b = f; var e = c + d - 1; return W(c, function (a) { return a <= e }, function (a) { return a + 1 }, x, b) }, mb = c.Repeat = function (g, c, d) { if (d === a)d = f; if (c === a)c = -1; var e = c; return b(function (a) { return d.ScheduleRecursive(function (b) { a.OnNext(g); if (e > 0) { e--; if (e == 0) { a.OnCompleted(); return } } b() }) }) }, W = c.Generate = function (d, e, g, h, c) { if (c === a)c = f; return b(function (b) { var a = d, f = true; return c.ScheduleRecursive(function (i) { var c = false, d; try { if (f)f = false; else a = g(a); c = e(a); if (c)d = h(a) } catch (j) { b.OnError(j); return } if (c) { b.OnNext(d); i() } else b.OnCompleted() }) }) }, nb = c.GenerateWithTime = function (d, e, f, g, h, c) { if (c === a)c = i; return new b(function (i) { var a = d, l = true, b = false, j, k; return c.ScheduleRecursiveWithTime(function (c) { b && i.OnNext(j); try { if (l)l = false; else a = f(a); b = e(a); if (b) { j = g(a); k = h(a) } } catch (d) { i.OnError(d); return } if (b)c(k); else i.OnCompleted() }, 0) }) }, Y = c.OnErrorResumeNext = function (g, c) { if (c === a)c = f; return b(function (b) { var f = new e, a = 0, h = c.ScheduleRecursive(function (c) { if (a < g.length) { var h = g[a]; a++; var d = new e; f.Replace(d); d.Replace(h.Subscribe(function (a) { b.OnNext(a) }, c, c)) } else b.OnCompleted() }); return new d(f, h) }) }, pb = c.Amb = function () { var a = arguments; return b(function (f) { var c = new d, b = new e; b.Replace(c); for (var j = false, h = 0; h < a.length; h++) { var l = a[h], i = new e, k = new g(function (a) { if (!j) { c.Remove(this.z, true); c.Dispose(); b.Replace(this.z); j = true } f.OnNext(a) }, function (a) { f.OnError(a); b.Dispose() }, function () { f.OnCompleted(); b.Dispose() }); k.z = i; i.Replace(l.Subscribe(k)); c.Add(i) } return b }) }, qb = c.ForkJoin = function () { var c = arguments; return b(function (b) { for (var e = [], g = [], f = [], i = new d, h = 0; h < c.length; h++)(function (d) { i.Add(c[d].Subscribe(function (a) { e[d] = true; f[d] = a }, function (a) { b.OnError(a) }, function () { if (!e[d]) { b.OnCompleted(); f = a; e = a; return } g[d] = true; for (var i = true, h = 0; h < c.length; h++)if (!g[h])i = false; if (i) { b.OnNext(f); b.OnCompleted(); f = a; g = a; e = a } })) })(h); return i }) }, ab = c.Interval = function (a, b) { return C(a, a, b) }, M = function (a) { return Math.max(0, a) }, C = c.Timer = function (e, f, d) { if (d === a)d = i; if (e === a)return U(); if (e instanceof Date)return q(function () { return c.Timer(e - new Date, f, d) }); var g = M(e); if (f === a)return b(function (a) { return d.ScheduleWithTime(function () { a.OnNext(0); a.OnCompleted() }, g) }); var h = M(f); return b(function (a) { var b = 0; return d.ScheduleRecursiveWithTime(function (c) { a.OnNext(b++); c(h) }, g) }) }, N = c.While = function (a, c) { return b(function (b) { var g = new e, h = new d(g); h.Add(f.ScheduleRecursive(function (e) { var d; try { d = a() } catch (f) { b.OnError(f); return } if (d)g.Replace(c.Subscribe(function (a) { b.OnNext(a) }, function (a) { b.OnError(a) }, function () { e() })); else b.OnCompleted() })); return h }) }, bb = c.If = function (c, d, b) { if (b === a)b = B(); return q(function () { return c() ? d : b }) }, cb = c.DoWhile = function (a, b) { return G([a, N(b, a)]) }, db = c.Case = function (d, e, b, c) { if (c === a)c = f; if (b === a)b = B(c); return q(function () { var c = e[d()]; if (c === a)c = b; return c }) }, eb = c.For = function (a, c) { return b(function (b) { var e = new d, g = 0; e.Add(f.ScheduleRecursive(function (f) { if (g < a.length) { var d; try { d = c(a[g]) } catch (h) { b.OnError(h); return } e.Add(d.Subscribe(function (a) { b.OnNext(a) }, function (a) { b.OnError(a) }, function () { g++; f() })) } else b.OnCompleted() })); return e }) }, fb = c.Let = function (a, b) { return q(function () { return b(a) }) }, l = h.Notification = function (a, b) { this.Kind = a; this.Value = b; this.toString = function () { return this.Kind + ": " + this.Value }; this.Accept = function (a) { switch (this.Kind) { case"N": a.OnNext(this.Value); break; case"E": a.OnError(this.Value); break; case"C": a.OnCompleted() } return o }; this.w = function (b) { var c = this.Accept(b); a == "N" && b.OnCompleted(); return c } }; l.prototype = new c; var m = h.Subject = function () { var a = new r, b = false; this.OnNext = function (e) { if (!b)for (var d = a.ToArray(), c = 0; c < d.length; c++) { var f = d[c]; f.OnNext(e) } }; this.OnError = function (e) { if (!b) { for (var d = a.ToArray(), c = 0; c < d.length; c++) { var f = d[c]; f.OnError(e) } b = true; a.Clear() } }; this.OnCompleted = function () { if (!b) { for (var d = a.ToArray(), c = 0; c < d.length; c++) { var e = d[c]; e.OnCompleted() } b = true; a.Clear() } }; this.w = function (c) { if (!b) { a.Add(c); return n(function () { a.Remove(c) }) } else return o } }; m.prototype = new c; for (var D in g.prototype)m.prototype[D] = g.prototype[D]; var v = h.AsyncSubject = function (e) { var b = new r, c, d = false; if (e === a)e = f; this.OnNext = function (a) { if (!d)c = new l("N", a) }; this.OnError = function (f) { if (!d) { c = new l("E", f); for (var g = b.ToArray(), e = 0; e < g.length; e++) { var h = g[e]; h !== a && h.OnError(f) } d = true; b.Clear() } }; this.OnCompleted = function () { if (!d) { if (c === a)c = new l("C"); for (var f = b.ToArray(), e = 0; e < f.length; e++) { var g = f[e]; g !== a && c.w(g) } d = true; b.Clear() } }; this.w = function (a) { if (!d) { b.Add(a); return n(function () { b.Remove(a) }) } else return e.Schedule(function () { c.w(a) }) } }; v.prototype = new m; var gb = h.BehaviorSubject = function (b, c) { var a = new w(1, -1, c); a.OnNext(b); return a }, w = h.ReplaySubject = function (h, i, e) { var c = new r, b = new r, f = false; if (e === a)e = j; var k = i > 0, g = function (c, a) { b.Add({Value: new l(c, a), Timestamp: e.Now()}) }; this.A = function () { if (h !== a)while (b.GetCount() > h)b.RemoveAt(0); if (k)while (b.GetCount() > 0 && e.Now() - b.GetItem(0).Timestamp > i)b.RemoveAt(0) }; this.OnNext = function (d) { if (!f) { for (var b = c.ToArray(), a = 0; a < b.length; a++) { var e = b[a]; e.OnNext(d) } g("N", d) } }; this.OnError = function (d) { if (!f) { for (var b = c.ToArray(), a = 0; a < b.length; a++) { var e = b[a]; e.OnError(d) } f = true; c.Clear(); g("E", d) } }; this.OnCompleted = function () { if (!f) { for (var b = c.ToArray(), a = 0; a < b.length; a++) { var d = b[a]; d.OnCompleted() } f = true; c.Clear(); g("C") } }; this.w = function (f) { var a = new O(this, f), g = new d(a), h = this; g.Add(e.Schedule(function () { if (!a.B) { h.A(); for (var d = 0; d < b.GetCount(); d++)b.GetItem(d).Value.Accept(f); c.Add(f); a.C = true } })); return g }; this.D = function (a) { c.Remove(a) } }; w.prototype = new m; var O = function (a, b) { this.E = a; this.F = b; this.C = false; this.B = false; this.Dispose = function () { this.C && this.E.D(this.F); this.B = true } }, P = c.ToAsync = function (c, b) { if (b === a)b = i; return function () { var a = new v(b), d = function () { var b; try { b = c.apply(this, arguments) } catch (d) { a.OnError(d); return } a.OnNext(b); a.OnCompleted() }, e = this, f = J(arguments); b.Schedule(function () { d.apply(e, f) }); return a } }, hb = c.Start = function (c, d, b, e) { if (b === a)b = []; return P(c, e).apply(d, b) }, p = h.ConnectableObservable = function (c, b) { if (b === a)b = new m; this.E = b; this.G = c; this.H = false; this.Connect = function () { var a, e = false; if (!this.H) { this.H = true; var b = this; a = new d(n(function () { b.H = false })); this.I = a; a.Add(c.Subscribe(this.E)) } return this.I }; this.w = function (a) { return this.E.Subscribe(a) }; this.RefCount = function () { var a = 0, b = this, c; return E(function (e) { var d = false; a++; d = a == 1; var f = b.Subscribe(e); if (d)c = b.Connect(); return function () { f.Dispose(); a--; a == 0 && c.Dispose() } }) } }; p.prototype = new c })(); (function () { var c = jQuery, a = c.fn, h = this, e; if (typeof ProvideCustomRxRootObject == "undefined")e = h.Rx; else e = ProvideCustomRxRootObject(); var g = e.Observable, b = e.AsyncSubject, f = g.Create, i = e.Disposable.Empty; a.toObservable = function (a, c) { var b = this; return f(function (e) { var d = function (a) { e.OnNext(a) }; b.bind(a, c, d); return function () { b.unbind(a, d) } }) }; a.toLiveObservable = function (a, c) { var b = this; return f(function (e) { var d = function (a) { e.OnNext(a) }; b.live(a, c, d); return function () { b.die(a, d) } }) }; a.hideAsObservable = function (c) { var a = new b; this.hide(c, function () { a.OnNext(this); a.OnCompleted() }); return a }; a.showAsObservable = function (c) { var a = new b; this.show(c, function () { a.OnNext(this); a.OnCompleted() }); return a }; a.animateAsObservable = function (c, d, e) { var a = new b; this.animate(c, d, e, function () { a.OnNext(this); a.OnCompleted() }); return a }; a.fadeInAsObservable = function (c) { var a = new b; this.fadeIn(c, function () { a.OnNext(this); a.OnCompleted() }); return a }; a.fadeToAsObservable = function (c, d) { var a = new b; this.fadeTo(c, d, function () { a.OnNext(this); a.OnCompleted() }); return a }; a.fadeOutAsObservable = function (c) { var a = new b; this.fadeOut(c, function () { a.OnNext(this); a.OnCompleted() }); return a }; a.slideDownAsObservable = function (c) { var a = new b; this.slideDown(c, function () { a.OnNext(this); a.OnCompleted() }); return a }; a.slideUpAsObservable = function (c) { var a = new b; this.slideUp(c, function () { a.OnNext(this); a.OnCompleted() }); return a }; a.slideToggleAsObservable = function (c) { var a = new b; this.slideToggle(c, function () { a.OnNext(this); a.OnCompleted() }); return a }; var d = c.ajaxAsObservable = function (e) { var a = {}; for (var f in e)a[f] = e[f]; var d = new b; a.success = function (c, b, a) { d.OnNext({data: c, textStatus: b, xmlHttpRequest: a}); d.OnCompleted() }; a.error = function (a, c, b) { d.OnError({xmlHttpRequest: a, textStatus: c, errorThrown: b}) }; c.ajax(a); return d }; c.getJSONAsObservable = function (b, a) { return d({url: b, dataType: "json", data: a}) }; c.getScriptAsObservable = function (b, a) { return d({url: b, dataType: "script", data: a}) }; c.postAsObservable = function (b, a) { return d({url: b, type: "POST", data: a}) }; a.loadAsObservable = function (e, d) { var a = new b, c = function (d, b, c) { if (b === "error")a.OnError({response: d, status: b, xmlHttpRequest: c}); else { a.OnNext({response: d, status: b, xmlHttpRequest: c}); a.OnCompleted() } }; this.load(e, d, c); return a }; c.getScriptAsObservable = function (a) { return d({url: a, dataType: "script"}) }; c.postAsObservable = function (c, a, b) { return d({url: c, dataType: b, data: a, type: "POST"}) } })(); var dateFormat = function () { var d = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g, c = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g, b = /[^-+\dA-Z]/g, a = function (a, b) { a = String(a); b = b || 2; while (a.length < b)a = "0" + a; return a }; return function (e, f, k) { var i = dateFormat; if (arguments.length == 1 && Object.prototype.toString.call(e) == "[object String]" && !/\d/.test(e)) { f = e; e = undefined } e = e ? new Date(e) : new Date; if (isNaN(e))throw SyntaxError("invalid date"); f = String(i.masks[f] || f || i.masks["default"]); if (f.slice(0, 4) == "UTC:") { f = f.slice(4); k = true } var h = k ? "getUTC" : "get", j = e[h + "Date"](), p = e[h + "Day"](), m = e[h + "Month"](), s = e[h + "FullYear"](), g = e[h + "Hours"](), q = e[h + "Minutes"](), r = e[h + "Seconds"](), l = e[h + "Milliseconds"](), n = k ? 0 : e.getTimezoneOffset(), o = { d: j, dd: a(j), ddd: i.i18n.dayNames[p], dddd: i.i18n.dayNames[p + 7], m: m + 1, mm: a(m + 1), mmm: i.i18n.monthNames[m], mmmm: i.i18n.monthNames[m + 12], yy: String(s).slice(2), yyyy: s, h: g % 12 || 12, hh: a(g % 12 || 12), H: g, HH: a(g), M: q, MM: a(q), s: r, ss: a(r), l: a(l, 3), L: a(l > 99 ? Math.round(l / 10) : l), t: g < 12 ? "a" : "p", tt: g < 12 ? "am" : "pm", T: g < 12 ? "A" : "P", TT: g < 12 ? "AM" : "PM", Z: k ? "UTC" : (String(e).match(c) || [""]).pop().replace(b, ""), o: (n > 0 ? "-" : "+") + a(Math.floor(Math.abs(n) / 60) * 100 + Math.abs(n) % 60, 4), S: (["th", "st", "nd", "rd"])[j % 10 > 3 ? 0 : (j % 100 - j % 10 != 10) * j % 10] }; return f.replace(d, function (a) { return a in o ? o[a] : a.slice(1, a.length - 1) }) } }(); dateFormat.masks = { "default": "ddd mmm dd yyyy HH:MM:ss", shortDate: "m/d/yy", mediumDate: "mmm d, yyyy", longDate: "mmmm d, yyyy", fullDate: "dddd, mmmm d, yyyy", shortTime: "h:MM TT", mediumTime: "h:MM:ss TT", longTime: "h:MM:ss TT Z", isoDate: "yyyy-mm-dd", isoTime: "HH:MM:ss", isoDateTime: "yyyy-mm-dd'T'HH:MM:ss", isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'" }; dateFormat.i18n = { dayNames: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], monthNames: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] }; Date.prototype.format = function (a, b) { return dateFormat(this, a, b) }; (function () { var a = 8, m = "", l = 0, i = function (c) { for (var d = [], f = (1 << a) - 1, e = c.length * a, b = 0; b < e; b += a)d[b >> 5] |= (c.charCodeAt(b / a) & f) << 32 - a - b % 32; return d }, h = function (c) { for (var d = [], e = c.length, b, a = 0; a < e; a += 2) { b = parseInt(c.substr(a, 2), 16); if (!isNaN(b))d[a >> 3] |= b << 24 - 4 * (a % 8); else return "INVALID HEX STRING" } return d }, g = function (d) { for (var e = l ? "0123456789ABCDEF" : "0123456789abcdef", c = "", f = d.length * 4, b, a = 0; a < f; a += 1) { b = d[a >> 2] >> (3 - a % 4) * 8; c += e.charAt(b >> 4 & 15) + e.charAt(b & 15) } return c }, f = function (b) { for (var g = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", d = "", f = b.length * 4, c, e, a = 0; a < f; a += 3) { e = (b[a >> 2] >> 8 * (3 - a % 4) & 255) << 16 | (b[a + 1 >> 2] >> 8 * (3 - (a + 1) % 4) & 255) << 8 | b[a + 2 >> 2] >> 8 * (3 - (a + 2) % 4) & 255; for (c = 0; c < 4; c += 1)if (a * 8 + c * 6 <= b.length * 32)d += g.charAt(e >> 6 * (3 - c) & 63); else d += m } return d }, b = function (b, a) { return b << a | b >>> 32 - a }, j = function (a, b, c) { return a ^ b ^ c }, o = function (a, b, c) { return a & b ^ ~a & c }, n = function (a, b, c) { return a & b ^ a & c ^ b & c }, c = function (b, c) { var a = (b & 65535) + (c & 65535), d = (b >>> 16) + (c >>> 16) + (a >>> 16); return (d & 65535) << 16 | a & 65535 }, d = function (a, b, c, d, e) { var f = (a & 65535) + (b & 65535) + (c & 65535) + (d & 65535) + (e & 65535), g = (a >>> 16) + (b >>> 16) + (c >>> 16) + (d >>> 16) + (e >>> 16) + (f >>> 16); return (g & 65535) << 16 | f & 65535 }, e = function (p, q) { var f = [], g, h, i, k, l, m, r, a, t, e = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], s = [1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1518500249, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 1859775393, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 2400959708, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782, 3395469782]; p[q >> 5] |= 128 << 24 - q % 32; p[(q + 65 >> 9 << 4) + 15] = q; t = p.length; for (r = 0; r < t; r += 16) { g = e[0]; h = e[1]; i = e[2]; k = e[3]; l = e[4]; for (a = 0; a < 80; a += 1) { if (a < 16)f[a] = p[a + r]; else f[a] = b(f[a - 3] ^ f[a - 8] ^ f[a - 14] ^ f[a - 16], 1); if (a < 20)m = d(b(g, 5), o(h, i, k), l, s[a], f[a]); else if (a < 40)m = d(b(g, 5), j(h, i, k), l, s[a], f[a]); else if (a < 60)m = d(b(g, 5), n(h, i, k), l, s[a], f[a]); else m = d(b(g, 5), j(h, i, k), l, s[a], f[a]); l = k; k = i; i = b(h, 30); h = g; g = m } e[0] = c(g, e[0]); e[1] = c(h, e[1]); e[2] = c(i, e[2]); e[3] = c(k, e[3]); e[4] = c(l, e[4]) } return e }, k = function (b, c) { this.sha1 = null; this.strBinLen = null; this.strToHash = null; if ("HEX" === c) { if (0 !== b.length % 2)return "TEXT MUST BE IN BYTE INCREMENTS"; this.strBinLen = b.length * 4; this.strToHash = h(b) } else if ("ASCII" === c || "undefined" === typeof c) { this.strBinLen = b.length * a; this.strToHash = i(b) } else return "UNKNOWN TEXT INPUT TYPE" }; k.prototype = { getHash: function (c) { var a = null, b = this.strToHash.slice(); switch (c) { case"HEX": a = g; break; case"B64": a = f; break; default: return "FORMAT NOT RECOGNIZED" } if (null === this.sha1)this.sha1 = e(b, this.strBinLen); return a(this.sha1) }, getHMAC: function (j, o, p) { var l, b, c, k, d, m = [], n = []; switch (p) { case"HEX": l = g; break; case"B64": l = f; break; default: return "FORMAT NOT RECOGNIZED" } if ("HEX" === o) { if (0 !== j.length % 2)return "KEY MUST BE IN BYTE INCREMENTS"; b = h(j); d = j.length * 4 } else if ("ASCII" === o) { b = i(j); d = j.length * a } else return "UNKNOWN KEY INPUT TYPE"; if (64 < d / 8) { b = e(b, d); b[15] &= 4294967040 } else if (64 > d / 8)b[15] &= 4294967040; for (c = 0; c <= 15; c += 1) { m[c] = b[c] ^ 909522486; n[c] = b[c] ^ 1549556828 } k = e(m.concat(this.strToHash), 512 + this.strBinLen); k = e(n.concat(k), 672); return l(k) } }; window.jsSHA = k })(); jSaaspose.PortalService = function (b, c, a) { this._init(b, c, a) }; $.extend(jSaaspose.PortalService.prototype, { _urlSuffix: "", _lastError: null, _service: null, _cacheTimeout: 300, applicationPath: null, useJSONP: false, _useHttpHandlers: false, urlPrefix: "", _init: function (c, a, b) { this.applicationPath = c; this._useHttpHandlers = a; if (a)this._urlSuffix = "Handler"; if ($.browser.msie && $.browser.version == 8 && b)this.useJSONP = true }, viewDocumentAsHtml: function (t, r, v, i, k, d, c, q, n, j, o, g, h, e, f, b, m, p, a, l, s) { var u = { userId: t, privateKey: r, guid: v, useHtmlBasedEngine: true, preloadPagesCount: i, fileDisplayName: k, usePngImagesForHtmlBasedEngine: d, convertWordDocumentsCompletely: c, ignoreDocumentAbsence: g, supportPageRotation: h, supportListOfContentControls: e, supportListOfBookmarks: f, watermarkText: q, watermarkColor: n, watermarkPosition: j, watermarkWidth: o, embedImagesIntoHtmlForWordFiles: b, instanceIdToken: l, locale: s }; this._runServiceAsync(this.applicationPath + this.urlPrefix + "ViewDocument" + this._urlSuffix, u, m, p, a != null ? a : false) }, getDocumentPageHtml: function (i, f, e, a, c, d, b, g) { var h = { path: i, pageIndex: f, usePngImages: e, embedImagesIntoHtmlForWordFiles: a, instanceIdToken: b, locale: g }; this._runServiceAsync(this.applicationPath + this.urlPrefix + "GetDocumentPageHtml" + this._urlSuffix, h, c, d, false) }, viewDocument: function (u, s, p, r, f, o, h, n, k, g, l, d, e, b, c, j, m, a, i, q) { var t = { guid: u, width: s, quality: p, usePdf: r, preloadPagesCount: f, password: o, fileDisplayName: h, watermarkText: n, watermarkColor: k, watermarkPosition: g, watermarkWidth: l, ignoreDocumentAbsence: d, supportPageRotation: e, supportListOfContentControls: b, supportListOfBookmarks: c, instanceIdToken: i, locale: q }; this._runServiceAsync(this.applicationPath + this.urlPrefix + "ViewDocument" + this._urlSuffix, t, j, m, a != null ? a : false) }, getPdf2JavaScript: function (g, f, e, a, b, c) { var d = {guid: e, descForHtmlBasedEngine: a}; return this._runServiceAsync(this.applicationPath + this.urlPrefix + "GetPdf2JavaScript" + this._urlSuffix, d, b, c, false) }, getImageUrlsAsync: function (s, l, v, m, t, n, o, p, r, k, j, h, e, d, a, c, b, g, i, f, q) { var u = { userId: s, privateKey: l, guid: v, dimension: m, token: t, firstPage: n, pageCount: o, quality: p, usePdf: r, docVersion: k, watermarkText: j, watermarkColor: h, watermarkPosition: e, watermarkFontSize: d, ignoreDocumentAbsence: a, useHtmlBasedEngine: c, supportPageRotation: b, instanceIdToken: f, locale: q }; return this._runServiceAsync(this.applicationPath + this.urlPrefix + "GetImageUrls" + this._urlSuffix, u, g, i, false) }, loadFileBrowserTreeData: function (m, e, o, g, j, k, i, l, f, h, c, d, a, b) { var n = { userId: m, privateKey: e, path: o, pageIndex: g, pageSize: j, orderBy: k, orderAsc: i, filter: l, fileTypes: f, extended: h, instanceIdToken: b }; return this._runServiceAsync(this.applicationPath + this.urlPrefix + "LoadFileBrowserTreeData" + this._urlSuffix, n, c, d, a != null ? a : true) }, getPrintableHtml: function (m, b, d, j, g, c, h, a, f, i, e, k) { var l = { path: m, useHtmlBasedEngine: b, displayName: d, watermarkText: j, watermarkColor: g, watermarkPosition: c, watermarkWidth: h, ignoreDocumentAbsence: a, instanceIdToken: e, locale: k }; return this._runServiceAsync(this.applicationPath + this.urlPrefix + "GetPrintableHtml" + this._urlSuffix, l, f, i, false) }, reorderPage: function (g, e, d, b, c, a) { var f = {path: g, oldPosition: e, newPosition: d, instanceIdToken: a}; return this._runServiceAsync(this.applicationPath + this.urlPrefix + "ReorderPage" + this._urlSuffix, f, b, c, false) }, rotatePage: function (g, e, c, b, d, a) { var f = {path: g, pageNumber: e, rotationAmount: c, instanceIdToken: a}; return this._runServiceAsync(this.applicationPath + this.urlPrefix + "RotatePage" + this._urlSuffix, f, b, d, false) }, _runServiceSync: function (f, e, d) { var a = null, b = false, c = function (c) { b = true; a = c.data }; this._runService(f, e, false, c, null, d); return a }, _runServiceAsync: function (f, e, a, b, d, c) { return this._runService(f, e, true, a, b, d, c) }, _runService: function (h, k, m, i, c, j, l) { var e = JSON.stringify(k), g = null; if (j) { g = Container.Resolve("Cacher"); var f = g.get(h + e); if (f) { f.value.Subscribe(function (a) { this._successHandler(a, i) }.bind(this), function (a) { this._errorHandler(a, c, false) }.bind(this)); return f.value } } var d; if (this.useJSONP)if (this._useHttpHandlers)d = "data=" + e.toString(); else d = k; else d = e; var b = Container.Resolve("RequestObservable")({ url: h, type: this.useJSONP ? "GET" : "POST", contentType: "application/json; charset=utf-8", dataType: this.useJSONP ? "jsonp" + (l ? " xml" : "") : null, data: d, async: m }), a = Container.Resolve("AsyncSubject"); b.Finally = function (b) { a.Subscribe(b) }; b.Subscribe(function (b) { if (b)if (b.data.success === false) { var d = {code: b.data.code, Reason: b.data ? b.data.Reason : null}; c && c(d) } else this._successHandler(b, i); a.OnNext(); a.OnCompleted() }.bind(this), function (b) { this._errorHandler(b, c, false); a.OnNext(); a.OnCompleted() }.bind(this)); j && g.add(h + e, b, this._cacheTimeout); return b }, _errorHandler: function (b, c, e) { var a; if (b.xmlHttpRequest.readyState == 0)if (b.xmlHttpRequest.status === 0)a = {Reason: "Can't connect to server"}; else return; if (b.xmlHttpRequest.status == 401) { window.location = Container.Resolve("HttpProvider").buildUrl("/", "sign-in", {returnUrl: window.location.href}); return } var d = 0; if (this._lastError != 404 && e) { this._lastError = d; if (d == 404)jerror(a.Reason); else jerror() } try { c && c(a) } catch (f) { } }, _successHandler: function (a, b) { if (b) { if (a.xmlHttpRequest.responseText == "")a.data = null; b(a) } } }); (function () { var a = jQuery.event.special, b = "D" + +new Date, c = "D" + (+new Date + 1); a.scrollstart = { setup: function () { var c, d = function (d) { var b = this, e = arguments; if (c)clearTimeout(c); else { d.type = "scrollstart"; $(b).trigger("scrollstart") } c = setTimeout(function () { c = null }, a.scrollstop.latency) }; jQuery(this).bind("scroll", d).data(b, d) }, teardown: function () { jQuery(this).unbind("scroll", jQuery(this).data(b)) } }; a.scrollstop = { latency: 300, setup: function () { var b, d = function (d) { var c = this, e = arguments; b && clearTimeout(b); b = setTimeout(function () { b = null; d.type = "scrollstop"; $(c).trigger("scrollstop") }, a.scrollstop.latency) }; jQuery(this).bind("scroll", d).data(c, d) }, teardown: function () { jQuery(this).unbind("scroll", jQuery(this).data(c)) } } })(); (function (a, b) { a.widget("ui.docViewer", { _viewModel: null, options: { fileId: 0, fileVersion: 1, userId: 0, userKey: null, baseUrl: null, _mode: "full", _docGuid: "", quality: null, use_pdf: "true", showHyperlinks: true }, _create: function () { a.extend(this.options, { documentSpace: this.element, emptyImageUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNgYAAAAAMAASsJTYQAAAAASUVORK5CYII=" }); this.options.createHtml && this._createHtml(); this._viewModel = this.getViewModel(); ko.applyBindings(this._viewModel, this.element.get(0)) }, _init: function () { a(this._viewModel).bind("getPagesCount", function (c, b) { a(this.element).trigger("getPagesCount", [b]) }.bind(this)); a(this._viewModel).bind("onDocumentLoaded", function (b, a) { this.element.trigger("onDocumentLoaded", a) }.bind(this)); a(this._viewModel).bind("onDocumentPasswordRequired", function () { a(this.element).trigger("onDocumentPasswordRequired") }.bind(this)); a(this._viewModel).bind("_onProcessPages", function (c, b) { a(this.element).trigger("_onProcessPages", [b]) }.bind(this)); a(this._viewModel).bind("onProcessPages", function (c, b) { a(this.element).trigger("onProcessPages", [b]) }.bind(this)); a(this._viewModel).bind("onScrollDocView", function (c, b) { a(this.element).trigger("onScrollDocView", [b]) }.bind(this)); a(this._viewModel).bind("onBeforeScrollDocView", function (c, b) { a(this.element).trigger("onBeforeScrollDocView", [b]) }.bind(this)); a(this._viewModel).bind("onDocumentLoadComplete", function (d, c, b) { a(this.element).trigger("onDocumentLoadComplete", [c, b]) }.bind(this)); a(this._viewModel).bind("onSearchPerformed", function (c, b) { a(this.element).trigger("onSearchPerformed", [b]) }.bind(this)); a(this._viewModel).bind("onPageImageLoaded", function () { a(this.element).trigger("onPageImageLoaded") }.bind(this)); a(this._viewModel).bind("onDocViewScrollPositionSet", function (c, b) { a(this.element).trigger("onDocViewScrollPositionSet", [b]) }.bind(this)); a(this._viewModel).bind("onDocumentPageSet", function (c, b) { a(this.element).trigger("onDocumentPageSet", [b]) }.bind(this)) }, getViewModel: function () { if (this._viewModel == null)this._viewModel = this._createViewModel(); return this._viewModel }, _createViewModel: function () { return new docViewerViewModel(this.options) }, applyBindings: function () { ko.applyBindings(this._viewModel, this.element.get(0)) }, _createHtml: function () { var b; if (this.options.supportPageRotation)b = " + ' translateY(' + (($root.isHtmlDocument() && $data.rotation() == 180) ? '100%' : '0') + ') ' + 'rotate(' + $data.rotation() + 'deg)' + ' translateX(' + (($data.rotation() == 180 || $data.rotation() == 270) ? '-100%' : '0') + ')' + ' translateY(' + (($data.rotation() == 90 || (!$root.isHtmlDocument() && $data.rotation() == 180)) ? '-100%' : '0') + ') ' "; else b = ""; var c = "'-ms-transform': 'scale(' + $data.heightRatio() * $root.zoom() / 100.0 + ')' "; if (this.options.pageContentType == "html" && a.browser.msie)if (a.browser.version == 8)c = "zoom: $data.heightRatio() * $root.zoom() / 100.0 "; else c += b; c += ","; var e; if (this.options.watermarkText)e = ''; else e = ""; var i = '
' + e, j = '
", g; if (this.options.useEmScaling)g = j; else g = i; var d, f = this.options.pageContentType == "html"; if (f && this.options.useEmScaling)d = 'class="pages_container html_pages_container" data-bind="style:{fontSize: (16.* $root.zoom() / 100.0) + \'px\'}"'; else d = 'class="pages_container ' + (f ? "html_pages_container" : "") + "\" data-bind=\"style: { height: $root.useVirtualScrolling ? ($root.documentHeight() + 'px') : 'auto', width: ($root.layout() == $root.Layouts.TwoPagesInRow || $root.layout() == $root.Layouts.CoverThenTwoPagesInRow) ? ($root.pageWidth() + $root.imageHorizontalMargin) * 2 + 'px': 'auto'}\""; var k = '

Loading your content...

' + (f ? g : '
") + '
', h = this.element; a(k).appendTo(h); h.trigger("onHtmlCreated"); this.element = a("#" + this.options.docViewerId) } }); docViewerModel = function (b) { a.extend(this, b); this._init() }; a.extend(docViewerModel.prototype, { _init: function () { this._portalService = Container.Resolve("PortalService") }, loadDocument: function (d, f, b, k, g, j, h, e, i, n, o, l, m, p, q, a, r) { var c = function (b) { if (b.data != null && typeof b.data.guid !== "undefined")q.apply(this, [b.data]); else a.apply(this, [{ code: b.data.code, Reason: b.data ? b.data.Reason : null }]) }; switch (this._mode) { case"embed": this._portalService.viewEmbedDocumentAllAsync(this.userId, this.userKey, d, b, this.quality, this.use_pdf, this.preloadPagesCount, k, g, c, a); break; case"webComponent": this._portalService.viewDocument(d, b, this.quality, this.usePdf, this.preloadPagesCount, k, g, j, h, e, i, n, o, l, m, c, a, false, p, r); break; case"annotatedDocument": this._portalService.viewAnnotatedDocumentAsync(this.userId, this.userKey, d, null, f, b, null, this.quality, this.use_pdf, { text: j, color: h, position: e, fontSize: i }, c, a, false); break; default: this._portalService.viewDocumentAllAsync(this.userId, this.userKey, d, null, f, b, null, this.quality, this.use_pdf, c, a, false) } }, loadDocumentAsHtml: function (p, r, i, n, c, m, k, h, l, f, g, d, e, b, j, o, a, q) { this._portalService.viewDocumentAsHtml(this.userId, this.userKey, p, this.preloadPagesCount, i, n, c, m, k, h, l, f, g, d, e, b, function (b) { if (b.data && typeof b.data.guid !== "undefined")o.apply(this, [b.data]); else a.apply(this) }, function (b) { a.apply(this, [b]) }, false, j, q) }, loadProperties: function (b, a) { this._portalService.getDocInfoAsync(this.userId, this.userKey, b, function (b) { a.apply(this, [b.data]) }) }, loadHyperlinks: function (c, b, a) { this._portalService.getDocumentHyperlinks(c, function (a) { b.apply(this, [a.data]) }, function (b) { a.apply(this, [b]) }) }, retrieveImageUrls: function (m, o, k, f, j, g, d, h, a, c, b, e, l, i, n) { this._portalService.getImageUrlsAsync(this.userId, this.userKey, m, f, o, 0, k, this.quality == null ? "" : this.quality, this.use_pdf, this.fileVersion, j, g, d, h, a, c, b, function (a) { l.apply(this, [a.data]) }, function (a) { i.apply(this, [a]) }, e, n) }, getDocumentPageHtml: function (g, e, d, a, b, f, c, h) { this._portalService.getDocumentPageHtml(g, e, d, a, function (a) { f.apply(this, [a.data]) }, function (a) { c.apply(this, [a]) }, b, h) }, reorderPage: function (f, d, c, a, e, b) { this._portalService.reorderPage(f, d, c, function (a) { e.apply(this, [a.data]) }, function (a) { b.apply(this, [a]) }, a) }, rotatePage: function (f, e, c, a, b, d) { this._portalService.rotatePage(f, e, c, function (a) { b.apply(this, [a.data]) }, function (a) { d.apply(this, [a]) }, a) } }); docViewerViewModel = function (b) { a.extend(this, b); this._create(b) }; a.extend(docViewerViewModel.prototype, { Layouts: { ScrollMode: 1, BookMode: 2, OnePageInRow: 3, TwoPagesInRow: 4, CoverThenTwoPagesInRow: 5 }, _model: null, pagesDimension: null, pageImageWidth: 0, imageHorizontalMargin: 34, imageVerticalMargin: 0, initialZoom: 100, zoom: null, scale: null, docWasLoadedInViewer: false, scrollPosition: [0, 0], inprogress: null, pages: null, pageInd: null, pageWidth: null, pageHeight: null, pageCount: null, docType: null, fileId: null, _dvselectable: null, _thumbnailHeight: 140, _firstPage: null, _sessionToken: "", imageUrls: [], pagePrefix: "page-", documentName: null, fit90PercentWidth: false, _pageBounds: null, unscaledPageHeight: null, unscaledPageWidth: null, pageLeft: null, preloadPagesCount: null, viewerLayout: 1, changedUrlHash: false, hashPagePrefix: "page", pageContentType: "image", scrollbarWidth: null, password: null, useJavaScriptDocumentDescription: false, minimumImageWidth: null, fileDisplayName: null, hyperlinks: null, watermarkText: null, watermarkWidth: null, watermarkColor: null, watermarkLeft: null, watermarkTop: null, watermarkScreenWidth: null, searchText: null, htmlSearchHighlightClassName: "search_highlight_html", htmlSearchHighlightElement: "span", htmlSearchHighlightSvgElement: "tspan", currentWordCounter: 0, matchedNods: null, searchMatches: null, matchedNodsCount: 0, matchesCount: null, searchSeparatorsList: '\\-[\\]{}()*+?\\\\^|\\s.,:;+"/', usePngImagesForHtmlBasedEngine: false, loadAllPagesOnSearch: false, serverPages: null, convertWordDocumentsCompletely: false, ignoreDocumentAbsence: false, tabs: null, useTabsForPages: null, tabPanelHeight: 30, supportPageRotation: false, fileType: null, activeTab: null, autoHeight: null, isHtmlDocument: null, rotatedWidth: null, alwaysShowLoadingSpinner: null, supportListOfContentControls: false, supportListOfBookmarks: false, isDocumentLoaded: false, options: {showHyperlinks: true}, _create: function (a) { this._model = new docViewerModel(a); this._init(a) }, _init: function (b) { var e = this; this.initCustomBindings(); if (this.viewerLeft != 0) { this.viewerWidth -= this.viewerLeft; this.documentSpace.css("width", this.viewerWidth + "px") } var c = 852, d = 1100; this.pageImageWidth = c; this.pages = ko.observableArray([]); this.scale = ko.observable(this.initialZoom / 100); this.inprogress = ko.observable(false), this.pageLeft = ko.observable(0); this.pageInd = ko.observable(1); this.pageWidth = ko.observable(c); this.pageHeight = ko.observable(d); this.pageCount = ko.observable(0); this.docType = ko.observable(-1); this.documentName = ko.observable(""); this.password = ko.observable(""); this.preloadPagesCount = b.preloadPagesCount; this.browserIsChrome = ko.observable(false); this.hyperlinks = ko.observableArray(); this.useTabsForPages = ko.observable(null); this.tabs = ko.observableArray([]); this.activeTab = ko.observable(0); this.autoHeight = ko.observable(false); this.isHtmlDocument = ko.observable(false); this.alwaysShowLoadingSpinner = ko.observable(false); this.rotatedWidth = ko.computed(function () { if (this.useTabsForPages()) { var a; a = this.pageWidth(); return a / this.zoom() * 100 + "px" } else return "auto" }, this); this.layout = ko.observable(this.viewerLayout); this.firstVisiblePageForVirtualMode = ko.observable(0).extend({ rateLimit: { method: "notifyWhenChangesStop", timeout: 400 } }); this.lastVisiblePageForVirtualMode = ko.observable(0).extend({ rateLimit: { method: "notifyWhenChangesStop", timeout: 400 } }); this.documentHeight = ko.observable(0); if (this.pageContentType == "html") { this.imageHorizontalMargin = 0; this.calculatePointToPixelRatio() } if (!this.docViewerId)this.docViewerId = this.documentSpace.attr("id"); this.pagePrefix = this.docViewerId + "-page-"; if (b.fit90PercentWidth)this.pageImageWidth = this.documentSpace.width() * .9 - 2 * this.imageHorizontalMargin; if (this.pageContentType == "image")this.initialWidth = this.pageImageWidth; if (this.zoomToFitWidth)this.initialWidth = this.pageImageWidth = this.getFitWidth(); this.zoom = ko.observable(this.initialZoom); this.documentHeight = ko.observable(0); this.options.showHyperlinks = b.showHyperlinks != false && this.use_pdf != "false"; this.options.highlightColor = b.highlightColor; this.matchedNods = []; this.searchMatches = []; this.serverPages = [{w: this.initialWidth, h: 100}]; var a; if (this.pages().length == 0) { a = { number: 1, visible: ko.observable(false), url: ko.observable(this.emptyImageUrl), htmlContent: ko.observable(""), searchText: ko.observable(null) }; if (this.supportPageRotation)a.rotation = ko.observable(0); if (this.variableHeightPageSupport) { a.prop = ko.observable(1); a.heightRatio = ko.observable(1) } if (this.useVirtualScrolling) { a.left = 0; a.top = ko.observable(0) } this.pages.push(a) } this.pagesContainerElement = this.documentSpace.find(".pages_container"); this.contentControlsFromHtml = []; if (b.fileId)this.loadDocument(); else a.visible(true) }, loadDocument: function (a) { this.inprogress(true); this.documentSpace.trigger("onDocumentloadingStarted"); var c = 1; if (this.pageContentType == "image") { var b; if (this.shouldMinimumWidthBeUsed(this.pageImageWidth * this.initialZoom / 100, false))b = this.minimumImageWidth; else b = Math.round(this.pageImageWidth * this.initialZoom / 100); this._model.loadDocument(a || this.fileId, c, b, this.password(), this.fileDisplayName, this.watermarkText, this.watermarkColor, this.watermarkPosition, this.watermarkWidth, this.ignoreDocumentAbsence, this.supportPageRotation, this.supportListOfContentControls, this.supportListOfBookmarks, this.instanceIdToken, function (b) { if (typeof a !== "undefined")this.fileId = a; this.pageWidth(this.pageImageWidth * (this.initialZoom / 100)); this.zoom(this.initialZoom); this.docWasLoadedInViewer && this.setPageNumerInUrlHash(1); this._onDocumentLoadedBeforePdf2Xml(b) }.bind(this), function (a) { this._onDocumentLoadFailed(a) }.bind(this), this.locale) } else this.pageContentType == "html" && this._model.loadDocumentAsHtml(a || this.fileId, c, this.fileDisplayName, this.usePngImagesForHtmlBasedEngine, this.convertWordDocumentsCompletely, this.watermarkText, this.watermarkColor, this.watermarkPosition, this.watermarkWidth, this.ignoreDocumentAbsence, this.supportPageRotation, this.supportListOfContentControls, this.supportListOfBookmarks, this.embedImagesIntoHtmlForWordFiles, this.instanceIdToken, function (b) { if (typeof a !== "undefined")this.fileId = a; this.pageWidth(this.pageImageWidth * (this.initialZoom / 100)); this._onDocumentLoadedBeforePdf2Xml(b) }.bind(this), function (a) { this._onDocumentLoadFailed(a) }.bind(this), this.locale); typeof viewModelPathOnlineDoc !== "undefined" && viewModelPathOnlineDoc.pathOnlineDoc("") }, getDocumentPageHtml: function (b, c) { var a; if (this.useTabsForPages())a = this.tabs()[b]; else a = this.pages()[b]; if (!a.visible() && !a.startedDownloadingPage) { var d = this.preloadedPages && this.preloadedPages.html[b]; if (d) { a.htmlContent(d); var e = this.preloadedPages.css[b]; this.setPageHtml(a, b, d, e); c && c.call(); return } a.startedDownloadingPage = true; this._model.getDocumentPageHtml(this.fileId, b, this.usePngImagesForHtmlBasedEngine, this.embedImagesIntoHtmlForWordFiles, this.instanceIdToken, function (d) { this.setPageHtml(a, b, d.pageHtml, d.pageCss); c && c.call() }.bind(this), function (b) { a.startedDownloadingPage = false; this._onError(b) }.bind(this), this.locale) } }, setPageHtml: function (b, i, c, j) { var d = j; if (!this.pageCssElement)this.pageCssElement = a([]); if (this.browserIsIE9OrLess) { var h = this.pageCssElement.filter("style:first"); d = h.html(); h.remove(); d += j } var g = a(""); this.pageCssElement = this.pageCssElement.add(g); g.appendTo("head"); var f = this.useTabsForPages(); if (f || f === null)c = c.replace(/^[\r\n\s]+|[\r\n\s]+$/g, ""); b.htmlContent(c); var e = { text: this.searchText, isCaseSensitive: false, searchForSeparateWords: this.searchForSeparateWords, treatPhrasesInDoubleQuotesAsExact: this.treatPhrasesInDoubleQuotesAsExact, pageNumber: i }; if (this.useVirtualScrolling) { b.parsedHtmlElement = a(c); b.currentValue = c; this.parseSearchParameters(b.parsedHtmlElement.not("style")[0], e) } b.searchText(e); b.visible(true); b.startedDownloadingPage = false; this.markContentControls(i) }, addPageCss: function (e) { var b = e; if (!this.pageCssElement)this.pageCssElement = a([]); if (this.browserIsIE9OrLess) { var d = this.pageCssElement.filter("style:first"); b = d.html(); d.remove(); b += e } var c = a(""); this.pageCssElement = this.pageCssElement.add(c); c.appendTo("head") }, retrieveImageUrls: function (d) { var a, c, b; if (this.shouldMinimumWidthBeUsed(this.pageWidth(), true))b = this.minimumImageWidth; else b = this.pageWidth(); c = Math.floor(b) + "x"; this._model.retrieveImageUrls(this.fileId, this._sessionToken, d, c, this.watermarkText, this.watermarkColor, this.watermarkPosition, this.watermarkWidth, this.ignoreDocumentAbsence, this.useHtmlBasedEngine, this.supportPageRotation, this.instanceIdToken, function (b) { for (a = 0; a < d; a++) { this.pages()[a].url(b.image_urls[a]); this.loadImagesForVisiblePages() } }.bind(this), function (a) { this._onError(a) }.bind(this), this.locale) }, _onError: function (b) { this.inprogress(false); var a = window.jerror || window.jGDError && window.jGDError[this.instanceId]; a && a(b.Reason || "The document couldn't be loaded...") }, _onDocumentLoadFailed: function (b) { this.inprogress(false); if (b.code == "Unauthorized")a(this).trigger("onDocumentPasswordRequired"); else { this._onError(b); this.documentSpace.trigger("documentLoadFailed.groupdocs") } }, _onDocumentLoadedBeforePdf2Xml: function (a) { var d = this; function c() { d._onDocumentLoaded(a) } var b = { userId: this.userId, privateKey: this.userKey, fileId: this.fileId, guid: a.guid, documentDescription: a.documentDescription, callback: c }; if (this.useJavaScriptDocumentDescription) { b.synchronousWork = this.textSelectionSynchronousCalculation; b.descForHtmlBasedEngine = this.pageContentType == "html" || this.use_pdf == "false"; this._pdf2XmlWrapper = new jGroupdocs.Pdf2JavaScriptWrapper(b); this._onDocumentLoaded(a) } else if (this.use_pdf == "false")this._onDocumentLoaded(a); else this._pdf2XmlWrapper = new jSaaspose.Pdf2XmlWrapper(b) }, _onDocumentLoaded: function (c) { this.isDocumentLoaded = true; if (this.useJavaScriptDocumentDescription)c.page_count = this._pdf2XmlWrapper.getPageCount(); if (!c.page_size)c.page_size = {}; a(this).trigger("onDocumentLoaded", c); var m = this; this._sessionToken = c.token; this.docGuid = c.guid; this.pageCount(c.page_count); this.documentName(c.name); this.docType(c.doc_type); this.password(c.password); this.matchesCount = 0; a(this).trigger("getPagesCount", c.page_count); if (this.variableHeightPageSupport)c.documentDescription = this._pdf2XmlWrapper.documentDescription; var f = null, h = null, d, g, z, s; if (this.supportListOfContentControls)this.contentControls = this._pdf2XmlWrapper.getContentControls(); if (this.supportListOfBookmarks)this.bookmarks = this._pdf2XmlWrapper.getBookmarks(); if (this.pageContentType == "image") { if (this.use_pdf != "false" || this.variableHeightPageSupport) { h = this._pdf2XmlWrapper.getPageSize(); if (this.variableHeightPageSupport) { c.page_size.Width = h.width; c.page_size.Height = h.height } this.scale(this.pageImageWidth * (this.initialZoom / 100) / h.width); this.unscaledPageHeight = Number(h.height); this.unscaledPageWidth = Number(h.width) } this.heightWidthRatio = parseFloat(c.page_size.Height / c.page_size.Width); this.pageHeight(Math.round(this.pageImageWidth * this.heightWidthRatio * (this.initialZoom / 100))); a(this).trigger("_onProcessPages", c) } else if (this.pageContentType == "html") { this.watermarkScreenWidth = null; this.zoom(100); this.fileType = c.fileType; this.urlForResourcesInHtml = c.urlForResourcesInHtml; z = this.fileType == "Txt" || this.fileType == "Xml"; this.isHtmlDocument(this.fileType == "Html" || this.fileType == "Htm" || z); var n = c.doc_type == "Cells" || this.isHtmlDocument(); this.useTabsForPages(n); n |= c.doc_type == "Image"; this.documentSpace.trigger("isDocumentSinglePaged.groupdocs", n); this.alwaysShowLoadingSpinner(!n); var P = a.browser.webkit && !!window.chrome; this.browserIsChrome(P); var q = c.pageCss[0]; if (!q)q = ""; this.pageCssElement && this.pageCssElement.remove(); this.urlForImagesInHtml = c.urlForImagesInHtml; this.urlForFontsInHtml = c.urlForFontsInHtml; this.pageCssElement = a([]); this.preloadedPages = {html: c.pageHtml, css: c.pageCss}; var p = c.pageHtml[0], j = this.pages()[0]; f = this._pdf2XmlWrapper.documentDescription.pages; this.autoHeight(this.useTabsForPages()); var i; if (this.useTabsForPages()) { this.pageCount(1); if (this.isHtmlDocument()) { var A; if (z)A = "
" + p + "
"; else { var B = this.getHtmlElementContents(p, "head"); if (B) { var w = this.getHtmlElements(B, "style"), y = this.getHtmlElementAttributess(B, "link"); if (y != null)for (d = 0; d < y.length; d++) { i = a(y[d]); var T = i.attr("rel"); if (T == "stylesheet") { var L = i.attr("href"); if (document.createStyleSheet)document.createStyleSheet(L); else { i = a(""); this.pageCssElement = this.pageCssElement.add(i); i.appendTo("head") } } } if (w)for (d = 0; d < w.length; d++) { var S = w[d]; q += S } } A = this.getPageBodyContentsWithReplace(p) } var x = a(A); x.find("script").remove(); x.addClass("html_document_wrapper"); p = x[0].outerHTML; var Q = ".grpdx .ie .doc-page .html_page_contents > div {font-size:1em;}"; q += Q } } else { h = this._pdf2XmlWrapper.getPageSize(); j.prop(f[0].h / f[0].w); s = this.getScaleRatioForPage(h.width, h.height, f[0].w, f[0].h); j.heightRatio(s); this.documentSpace.css("background-color", "inherit") } i = a(""); this.pageCssElement = this.pageCssElement.add(i); i.appendTo("head"); var K = c.sharedCss; if (K) { var I = a(""); this.pageCssElement = this.pageCssElement.add(I); I.appendTo("head") } this.calculatePointToPixelRatio(); var O = this.documentSpace.find(".html_page_contents:first"); j.htmlContent(p); j.visible(true); this.clearContentControls(); this.markContentControls(0); this.tabs.removeAll(); if (this.useTabsForPages()) { var D = this._pdf2XmlWrapper.documentDescription.sheets; if (D)for (d = 0; d < D.length; d++)this.tabs.push({ name: D[d].name, visible: ko.observable(false), htmlContent: ko.observable(""), searchText: ko.observable(null) }); this.activeTab(0); this.documentSpace.css("background-color", "white") } if (this.useTabsForPages() && this.tabs().length > 0)this.documentSpace.addClass("doc_viewer_tabs"); else this.documentSpace.removeClass("doc_viewer_tabs"); var k = O.children("div,table,img"), l; if (this.useTabsForPages()) { l = k.width(); var G = k.height(); j.prop(G / l); h = {width: l, height: G}; j.heightRatio(1) } if (this.supportPageRotation) { if (f)g = f[0].rotation; else g = 0; if (typeof g == "undefined")g = 0; this.applyPageRotationInBrowser(0, j, g) } this.imageHorizontalMargin = 7; c.page_size.Width = h.width; c.page_size.Height = h.height; var M = h.width, H = false, F = k.children(); if (F.length == 1 && F.filter("img").length == 1)H = true; var u = null; if (!H && !this.useTabsForPages()) { u = k.css("width"); k.css("width", M + "pt") } if (this.isHtmlDocument())l = this.getFitWidth(); else l = k.width(); this.heightWidthRatio = parseFloat(c.page_size.Height / c.page_size.Width); (!this.useTabsForPages() || !this.supportPageRotation || j.rotation % 180 == 0) && this.pageWidth(l); u !== null && typeof u != "undefined" && k.css("width", u); this.pageHeight(Math.round(this.pageWidth() * this.heightWidthRatio)); this.initialWidth = this.pageWidth() } var t = this.pageCount(); if (!c.lic && t > 3)t = 3; var o = [], e; if (this.pageContentType == "image") { var C, E; if (this.variableHeightPageSupport) { this.serverPages = f = this._pdf2XmlWrapper.documentDescription.pages; E = this._pdf2XmlWrapper.getPageCount() } for (d = 0; d < t; d++) { if (d < c.image_urls.length)C = c.image_urls[d]; else C = ""; e = {number: d + 1, visible: ko.observable(false), url: ko.observable(C)}; if (this.variableHeightPageSupport)if (d < E && f)e.prop = ko.observable(f[d].h / f[d].w); else e.prop = ko.observable(this.pageHeight() / this.pageWidth()); if (this.supportPageRotation) { g = this.serverPages[d].rotation; if (typeof g == "undefined")g = 0; e.rotation = ko.observable(g); this.applyPageRotationInBrowser(d, e, g) } if (this.useVirtualScrolling) { e.left = 0; e.top = ko.observable(0) } o.push(e) } } else if (this.pageContentType == "html") { this.serverPages = f = this._pdf2XmlWrapper.documentDescription.pages; pageWidth = this.pageWidth(); e = this.pages()[0]; o.push(e); var J; for (d = 1; d < t; d++) { s = this.getScaleRatioForPage(h.width, h.height, f[d].w, f[d].h); J = f[d].h / f[d].w; e = { number: d + 1, visible: ko.observable(false), htmlContent: ko.observable(""), prop: ko.observable(J), heightRatio: ko.observable(s), searchText: ko.observable(null) }; if (this.supportPageRotation) { g = this.serverPages[d].rotation; if (typeof g == "undefined")g = 0; e.rotation = ko.observable(g); this.applyPageRotationInBrowser(d, e, g) } if (this.useVirtualScrolling) { e.left = 0; e.top = ko.observable(0) } o.push(e) } if (n)c.page_count = 0; this.documentSpace.trigger("_onProcessPages", [c, o, this.getDocumentPageHtml, this, this.pointToPixelRatio, this.docViewerId]) } this.pages(o); this.calculatePagePositionsForVirtualMode(); this._firstPage = this.documentSpace.find("#" + this.pagePrefix + "1"); if (this.pages().length > 0 && this._firstPage.length == 0 && !this.useVirtualScrolling)return; a(this).trigger("onProcessPages", [this.docGuid]); this.inprogress(false); this.pageContentType == "image" && this.recalculatePageLeft(); var v = Math.floor(this.pagesContainerElement.width() / this.pageWidth()); if (v == 0)v = 1; if (this.layout() == this.Layouts.OnePageInRow)v = 1; var R = this.scale(); this._dvselectable = this.pagesContainerElement.dvselectable({ txtarea: this.selectionContent, pdf2XmlWrapper: this._pdf2XmlWrapper, startNumbers: this.getVisiblePagesNumbers(), pagesCount: this.pageCount(), proportion: R, pageHeight: this.getPageHeight(), horizontalPageCount: v, docSpace: this.documentSpace, pagePrefix: this.pagePrefix, searchPartialWords: this.searchPartialWords, storeAnnotationCoordinatesRelativeToPages: this.storeAnnotationCoordinatesRelativeToPages, initializeStorageOnly: this.pageContentType == "html", preventTouchEventsBubbling: this.preventTouchEventsBubbling, highlightColor: this.options.highlightColor, useVirtualScrolling: this.useVirtualScrolling, pageLocations: this.useVirtualScrolling ? this.pages() : null }); this._dvselectable.dvselectable("setVisiblePagesNumbers", this.getVisiblePagesNumbers()); if (!this.docWasLoadedInViewer && (this.usePageNumberInUrlHash === b || this.usePageNumberInUrlHash == true)) { var N = location.pathname; location.hash.substring(1, this.hashPagePrefix.length + 1) != this.hashPagePrefix && this.setPage(1); Sammy(function () { this.get(/\#page(.*)/i, b); this.get(N, a); function a() { m.pageInd() != 1 && m.setPage(1) } function b() { if (!m.changedUrlHash)if (!(this.params.splat.length == 0 || this.params.splat[0].length == 0)) { var b = this.params.splat[0], a = Number(b); if (isNaN(a))a = 1; if (a > m.pageCount())a = m.pageCount(); if (a < 1)a = 1; m.setPage(a) } } }).run() } else this.setPage(1); !this.zoomToFitHeight && this.loadImagesForVisiblePages(true); this.adjustInitialZoom(); this.docWasLoadedInViewer = true; this.pageContentType == "image" && this._mode != "webComponent" && this._mode != "annotatedDocument" && this._loadHyperlinks(); if (this.preloadPagesOnBrowserSide) { var r = this.preloadPagesCount; if (r === null || r > this.pageCount())r = this.pageCount(); this.loadImagesForPages(1, r) } a(this).trigger("onScrollDocView", {pi: 1, direction: "up", position: 0}); a(this).trigger("onDocumentLoadComplete", [c, this._pdf2XmlWrapper]); this.documentSpace.trigger("documentLoadCompleted.groupdocs") }, _onDocumentHyperlinksLoaded: function (b) { if (!b || !b.links) { this.hyperlinks.removeAll(); return } var d = [], e = this, c = this.getSelectableInstance(); a.each(b.links, function () { var a = { url: this.Url, pageNumber: this.PageNumber, targetPage: this.TargetPage, rect: new jSaaspose.Rect(this.Bounds.X, this.Bounds.Y, this.Bounds.X + this.Bounds.Width, this.Bounds.Y + this.Bounds.Height) }; a.frame = ko.observable(c != null ? c.convertPageAndRectToScreenCoordinates(a.pageNumber, a.rect) : a.rect); d.push(a) }); this.hyperlinks(d) }, _loadHyperlinks: function () { this.options.showHyperlinks == true && this._model.loadHyperlinks(this.fileId, this._onDocumentHyperlinksLoaded.bind(this), function () { }) }, _refreshHyperlinkFrames: function () { var b = this.getSelectableInstance(); a.each(this.hyperlinks(), function () { this.frame(b != null ? b.convertPageAndRectToScreenCoordinates(this.pageNumber, this.rect) : this.rect) }) }, setPageWidth: function (a) { this.pageImageWidth = a }, setContainerWidth: function (a) { this.viewerWidth = a }, getFitWidth: function () { var a; if (this.viewerWidth)a = this.viewerWidth; else a = this.documentSpace.width(); var b = this.getScrollbarWidth(); return a - b - 2 * (this.imageHorizontalMargin + 1) }, getFitWidthZoom: function () { return this.getFitWidth() / this.initialWidth * 100 }, setContainerHeight: function (a) { this.viewerHeight = a }, getViewerHeight: function () { var a; if (this.viewerHeight)a = this.viewerHeight; else a = this.documentSpace.parent().height(); return a }, getFitHeightZoom: function () { var a = this.getViewerHeight(); return (a - (this.imageVerticalMargin + 2)) / Math.round(this.initialWidth * this.heightWidthRatio) * 100 }, getScrollbarWidth: function () { if (this.scrollbarWidth == null) { var c = a("
").css("width", "100px").css("height", "100px").css("overflow", "scroll").css("position", "absolute").css("top", "-9999px"), b = c[0]; document.body.appendChild(b); this.scrollbarWidth = b.offsetWidth - b.clientWidth; document.body.removeChild(b) } return this.scrollbarWidth }, getPageHeight: function () { return this.unscaledPageHeight * this.scale() }, getSelectable: function () { return this._dvselectable }, _onPropertiesLoaded: function (b) { a(this).trigger("onDocumentLoaded", {fileId: this.fileId, response: b}) }, getFileId: function () { return this.fileId }, ScrollDocView: function (w, v) { var t = this.isSetCalled; this.isSetCalled = false; if (t)return; if (this.useTabsForPages())return; var b = null, u = this.documentSpace.height(), d = a(v.target).scrollTop(); a(this).trigger("onBeforeScrollDocView", {position: d}); if (this.variableHeightPageSupport) { var k = this.getSelectableInstance(); if (k == null)return null; k.initStorage(); var s = k.pageLocations, e, p, q = this.pages(), i; i = this.getVisiblePagesNumbers(); for (var r = this.documentSpace.height(), n = null, g = null, o, l, m, h, c = i.start - 1; c <= i.end - 1; c++) { if (this.useVirtualScrolling)e = q[c].top(); else e = s[c].y; pageHeight = q[c].prop() * this.pageWidth(); p = Math.floor(e + pageHeight); o = Math.max(e, d); l = Math.min(p, d + r); m = l - o; h = m / pageHeight; if (g == null || h > g) { g = h; n = c } } b = n + 1 } else if (this._firstPage != null) { b = (d + u / 2) / this._firstPage.outerHeight(true); var f = Math.floor(this.pagesContainerElement.width() / this._firstPage.width()); if (f == 0)f = 1; if (this.layout() == this.Layouts.OnePageInRow)f = 1; b = b >> 0; var j = this.pageCount(); if (b != j)b = b + 1; b = (b - 1) * f + 1; if (b > j)b = j } if (b !== null) { this.pageInd(b); this.setPageNumerInUrlHash(b); a(this).trigger("onScrollDocView", {pi: b, position: d}); this.documentSpace.trigger("documentScrolledToPage.groupdocs", [b]) } }, ScrollDocViewEnd: function (d, b) { if (this.useTabsForPages())return; this.isSetCalled = false; this.scrollPosition = [a(b.target).scrollLeft(), a(b.target).scrollTop()]; var c = this.loadImagesForVisiblePages(); this._dvselectable && a(this._dvselectable).dvselectable("setVisiblePagesNumbers", c); a(this).trigger("onDocumentPageSet", [this.pageInd()]); this.documentSpace.trigger("documentScrolledToPage.groupdocs", [this.pageInd()]) }, getVisiblePagesNumbers: function () { if (!this.isDocumentLoaded)return null; if (this.useTabsForPages())return {start: 1, end: 1}; var f = null, g = null, a = this.documentSpace.scrollTop(), e, l = null, h = this.documentSpace.height(); if (this.variableHeightPageSupport) { var n = this.getSelectableInstance(); if (n == null && !this.useVirtualScrolling)return null; var k = this.pages(), j, m; if (this.useVirtualScrolling)m = k.length; else { j = n.pageLocations; if (j.length != k.length)return null; m = j.length } for (var d, i, b = 0; b < m; b++) { if (this.useVirtualScrolling)d = k[b].top(); else d = j[b].y; e = k[b].prop() * this.pageWidth(); i = d + e; if (d >= a && d <= a + h || i >= a && i <= a + h || d <= a && i >= a + h)if (f === null)f = b + 1; else g = b + 1 } if (g === null)g = f } else if (this._firstPage != null) { e = this._firstPage.outerHeight(true); var p = this._firstPage.outerWidth(true), q = this.pagesContainerElement.width(); l = Math.floor(a / e) + 1; var o = Math.floor((a + h) / e) + 1, c = Math.floor(q / p); if (c == 0)c = 1; if (this.layout() == this.Layouts.OnePageInRow)c = 1; f = l != 1 ? (l - 1) * c + 1 : 1; g = o * c <= this.pageCount() ? o * c : this.pageCount() } return {start: f, end: g} }, loadImagesForVisiblePages: function (d) { var a = this.getVisiblePagesNumbers(); if (a != null) { var b = a.start, c = a.end; if (b !== null && c !== null) { this.loadImagesForPages(b, c, d); if (this.useVirtualScrolling) { this.firstVisiblePageForVirtualMode(a.start - 1); this.lastVisiblePageForVirtualMode(a.end - 1) } } } return a }, loadImagesForPages: function (h, i, f) { for (var g = this.pages(), c = "", b, d, a = h; a <= i; a++) { b = g[a - 1]; d = b.visible(); d && this.markContentControls(a - 1); if (this.pageContentType == "image") { this.triggerImageLoadedEvent(a); this.supportPageRotation && f && this.addSuffixToImageUrl(b) } else if (this.pageContentType == "html")if (!d) { var e = this.preloadedPages && this.preloadedPages.html[a - 1]; if (e) { b.htmlContent(e); if (this.preloadedPages.css[a - 1])c += this.preloadedPages.css[a - 1]; b.visible(true); continue } else this.getDocumentPageHtml(a - 1) } b.visible(true) } this.pageContentType == "html" && c != "" && this.addPageCss(c) }, setPage: function (j) { this.isSetCalled = true; var b = Number(j); if (isNaN(b) || b < 1)b = 1; this.pageInd(b); var c; if (this.variableHeightPageSupport)if (this.useVirtualScrolling)c = this.pages()[b - 1].top(); else { var d = this.getSelectableInstance(); if (d != null)if (d.pageLocations && d.pageLocations.length > 0) { var h = d.pageLocations[b - 1].y; c = h } } else { var e = Math.floor(this.pagesContainerElement.width() / this._firstPage.width()); if (e == 0)e = 1; if (this.layout() == this.Layouts.OnePageInRow)e = 1; var i = Math.ceil(b / e) - 1; c = i * this._firstPage.outerHeight(true) } var g = this.documentSpace.scrollTop(); this.documentSpace.scrollTop(c); if (this.documentSpace.scrollTop() == g)this.isSetCalled = false; a(this).trigger("onDocViewScrollPositionSet", {position: c}); var f = this.pages()[b - 1]; if (this.pageContentType == "image") { this.triggerImageLoadedEvent(b); f.visible(true) } else if (this.pageContentType == "html")!f.visible() && this.getDocumentPageHtml(b - 1); this.setPageNumerInUrlHash(b); a(this).trigger("onDocumentPageSet", [b]); this.documentSpace.trigger("documentPageSet.groupdocs", b) }, triggerImageLoadedEvent: function (b) { if (a.browser.msie)!this.pages()[b - 1].visible() && a("img#img-" + b).load(function () { a(this).trigger("onPageImageLoaded") }) }, setZoom: function (a) { this.zoom(a); this.loadPagesZoomed(); this.clearContentControls(); if (this.pageContentType == "image") { if (this._pdf2XmlWrapper) { var b = this._pdf2XmlWrapper.getPageSize(); this.scale(this.pageImageWidth / b.width * a / 100) } this._dvselectable.dvselectable("changeSelectedRowsStyle", this.scale()); this.reInitSelectable(); if (this.useVirtualScrolling) { this.getSelectableInstance().recalculateSearchPositions(this.scale()); this.highlightSearch() } this.recalculatePageLeft(); this.setPage(this.pageInd()); this.shouldMinimumWidthBeUsed(this.pageWidth(), true) && this.loadImagesForVisiblePages(); this.options.showHyperlinks && this._refreshHyperlinkFrames() } else if (this.pageContentType == "html") { this.reInitSelectable(); this.setPage(this.pageInd()); this.loadImagesForVisiblePages() } }, loadPagesZoomed: function () { var a = Math.round(this.initialWidth * this.zoom() / 100), b = Math.round(a * this.heightWidthRatio), i = this.pages(); if (a != this.pageWidth() || b != this.pageHeight()) { this.pagesDimension = Math.floor(a) + "x"; this.pageWidth(a); this.pageHeight(b); if (this.useTabsForPages()) { var c = this.documentSpace.find(".html_page_contents:first"), e = c.children("div,table,img"), g = e[0].getBoundingClientRect(), d = 20, f = this.autoHeight(); this.autoHeight(true); i[0].prop((g.height + d) / a); this.autoHeight(f) } else this.calculatePagePositionsForVirtualMode(); if (this.pageContentType == "image") { var h = this.pageCount(); !this.shouldMinimumWidthBeUsed(a, true) && this.retrieveImageUrls(h) } } }, performSearch: function (f, h, d, c, j) { if (this.pageContentType == "image") { var i = this.getSelectableInstance(); if (i != null) { var l = i.performSearch(f, this.scale(), h, d, c, j); a(this).trigger("onSearchPerformed", [l]) } } else { this.searchText = f; this.searchForSeparateWords = d; this.treatPhrasesInDoubleQuotesAsExact = c; var e = this.pages(), g; this.loadAllPagesOnSearch && this.loadImagesForPages(1, e.length); for (var b = 0; b < e.length; b++) { g = e[b]; if (g.visible()) { var k = { text: f, isCaseSensitive: h, searchForSeparateWords: d, treatPhrasesInDoubleQuotesAsExact: c, pageNumber: b }; g.searchText(k) } } } }, searchHtmlElement: function (a, s, r, j, z, E, n, p, D) { s = s || this.htmlSearchHighlightElement; var o, g, F = 0, b = null, e = null, K; if (a.nodeType === 3) { if (j) { o = j.length; var q = a.data.replace(/[\r\n\s]+$/g, ""), G = "[" + this.searchSeparatorsList + "]", x, y, L = /[\-[\]{}()*+?\\^|\s.,:;+"]+$/g, I, l, h, i, m, d, k = -1, J = 0, c = 0; q = q.replace(L, ""); if (q.length == 0)return 0; if (E && !p) { for (var f = [], t = 0; t < j.length; t++) { I = j[t]; l = z[t]; g = l; i = g.length; e = a.data; if (!n) { g = g.toLocaleLowerCase(); e = e.toLocaleLowerCase() } c = 0; do { h = e.indexOf(g, c); if (h != -1) { f.push({index: h, length: i}); c = h + i } } while (h != -1) } f.sort(function (a, b) { return b.index - a.index }); var H = []; f = f.filter(function (a, b) { return !f.some(function (c, e) { var d = e != b && (a.index >= c.index && a.index < c.index + c.length) || a.index + a.length > c.index && a.index + a.length < c.index + c.length; if (d) { if (H.indexOf(a) != -1)return false; H.push(c) } return d }) }); for (d = 0; d < f.length; d++) { m = "search_highlight" + this.matchesCount.toString(); this.matchesCount++; this.highlightOneNode(a, f[d].index, f[d].length, m, r, D) } return f.length } var B, C, w; do { I = j[this.currentWordCounter]; l = z[this.currentWordCounter]; B = this.currentWordCounter == 0; C = this.currentWordCounter == o - 1; if (B && !p)x = ""; else x = "(?:" + G + "|^)+"; if (C && !p)y = ""; else y = "(?:" + G + "|$)+"; g = x + "(" + l + y + ")"; e = a.data; e = e.substr(c, e.length - c); if (this.matchedNodsCount > 0 && k == -1 || k != -1)g = "^" + g; K = new RegExp(g, n ? "" : "i"); w = false; b = e.match(K); if (b) { if (k == -1)this.matchedNodsCount++; F++; this.matchedNods.push(a); h = c + b.index; i = b[0].length; if (B) { h = c + e.indexOf(b[1], b.index); i = b[1].length } if (C && !this.useAccentInsensitiveSearch) { var u = j[this.currentWordCounter], A = e; if (!n) { u = u.toLowerCase(); A = A.toLowerCase() } var N = c + A.indexOf(u, b.index); i = u.length + N - h } this.searchMatches.push({index: h, length: i}); k = c + b.index; J = b[0].length; c = k + J; this.currentWordCounter++; if (this.currentWordCounter >= o) { m = "search_highlight" + this.matchesCount.toString(); for (d = o - 1; d >= 0; d--)this.highlightOneNode(this.matchedNods[d], this.searchMatches[d].index, this.searchMatches[d].length, m, r, D); this.currentWordCounter = 0; this.matchedNods = []; this.searchMatches = []; this.matchedNodsCount = 0; this.matchesCount++; return F } } else { this.matchedNods = []; this.searchMatches = []; if (this.currentWordCounter > 0) { k = -1; this.matchedNodsCount = 0; w = true } this.currentWordCounter = 0 } } while (b && c < q.length || w); if (!b)this.matchedNodsCount = 0; return 0 } } else if (a.nodeType === 1 && a.childNodes && !/(script|style)/i.test(a.tagName) && !(a.tagName === s.toUpperCase() && a.className === r))for (var M = 0, v = M; v < a.childNodes.length; v++)v += this.searchHtmlElement(a.childNodes[v], s, r, j, z, E, n, p, D); return 0 }, highlightOneNode: function (i, k, j, e, h, l) { var n = false, g = a(i), b, c; if (g.is("tspan") || g.parent().is("tspan")) { n = true; c = this.htmlSearchHighlightSvgElement; var o = "http://www.w3.org/2000/svg"; b = document.createElementNS(o, c); b.setAttribute("class", h || this.htmlSearchHighlightClassName) } else { c = this.htmlSearchHighlightElement; b = document.createElement(c); b.className = h || this.htmlSearchHighlightClassName } var f = a(b); e && f.attr("name", e); f.attr("data-page-num", l.toString()); var d = i.splitText(k); d.splitText(j); var m = d.cloneNode(true); b.appendChild(m); d.parentNode.replaceChild(b, d) }, removeSearchHighlight: function (d) { var b = this.htmlSearchHighlightElement + "." + this.htmlSearchHighlightClassName, c = this.htmlSearchHighlightSvgElement + "." + this.htmlSearchHighlightClassName; a(d).find(b + "," + c).each(function () { var a = this.parentNode; a.replaceChild(this.firstChild, this); a.normalize() }) }, getWords: function (f) { var d = "[^" + this.searchSeparatorsList + "]+", e = new RegExp(d, "g"), c = f.match(e), b; if (c == null)b = null; else b = a.map(c, function (a) { if (a != "")return a }); return b }, selectTextInRect: function (g, d, e, b, f, c) { return this._dvselectable ? a(this._dvselectable).dvselectable("highlightPredefinedArea", g, d, e, b, f, c) : null }, deselectTextInRect: function (e, c, d, b) { this._dvselectable && a(this._dvselectable).dvselectable("unhighlightPredefinedArea", e, c, d, b) }, recalculatePageLeft: function () { if (this._firstPage != null && this.pagesContainerElement != null) { var a = this._firstPage.offset().left - this.pagesContainerElement.offset().left; this.pageLeft(a) } }, reInitSelectable: function () { var a = this.getVisiblePagesNumbers(); this._dvselectable != null && this._dvselectable.dvselectable("reInitPages", this.scale(), a, this.scrollPosition, this.getPageHeight(), this.pages()) }, reInitCanvasOffset: function () { var a = this.getSelectableInstance(); a.initCanvasOffset() }, openCurrentPage: function () { this.setPage(this.pageInd()) }, setPageNumerInUrlHash: function (a) { if (this.usePageNumberInUrlHash === b || this.usePageNumberInUrlHash == true)if (location.hash != "" || a > 1) { this.changedUrlHash = true; location.hash = this.hashPagePrefix + a.toString(); this.changedUrlHash = false } }, isScrollViewerVisible: function () { return this.documentSpace.is(":visible") }, getSelectableInstance: function () { if (this._dvselectable == null)return null; var a = this._dvselectable.data("ui-dvselectable"); if (!a)a = this._dvselectable.data("dvselectable"); return a }, shouldMinimumWidthBeUsed: function (d, b) { var a = null; if (this.use_pdf != "false" && b) { var c = this._pdf2XmlWrapper.getPageSize(); a = c.width } return this.minimumImageWidth != null && (d <= this.minimumImageWidth || a !== null && a < this.minimumImageWidth) }, resizeViewerElement: function (a) { var c = this.documentSpace.parent(), b = c.width(); if (typeof a == "undefined")a = 0; else this.viewerLeft = a; this.documentSpace.width(b - a); this.reInitSelectable(); this.loadImagesForVisiblePages() }, onPageReordered: function (b, a) { this._model.reorderPage(this.fileId, b, a, this.instanceIdToken, function () { if (this.pageContentType == "image")for (var d = this.pages(), e, g = Math.min(b, a), f = Math.max(b, a), c = g; c <= f; c++) { e = d[c].url(); d[c].url(e + "#0"); d[c].visible(true) } this._pdf2XmlWrapper && this._pdf2XmlWrapper.reorderPage(b, a); this.reInitSelectable(); this.loadImagesForVisiblePages() }.bind(this), function (a) { this._onError(a) }.bind(this)) }, rotatePage: function (b, t) { var a = this.pageInd() - 1; this._model.rotatePage(this.fileId, a, b, this.instanceIdToken, function (b) { t && t(); var c = this.pages()[a]; this.applyPageRotationInBrowser(a, c, b.resultAngle); this.setPage(a + 1); this.loadImagesForVisiblePages(true) }.bind(this), function (a) { t && t(), this._onError(a) }.bind(this)) }, applyPageRotationInBrowser: function (l, a, g) { if (!this.supportPageRotation)return; var j = a.rotation(); if (j == 0 && g == 0)return; if (this.pageContentType == "image" && j != g) { a.visible(false); this.addSuffixToImageUrl(a); a.visible(true) } a.rotation(g); var n = a.rotation() % 180, i = this._pdf2XmlWrapper.documentDescription.pages, d, e, b, c, h; if (this.useTabsForPages()) { var o = this.documentSpace.find(".html_page_contents:first"), k = o.children("div,table"); b = k.width(); c = k.height(); this.initialWidth = b; if (n > 0)h = b; else h = c; this.pageWidth(b * this.zoom() / 100); return } else if (i) { d = this.getPageSize(); e = i[l]; e.rotation = g; b = e.w; c = e.h; h = d.height } else return; var f; if (n > 0) { a.prop(b / c); if (this.pageContentType == "html") { f = this.getScaleRatioForPage(d.width, d.height, c, b); a.heightRatio(f) } } else { a.prop(c / b); if (this.pageContentType == "html") { f = this.getScaleRatioForPage(d.width, d.height, b, c); a.heightRatio(f) } } this.calculatePagePositionsForVirtualMode(); this.reInitSelectable(); var m = this.getSelectableInstance(); m != null && m.clearSelectionOnPage(l); this.loadImagesForVisiblePages(true) }, getHtmlElements: function (d, a) { var c = new RegExp("<" + a + "[^>]*>(?:.|\\r?\\n)*?<\\/" + a + ">", "gi"), b = d.match(c); return b }, getHtmlElementContents: function (e, b) { var d = new RegExp("<" + b + "[^>]*>((?:.|\\r?\\n)*?)<\\/" + b + ">", "i"), c = e.match(d), a = null; if (c)a = c[1]; return a }, getHtmlElementAttributess: function (c, d) { var b = new RegExp("<" + d + "[^>]*/?>", "gi"), a = c.match(b); return a }, getPageBodyContents: function (b) { return b.match(/]*>((?:.|\r?\n)*?)<\/body>/)[1] }, getPageBodyContentsWithReplace: function (a) { var c = ""), d = ""; return d }, isPageVisible: function (a) { return this.pages()[a].visible() }, getPageLocations: function () { return this.getSelectableInstance().pageLocations }, getPageSize: function () { return this._pdf2XmlWrapper.getPageSize() }, fixImageReferencesInHtml: function (b) { return this.getPageBodyContents(b) }, calculatePointToPixelRatio: function () { var c = 100, b = a("
").css("width", c + "pt").css("height", "0"); b.appendTo(this.documentSpace); var d = b.width(); this.pointToPixelRatio = d / c; b.remove() }, activateTab: function (b) { var d = this.tabs()[b], a = this; function c() { var h = a.pages(), c = h[0]; c.htmlContent(d.htmlContent()); var g = a.documentSpace.find(".html_page_contents:first"), f = g.children("div,table"), e = f.width(); a.initialWidth = e; c.prop(f.height() / e); a.pageWidth(e * a.zoom() / 100); a.activeTab(b); a.supportPageRotation && a.applyPageRotationInBrowser(0, c, c.rotation()) } if (d.visible())c(); else this.getDocumentPageHtml(b, function () { c() }) }, adjustInitialZoom: function () { this.zoomToFitHeight && this.setZoom(this.getFitHeightZoom()); if (this.pageContentType == "html" && this.zoomToFitWidth) { var b = this.getFitWidth(), a = this.pageWidth(); if (!this.onlyShrinkLargePages || a > b) { var c = b / a * 100; this.setZoom(c) } } }, intToColor: function (a) { if (a === null)a = 4294901760; else a >>>= 0; var c = a & 255, d = (a & 65280) >>> 8, e = (a & 16711680) >>> 16, b = ((a & 4278190080) >>> 24) / 255; return "rgba(" + [e, d, c, b].join(",") + ")" }, watermarkTransform: function (t, C) { var m = 0; if (t.rotation)m = t.rotation(); var A = t.prop(), f = "Top", y = "Bottom", l = "Diagonal", s = "Left", o = "Center", r = "Right", b = "", g = o; if (this.watermarkPosition.indexOf(f) == 0)b = f; else if (this.watermarkPosition.indexOf(y) == 0)b = y; else if (this.watermarkPosition.indexOf(l) == 0) { b = l; g = o } if (b != l)if (this.watermarkPosition.indexOf(s) != -1)g = s; else if (this.watermarkPosition.indexOf(o) != -1)g = o; else if (this.watermarkPosition.indexOf(r) != -1)g = r; var p = "translate(", D = 10, n = 100, d = n * A, x; if (this.watermarkScreenWidth == null) { var B = C.getBBox(); this.watermarkScreenWidth = B.width } x = this.watermarkScreenWidth; var a; if (this.watermarkWidth == 0)a = 1; else a = this.watermarkWidth / 100; var w = n; if (b == l && d < n)w = d; var v = w * a, z = w / x; if (m % 180 != 0 && b != l) { v = d * a; z = d / x } a *= z; var e = n / 2, c = d / 2, h = 0; switch (g) { case o: h = (n - v) / 2; break; case s: h = 0; break; case r: h = n - v } p += h + "," + (b == f ? 0 : d - d * a) + ")scale(" + a + ")"; if (b == l)p += "translate(0," + -c / a + ") rotate(" + (-50 + m) + "," + (e - h) / a + "," + d + ") "; if (!t.rotation || b == l)return p; var k = 0, j = 0, u = 0, q, i = 0; if (g == o) { q = (e - h) / a; if (b == f)i = 0; else i = d } else if (g == s) { q = e / a; if (m % 180 != 0)u = (e - c) / a; if (b == f)i = 0; else i = d } else if (g == r) { q = -(h - e) / a; if (m % 180 != 0)u = -(e - c) / a; if (b == f)i = 0; else i = d } switch (m) { case 90: if (b == f) { k = c / a; j = -e / a } else { k = -c / a; j = e / a } break; case 180: if (b == f) { k = c / a; j = -c / a } else { k = -c / a; j = c / a } break; case 270: if (b == f) { k = c / a; j = -e / a } else { k = -c / a; j = e / a } } if (b == f || b == y)p += "translate(0," + k + ") rotate(" + m + "," + q + "," + i + ") translate(" + u + "," + j + ")"; return p }, addSuffixToImageUrl: function (d) { var a = d.url(), c = "?", b = a.indexOf("dummy="); if (b != -1)a = a.substring(0, b - 1); var e = a.indexOf("?"); if (e != -1)c = "&"; d.url(a + c + "dummy=" + (new Date).getTime()) }, isRTL: function (d) { return false; var b = "A-Za-zÀ-Ö�?-öø-ʸ̀-֐ࠀ-῿Ⰰ-﬜﷾-﹯﻽-￿", c = "֑-߿יִ-﷽ﹰ-ﻼ", a = new RegExp("^[^" + b + "]*[" + c + "]"); return a.test(d) }, setLoadingState: function (a) { this.inprogress(a) }, getScaleRatioForPage: function (c, f, e) { var a, d; if (c === b)a = 1; else a = c / e; d = a; return d }, pageElementStyle: function (b) { var a = {}, c = this.pages(); if (this.useVirtualScrolling) { var d = this.firstVisiblePageForVirtualMode(); b += d; if (d < c.length)a.top = c[d].top() + "px" } else a.top = ""; if (this.layout() == this.Layouts.OnePageInRow) { a.display = "block"; a.marginLeft = "auto"; a.marginRight = "auto" } else { a.display = ""; a.marginLeft = ""; a.marginRight = "" } var e = this.pageWidth(); if (this.options.useEmScaling) { a.width = this.serverPages[b].w * this.pointToPixelRatio / 16 + "em"; a.height = this.serverPages[b].h * this.pointToPixelRatio / 16 + "em" } else { a.width = e + (this.useHtmlBasedEngine ? this.imageHorizontalMargin : 0) + "px"; if (this.autoHeight()) { a.height = "auto"; a.overflow = "visible" } else { if (b < c.length)a.height = e * c[b].prop() + "px"; a.overflow = "hidden" } } return a }, setLayout: function (a) { this.layout(a); this.calculatePagePositionsForVirtualMode(); this.loadImagesForVisiblePages() }, calculatePagePositionsForVirtualMode: function () { if (this.useVirtualScrolling) { var j = 15, p = 2 * 7, n = this.pages(), o = this.pageWidth(), l = 0, e, m, g, h = 0, i = 0, d = 0, a, c = this.layout(); switch (c) { case this.Layouts.ScrollMode: a = Math.floor(this.pagesContainerElement.width() / this.pageWidth()); if (a == 0)a = 1; break; case this.Layouts.OnePageInRow: a = 1; break; case this.Layouts.TwoPagesInRow: case this.Layouts.CoverThenTwoPagesInRow: a = 2 } for (var f, k, b = 0; b < n.length; b++) { e = n[b]; m = e.prop(); g = o * m; e.left = h; e.top(i); f = c != this.Layouts.CoverThenTwoPagesInRow && b % a == 0 || c == this.Layouts.CoverThenTwoPagesInRow && (b == 0 || b % a == 1); k = c == this.Layouts.OnePageInRow || c == this.Layouts.TwoPagesInRow && b % a == 1 || c == this.Layouts.CoverThenTwoPagesInRow && (b == 0 || b % a == 0) || c == this.Layouts.ScrollMode && b % a == a - 1; if (f || !f && g > d)d = g; l = i + d + j; if (k) { i += d + j; h = 0 } else h += o + p } this.documentHeight(l) } }, clearContentControls: function () { if (!this.supportListOfContentControls || !this.contentControlsFromHtml)return; for (var a, b = 0; b < this.contentControlsFromHtml.length; b++) { a = this.contentControlsFromHtml[b]; typeof a != "undefined" && a.visualWrapper && a.visualWrapper.remove() } this.contentControlsFromHtml.length = 0 }, markContentControls: function (f) { if (!this.supportListOfContentControls || !this.contentControls)return; for (var e, b = 0; b < this.contentControlsFromHtml.length; b++) { e = this.contentControlsFromHtml[b]; if (typeof e != "undefined" && e.pageNumber == f)return } var h = "2D5FABC2", j = "start", n = "end", m = "=", g = this.documentSpace; if (typeof f != "undefined")g = this.documentSpace.find("#" + this.pagePrefix + (f + 1).toString()); g.find(".content_control_visual_wrapper").remove(); var l = g.find("a[name^='" + h + "']"), c = [], i = 0, d, k = this; l.each(function () { var e = a(this), b = e.attr("name"), r = new RegExp("(" + j + ")|(" + n + ")"), i = b.search(r), p = b.substring(h.length + 1, i); d = parseInt(p); if (f >= k.contentControls[d].startPage && f <= k.contentControls[d].endPage)if (b.indexOf(j) == i) { var o = b.indexOf(m, i) + 1, q = b.substring(o, b.length), l = b[i + j.length] == "1", g = e; if (typeof c[d] == "undefined") { if (l || g.parent().children(":not([name^='" + h + "'])").length == 0)g = g.parent(); c[d] = {title: q, number: d} } c[d].startElement = g; c[d].moveUpInDom = l } else { if (e.parent().children(":not([name^='" + h + "'])").length == 0)e = e.parent(); if (typeof c[d] == "undefined")c[d] = {endElement: e, number: d}; c[d].endElement = e } }); for (b = 0; b < this.contentControls.length; b++)if (f >= this.contentControls[b].startPage && f <= this.contentControls[b].endPage)if (!c[b])c[b] = { number: b, title: this.contentControls[b].title }; for (b = 0; b < c.length; b++) { e = c[b]; if (e) { if (!e.startElement)e.startElement = g.children(".html_page_contents").children(".pageWordToHtml").children(":first"); if (!e.endElement)e.endElement = g.children(".html_page_contents").children(".pageWordToHtml").children(":last"); e.title = this.contentControls[b].title; e.pageNumber = f; i++; (function (a) { window.setTimeout(function () { i--; k.createContentControlWrappers(g, c, a, h, i) }, 2e3) })(b) } } }, createContentControlWrappers: function (o, e, s, v, x) { var b = e[s], p = b.startElement, r = b.endElement, z = p.offset().top; z -= this.pagesContainerElement.offset().top; var c = a("
").appendTo(o); b.visualWrapper = c; c.addClass("content_control_visual_wrapper"); var d = p.nextUntil(r, ":not([name^='" + v + "'])").add(r); if (b.moveUpInDom)d = d.add(p); var w = d.find("*"); d = d.add(w); var h = null, l = null, i = null, k = null, f, n, g, m, q = this.zoom() / 100; d.each(function () { var b = a(this); if (b.width() == 0 || b.height() == 0)return; f = b.offset().left; if (h === null || f < h)h = f; n = b.width() * q; if (l === null || f + n > l)l = f + n; g = b.offset().top; if (i === null || g < i)i = g; m = b.height() * q; if (k === null || g + m > k)k = g + m }); var t = o.offset().left, u = o.offset().top; c.css("left", h - t + "px"); c.css("width", l - h + "px"); c.css("top", i - u + "px"); c.css("height", k - i + "px"); c.attr("data-title", b.title); if (x == 0) { e.sort(function (a, b) { return a.visualWrapper && b.visualWrapper ? b.visualWrapper.width() * b.visualWrapper.height() - a.visualWrapper.width() * a.visualWrapper.height() : 0 }); for (var y = 1, j = 0; j < e.length; j++) { b = e[j]; if (typeof b != "undefined" && b.visualWrapper) { b.visualWrapper.css("z-index", j + y); if (this.contentControlToBeOpened !== null && this.contentControlToBeOpened == b.number) { this.visuallySelectContentControl(b); this.contentControlToBeOpened = null } } this.contentControlsFromHtml.push(e[j]) } } }, getContentControlDescriptions: function () { return this.contentControls }, navigateToContentControl: function (a) { a = parseInt(a); var d = this.contentControls[a].startPage, e = false; if (this.pages()[d].visible())for (var b, c = 0; c < this.contentControlsFromHtml.length; c++) { b = this.contentControlsFromHtml[c]; if (typeof b != "undefined" && b.number == a) { this.visuallySelectContentControl(b); e = true; break } } if (!e) { this.contentControlToBeOpened = a; this.setPage(d + 1) } }, visuallySelectContentControl: function (b) { var d = 20; this.documentSpace[0].scrollTop = b.visualWrapper.offset().top - this.pagesContainerElement.offset().top - d; var c = "hover", a = this.documentSpace.find(".doc-page .content_control_visual_wrapper"); a.removeClass(c); a.unbind("mouseleave"); b.visualWrapper.addClass(c); a.bind("mouseleave", function () { b.visualWrapper.removeClass(c); a.unbind("mouseleave") }); this.documentSpace.trigger("ScrollDocView", [null, {target: this.documentSpace[0]}]); this.documentSpace.trigger("ScrollDocViewEnd", [null, {target: this.documentSpace[0]}]) }, initCustomBindings: function () { if (!ko.bindingHandlers.searchText)ko.bindingHandlers.searchText = { update: function (e, c, h, g, a) { var d = a.$root, b = a.$data; if (!b.searched) { var f = ko.utils.unwrapObservable(c()); d.parseSearchParameters(e, f) } b.searched = false } }; if (!ko.bindingHandlers.parsedHtml)ko.bindingHandlers.parsedHtml = { init: function (h, g, e) { var d = g(), f = a(h), c = f.html(); if (ko.isWriteableObservable(d))d(c); else { var b = e(); b._ko_property_writers && b._ko_property_writers.parsedHtml && b._ko_property_writers.parsedHtml(c) } }, update: function (h, f, i, j, e) { var c = ko.unwrap(f()) || "", b = e.$data, d = a(h); d.empty(); if (c) { if (typeof b.currentValue == "undefined" || b.currentValue === null || b.currentValue != c) { var g = c.replace(/^[\r\n\s]+|[\r\n\s]+$/g, ""); b.parsedHtmlElement = a(g); b.currentValue = c } d.append(b.parsedHtmlElement) } else { b.parsedHtmlElement = null; b.currentValue = null } } } }, parseSearchParameters: function (i, d) { var a = this; a.removeSearchHighlight(i); if (d) { var c = d.text; if (c) { var b, k = d.isCaseSensitive, h = false; if (d.treatPhrasesInDoubleQuotesAsExact) { var e = c.replace(/^[\r\n\s]+|[\r\n\s]+$/g, ""); if (e.length >= 2 && e[0] == '"' && e[e.length - 1] == '"') { c = c.substr(1, e.length - 2); c = c.replace(/^[\r\n\s]+|[\r\n\s]+$/g, ""); a.currentWordCounter = 0; a.matchedNods = []; a.searchMatches = []; a.matchedNodsCount = 0; h = true } } var j = /[-[\]{}()*+?.,\\^$|#\s]/g; b = a.getWords(c); if (b == null)return; b = jQuery.map(b, function (a) { return a.replace(j, "\\$&") }); var g = b, f; if (a.useAccentInsensitiveSearch || a.useRtl) { g = []; for (wordNum = 0; wordNum < b.length; wordNum++) { f = b[wordNum]; if (a.useAccentInsensitiveSearch)f = window.jGroupdocs.stringExtensions.getAccentInsensitiveRegexFromString(f); g.push(f) } } a.searchHtmlElement(i, null, null, b, g, d.searchForSeparateWords, k, h, d.pageNumber); return } } }, highlightSearch: function () { if (this.pageContentType == "image" && this.useVirtualScrolling) { var a = this.getSelectableInstance(); a && a.highlightSearch(this.firstVisiblePageForVirtualMode(), this.lastVisiblePageForVirtualMode()) } } }) })(jQuery); DocViewerAdapter = function (a) { $.extend(this, a); this.init() }; $.extend(DocViewerAdapter.prototype, { docViewerWidget: null, docViewerViewModel: null, navigationWidget: null, navigationViewModel: null, thumbnailsWidget: null, thumbnailsViewModel: null, zoomViewModel: null, init: function () { var g = null, f = null, d = null, l = null, h = null, r = null, m = null, b = null, i = null, c = null, e = null, j = null, k = null, p = null, q = "onMenuClicked"; if (this.thumbnails) { d = this.thumbnails.thumbnails(this.thumbnailsOptions || { baseUrl: this.baseUrl, quality: this.quality, use_pdf: this.use_pdf }); c = this.thumbnails.thumbnails("getViewModel") } else { d = this.thumbnailsCreator(); c = this.thumbnailsViewModelCreator() } var o = 0; if (this.thumbnails)o = c.getThumbnailsPanelWidth(); if (this.docSpace) { var s = $.extend({ userId: this.userId, userKey: this.userKey, baseUrl: this.baseUrl, fileId: this.fileId, fileVersion: this.fileVersion, quality: this.quality, use_pdf: this.use_pdf, pageImageWidth: this.pageImageWidth, _mode: this._mode, docViewerId: this.docViewerId, createHtml: this.createHtml, initialZoom: this.initialZoom, alwaysOnePageInRow: this.alwaysOnePageInRow, zoomToFitWidth: this.zoomToFitWidth, zoomToFitHeight: this.zoomToFitHeight, viewerLeft: o, viewerWidth: this.viewerWidth, viewerHeight: this.viewerHeight, preloadPagesCount: this.preloadPagesCount, selectionContent: this.selectionContent, usePageNumberInUrlHash: this.usePageNumberInUrlHash, pageContentType: this.pageContentType, imageHorizontalMargin: this.imageHorizontalMargin, imageVerticalMargin: this.imageVerticalMargin, useJavaScriptDocumentDescription: this.useJavaScriptDocumentDescription, searchPartialWords: this.searchPartialWords, variableHeightPageSupport: this.variableHeightPageSupport, textSelectionSynchronousCalculation: this.textSelectionSynchronousCalculation, minimumImageWidth: this.minimumImageWidth, fileDisplayName: this.fileDisplayName, preventTouchEventsBubbling: this.preventTouchEventsBubbling, watermarkText: this.watermarkText, instanceId: this.instanceId }, this.viewerOptions); g = this.docSpace.docViewer(s); b = this.docSpace.docViewer("getViewModel") } else { g = this.docSpaceCreator(); b = this.docSpaceViewModel() } var n = null, a = null; if (this.docSpacePageFlip) { n = this.docSpacePageFlip.docViewerPageFlip({ userId: this.userId, userKey: this.userKey, baseUrl: this.baseUrl, fileId: this.fileId, fileVersion: this.fileVersion, quality: this.quality, use_pdf: this.use_pdf, pageImageWidth: this.pageImageWidth, _mode: this._mode, docViewerId: this.docViewerId, createHtml: this.createHtml, initialZoom: this.initialZoom, alwaysOnePageInRow: this.alwaysOnePageInRow, zoomToFitWidth: this.zoomToFitWidth, zoomToFitHeight: this.zoomToFitHeight, viewerWidth: this.viewerWidth, viewerHeight: this.viewerHeight, selectionContent: this.selectionContent, minimumImageWidth: this.minimumImageWidth }); a = this.docSpacePageFlip.docViewerPageFlip("getViewModel") } if (this.navigation) { f = this.navigation.navigation(this.navigationOptions); i = this.navigation.navigation("getViewModel") } if (this.search) { h = this.search.search($.extend(this.searchOptions, {viewerViewModel: b})); j = this.search.search("getViewModel") } if (this.zooming) { l = this.zooming.zooming(this.zoomingOptions || {}); e = this.zooming.zooming("getViewModel") } if (this.embedSource) { r = this.embedSource.embedSource(); k = this.embedSource.embedSource("getViewModel") } if (this.viewTypeMenu) { m = this.viewTypeMenu; p = this.viewTypeViewModel } this.docViewerViewModel = b; this.docViewerPageFlipViewModel = a; this.navigationViewModel = i; this.thumbnailsViewModel = c; this.zoomViewModel = e; this.searchViewModel = j; this.embedSourceViewModel = k; g.bind("getPagesCount", function (b, a) { f && i.setPagesCount(a) }.bind(this)); g.bind("onDocumentloadingStarted", function () { d && c.hideThumbnails() }.bind(this)); g.bind("documentLoadFailed.groupdocs", function () { d && c.showThumbnails(true) }.bind(this)); g.bind("_onProcessPages", function (i, h, g, a, e, b, f) { if (d)c.onProcessPages(h, g, a, e, b, f) }.bind(this)); g.bind("onScrollDocView", function (b, a) { d && c.setThumbnailsScroll(a); f && i.setPageIndex(a.pi); h && j.scrollPositionChanged(a.position) }.bind(this)); g.bind("onSearchPerformed", function () { h }.bind(this)); g.bind("onDocumentPageSet", function (c, b) { if (a)a.onDocumentPageSet(b); h && j.documentPageSetHandler() }); g.bind("onDocumentLoadComplete", function (g, c, d) { a && a._onDocumentLoaded(c, d); var f = c.url; $("#btnDownload,#btnDownload2").bind({ click: function () { window.location.href = f; return false } }); if (r) { k.setGuid(c.guid); k.setFileId(b.getFileId()); k.password(b.password()) } if (l)if (b.isScrollViewerVisible()) { e.setFitWidthZoom(b.getFitWidthZoom()); e.setFitHeightZoom(b.getFitHeightZoom()); e.setZoomWithoutEvent(b.zoom()) } else if (a) { e.setFitWidthZoom(a.getFitWidthZoom()); e.setFitHeightZoom(a.getFitHeightZoom()); e.setZoomWithoutEvent(a.zoom()) } h && j.documentLoaded() }.bind(this)); n && n.bind("onPageTurned", function (e, a) { f && i.setPageIndex(a); d && c.pageInd(a); b.pageInd(a); b.setPageNumerInUrlHash(a) }); h && h.bind("onPerformSearch", function (g, f, e, d, a, c) { b.performSearch(f, e, d, a, c) }); if (f) { f.bind("onUpNavigate", function (f, e) { a && a.setPage(e); b.setPage(e); if (d) { c.setPageWithoutEvent(e); c.setThumbnailsScroll({pi: e, direction: "up"}) } }.bind(this)); f.bind("onDownNavigate", function (f, e) { a && a.setPage(e); b.setPage(e); if (d) { c.setPageWithoutEvent(e); c.setThumbnailsScroll({pi: e, direction: "down"}) } }.bind(this)); f.bind("onSetNavigate", function (f, e) { a && a.setPage(e.pageIndex); b.setPage(e.pageIndex); if (d) { c.setPageWithoutEvent(e.pageIndex); c.setThumbnailsScroll({pi: e.pageIndex, direction: e.direction, eventAlreadyRaised: true}) } }.bind(this)) } if (l) { l.bind("onSetZoom", function (d, c) { a && a.setZoom(c); b.setZoom(c); h && j.resetButtons() }.bind(this)); l.bind(q, function () { m && p.showDropDownMenu(false) }) } if (d) { d.bind("onSetThumbnails", function (d, c) { b.setPage(c); a && a.setPage(c); f && i.setPageIndex(c) }.bind(this)); d.bind("onSetThumbnailsScroll", function (b, a) { f && i.setPageIndex(a) }.bind(this)); d.bind("onResizeThumbnails", function (d, c) { b.resizeViewerElement(c); a && a.resizeViewerElement(c) }); d.bind("onPageReordered", function (d, c, a) { b.onPageReordered(c, a) }) } m && m.bind(q, function () { e && e.showDropDownMenu(false) }) }, thumbnailsCreator: function () { }, thumbnailsViewModelCreator: function () { return { "set": function () { }, setThumbnailsScroll: function () { }, onProcessPages: function () { }, getThumbnailsPanelWidth: function () { return 0 } } } }); jSaaspose.Point = function (a, b) { this.x = a || 0; this.y = b || 0 }; $.extend(jSaaspose.Point.prototype, { x: 0, y: 0, clone: function () { return new jSaaspose.Point(this.x, this.y) }, round: function () { this.x = Math.round(this.x); this.y = Math.round(this.y); return this } }); jSaaspose.Rect = function (b, d, c, e, a) { this.set(b, d, c, e, a) }; $.extend(jSaaspose.Rect.prototype, { topLeft: null, bottomRight: null, clone: function () { return new jSaaspose.Rect(this.topLeft.x, this.topLeft.y, this.bottomRight.x, this.bottomRight.y, false) }, "set": function (b, d, c, e, a) { if (!this.topLeft)this.topLeft = new jSaaspose.Point; if (!this.bottomRight)this.bottomRight = new jSaaspose.Point; this.topLeft.x = b; this.topLeft.y = d; this.bottomRight.x = c; this.bottomRight.y = e; return a ? this.normalize() : this }, add: function (a) { this.topLeft.x += a.x; this.topLeft.y += a.y; this.bottomRight.x += a.x; this.bottomRight.y += a.y; return this }, subtract: function (a) { this.topLeft.x -= a.x; this.topLeft.y -= a.y; this.bottomRight.x -= a.x; this.bottomRight.y -= a.y; return this }, scale: function (a) { this.topLeft.x *= a; this.topLeft.y *= a; this.bottomRight.x *= a; this.bottomRight.y *= a; return this }, round: function () { this.topLeft = this.topLeft.round(); this.bottomRight = this.bottomRight.round(); return this }, left: function () { return this.topLeft.x }, top: function () { return this.topLeft.y }, right: function () { return this.bottomRight.x }, bottom: function () { return this.bottomRight.y }, width: function () { return this.bottomRight.x - this.topLeft.x }, height: function () { return this.bottomRight.y - this.topLeft.y }, setLeft: function (a) { this.topLeft.x = a }, setTop: function (a) { this.topLeft.y = a }, setRight: function (a) { this.bottomRight.x = a }, setBottom: function (a) { this.bottomRight.y = a }, contains: function (a) { return this.topLeft.x <= a.x && a.x <= this.bottomRight.x && this.topLeft.y <= a.y && a.y <= this.bottomRight.y }, includes: function (a) { return this.contains(a.topLeft) && this.contains(a.bottomRight) }, intersects: function (a) { return !(this.topLeft.x > a.bottomRight.x || this.bottomRight.x < a.topLeft.x || this.topLeft.y > a.bottomRight.y || this.bottomRight.y < a.topLeft.y) }, normalize: function () { if (this.topLeft.x > this.bottomRight.x)this.bottomRight.x = ([this.topLeft.x, this.topLeft.x = this.bottomRight.x])[0]; if (this.topLeft.y > this.bottomRight.y)this.bottomRight.y = ([this.topLeft.y, this.topLeft.y = this.bottomRight.y])[0]; return this } }); $.ctrl = function (c, b, a) { $(document).keydown(function (d) { if (!a)a = []; if (d.keyCode == c.charCodeAt(0) && d.ctrlKey) { b.apply(this, a); return true } }) }; (function (a, b) { a.widget("ui.dvselectable", a.ui.mouse, { customArea: [], search: null, lasso: null, pages: [], prevProportions: 1, prevCustomTemplateProportions: 1, searchProportions: 1, selectedRowsCoordinates: [], highlightPaneContainer: null, highlightSearchPaneContainer: null, buttonPaneContainer: null, template: "
", searchTemplate: "
", addTemplate: "
", cAreaPageIndex: 0, cAreaFieldIndex: 0, annotationContainer: "
{1}
", annotationTemplate: "
", timeouts: [], flag: 0, options: { appendTo: "body", txtarea: "", pdf2XmlWrapper: null, startNumbers: null, pagesCount: 0, proportion: 1, cancel: ":input,option,.comment", bookLayout: false, docSpace: "", highlightColor: null }, _initialized: false, _textSelectionByCharModeEnabled: false, _canvasOffset: null, _canvasScroll: null, _mouseStartPos: null, _selectionInfo: {position: -1, length: 0}, SelectionModes: { SelectText: 0, SelectRectangle: 1, SelectTextToStrikeout: 2, ClickPoint: 3, TrackMouseMovement: 4, DoNothing: 5 }, _mode: null, _lassoCssElement: null, rightMargin: 35, parentElement: null, _viewModel: null, selectionCounter: 0, _create: function () { this._initialized = false; this.initCanvasOffset(); if (!this.options.initializeStorageOnly) { this.dragged = false; if (this.options.preventTouchEventsBubbling) { function b(a) { a.preventBubble() } this.element.bind({touchstart: b, touchmove: b, touchend: b}) } this._mouseInit(); this.helper = a("
"); this.createEventHandlers(); this.setMode(this.SelectionModes.SelectText); this.pagePrefix = this.options.pagePrefix } this.search = [] }, createEventHandlers: function () { var b = this; a.ctrl("C", function () { var c = a(document.activeElement), e = c.attr("id"), d = c.attr("name"); if ((e !== b.options.txtarea.attr("id") || d !== b.options.txtarea.attr("name")) && (c.is("input") || c.is("textarea")))return; b.options.txtarea.focus().select() }); a(b.element).bind({ click: function (a) { return b.mouseClickHandler(a) } }) }, _init: function () { this._initialized = false; if (this.options.pdf2XmlWrapper == null)return; this.initStorage(); this._initialized = false }, destroy: function () { this._mouseDestroy(); return this }, initStorage: function () { if (this._initialized)return; this._initialized = true; var b; if (this.options.useVirtualScrolling)this.pageLocations = a.map(this.options.pageLocations, function (a) { return new jSaaspose.Point(a.left, a.top()) }); else this.pageLocations = this._getPageLocations(); b = this.pageLocations; if (this.options.pdf2XmlWrapper != null)if (this.options.bookLayout)this.pages = this.options.pdf2XmlWrapper.getPages(this.options.proportion, b, this.options.startNumbers.start - 1, this.options.startNumbers.end - 1, this.options.useVirtualScrolling); else this.pages = this.options.pdf2XmlWrapper.getPages(this.options.proportion, b, 0, this.options.pagesCount - 1) }, initCanvasOffset: function () { this.parentElement = this.options.docSpace.parent(); var b = this.element.parent().offset(), c = b.left, a = b.top; if (this.options.bookLayout)a = this.parentElement.offset().top; this._canvasOffset = new jSaaspose.Point(c, a) }, getPages: function () { this.initStorage(); return this.pages }, _getPageLocations: function () { var b = this, d = this.options.docSpace.attr("id"), e = ".page-image", c = this.element.find(e); if (this.options.bookLayout)c = c.filter("[id='" + d + "-img-" + this.options.startNumbers.start.toString() + "'],[id='" + d + "-img-" + this.options.startNumbers.end.toString() + "']"); this._canvasScroll = this.getCanvasScroll(); return a.map(c, function (d) { var c = a(d), e = c.offset().left - b._canvasOffset.x + b._canvasScroll.x, f = b.options.bookLayout ? 0 : c.offset().top - b.element.offset().top; return new jSaaspose.Point(e, f) }) }, getCanvasScroll: function () { return this.options.bookLayout ? new jSaaspose.Point(this.parentElement.scrollLeft(), this.parentElement.scrollTop()) : new jSaaspose.Point(this.element.parent().scrollLeft(), this.element.parent().scrollTop()) }, clearSelection: function () { this.element.find(".selection-highlight:not(.static)").remove() }, clearSelectionOnPage: function (a) { this.element.find("#" + this.pagePrefix + (a + 1) + " > .highlight-pane > .selection-highlight:not(.static)").remove() }, _mouseCapture: function (a) { var b = null; this._canvasScroll = this.getCanvasScroll(); this._mouseStartPos = new jSaaspose.Point(a.pageX - this._canvasOffset.x + this._canvasScroll.x, a.pageY - this._canvasOffset.y + this._canvasScroll.y); return this._mode != this.SelectionModes.DoNothing && this._findPageAt(this._mouseStartPos) != null }, _mouseStart: function () { this.options.docSpace.focus(); this.initStorage(); this.clearSelection(); if (this._mode == this.SelectionModes.DoNothing)return false; this.selectionCounter++; this._canvasScroll = this.getCanvasScroll(); if (this.options.bookLayout)this._canvasScroll.y += this.parentElement.parent().scrollTop(); if (this.checkMouseIsInEdgeInBookMode(this._mouseStartPos.x, this._mouseStartPos.y))return false; if (this._mode == this.SelectionModes.TrackMouseMovement) { var a = this._mouseStartPos.y, c = this.findPageAtVerticalPosition(a), b = parseInt(c.pageId) - 1; this.element.trigger("onMouseMoveStarted", [b, {left: this._mouseStartPos.x, top: a}]) } else { this.element.append(this.helper); this.helper.css({left: this._mouseStartPos.x, top: this._mouseStartPos.y, width: 0, height: 0}) } this.options.txtarea.val(""); this.lasso = new jSaaspose.Rect }, _mouseDrag: function (h) { if (this._mode == this.SelectionModes.DoNothing || this.checkMouseIsInEdgeInBookMode(this._mouseStartPos.x, this._mouseStartPos.y))return false; var a = this._mouseStartPos.x, d = this._mouseStartPos.y, c = h.pageX - this._canvasOffset.x + this._canvasScroll.x, e = h.pageY - this._canvasOffset.y + this._canvasScroll.y, f = c, g = e; if (!this._findPageAt(new jSaaspose.Point(f, g)))return false; this.dragged = true; if (a > c) { var i = c; c = a; a = i } if (d > e) { var i = e; e = d; d = i } this.lasso.set(a, d, c, e); this._mode != this.SelectionModes.ClickPoint && this._mode != this.SelectionModes.TrackMouseMovement && this.helper.css({ left: a, top: d, width: this.lasso.width(), height: this.lasso.height() }); this.findSelectedPages(false, null, b, this.options.highlightColor); this.element.trigger("onMouseDrag", [{left: f, top: g}]); return false }, _mouseStop: function (u) { if (this._mode == this.SelectionModes.DoNothing)return false; this.helper.remove(); var r = this._findPageAt(this.lasso.topLeft) || this.pages[0]; if (typeof r === "undefined")return false; var k, e = parseInt(r.pageId) - 1, h = null; if (e < 0)return false; if (this._mode == this.SelectionModes.SelectText || this._mode == this.SelectionModes.SelectTextToStrikeout) { if (!this.dragged)return false; var w = this; this.dragged = false; var b = w._getDocumentHighlightRects(); if (!b || b.length == 0)return false; var o = "", c = this.options.storeAnnotationCoordinatesRelativeToPages ? this.convertRectToRelativeToPageUnscaledCoordinates(this.lasso) : this.convertRectToAbsoluteCoordinates(this.lasso), g = c.top(), f = c.bottom(); c = b[0].originalRect; var n = c.left(), m = c.right(), j = c.top(), i = c.bottom(), p = b[0].position, s = b[b.length - 1].position + b[b.length - 1].length - p; h = []; for (var d = 0; d < b.length; d++) { o += b[d].text; o += d > 0 && (b[d - 1].page != b[d].page || b[d - 1].row != b[d].row) ? "\r\n" : " "; c = b[d].originalRect; h.push(c); n = Math.min(n, c.left()); m = Math.max(m, c.right()); j = Math.min(j, c.top()); i = Math.max(i, c.bottom()) } var v = this.options.proportion; if (this.options.storeAnnotationCoordinatesRelativeToPages) { g = Math.min(j, g); f = Math.max(i, f) } else { k = e * this.options.pageHeight; k /= v; g = Math.max(k + j, g); f = Math.min(k + i, f) } var t = new jSaaspose.Rect(n, g, m, f), q = t.clone(); this.options.txtarea.val(a.trim(o)) } switch (this._mode) { case this.SelectionModes.SelectText: this.element.trigger("onTextSelected", [e, q, p, s, this.selectionCounter, h]); break; case this.SelectionModes.SelectTextToStrikeout: this.element.trigger("onTextToStrikeoutSelected", [e, q, p, s, this.selectionCounter, h]); break; case this.SelectionModes.SelectRectangle: var l; if (this.options.storeAnnotationCoordinatesRelativeToPages)l = this.convertRectToRelativeToPageUnscaledCoordinates(this.lasso, this._mouseStartPos); else l = this.convertRectToAbsoluteCoordinates(this.lasso, this._mouseStartPos); this.element.trigger("onRectangleSelected", [e, l]); break; case this.SelectionModes.ClickPoint: this.mouseClickHandler(u); break; case this.SelectionModes.TrackMouseMovement: a(this.element).trigger("onMouseMoveStopped", []) } return false }, mouseClickHandler: function (b) { this.options.docSpace.focus(); if (this._mode == this.SelectionModes.ClickPoint) { this.initStorage(); this._canvasScroll = this.getCanvasScroll(); var c = b.pageX - this._canvasOffset.x + this._canvasScroll.x, d = b.pageY - this._canvasOffset.y + this._canvasScroll.y, a = new jSaaspose.Rect(c, d, c, d), e = this._findPageAt(a.topLeft); if (!e)return true; var f = parseInt(e.pageId) - 1; if (this.options.storeAnnotationCoordinatesRelativeToPages)a = this.convertRectToRelativeToPageUnscaledCoordinates(a); else a = this.convertRectToAbsoluteCoordinates(a); this.element.trigger("onPointClicked", [f, a]); return false } return true }, checkMouseIsInEdgeInBookMode: function (c, d) { var f = this.element.width(), e = this.element.height(), b = 100, a = 100; return this.options.bookLayout && (c > f - b && d < a || c > f - b && d > e - a || c < b && d < a || c < b && d > e - a) ? true : false }, convertRectToAbsoluteCoordinates: function (g, d) { this.initStorage(); var a = g.clone(), e = this.options.proportion, b = null; if (d)b = this._findPageNearby(d); else b = this._findPageNearby(a.topLeft); a.subtract(b.rect.topLeft); var f = parseInt(b.pageId) - 1, c = f * this.options.pageHeight; c /= e; a.scale(1 / e); a.add(new jSaaspose.Point(0, c)); return a }, convertRectToScreenCoordinates: function (d) { this.initStorage(); var a = d.clone().scale(this.options.proportion); a.top() < 0 && a.setTop(0); var b = this.options.pageHeight, c = Math.floor(a.top() / b); a.subtract(new jSaaspose.Point(0, c * b)); this.pages.length != 0 && a.add(this.pages[c].rect.topLeft); return a }, convertRectToRelativeToPageUnscaledCoordinates: function (e, c) { this.initStorage(); var a = e.clone(), d = this.options.proportion, b = null; if (c)b = this._findPageNearby(c); else b = this._findPageNearby(a.topLeft); a.subtract(b.rect.topLeft); a.scale(1 / d); return a }, convertPageAndRectToScreenCoordinates: function (b, c) { this.initStorage(); var a = c.clone().scale(this.options.proportion); a.top() < 0 && a.setTop(0); this.pages.length != 0 && a.add(this.pages[b].rect.topLeft); return a }, highlightPredefinedArea: function (c, e, g, a, h, d) { this.initStorage(); this.dragged = true; if (this.options.storeAnnotationCoordinatesRelativeToPages)this.lasso = this.convertPageAndRectToScreenCoordinates(g, c); else this.lasso = this.convertRectToScreenCoordinates(c); this.selectionCounter++; var b = this._findPageAt(this.lasso.topLeft) || this.pages[0], f = this.options.startNumbers; this.options.startNumbers = {start: parseInt(b.pageId), end: parseInt(b.pageId)}; this.findSelectedPages(true, e, a, h || this.options.highlightColor, d); this.options.startNumbers = f; this.dragged = false; return typeof a == "undefined" ? this.selectionCounter : a }, unhighlightPredefinedArea: function (f, g, h, d) { if (this.options.storeAnnotationCoordinatesRelativeToPages)this.lasso = this.convertPageAndRectToScreenCoordinates(h, f); else this.lasso = this.convertRectToScreenCoordinates(f); var b = this._getDocumentHighlightRects(); if (!b || b.length == 0)return; if (typeof d == "undefined")d = ""; for (var c = 0; c < b.length; c++) { var i = b[c].page + 1, j = b[c].row + 1, e = "#" + this.pagePrefix + i + "-highlight-" + j + "-" + d; if (g)e += ".static"; else e += ":not(.static)"; a(e).remove() } }, setVisiblePagesNumbers: function (a) { this.options.startNumbers = a }, handleDoubleClick: function (a) { this.lasso = new jSaaspose.Rect(a.pageX, a.pageY, a.pageX, a.pageY); this.initStorage(); this.findSelectedPages() }, initHighlightSearchPaneContainer: function () { for (var a = this._getElementsByClassName("search-pane", document.getElementById(this.options.docSpace.attr("id") + "-pages-container")), c = a.length, b = c; b--;)if (a[b].children.length != 0)a[b].innerHTML = ""; this.highlightSearchPaneContainer = a }, initButtonPaneContainer: function () { for (var a = this._getElementsByClassName("button-pane", document.getElementById(this.options.docSpace.attr("id") + "-pages-container")), c = a.length, b = c; b--;)if (a[b].children.length != 0)a[b].innerHTML = ""; this.buttonPaneContainer = a }, reInitPages: function (b, a, d, c) { this._initialized = false; this.options.startNumbers = a; this.options.proportion = b; this.options.pageHeight = c; this.initCanvasOffset(); this.initStorage() }, changeSelectedRowsStyle: function (b) { this.changeCustomAreasStyle(b); this.changeSearchStyle(b); var d = this.element.find(".highlight-pane .highlight"), c = b / this.options.proportion; this.options.proportion = b; a.each(d, function () { var b = a(this).position(); a(this).css({ top: b.top * c, left: b.left * c, width: a(this).width() * c, height: a(this).height() * c }) }) }, performSearch: function (W, mb, K, H, Q, F) { var d, T = false; if (K)d = W; else d = W.toLowerCase(); if (H && Q) { var t = d.replace(/^[\r\n\s]+|[\r\n\s]+$/g, ""); if (t.length >= 2 && t[0] == '"' && t[t.length - 1] == '"') { H = false; d = t.substr(1, t.length - 2); d = d.replace(/^[\r\n\s]+|[\r\n\s]+$/g, ""); T = true } } this.search.length = 0; this.initHighlightSearchPaneContainer(); if (d == "")return -1; this.searchProportions = mb; var P = this.pages, nb = P.length, l = [], A = [], i = [], o, qb, fb, gb, f, bb = 0, w, R; if (F)R = new RegExp(window.jGroupdocs.stringExtensions.getAccentInsensitiveRegexFromString(d)); for (var b, r = 0; r < nb; r++) { for (var ib = P[r].rows, ob = ib.length, pb = r + 1, c, x, y = 0; y < ob; y++) { var e = 0, h = 0, v = ib[y], u; if (K)u = v.text; else u = v.text.toLowerCase(); if (H) { i = this.getWords(d); if (F) { for (var U = [], O = 0; O < words.length; O++)U.push(new RegExp(window.jGroupdocs.stringExtensions.getAccentInsensitiveRegexFromString(i[O]))); i = U } o = i.length; if (o == 0)break; c = v.words; x = c.length; for (var B, p = 0; p < x; p++)for (B = 0; B < o; B++) { var D = a.trim(i[B]), N = c[p].text; if (!K) { D = D.toLowerCase(); N = N.toLowerCase() } w = N.indexOf(D); if (w != -1) { for (var g = this.options.pdf2XmlWrapper.getRowCharacterCoordinates(r, y), k = c[p].originalRect.left(), z = 0, j = 0; j < g.length; j++) { var I = g[j]; if (Math.round(I) >= Math.round(k)) { z = j; break } } var s = z + w; if (s < g.length)e = g[s]; else e = k; if (e < k || e > M)e = k; m = s + D.length; if (m >= g.length)h = v.originalRect.right(); else h = g[m]; b = c[p].rect.clone(); b.subtract(c[p].pageLocation); var E = this.options.proportion, eb = e * E, db = h * E; b.setLeft(eb); b.setRight(db); l.push(b); b = c[p].originalRect.clone(); b.setLeft(e); b.setRight(h); A.push(b) } } } else { var jb = this.options.proportion * this.options.pdf2XmlWrapper.getPageSize().width, q; if (F)q = u.search(R); else q = u.indexOf(d); while (q != -1) { c = v.words; if (this.options.searchPartialWords) { var ab = /\s/g, J = u.substring(0, q), cb = J.match(ab), Z = d.match(ab), n = 0, X = 0; if (cb)n = cb.length; if (Z)X = Z.length; var C = n + X, g = this.options.pdf2XmlWrapper.getRowCharacterCoordinates(r, y), k = c[n].originalRect.left(), lb = c[C].originalRect.left(), M = c[C].originalRect.right(), hb = v.originalRect.right(); w = J.length - J.lastIndexOf(" ") - 1; for (var z = 0, V = 0, S = false, j = 0; j < g.length; j++) { var I = g[j]; if (!S && Math.round(I) >= Math.round(k)) { z = j; S = true } if (Math.round(I) >= Math.round(lb)) { V = j; break } } var s = z + w; if (s < g.length)e = g[s]; else e = k; if (e < k || e > M)e = k; var kb = d.lastIndexOf(" "), G = d.substring(kb + 1, d.length), m; if (n == C)m = s + d.length; else m = V + G.length; var Y = true; if (m < g.length) { var L = c[C].text.toLowerCase(); if (L.substring(L.length - G.length, L.length) == G)h = M; else { h = g[m]; Y = false } } else h = hb; if (h < e)h = hb; if (!Q || !T || Y) { b = c[n].rect.clone(); b.subtract(c[n].pageLocation); var E = jb / P[r].originalWidth, eb = e * E, db = h * E; b.setLeft(eb); b.setRight(db); l.push(b); b = c[n].originalRect.clone(); b.setLeft(e); b.setRight(h); A.push(b) } q = u.indexOf(d, q + d.length) } else { i = this.getWords(d); o = i.length; if (o == 0)break; x = c.length; if (o == 1) { for (f = 0; f < x; f++)if (c[f].text.toLowerCase() == a.trim(i[0].toLowerCase())) { b = c[f].rect.clone(); b.subtract(c[f].pageLocation); l.push(b) } } else { fb = 0; gb = o - 1; for (f = 0; f < x; f++)if (c[f].text.toLowerCase() == a.trim(i[fb].toLowerCase())) { b = c[f].rect.clone(); b.subtract(c[f].pageLocation); b.setRight(b.left() + c[f + gb].rect.right() - c[f].rect.left()); l.push(b) } } q = -1 } } } } if (l.length > 0) { this.search.push({PageId: pb, pageWords: l.slice(0), pageWordsUnscaled: A.slice(0)}); bb += l.length; l.length = 0; A.length = 0 } } this.highlightSearch(null, null); return bb }, getWords: function (b) { return a.map(b.split(" "), function (a) { if (a != "")return a }) }, highlightSearch: function (g, h) { if (!this.search)return; var f = this.search; this.initHighlightSearchPaneContainer(); for (var e = 0; e < f.length; e++) { var d = f[e].PageId; if (g === null || h === null || d - 1 >= g && d - 1 <= h)for (var c = f[e].pageWords, b = 0; b < c.length; b++) { var i = window.jGroupdocs.stringExtensions.format(this.searchTemplate, this.pagePrefix + d + "-search-highlight-" + b, c[b].top(), c[b].height(), c[b].width(), c[b].left()); a("#" + this.pagePrefix + d + " div.search-pane").append(i) } } }, changeSearchStyle: function (d) { if (this.options.useVirtualScrolling || this.search.length == 0)return; this.initHighlightSearchPaneContainer(); for (var f = this.search, i = 0, m = f.length, c = this.searchProportions, l = this.highlightSearchPaneContainer, e = 0; e < m; e++) { for (var h = "", g = f[e].PageId, b = f[e].pageWords, k = b.length, a = 0; a < k; a++) { var q = Math.round(Math.round(b[a].width() / c) * d), n = Math.round(Math.round(b[a].height() / c) * d), p = Math.round(Math.round(b[a].top() / c) * d), o = Math.round((b[a].left() - i) / c * d + i), j = window.jGroupdocs.stringExtensions.format(this.searchTemplate, this.pagePrefix + g + "-search-highlight-" + a, p, n, q, o); h += j } l[g - 1].innerHTML = h } }, recalculateSearchPositions: function (c) { if (!this.options.useVirtualScrolling || this.search.length == 0)return; this.initHighlightSearchPaneContainer(); for (var h = this.search, l = h.length, d = 0; d < l; d++)for (var g = h[d], b = g.pageWordsUnscaled, k = b.length, j, i, f, e, a = 0; a < k; a++) { e = Math.round(b[a].left() * c); j = Math.round(b[a].width() * c); f = Math.round(b[a].top() * c); i = Math.round(b[a].height() * c); g.pageWords[a].set(e, f, e + j, f + i) } }, clearAllTimeOuts: function () { var a = this.timeouts, b = a.length; if (b > 0) { for (var c = b; c--;)clearTimeout(a[c]); a = [] } }, _getElementsByClassName: function (e, b) { if (!b)b = document.getElementsByTagName("body")[0]; for (var d = [], f = new RegExp("\\b" + e + "\\b"), c = b.getElementsByTagName("*"), a = 0, g = c.length; a < g; a++)f.test(c[a].className) && d.push(c[a]); return d }, highlightTemplateAreas: function (c, b) { this.customArea = a.extend(true, [], c); this.changeCustomAreasStyle(b) }, changeCustomAreasStyle: function (d) { if (typeof this.customArea === "undefined")return; if (this.customArea.length == 0)return; var f = this, e = this.customArea, g = 31, h = e.length; a("#" + this.options.docSpace.attr("id") + "-pages-container .custom-pane").html(""); var b = 0, c = ""; (function i() { for (var k = e[b].fields, s = k.length, l = e[b].PageId, j = 0; j < s; j++) { var o = Math.round(Math.round(k[j].Width) * d), t = Math.round(Math.round(k[j].Height) * d), n = Math.round(Math.round(k[j].Y) * d), m = Math.round((k[j].X - g) * d + g), q = f.cAreaPageIndex == b && f.cAreaFieldIndex == j ? "border-color:blue" : ""; c += "
"; var p = window.jGroupdocs.stringExtensions.format(f.addTemplate, this.pagePrefix + b + "-custom-check-" + j, n - 5, m + o - 8, k[j].iconType == 1 ? "selection-check" : "selection-del", b + "/" + j); c += p } ++b; var r = b < h ? e[b].PageId : -1; if (c != "" && r != l) { a("#" + this.pagePrefix + l + " .custom-pane").html(c); f.bindCustomHandler(l); c = "" } b < h && setTimeout(i, 0) })() }, bindCustomHandler: function (b) { var c = this; a("#" + this.pagePrefix + b + " div.input-overlay1, #" + this.pagePrefix + b + " div.selection-check, #" + this.pagePrefix + b + " div.selection-del").bind({ click: function () { var f = a(this).attr("index"), g = a("#doc-space").docAssemblyViewer("getViewModel"); if (typeof f !== "undefined") { var d = f.split("/"), e = d[0], b = d[1]; c.cAreaPageIndex = e; c.cAreaFieldIndex = b; g.moveTo({groupIndex: parseInt(e), fieldIndex: parseInt(b)}); return false } } }); a("#" + this.pagePrefix + b + " div.input-overlay1").bind({ mouseover: function (g) { var c = a(this).attr("index"), d = a("#doc-space").docAssemblyViewer("getViewModel"); if (typeof c !== "undefined") { var b = c.split("/"), f = b[0], e = b[1]; d.mouseover(g, {groupIndex: parseInt(f), fieldIndex: parseInt(e)}) } }, mouseout: function (g) { var c = a(this).attr("index"), d = a("#doc-space").docAssemblyViewer("getViewModel"); if (typeof c !== "undefined") { var b = c.split("/"), f = b[0], e = b[1]; d.mouseout(g, {groupIndex: parseInt(f), fieldIndex: parseInt(e)}) } } }) }, setCustomAreaIndex: function (a) { var c = a.pageIndex, b = a.fieldIndex; this.cAreaPageIndex = c; this.cAreaFieldIndex = b }, changeTemplateAreaIcon: function (b) { var d = this.customArea, f = d[b.pageIndex].fields, c = this.pagePrefix + "{0}-custom-check-{1}", e = window.jGroupdocs.stringExtensions.format(c, b.pageIndex, b.fieldIndex); a("#" + e).attr("class", b.iconType == 1 ? "selection-check" : "selection-del"); f[b.fieldIndex].iconType = b.iconType }, findSelectedPages: function (r, m, f, o, j) { if (this._mode != this.SelectionModes.SelectText && this._mode != this.SelectionModes.SelectTextToStrikeout)return; if (typeof f == "undefined")f = this.selectionCounter; var c = this._getDocumentHighlightRects(f); if (!c || c.length == 0)return; for (var g = null, l = null, s = "
", e = 0; e < c.length; e++) { var d = c[e].bounds, h = c[e].page + 1, t = c[e].row + 1; if (g == null || l != null && l != h) { g = this.element.find("#" + this.pagePrefix + h + " div.highlight-pane"); l = h } var n = this.pagePrefix + h + "-highlight-" + t + "-" + f, b = g.find("#" + n); if (b.length == 0) { var p = a(window.jGroupdocs.stringExtensions.format(s, n, d.top() + 2, d.height())); g.append(p); b = p } if (m) { var i = a._data(b.get(0), "events"); (!i || !i.click) && b.click(m) } if (j) { var i = a._data(b.get(0), "events"); (!i || !i.mouseover) && b.hover(j.mouseenter, j.mouseleave) } if (r) { b.addClass("static"); o && b.css("background-color", o) } b.css({left: d.left() - 1, width: d.width(), height: d.height()}); if (!this.options.bookLayout) { var u = this.pages[c[e].page], k = u.rotation; if (typeof k == "undefined")k = 0; var q = k % 180 > 0; q && b.css({top: d.top()}) } } }, _getDocumentHighlightRects: function (f) { var b = this.pages; if (b.length == 0)return null; for (var e = this, g = e.lasso, c = [], a = 0; a < b.length; a++)if (b[a] && g.intersects(b[a].rect)) { var d = e._getPageHighlightRects(a, f); if (d && d.length)c = c.concat(d) } return c }, _getPageHighlightRects: function (g, i) { for (var e = this.lasso, d = this.pages[g].rows, h = [], b = 0; b < d.length; b++) { if (!e.intersects(d[b].rect)) { this.dragged && a("#" + this.pagePrefix + (g + (this.options.bookLayout ? this.options.startNumbers.start : 1)) + "-highlight-" + (b + 1) + "-" + i + ":not(.static)").remove(); continue } var c = d[b].rect; if (e.left() < c.left() && e.bottom() > c.bottom() || e.right() > c.right() && e.top() < c.top() || e.bottom() > c.bottom() && e.top() < c.top()) { var k = new jSaaspose.Rect(c.left(), c.top() + 1, c.right(), c.bottom() - 1); k.subtract(d[b].pageLocation); var f = { bounds: k, originalRect: d[b].originalRect, text: "", page: g + (this.options.bookLayout ? this.options.startNumbers.start - 1 : 0), row: b, position: -1, length: 0 }; h.push(f); if (!this.dragged) { var j = d[b].words[d[b].words.length - 1]; f.text = d[b].text; f.position = d[b].words[0].position; f.length = j.position + j.text.length - f.position } } else { var f = this._getRowHighlightRect(g, b); if (f != null)h.push(f); else this.dragged && a("#" + this.pagePrefix + (g + (this.options.bookLayout ? this.options.startNumbers.start : 1)) + "-highlight-" + (b + 1) + "-" + i + ":not(.static)").remove() } } return h }, _getRowHighlightRect: function (w, x) { var e = this.lasso, p = Math.min(e.top(), e.bottom()), l = Math.max(e.top(), e.bottom()), u = this.pages[w], k = u.rotation; if (typeof k == "undefined")k = 0; for (var A = k % 180 > 0, f = u.rows[x], r = f.rect.top(), o = f.rect.bottom(), c = this._textSelectionByCharModeEnabled && f.chars ? f.chars : f.words, B = r < p && p < o && l >= o && !A, g = p <= r && r < l && l < o, n = g ? -1 : 1, b = g ? c.length - 1 : 0; b < c.length && b >= 0 && !e.intersects(c[b].rect); b += n)c[b].shown = false; if (b == c.length || b < 0)return null; for (var a = c[b], s = 0, q = 0, t = a.rect.left(), v = a.rect.top(), j = a.originalRect.left(), m = a.originalRect.top(), i = 0, h = 0, d = { bounds: null, text: "", page: w + (this.options.bookLayout ? this.options.startNumbers.start - 1 : 0), row: x, position: a.position, length: a.text.length }; b < c.length && b >= 0 && (g || B || e.intersects(c[b].rect)); b += n) { a = c[b]; a.shown = true; if (!this.dragged)if (!this._textSelectionByCharModeEnabled)d.text += a.text + " "; else if (this._textSelectionByCharModeEnabled)if (!a.isLastWordChar)d.text += a.text; else d.text += a.text + " "; t = Math.min(t, a.rect.left()); v = Math.min(v, a.rect.top()); s = Math.max(s, a.rect.right()); q = Math.max(q, a.rect.bottom()); j = Math.min(j, a.originalRect.left()); m = Math.min(m, a.originalRect.top()); i = Math.max(i, a.originalRect.right()); h = Math.max(h, a.originalRect.bottom()) } for (; b < c.length && b >= 0; b += n)c[b].shown = false; var y = new jSaaspose.Rect(t, v + 1, s, q - 1); y.subtract(u.rect.topLeft); d.bounds = y; var z = new jSaaspose.Rect(j, m + 1, i, h - 1); d.originalRect = z; d.length = a.position + a.text.length; return d }, _findPageAt: function (b) { if (this.pages != null)for (var a = 0; a < this.pages.length; a++)if (this.pages[a].rect.contains(b))return this.pages[a]; return null }, _findPageNearby: function (b) { for (var d = 0, e = 0, c = null, h = false, f = false, a = 0; a < this.pages.length; a++)if (this.pages[a].rect.contains(b))return this.pages[a]; else if (b.y >= this.pages[a].rect.top() && b.y <= this.pages[a].rect.bottom()) { var g = Math.abs(b.x - this.pages[a].rect.left()); if (!h || g < d) { d = g; h = true; c = a } } else if (b.x >= this.pages[a].rect.left() && b.x <= this.pages[a].rect.right()) { var i = Math.abs(b.y - this.pages[a].rect.top()); if (!f || i < e) { e = i; f = true; c = a } } return this.pages[c] }, findPageAtVerticalPosition: function (b) { for (var a = 0; a < this.pages.length; a++)if (b >= this.pages[a].rect.top() && b <= this.pages[a].rect.bottom() || b >= this.pages[a].rect.bottom() && a + 1 >= this.pages.length || b >= this.pages[a].rect.bottom() && b <= this.pages[a + 1].rect.top())return this.pages[a]; return null }, setTextSelectionMode: function (a) { this._textSelectionByCharModeEnabled = a }, setMode: function (b) { this._mode = b; if (b == this.SelectionModes.SelectText || b == this.SelectionModes.SelectTextToStrikeout) { if (this._lassoCssElement == null)this._lassoCssElement = a('').appendTo("head") } else if (this._lassoCssElement) { this._lassoCssElement.remove(); this._lassoCssElement = null } }, getMode: function () { return this._mode }, getRowsFromRect: function (f) { this.initStorage(); var c = null; this.lasso = f.clone(); this.lasso = new jSaaspose.Rect(Math.round(this.lasso.left()), Math.round(this.lasso.top()) + .001, Math.round(this.lasso.right()), Math.round(this.lasso.bottom()) - .001); for (var a = this._getDocumentHighlightRects(), b = 0; b < a.length; b++) { c = a[b].bounds; var d = this.pages[a[b].page].rect.topLeft.x - this.pages[0].rect.topLeft.x, e = this.pages[a[b].page].rect.topLeft.y; c.add(new jSaaspose.Point(d, e)) } return a } }) })(jQuery); if (!window.jGroupdocs)window.jGroupdocs = {}; window.jGroupdocs.Pdf2JavaScriptWrapper = function (a) { this.options = $.extend(true, {}, this.options, a); this.init() }; $.extend(window.jGroupdocs.Pdf2JavaScriptWrapper.prototype, { documentDescription: null, _portalService: Container.Resolve("PortalService"), proportion: 1, options: {userId: 0, privateKey: "", guid: ""}, init: function () { var a = this; this.documentDescription = JSON.parse(this.options.documentDescription) }, getPageCount: function () { return this.documentDescription.pages ? this.documentDescription.pages.length : typeof this.documentDescription.pageCount != "undefined" ? this.documentDescription.pageCount : 0 }, getPageSize: function () { var b = this.documentDescription.widthForMaxHeight, a = this.documentDescription.maxPageHeight; if (typeof b === "undefined" || typeof a === "undefined")if (this.documentDescription.pages) { var c = this.documentDescription.pages[0]; b = c.w; a = c.h } else b = a = null; return {width: b, height: a} }, getContentControls: function () { return this.documentDescription.contentControls }, getBookmarks: function () { return this.documentDescription.bookmarks }, getPages: function (c, a, e, g, k) { if (!this.documentDescription.pages)return null; var h = [], m = 0; this.proportion = c; var b = this.documentDescription.pages.length; if (b > 0 && a.length < b && a.length < g - e + 1)return null; var f = 100, j = Math.ceil(b / f), l = c * this.documentDescription.widthForMaxHeight, n = 0, d = function (u, i, g, o, r, w) { for (var q = false, e = i * f; e < b && e < (i + 1) * f; e++) { var h = this.documentDescription.pages[e], c; if (typeof o !== "undefined") { if (e < o)continue; if (e > r) { q = true; break } c = a[e - o] } else c = a[e]; var t = h.number; g = l / h.w; var k = h.rotation; if (typeof k == "undefined")k = 0; var n = h.w, p = h.h; if (k % 180 != 0)g *= n / p; var x = this.getRows(h, t, g, m, c), v = c.x + n * g, s = c.y + p * g; switch (k) { case 90: case 270: v = c.x + p * g; s = c.y + n * g } u.push({ pageId: t, rows: x, rect: new jSaaspose.Rect(c.x, c.y, v, s), originalWidth: n, rotation: h.rotation }) } if (w)return q; i++; i < j && !q && window.setTimeout(function () { d(u, i, g, o, r) }, 10) }.bind(this); if (k || this.options.synchronousWork) { for (var i = 0; i < j; i++)if (d(h, i, c, e, g, true))break } else window.setTimeout(function () { d(h, n, c, e, g) }, 10); return h }, getRows: function (c, o, b, l, d) { var f = c.rotation, h = c.w, g = c.h, q = []; if (c.rows)for (var k = 0; k < c.rows.length; k++) { var a = c.rows[k], t = this.getWords(a, o, b, l, d, f, h, g), s = this.getChars(a, o, b, l, d, f, h, g), e = this.getRotatedtextCoordinates(f, h, g, a.l, a.t, a.w, a.h), i = e.left, j = e.top, n = e.width, m = e.height, u = i * b, v = j * b, p = u + d.x, r = v + d.y, x = n * b, w = m * b; q.push({ text: a.s, words: t, chars: s, pageLocation: d, originalRect: new jSaaspose.Rect(i, j, i + n, j + m), rect: new jSaaspose.Rect(p, r, p + x, r + w) }) } return q }, getWords: function (d, x, c, w, h, o, q, p) { var k = [], f = [], l = [], v = d.s.split(" "); f = $.map(d.c, function (a, b) { if (b % 2 == 0)return a; else l.push(a) }); for (var a = 0; a < f.length; a++) { var b = this.getRotatedtextCoordinates(o, q, p, f[a], d.t, l[a], d.h), e = b.left, g = b.top, j = b.width, i = b.height, r = Math.round(e * c), s = Math.round(g * c), m = r + h.x, n = s + h.y, u = Math.round(j * c), t = Math.round(i * c); k.push({ text: v[a], pageLocation: h, originalRect: new jSaaspose.Rect(e, g, e + j, g + i), rect: new jSaaspose.Rect(m, n, m + u, n + t) }) } return k }, getChars: function (a, A, f, z, k, r, t, s) { var o = [], i = [], h = [], d = [], u = a.s.replace(/\s+/g, ""); if (a.ch) { for (var m = 1, b = 0; b < a.ch.length; b++) { if (a.s.charAt(b + m) == " ") { m++; d.push(true) } else b != a.ch.length - 1 && d.push(false); i.push(a.ch[b]); if (b < a.ch.length - 1)h.push(a.ch[b + 1] - a.ch[b]); else if (b == a.ch.length - 1) { d.push(true); h.push(a.w - a.ch[b]) } } for (var c = 0; c < i.length; c++) { var e = this.getRotatedtextCoordinates(r, t, s, i[c], a.t, h[c], a.h), g = e.left, j = e.top, n = e.width, l = e.height, v = Math.round(g * f), w = Math.round(j * f), p = v + k.x, q = w + k.y, y = Math.round(n * f), x = Math.round(l * f); o.push({ text: u.charAt(c), isLastWordChar: d[c], pageLocation: k, originalRect: new jSaaspose.Rect(g, j, g + n, j + l), rect: new jSaaspose.Rect(p, q, p + y, q + x) }) } } return o }, getRowCharacterCoordinates: function (b, c) { return this.documentDescription.pages[b].rows[c].ch }, reorderPage: function (b, c) { var a = this.documentDescription.pages, d = a[b]; a.splice(b, 1); a.splice(c, 0, d) }, getRotatedtextCoordinates: function (k, j, i, g, h, b, a) { var e = g, f = h, d = b, c = a; switch (k) { case 90: e = i - h - a; f = g; d = a; c = b; break; case 180: e = j - g - b; f = i - h - a; d = b; c = a; break; case 270: e = h; f = j - g - b; d = a; c = b } return {left: e, top: f, width: d, height: c} } }); (function (a) { a.widget("ui.navigation", { _viewModel: null, _pageCount: 0, _create: function () { if (this.options.createHtml)this._createHtml(); else this.options.createEmbeddedHtml && this._createEmbeddedHtml(); this._viewModel = this.getViewModel(); ko.applyBindings(this._viewModel, this.element.get(0)) }, _createViewModel: function () { var a = {pageInd: ko.observable(0), pageCount: ko.observable(0)}; a.up = function () { this.up() }.bind(this); a.down = function () { this.down() }.bind(this); a.selectPage = function (a) { this.set(a) }.bind(this); a.onKeyPress = function (b, a) { this.onKeyPress(a); return true }.bind(this); a.setPageIndex = function (a) { this.setPageIndex(a) }.bind(this); a.openFirstPage = function () { this.set(1) }.bind(this); a.openLastPage = function () { this.set(this._viewModel.pageCount()) }.bind(this); a.setPagesCount = function (a) { this.setPagesCount(a) }.bind(this); return a }, getViewModel: function () { if (!this._viewModel)this._viewModel = this._createViewModel(); return this._viewModel }, up: function () { var c = this._viewModel.pageInd(), d = this._viewModel.pageCount(), b; if (c <= 0)b = 1; else if (c > d)b = d; else b = c != 1 ? c - 1 : 1; this._viewModel.pageInd(b); a(this.element).trigger("onUpNavigate", b) }, down: function () { var b = this._viewModel.pageInd(), d = this._viewModel.pageCount(), c; if (b <= 0)c = 1; else if (b > d)c = d; else c = b != d ? parseInt(b) + 1 : b; this._viewModel.pageInd(c); a(this.element).trigger("onDownNavigate", c) }, "set": function (e) { var d = this._viewModel.pageInd(), b = this.setPageIndex(e), c = "up"; if (d > b)c = "down"; a(this.element).trigger("onSetNavigate", {pageIndex: b, direction: c}) }, setPageIndex: function (c) { var a = Number(c), b = this._viewModel.pageCount(); if (isNaN(a))a = 1; else if (a <= 0)a = 1; else if (a > b)a = b; this._viewModel.pageInd(a); return a }, openFirstPage: function () { this.selectPage(1) }, openLastPage: function () { this.selectPage(this.pageCount()) }, onKeyPress: function (a) { a.keyCode == 13 && this.set(this._viewModel.pageInd()) }, setPagesCount: function (a) { this._pageCount = a; this._viewModel.pageCount(a) }, _createHtml: function () { var b = this.element; b.addClass("left"); a('

of

').appendTo(b); b.trigger("onHtmlCreated") }, _createEmbeddedHtml: function () { var b = this.element; b.addClass("left"); a('

Page

of

').appendTo(b); b.trigger("onHtmlCreated") } }) })(jQuery); (function (a) { a.widget("ui.thumbnails", { _viewModel: null, _pageCount: 0, _sessionToken: "", _docGuid: "", _docVersion: 1, _pagesWidth: "150", _heightWidthRatio: 0, _thumbsSelected: 0, _thumbnailWidth: 150, _portalService: Container.Resolve("PortalService"), options: {quality: null, use_pdf: "false", baseUrl: null, userId: 0, userKey: null, supportPageRotation: false}, _create: function () { this.useHtmlThumbnails = this.options.useHtmlThumbnails; this.useHtmlBasedEngine = this.options.useHtmlBasedEngine; this.emptyImageUrl = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNgYAAAAAMAASsJTYQAAAAASUVORK5CYII="; if (this.options.supportPageReordering) { var b = this; ko.bindingHandlers.sortableArray = { init: function (e, d) { var c = d(); a(e).sortable({ axis: "y", update: function (h, e) { var f = e.item[0], d = ko.dataFor(f), g = c.indexOf(d), a = ko.utils.arrayIndexOf(e.item.parent().children(), f); e.item.remove(); if (a >= 0) { c.remove(d); c.splice(a, 0, d) } b.rootElement.trigger("onPageReordered", [g, a]) } }) } } } this.options.createHtml && this._createHtml(); if (this.options.thumbnailWidth)this._thumbnailWidth = this.options.thumbnailWidth; this._viewModel = this.getViewModel(); ko.applyBindings(this._viewModel, this.element.get(0)); this.options.useInnerThumbnails && ko.applyBindings(this._viewModel, this.toggleThuumbnailsButton[0]) }, _createViewModel: function () { var a = { thumbnails: ko.observableArray([]), pageInd: ko.observable(1), pageCount: ko.observable(0), busy: ko.observable(true) }; a._thumbnailHeight = ko.observable(201); a.useInnerThumbnails = this.options.useInnerThumbnails; a.openThumbnails = ko.observable(this.options.openThumbnails); a.element = this.element; a.rootElement = this.rootElement; a.thumbnailPanelElement = this.thumbnailPanelElement; a.emptyImageUrl = this.emptyImageUrl; if (this.useHtmlThumbnails)a.scale = ko.observable(0); a.scrollThumbnailsPanel = function (a) { this._onScrollLeftPanel(a) }.bind(this); a.selectPage = function (a) { this.set(a) }.bind(this); a.showThumbnails = function (c) { for (var b, a = 0; a < this.thumbnails().length; a++) { b = this.thumbnails()[a]; b.visible(c) } }; a.hideThumbnails = function () { this.showThumbnails(false) }; a.onProcessPages = function (f, e, a, c, b, d) { this.onProcessPages(f, e, a, c, b, d) }.bind(this); a.setThumbnailsScroll = function (a) { this.setThumbnailsScroll(a) }.bind(this); a.set = function (a) { this.set(a) }.bind(this); a.setPageWithoutEvent = function (a) { this.setPageWithoutEvent(a) }.bind(this); a.getThumbnailsPanelWidth = function () { var a = 0; if (this.useInnerThumbnails)a = this.element.parent().width(); return a }; a.toggleThumbnails = function () { this.openThumbnails(!this.openThumbnails()); this.rootElement.trigger("onResizeThumbnails", this.thumbnailPanelElement.width()) }; return a }, getViewModel: function () { if (!this._viewModel)this._viewModel = this._createViewModel(); return this._viewModel }, onProcessPages: function (a, D, v, x, o, y) { this._sessionToken = a.token; this._docGuid = a.guid; this._docVersion = a.version; this._viewModel.pageCount(a.page_count); !a.lic && this._viewModel.pageCount() > 3 && this._viewModel.pageCount(3); this._heightWidthRatio = parseFloat(a.page_size.Height / a.page_size.Width); var E = this._thumbnailWidth, h = false, f = null, k, p, e = null, z; if (a.documentDescription && a.documentDescription.pages) { h = true; f = a.documentDescription.pages; k = a.documentDescription.maxPageHeight; p = a.documentDescription.widthForMaxHeight; e = k / p * this._thumbnailWidth; z = e / k / o; if (this.useHtmlThumbnails) { this.getDocumentPageHtmlCallback = v; this.viewerViewModel = x; this._viewModel.docViewerId = y; var w = this.element.width() } } for (var n = [], b, j, g, c, i, r = 47, A = this._viewModel.pageCount(), u, s, t, q, d = 0; d < A; d++) { b = { number: d + 1, busy: ko.observable(true), visible: ko.observable(false), url: ko.observable(this.emptyImageUrl) }; if (h) { if (d < f.length) { u = f[d].w; s = f[d].h; var m = s / u, l = f[d].rotation; if (typeof l == "undefined")l = 0; if (l % 180 != 0)m = 1 / m; g = this._thumbnailWidth; c = this._thumbnailWidth * m; if (c > e) { t = e / c; c = e; g = this._thumbnailWidth * t } } else { g = this._thumbnailWidth; c = 215 } b.width = ko.observable(g); b.height = ko.observable(c); j = 0; i = ""; if (c < r) { j = ((r - c) / 2).toString(); i = "white" } b.verticalPadding = ko.observable(j); b.backgroundColor = ko.observable(i); b.wrapperHeight = e; b.scale = ko.observable(c / f[d].h / o); q = (w - g) / 2; b.thumbLeftCoord = ko.observable(q); if (this.useHtmlThumbnails)b.htmlContent = D[d].htmlContent } n.push(b) } this._viewModel.thumbnails(n); var C = parseInt(this._heightWidthRatio * E), B = ""; if (!h)B = ".grpdx .thumbnailsContainer .thumb-page{min-height:" + C.toString() + "px}"; this.loadThumbnails() }, loadThumbnails: function () { var a = Math.ceil(this.element.height() / parseInt(this._heightWidthRatio * 150)); this._countToShowOnThumbDiv = a; this._thumbsCountToShow = Number(a) + Math.ceil(Number(Number(a) / 2)); this._thumbsSelected = this._thumbsCountToShow; this.retrieveImageUrls(this._viewModel.pageCount()) }, retrieveImageUrls: function (a) { this._portalService.getImageUrlsAsync(this.options.userId, this.options.userKey, this._docGuid, this._thumbnailWidth.toString() + "x", this._sessionToken, 0, a, this.options.quality, this.options.use_pdf, this._docVersion, null, null, null, null, this.options.ignoreDocumentAbsence, this.options.useHtmlBasedEngine, this.options.supportPageRotation, function (c) { for (var b = 0; b < a; b++)this._viewModel.thumbnails()[b].url(c.data.image_urls[b]); this._onScrollLeftPanel() }.bind(this), function () { for (var b = 0; b < a; b++)this.makeThumbnailNotBusy(b) }.bind(this), this.options.instanceIdToken, this.options.locale) }, makeThumbnailNotBusy: function (b) { var a = this._viewModel.thumbnails()[b]; a.busy(false) }, _onScrollLeftPanel: function () { for (var e = this._viewModel.pageCount(), j = this._thumbnailWidth, b = this.element, d = b.find(".thumb-page:first").outerHeight(false), f = b.scrollTop(), i = b.height(), g = Math.floor(f / d), c = Math.floor((f + i) / d) + 1, h = c < e - 2 ? c + 2 : e, a = g; a < h; a++) { this.useHtmlThumbnails && this.getDocumentPageHtmlCallback.call(this.viewerViewModel, a); this._viewModel.thumbnails()[a].visible(true) } this._thumbsSelected = c }, setThumbnailsScroll: function (f) { var d = f.pi; if (this._viewModel.pageInd != d) { this._viewModel.pageInd(d); !f.eventAlreadyRaised && this.element.trigger("onSetThumbnailsScroll", d) } var e = this.element.offset().top, c = this.element.children("ul").children("li:nth-child(" + this._viewModel.pageInd() + ")"); if (c.length == 0)return; var b = c.offset().top, h = b - a(window).height(), i = b + c.height() - e, g = this.element.scrollTop(), j = b - e; (h > 0 || i < 0) && this.element.scrollTop(g + j) }, "set": function (b) { this._viewModel.pageInd(b); a(this.element).trigger("onSetThumbnails", b) }, setPageWithoutEvent: function (a) { this._viewModel.pageInd(a) }, setPagesCount: function (a) { this._pageCount = a; this._viewModel.pageCount(a) }, _createHtml: function () { var c = this.element, b; if (this.options.supportPageReordering)b = "foreach: thumbnails, sortableArray: thumbnails"; else b = "foreach: thumbnails"; this.element = a('
  • ' + (this.useHtmlThumbnails ? "
    " : '
    ") + '
'); if (this.options.useInnerThumbnails) { this.thumbnailPanelElement = a('
'); this.element.appendTo(this.thumbnailPanelElement); this.toggleThuumbnailsButton = a('
'); this.toggleThuumbnailsButton.appendTo(this.thumbnailPanelElement); this.thumbnailPanelElement.prependTo(c) } else this.element.appendTo(c); this.rootElement = c } }) })(jQuery); (function (a) { fileOpenDialogViewModel = function (a, c, b) { this.fileOpenDialog = a; this.fileUploader = c; this.fileExplorer = b; this._init() }; a.extend(fileOpenDialogViewModel.prototype, { _explorerViewModel: null, _uploaderElements: [], _init: function () { this.fileExplorer.bind("onPathChanged", this._onExplorerPathChanged.bind(this)); this.fileExplorer.bind("onNodeSelected", this._onExplorerNodeSelected.bind(this)); this._explorerViewModel = a(this.fileExplorer).explorer("getViewModel"); this.fileUploader.bind("onStart", this._onFileUploaderStart.bind(this)); this.fileUploader.bind("onProgress", this._onFileUploaderProgress.bind(this)); this.fileUploader.bind("onComplete", this._onFileUploaderComplete.bind(this)) }, _onExplorerPathChanged: function () { }, _onExplorerNodeSelected: function (c, b) { b.id > 0 && b.type === "file" && a(this.fileOpenDialog.fileExplorer).trigger("fileSelected", b) }, _onFileUploaderStart: function (d, c, a, b) { this._explorerViewModel.busy(true); this._uploaderElements[c] = this._explorerViewModel.createFile(a, b) }, _onFileUploaderProgress: function (f, e, d, c, b) { b > 0 && a(this.fileOpenDialog.explorerProgressPercentage).text(Math.round(c / b * 100) + " %") }, _onFileUploaderComplete: function (f, b, d) { var c = this._uploaderElements, e = this._explorerViewModel; a(this.fileOpenDialog.explorerProgressPercentage).text("100 %"); e.busy(false); if (b && d) { c[b].id = d.id; c[b].guid = d.guid; c[b].url = d.url; c[b].Name = d.name; c[b].docType(d.docType); c[b].sizeInKb(Math.round(d.size / 1024)); c[b].version = d.version; c[b].path = e.path() + "/" + d.name; c[b].name(d.name); c[b].uploading(false); c[b].open() } else e._removeEntity(c[b]) } }) })(jQuery); (function (a) { a.widget("ui.fileOpenDialog", { _viewModel: null, options: { autoOpen: true, url: "", uploadWebFiles: false, fileTypes: "doc,docx,docm,dot,dotx,dotm,rtf,odt,ott,pdf", resourcePrefix: "" }, _create: function () { var b = this, k = b.options, g = this.element; g.addClass("modal fade modal2 modal800px"); var e = (b.wrapper = a("
")).addClass("modal_inner_wrapper").prependTo(g); this._buildDialogHeader(e); var i = (b.content = a("
")).addClass("modal_content").appendTo(e), h = (b.inputWrapLeft = a("
")).addClass("modal_input_wrap_left").appendTo(i), f = (b.fileExplorer = a("
")).addClass("file_browser_content").appendTo(h); this._buildFileUploader(f, b); var c = (b.filesArea = a("
")).attr("data-bind", "fileDnD: {}").css({position: "relative"}).appendTo(f), j = a("
").css({position: "relative"}).appendTo(c), d = a("
").addClass("file_browser_sort").appendTo(c); this._buildExplorerHeaders(d, "file_browser_sort_filename", "Name", "File Name", "FileName"); this._buildExplorerHeaders(d, "file_browser_sort_size", "Size", "Size", "Size"); this._buildExplorerHeaders(d, "file_browser_sort_modified", "ModifiedOn", "Modified", "Modified"); this._buildFoldersList(c); this._buildFilesList(c); this._buildFooter(e); this.element.trigger("onHtmlCreated"); this._viewModel = this.getViewModel() }, _init: function () { }, _buildDialogHeader: function (b) { var e = a("
").addClass("popclose").attr("data-dismiss", "modal").appendTo(b), c = a("
").addClass("modal_header").appendTo(b), d = a("

").text("Open File").attr("data-localize", "OpenFile").appendTo(c) }, _buildFileUploader: function (d, c) { var b = (c.fileUploader = a("
")).addClass("file_browser_toolbar").css({ position: "relative", display: "inline-block", overflow: "hidden" }).appendTo(d), g = a("").appendTo(b), e = a("").addClass("small_button file_browser_upload_btn").attr("data-localize", "ParentFolder").attr("data-bind", "click: function () { $parent.openParentFolder();}").text("Parent folder").appendTo(b), h = a("").appendTo(b); if (c.options.uploadWebFiles)var f = (c.openFromUrlButton = a("")).addClass("small_button").text("Open From URL").appendTo(b) }, _buildExplorerProgress: function (d) { var c = a("
").attr("data-bind", "visible: busy()").addClass("explorer-progress").appendTo(d), b = a("
").css({ position: "relative", top: "50px", left: "50%", width: "96px", height: "56px" }).appendTo(c), f = a("").attr("src", this.options.resourcePrefix + "Images/uploading.gif").attr("alt", "").css({ width: "16px", height: "16px" }).appendTo(b), g = a("
").appendTo(b), e = (self.explorerProgressPercentage = a("")).attr("id", "explorer-progress-percentage").appendTo(b) }, _buildExplorerHeaders: function (g, e, b, f, d) { var c = a("").attr("href", "#").attr("data-bind", 'click: function() { setOrder("' + b + '");}').addClass(e).appendTo(g), i = a("

").text(f).attr("data-localize", d).appendTo(c), h = a("").addClass("smallarrow").attr("data-bind", "visible: orderBy() === '" + b + "', css: {up: orderAsc(), down: !orderAsc()}").appendTo(c) }, _buildFoldersList: function (e) { var d = a("
    ").addClass("file_browser_folder_list").attr("data-bind", "foreach: folders").appendTo(e), c = a("
  • ").attr("data-bind", "attr: { id: 'explorer-entity-' + id }, click: open").appendTo(d), b = a("
    ").addClass("file_browser_listbox folderlist").appendTo(c), f = a("").addClass("listicons licon_folder").appendTo(b), g = a("

    ").addClass("listname_file_browser foldername").attr("data-bind", "text: name()").appendTo(b) }, _buildFilesList: function (e) { var d = a("
      ").addClass("file_browser_file_list").attr("data-bind", "foreach: files").appendTo(e), c = a("
    • ").attr("data-bind", "attr: { id: 'explorer-entity-' + id }, click: open").appendTo(d), b = a("
      ").addClass("file_browser_listbox filelist").appendTo(c), f = a("").addClass("listicons").attr("data-bind", "css: { 'licon_unkwn': (docType() != 'words' && docType() != 'pdf' && docType() != 'slides' &&docType() != 'cells' && docType() != 'image' && docType() != 'email' && docType() != 'diagram' && docType() != 'project' && docType() != 'taggedimage'), 'licon_word': docType() == 'words', 'licon_pdf': docType() == 'pdf', 'licon_ppt': docType() == 'slides', 'licon_xls': docType() == 'cells', 'licon_bmp': (docType() == 'image' || docType() == 'taggedimage'), 'licon_outlook': docType() == 'email', 'licon_visio': docType() == 'diagram', 'licon_mpp': docType() == 'project' }").appendTo(b), g = a("

      ").addClass("listname_file_browser filenameellipses").attr("data-bind", "text: name(), ellipsis: true").appendTo(b), h = a("

      ").addClass("listfilesize listsmalltext").attr("data-bind", "text: (sizeInKb() + 'Kb')").appendTo(b); a("

      ").addClass("listfilesize listsmalltext").attr("data-bind", "text: modifiedOn()").appendTo(b) }, _buildFooter: function (c) { var b = (self.footer = a("
      ")).addClass("modal_footer").appendTo(c), d = a("
      ").addClass("modal_btn_wrapper").appendTo(b) }, _createViewModel: function () { var f = this.options.hostUrl, c = this.options.userId, b = this.options.userKey, d = a(this.fileExplorer).explorer({ userId: c, privateKey: b, pageSize: 30, fileTypes: this.options.fileTypes, urlHashEnabled: this.options.urlHashEnabled, instanceIdToken: this.options.instanceIdToken }), e = a(this.fileUploader).uploader({ url: f, userId: c, key: b, proxy: "Uploader.aspx", fld: "", multiple: true, addFileBtn: a(this.uploadButton) }); return new fileOpenDialogViewModel(this, e, d) }, getViewModel: function () { if (!this._viewModel)this._viewModel = this._createViewModel(); return this._viewModel }, destroy: function () { a.Widget.prototype.destroy.call(this) } }) })(jQuery); (function (a, b) { a.widget("ui.explorer", { _viewModel: null, _init: function () { var b = this; this._viewModel = this.getViewModel(); this._viewModel.path.subscribe(function (b) { a(this.element).trigger("onPathChanged", [b]) }.bind(this)); a(this._viewModel).bind("onNodeSelected", function (d, c, b) { a(this.element).trigger("onNodeSelected", [c, b]) }.bind(this)); ko.applyBindings(this._viewModel, this.element.get(0)) }, _createViewModel: function () { return new explorerViewModel(this._getViewModelOptions()) }, _getViewModelOptions: function () { return { userId: this.options.userId, userKey: this.options.privateKey, pageSize: this.options.pageSize, fileTypes: this.options.fileTypes, startupPath: this.options.startupPath, view: this.options.view, urlHashEnabled: this.options.urlHashEnabled, instanceIdToken: this.options.instanceIdToken } }, getViewModel: function () { if (!this._viewModel)this._viewModel = this._createViewModel(); return this._viewModel }, setFilter: function (a) { this._viewModel.setFilter(a) }, setOrder: function (a) { this._viewModel.setFilter(a) } }); explorerModel = function (b) { a.extend(this.options, b); this._init() }; a.extend(explorerModel.prototype, { _portalService: Container.Resolve("PortalService"), _path: "", _entitiesLoaded: 0, _entitiesTotal: 0, _filter: {name: "", types: null}, _order: {by: ko.observable("Name"), asc: ko.observable(true)}, options: {userId: "", userKey: "", pageSize: 30, extended: false}, _init: function () { }, _loadPage: function (b, c, d, a) { this._portalService.loadFileBrowserTreeData(this.options.userId, this.options.userKey, c, b ? b : 0, this.options.pageSize, this._order.by(), this._order.asc(), this._filter.name, this._filter.types, this.options.extended, function (b) { if (b.textStatus === "success") { this._entitiesLoaded += b.data.nodes.length; this._entitiesTotal = b.data.count; d.apply(this, [c, b.data.nodes]) } else a.apply(this, []) }.bind(this), function (b) { a.apply(this, [b]) }.bind(this), false, this.options.instanceIdToken) }, openFolder: function (c, b, a) { this._path = c || ""; this._entitiesLoaded = 0; this._entitiesTotal = 0; this._loadPage(0, this._path, b, a) }, loadMore: function (b, a) { if (this._entitiesLoaded >= this._entitiesTotal)return false; var c = Math.ceil(this._entitiesLoaded / this.options.pageSize); this._loadPage(c, this._path, b, a); return true }, createFolder: function (a, c, b) { this._portalService.createFolderAsync(this.options.userId, this.options.userKey, a, function (d) { if (d.data > 0)c.apply(this, [a, d.data]); else b.apply(this, [a, null, d.data]) }.bind(this), function (c) { b.apply(this, [c, a]) }.bind(this)).Subscribe() }, setFilter: function (a) { this._filter.name = a.name; this._filter.types = a.types }, setOrder: function (a) { if (this._order.by() == a) { var b = !this._order.asc(); this._order.asc(b) } else { this._order.asc(true); this._order.by(a) } } }); explorerViewModel = function (a) { this._init(a) }; a.extend(explorerViewModel.prototype, { _model: null, _filtering: false, _ordering: false, _userId: null, _userKey: null, urlHashEnabled: true, busy: ko.observable(false), path: ko.observable(""), entities: ko.observableArray(), files: ko.observableArray(), folders: ko.observableArray(), changedUrlHash: false, view: ko.observable("listing"), _init: function (a) { this._model = this._createModel(a); this._userId = a.userId; this._userKey = a.userKey; if (typeof a.urlHashEnabled != "undefined")this.urlHashEnabled = a.urlHashEnabled; this.busy = ko.observable(false); this.path = ko.observable(""); this.entities = ko.observableArray(); this.files = ko.observableArray(); this.folders = ko.observableArray(); this.isNotRootFolder = ko.computed({ read: function () { return !(this.path() === "") }, owner: this }); !a.skipStartupPathLoad && this.openFolder(a.startupPath) }, _createModel: function (a) { return new explorerModel(a) }, _addRoot: function () { var a = this._createEntity("Home", "folder"); a.path = ""; this.entities.push(a); return a }, _onEntitiesLoaded: function (c, d) { var b = this; if (b._filtering || b._ordering || c != b.path()) { b.entities.removeAll(); b.files.removeAll(); b.folders.removeAll() } a.each(d, function () { if (!this.extended) { var a = this; b._extendEntity(a); b.entities.push(a) } if (this.type == "file")b.files.push(this); else b.folders.push(this) }); b._filtering = false; b._ordering = false; b.path(c); if (this.urlHashEnabled) { this.changedUrlHash = true; location.hash = b.view() + "#" + c; this.changedUrlHash = false } b.busy(false) }, _onNetworkError: function (a) { this.busy(false); jerror(a.Reason || a) }, _extendEntity: function (b) { var c = this, d = b.supportedTypes ? a.map(b.supportedTypes, function (a) { return a.toUpperCase() }) : []; a.extend(b, { extended: true, name: ko.observable(b.name), uploading: ko.observable(false), isNewVersion: false, processingOnServer: false, sizeInKb: ko.observable(Math.round(b.size / 1024)), docType: ko.observable(b && b.docType ? b.docType.toLowerCase() : ""), modifiedOn: function () { return isNaN(b.modifyTime) || b.modifyTime < 0 ? "---" : (new Date(b.modifyTime)).format("mmm dd, yyyy") }, percentCompleted: ko.observable(0), uploadSpeed: ko.observable(0), remainingTime: ko.observable(0), supportedTypes: ko.observableArray(d), thumbnail: ko.observable(b.thumbnail), selected: ko.observable(false), isVisible: ko.observable(true), viewJobId: ko.observable(null), viewJobPoller: null }); b.statusText = ko.computed(function () { return this.viewJobId() && this.viewJobId() > 0 ? "Server-side processing ..." : "Time remaining: " + this.remainingTime() + " secs @ " + this.uploadSpeed() + " kb/Sec." }, b); b.open = function (d) { if (b.type === "file")a(c).trigger("onNodeSelected", [b, d]); else c.openFolder(b.path) }; b.viewJobId.subscribe(function (a) { if (a && a > 0) { b.processingOnServer = true; this.viewJobPoller = new jobPoller({ userId: c._userId, userKey: c._userKey, jobId: a, completed: function () { b.uploading(false); b.processingOnServer = false; b.viewJobPoller = null }, failed: function () { b.uploading(false); b.processingOnServer = false; b.viewJobPoller = null }, timedout: function () { b.uploading(false); b.processingOnServer = false; b.viewJobPoller = null } }); this.viewJobPoller.start() } }) }, _findEntity: function (c, d) { for (var b = 0; b < this.entities().length; b++) { var a = this.entities()[b]; if (a.name().toLowerCase() == c.toLowerCase() && a.type == d)return a } return null }, _findEntityAt: function (c, d) { for (var b = 0; b < this.entities().length; b++) { var a = this.entities()[b]; if (a.path().toLowerCase() == c.toLowerCase() && a.type == d)return a } return null }, _createEntity: function (c, f, e, d) { var a = { id: 0, path: (this.path().trim("/") + "/" + (d ? d : c)).trim("/"), name: c, type: f, docType: "undefined", time: (new Date).getTime(), modifyTime: (new Date).getTime(), url: b, isKnown: false, fileCount: 0, folderCount: 0, supportedTypes: [], selected: false, size: e }; this._extendEntity(a); return a }, _getPathLevel: function (a) { return a && a.length > 0 ? a.length - a.replace(/\/+/g, "").length + 1 : 0 }, getSelectedEntities: function () { return a.map(this.entities(), function (a) { if (a.id && a.selected())return a }) }, openFolder: function (a) { if (this.busy())return; this.busy(true); this._model.openFolder(a, this._onEntitiesLoaded.bind(this), this._onNetworkError.bind(this)) }, openParentFolder: function () { var b = this.path().lastIndexOf("/"), a = this.path().substr(0, b > 0 ? b : 0); a != this.path() && this.openFolder(a) }, loadMore: function () { !this.busy() && this.busy(this._model.loadMore(this._onEntitiesLoaded.bind(this), this._onNetworkError.bind(this))); return this.busy() }, createFile: function (c, d) { var b = this._findEntity(c, "file"); if (b) { b.uploading(true); b.isNewVersion = true; return b } var e = this, a = this._createEntity(c, "file", d); a.uploading(true); a.isNewVersion = false; this.entities.push(a); this.files.unshift(a); return a }, entityExists: function (a, b) { return this._findEntity(a, b) != null }, setFilter: function (a) { this._filtering = true; this._model.setFilter(a); this.openFolder(this.path()) }, setOrder: function (a) { this._ordering = true; this._model.setOrder(a); this.openFolder(this.path()) }, orderBy: function () { return this._model._order.by() }, orderAsc: function () { return this._model._order.asc() }, findEntity: function (a, b) { return this._findEntity(a, b) }, isNullOrWhiteSpace: function (a) { return a === null || a == "undefined" || a.match(/^ *$/) !== null } }) })(jQuery); var OverrideMode = {Override: 0, Rename: 1, Break: 2, Skip: 3}; (function (a, b) { a.widget("ui.uploader", { _appender: null, _handler: null, options: { multiple: true, userId: b, key: "", url: "", proxy: "", fld: "documents", formats: "", onComplete: null, onStart: null, addFileBtn: null, skipErrors: false, delayedStart: false, isForUserStorage: false, overrideMode: OverrideMode.Override }, _initHandler: function () { if (this._handler == null) { var b = Container.Resolve("HttpProvider").buildUrl(this.options.url, this.options.proxy, { user_id: this.options.userId, fld: this.options.fld }); this._handler = a.handlerFactory.get({ multiple: this.options.multiple, baseServerHost: this.options.url, isForUserStorage: this.options.isForUserStorage, folder: this.options.fld, action: this.options.key ? Container.Resolve("HttpProvider").signUrl(b, this.options.key) : b, skipErrors: this.options.skipErrors, overrideMode: this.options.overrideMode }); a(this._handler).hitch("onComplete", this._onComplete, this); a(this._handler).hitch("onProgress", this._onProgress, this); a(this._handler).hitch("onStart", this._onStart, this) } }, _initAppender: function () { if (this._appender == null) { var b = this; this._appender = new FileAppender({ container: this.element, multiple: !this._handler.sync, _addFileBtn: this.options.addFileBtn, onAddItemAction: function (c) { if (b.options.delayedStart)a(b.element).trigger("onFileSelected", [a.fileInputUtils.getName(c), c]); else b._uploadFile(c) } }) } }, _create: function () { this._initHandler(); this._initAppender() }, _onCancel: function (b) { var a = b.data; this._handler.cancel(a) }, _onComplete: function (d, c, b) { if (this.options.onComplete)this.options.onComplete.apply(this, [c, b]); else a(this.element).trigger("onComplete", [c, b]) }, _beforeStart: function (a) { return this.options.beforeStart ? this.options.beforeStart(a) : true }, _onStart: function (e, d, b, c) { if (this.options.onStart)this.options.onStart.apply(this, [d, b, c]); else a(this.element).trigger("onStart", [d, b, c]) }, _onProgress: function (h, g, d, e, f, b, c) { if (this.options.onProgress)this.options.onProgress.apply(this, [g, d, e, f, b, c]); else a(this.element).trigger("onProgress", [g, d, e, f, b, c]) }, _uploadFile: function (f, c) { var b = this._handler.add(f, jSaaspose.utils.getSequenceNumber()), e = this._handler.getPath(b); if (typeof c !== "undefined")this._handler.overrideMode = c; if (!this._beforeStart(e)) { this._handler.cancel(b); return } var d = this._addFileItem(b, e); if (this.options.formats == "" || this.options.formats.indexOf(d.ext.toLowerCase()) != -1) { a(this.element).trigger("onAdded", [d, null]); this._handler.upload(b) } else a(this.element).trigger("onAdded", [null, "Not allowed format"]); return b }, upload: function () { throw new ("not implemented"); }, uploadFile: function (b, a) { return this._uploadFile(b, a) }, cancelUploadFile: function (a) { this._handler.cancel(a) }, _addFileItem: function (c, a) { return {id: c, name: a, ext: this._getExt(a)} }, _getExt: function (a) { return Container.Resolve("PathProvider").getExt(a).toUpperCase() }, _setOption: function (b, c) { a.Widget.prototype._setOption.call(this, b, c); if (b === "fld") { this._handler = null; this._initHandler() } } }); UploadHandlerBasic = function (b) { a.extend(this, b) }; a.extend(UploadHandlerBasic.prototype, { action: "", _inputs: {}, sync: true, skipErrors: false, getPath: function (b) { return a.fileInputUtils.getPath(this._inputs[b]) }, getSize: function (c) { var b = this._inputs[c]; return a.fileInputUtils.getSize(b) }, add: function (b, c) { this._inputs[c] = b; a(b).detach(); return c }, upload: function (a) { this._upload(a) }, cancel: function (a) { this._cancel(a) }, _parseResponse: function (a) { try { var b = eval("(" + a + ")") } catch (c) { throw"Error in file processing at server side:" + a; } return b }, _upload: function () { }, _cancel: function () { } }); IFrameHandler = function () { UploadHandlerBasic.apply(this, arguments) }; a.extend(IFrameHandler.prototype, UploadHandlerBasic.prototype, { _upload: function (c) { var e = this._inputs[c], f = Container.Resolve("PathProvider").getName(this.getPath(c)); a(e).attr("name", f); var d = this._createForm(c), b = this._createIFrame(c); d.append(e); var g = b.get(0).document ? b.get(0).document : b.get(0).contentDocument ? b.get(0).contentDocument : b.get(0).contentWindow.document; g.body.appendChild(d.get(0)); b.hitch("load", function () { var d = this._getIframeContentJSON(b[0]); a(this).trigger("onComplete", [c, d.success ? d.parsed : null]); delete this._inputs[c]; setTimeout(function () { b.remove() }, 1) }, this); a(this).trigger("onStart", [c, f]); d.submit(); d.remove() }, _createForm: function (c) { var b = a('
      '); b.attr("id", "form" + c); b.attr("target", "iframe" + c); b.attr("action", this.isForUserStorage ? this._buildUriForIframeAction() : this.action); return b }, _buildUriForIframeAction: function () { var b = ""; a.ajax({ url: this.baseServerHost + "getFileUploadUrl", data: "path=" + this.folder + "&forIframe=true", async: false, success: function (a) { b = a } }); return b }, _createIFrame: function (c) { var b = a('").appendTo("body"); o = v(h) } o.write("
      " + r + "
      " + e.popupWindowTitle + ""); i = a(o).find("form") } i.submit() } setTimeout(u, e.checkInterval); function u() { if (document.cookie.indexOf(e.cookieName + "=" + e.cookieValue) != -1) { k.onSuccess(f); document.cookie = e.cookieName + "=; expires=" + (new Date(1e3)).toUTCString() + "; path=" + e.cookiePath; s(false); return } if (g || h)try { var b = g ? g.document : v(h); if (b && b.body != null && b.body.innerHTML.length) { var d = true; if (i && i.length) { var c = a(b.body).contents().first(); if (c.length && c[0] === i[0])d = false } if (d) { k.onFail(b.body.innerHTML, f); s(true); return } } } catch (j) { k.onFail(j.message, f); s(true); return } setTimeout(u, e.checkInterval) } function v(b) { var a = b[0].contentWindow || b[0].contentDocument; if (a && a.document)a = a.document; return a } function s(a) { setTimeout(function () { if (g) { l && g.close(); if (p) { g.focus(); a && g.close() } } }, 0) } function t(a) { return a.replace(d, function (a) { return "&" + c[a] }) } return n.promise() } }) })(jQuery, this);




      © 2015 - 2025 Weber Informatics LLC | Privacy Policy