Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (top == window) {
- var fnNameSpace = "fntoolbar";
- if (typeof window[fnNameSpace] == "undefined") {
- window[fnNameSpace] = {}
- }
- window[fnNameSpace].Manager = function() {
- var TOOLBAR_IFRAME_ID = "fn_layer8";
- var RELOCATE_TOOLBAR_ON_LOAD_INTERVAL = 1000;
- var ATTEMP_TO_RELOCATE_TOOLBAR_AFTER_LOAD_TIMEOUT = 5000;
- var SCREEN_OVERLAY_ID = "fnscreenOverlay";
- var toolbarsById = new Object();
- this.toolbarsById = toolbarsById;
- this.toolbarsZIndex = 2147483646;
- this.toolbarData;
- this.currentToolbar;
- this.isRestorePreviousViewportNeeded = false;
- this.initialToolbarBindingIntervalMethod = false;
- this.lastNotifiedOrientation;
- this.tbstatus = {
- isMinimize: undefined,
- suspendDragDrop: false
- };
- this.flashPlayerManager = undefined;
- this.enableFlashPlayerManager = true;
- this.updateScrollTimerId = 0;
- this.isToolbarSrcReloaded = false;
- this.monitorScrollDown = false;
- this.l8FocusState = false;
- this.lastWindowAndScreenSizes = {
- windowWidth: 0,
- windowHeight: 0,
- screenWidth: 0,
- screenHeight: 0
- };
- this.screenOverlayElement = undefined;
- this._scriptInjectionRequestTimeouts = {};
- this.initManager = function() {
- try {
- this.initGlobals();
- this.calculateMaxZIndex();
- this.isMobileAwareSite = window[fnNameSpace].ViewPort.isMobileAwareSite();
- this.lastNotifiedOrientation = window[fnNameSpace].displayUtils.isPortrait();
- window[fnNameSpace].message.assignTo(this);
- this.initToolbarData();
- var loadedTB = this.loadToolbar(TOOLBAR_IFRAME_ID, "portrait");
- if (loadedTB === false) {
- throw "No toolbars found"
- }
- this.appendScreenOverlayLayout(SCREEN_OVERLAY_ID);
- if (typeof window[fnNameSpace].OverlayTextBox !== "undefined") {
- window[fnNameSpace].OverlayTextBox.appendScreenOverlayTextBoxLayout()
- }
- this.initManagerDevice();
- this.setCurrentToolbar(toolbarsById[TOOLBAR_IFRAME_ID]);
- if (!this.currentToolbar) {
- throw "No toolbar is set!"
- }
- window[fnNameSpace].EventRegister(this.eventsToRegister);
- if (this.enableFlashPlayerManager) {
- this.flashPlayerManager = new window[fnNameSpace].FlashPlayerManager();
- this.flashPlayerManager.modifyFlashPlayerWmode()
- }
- this.notifyManagerIsUp();
- this.setToolbarLocationAfterPageLoad()
- } catch (ex) {
- return false
- }
- };
- if (!this.startIos7FixResizeInterval) {
- this.startIos7FixResizeInterval = function() {}
- }
- this.initGlobals = function() {
- this.initGetComputedStyleIfNeeded()
- };
- this.initGetComputedStyleIfNeeded = function() {
- if (!window.getComputedStyle) {
- window.getComputedStyle = function(el, pseudo) {
- this.el = el;
- this.getPropertyValue = function(prop) {
- var re = /(\-([a-z]){1})/g;
- if (prop == "float") {
- prop = "styleFloat"
- }
- if (re.test(prop)) {
- prop = prop.replace(re, function() {
- return arguments[2].toUpperCase()
- })
- }
- return el.currentStyle[prop] ? el.currentStyle[prop] : null
- };
- return this
- }
- }
- };
- this.scrollToDest = function(x, y) {
- if (y == "bottom") {
- y = document.body.scrollHeight
- } else {
- if (y == "top") {
- if (window.scrollY == 0) {
- return
- } else {
- y = 0
- }
- }
- }
- window.scrollTo(x, y)
- };
- this.setPageOpcityTrick = function() {
- document.body.style.opacity = 0.999;
- window.setTimeout(function() {
- document.body.style.opacity = 1;
- document.body.style.opacity = ""
- }, 1)
- };
- this.addCssClassToHead = function(cssProp) {
- var head = document.getElementsByTagName("head")[0];
- var styleElement = document.createElement("style");
- styleElement.setAttribute("type", "text/css");
- if (styleElement.styleSheet) {
- styleElement.styleSheet.cssText = cssProp
- } else {
- styleElement.appendChild(document.createTextNode(cssProp))
- }
- head.appendChild(styleElement)
- };
- this.setToolbarLocationAfterPageLoad = function() {
- if (window[fnNameSpace].util.Browser.isIOS) {
- var metas = document.getElementsByTagName("meta");
- var currentZoomLevel = window[fnNameSpace].displayUtils.getIframeZoomLevel() / 100;
- var lastScreenHeight = window.innerHeight / currentZoomLevel;
- for (i = 0; i < metas.length; i++) {
- if (metas[i].getAttribute("name") == "apple-itunes-app") {
- i = metas.length;
- var metaTagInterval = window.setInterval(function() {
- currentZoomLevel = window[fnNameSpace].displayUtils.getIframeZoomLevel() / 100;
- var heightToCheck;
- if (window[fnNameSpace].util.Browser.isiPhone4 && window[fnNameSpace].util.Browser.isIOS7) {
- heightToCheck = 371
- } else {
- if (window[fnNameSpace].util.Browser.isiPhone4 && window[fnNameSpace].util.Browser.isIOS6) {
- heightToCheck = 278
- } else {
- if (window[fnNameSpace].util.Browser.isiPhone4 || window[fnNameSpace].util.Browser.isIOS6) {
- heightToCheck = 443
- } else {
- heightToCheck = 459
- }
- }
- }
- if (lastScreenHeight <= heightToCheck && window.innerHeight / currentZoomLevel > heightToCheck) {
- manager.scrollToDest(0, window.scrollY - 1);
- window.clearInterval(metaTagInterval)
- }
- lastScreenHeight = window.innerHeight
- }, 2000)
- }
- }
- }
- if (RELOCATE_TOOLBAR_ON_LOAD_INTERVAL <= 0) {
- return
- }
- this.initialToolbarBindingIntervalMethod = new window[fnNameSpace].StopWatch();
- this.initialToolbarBindingIntervalMethod.create(function() {
- if (typeof manager.currentToolbar.move == "function") {
- setTimeout(function() {
- manager.currentToolbar.move()
- }, 0)
- }
- }, RELOCATE_TOOLBAR_ON_LOAD_INTERVAL, "Fix toolbar location on page load");
- var intervalRemover = new window[fnNameSpace].StopWatch();
- intervalRemover.create(function() {
- manager.initialToolbarBindingIntervalMethod.remove()
- }, ATTEMP_TO_RELOCATE_TOOLBAR_AFTER_LOAD_TIMEOUT, "Remove toolbar location fix timer", true)
- };
- this.calculateMaxZIndex = function() {
- this.maxZIndexOnPage = window[fnNameSpace].domHelper.getMaxZIndex();
- this.toolbarsZIndex = (this.maxZIndexOnPage > this.toolbarsZIndex) ? this.maxZIndexOnPage + 1 : this.toolbarsZIndex
- };
- this.appendScreenOverlayLayout = function(screenOverlayId) {
- var screenOverlay = document.createElement("div");
- screenOverlay.setAttribute("id", screenOverlayId);
- window[fnNameSpace].util.setStyleWithImportant(screenOverlay, "background-color", "transparent", true);
- if (window[fnNameSpace].util.Browser.isAndroid23) {
- window[fnNameSpace].util.setStyleWithImportant(screenOverlay, "position", "absolute", true);
- window[fnNameSpace].util.setStyleWithImportant(screenOverlay, "top", window.scrollY + "px", true);
- window[fnNameSpace].util.setStyleWithImportant(screenOverlay, "left", window.scrollX + "px", true);
- window[fnNameSpace].util.setStyleWithImportant(screenOverlay, "right", "auto", true);
- window[fnNameSpace].util.setStyleWithImportant(screenOverlay, "bottom", "auto", true);
- window[fnNameSpace].util.setStyleWithImportant(screenOverlay, "height", "1000%", true)
- } else {
- window[fnNameSpace].util.setStyleWithImportant(screenOverlay, "position", "fixed", true);
- window[fnNameSpace].util.setStyleWithImportant(screenOverlay, "bottom", "0px", true);
- window[fnNameSpace].util.setStyleWithImportant(screenOverlay, "left", "0px", true);
- window[fnNameSpace].util.setStyleWithImportant(screenOverlay, "top", "auto", true);
- window[fnNameSpace].util.setStyleWithImportant(screenOverlay, "right", "auto", true);
- window[fnNameSpace].util.setStyleWithImportant(screenOverlay, "height", document.documentElement.scrollHeight + "px", true)
- }
- window[fnNameSpace].util.setStyleWithImportant(screenOverlay, "z-index", 2147483645, true);
- window[fnNameSpace].util.setStyleWithImportant(screenOverlay, "width", "100%", true);
- window[fnNameSpace].util.setStyleWithImportant(screenOverlay, "text-align", "center", true);
- window[fnNameSpace].util.setStyleWithImportant(screenOverlay, "margin", "0", true);
- window[fnNameSpace].util.setStyleWithImportant(screenOverlay, "padding", "0", true);
- window[fnNameSpace].util.setStyleWithImportant(screenOverlay, "border", "0", true);
- window[fnNameSpace].util.setStyleWithImportant(screenOverlay, "opacity", "0", true);
- window[fnNameSpace].util.setStyleWithImportant(screenOverlay, "display", "none", true);
- manager.screenOverlayElement = screenOverlay;
- screenOverlay.addEventListener("touchstart", function(e) {
- e.preventDefault()
- }, false);
- screenOverlay.addEventListener("touchmove", function(e) {
- e.preventDefault()
- }, false);
- document.body.appendChild(screenOverlay);
- return screenOverlay
- };
- this.setCurrentToolbar = function(toolbar) {
- if (this.currentToolbar) {
- this.currentToolbar.hide(true);
- this.currentToolbar.isCurrentToolbar = false
- }
- this.currentToolbar = toolbar;
- this.currentToolbar.isCurrentToolbar = true;
- if (toolbar.isReady) {
- toolbar.loadToolbar();
- this.currentToolbar.sendCurrentZoomLevelToToolbar()
- }
- };
- this.loadToolbar = function(toolbarId, type) {
- if (!window[fnNameSpace].domHelper.checkElementOnPageById(toolbarId)) {
- return false
- }
- var toolbarDOM = window[fnNameSpace].domHelper.getElement(toolbarId);
- var toolbarInstance = new window[fnNameSpace].Toolbar(toolbarDOM, this.toolbarsZIndex);
- toolbarsById[toolbarInstance.id] = toolbarInstance;
- return true
- };
- this.isDebug = function() {
- if (window[fnNameSpace].util.fetchGetVariableValue("fndebug") == "true") {
- return true
- }
- return false
- };
- this.messageAllToolbars = function(msg) {
- window[fnNameSpace].util.console("sending message to all toolbars!", "messaging");
- for (var i in toolbarsById) {
- if (toolbarsById.hasOwnProperty(i)) {
- window[fnNameSpace].util.console("sending message: " + window[fnNameSpace].util.serialize(msg) + " to toolbar: " + toolbarsById[i].id, "messaging");
- toolbarsById[i].sendMessage(msg)
- }
- }
- };
- this.notifyManagerIsUp = function() {
- var msg = this.getManagerUpMessage();
- this.messageAllToolbars(msg)
- };
- this.notifyManagerIsUpToOneFrame = function(toolbarInstance) {
- var msg = this.getManagerUpMessage();
- msg.frameAlreadyUp = true;
- toolbarInstance.sendMessage(msg)
- };
- this.getManagerUpMessage = function() {
- var msg = new Object();
- msg.message = "ManagerUp";
- msg.toolbarData = this.toolbarData;
- var visualViewportInfo = window[fnNameSpace].displayUtils.getVisualViewportInfo();
- msg.windowWidth = visualViewportInfo.width;
- msg.windowHeight = visualViewportInfo.height;
- var screenSize = window[fnNameSpace].displayUtils.calcScreenSize();
- msg.screenWidth = screenSize.width;
- msg.screenHeight = screenSize.height;
- msg.isPortrait = window[fnNameSpace].displayUtils.isPortrait();
- msg.zoomLevel = window[fnNameSpace].displayUtils.getIframeZoomLevel();
- msg.pageInfo = {
- url: window.location.href,
- title: window.document.title,
- icon: window.location.href + "/favicon.ico"
- };
- msg.doNotQueue = true;
- msg.isMobileAwareSite = manager.isMobileAwareSite;
- msg.iframePositioning = manager.currentToolbar.getIframePositioning();
- msg.isNonScrollAbleSite = window.innerHeight >= document.body.scrollHeight;
- msg.isToolbarSrcReloaded = this.isToolbarSrcReloaded;
- return msg
- };
- this.initToolbarData = function() {
- var toolbarData;
- if (window[fnNameSpace].domHelper.checkElementOnPageById(window[fnNameSpace].util.FN_TOOLBAR_SCRIPT) === false) {
- return false
- }
- toolbarData = document.getElementById(window[fnNameSpace].util.FN_TOOLBAR_SCRIPT).getAttribute(window[fnNameSpace].util.TOOLBAR_DATA_ATTRIBUTE);
- this.toolbarData = toolbarData;
- if (!toolbarData) {
- return false
- }
- return true
- };
- this.updateAllFramesWithWindowSize = function() {
- var visualViewportInfo = window[fnNameSpace].displayUtils.getVisualViewportInfo();
- var screenSize = window[fnNameSpace].displayUtils.calcScreenSize();
- var screenWidth = screenSize.width;
- var screenHeight = screenSize.height;
- if (typeof(this.lastWindowAndScreenSizes) !== undefined) {
- if ((this.lastWindowAndScreenSizes.windowWidth !== visualViewportInfo.width) || (this.lastWindowAndScreenSizes.windowHeight !== visualViewportInfo.height) || (this.lastWindowAndScreenSizes.screenWidth !== screenWidth) || (this.lastWindowAndScreenSizes.screenHeight !== screenHeight)) {
- this.lastWindowAndScreenSizes = {
- windowWidth: visualViewportInfo.width,
- windowHeight: visualViewportInfo.height,
- screenWidth: screenWidth,
- screenHeight: screenHeight
- };
- var msg = new Object();
- msg.message = "ScreenSizeChange";
- msg.windowWidth = visualViewportInfo.width;
- msg.windowHeight = visualViewportInfo.height;
- msg.screenWidth = screenWidth;
- msg.screenHeight = screenHeight;
- this.messageAllToolbars(msg)
- }
- }
- };
- this.loadToolbarPosition = function() {
- var msg = new Object();
- msg.message = "LoadToolbarPosition";
- this.currentToolbar.sendMessage(msg)
- };
- this.storeToolbarPosition = function(verticalPos, horizontalPos) {
- var msg = new Object();
- msg.message = "StoreToolbarPosition";
- msg.verticalPos = verticalPos;
- msg.horizontalPos = horizontalPos;
- this.currentToolbar.sendMessage(msg)
- };
- this.attachClassToElement = function(elementId, className) {
- var msg = new Object();
- msg.message = "AttachClassToElement";
- msg.elementId = elementId;
- msg.className = className;
- this.currentToolbar.sendMessage(msg)
- };
- this.maximizeToolbarRequest = function() {
- var msg = new Object();
- msg.message = "MaximizeToolbarRequest";
- this.currentToolbar.sendMessage(msg)
- };
- this.minimizeToolbarRequest = function() {
- var msg = new Object();
- msg.message = "MinimizeToolbarRequest";
- this.currentToolbar.sendMessage(msg)
- };
- this.sendOverlayTextBoxValue = function(elementId, textValue) {
- var msg = new Object();
- msg.message = "SendOverlayTextBoxValue";
- msg.elementId = elementId;
- msg.textValue = encodeURI(textValue);
- this.currentToolbar.sendMessage(msg)
- };
- this.notifyOverlayTextBoxSubmit = function(submitString) {
- var msg = new Object();
- msg.message = "NotifyOverlayTextBoxSubmit";
- msg.submitString = submitString;
- this.currentToolbar.sendMessage(msg)
- };
- this.notifyOverlayTextBoxClose = function(closeString) {
- var msg = new Object();
- msg.message = "NotifyOverlayTextBoxClose";
- msg.closeString = closeString;
- this.currentToolbar.sendMessage(msg)
- };
- this.scrollDownAndUp = function() {
- var msg = {
- message: "ScrollDownAndUp",
- scrollY: window.scrollY,
- innerHeight: window.innerHeight,
- scrollHeight: document.body.scrollHeight
- };
- this.currentToolbar.sendMessage(msg)
- };
- this.scrollDown = function() {
- var msg = {
- message: "ScrollDown",
- scrollY: window.scrollY,
- innerHeight: window.innerHeight,
- scrollHeight: document.body.scrollHeight
- };
- this.currentToolbar.sendMessage(msg)
- };
- this.handleL8FocusEvent = function(state) {
- manager.l8FocusState = state.disable;
- if (manager.l8FocusState) {
- var innerHeight = 0;
- window.setTimeout(function() {
- var interval = setInterval(function() {
- if (innerHeight !== 0 && window.innerHeight > (innerHeight + 41)) {
- manager.currentToolbar.l8BlurEvent();
- clearInterval(interval);
- return
- }
- innerHeight = window.innerHeight
- }, 500)
- }, 300)
- }
- };
- this.scrollUp = function() {
- var msg = {
- message: "ScrollUp",
- scrollY: window.scrollY,
- innerHeight: window.innerHeight,
- scrollHeight: document.body.scrollHeight
- };
- this.currentToolbar.sendMessage(msg)
- };
- this.mouseOutEvent = function(e) {
- var msg = {
- message: "MouseOutEvent"
- };
- this.currentToolbar.sendMessage(msg)
- };
- this.onInitializeDragDropManager = function(eventMessage) {
- if (typeof window[fnNameSpace].DragDropManager === "undefined") {
- window[fnNameSpace].util.console("DragDropManager is undefined", "DragDrop");
- return
- }
- if (toolbarsById[eventMessage.sender]) {
- if (window[fnNameSpace].dragdropManager != null) {
- return
- }
- var params = eventMessage.params || {};
- window[fnNameSpace].dragdropManager = new window[fnNameSpace].DragDropManager(params);
- window[fnNameSpace].dragdropManager.registerDragSupport()
- }
- };
- this.onSuspendDragDrop = function(eventMessage) {
- manager.tbstatus.suspendDragDrop = eventMessage.bSuspend;
- if (toolbarsById[eventMessage.sender]) {
- if (window[fnNameSpace].dragdropManager) {
- window[fnNameSpace].dragdropManager.suspendDragDrop()
- }
- }
- };
- this.onToolbarSetDragPosition = function(eventMessage) {
- if (toolbarsById[eventMessage.sender]) {
- if (window[fnNameSpace].dragdropManager) {
- window[fnNameSpace].dragdropManager.setPosition(eventMessage.verticalPos, eventMessage.horizontalPos)
- }
- }
- };
- this.onSetDragIcon = function(eventMessage) {
- if (toolbarsById[eventMessage.sender]) {
- if (window[fnNameSpace].dragdropManager) {
- window[fnNameSpace].dragdropManager.setDragIcon(eventMessage.iconUrl)
- }
- }
- };
- this.onFrameUp = function(eventMessage) {
- var toolbarInstance = toolbarsById[eventMessage.sender];
- if (!toolbarInstance) {
- return
- }
- if (!eventMessage.managerUp) {
- this.notifyManagerIsUpToOneFrame(toolbarInstance);
- return
- }
- toolbarInstance.onFrameReady();
- if (toolbarInstance.isCurrentToolbar) {
- toolbarInstance.loadToolbar(eventMessage.config);
- toolbarInstance.sendCurrentZoomLevelToToolbar()
- }
- };
- this.onRequestPageNavigation = function(eventMessage) {
- window.location.href = eventMessage.url
- };
- this.onUpdateToolbarStatus = function(eventMessage) {
- manager.tbstatus.isMinimize = eventMessage.isMinimize;
- if (toolbarsById[eventMessage.sender]) {
- if (window[fnNameSpace].dragdropManager) {
- window[fnNameSpace].dragdropManager.toolbarStateChanged()
- }
- }
- };
- this.onFlapClick = function(eventMessage) {
- document.activeElement.blur()
- }, this.onToolbarResize = function(eventMessage) {
- if (toolbarsById[eventMessage.sender]) {
- toolbarsById[eventMessage.sender].resize(eventMessage.width, eventMessage.height, true, eventMessage.ratio)
- }
- };
- this.onToolbarScrollToDest = function(eventMessage) {
- if (toolbarsById[eventMessage.sender]) {
- manager.scrollToDest(eventMessage.x, eventMessage.y)
- }
- };
- this.onToolbarOpacityRenderTrick = function(eventMessage) {
- if (toolbarsById[eventMessage.sender]) {
- manager.setPageOpcityTrick()
- }
- };
- this.onToolbarMove = function(eventMessage) {
- if (toolbarsById[eventMessage.sender]) {
- toolbarsById[eventMessage.sender].move(eventMessage.positioning)
- }
- };
- this.onShowToolbar = function(eventMessage) {
- if (toolbarsById[eventMessage.sender]) {
- toolbarsById[eventMessage.sender].show();
- toolbarsById[eventMessage.sender].sendCurrentZoomLevelToToolbar(true);
- manager.currentToolbar.showL8CompletedCallback()
- }
- };
- this.onHideToolbar = function(eventMessage) {
- if (toolbarsById[eventMessage.sender]) {
- toolbarsById[eventMessage.sender].hide()
- }
- };
- this.onChangeIframePosition = function(eventMessage) {
- if (toolbarsById[eventMessage.sender]) {
- manager.toolbarPositionControl(eventMessage)
- }
- };
- this.onChangeIframeVerticalPosition = function(eventMessage) {
- if (toolbarsById[eventMessage.sender]) {
- manager.toolbarPositionVerticalPosition(eventMessage)
- }
- };
- this.onChangeIframeOpacity = function(eventMessage) {
- if (toolbarsById[eventMessage.sender]) {
- manager.toolbarOpacityControl(eventMessage)
- }
- };
- this.onSetScreenOverlay = function(eventMessage) {
- if (toolbarsById[eventMessage.sender]) {
- manager.toolbarScreenOverlay(eventMessage.screenOverlayId, eventMessage)
- }
- };
- this.onShowOverlayTextBox = function(eventMessage) {
- if (toolbarsById[eventMessage.sender]) {
- if (typeof window[fnNameSpace].OverlayTextBox !== "undefined") {
- window[fnNameSpace].OverlayTextBox.showOverlayTextBox(eventMessage)
- }
- }
- };
- this.onMonitorScrollDown = function(eventMessage) {
- if (toolbarsById[eventMessage.sender]) {
- manager.monitorScrollDown = eventMessage.monitor
- }
- };
- this.onL8FocusEvent = function(eventMessage) {
- if (toolbarsById[eventMessage.sender]) {
- manager.handleL8FocusEvent(eventMessage)
- }
- };
- this.onTollbarLocationParametersUpdate = function(eventMessage) {
- if (toolbarsById[eventMessage.sender]) {
- manager.handleTollbarLocationParametersUpdate()
- }
- };
- this.handleTollbarLocationParametersUpdate = function() {
- var bodyScrollHeight = document.body.scrollHeight;
- var windowInnerHeight = window.innerHeight;
- var windowScrollY = window.scrollY;
- var msg = {
- message: "TopBottomTollbarLocationParameters",
- bodyScrollHeight: bodyScrollHeight,
- windowInnerHeight: windowInnerHeight,
- windowScrollY: windowScrollY
- };
- this.currentToolbar.sendMessage(msg)
- };
- this.onScriptInjectionRequest = function(eventMessage) {
- var toolbarInstance = toolbarsById[eventMessage.sender];
- if (toolbarInstance) {
- var id = eventMessage.id;
- var sourceUrl = eventMessage.sourceUrl;
- var callbackName = eventMessage.callbackName;
- var preScriptEvalCode = eventMessage.preScriptEvalCode;
- var timeout = eventMessage.timeout;
- if (typeof preScriptEvalCode === "string" && preScriptEvalCode !== "") {
- window.eval(preScriptEvalCode)
- }
- window[callbackName] = function() {};
- var me = this;
- this._scriptInjectionRequestTimeouts[id] = window.setTimeout(function() {
- me._scriptInjectionRequestFinished.call(me, toolbarInstance, id, undefined)
- }, timeout);
- this._scriptInjectionRequestAppendScript(toolbarInstance, id, sourceUrl, callbackName)
- }
- };
- this._scriptInjectionRequestFinished = function(toolbarInstance, id, result) {
- var timeoutId = this._scriptInjectionRequestTimeouts[id];
- if (typeof timeoutId !== "undefined" && timeoutId !== null) {
- window.clearTimeout(timeoutId);
- delete this._scriptInjectionRequestTimeouts[id];
- toolbarInstance.notifyScriptInjectionFinished(id, result)
- }
- };
- this._scriptInjectionRequestAppendScript = function(toolbarInstance, id, sourceUrl, callbackName) {
- var me = this;
- var injectionScript = document.createElement("script");
- injectionScript.src = sourceUrl;
- injectionScript.onload = function() {
- if (typeof callbackName === "string" && callbackName !== "") {
- window[callbackName] = function() {
- var result = Array.prototype.concat.apply([], arguments);
- me._scriptInjectionRequestFinished.call(me, toolbarInstance, id, result);
- delete window[callbackName]
- }
- } else {
- me._scriptInjectionRequestFinished.call(me, toolbarInstance, id, undefined)
- }
- };
- document.body.appendChild(injectionScript)
- }
- };
- window[fnNameSpace].Manager.prototype.handleOrientationChange = function(a) {
- manager.firstOrientationChangeOccur = true;
- var c = window[fnNameSpace].displayUtils.isPortrait();
- if (this.lastNotifiedOrientation != c) {
- if (manager.l8FocusState && c) {
- return
- }
- this.handleOrientationChangeDevice();
- window[fnNameSpace].domHelper.hideiFrameWithOpacity(0.2);
- this.lastNotifiedOrientation = c;
- var b = this;
- window.setTimeout(function() {
- b.currentToolbar.sendCurrentZoomLevelToToolbar();
- b.currentToolbar.resize();
- b.currentToolbar.onOrientationChange(c);
- if (window[fnNameSpace].dragdropManager) {
- window[fnNameSpace].dragdropManager.orientationChange(c)
- }
- if (!b.currentToolbar.changeIframeCSSPosition()) {
- window[fnNameSpace].domHelper.showiFrameWithOpacity(0.6)
- }
- }, 500)
- }
- };
- window[fnNameSpace].Manager.prototype.handleOrientationChangeDevice = function() {};
- window[fnNameSpace].Manager.prototype.triggerUpdateScrollEventTimer = function() {
- if (this.updateScrollTimerId === 0) {
- this.updateScrollTimerId = window.setTimeout(function() {
- var a = new Object();
- a.message = "PageScroll";
- a.scrollTop = document.body.scrollTop;
- a.scrollHeight = document.body.scrollHeight;
- a.scrollWidth = document.body.scrollWidth;
- manager.currentToolbar.sendMessage(a);
- manager.updateScrollTimerId = 0
- }, 2000)
- }
- };
- window[fnNameSpace].Manager.prototype.handleScroll = function(a) {};
- window[fnNameSpace].Manager.prototype.lastVisualViewportInfo = undefined;
- window[fnNameSpace].Manager.prototype.handleResize = function(a) {
- var b = this;
- setTimeout(function() {
- var d = window[fnNameSpace].displayUtils.getVisualViewportInfo();
- if (window[fnNameSpace].OverlayTextBox && window[fnNameSpace].OverlayTextBox.isDisplayed()) {
- if (b.lastNotifiedOrientation === window[fnNameSpace].displayUtils.isPortrait()) {
- if (b.lastVisualViewportInfo && (b.lastVisualViewportInfo.width === d.width) && ((b.lastVisualViewportInfo.height < d.height))) {
- window[fnNameSpace].OverlayTextBox._restoreLayer8()
- }
- }
- }
- b.lastVisualViewportInfo = d;
- if (typeof window[fnNameSpace].Manager.prototype.toolbarScreenOverlayVisible === "object") {
- var e = (window[fnNameSpace].displayUtils.getIframeZoomLevel()) / 100;
- for (var c in window[fnNameSpace].Manager.prototype.toolbarScreenOverlayVisible) {
- overlayLayout = document.getElementById(c);
- if (overlayLayout) {
- if (window[fnNameSpace].util.Browser.isAndroid23) {
- window[fnNameSpace].util.setStyleWithImportant(overlayLayout, "height", "1000%", true)
- } else {
- window[fnNameSpace].util.setStyleWithImportant(overlayLayout, "height", window.screen.height * e + "px", true)
- }
- }
- }
- }
- }, 0);
- this.handleOrientationChange();
- this.handleTollbarLocationParametersUpdate();
- var b = this;
- setTimeout(function() {
- b.currentToolbar.sendCurrentZoomLevelToToolbar();
- b.currentToolbar.resize();
- b.updateAllFramesWithWindowSize();
- b.currentToolbar.changeIframeCSSPosition()
- }, 500)
- };
- window[fnNameSpace].Manager.prototype.initManagerDevice = function() {};
- window[fnNameSpace].Manager.prototype.eventsToRegister = [{
- event: "pagehide",
- func: function(a) {
- window[fnNameSpace].uiEventHandler.beforeunloadEvent(a)
- },
- element: window,
- capture: false
- }, {
- event: "click",
- func: function(a) {
- window[fnNameSpace].touchEventsHandler.clickEvent(a)
- },
- element: document,
- capture: false
- }, {
- event: "touchmove",
- func: function(a) {
- window[fnNameSpace].touchEventsHandler.touchmoveEvent(a)
- },
- element: top.document,
- capture: false
- }, {
- event: "touchend",
- func: function(a) {
- window[fnNameSpace].touchEventsHandler.touchendEvent(a)
- },
- element: top.document,
- capture: false
- }, {
- event: "touchcancel",
- func: function(a) {
- window[fnNameSpace].touchEventsHandler.touchcancelEvent(a)
- },
- element: top.document,
- capture: false
- }, {
- event: "scroll",
- func: function(a) {
- window[fnNameSpace].uiEventHandler.scrollEvent(a)
- },
- element: window,
- capture: true
- }, {
- event: "resize",
- func: function(a) {
- window[fnNameSpace].uiEventHandler.resizeEvent(a)
- },
- element: window,
- capture: false
- }, {
- event: "orientationchange",
- func: function(a) {
- window[fnNameSpace].uiEventHandler.orientationChangeEvent(a)
- },
- element: window,
- capture: false
- }];
- window[fnNameSpace].Manager.prototype.handleScroll = function(a) {
- if (!this.currentToolbar) {
- return
- }
- if (!this.currentToolbar.isVisible) {
- return
- }
- var b = window[fnNameSpace].displayUtils.getVisualViewportInfo();
- manager.lastVisualViewportInfo = b;
- this.currentToolbar.move();
- this.triggerUpdateScrollEventTimer();
- var c = this;
- window.setTimeout(function() {
- c.currentToolbar.sendCurrentZoomLevelToToolbar();
- c.currentToolbar.resize();
- c.updateAllFramesWithWindowSize();
- c.currentToolbar.changeIframeCSSPosition()
- }, 500)
- };
- window[fnNameSpace].Manager.prototype.initManagerDevice = function() {
- if (window[fnNameSpace].util.Browser.isIOS6) {
- window.addEventListener("pageshow", function(a) {
- if (a.persisted) {
- manager.isToolbarSrcReloaded = true;
- manager.currentToolbar.hide();
- var c = window.scrollX;
- var b = window.scrollY;
- window.setTimeout(function() {
- manager.scrollToDest(c, b - 1);
- manager.currentToolbar.dom.src = manager.currentToolbar.dom.src;
- window.setTimeout(function() {
- manager.scrollToDest(c, b);
- manager.currentToolbar.show()
- }, 100)
- }, 1000)
- }
- }, false)
- }
- };
- window[fnNameSpace].Manager.prototype.startIos7FixResizeInterval = function(a) {
- if (typeof manager.ios7Interval !== "undefined") {
- window.clearInterval(manager.ios7Interval)
- }
- manager.lastVisualViewportInfo = a;
- manager.ios7Interval = window.setInterval(function() {
- var b = window[fnNameSpace].displayUtils.getVisualViewportInfo();
- if ((manager.lastVisualViewportInfo.width !== b.width) || (manager.lastVisualViewportInfo.height !== b.height)) {
- manager.handleScroll()
- }
- }, 5000)
- };
- window[fnNameSpace].EventRegister = function(a) {
- for (var b in a) {
- window[fnNameSpace].util.addEvent(a[b].event, a[b].func, a[b].capture, a[b].element)
- }
- };
- window[fnNameSpace].MouseEventsHandler = function() {
- this.clickEvent = function(a) {};
- this.mouseupEvent = function(a) {};
- this.mouseoverEvent = function(a) {};
- this.mouseoutEvent = function(a) {
- this.handleMouseOutEvent()
- };
- this.mousedownEvent = function(a) {};
- this.mousewheelEvent = function(a) {
- if (manager.screenOverlayElement.style.display == "block") {
- a.preventDefault()
- }
- };
- this.handleMouseOutEvent = function(a) {
- manager.mouseOutEvent(a)
- }
- };
- window[fnNameSpace].mouseEventsHandler = new window[fnNameSpace].MouseEventsHandler();
- window[fnNameSpace].TouchEventsHandler = function() {
- this.detectZoom = function(a) {
- if (a.touches.length > 1) {
- return true
- }
- return false
- };
- this.touchstartEvent = function(a) {
- if (typeof manager.currentToolbar === "undefined") {
- return
- }
- if (typeof manager.currentToolbar.stage === "undefined") {
- return
- }
- if (!manager.currentToolbar.isVisible) {
- return
- }
- };
- this.touchmoveEvent = function(a) {
- if (a.touches.length > manager.currentToolbar.config.hideOnXTouches && manager.screenOverlayElement.style.display == "none") {
- manager.touchCurrentCounter = 2;
- window[fnNameSpace].domHelper.hideiFrameWithOpacity(0)
- } else {
- manager.touchCurrentCounter = 1
- }
- };
- this.touchendEvent = function(b) {
- if (typeof manager.currentToolbar === "undefined") {
- return
- }
- if (typeof manager.currentToolbar.stage === "undefined") {
- return
- }
- manager.touchCurrentCounter = 1;
- var a = new window[fnNameSpace].StopWatch();
- a.create(function() {
- manager.handleScroll()
- }, 250, "Relocates toolbar after double click", true)
- };
- this.touchcancelEvent = function(a) {};
- this.clickEvent = function(a) {}
- };
- window[fnNameSpace].touchEventsHandler = new window[fnNameSpace].TouchEventsHandler();
- window[fnNameSpace].UiEventHandler = function() {
- this.beforeunloadEvent = function(b) {
- if (window[fnNameSpace].util.Browser.isIOS6) {
- manager.currentToolbar.hide()
- }
- };
- this.loadEvent = function(b) {};
- this.scrollEvent = function(b) {
- if (b.target !== document) {
- return
- }
- if ((manager.currentToolbar) && (manager.currentToolbar.stage)) {
- manager.touchCurrentCounter = 1;
- manager.handleScroll(b)
- }
- this.checkScrollPosition()
- };
- this.resizeEvent = function(b) {
- if (manager.l8FocusState && window[fnNameSpace].displayUtils.isPortrait()) {
- return
- }
- manager.handleResize(b);
- return false
- };
- this.orientationChangeEvent = function(b) {
- manager.handleOrientationChange(b)
- };
- this.yOffset = 0;
- var a;
- this.checkScrollPosition = function() {
- if (manager.currentToolbar.config.serviceNotificationThresholds && window[fnNameSpace].displayUtils.isPortrait()) {
- if (typeof a !== undefined && a === window[fnNameSpace].displayUtils.getIframeZoomLevel()) {
- if (this.yOffset > window.pageYOffset) {
- manager.scrollDownAndUp();
- manager.scrollUp()
- } else {
- if (manager.monitorScrollDown === true && this.yOffset < window.pageYOffset) {
- manager.scrollDown()
- } else {
- if (this.yOffset < window.pageYOffset) {
- manager.scrollDown()
- }
- }
- }
- }
- window.setTimeout(function() {
- a = window[fnNameSpace].displayUtils.getIframeZoomLevel()
- }, 10);
- this.yOffset = window.pageYOffset
- }
- }
- };
- window[fnNameSpace].uiEventHandler = new window[fnNameSpace].UiEventHandler();
- window[fnNameSpace].Manager.prototype.toolbarPositionVerticalPosition = function(f) {
- var d = window[fnNameSpace].util.Browser.isAndroid ? manager.currentToolbar.dom.parentElement.style.position : manager.currentToolbar.dom.style.position;
- if (d === "absolute") {
- return
- }
- var c = "";
- var a = "";
- var e = parseFloat(manager.currentToolbar.dom.parentElement.style.left);
- var b = parseFloat(manager.currentToolbar.dom.parentElement.style.right);
- if (f.topPosition == true) {
- c = 0;
- a = "auto"
- } else {
- c = "auto";
- a = 0
- }
- manager.currentToolbar.setIframePositioning(c, a, e, b)
- };
- window[fnNameSpace].Manager.prototype.toolbarPositionControl = function(c) {
- var e = "";
- var a = "";
- var d = "";
- var b = "";
- if (c.lr == "left" && c.tb == "bottom") {
- a = c.y;
- d = c.x
- } else {
- if (c.lr == "left" && c.tb == "top") {
- e = c.y;
- d = c.x
- } else {
- if (c.lr == "right" && c.tb == "bottom") {
- a = c.y;
- b = c.x
- } else {
- if (c.lr == "right" && c.tb == "top") {
- e = c.y;
- b = c.x
- }
- }
- }
- }
- manager.currentToolbar.setIframePositioning(e, a, d, b)
- };
- window[fnNameSpace].Manager.prototype.toolbarOpacityControl = function(c) {
- var a = c.opacity;
- var d = {
- opacity: a
- };
- var b = {
- opacity: a
- };
- if (manager.tbstatus.isMinimize) {
- for (var e in b) {
- window[fnNameSpace].util.setStyleWithImportant(manager.currentToolbar.dom, e, b[e], true)
- }
- } else {
- for (var e in d) {
- window[fnNameSpace].util.setStyleWithImportant(manager.currentToolbar.dom, e, d[e], true)
- }
- }
- };
- window[fnNameSpace].Manager.prototype.toolbarScreenOverlayVisible = {};
- window[fnNameSpace].Manager.prototype.toolbarScreenOverlay = function(h, f) {
- var d = document.getElementById(h);
- if (!window[fnNameSpace].util.Browser.isIOS5) {
- window[fnNameSpace].util.setStyleWithImportant(d, "-webkit-transform", "translateZ(997px)", true)
- }
- if (!d) {
- return
- }
- var c = function(p, n, q) {
- var m, l, j = "DXImageTransform.Microsoft.";
- try {
- l = p.filters.item(j + n);
- m = true
- } catch (o) {}
- if (!m) {
- try {
- l = p.filters.item(n);
- m = true
- } catch (o) {}
- }
- if (m) {
- l.Enabled = true;
- if (q) {
- for (var k in q) {
- l[k] = q[k]
- }
- }
- } else {
- l = "";
- if (q) {
- for (var k in q) {
- l += k.toLowerCase() + "=" + q[k] + ","
- }
- }
- if (q) {
- l = "(" + l.substr(0, l.length - 1) + ")"
- }
- p.style.filter += "progid:" + j + n + l + " "
- }
- if (!p.style.zoom) {
- p.style.zoom = 1
- }
- };
- var b = f.background;
- var g = f.backgroundImage;
- var a = f.opacity;
- if (f.transition > 0) {
- window[fnNameSpace].util.setStyleWithImportant(d, "opacity", "0", true);
- if (document.body.filters) {
- c(d, "Alpha", {
- Opacity: 100
- })
- }
- if (b == "disable" || b == "") {
- window[fnNameSpace].util.setStyleWithImportant(d, "opacity", a, true);
- if (document.body.filters) {
- c(d, "Alpha", {
- Opacity: a * 100
- })
- }
- }
- window[fnNameSpace].util.setStyleWithImportant(d, "-webkit-transition", "opacity " + f.transition + "s ease", true);
- window[fnNameSpace].util.setStyleWithImportant(d, "-moz-transition", "opacity " + f.transition + "s ease", true);
- window[fnNameSpace].util.setStyleWithImportant(d, "transition", "opacity " + f.transition + "s ease", true)
- } else {
- window[fnNameSpace].util.setStyleWithImportant(d, "-webkit-transition", "", true);
- window[fnNameSpace].util.setStyleWithImportant(d, "-moz-transition", "", true);
- window[fnNameSpace].util.setStyleWithImportant(d, "transition", "", true)
- }
- if (b == "disable" || b == "") {
- window[fnNameSpace].util.setStyleWithImportant(d, "opacity", "0", true);
- if (document.body.filters) {
- c(d, "Alpha", {
- Opacity: 100
- })
- }
- window.setTimeout(function() {
- window[fnNameSpace].util.setStyleWithImportant(d, "display", "none", true)
- }, f.transition);
- return
- } else {
- window[fnNameSpace].util.setStyleWithImportant(d, "display", "block", true)
- }
- var e = (window[fnNameSpace].displayUtils.getIframeZoomLevel()) / 100;
- if (!window[fnNameSpace].util.Browser.isAndroid23) {
- window[fnNameSpace].util.setStyleWithImportant(d, "height", window.screen.height * e + "px", true);
- window[fnNameSpace].util.setStyleWithImportant(d, "top", "0px", true);
- window[fnNameSpace].util.setStyleWithImportant(d, "bottom", "auto", true)
- } else {
- window[fnNameSpace].util.setStyleWithImportant(d, "height", "1000%", true)
- }
- window[fnNameSpace].util.setStyleWithImportant(d, "width", "100%", true);
- delete window[fnNameSpace].Manager.prototype.toolbarScreenOverlayVisible[h];
- window[fnNameSpace].Manager.prototype.toolbarScreenOverlayVisible[h] = true;
- d.style.top = "0px";
- d.style.bottom = "auto";
- if (b == "image") {
- window[fnNameSpace].util.setStyleWithImportant(d, "background-image", g, true);
- window[fnNameSpace].util.setStyleWithImportant(d, "background-size", "100% 100%", true);
- window[fnNameSpace].util.setStyleWithImportant(d, "background-repeat", "no-repeat", true)
- } else {
- window[fnNameSpace].util.setStyleWithImportant(d, "background-color", b, true)
- }
- window.setTimeout(function() {
- window[fnNameSpace].util.setStyleWithImportant(d, "opacity", a, true)
- }, 0);
- if (document.body.filters) {
- c(d, "Alpha", {
- Opacity: a * 100
- })
- }
- };
- window[fnNameSpace].Toolbar = function(a, b) {
- this.isReady = false;
- this.dom = a;
- this.queuedMessages = new window[fnNameSpace].Message.MessageQueue();
- this.isVisible = false;
- this.config = false;
- this.id = this.dom.id;
- this.isFirstLoad = true;
- this.isCurrentToolbar = false;
- this.zIndexLevel = (parseInt(b) > 0) ? b : 99999;
- this.stage;
- this.initialOpacityReset = false;
- this.lastOpacity = 1;
- this.init = function() {
- this.initialOpacityReset = true;
- window[fnNameSpace].util.setStyleWithImportant(this.dom, "opacity", "0", true);
- this.setStyleDisplay(true);
- if (this.dom.tagName.toLowerCase() != "iframe") {
- throw "Expected iframe! got: " + this.dom.tagName
- }
- var c = this.dom;
- window[fnNameSpace].util.thread(function() {
- if (Number(c.style.zIndex) <= Number(window[fnNameSpace].domHelper.maxZIndexOnPage)) {
- window[fnNameSpace].util.setStyleWithImportant(c, "z-index", 2147483646, true)
- }
- });
- return true
- };
- if (!this.initialToolbarIframe) {
- this.initialToolbarIframe = function() {
- var e = {
- "z-index": this.zIndexLevel,
- position: this.config.Position,
- bottom: this.config.Bottom,
- right: this.config.Right,
- top: this.config.Top,
- left: this.config.Left,
- padding: this.config.Padding,
- margin: this.config.Margin,
- border: this.config.Border,
- "min-width": "0px",
- "min-height": "0px",
- "max-width": "none",
- "max-height": "none",
- background: "transparent"
- };
- if (this.config.Opacity !== "undefined") {
- this.lastOpacity = this.config.Opacity
- }
- var c = {
- scrolling: this.config.ATT_Scrolling,
- frameborder: this.config.ATT_Frameborder,
- scroll: this.config.ATT_Scroll,
- allowTransparency: this.config.ATT_Allowtransparency
- };
- for (var d in e) {
- window[fnNameSpace].util.setStyleWithImportant(this.dom, d, e[d], true)
- }
- for (var d in c) {
- this.dom.setAttribute(d, c[d])
- }
- if (this.initialToolbarIframeSpecificDevice) {
- this.initialToolbarIframeSpecificDevice(e, c)
- }
- }
- }
- this.loadConfiguration = function(c) {
- this.config = c;
- this.stage = new window[fnNameSpace].StageLogicManager(this);
- this.changeIframeCSSPosition();
- this.move(c);
- return true
- };
- this.sendMessage = function(c) {
- c.to = this.id;
- if ((!this.isReady) && (!c.doNotQueue)) {
- this.queuedMessages.add(c);
- window[fnNameSpace].util.console("[" + this.id + "]Message was added to queue for toolbar " + this.id + " content: " + window[fnNameSpace].util.serialize(c), "messaging")
- } else {
- window[fnNameSpace].message.send(c, this.dom);
- window[fnNameSpace].util.console("[" + this.id + "]Message sent to toolbar " + this.id + " content: " + window[fnNameSpace].util.serialize(c), "messaging")
- }
- };
- this.sendQueuedMessages = function() {
- window[fnNameSpace].util.console("[" + this.id + "]sending queued messages", "messaging");
- while (message = this.queuedMessages.shift()) {
- this.sendMessage(message)
- }
- };
- if (!this.setStyleDisplay) {
- this.setStyleDisplay = function(c) {
- window[fnNameSpace].util.setStyleWithImportant(this.dom, "display", c ? "block" : "none", true);
- this.isVisible = c
- }
- }
- if (!this.getStylePosition) {
- this.getStylePosition = function() {
- return this.dom.style.position
- }
- }
- this.hide = function() {
- if (!this.config) {
- this.delayedShow = false;
- return
- }
- if (this.initialOpacityReset) {
- this.initialOpacityReset = false;
- window[fnNameSpace].domHelper.showiFrameWithOpacity(0)
- }
- if (!this.isVisible) {
- return
- }
- this.setStyleDisplay(false);
- if (window[fnNameSpace].util.Browser.isIOS7) {
- window.clearInterval(manager.ios7Interval)
- }
- var c = new Object();
- c.message = "ToolbarHide";
- this.sendMessage(c)
- };
- this.show = function() {
- if (!this.config) {
- this.delayedShow = true;
- return
- }
- if (this.initialOpacityReset) {
- this.initialOpacityReset = false;
- window[fnNameSpace].domHelper.showiFrameWithOpacity(0, true)
- }
- var c = window[fnNameSpace].displayUtils.getVisualViewportInfo();
- if (window[fnNameSpace].util.Browser.isIOS7) {
- manager.startIos7FixResizeInterval(c)
- }
- if (!this.isVisible) {
- this.setStyleDisplay(true);
- this.move()
- } else {
- return
- }
- var d = {};
- d.message = "ToolbarShow";
- d.isFirstLoad = this.isFirstLoad;
- var c = window[fnNameSpace].displayUtils.getVisualViewportInfo();
- d.windowWidth = c.width;
- d.windowHeight = c.height;
- this.sendMessage(d);
- window[fnNameSpace].util.console("[" + this.id + "] running show on toolbar " + this.id, "hideAndShow")
- };
- if (!(typeof this.move === "function")) {
- this.move = function(c) {}
- }
- this.resize = function(f, c, d, e) {
- if (!d) {
- d = false
- }
- if (this.stage) {
- this.stage.resize(f, c, d, e)
- }
- };
- this.loadToolbar = function(c) {
- var d = this;
- if (!c) {
- var c = d.config
- }
- if (d.isFirstLoad) {
- d.loadConfiguration(c);
- d.initialToolbarIframe();
- d.onIframePositioningChange();
- d.isFirstLoad = false
- }
- if (this.delayedShow == true) {
- this.show()
- }
- };
- this.showL8CompletedCallback = function() {
- var c = new Object();
- c.message = "ShowL8CompletedCallback";
- this.sendMessage(c)
- };
- this.l8BlurEvent = function() {
- var c = new Object();
- c.message = "L8BlurEvent";
- this.sendMessage(c)
- };
- this.sendCurrentZoomLevelToToolbar = function(c) {
- if (!this.isVisible) {
- return
- }
- var d = new Object();
- d.message = "ChangeZoom";
- d.zoom = parseFloat(window[fnNameSpace].displayUtils.getIframeZoomLevel()) + "%";
- d.pageBodyZoomLevel = window[fnNameSpace].displayUtils.getBodyZoomLevel();
- d.postShowIframe = c === true ? true : false;
- this.sendMessage(d)
- };
- this.updateStageSize = function(d, c) {
- var e = new Object();
- e.message = "UpdateStageSize";
- e.width = d;
- e.height = c;
- this.sendMessage(e)
- };
- this.onOrientationChange = function(e) {
- var f = new Object();
- f.message = "OrientationChange";
- var c = window[fnNameSpace].displayUtils.getVisualViewportInfo();
- f.isPortrait = e;
- f.pageHeight = c.height;
- f.windowWidth = c.width;
- f.windowHeight = c.height;
- var d = window[fnNameSpace].displayUtils.calcScreenSize();
- f.screenWidth = d.width;
- f.screenHeight = d.height;
- this.sendMessage(f)
- };
- this.onFrameReady = function() {
- this.isReady = true;
- this.sendQueuedMessages()
- };
- if (!this.getIframePositioning) {
- this.getIframePositioning = function() {
- return {
- top: this.dom.style.top,
- bottom: this.dom.style.bottom,
- left: this.dom.style.left,
- right: this.dom.style.right
- }
- }
- }
- if (!this.setIframePositioning) {
- this.setIframePositioning = function(f, c, e, d) {
- window[fnNameSpace].util.setStyleWithImportant(this.dom, "top", f === "" ? "auto" : f, true);
- window[fnNameSpace].util.setStyleWithImportant(this.dom, "bottom", c === "" ? "auto" : c, true);
- window[fnNameSpace].util.setStyleWithImportant(this.dom, "left", e === "" ? "auto" : e, true);
- window[fnNameSpace].util.setStyleWithImportant(this.dom, "right", d === "" ? "auto" : d, true);
- this.onIframePositioningChange()
- }
- }
- this.onIframePositioningChange = function() {
- var c = {};
- c.message = "IframePositioningChange";
- c.iframePositioning = this.getIframePositioning();
- this.sendMessage(c)
- };
- this.notifyScriptInjectionFinished = function(e, c) {
- var d = {};
- d.message = "ScriptInjectionFinished";
- d.id = e;
- d.result = c;
- this.sendMessage(d)
- };
- this.changeIframeCSSPosition = function() {
- if ((typeof this.config.changeCSSPositionZoomThreshold !== "undefined") && (this.config.changeCSSPositionZoomThreshold !== 0)) {
- var d = window[fnNameSpace].displayUtils.getIframeZoomLevel();
- var c = this.dom.style.position;
- if (d < this.config.changeCSSPositionZoomThreshold) {
- if (c === "fixed") {
- this._setIframeCSSPosition("absolute");
- this.iframePositionStateChanged = true
- }
- } else {
- if ((this.iframePositionStateChanged) && (c == "absolute")) {
- this._setIframeCSSPosition("fixed");
- this.iframePositionStateChanged = false
- }
- }
- }
- return this._handleZoomThreshold()
- };
- this._setIframeCSSPosition = function(c) {
- if (window[fnNameSpace].dragdropManager) {
- window[fnNameSpace].dragdropManager.setDragStyle("position", c)
- }
- window[fnNameSpace].util.setStyleWithImportant(this.dom, "position", c, true);
- this.config.Position = c;
- this.move(this.config)
- };
- this.calcAbsolutePosition = function(j) {
- if (this.getStylePosition() !== "absolute") {
- return {
- top: j.Top,
- left: j.Left,
- bottom: j.Bottom,
- right: j.Right
- }
- }
- var x = manager.currentToolbar;
- var s = this.dom.style.display;
- var u = this.dom.style.visibility;
- if (s === "none") {
- window[fnNameSpace].util.setStyleWithImportant(this.dom, "visibility", "hidden", true);
- window[fnNameSpace].util.setStyleWithImportant(this.dom, "display", "block", true)
- }
- var n;
- var c;
- var m = window[fnNameSpace].displayUtils;
- var t = m.getVisualViewportInfo();
- var z = t.width;
- var f = t.height;
- if (j.Top && (j.Top === "0px" || j.Top === "0%")) {
- c = 0
- } else {
- if (j.Bottom && (j.Bottom === "0px" || j.Bottom === "0%")) {
- c = (f - x.dom.offsetHeight) / f
- }
- }
- if (j.Left && (j.Left === "0px" || j.Left === "0%")) {
- n = 0
- } else {
- if (j.Right && (j.Right === "0px" || j.Right === "0%")) {
- n = (z - x.dom.offsetWidth) / z
- } else {
- if ((j.Right && j.Right === "50%") || (j.Left && j.Left === "50%") || ((j.Position && j.Position === "relative") && (j.Margin && j.Margin === "auto"))) {
- n = ((z - x.dom.offsetWidth) / z) / 2
- }
- }
- }
- var q = m.getBodyZoomLevel();
- var l = window.pageYOffset / q;
- var y = window.pageXOffset / q;
- var r = 0;
- var o = m.getComputedStyle(document.body, "position");
- var g = m.getComputedStyle(document.body, "top");
- if ((o && o !== "static" && o !== "relative") && (g && !isNaN(g))) {
- try {
- r = parseFloat(g)
- } catch (w) {
- r = 0
- }
- }
- var v = 1;
- var k = 1;
- if (window[fnNameSpace].dragdropManager) {
- v = window[fnNameSpace].dragdropManager.getScreenPosRatio().vertical;
- k = window[fnNameSpace].dragdropManager.getScreenPosRatio().horizontal
- }
- var p = Math.max(l - r + ((f) * v * c), 0);
- var h = Math.max(y + ((z) * k * n), 0);
- window[fnNameSpace].util.setStyleWithImportant(this.dom, "display", s, true);
- window[fnNameSpace].util.setStyleWithImportant(this.dom, "visibility", u, true);
- var d = parseFloat(window[fnNameSpace].displayUtils.getComputedStyle(document.body, "right"));
- d = isNaN(d) ? 0 : d;
- p = parseInt(p) + "px";
- h = parseInt(h) + d + "px";
- return {
- top: p,
- left: h,
- bottom: "",
- right: ""
- }
- };
- this._handleZoomThreshold = function() {
- var d = window[fnNameSpace].displayUtils.isPortrait() ? this.config.hideZoomThreshold.portrait : this.config.hideZoomThreshold.landscape;
- if ((typeof d === "undefined") || (d === 0)) {
- return false
- }
- var c = window[fnNameSpace].displayUtils.getIframeZoomLevel();
- if (c < d) {
- window[fnNameSpace].domHelper.hideiFrameWithOpacity(0.3);
- return true
- } else {
- window[fnNameSpace].domHelper.showiFrameWithOpacity(0.6);
- return false
- }
- };
- this.init()
- };
- if (window[fnNameSpace].Toolbar) {
- window[fnNameSpace].Toolbar.prototype.initialToolbarIframeSpecificDevice = function(g, d) {
- var b = window[fnNameSpace].displayUtils.getComputedStyle(document.body, "position");
- var f = window[fnNameSpace].displayUtils.getVisualViewportInfo().height;
- var c = window[fnNameSpace].displayUtils.isPortrait();
- var a = false;
- var e = {
- portrait: {
- iPhone4: 416,
- iPhone5: 504
- },
- landscape: {
- iPhone4: 268,
- iPhone5: 268
- }
- };
- if (b === "absolute" && window[fnNameSpace].util.Browser.isIOS6) {
- if (c === true) {
- if ((window[fnNameSpace].util.Browser.isiPhone4 && f >= e.portrait.iPhone4) || (window[fnNameSpace].util.Browser.isiPhone5 && f >= e.portrait.iPhone5)) {
- a = true
- }
- } else {
- if ((window[fnNameSpace].util.Browser.isiPhone4 && f >= e.landscape.iPhone4) || (window[fnNameSpace].util.Browser.isiPhone5 && f >= e.landscape.iPhone5)) {
- a = true
- }
- }
- }
- if (a === true) {
- this._setIframeCSSPosition("absolute")
- }
- }
- }
- window[fnNameSpace].StageLogicManager = function(b) {
- this.parentTB = b;
- var k = null;
- var h = null;
- var j = null;
- var l = function(m) {
- j = m
- };
- var f = function() {
- if (j === null) {
- var m = window[fnNameSpace].displayUtils.getIFrameDesignDimensions();
- l(parseFloat(m.width) / parseFloat(m.height))
- }
- return j
- };
- var g = function(n, m) {
- if ((typeof n == "undefined") && (typeof m == "undefined")) {
- return
- }
- k = n;
- h = m
- };
- var e = function() {
- if (!d(k) || !d(h)) {
- return undefined
- } else {
- return {
- width: k,
- height: h
- }
- }
- };
- var d = function(m) {
- return window[fnNameSpace].util.validateWidthHeight(m)
- };
- var c = function(m, t, v) {
- v = v || 1;
- var x = {};
- if (!d(m) || !d(t)) {
- return undefined
- }
- var q = window[fnNameSpace].displayUtils.getVisualViewportInfo();
- var n = q.width;
- var r = q.height;
- var s, o;
- var p = window[fnNameSpace].util.isNumberPercentageBased(m);
- var u = window[fnNameSpace].util.isNumberPercentageBased(t);
- if (p && u) {
- s = n * parseFloat(m) / 100;
- o = r * parseFloat(t) / 100
- } else {
- if (p) {
- s = n * parseFloat(m) / 100;
- o = (parseFloat(s) * (1 / f()))
- } else {
- if (u) {
- o = r * parseFloat(t) / 100;
- s = (parseFloat(o) * f())
- } else {
- if (window[fnNameSpace].util.isNumberPixelBased(m) && window[fnNameSpace].util.isNumberPixelBased(t)) {
- s = (parseFloat(m) * v);
- o = (parseFloat(t) * v)
- }
- }
- }
- }
- x.width = Math.ceil(s) + "px";
- x.height = Math.ceil(o) + "px";
- return x
- };
- if (!this.changeParentTBSize) {
- this.changeParentTBSize = function(n, m) {
- window[fnNameSpace].util.setStyleWithImportant(this.parentTB.dom, "width", n, true);
- window[fnNameSpace].util.setStyleWithImportant(this.parentTB.dom, "height", m, true)
- }
- }
- var a = function(q, o, p, s) {
- manager.updateAllFramesWithWindowSize();
- if (s) {
- l(s)
- }
- var r = window[fnNameSpace].displayUtils.getIframeZoomLevel() / 100;
- var n = c(q, o, r);
- if (!n) {
- var m = e();
- if (!m) {
- m = window[fnNameSpace].displayUtils.getIFrameDesignDimensions()
- }
- n = c(m.width, m.height, r)
- }
- if (n && n.width && n.height) {
- this.changeParentTBSize(n.width, n.height);
- g(q, o);
- b.updateStageSize(n.width, n.height)
- }
- };
- this.resize = function(p, m, n, o) {
- a.call(this, p, m, n, o);
- b.move();
- if (window[fnNameSpace].dragdropManager != null) {
- window[fnNameSpace].dragdropManager.resize()
- }
- if (window[fnNameSpace].OverlayTextBox != null) {
- window[fnNameSpace].OverlayTextBox.resizeOverlayTextBox()
- }
- }
- };
- window[fnNameSpace].DOMHelper = function() {
- this.maxZIndexOnPage = 0;
- this.showiFrameTimeOut = 0;
- this.checkElementOnPageById = function(a) {
- if (!document.getElementById(a)) {
- return false
- }
- return true
- };
- this.checkElementOnPageByTag = function(a) {
- if (!document.getElementsByTagName(a)[0]) {
- return false
- }
- return true
- };
- this.checkElementOnPageByTagName = function(a) {
- return this.checkElementOnPageByTag(a)
- };
- this.getElementsByTagName = function(a) {
- if (!this.checkElementOnPageByTag(a)) {
- return false
- }
- return document.getElementsByTagName(a)
- };
- this.getElement = function(a) {
- if (!this.checkElementOnPageById(a)) {
- return false
- }
- return document.getElementById(a)
- };
- this.removeElement = function(a) {
- a.parentNode.removeChild(a)
- };
- this.removeElementById = function(b) {
- var a = this.getElement(b);
- if (a) {
- this.removeElement(a)
- }
- };
- this.hideElement = function(a) {
- if (this.isElementVisible(a)) {
- window[fnNameSpace].util.setStyleWithImportant(a, "display", "none", true)
- }
- };
- this.showElement = function(a) {
- if (!this.isElementVisible(a)) {
- window[fnNameSpace].util.setStyleWithImportant(a, "display", "block", true)
- }
- };
- this.hideiFrameWithOpacity = function(a) {
- window[fnNameSpace].util.setStyleWithImportant(manager.currentToolbar.dom, "-webkit-transition", "opacity " + a + "s ease", true);
- window[fnNameSpace].util.setStyleWithImportant(manager.currentToolbar.dom, "opacity", "0", true);
- window[fnNameSpace].util.setStyleWithImportant(manager.currentToolbar.dom, "pointer-events", "none", true)
- };
- this.showiFrameWithOpacity = function(c, b) {
- c = typeof c !== "undefined" ? c : 0;
- if (manager.currentToolbar.initialOpacityReset === true) {
- return
- }
- if (this.showiFrameTimeOut && this.showiFrameTimeOut > 1) {
- window.clearTimeout(this.showiFrameTimeOut)
- }
- var a = (b === true) ? 0 : 700;
- this.showiFrameTimeOut = window.setTimeout(function() {
- window[fnNameSpace].util.setStyleWithImportant(manager.currentToolbar.dom, "-webkit-transition", "opacity " + c + "s ease", true);
- window[fnNameSpace].util.setStyleWithImportant(manager.currentToolbar.dom, "opacity", manager.currentToolbar.lastOpacity, true);
- window[fnNameSpace].util.setStyleWithImportant(manager.currentToolbar.dom, "pointer-events", "all", true)
- }, a)
- };
- this.isElementVisible = function(a) {
- return (a.style.display !== "none")
- };
- this.getMaxZIndex = function(e) {
- var a = this.getElementsByTagName("*");
- var d = 0;
- for (var c = 0, f = a.length; c < f; c++) {
- var b = Number(a[c].style.zIndex);
- var g = Number(window[fnNameSpace].displayUtils.getComputedStyle(a[c], "zIndex"));
- if (g > b) {
- b = g
- }
- if (b > d) {
- d = b
- }
- }
- this.maxZIndexOnPage = d;
- return d
- };
- this.appendChildToHead = function(b) {
- var a = document.getElementsByTagName("head")[0];
- if (a == "undefined") {
- return false
- }
- a.appendChild(b);
- return true
- }
- };
- window[fnNameSpace].domHelper = new window[fnNameSpace].DOMHelper();
- window[fnNameSpace].Util = function() {
- this.useSerialization = true;
- this.TOOLBAR_DATA_TAG = "TBData";
- this.TOOLBAR_DATA_ITEM_TAG = "TBDataItem";
- this.TOOLBAR_DATA_ATTRIBUTE = "toolbardata";
- this.NAME_ATTRIBUTE = "name";
- this.VALUE_ATTRIBUTE = "value";
- this.FN_TOOLBAR_SCRIPT = "fn_toolbar_script";
- this.addEvent = function(event, func, capture, element) {
- if ((typeof event === "undefined") || (typeof func === "undefined")) {
- return
- }
- if (typeof capture === "undefined") {
- capture = false
- }
- if (typeof element === "undefined") {
- element = document
- }
- if (element.addEventListener) {
- element.addEventListener(event, func, capture)
- } else {
- if (element.attachEvent) {
- element.attachEvent("on" + event, func)
- } else {
- element[event] = func
- }
- }
- };
- this.setStyleWithImportant = function(element, prop, value, important) {
- if (element.style.setProperty) {
- element.style.setProperty(prop, value, important ? "important" : "")
- } else {
- element.style[prop] = value
- }
- };
- this.removeEvent = function(event, func, capture, element) {
- if ((typeof event === "undefined") || (typeof func === "undefined")) {
- return
- }
- if (typeof capture === "undefined") {
- capture = false
- }
- if (typeof element === "undefined") {
- element = document
- }
- if (element.removeEventListener) {
- element.removeEventListener(event, func, capture)
- } else {
- if (element.detachEvent) {
- element.detachEvent("on" + event, func)
- } else {
- element[event] = null
- }
- }
- };
- this.LOG_TO_CONSOLE_MAP = {
- debug: "debug",
- info: "info",
- warn: "warn",
- error: "error"
- };
- this.console = function(msg, level) {
- var consoleLevel = this.LOG_TO_CONSOLE_MAP[level];
- if ((typeof console !== "undefined") && (typeof console[consoleLevel] === "function")) {
- console[consoleLevel](msg)
- } else {
- if ((typeof console !== "undefined") && (typeof console.log === "function") && (typeof consoleLevel !== "undefined")) {
- console.log("[" + consoleLevel + "]\t" + msg)
- }
- }
- };
- this.serialize = function(obj) {
- var t = typeof(obj);
- if (t != "object" || obj === null) {
- if (t == "string") {
- obj = '"' + obj + '"'
- }
- return String(obj)
- } else {
- var n, v, json = [],
- arr = (obj && obj.constructor == Array);
- for (n in obj) {
- if (obj.hasOwnProperty(n)) {
- v = obj[n];
- t = typeof(v);
- if (t == "string") {
- v = '"' + v + '"'
- } else {
- if (t == "object" && v !== null) {
- v = JSON.stringify(v)
- }
- }
- json.push((arr ? "" : '"' + n + '":') + String(v))
- }
- }
- return (arr ? "[" : "{") + String(json) + (arr ? "]" : "}")
- }
- };
- this.deserialize = function(jsonString) {
- try {
- if (jsonString === "") {
- jsonString = '""'
- }
- eval("var object=" + jsonString + ";");
- return object
- } catch (ex) {
- this.console("Deserialize error! on string: " + jsonString, "info");
- return
- }
- };
- this.registerLoadFunction = function(func) {
- if (window.addEventListener) {
- window.addEventListener("load", func, false)
- } else {
- if (window.attachEvent) {
- window.attachEvent("onload", func)
- } else {
- var tmp1 = window.onload;
- if (tmp1) {
- window.onload = function() {
- func();
- tmp1()
- }
- } else {
- window.onload = func
- }
- }
- }
- };
- this.fetchGetVariableValue = function(variable) {
- var query = window.location.search.substring(1);
- var vars = query.split("&");
- for (var i = 0; i < vars.length; i++) {
- var pair = vars[i].split("=");
- if (pair[0] == variable) {
- return pair[1]
- }
- }
- return false
- };
- this.xmlToObject = function(string, rootTag, item, keyTag, valueTag) {
- var parser;
- var response;
- try {
- parser = new DOMParser();
- response = parser.parseFromString(string, "text/xml");
- response = this.parseDataXML(response, rootTag, item, keyTag, valueTag);
- return response
- } catch (e) {}
- };
- this.parseDataXML = function(xml, rootTag, item, keyTag, valueTag) {
- var returnObj = new Object();
- var elem;
- var valuesArray;
- if (xml && xml.firstChild) {
- elem = xml.firstChild;
- if (xml.firstChild.target == "xml") {
- elem = xml.firstChild.nextSibling
- }
- if (elem.tagName == rootTag) {
- if (elem.children) {
- valuesArray = elem.children
- } else {
- valuesArray = elem.childNodes
- }
- }
- }
- if (valuesArray) {
- window[fnNameSpace].util.console("--------------------------- parsing " + rootTag + " data xml. valuesArray=" + valuesArray.length, "data")
- } else {
- window[fnNameSpace].util.console(" --------------------------- parsing " + rootTag + " data xml. valuesArray=" + valuesArray, "data")
- }
- if (valuesArray) {
- for (var i = 0; i < valuesArray.length; i++) {
- if (valuesArray[i].tagName != item) {
- continue
- }
- var key = valuesArray[i].getAttribute(keyTag);
- var value = valuesArray[i].getAttribute(valueTag);
- returnObj[key] = unescape(value)
- }
- }
- return returnObj
- };
- this.getCookieData = function(cookieName) {
- var cookiePrefix = cookieName + "=";
- var cookies = document.cookie.split(";");
- for (var i = 0; i < cookies.length; i++) {
- var c = cookies[i];
- while (c.charAt(0) == " ") {
- c = c.substring(1, c.length)
- }
- var indx = c.indexOf(cookiePrefix);
- if (indx >= 0) {
- return c.substring(indx + cookiePrefix.length, c.length)
- }
- }
- return null
- };
- this.initXMLHttpClient = function() {
- var xmlhttp;
- try {
- xmlhttp = new XMLHttpRequest()
- } catch (e) {
- var XMLHTTP_IDS = new Array("MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP");
- var success = false;
- for (var i = 0; i < XMLHTTP_IDS.length && !success; i++) {
- try {
- xmlhttp = new ActiveXObject(XMLHTTP_IDS[i]);
- success = true
- } catch (e) {}
- }
- if (!success) {
- throw new Error("Unable to create XMLHttpRequest.")
- }
- }
- return xmlhttp
- };
- this.trim = function(string) {
- return string.replace(/^\s*/, "").replace(/\s*$/, "")
- };
- this.thread = function(method) {
- setTimeout(method, 1)
- };
- this.isInteger = function(input) {
- var pos = input.indexOf("px");
- if (pos != -1) {
- input = input.substr(0, pos - 1)
- }
- return (input.toString().search(/^-?[0-9]+$/) == 0)
- };
- this.loadScript = function(src, callback) {
- var head = document.getElementsByTagName("head")[0];
- var script = document.createElement("script");
- script.type = "text/javascript";
- var base = location.href.split("/");
- base.splice(-1, 1);
- base = base.join("/");
- var scriptPath = base + src;
- script.src = scriptPath;
- script.onreadystatechange = function() {
- if (this.readyState == "complete") {
- callback()
- }
- };
- script.onload = callback;
- head.appendChild(script)
- };
- this.clone = function(obj) {
- if (obj instanceof HTMLElement) {
- return obj.cloneNode()
- }
- var target = {};
- for (var i in obj) {
- if (obj.hasOwnProperty(i)) {
- if (typeof obj[i] == "object") {
- target[i] = this.clone(obj[i])
- } else {
- target[i] = obj[i]
- }
- }
- }
- return target
- };
- this.validateWidthHeight = function(widthOrHeight) {
- if (!isNaN(parseInt(widthOrHeight)) || (widthOrHeight === "auto")) {
- return true
- } else {
- return false
- }
- };
- this.isNumberPixelBased = function(number) {
- if (typeof number === "undefined") {
- return false
- }
- if (!isNaN(parseInt(number)) && (number.length >= 2) && number.substring(number.length - 2) === "px") {
- return true
- } else {
- return false
- }
- };
- this.isNumberPercentageBased = function(number) {
- if (typeof number === "undefined") {
- return false
- }
- if (!isNaN(parseInt(number)) && (number.length >= 1) && number.substring(number.length - 1) === "%") {
- return true
- } else {
- return false
- }
- };
- this.Browser = (function() {
- var userAgent = navigator.userAgent.toLowerCase();
- var docMode = document.documentMode;
- var isOpera = check(/opera/);
- var isChrome = check(/\bchrome\b/);
- var isWebKit = check(/webkit/);
- var isSafari = !isChrome && check(/safari/);
- var isIE = !isOpera && check(/msie/);
- var isIE7 = isIE && (check(/msie 7/) || docMode === 7);
- var isIE8 = isIE && (check(/msie 8/) && docMode != 7);
- var isIE9 = isIE && check(/msie 9/);
- var isIE10 = isIE && check(/msie 10/);
- var isFirefox = !isWebKit && check(/gecko/);
- var isFirefox3 = isFirefox && check(/rv:1\.9/);
- var isIOS = check(/iphone|ipad|ipod/);
- var isIOS5 = isIOS && check(/iphone os 5_/);
- var isIOS6 = isIOS && check(/iphone os 6_/);
- var isIOS7 = isIOS && check(/iphone os 7_/);
- var isIOS8 = isIOS && check(/iphone os 8_/);
- var isiPhone4 = isIOS && (window.screen.height == (960 / 2));
- var isiPhone5 = isIOS && (window.screen.height == (1136 / 2));
- var isWindows = check(/windows/);
- var isWindows7 = isWindows && check(/windows nt 6.1/);
- var isWindows8 = isWindows && check(/windows nt 6.2/);
- var isAndroid = check(/android/);
- var isAndroid23 = isAndroid && check(/android 2\.3/);
- var isAndroid40 = isAndroid && check(/android 4\.0/);
- var isAndroid41 = isAndroid && check(/android 4\.1/);
- var isMobile = isAndroid || isIOS;
- var isChromeOniPhone = isIOS && check(/\bcrios\b/);
- var isAndroidTablet = isAndroid && !(check(/mobile/));
- var isIpad = check(/ipad/);
- function check(re) {
- return re.test(userAgent)
- }
- return {
- isOpera: isOpera,
- isChrome: isChrome,
- isWebKit: isWebKit,
- isSafari: isSafari,
- isIE: isIE,
- isIE7: isIE7,
- isIE8: isIE8,
- isIE9: isIE9,
- isIE10: isIE10,
- isFirefox: isFirefox,
- isFirefox3: isFirefox3,
- isIOS: isIOS,
- isIOS5: isIOS5,
- isIOS6: isIOS6,
- isIOS7: isIOS7,
- isIOS8: isIOS8,
- isiPhone4: isiPhone4,
- isiPhone5: isiPhone5,
- isWindows: isWindows,
- isWindows7: isWindows7,
- isWindows8: isWindows8,
- isAndroid: isAndroid,
- isAndroid23: isAndroid23,
- isAndroid40: isAndroid40,
- isAndroid41: isAndroid41,
- isMobile: isMobile,
- isChromeOniPhone: isChromeOniPhone,
- isAndroidTablet: isAndroidTablet,
- isIpad: isIpad
- }
- })()
- };
- window[fnNameSpace].util = new window[fnNameSpace].Util();
- window[fnNameSpace].DisplayUtils = function() {
- var d = function() {
- if (typeof window.orientation === "undefined") {
- return false
- } else {
- return (window.orientation === 0) ? true : false
- }
- };
- var a = function(l, m) {
- var k = window.getComputedStyle(l, null) || {};
- return k[m] || l.style[m]
- };
- var c = function() {
- var k = window.getComputedStyle(document.body);
- var l = 1;
- if (k && k.zoom) {
- l = k.zoom;
- if (window[fnNameSpace].util.isNumberPercentageBased(l)) {
- l = parseFloat(l) / 100
- } else {
- if (!isNaN(parseFloat(l))) {
- l = parseFloat(l)
- }
- }
- }
- return l
- };
- var g = function() {
- var k = c();
- return {
- width: b("Width") / k,
- height: b("Height") / k
- }
- };
- var j = function() {
- return {
- width: (this.isPortrait()) ? screen.width : ((!window[fnNameSpace].util.Browser.isIOS) ? screen.width : screen.height),
- height: (this.isPortrait()) ? screen.height : ((!window[fnNameSpace].util.Browser.isIOS) ? screen.height : screen.width)
- }
- };
- var e = function() {
- var k = {};
- if (window[fnNameSpace].util.Browser.isAndroid) {
- var l = h();
- var m = "portrait";
- if (!d()) {
- m = "landscape"
- }
- k.width = l[m].width + "px";
- k.height = l[m].height + "px"
- } else {
- k.width = window[fnNameSpace].displayUtils.calcScreenSize().width;
- k.height = window[fnNameSpace].displayUtils.calcScreenSize().height
- }
- return k
- };
- var h = function() {
- var k = manager.currentToolbar.config;
- if (!k) {
- throw "Util.getDeviceDetails() - configuration not set"
- }
- var m = {};
- m.portrait = {};
- m.landscape = {};
- m.portrait.width = k.PortraitSize.Width;
- m.portrait.height = k.PortraitSize.Height;
- if (window[fnNameSpace].util.Browser.isIOS) {
- var l = 568;
- var n = 480;
- if (window.screen.height === l) {
- m.landscape.width = (l / n) * k.LandscapeSize.Width
- } else {
- m.landscape.width = k.LandscapeSize.Width
- }
- } else {
- m.landscape.width = k.LandscapeSize.Width
- }
- m.landscape.height = k.LandscapeSize.Height;
- return m
- };
- var f = function() {
- var n;
- try {
- var m = g();
- var k = e();
- n = ((m.width / parseInt(k.width)) * 100)
- } catch (l) {
- n = 100
- }
- return n
- };
- var b = function(n) {
- if (window[fnNameSpace].util.Browser.isAndroid23) {
- return window["inner" + n]
- } else {
- if (window[fnNameSpace].util.Browser.isIOS) {
- return window["inner" + n]
- } else {
- if (window[fnNameSpace].util.Browser.isAndroid) {
- var m;
- m = window["inner" + n] !== 0 && window["inner" + n];
- m = m || document.documentElement && document.documentElement["client" + n] !== 0 && document.documentElement["client" + n];
- m = m || document.body["client" + n];
- return m
- } else {
- var l = document.documentElement && document.documentElement["client" + n] !== 0 && document.documentElement["client" + n];
- if (window[fnNameSpace].util.Browser.isIE) {
- return l || document.documentElement["offset" + n]
- }
- var m;
- var k = document.documentElement && document.documentElement["scroll" + n] !== 0 && document.documentElement["scroll" + n];
- if ((k && l) && (k === l)) {
- if (window[fnNameSpace].util.Browser.isFirefox) {
- m = window["inner" + n] !== 0 && window["inner" + n]
- } else {
- m = document.body["client" + n]
- }
- }
- m = m || l;
- m = m || window["inner" + n] !== 0 && window["inner" + n];
- m = m || document.body["client" + n];
- return m
- }
- }
- }
- };
- return {
- isPortrait: d,
- getComputedStyle: a,
- getBodyZoomLevel: c,
- getVisualViewportInfo: g,
- getIFrameDesignDimensions: e,
- getIframeZoomLevel: f,
- calcScreenSize: j
- }
- };
- window[fnNameSpace].displayUtils = new window[fnNameSpace].DisplayUtils();
- window[fnNameSpace].Message = function() {
- this.assignedObject;
- this.assignTo = function(c) {
- this.assignedObject = c;
- var b = this;
- window[fnNameSpace].util.addEvent("message", function(d) {
- b.handleMessage.call(b, d)
- }, false, window);
- window[fnNameSpace].util.console("Message handler assigned")
- };
- this.send = function(c, b) {
- if (!b) {
- return false
- }
- if ((typeof(window[fnNameSpace].Manager) != "undefined") && ((b.tagName == "IFRAME" || b.tagName == "iframe"))) {
- b = b.contentWindow
- } else {
- if (b != parent) {
- return false
- }
- }
- c.messageKey = fnMessageKey;
- if (window[fnNameSpace].util.useSerialization) {
- c = window[fnNameSpace].util.serialize(c)
- }
- b.postMessage(c, "*");
- return true
- };
- var a = function(b) {
- if (typeof b == "undefined") {
- return false
- }
- if (typeof b == "object") {
- if (typeof b.messageKey != "string") {
- return false
- }
- if (b.messageKey != fnMessageKey) {
- return false
- }
- } else {
- if (typeof b == "string") {
- if (typeof b.search != "function") {
- return false
- }
- if (b.search(fnMessageKey) == -1) {
- return false
- }
- if (b.search("message") == -1) {
- return false
- }
- if (b.search("function") != -1) {
- return false
- }
- } else {
- return false
- }
- }
- return true
- };
- this.triggerMessageEvent = function(c) {
- var b;
- window[fnNameSpace].util.console("Sending message: " + window[fnNameSpace].util.serialize(c), "messaging");
- if (!this.assignedObject) {
- window[fnNameSpace].util.console("Unable to send message message.message. no object assigned. ", "messaging");
- return
- }
- b = "on" + c.message;
- var d = typeof this.assignedObject[b];
- if (d !== "function") {
- window[fnNameSpace].util.console("called event " + b + " was not found", "messaging");
- return
- }
- this.assignedObject[b](c)
- };
- this.handleMessage = function(c) {
- var b = c.data;
- if (!a(b)) {
- window[fnNameSpace].util.console("Invalid message rejected! " + window[fnNameSpace].util.serialize(b), "messaging");
- return false
- }
- if (typeof(b) !== "object") {
- b = window[fnNameSpace].util.deserialize(b)
- }
- this.triggerMessageEvent(b)
- }
- };
- window[fnNameSpace].message = new window[fnNameSpace].Message();
- var fnMessageKey = "FNMESSAGEKEY78dh782ijhk8abn2";
- window[fnNameSpace].Message.MessageQueue = function() {
- var a = 100;
- var c = true;
- var b = [];
- this.removeOldMessages = true;
- this.add = function(d) {
- while (b.length >= a) {
- if (this.removeOldMessages) {
- this.shift()
- } else {
- return
- }
- }
- c = false;
- b.push(d)
- };
- this.shift = function() {
- if (c) {
- return false
- }
- var d = b.shift();
- if ((!d) || (d == null)) {
- c = true;
- return false
- }
- return d
- };
- this.setMaxQueuedMessages = function(d) {
- if (parseInt(d) != d) {
- throw "Cant set new max queued messages, excepting integer. sent value: " + d
- }
- if (a === d) {
- return
- }
- a = d;
- while (a < b.length) {
- this.shift()
- }
- }
- };
- window[fnNameSpace].ViewPort = function(c) {
- var k;
- var g = this;
- var d = function(m) {
- m = m || {};
- k = m.metaObject;
- if (k) {
- f(k)
- } else {
- l(m)
- }
- };
- var e = function() {
- var m = window[fnNameSpace].ViewPort.VIEWPORT_PROPERTIES;
- for (var n in m) {
- var o = b(n);
- g[o] = m[n]
- }
- };
- var l = function(n) {
- var m = "";
- for (var o in n) {
- if ((typeof n[o] != "function") && (typeof o != "undefined") && (o.length >= "content".length) && (o.substring(0, "content".length) == "content") && (typeof n[o] != "undefined")) {
- if (m.length) {
- m = m + ", "
- }
- m = m + h(o) + "=" + n[o]
- }
- }
- g.setMetaObj(m)
- };
- var a = function() {
- var m = document.createElement("meta");
- m.name = "viewport";
- m.content = "";
- m.id = "FNViewport";
- return m
- };
- var f = function(n) {
- var m = n.content;
- var o = m.split(",");
- if (o.length == 1) {
- o = o[0].split(";")
- }
- e();
- for (var p = 0; p < o.length; p++) {
- j(o[p])
- }
- };
- var j = function(m) {
- m = m.toLowerCase();
- m = m.replace(/^\s+|\s+$/g, "");
- var n = m.split("=");
- var o = b(n[0]);
- if (o) {
- g[o] = n[1]
- } else {
- window[fnNameSpace].util.console("Could not read VP variable: " + n[0] + " value:" + n[1])
- }
- };
- var b = function(n) {
- n = window[fnNameSpace].util.trim(n);
- switch (n) {
- case "width":
- case "height":
- return "content" + n.substr(0, 1).toUpperCase() + n.substr(1);
- break;
- case "initial-scale":
- case "minimum-scale":
- case "maximum-scale":
- case "user-scalable":
- var m = n.split("-");
- m[0] = m[0].substr(0, 1).toUpperCase() + m[0].substr(1);
- m[1] = m[1].substr(0, 1).toUpperCase() + m[1].substr(1);
- return "content" + m[0] + m[1];
- break;
- default:
- window[fnNameSpace].util.console("Could not read VP variable: " + n);
- break
- }
- };
- var h = function(o) {
- var n = o.match(/[A-Z][a-z]*/g);
- var p = "";
- for (var m = 0; m < n.length; m++) {
- if (p.length) {
- p += "-"
- }
- p += n[m].substr(0, 1).toLowerCase() + n[m].substr(1)
- }
- window[fnNameSpace].util.console(o + " converted to : " + p);
- return p
- };
- this.getMetaObj = function() {
- return k
- };
- this.setMetaObj = function(m) {
- if (!k) {
- k = a()
- }
- if (typeof m === "string") {
- k.content = m
- } else {
- k.content = m.content
- }
- f(k)
- };
- this.updateMetaObj = function(m) {
- l(m)
- };
- this.update = function(n) {
- var m = n.getMetaObj();
- this.setMetaObj(m)
- };
- this.clone = function() {
- var m = {
- metaObject: this.getMetaObj().cloneNode()
- };
- var n = new window[fnNameSpace].ViewPort(m);
- return n
- };
- d(c);
- return this
- };
- window[fnNameSpace].ViewPort.isMobileAwareSite = function() {
- var c = window[fnNameSpace].ViewPort.getViewports();
- var a;
- var d;
- for (var b = 0; b < c.length; b++) {
- a = c[b];
- d = a.getMetaObj();
- if ((d.content.toLowerCase().indexOf("minimum-scale=1") != -1) || (d.content.toLowerCase().indexOf("maximum-scale=1") != -1) || (d.content.toLowerCase().indexOf("user-scalable=no") != -1) || (d.content.toLowerCase().indexOf("width=device-width") != -1)) {
- return true
- }
- }
- return false
- };
- window[fnNameSpace].ViewPort.getViewports = function() {
- var b = new Array();
- if (!window[fnNameSpace].domHelper.checkElementOnPageByTagName("META")) {
- return b
- }
- var a = window[fnNameSpace].domHelper.getElementsByTagName("META");
- for (var c = 0; c < a.length; c++) {
- if (a[c].name.toLowerCase() == "viewport") {
- b.push(new window[fnNameSpace].ViewPort({
- metaObject: a[c]
- }))
- }
- }
- if (b) {
- return b
- }
- };
- window[fnNameSpace].ViewPort.disableUserScalable = function() {
- if (window[fnNameSpace].ViewPort.isMobileAwareSite()) {
- return
- }
- window[fnNameSpace].ViewPort.originalViewPortContent = null;
- var c = document.getElementsByTagName("meta");
- var e = -1;
- while (c[++e]) {
- if (c[e].name === "viewport") {
- var d = c[e].content;
- if (d.search("user-scalable=no") !== -1) {
- return
- } else {
- var b = d.search("user-scalable=yes");
- if (b !== -1) {
- d = d.replace("user-scalable=yes", "user-scalable=no")
- } else {
- d = "user-scalable=no, " + d
- }
- }
- window[fnNameSpace].ViewPort.originalViewPortContent = c[e].content;
- c[e].content = d;
- return
- }
- }
- var a = document.createElement("meta");
- a.id = fnNameSpace + "_ViewPortMetaTagId";
- a.name = "viewport";
- a.content = "user-scalable=no";
- document.head.appendChild(a)
- };
- window[fnNameSpace].ViewPort.restoreUserScalable = function() {
- if (window[fnNameSpace].ViewPort.originalViewPortContent) {
- var b = document.getElementsByTagName("meta");
- var c = -1;
- while (b[++c]) {
- if (b[c].name === "viewport") {
- b[c].content = "user-scalable=yes";
- b[c].content = window[fnNameSpace].ViewPort.originalViewPortContent;
- window[fnNameSpace].ViewPort.originalViewPortContent = null;
- return
- }
- }
- } else {
- var a = document.getElementById(fnNameSpace + "_ViewPortMetaTagId");
- if (a !== null) {
- a.content = "user-scalable=yes";
- document.head.removeChild(a)
- }
- }
- };
- window[fnNameSpace].ViewPort.createDefaultViewport = function() {};
- window[fnNameSpace].ViewPort.VIEWPORT_PROPERTIES = {
- width: "",
- height: "",
- "initial-scale": "",
- "minimum-scale": "",
- "maximum-scale": "",
- "user-scalable": ""
- };
- window[fnNameSpace].StopWatchManager = function() {
- this.watches = [];
- this.startNew = function(b, f, e, d) {
- var c;
- if ((!b) || (!f)) {
- return false
- }
- if (!e) {
- e = ""
- }
- if (d) {
- c = window.setTimeout(b, f)
- } else {
- c = window.setInterval(b, f)
- }
- var a = (this.watches.length != false) ? this.watches.length : 1;
- this.watches[a] = [];
- this.watches[a].watchId = c;
- this.watches[a].tickTime = f;
- this.watches[a].comment = e;
- this.watches[a].tickOnce = d;
- this.watches[a].methodToExecute = b;
- this.watches[a].frozen = false;
- return a
- };
- this.getRealWatchId = function(a) {
- return this.watches[a].watchId
- };
- this.start = function(b) {
- if (this.watches[b].frozen == false) {
- return
- }
- var a = this.watches[b];
- this.remove(b);
- return this.startNew(a.methodToExecute, a.tickTime, a.comment, a.tickOnce)
- };
- this.stop = function(a) {
- this.watches[a].frozen = true;
- clearInterval(this.getRealWatchId(a))
- };
- this.remove = function(a) {
- this.stop(a);
- delete this.watches[a]
- }
- };
- window[fnNameSpace].stopWatchMgr = new window[fnNameSpace].StopWatchManager();
- window[fnNameSpace].StopWatch = function() {
- this.watchId = null;
- this.isRunning = false;
- this.tickMethod = null;
- this.create = function(a, e, d, c) {
- var b = null;
- b = window[fnNameSpace].stopWatchMgr.startNew(a, e, d, c);
- if (b) {
- this.watchId = b;
- this.isRunning = true;
- this.tickMethod = a;
- return true
- }
- return false
- };
- this.tick = function() {
- this.tickMethod()
- };
- this.start = function() {
- if (this.isRunning) {
- return
- }
- this.watchId = window[fnNameSpace].stopWatchMgr.start(this.watchId);
- this.isRunning = true
- };
- this.stop = function() {
- window[fnNameSpace].stopWatchMgr.stop(this.watchId);
- this.isRunning = false
- };
- this.remove = function() {
- window[fnNameSpace].stopWatchMgr.remove(this.watchId);
- this.isRunning = false
- }
- };
- window[fnNameSpace].FlashPlayerManager = function() {
- this.modifyFlashPlayerWmode = function() {
- if (window[fnNameSpace].util.Browser.isIE) {
- this._changeWmodeOnYoutube()
- } else {
- if (window[fnNameSpace].util.Browser.isFirefox || window[fnNameSpace].util.Browser.isFirefox3 || window[fnNameSpace].util.Browser.isSafari || window[fnNameSpace].util.Browser.isOpera) {
- this._changeWmodeOn("embed");
- this._changeObjectType("application/x-silverlight", "windowless", "true")
- } else {
- if (window[fnNameSpace].util.Browser.isChrome) {
- this._changeObjectType("application/x-silverlight", "windowless", "true")
- }
- }
- }
- };
- this._changeWmodeOnYoutube = function() {
- try {
- if (!document) {
- return false
- }
- var b = document.getElementsByTagName("object");
- if (!b) {
- return false
- }
- if (location.host.search("youtube") < 0) {
- return false
- }
- for (var h = 0; h < b.length; h++) {
- var g = b[h];
- var a = location.href.split("?")[0].replace(/watch/, "embed/");
- var d = location.href.split("?")[1].split("&");
- for (var h = 0; h < d.length; h++) {
- if (d[h].split("v=").length > 1) {
- a += d[h].split("v=")[1];
- d.splice(h, 1);
- break
- }
- }
- d.push("wmode=opaque");
- a += "?" + d.join("&");
- var l = g.clientHeight;
- var c = g.clientWidth;
- var k = g.parentElement;
- k.removeChild(k.firstChild);
- var f = document.createElement("iframe");
- f.setAttribute("src", a);
- f.setAttribute("height", l);
- f.setAttribute("width", c);
- k.appendChild(f)
- }
- } catch (j) {
- return false
- }
- return true
- };
- this._changeWmodeOn = function(c) {
- try {
- if (!document) {
- return false
- }
- var b = document.getElementsByTagName(c);
- if (!b) {
- return false
- }
- for (var a = 0; a < b.length; a++) {
- if ((b[a].getAttribute("wmode") == null) || (b[a].getAttribute("wmode").toLowerCase() == "window")) {
- b[a].setAttribute("wmode", "opaque");
- if (b[a].outerHTML) {
- b[a].outerHTML = b[a].outerHTML
- }
- }
- }
- } catch (d) {
- return false
- }
- return true
- };
- this._changeObjectType = function(m, g, b) {
- try {
- if (!document) {
- return false
- }
- var n = document.getElementsByTagName("object");
- if (!n) {
- return false
- }
- for (var f = 0; f < n.length; f++) {
- if (n[f].type.search(m) < 0) {
- continue
- }
- var k = n[f].getElementsByTagName("param");
- var d = false;
- if (k) {
- for (var c = 0; c < k.length; c++) {
- var h = k[c].getAttribute("name");
- if (h && h.toLowerCase() == g) {
- k[c].setAttribute("value", b);
- d = true;
- break
- }
- }
- if (!d) {
- var a = document.createElement("param");
- a.setAttribute("name", g);
- a.setAttribute("value", b);
- n[f].appendChild(a)
- }
- n[f].outerHTML = n[f].outerHTML
- }
- }
- } catch (l) {
- return false
- }
- return true
- }
- };
- window[fnNameSpace].DragDropManager = function(a) {
- this._params = a;
- this._isMoveByTouch = false;
- this._offset = {
- x: 0,
- y: 0
- };
- this._dragDivMiddle = {
- x: 0,
- y: 0
- };
- this._inSuspendMode = false;
- this._screenDimensions = {
- width: 0,
- height: 0
- };
- this._screenPosRatio = {
- horizontal: 1,
- vertical: 1
- };
- this._screenPosRatioLast = {
- horizontal: 1,
- vertical: 1
- };
- this._lastPosition = {
- horizontal: "TB_HORIZONTAL_POSITION_RIGHT",
- vertical: "TB_VERTICAL_POSITION_BOTTOM"
- };
- this._currentOrientation = manager.lastNotifiedOrientation;
- this.restInitialIframePositioning = function() {
- var c = {
- Top: this._params.initTop,
- Left: this._params.initLeft,
- Bottom: this._params.initBottom,
- Right: this._params.initRight
- };
- this._screenPosRatio = {
- horizontal: 1,
- vertical: 1
- };
- var b = manager.currentToolbar.calcAbsolutePosition(c);
- this.moveDragDiv(null, b)
- };
- this.enableDragState = function(b) {
- if (this._params.dragToolbarPosition === "fixed") {
- return
- }
- if (!manager) {
- return
- }
- var c = manager.currentToolbar.dom;
- if (c) {
- if (b || b == null) {
- this._screenPosRatio = this._screenPosRatioLast;
- if ((manager) && ((manager.tbstatus.isMinimize && this._params.allowDragMinimize) || (!manager.tbstatus.isMinimize && this._params.allowDragMaximize))) {
- manager.loadToolbarPosition()
- }
- } else {
- this.showDragDiv(false);
- this._screenPosRatioLast = this._screenPosRatio;
- this.restInitialIframePositioning()
- }
- }
- };
- this.handleOnClick = function(b, c) {
- if (b._isMaximized === true) {
- manager.minimizeToolbarRequest()
- } else {
- manager.maximizeToolbarRequest()
- }
- };
- this.registerDragSupport = function() {
- window[fnNameSpace].util.console("Toolbar registration for Drag and Drop.");
- try {
- if (this._params.dragToolbarPosition == "fixed") {
- this.restInitialIframePositioning();
- return
- }
- var d = document.createElement("div");
- d.setAttribute("id", "dragDiv");
- if (!window[fnNameSpace].util.Browser.isIOS5) {
- window[fnNameSpace].util.setStyleWithImportant(d, "-webkit-transform", "translateZ(999px)", true)
- }
- window[fnNameSpace].DragDropManager.setElementStyle(d, this);
- document.body.appendChild(d);
- var b = this;
- this.addEvent(d, "touchstart", function(e) {
- if (e.preventDefault) {
- e.preventDefault()
- }
- var f = e.target || e.srcElement || e.originalTarget || this;
- b._isMoveByTouch = false;
- window[fnNameSpace].util.setStyleWithImportant(f, "opacity", "0.7", true);
- b._dragDivMiddle.x = parseInt(f.style.width) / 2;
- b._dragDivMiddle.y = parseInt(f.style.height) / 2;
- var g = b.getPosition(f);
- b._offset = {
- x: e.targetTouches[0].pageX - g.left,
- y: e.targetTouches[0].pageY - g.top
- };
- b._screenDimensions = {
- width: g.width,
- height: g.height
- }
- });
- this.addEvent(d, "touchmove", function(f) {
- f.stopPropagation();
- if (f.touches.length != 1) {
- return
- }
- var g = f.target || f.srcElement || f.originalTarget || this;
- var e = 0;
- var h = 0;
- if (g.style.position === "absolute") {
- e = f.targetTouches[0].pageX - b._offset.x;
- h = f.targetTouches[0].pageY - b._offset.y;
- e = e < 0 ? 0 : ((e + g.offsetWidth) > b._screenDimensions.width) ? (e = b._screenDimensions.width - g.offsetWidth) : e
- } else {
- e = f.targetTouches[0].pageX - pageXOffset - b._dragDivMiddle.x;
- h = f.targetTouches[0].pageY - pageYOffset - b._dragDivMiddle.y
- }
- window[fnNameSpace].util.setStyleWithImportant(g, "left", e + "px", true);
- window[fnNameSpace].util.setStyleWithImportant(g, "top", h + "px", true);
- window[fnNameSpace].util.setStyleWithImportant(g, "bottom", "auto", true);
- window[fnNameSpace].util.setStyleWithImportant(g, "right", "auto", true);
- b._isMoveByTouch = true;
- f.preventDefault()
- });
- this.addEvent(d, "touchend", function(f) {
- var h = f.target || f.srcElement || f.originalTarget || this;
- window[fnNameSpace].util.setStyleWithImportant(h, "opacity", "0", true);
- if (b._isMoveByTouch) {
- b._isMoveByTouch = false;
- var e = {
- top: "",
- left: "",
- bottom: "",
- right: ""
- };
- var g = b.getDimensions(h);
- if (h.style.position === "absolute") {
- e = b.calcPositionByXY(h, h.offsetLeft - pageXOffset, h.offsetTop - pageYOffset);
- b.updateScreenRatio(g, e);
- e = b.getAbsolutePosition(g, e)
- } else {
- e = b.calcPositionByXY(h, h.offsetLeft, h.offsetTop);
- b.updateScreenRatio(g, e)
- }
- b.moveDragDiv(h, e);
- if (manager) {
- manager.storeToolbarPosition(b._lastPosition.vertical, b._lastPosition.horizontal)
- }
- } else {
- b.handleOnClick(b, f)
- }
- });
- this.enableDragState(false);
- this.suspendDragDrop()
- } catch (c) {}
- };
- this.suspendDragDrop = function() {
- var b = manager.tbstatus.suspendDragDrop;
- if (b && !this._inSuspendMode) {
- this.enableDragState(false);
- this._inSuspendMode = true
- } else {
- if (!b && this._inSuspendMode) {
- this.enableDragState(true);
- this._inSuspendMode = false
- }
- }
- };
- this.getPosition = function(c) {
- var b = window[fnNameSpace].displayUtils.getVisualViewportInfo();
- var e = 0;
- var d = 0;
- if (c.offsetParent) {
- e = c.offsetLeft;
- d = c.offsetTop;
- while (c = c.offsetParent) {
- e += c.offsetLeft;
- d += c.offsetTop
- }
- }
- return {
- left: e,
- top: d,
- width: b.width,
- height: b.height
- }
- };
- this.getDimensions = function(d) {
- var g = false;
- if (d.style.display !== "block") {
- g = true;
- var f = d.style.visibility;
- var c = d.style.display;
- window[fnNameSpace].util.setStyleWithImportant(d, "visibility", "hidden", true);
- window[fnNameSpace].util.setStyleWithImportant(d, "display", "block", true)
- }
- var e = d.offsetWidth;
- var b = d.offsetHeight;
- if (g) {
- window[fnNameSpace].util.setStyleWithImportant(d, "visibility", f, true);
- window[fnNameSpace].util.setStyleWithImportant(d, "display", c, true)
- }
- return {
- offsetWidth: e,
- offsetHeight: b
- }
- };
- this.getScreenPosRatio = function() {
- return this._screenPosRatio
- };
- this.calcPosition = function(g) {
- var f = {
- top: "",
- left: "",
- bottom: "",
- right: ""
- };
- var e = window[fnNameSpace].displayUtils.getVisualViewportInfo();
- var d = e.height;
- var c = e.width;
- var b = d / 2;
- if (this._lastPosition.vertical === "TB_VERTICAL_POSITION_TOP") {
- f.top = this._params.verticalMargin
- } else {
- if (this._lastPosition.vertical === "TB_VERTICAL_POSITION_MIDDLE") {
- f.bottom = (b - (g.offsetHeight / 2)) + "px"
- } else {
- if (this._lastPosition.vertical === "TB_VERTICAL_POSITION_BOTTOM") {
- f.bottom = this._params.verticalMargin
- } else {
- if (this._lastPosition.vertical && this._lastPosition.vertical.length > 0) {
- percentagesHeight = Math.max((d - g.offsetHeight) / d, 0);
- f.top = this._lastPosition.vertical = this._screenPosRatio.vertical * d * percentagesHeight + "px"
- } else {
- f.bottom = this._params.initBottom;
- f.top = this._params.initTop
- }
- }
- }
- }
- if (this._lastPosition.horizontal === "TB_HORIZONTAL_POSITION_LEFT") {
- f.left = this._params.horizontalMargin
- } else {
- if (this._lastPosition.horizontal === "TB_HORIZONTAL_POSITION_RIGHT") {
- f.right = this._params.horizontalMargin
- } else {
- if (this._lastPosition.horizontal && this._lastPosition.horizontal.length > 0) {
- percentagesWidth = Math.max((c - g.offsetWidth) / c, 0);
- f.left = this._lastPosition.horizontal = this._screenPosRatio.horizontal * c * percentagesWidth + "px"
- } else {
- f.right = this._params.initRight;
- f.left = this._params.initLeft
- }
- }
- }
- return f
- };
- this.setPosition = function(b, f) {
- if (this._inSuspendMode) {
- return
- }
- if (b != null) {
- this._lastPosition.vertical = b
- }
- if (f != null) {
- this._lastPosition.horizontal = f
- }
- var e = document.getElementById("dragDiv");
- if (!e) {
- return
- }
- var d = this.getDimensions(e);
- var c = this.calcPosition(d);
- this.updateScreenRatio(d, c);
- if (e.style.position === "absolute") {
- c = this.getAbsolutePosition(d, c)
- }
- this.moveDragDiv(e, c);
- this.showDragDiv(true)
- };
- this.calcPositionByXY = function(c, g, f, e) {
- c = c || document.getElementById("dragDiv");
- if (!c) {
- return
- }
- var b = {
- top: "",
- left: "",
- bottom: "",
- right: ""
- };
- var d = window[fnNameSpace].displayUtils.getVisualViewportInfo();
- var l = d.width / 2;
- var k = d.height / 2;
- e = e || this._params.dragToolbarPosition;
- switch (e) {
- case "four":
- if (g < l) {
- b.left = this._params.horizontalMargin;
- this._lastPosition.horizontal = "TB_HORIZONTAL_POSITION_LEFT"
- } else {
- b.right = this._params.horizontalMargin;
- this._lastPosition.horizontal = "TB_HORIZONTAL_POSITION_RIGHT"
- }
- if (f < k) {
- b.top = this._params.verticalMargin;
- this._lastPosition.vertical = "TB_VERTICAL_POSITION_TOP"
- } else {
- b.bottom = this._params.verticalMargin;
- this._lastPosition.vertical = "TB_VERTICAL_POSITION_BOTTOM"
- }
- break;
- case "six":
- screenThirdY = d.height / 3;
- if (g < l) {
- b.left = this._params.horizontalMargin;
- this._lastPosition.horizontal = "TB_HORIZONTAL_POSITION_LEFT"
- } else {
- b.right = this._params.horizontalMargin;
- this._lastPosition.horizontal = "TB_HORIZONTAL_POSITION_RIGHT"
- }
- if (f < screenThirdY) {
- b.top = this._params.verticalMargin;
- this._lastPosition.vertical = "TB_VERTICAL_POSITION_TOP"
- } else {
- if ((f > screenThirdY) && f < (2 * screenThirdY)) {
- b.bottom = k - parseInt(c.offsetHeight / 2) + "px";
- this._lastPosition.vertical = "TB_VERTICAL_POSITION_MIDDLE"
- } else {
- b.bottom = this._params.verticalMargin;
- this._lastPosition.vertical = "TB_VERTICAL_POSITION_BOTTOM"
- }
- }
- break;
- default:
- var h = d.height - c.offsetHeight;
- var j = d.width - c.offsetWidth;
- b.top = this._lastPosition.vertical = (f > h ? h : (f < (c.offsetHeight / 4) ? 0 : f)) + "px";
- b.left = this._lastPosition.horizontal = (g > j ? j : (g < (c.offsetWidth / 4) ? 0 : g)) + "px";
- b.bottom = "";
- b.right = "";
- break
- }
- return b
- };
- this.getAbsolutePosition = function(e, b) {
- var d = {
- top: "",
- left: "",
- bottom: "",
- right: ""
- };
- var c = window[fnNameSpace].displayUtils.getVisualViewportInfo();
- if (b.top.length > 0) {
- d.top = parseInt(b.top) + pageYOffset + "px"
- } else {
- d.top = pageYOffset + c.height - parseInt(b.bottom) - e.offsetHeight + "px"
- }
- if (b.left.length > 0) {
- d.left = parseInt(b.left) + pageXOffset + "px"
- } else {
- d.left = pageXOffset + c.width - parseInt(b.right) - e.offsetWidth + "px"
- }
- return d
- };
- this.updateScreenRatio = function(g, b) {
- var f = this._lastPosition.vertical === "TB_VERTICAL_POSITION_MIDDLE" ? g.offsetHeight / 2 : 0;
- var e = window[fnNameSpace].displayUtils.getVisualViewportInfo();
- var d = e.width;
- var c = e.height;
- if (b.top.length > 0) {
- percentagesHeight = Math.max((c - g.offsetHeight), 0) / c;
- if (percentagesHeight != 0) {
- this._screenPosRatio.vertical = (parseInt(b.top) + f) / c / percentagesHeight
- }
- } else {
- this._screenPosRatio.vertical = (c - parseInt(b.bottom) - f) / c
- }
- if (b.left.length > 0) {
- percentagesWidth = Math.max((d - g.offsetWidth), 0) / d;
- if (percentagesWidth != 0) {
- this._screenPosRatio.horizontal = parseInt(b.left) / d / percentagesWidth
- }
- } else {
- this._screenPosRatio.horizontal = (d - parseInt(b.right)) / d
- }
- };
- this.repositionAfterZoom = function() {
- if (this.isDragDivEnable()) {
- this.setPosition()
- }
- };
- this.moveDragDiv = function(c, b) {
- c = c || document.getElementById("dragDiv");
- if (!c) {
- return false
- }
- window[fnNameSpace].util.setStyleWithImportant(c, "left", b.left === "" ? "auto" : b.left, true);
- window[fnNameSpace].util.setStyleWithImportant(c, "top", b.top === "" ? "auto" : b.top, true);
- window[fnNameSpace].util.setStyleWithImportant(c, "bottom", b.bottom === "" ? "auto" : b.bottom, true);
- window[fnNameSpace].util.setStyleWithImportant(c, "right", b.right === "" ? "auto" : b.right, true);
- manager.currentToolbar.setIframePositioning(b.top, b.bottom, b.left, b.right);
- return true
- };
- this.showDragDiv = function(b) {
- var c = document.getElementById("dragDiv");
- if (!c) {
- return
- }
- if (b) {
- window[fnNameSpace].util.setStyleWithImportant(c, "display", "block", true);
- window[fnNameSpace].util.setStyleWithImportant(c, "visibility", "", true);
- window[fnNameSpace].util.setStyleWithImportant(c, "z-index", 2147483647, true)
- } else {
- window[fnNameSpace].util.setStyleWithImportant(c, "display", "none", true);
- window[fnNameSpace].util.setStyleWithImportant(c, "visibility", "hidden", true);
- window[fnNameSpace].util.setStyleWithImportant(c, "z-index", "0", true)
- }
- };
- this.isDragDivEnable = function() {
- var b = document.getElementById("dragDiv");
- if (!b) {
- return false
- }
- if (b.style.display === "block") {
- return true
- }
- return false
- };
- this.setDragIcon = function(b) {
- var c = document.getElementById("dragDiv");
- if (!c) {
- return
- }
- window[fnNameSpace].util.setStyleWithImportant(c, "background-image", "url('" + b + "')", true)
- };
- this.setDragStyle = function(b, c) {
- var d = document.getElementById("dragDiv");
- if (!d) {
- return
- }
- d.style[b] = c
- };
- this.toolbarStateChanged = function() {
- try {
- var b = manager.tbstatus.isMinimize;
- if (typeof b === "undefined") {
- return
- } else {
- if (b) {
- this._isMaximized = false;
- this.enableDragState(this._params.allowDragMinimize)
- } else {
- this._isMaximized = true;
- this.enableDragState(this._params.allowDragMaximize)
- }
- }
- } catch (c) {}
- };
- this.resize = function() {
- var b = document.getElementById("dragDiv");
- if (b) {
- window[fnNameSpace].util.setStyleWithImportant(b, "width", manager.currentToolbar.dom.style.width, true);
- window[fnNameSpace].util.setStyleWithImportant(b, "height", manager.currentToolbar.dom.style.height, true);
- if (b.style.position === "fixed") {
- window[fnNameSpace].dragdropManager.repositionAfterZoom()
- }
- }
- };
- this.orientationChange = function(b) {
- this._currentOrientation = b
- };
- this.addEvent = (function() {
- if (document.addEventListener) {
- return function(e, d, c) {
- if (e && e.nodeName || e === window) {
- e.addEventListener(d, c, false)
- } else {
- if (e && e.length) {
- for (var b = 0; b < e.length; b++) {
- addEvent(e[b], d, c)
- }
- }
- }
- }
- } else {
- return function(e, d, c) {
- if (e && e.nodeName || e === window) {
- e.attachEvent("on" + d, function() {
- return c.call(e, window.event)
- })
- } else {
- if (e && e.length) {
- for (var b = 0; b < e.length; b++) {
- addEvent(e[b], d, c)
- }
- }
- }
- }
- }
- })()
- };
- if (window[fnNameSpace].DragDropManager) {
- window[fnNameSpace].DragDropManager.setElementStyle = function(a, b) {
- if (!a) {
- return
- }
- b = b || window;
- window[fnNameSpace].util.setStyleWithImportant(a, "min-height", "0px", true);
- window[fnNameSpace].util.setStyleWithImportant(a, "min-width", "0px", true);
- window[fnNameSpace].util.setStyleWithImportant(a, "border", "0", true);
- window[fnNameSpace].util.setStyleWithImportant(a, "margin", "0", true);
- window[fnNameSpace].util.setStyleWithImportant(a, "padding", "0", true);
- window[fnNameSpace].util.setStyleWithImportant(a, "background", "transparent", true);
- window[fnNameSpace].util.setStyleWithImportant(a, "opacity", "0", true);
- window[fnNameSpace].util.setStyleWithImportant(a, "background-size", "80%", true);
- window[fnNameSpace].util.setStyleWithImportant(a, "-webkit-user-select", "none", true);
- window[fnNameSpace].util.setStyleWithImportant(a, "display", "none", true);
- window[fnNameSpace].util.setStyleWithImportant(a, "position", "fixed", true);
- window[fnNameSpace].util.setStyleWithImportant(a, "background-image", "url('" + b._params.dragIconSrc + "')", true);
- window[fnNameSpace].util.setStyleWithImportant(a, "background-position", "50% 50%", true);
- window[fnNameSpace].util.setStyleWithImportant(a, "background-repeat", "no-repeat", true)
- }
- }
- if (top == window) {
- var manager = new window[fnNameSpace].Manager();
- var origOnLoadFnc = window.onload;
- window.onload = function(a) {
- if ((origOnLoadFnc !== "undefined") && (typeof(origOnLoadFnc) === "function")) {
- origOnLoadFnc.apply(window)
- }
- window[fnNameSpace].uiEventHandler.loadEvent(a)
- };
- var intrvl = null;
- var numberOfRetries = 50;
- var checkWhenLoadedDone = function() {
- if (intrvl == null) {
- return
- }
- if (document.readyState == "complete" || numberOfRetries == 0) {
- window.setTimeout(function() {
- manager.initManager()
- }, 1000)
- } else {
- intrvl = window.setTimeout(checkWhenLoadedDone, 500)
- }
- numberOfRetries--
- };
- if (document.readyState == "complete") {
- window.setTimeout(function() {
- manager.initManager()
- }, 1000)
- } else {
- if (document.readyState == "loaded" || document.readyState == "interactive") {
- if (intrvl == null) {
- intrvl = window.setTimeout(checkWhenLoadedDone, 500)
- }
- } else {
- window[fnNameSpace].util.registerLoadFunction(function() {
- window.setTimeout(function() {
- manager.initManager()
- }, 1000)
- })
- }
- }
- }
- if (window[fnNameSpace].Toolbar) {
- window[fnNameSpace].Toolbar.prototype.move = function(d) {
- if (this.config.Position === "fixed") {
- if (window[fnNameSpace].dragdropManager) {
- if (window[fnNameSpace].dragdropManager.isDragDivEnable()) {
- return
- }
- }
- manager.currentToolbar.setIframePositioning(this.config.Top, this.config.Bottom, this.config.Left, this.config.Right);
- return
- }
- var c = manager.currentToolbar;
- if (!d && !c.rememberedPositioning) {
- console.log("move: - missing positioning");
- return false
- }
- if (!d || (d == null) || (d == false)) {
- d = c.rememberedPositioning
- }
- c.rememberedPositioning = d;
- var a = c.calcAbsolutePosition(c.rememberedPositioning);
- if (window[fnNameSpace].dragdropManager) {
- window[fnNameSpace].dragdropManager.moveDragDiv(null, a);
- return
- }
- var b = Math.min(parseFloat(a.top), document.body.scrollHeight - parseFloat(manager.currentToolbar.dom.style.height));
- manager.currentToolbar.setIframePositioning(b + "px", "", a.left, "")
- };
- window[fnNameSpace].Toolbar.prototype.moveOffset = function(b) {
- if (!b) {
- return false
- }
- var a = 0;
- var c = 0;
- if (window[fnNameSpace].util.isNumberPixelBased(b.Top)) {
- a = b.Top
- }
- if (window[fnNameSpace].util.isNumberPixelBased(b.Left)) {
- c = b.Left
- }
- var f = manager.currentToolbar.getIframePositioning();
- var e = parseInt(f.top) + parseInt(a) + "px";
- var d = parseInt(f.left) + parseInt(c) + "px";
- manager.currentToolbar.setIframePositioning(e, f.bottom, d, f.right);
- return true
- };
- window[fnNameSpace].Toolbar.prototype.initialToolbarIframe = function() {
- var c = {
- "z-index": 2147483646,
- position: this.config.Position,
- padding: this.config.Padding,
- margin: this.config.Margin,
- border: this.config.Border,
- "min-width": "0px",
- "min-height": "0px",
- "max-width": "none",
- "max-height": "none",
- background: "transparent",
- "-webkit-transform": "translateZ(998px)"
- };
- if (!window[fnNameSpace].util.Browser.isIOS5) {
- c["-webkit-transform"] = "translateZ(998px)"
- }
- if (this.config.Opacity !== "undefined") {
- this.lastOpacity = this.config.Opacity
- }
- var a = {
- scrolling: this.config.ATT_Scrolling,
- frameborder: this.config.ATT_Frameborder,
- scroll: this.config.ATT_Scroll,
- allowTransparency: this.config.ATT_Allowtransparency
- };
- for (var b in c) {
- window[fnNameSpace].util.setStyleWithImportant(this.dom, b, c[b], true)
- }
- for (var b in a) {
- this.dom.setAttribute(b, a[b])
- }
- if (this.initialToolbarIframeSpecificDevice) {
- this.initialToolbarIframeSpecificDevice(c, a)
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement