/* Gallery */ (function (window){ var FWDM = function(props){ var _s = this; _s.skinPath_str = props.skinPath; if((_s.skinPath_str.lastIndexOf("/") + 1) != _s.skinPath_str.length){ _s.skinPath_str += "/"; } _s.warningIconPath_str = _s.skinPath_str + "warning.png"; /* init gallery */ _s.init = function(){ FWDMUtils.checkIfHasTransforms(); FWDTweenLite.ticker.useRAF(false); _s.props_obj = props; _s.isFullScreen_bl = false; _s.mustHaveHolderDiv_bl = false; _s.displayType = props.displayType.toLowerCase(); if(!_s.displayType) _s.displayType = FWDM.FULL_SCREEN; if(_s.displayType == FWDM.RESPONSIVE) _s.mustHaveHolderDiv_bl = true; _s.body = document.getElementsByTagName("body")[0]; if(!_s.props_obj){ alert("FWDM constructor properties object is not defined!"); return; } if(!_s.props_obj){ alert("FWDM constructor properties object is not defined!"); return; } if(!_s.props_obj.parentId){ if(_s.mustHaveHolderDiv_bl){ alert("Property parentId is not defined in the FWDM constructor, _s property represents the div id into which the megazoom is added as a child!"); return; } } if(_s.mustHaveHolderDiv_bl && !FWDMUtils.getChildById(_s.props_obj.parentId)){ alert("FWDM holder div is not found, please make sure that the div exsists and the id is correct! " + _s.props_obj.parentId); return; } //check for the playlist id property. if(!_s.props_obj.markersAndInfoWindowId){ alert("The markersAndInfoWindowId property which represents the megazoom playlist id is not defined in the constructor function!"); return; }; _s.rootElement_el = FWDMUtils.getChildById(_s.props_obj.markersAndInfoWindowId); if(_s.displayType == FWDM.FULL_SCREEN || _s.displayType == FWDM.LIGHTBOX){ if(FWDMUtils.isIEAndLessThen9){ _s.stageContainer = _s.body; }else{ _s.stageContainer = document.documentElement; } }else{ _s.stageContainer = FWDMUtils.getChildById(_s.props_obj.parentId); } _s.isSkin1 = _s.props_obj.skinPath.indexOf('skin1') != -1 ? true : false; _s.useVectorIcons = _s.props_obj.useVectorIcons == "yes" ? true : false; _s.originalWidth = _s.props_obj.zoomerWidth || 500; _s.originalHeight = _s.props_obj.zoomerHeight || 400; _s.autoScale = _s.props_obj.autoScale == "yes" ? true : false; _s.listeners = {events_ar:[]}; _s.customContextMenu = null; _s.info_do = null; _s.main_do = null; _s.preloader_do = null; _s.navigator_do = null; _s.controller_do = null; _s.imageManager_do = null; _s.descriptionWindow_do = null; _s.hider = null; _s.lightBox_do = null; _s.disable_sdo = null; _s.backgroundColor_str = _s.props_obj.backgroundColor || "transparent"; _s.lightBoxBackgroundColor_str = _s.props_obj.lightBoxBackgroundColor || "transparent"; _s.initializeOnlyWhenVisible_bl = _s.props_obj.initializeOnlyWhenVisible; _s.initializeOnlyWhenVisible_bl = _s.initializeOnlyWhenVisible_bl == "yes" ? true : false; _s.viewportWidth = 0; _s.viewportHeight = 0; _s.stageWidth = 0; _s.stageHeight = 0; _s.pageXOffset = window.pageXOffset; _s.pageYOffset = window.pageYOffset; _s.lastScrollY; _s.lastScrollX; _s.lightBoxBackgroundOpacity = _s.props_obj.lightBoxBackgroundOpacity || 1; _s.lightBoxWidth = _s.props_obj.lightBoxWidth || 500; _s.lightBoxHeight = _s.props_obj.lightBoxHeight || 400; _s.finalLightBoxWidth; _s.finalLightBoxHeight; _s.resizeHandlerId_to; _s.resizeHandler2Id_to; _s.lighboxAnimDoneId_to; _s.startHiderWithDelayId_to; _s.initPluginId_to; _s.activateWithDelayImagemanagerId_to; _s.hidePreloaderId_to; _s.centerImageNormalScreenId_to; _s.orientationChangeId_to; _s.orintationChangeComplete_bl = true; _s.isMobile_bl = FWDMUtils.isMobile; _s.hibernate_bl = false; if(_s.displayType != FWDM.LIGHTBOX){ _s.setupMainDo(); _s.startResizeHandler(); if(_s.initializeOnlyWhenVisible_bl){ window.addEventListener("scroll", _s.onInitlalizeScrollHandler); _s.scrollInit_to = setTimeout(_s.onInitlalizeScrollHandler, 500); }else{ _s.setupMegazoom(); } }else{ _s.initPluginId_to = setTimeout(function(){_s.setupLightBox();}, 50); } }; _s.onInitlalizeScrollHandler = function(){ var scrollOffsets = FWDMUtils.getScrollOffsets(); _s.pageXOffset = scrollOffsets.x; _s.pageYOffset = scrollOffsets.y; if(_s.main_do.getGlobalY() >= -_s.stageHeight && _s.main_do.getGlobalY() < _s.ws.h){ window.removeEventListener("scroll", _s.onInitlalizeScrollHandler); _s.setupMegazoom(); } }; //#############################################// /* setup megazoom main instances */ //#############################################// _s.setupMegazoom = function(){ if(_s.initialized) return; _s.initialized = true; if(_s.displayType == FWDM.LIGHTBOX){ _s.setupMainDo(); _s.startResizeHandler(); } _s.setupInfo(); _s.setupData(); if(FWDMUtils.hasPointerEvent && FWDMUtils.isMobile) window.addEventListener("contextmenu", _s.preventContextMenu); }; //#############################################// /* setup main do */ //#############################################// _s.setupMainDo = function(){ _s.main_do = new FWDMDisplayObject("div", "relative"); _s.main_do.getStyle().msTouchAction = "none"; _s.main_do.setBackfaceVisibility(); _s.main_do.setBkColor(_s.backgroundColor_str); if(!FWDMUtils.isMobile || (FWDMUtils.isMobile && FWDMUtils.hasPointerEvent)) _s.main_do.setSelectable(false); _s.zoomBk_do = new FWDMDisplayObject("div"); _s.zoomBk_do.getStyle().width = '100%'; _s.zoomBk_do.getStyle().height = '100%'; _s.zoomBk_do.setAlpha(0); _s.main_do.addChild(_s.zoomBk_do); if(_s.useVectorIcons){ _s.background_sdo = new FWDMSimpleDisplayObject("div"); if(_s.isSkin1){ _s.background_sdo.screen.className = 'fwdm-controler-skin1-vector'; }else{ _s.background_sdo.screen.className = 'fwdm-controler-skin2-vector'; } _s.background_sdo.setX(-5000); _s.main_do.addChild(_s.background_sdo); setTimeout(function(){ //_s.controllerHeight = _s.background_sdo.getHeight(); _s.controllerHeight = parseInt(getComputedStyle(_s.background_sdo.screen).getPropertyValue('height')); }, 1); } //start full screen if(_s.displayType == FWDM.FULL_SCREEN){ _s.stageContainer.style.overflow = "hidden"; _s.main_do.getStyle().position = "absolute"; document.documentElement.style.overflow = "hidden"; _s.stageContainer.appendChild(_s.main_do.screen); }else if(_s.displayType == FWDM.LIGHTBOX){ _s.main_do.getStyle().zIndex = 99999991; _s.main_do.getStyle().position = "absolute"; _s.stageContainer.appendChild(_s.main_do.screen); }else{ _s.stageContainer.appendChild(_s.main_do.screen); } }; //#############################################// /* prevent context menu on windows8 mobile */ //############################################// _s.preventContextMenu = function(e){ e.preventDefault(); }; //#############################################// /* setup info_do */ //#############################################// _s.setupInfo = function(){ FWDMInfo.setPrototype(); _s.info_do = new FWDMInfo(_s, _s.warningIconPath_str); }; //#############################################// /* resize handler */ //#############################################// _s.startResizeHandler = function(){ window.addEventListener("resize", _s.onResizeHandler); window.addEventListener("scroll", _s.onScrollHandler); window.addEventListener("orientationchange", _s.orientationChange); _s.onResizeHandler(true); _s.resizeHandlerId_to = setTimeout(function(){_s.resizeHandler(true);}, 500); }; _s.stopResizeHandler = function(){ window.addEventListener("scroll", _s.onScrollHandler); window.removeEventListener("resize", _s.onResizeHandler); window.removeEventListener("orientationchange", _s.orientationChange); clearTimeout(_s.resizeHandlerId_to); }; _s.onResizeHandler = function(e){ _s.resizeHandler(); clearTimeout(_s.resizeHandler2Id_to); _s.resizeHandler2Id_to = setTimeout(function(){_s.resizeHandler();}, 300); }; _s.onScrollHandler = function(e){ if(_s.hibernate_bl) return; _s.scrollOffsets = FWDMUtils.getScrollOffsets(); _s.globalX = _s.main_do.getGlobalX(); _s.globalY = _s.main_do.getGlobalY(); }; _s.orientationChange = function(){ if(_s.displayType == FWDM.FULL_SCREEN || _s.isFullScreen_bl){ _s.resizeHandler(true); _s.orintationChangeComplete_bl = false; clearTimeout(_s.resizeHandlerId_to); clearTimeout(_s.resizeHandler2Id_to); clearTimeout(_s.orientationChangeId_to); _s.orientationChangeId_to = setTimeout(function(){ _s.orintationChangeComplete_bl = true; _s.resizeHandler(true); }, 1000); _s.main_do.setX(0); _s.main_do.setWidth(0); } }; _s.resizeHandler = function(overwrite){ if(!_s.orintationChangeComplete_bl) return; _s.scrollOffsets = FWDMUtils.getScrollOffsets(); var viewportSize = FWDMUtils.getViewportSize(); _s.globalX = _s.main_do.getGlobalX(); _s.globalY = _s.main_do.getGlobalY(); _s.ws = viewportSize; if(_s.viewportWidth == viewportSize.w && _s.viewportHeight == viewportSize.h && _s.pageXOffset == _s.scrollOffsets.x && _s.pageYOffset == _s.scrollOffsets.y && !overwrite) return; _s.viewportWidth = viewportSize.w; _s.viewportHeight = viewportSize.h; _s.pageXOffset = _s.scrollOffsets.x; _s.pageYOffset = _s.scrollOffsets.y; if(_s.displayType == FWDM.LIGHTBOX && !_s.isFullScreen_bl){ if(_s.lightBoxWidth > viewportSize.w){ _s.finalLightBoxWidth = viewportSize.w; _s.finalLightBoxHeight = parseInt(_s.lightBoxHeight * (viewportSize.w/_s.lightBoxWidth)); }else{ _s.finalLightBoxWidth = _s.lightBoxWidth; _s.finalLightBoxHeight = _s.lightBoxHeight; } if(_s.finalLightBoxHeight < _s.viewerMinHeight) _s.finalLightBoxHeight = _s.viewerMinHeight; _s.lightBox_do.setWidth(viewportSize.w); _s.lightBox_do.setHeight(viewportSize.h); _s.lightBox_do.setX(_s.scrollOffsets.x); _s.lightBox_do.setY(_s.scrollOffsets.y); _s.lightBox_do.mainLightBox_do.setX(parseInt((viewportSize.w - _s.finalLightBoxWidth)/2)); _s.lightBox_do.mainLightBox_do.setY(parseInt((viewportSize.h - _s.finalLightBoxHeight)/2)); if(_s.lightBox_do.closeButton_do && !_s.lightBox_do.closeButtonIsTweening_bl){ var closeButtonFinalX = parseInt((viewportSize.w + _s.finalLightBoxWidth)/2 - _s.lightBox_do.closeButton_do.totalWidth/2); var closeButtonFinalY = parseInt((viewportSize.h - _s.finalLightBoxHeight)/2 - _s.lightBox_do.closeButton_do.totalHeight/2); closeButtonFinalX = viewportSize.w - _s.lightBox_do.closeButton_do.totalWidth - 10; closeButtonFinalY = 10; FWDAnimation.killTweensOf(_s.lightBox_do.closeButton_do); _s.lightBox_do.closeButton_do.setX(closeButtonFinalX); _s.lightBox_do.closeButton_do.setY(closeButtonFinalY); } _s.main_do.setX(0); _s.main_do.setY(0); _s.lightBox_do.mainLightBox_do.setWidth(_s.finalLightBoxWidth); _s.lightBox_do.mainLightBox_do.setHeight(_s.finalLightBoxHeight); _s.stageWidth = _s.finalLightBoxWidth; _s.stageHeight = _s.finalLightBoxHeight; }else if(_s.isFullScreen_bl || _s.displayType == FWDM.FULL_SCREEN){ _s.main_do.setX(_s.scrollOffsets.x); _s.main_do.setY(_s.scrollOffsets.y); _s.stageWidth = viewportSize.w; _s.stageHeight = viewportSize.h; }else if(_s.displayType == FWDM.RESPONSIVE){ if (_s.autoScale){ _s.stageContainer.style.width = "100%"; if (_s.stageContainer.offsetWidth > _s.originalWidth){ _s.stageContainer.style.width = _s.originalWidth + "px"; } _s.scale = _s.stageContainer.offsetWidth/_s.originalWidth; _s.stageWidth = parseInt(_s.scale * _s.originalWidth); _s.stageHeight = Math.max(parseInt(_s.scale * _s.originalHeight), 300); _s.stageContainer.style.height = _s.stageHeight + "px"; }else{ _s.stageContainer.style.width = "100%"; if (_s.stageContainer.offsetWidth > _s.originalWidth){ _s.stageContainer.style.width = _s.originalWidth + "px"; } _s.stageWidth = _s.stageContainer.offsetWidth; _s.stageHeight = _s.originalHeight; _s.stageContainer.style.height = _s.originalHeight + "px"; } _s.main_do.setX(0); _s.main_do.setY(0); } _s.zoomBk_do.setAlpha(0); _s.main_do.setWidth(_s.stageWidth); _s.main_do.setHeight(_s.stageHeight); if(_s.preloader_do) _s.preloader_do.positionAndResize(); if(_s.controller_do) _s.controller_do.resizeAndPosition(); if(_s.imageManager_do) _s.imageManager_do.resizeAndPosition(false); if(_s.navigator_do) _s.navigator_do.resizeAndPosition(); if(_s.descriptionWindow_do && _s.descriptionWindow_do.isShowed_bl) _s.descriptionWindow_do.resizeAndPosition(); }; //#############################################// /* setup lighbox...*/ //#############################################// _s.setupLightBox = function(){ FWDMLightBox.setPrototype(); _s.lightBox_do = new FWDMLightBox(_s, _s.lightBoxBackgroundColor_str, _s.backgroundColor_str, _s.lightBoxBackgroundOpacity, _s.lightBoxWidth, _s.lightBoxHeight); _s.lightBox_do.getStyle().zIndex = 9999999; _s.lightBox_do.addListener(FWDMLightBox.CLOSE, _s.lightBoxCloseHandler); _s.lightBox_do.addListener(FWDMLightBox.HIDE_COMPLETE, _s.lightBoxHideCompleteHandler); _s.lighboxAnimDoneId_to = setTimeout(_s.setupMegazoom, 1200); }; _s.lightBoxCloseHandler = function(){ _s.stopResizeHandler(); if(_s._d) _s._d.stopToLoad(); }; _s.lightBoxHideCompleteHandler = function(){ if(_s.dispatchEvent) _s.dispatchEvent(FWDM.CLOSE_LIGHTBOX); _s.destroy(); }; //#############################################// /* setup context menu */ //#############################################// _s.setupContextMenu = function(){ if(_s._d.buttons_ar.length == 0) return; FWDMContextMenu.setPrototype(); _s.customContextMenu = new FWDMContextMenu(_s, _s._d); _s.customContextMenu.addListener(FWDMController.PAN, _s.contextMenuPanHandler); _s.customContextMenu.addListener(FWDMController.ZOOM_IN, _s.contextMenuZoomInHandler); _s.customContextMenu.addListener(FWDMController.ZOOM_OUT, _s.contextMenuZoomOutHandler); _s.customContextMenu.addListener(FWDMController.HIDE_MARKERS, function(){ _s.controllerHideMarkers(false); }); _s.customContextMenu.addListener(FWDMController.SHOW_MARKERS, function(){ _s.controllerShowMarkers(false); }); _s.customContextMenu.addListener(FWDMController.SHOW_INFO, _s.contextMenuShowInfoWindow); _s.customContextMenu.addListener(FWDMController.GO_FULL_SCREEN, _s.controllerGoFullScreen); _s.customContextMenu.addListener(FWDMController.GO_NORMAL_SCREEN, _s.controllerGoNormalScreen); _s.customContextMenu.addListener(FWDMController.HIDE_CONTROLLER, _s.contextMenuHideController); _s.customContextMenu.addListener(FWDMController.SHOW_CONTROLLER, _s.contextMenuShowController); }; _s.contextMenuPanHandler = function(e){ if(e.dir == "left"){ _s.controller_do.moveLeftButtonStartHandler(e.e); }else if(e.dir == "right"){ _s.controller_do.moveRightButtonStartHandler(e.e); }else if(e.dir == "up"){ _s.controller_do.moveUpButtonStartHandler(e.e); }else if(e.dir == "down"){ _s.controller_do.moveDownButtonStartHandler(e.e); } }; _s.contextMenuGoToNextImageHandler = function(e){ _s.controller_do.nextButtonStartHandler(e); }; _s.contextMenuGoToPrevImageHandler = function(e){ _s.controller_do.prevButtonStartHandler(e); }; _s.contextMenuZoomInHandler = function(e){ _s.controller_do.zoomInStartHandler(e); }; _s.contextMenuZoomOutHandler = function(e){ _s.controller_do.zoomOutStartHandler(e); }; _s.contextMenuShowInfoWindow = function(e){ _s.main_do.addChild(_s.descriptionWindow_do); _s.descriptionWindow_do.hide(false, true); _s.descriptionWindow_do.show(_s._d.infoText_str); }; _s.contextMenuHideController = function(){ _s.controller_do.setHideOrShowControllerAndToolTipState(1); }; _s.contextMenuShowController = function(){ _s.controller_do.setHideOrShowControllerAndToolTipState(0); }; //#############################################// /* setup _d */ //#############################################// _s.setupData = function(){ FWDMData.setPrototype(); _s._d = new FWDMData(_s.props_obj, _s.rootElement_el); _s._d.addListener(FWDMData.LIGHBOX_CLOSE_BUTTON_LOADED, _s.onLightboxCloseButtonLoadComplete); _s._d.addListener(FWDMData.PRELOADER_LOAD_DONE, _s.onPreloaderLoadDone); _s._d.addListener(FWDMData.LOAD_ERROR, _s.dataLoadError); _s._d.addListener(FWDMData.SKIN_PROGRESS, _s.dataSkinProgressHandler); _s._d.addListener(FWDMData.IMAGES_PROGRESS, _s.dataImagesProgressHandler); _s._d.addListener(FWDMData.LOAD_DONE, _s.dataLoadComplete); _s._d.addListener(FWDMData.READY, _s.dataImageLoadComplete); }; _s.onLightboxCloseButtonLoadComplete = function(){ setTimeout(function(){ if(_s.displayType == FWDM.LIGHTBOX) _s.lightBox_do.setupCloseButton(_s._d.mainLightboxCloseButtonN_img, _s._d.mainLightboxCloseButtonS_img); }, 200); }; _s.onPreloaderLoadDone = function(){ _s.setupPreloader(); }; _s.dataLoadError = function(e, text){ _s.main_do.addChild(_s.info_do); _s.info_do.showText(e.text); }; _s.dataSkinProgressHandler = function(e){ if(_s.preloader_do) _s.preloader_do.update(e.percent, "Loading skin: " + (Math.round(e.percent * 100)) + "%"); }; _s.dataImagesProgressHandler = function(e){ _s.preloader_do.update(e.percent, _s._d.preloaderText_str + (Math.round(e.percent * 100)) + "%"); }; _s.dataLoadComplete = function(e){ _s.main_do.addChild(_s.preloader_do); if(!_s.isMobile_bl) _s.setupContextMenu(); }; _s.dataImageLoadComplete = function(){ _s.isAPIReady = true; _s.zoomBk_do.setBkColor(_s._d.backgroundColorOnZoom); _s.hidePreloaderId_to = setTimeout(function(){_s.preloader_do.hide(true);}, 500); _s.setupImageManager(); _s.setupController(); if(_s._d.showNavigator_bl) _s.setupNavigator(); _s.main_do.addChild(_s.preloader_do); if(_s._d.hideController_bl){ _s.setupHider(); _s.controller_do.setupHider(_s.hider); _s.imageManager_do.setupHider(_s.hider); if(_s.navigator_do) _s.navigator_do.setupHider(_s.hider); _s.startHiderWithDelayId_to = setTimeout(function(){ _s.hider.start(); }, _s._d.hideControllerDelay); } if(_s.customContextMenu) _s.customContextMenu.isActive_bl = true; if(_s.navigator_do) _s.navigator_do.activate(_s._d.image_img); _s.setupDisableContainer(); _s.setupDescriptionWindow(); _s.dispatchEvent(FWDMData.READY); }; //#############################################// /* setup preloader */ //#############################################// _s.setupPreloader = function(){ FWDMPreloader.setPrototype(); _s.preloader_do = new FWDMPreloader( _s, _s._d.preloaderFontColor_str, _s._d.preloaderBackgroundColor_str); _s.preloader_do.addListener(FWDMPreloader.HIDE_COMPLETE, _s.onPreloaderHideCompleteHandler); _s.preloader_do.positionAndResize(); _s.preloader_do.hide(false); _s.preloader_do.show(true); _s.main_do.addChild(_s.preloader_do); }; _s.onPreloaderHideCompleteHandler = function(){ _s.main_do.removeChild(_s.preloader_do); _s.preloader_do.destroy(); _s.preloader_do = null; }; //###########################################// /* setup hider */ //###########################################// _s.setupHider = function(){ FWDMHider.setPrototype(); _s.hider = new FWDMHider(_s._d.isMobile_bl, _s.main_do, _s._d.hideControllerDelay); }; //###########################################// /* setup controller */ //###########################################// _s.setupController = function(){ FWDMController.setPrototype(); _s.controller_do = new FWDMController(_s._d, _s); _s.controller_do.addListener(FWDMController.MOUSE_DOWN, _s.controllerOnMouseDownHandler); _s.controller_do.addListener(FWDMController.PAN, _s.controllerOnPanHandler); _s.controller_do.addListener(FWDMController.DISABLE_PAN_OR_MOVE, _s.disablePanOrMoveHandler); _s.controller_do.addListener(FWDMController.ENABLE_PAN_OR_MOVE, _s.enablePanOrMoveHandler); _s.controller_do.addListener(FWDMController.SCROLL_BAR_UPDATE, _s.controllerScrollBarUpdateHandler); _s.controller_do.addListener(FWDMController.ZOOM_WITH_BUTTONS, _s.controllerZoomHandler); _s.controller_do.addListener(FWDMController.SHOW_INFO, _s.controllerShowInfoHandler); _s.controller_do.addListener(FWDMController.GO_FULL_SCREEN, _s.controllerGoFullScreen); _s.controller_do.addListener(FWDMController.GO_NORMAL_SCREEN, _s.controllerGoNormalScreen); _s.controller_do.addListener(FWDMController.HIDE_MARKERS, _s.controllerHideMarkers); _s.controller_do.addListener(FWDMController.SHOW_MARKERS, function(){ _s.controllerShowMarkers(true); }); _s.controller_do.addListener(FWDMController.HIDE_CONTROLLER, function(){ _s.controllerHideHandler(true); }); _s.controller_do.addListener(FWDMController.SHOW_CONTROLLER, _s.controllerShowHandler); if(_s.controller_do) _s.controller_do.resizeAndPosition(); if(!_s._d.disableZoom) _s.main_do.addChild(_s.controller_do); }; _s.controllerOnMouseDownHandler = function(){ _s.imageManager_do.hideToolTipWindow(); }; _s.controllerOnPanHandler = function(e){ _s.imageManager_do.panWithButtons(e.dir); }; _s.disablePanOrMoveHandler = function(){ _s.imageManager_do.disableOrEnablePanOrTouch(true); }; _s.enablePanOrMoveHandler = function(){ _s.imageManager_do.disableOrEnablePanOrTouch(false); }; _s.controllerScrollBarUpdateHandler = function(e){ _s.imageManager_do.zoomInOrOutWithScrollBar(e.percent); }; _s.controllerZoomHandler = function(e){ _s.imageManager_do.zoomInOrOutWithButtons(e.dir, e.withPause); }; _s.controllerShowInfoHandler = function(){ _s.main_do.addChild(_s.descriptionWindow_do); _s.descriptionWindow_do.hide(false, true); _s.descriptionWindow_do.show(_s._d.infoText_str); }; _s.controllerGoFullScreen = function(){ if(_s.isFullScreen_bl) return; _s.goFullScreen(); }; _s.controllerGoNormalScreen = function(){ if(!_s.isFullScreen_bl) return; _s.goNormalScreen(); _s.imageManager_do.centerImage(); _s.controller_do.setFullScreenButtonState(1); if(_s.customContextMenu) _s.customContextMenu.updateFullScreenButton(0); if(document.removeEventListener){ document.removeEventListener("fullscreenchange", _s.onFullScreenChange); document.removeEventListener("mozfullscreenchange", _s.onFullScreenChange); document.removeEventListener("webkitfullscreenchange", _s.onFullScreenChange); } }; _s.controllerHideMarkers = function(show){ if(_s.customContextMenu) _s.customContextMenu.updateHideOrShowMarkersButton(1); _s.controller_do.updateHideOrShowButtonTooltip(show); _s.imageManager_do.hideMarkers(); }; _s.controllerShowMarkers = function(show){ if(_s.customContextMenu) _s.customContextMenu.updateHideOrShowMarkersButton(0); _s.controller_do.updateHideOrShowButtonTooltip(show); _s.imageManager_do.showMarkers(); }; _s.onFullScreenChange = function(e){ if(!(document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen || document.msieFullScreen)){ if(_s.showButtonsLabels_bl) _s.fullscreenToolTip_do.setLabel(_s.fullscreenToolTip_do.toolTipLabel2_str); _s.controller_do.setFullScreenButtonState(1); if(_s.customContextMenu) _s.customContextMenu.updateFullScreenButton(0); _s.controllerGoNormalScreen(); _s.isFullScreen_bl = false; } }; _s.controllerHideHandler = function(){ if(_s.customContextMenu) _s.customContextMenu.startHideOrShowControllerHandler(1); }; _s.controllerShowHandler = function(){ if(_s.customContextMenu) _s.customContextMenu.startHideOrShowControllerHandler(0); }; //###########################################// /* setup image manager */ //###########################################// _s.setupImageManager = function(id){ FWDMImageManager.setPrototype(); _s.imageManager_do = new FWDMImageManager(_s._d, _s); _s.imageManager_do.addListener(FWDMImageManager.LARGE_IMAGE_LOAD_ERROR, _s.imageManagerLoadError); _s.imageManager_do.addListener(FWDMImageManager.SCROLL_BAR_UPDATE, _s.imageManagerScrollBarUpdate); _s.imageManager_do.addListener(FWDMImageManager.SHOW_NAVIGATOR, _s.imageManagerShowNavigatorHandler); _s.imageManager_do.addListener(FWDMImageManager.HIDE_NAVIGATOR, _s.imageManagerHideNavigatorHandler); _s.imageManager_do.addListener(FWDMImageManager.UPDATE_NAVIGATOR, _s.imageManagerUpdateNavigatorHandler); _s.imageManager_do.addListener(FWDMImageManager.SHOW_INFO, _s.imageManagerShowInfoHandler); _s.imageManager_do.addListener(FWDMImageManager.DISABLE_LEFT_AND_RIGHT_BUTTONS, _s.disableLeftAndRightHandler); _s.imageManager_do.addListener(FWDMImageManager.ENABLE_LEFT_AND_RIGHT_BUTTONS, _s.enableLeftAndRightHandler); _s.imageManager_do.addListener(FWDMImageManager.DISABLE_UP_AND_DOWN_BUTTONS, _s.disableUpAndDownHandler); _s.imageManager_do.addListener(FWDMImageManager.ENABLE_UP_AND_DOWN_BUTTONS, _s.enableUpAndDownHandler); _s.imageManager_do.addListener(FWDM.ZOOM, _s.imageManagerZoom); _s.main_do.addChild(_s.imageManager_do); }; _s.imageManagerZoom = function(e){ if(_s.imageManager_do.smallestPossibleScale == _s.imageManager_do.currentScale){ FWDAnimation.to(_s.zoomBk_do, .8, {alpha:0}); }else{ FWDAnimation.to(_s.zoomBk_do, .8, {alpha:1}); } _s.dispatchEvent(FWDM.ZOOM, {scale:e.scale}); } _s.imageManagerLoadError = function(e){ _s.main_do.addChild(_s.info_do); _s.info_do.showText(e.error); }; _s.imageManagerScrollBarUpdate = function(e){ _s.controller_do.updateScrollBar(e.percent, e.animate); }; _s.imageManagerShowNavigatorHandler = function(){ _s.navigator_do.show(true); }; _s.imageManagerHideNavigatorHandler = function(){ _s.navigator_do.hide(true); }; _s.imageManagerUpdateNavigatorHandler = function(e){ _s.navigator_do.update(e.percentX, e.percentY, e.percentWidth, e.percentHeight, e.animate); }; _s.imageManagerShowInfoHandler = function(e){ _s.main_do.addChild(_s.descriptionWindow_do); _s.descriptionWindow_do.hide(false, true); _s.descriptionWindow_do.show(e.text); }; _s.disableLeftAndRightHandler = function(){ _s.controller_do.disableLeftAndRightButtons(); if(_s.customContextMenu) _s.customContextMenu.disableLeftAndRightButtons(); }; _s.enableLeftAndRightHandler = function(){ _s.controller_do.enableLeftAndRightButtons(); if(_s.customContextMenu) _s.customContextMenu.enableLeftAndRightButtons(); }; _s.disableUpAndDownHandler = function(){ _s.controller_do.disableUpAndDownButtons(); if(_s.customContextMenu) _s.customContextMenu.disableUpAndDownButtons(); }; _s.enableUpAndDownHandler = function(){ _s.controller_do.enableUpAndDownButtons(); if(_s.customContextMenu) _s.customContextMenu.enableUpAndDownButtons(); }; //#############################################// /* Setup navigator */ //#############################################// _s.setupNavigator = function(){ FWDMNavigator.setPrototype(); _s.navigator_do = new FWDMNavigator(_s, _s._d); _s.navigator_do.addListener(FWDMNavigator.PAN_START, _s.navigatorOnPanStartHandler); _s.navigator_do.addListener(FWDMNavigator.PAN_END, _s.navigatorOnPanEndHandler); _s.navigator_do.addListener(FWDMNavigator.PAN, _s.navigatorPanHandler); _s.main_do.addChild(_s.navigator_do); }; _s.navigatorOnPanStartHandler = function(){ _s.imageManager_do.hideToolTipWindow(); if(!_s.isMobile_bl) _s.disableAll(); }; _s.navigatorOnPanEndHandler = function(){ if(!_s.isMobile_bl) _s.enableAll(); }; _s.navigatorPanHandler = function(e){ _s.imageManager_do.updateOnNavigatorPan(e.percentX, e.percentY); }; //#############################################// /* Setup description window */ //#############################################// _s.setupDescriptionWindow = function(){ FWDMDescriptionWindow.setPrototype(); _s.descriptionWindow_do = new FWDMDescriptionWindow(_s, _s._d); _s.descriptionWindow_do.addListener(FWDMDescriptionWindow.SHOW_START, _s.descWindowShowStartHandler); _s.descriptionWindow_do.addListener(FWDMDescriptionWindow.HIDE_COMPLETE, _s.descWindowHideComplteHandler); _s.main_do.addChild(_s.descriptionWindow_do); setTimeout(function(){ if(!_s) return; _s.main_do.removeChild(_s.descriptionWindow_do); }, 500); }; _s.descWindowShowStartHandler = function(){ if(_s.customContextMenu) _s.customContextMenu.disable(); }; _s.descWindowHideComplteHandler = function(){ if(_s.customContextMenu) _s.customContextMenu.enable(); _s.main_do.removeChild(_s.descriptionWindow_do); }; //##############################################// /* Setup disable container */ //#############################################// _s.setupDisableContainer = function(){ _s.disable_sdo = new FWDMSimpleDisplayObject("div"); _s.disable_sdo.screen.style.cursor = 'url(' + _s._d.handGrabPath_str + '), default'; if(FWDMUtils.isIE || FWDMUtils.isChrome){ _s.disable_sdo.setBkColor("#000000"); _s.disable_sdo.setAlpha(.0001); } _s.main_do.addChild(_s.disable_sdo); }; _s.disableAll = function(){ _s.disable_sdo.setWidth(_s.stageWidth + 3000); _s.disable_sdo.setHeight(_s.stageHeight + 3000); }; _s.enableAll = function(){ _s.disable_sdo.setWidth(0); _s.disable_sdo.setWidth(0); }; //#############################################// /* go fullscreen / normal screen */ //#############################################// _s.goFullScreen = function(){ if(!_s.isAPIReady) return; if(document.addEventListener){ document.addEventListener("fullscreenchange", _s.onFullScreenChange); document.addEventListener("mozfullscreenchange", _s.onFullScreenChange); document.addEventListener("webkitfullscreenchange", _s.onFullScreenChange); } _s.scrollOffsets = FWDMUtils.getScrollOffsets(); _s.controller_do.setFullScreenButtonState(0); if(_s.customContextMenu) _s.customContextMenu.updateFullScreenButton(1); _s.lastScrollX = _s.scrollOffsets.x; _s.lastScrollY = _s.scrollOffsets.y; if (document.documentElement.requestFullScreen) { document.documentElement.requestFullScreen(); }else if(document.documentElement.mozRequestFullScreen) { document.documentElement.mozRequestFullScreen(); }else if(document.documentElement.webkitRequestFullScreen) { document.documentElement.webkitRequestFullScreen(); }else if(document.documentElement.msieRequestFullScreen) { document.documentElement.msieRequestFullScreen(); } _s.main_do.getStyle().position = "absolute"; _s.body.style.overflow = "hidden"; document.documentElement.style.overflow = "hidden"; if(FWDMUtils.isIEAndLessThen9){ _s.body.appendChild(_s.main_do.screen); }else{ //_s.body.style.visiblity = "hidden"; document.documentElement.appendChild(_s.main_do.screen); } _s.main_do.getStyle().zIndex = 99999999; _s.main_do.setBkColor(_s._d.fullscreenBackgroundColor); _s.isFullScreen_bl = true; _s.resizeHandler(true); setTimeout(_s.resizeHandler, 500); _s.dispatchEvent(FWDM.GO_FULLSCREEN); }; _s.goNormalScreen = function(){ if (document.cancelFullScreen) { document.cancelFullScreen(); }else if (document.mozCancelFullScreen) { document.mozCancelFullScreen(); }else if (document.webkitCancelFullScreen) { document.webkitCancelFullScreen(); }else if (document.msieCancelFullScreen) { document.msieCancelFullScreen(); } _s.addMainDoToTheOriginalParent(); _s.isFullScreen_bl = false; _s.resizeHandler(true); setTimeout(_s.resizeHandler, 500); _s.centerImageNormalScreenId_to = setTimeout(function(){ _s.imageManager_do.resizeAndPosition(true, false); }, 50); _s.dispatchEvent(FWDM.GO_NORMALSCREEN); }; _s.addMainDoToTheOriginalParent = function(){ if(_s.displayType != FWDM.FULL_SCREEN){ if(FWDMUtils.isIEAndLessThen9){ document.documentElement.style.overflow = "auto"; _s.body.style.overflow = "auto"; _s.body.style.visibility = "visible"; }else{ document.documentElement.style.overflow = "visible"; _s.body.style.overflow = "visible"; _s.body.style.display = "inline"; } } if(_s.controller_do.fullScreenButton_do){ _s.controller_do.fullScreenButton_do.setButtonState(1); } if(_s.displayType == FWDM.FULL_SCREEN){ if(FWDMUtils.isIEAndLessThen9){ _s.body.appendChild(_s.main_do.screen); }else{ document.documentElement.appendChild(_s.main_do.screen); } }else if(_s.displayType == FWDM.LIGHTBOX){ _s.stageContainer.appendChild(_s.main_do.screen); //_s.stageContainer.appendChild(_s.closeButton_do.screen); }else{ _s.main_do.getStyle().position = "relative"; _s.stageContainer.appendChild(_s.main_do.screen); } _s.main_do.setBkColor(_s.backgroundColor_str); _s.main_do.getStyle().zIndex = 0; window.scrollTo(_s.lastScrollX, _s.lastScrollY); }; //#############################################// /* clean main events */ //#############################################// _s.cleanMainEvents = function(){ window.removeEventListener("resize", _s.onResizeHandler); window.removeEventListener("scroll", _s.onScrollHandler); document.removeEventListener("fullscreenchange", _s.onFullScreenChange); document.removeEventListener("mozfullscreenchange", _s.onFullScreenChange); document.removeEventListener("webkitfullscreenchange", _s.onFullScreenChange); if(_s.isMobile_bl){ window.removeEventListener("contextmenu", _s.preventContextMenu); } clearTimeout(_s.resizeHandlerId_to); clearTimeout(_s.resizeHandler2Id_to); clearTimeout(_s.lighboxAnimDoneId_to); clearTimeout(_s.startHiderWithDelayId_to); clearTimeout(_s.initPluginId_to); clearTimeout(_s.activateWithDelayImagemanagerId_to); clearTimeout(_s.hidePreloaderId_to); clearTimeout(_s.centerImageNormalScreenId_to); }; //################################// /* event dispatcher */ //#################################// this.addListener = function (type, listener){ if(type == undefined) throw Error("type is required."); if(typeof type === "object") throw Error("type must be of type String."); if(typeof listener != "function") throw Error("listener must be of type Function."); var event = {}; event.type = type; event.listener = listener; event.target = this; this.listeners.events_ar.push(event); }; this.dispatchEvent = function(type, props){ if(this.listeners == null) return; if(type == undefined) throw Error("type is required."); if(typeof type === "object") throw Error("type must be of type String."); for (var i=0, len=this.listeners.events_ar.length; i < len; i++){ if(this.listeners.events_ar[i].target === this && this.listeners.events_ar[i].type === type){ if(props){ for(var prop in props){ this.listeners.events_ar[i][prop] = props[prop]; } } this.listeners.events_ar[i].listener.call(this, this.listeners.events_ar[i]); } } }; this.removeListener = function(type, listener){ if(type == undefined) throw Error("type is required."); if(typeof type === "object") throw Error("type must be of type String."); if(typeof listener != "function") throw Error("listener must be of type Function." + type); for (var i=0, len=this.listeners.events_ar.length; i < len; i++){ if(this.listeners.events_ar[i].target === this && this.listeners.events_ar[i].type === type && this.listeners.events_ar[i].listener === listener ){ this.listeners.events_ar.splice(i,1); break; } } }; /* API */ _s.zoomIn = function(){ if(!_s.isAPIReady) return; _s.controller_do.zoomInStartHandler(); _s.controller_do.zoomInWithButtonsEndHandler(); } _s.zoomOut = function(){ if(!_s.isAPIReady) return; _s.controller_do.zoomOutStartHandler(); _s.controller_do.zoomOutWithButtonsEndHandler(); } /* destroy */ _s.destroy = function(){ _s.cleanMainEvents(); if(_s._d) _s._d.destroy(); if(_s.lightBox_do)_s.lightBox_do.destroy(); if(_s.preloader_do) _s.preloader_do.destroy(); if(_s.customContextMenu) _s.customContextMenu.destroy(); if(_s.info_do) _s.info_do.destroy(); if(_s.imageManager_do){ FWDAnimation.killTweensOf(_s.imageManager_do); _s.imageManager_do.destroy(); } if(_s.controller_do) _s.controller_do.destroy(); if(_s.navigator_do) _s.navigator_do.destroy(); if(_s.hider) _s.hider.destroy(); if(_s.descriptionWindow_do) _s.descriptionWindow_do.destroy(); try{ _s.main_do.screen.parentNode.removeChild(_s.main_do.screen); }catch(e){} if(_s.main_do){ _s.main_do.setInnerHTML(""); _s.main_do.destroy(); } _s._d = null; _s.lightBox_do = null; _s.customContextMenu = null; _s.preloader_do = null; _s.hider = null; _s.info_do = null; _s.main_do = null; _s.imageManager_do = null; _s.navigator_do = null; _s = null; }; _s.init(); }; FWDM.FULL_SCREEN = 'fullscreen'; FWDM.READY = "ready"; FWDM.IMA = "fullscreen"; FWDM.ZOOM = 'zoom'; FWDM.GO_FULLSCREEN = 'fullscreen'; FWDM.GO_NORMALSCREEN = 'normalscreen'; FWDM.LIGHTBOX = "lightbox"; FWDM.RESPONSIVE = "responsive"; FWDM.CLOSE_LIGHTBOX = "closeLightBox"; FWDM.CLOSE_LIGHTBOX = "closeLightBox"; window.FWDM = FWDM; }(window));