var ImagePanZoom = function(){ }; ImagePanZoom.prototype = { oSettings: {}, oUnPackedSettings: {}, aExternalMethods: [], iVWidth: 0, iVHeight: 0, oHeroElement: null, sElementID: '', sViewerID: '', sMediaID: '', sName: 'ImagePanZoom', sLoadingType: RICHFX.oOpts.oLoading.type, iLoadingDistance: RICHFX.oOpts.oLoading.distance, bInitialized: false, currClickLevel: 0, maxClickLevel: 4, bViewFinder: true, bShowControlBar: true, bHandlePinchZoom: false, bZoomType: "singleTap", sCallToActionType: "", sCallToAction: "", sCTAImageID: "", sCTAZoomImageID: "", sCTALeft: 45, sCTATop: 45, sCustomCursorMetadata: "", bShowLoadingMessage: false, sLoadingMessageText: "Loading Image", bFastTransition: false, iFadeTime: 1200, oZoomState: null, iCurrZIndex: 22000, iSourceChangeRecipeId: -1, hasBadgingRecipe: false, badgingRecipeId: 0, badgingRecipeName: 0, bUseFadeTransition: true, sLastPXmlReq: '', bStockImageLoad: false, config:{ baseUrl: RICHFX.settings.sJsDepsUrl, pluginPath: RICHFX.settings.sJsDepsUrl, // these paths help correct some path issues to plugins paths: { domReady:RICHFX.settings.sJsDepsUrl + 'cujo/curl/src/curl/plugin/domReady', 'curl/domReady':RICHFX.settings.sJsDepsUrl + 'cujo/curl/src/curl/domReady', js:RICHFX.settings.sJsDepsUrl + 'cujo/curl/src/curl/plugin/js' }, packages: [ // Add your packages here {name:'curl', location:'cujo/curl/src', main:'curl'}, {name:'wire', location:'cujo/wire', main:'wire'}, {name:'when', location:'cujo/when', main:'when'}, {name:'aop', location:'cujo/aop', main:'aop'} ] }, init: function(oSettings) { // unpack Settings Object this._unpackSettings(oSettings); // Setup variables etc... this.oSettings = this.oUnPackedSettings; this.oHeroElement = RICHFX.jQuery('#'+this.oSettings.element.id); this.sElementID = this.oSettings.element.id; this.sViewerID = this.oSettings.element.__richfx_id; /* check not needed for JSON version */ // Keep the width and height because we remove the element from the page if we are injecting on top of an image this.iVWidth = RICHFX.jQuery(this.oHeroElement).width(); this.iVHeight = RICHFX.jQuery(this.oHeroElement).height(); //console.log('ImagePanZoom init: ' + this.sElementID + ' | ' + this.sViewerID + ' | ' + this.iVWidth + ' | ' + this.iVHeight); if (this.oSettings.levelsOfZoom !== undefined && this.oSettings.levelsOfZoom !== "null") { this.maxClickLevel = this.oSettings.levelsOfZoom; } if (this.oSettings.showViewfinder !== undefined && this.oSettings.showViewfinder !== "null") { this.bViewFinder = this.oSettings.showViewfinder; } if (this.oSettings.showControlBar !== undefined && this.oSettings.showControlBar !== "null") { this.bShowControlBar = this.oSettings.showControlBar; } if (this.oSettings.enablePinchZoom !== undefined && this.oSettings.enablePinchZoom !== "null") { this.bHandlePinchZoom = this.oSettings.enablePinchZoom; } if (this.oSettings.callToAction !== undefined && this.oSettings.callToAction !== "null") { this.sCallToAction = this.oSettings.callToAction; } if (this.oSettings.callToActionType !== undefined && this.oSettings.callToActionType !== "null") { this.sCallToActionType = this.oSettings.callToActionType; } if (this.oSettings.callToActionMetadata !== undefined && this.oSettings.callToActionMetadata !== "null") { this.sCTAImageID = this.oSettings.callToActionMetadata; } if (this.oSettings.callToActionZoomMetadata !== undefined && this.oSettings.callToActionZoomMetadata !== "null") { this.sCTAZoomImageID = this.oSettings.callToActionZoomMetadata; } if (this.oSettings.callToActionPercLeft !== undefined && this.oSettings.callToActionPercLeft !== "null") { this.sCTALeft = this.oSettings.callToActionPercLeft; } if (this.oSettings.callToActionPercTop !== undefined && this.oSettings.callToActionPercTop !== "null") { this.sCTATop = this.oSettings.callToActionPercTop; } if (this.oSettings.touchZoomType !== undefined && this.oSettings.touchZoomType !== "null") { this.bZoomType = this.oSettings.touchZoomType; } if (this.oSettings.loadingType !== undefined && this.oSettings.loadingType !== "null") { this.sLoadingType = this.oSettings.loadingType; } if (this.oSettings.loadingDistance !== undefined && this.oSettings.loadingDistance !== "null") { this.iLoadingDistance = this.oSettings.loadingDistance; } if (this.oSettings.showLoadingMessage !== undefined && this.oSettings.showLoadingMessage !== "null") { this.bShowLoadingMessage = this.oSettings.showLoadingMessage; } if (this.oSettings.loadingMessageText !== undefined && this.oSettings.loadingMessageText !== "null") { this.sLoadingMessageText = this.oSettings.loadingMessageText; } if (this.oSettings.useFadeTransition !== undefined && this.oSettings.useFadeTransition !== "null") { this.bUseFadeTransition = this.oSettings.useFadeTransition; } // // Check for badging recipe id and save it // var heroSrc = RICHFX.jQuery(this.oHeroElement).attr('src'); if ( heroSrc.indexOf('adgeRecipeId=') != -1 ) { this.hasBadgingRecipe = true; var badgeParts = heroSrc.split('adgeRecipeId='); // remove 'b' from the start in case of capitalization badgeParts = badgeParts[1].split('&'); this.badgingRecipeId = badgeParts[0]; } if ( heroSrc.indexOf('adgeRecipeName=') != -1 ) { this.hasBadgingRecipe = true; var badgeParts = heroSrc.split('adgeRecipeName='); // remove 'b' from the start in case of capitalization badgeParts = badgeParts[1].split('&'); this.badgingRecipeName = badgeParts[0]; } this.register(); this.require(); }, require: function() { RICHFX.helpers.getScripts([RICHFX.settings.sJsDepsUrl+"modernizr/modernizr.touch.min.js"], function(){}); // register the available external calls this._methods(); this.embed(); }, embed: function() { // Check for the RichFX container, create it if it doesn't exist if (!RICHFX.jQuery('#RICHFXViewerContainer_'+this.sViewerID).length ) { RICHFX.jQuery(this.oHeroElement).replaceWith('
'); //RICHFX.jQuery(this.oHeroElement).clone().hide().appendTo('#RICHFXViewerContainer_'+this.sViewerID); RICHFX.jQuery(this.oHeroElement).clone().appendTo('#RICHFXViewerContainer_'+this.sViewerID); RICHFX.jQuery('#RICHFXViewerContainer_'+this.sViewerID).css('width', this.iVWidth); RICHFX.jQuery('#RICHFXViewerContainer_'+this.sViewerID).css('height', this.iVHeight); RICHFX.jQuery('#RICHFXViewerContainer_'+this.sViewerID).css('z-index', 20000); RICHFX.jQuery('#RICHFXViewerContainer_'+this.sViewerID).css('overflow', 'hidden'); var cursorURL = RICHFX.settings.sBaseURL +'ViewerDelivery/staticService?profileid=12056150&file=/assets/zoomCursor.png'; RICHFX.jQuery('#RICHFXViewerContainer_'+this.sViewerID).css('cursor', 'url('+cursorURL+'),default'); RICHFX.jQuery(this.oHeroElement).css('z-index', 10000); } // Bind the container to listen for change.source, then issue a changeSource call //RICHFX.jQuery('#RICHFXViewerContainer_'+this.sViewerID).bind(this.sName + '.change.source', RICHFX.jQuery.proxy(function(event, data){ RICHFX.jQuery('#RICHFXViewerContainer_'+this.sViewerID).bind('image.change.source', RICHFX.jQuery.proxy(function(event, data){ this.changeSource(data); RICHFX.jQuery('#RICHFXViewerContainer_'+this.sViewerID).trigger('viewfinder.change.source', data); return false; }, this)); RICHFX.jQuery('#RICHFXViewerContainer_'+this.sViewerID).bind('assetstate.zoom.changed assetstate.pinchzoom.changed', RICHFX.jQuery.proxy(function(eventObj){ this.updateDisplaySettings(); }, this)); var vars = [], hash; var heroSrc = RICHFX.jQuery(this.oHeroElement).attr('src'); var hashes = heroSrc.slice(heroSrc.indexOf('?') + 1).split('&'); for(var i = 0; i < hashes.length; i++) { hash = hashes[i].split('='); vars.push(hash[0]); vars[hash[0].toLowerCase()] = hash[1]; } var heroMediaStr = ""; var firstParam = true; var productXMLReq = this.oSettings.productXmlServiceUrl; //HACK: Required for iPad testing productXMLReq = productXMLReq.replace("dev-rfxweb-01/", "dev-rfxweb-01.channeladvisor.com/"); for ( var paramName in vars ) { if ( paramName.indexOf('recipe') == -1 && paramName.length > 1 ) { var paramVal = vars[paramName]; // Ensure consistency //paramName = paramName.toLowerCase(); if ( firstParam ) { productXMLReq = productXMLReq + paramName + "=" + paramVal; firstParam = false; } else { productXMLReq = productXMLReq + "&" + paramName + "=" + paramVal; } if ( heroMediaStr == "" ) { heroMediaStr = paramName + "=" + paramVal; } else { heroMediaStr = heroMediaStr + "&" + paramName + "=" + paramVal; } } } // create required function var callbackHero = heroMediaStr.replace(/[^a-z0-9]/gi, ''); var callbackName = 'productXmlCallback'+this.sName+callbackHero; var funcDef = "function " + callbackName + "(data) {return true;}"; eval(funcDef); // productXMLReq = productXMLReq + "&viewerid="+this.oSettings.organisatinalViewerId+"&callback=?"; /* // Build pXml call var heroMediaStr = RICHFX.helpers.buildProductXmlRequest(this.oHeroElement, this.oSettings.productXmlServiceUrl, this.oSettings.organisatinalViewerId); var productXMLReq = this.oSettings.productXmlServiceUrl + heroMediaStr + "&viewerid="+this.oSettings.organisatinalViewerId+"&callback=?"; // iPad needs this for testing productXMLReq = productXMLReq.replace("dev-rfxweb-01/", "dev-rfxweb-01.channeladvisor.com/"); // create required function var callbackHero = heroMediaStr.replace(/[^a-z0-9]/gi, ''); var callbackName = 'productXmlCallback'+this.sName+callbackHero; var funcDef = "function " + callbackName + "(data) {return true;}"; eval(funcDef); // */ if ( productXMLReq != this.sLastPXmlReq ) { this.sLastPXmlReq = productXMLReq; //console.log('calling pXml: ' + productXMLReq); productXMLReq = RICHFX.media.buildRequiredUrl(productXMLReq); RICHFX.jQuery.ajax({ url: productXMLReq, dataType: 'jsonp', jsonpCallback: callbackName, cache: true, context: this, success: function(data) { RICHFX.jQuery.proxy(this.handleProductXmlData(data), this); }, error: function(jqXHR, textStatus, errorThrown) { RICHFX.jQuery.Console.Warn("Ajax Error: ", errorThrown); } }); } }, execute: function(action, obj) { //console.log('calling: ' + action); // Check if the action is allowed if (RICHFX.jQuery.inArray( action, this.aExternalMethods ) >= 0 ) { if (this[action]) { this[action](obj); RICHFX.jQuery.Console.Debug('imagePanZoom is executing '+action+' on '+this.sElementID); } else { RICHFX.jQuery.Console.Warn(action+ ' has not been implemented by imagePanZoom'); } } }, originalSize: function() { RICHFX.jQuery('#RICHFXViewerContainer_' + this.sViewerID).trigger("reset.zoombehavior"); return false; }, zoomIn: function() { RICHFX.jQuery('#RICHFXViewerContainer_' + this.sViewerID).trigger("zoomin.zoombehavior"); return false; }, zoomOut: function() { RICHFX.jQuery('#RICHFXViewerContainer_' + this.sViewerID).trigger("zoomout.zoombehavior"); return false; }, // refactor the productXML Requests changeSource: function (data) { //console.log('imagePanZoom ChangeSource: ', RICHFX.jQuery(this.oHeroElement) ); var heroMedia = RICHFX.jQuery(this.oHeroElement).attr('rfxMedia'); //console.log('Handling changeSource for ' + heroMedia); if ( this.bStockImageLoad ) { this.bStockImageLoad = false; var origSrc = RICHFX.jQuery(this.oHeroElement).attr('src'); var recipe = origSrc.split('&recipe')[1]; var newSrc = 'http://richmedia.channeladvisor.com/ImageDelivery/imageService?'+heroMedia+'&recipe'+recipe; newSrc = RICHFX.media.buildRequiredUrl(newSrc); //console.log('changeSource dataSrc: ' + newSrc); RICHFX.jQuery(this.oHeroElement).attr('src', newSrc); this.embed(); } // create loading message if ( this.bShowLoadingMessage ) { var loadingMessageMarkup = '
' + this.sLoadingMessageText + '
'; RICHFX.jQuery('#RICHFXViewerContainer_' + this.sViewerID).append(loadingMessageMarkup).find(':last').css('opacity', 0.5); } // Get ProductXML data var vars = [], hash; var heroSrc = data.src; this.bFastTransition = data.fastTransition; //console.log('changeSource - heroMedia: ' + heroMedia + ', dataSrc: ' + data.src); //console.log('changeSource: ' + this.bInitialized + '|' + heroMedia + ' - ', data); var hashes = heroSrc.slice(heroSrc.indexOf('?') + 1).split('&'); for(var i = 0; i < hashes.length; i++) { hash = hashes[i].split('='); vars.push(hash[0]); vars[hash[0].toLowerCase()] = hash[1]; } var heroMediaStr = ""; var firstParam = true; var productXMLReq = this.oSettings.productXmlServiceUrl; // HACK: required for iPad testing productXMLReq = productXMLReq.replace("dev-rfxweb-01/", "dev-rfxweb-01.channeladvisor.com/"); if ( heroMedia != null && heroMedia != "" && heroMedia.indexOf('=') != -1 ) { productXMLReq = productXMLReq + "" + heroMedia + "&viewerid=" + this.oSettings.organisatinalViewerId + "&callback=?"; heroMediaStr = heroMedia; for ( var paramName in vars ) { if ( paramName.indexOf('recipeid') != -1 ) { this.iSourceChangeRecipeId = vars[paramName]; } } } else { // build request based on image request for ( var paramName in vars ) { if ( paramName.indexOf('recipeid') != -1 ) { this.iSourceChangeRecipeId = vars[paramName]; } if ( paramName.indexOf('recipe') == -1 && paramName.length > 1 ) { var paramVal = vars[paramName]; // Ensure consistency //paramName = paramName.toLowerCase(); if ( firstParam ) { productXMLReq = productXMLReq + paramName + "=" + paramVal; firstParam = false; } else { productXMLReq = productXMLReq + "&" + paramName + "=" + paramVal; } if ( heroMediaStr == "" ) { heroMediaStr = paramName + "=" + paramVal; } else { heroMediaStr = heroMediaStr + "&" + paramName + "=" + paramVal; } } } productXMLReq = productXMLReq + "&viewerid=" + this.oSettings.organisatinalViewerId + "&callback=?"; } // create required function var callbackHero = heroMediaStr.replace(/[^a-z0-9]/gi, ''); var callbackName = 'productXmlCallback'+this.sName+callbackHero; //console.log('created callback function: ' + callbackName); var funcDef = "function " + callbackName + "(data) {return true;}"; eval(funcDef); // /* // Build pXml call var heroMediaStr = RICHFX.helpers.buildProductXmlRequest(this.oHeroElement, this.oSettings.productXmlServiceUrl, this.oSettings.organisatinalViewerId); var productXMLReq = this.oSettings.productXmlServiceUrl + heroMediaStr + "&viewerid="+this.oSettings.organisatinalViewerId+"&callback=?"; // iPad needs this for testing productXMLReq = productXMLReq.replace("dev-rfxweb-01/", "dev-rfxweb-01.channeladvisor.com/"); // create required function var callbackHero = heroMediaStr.replace(/[^a-z0-9]/gi, ''); var callbackName = 'productXmlCallback'+this.sName+callbackHero; var funcDef = "function " + callbackName + "(data) {return true;}"; eval(funcDef); // */ if ( productXMLReq != this.sLastPXmlReq ) { this.sLastPXmlReq = productXMLReq; //console.log('calling pXml2: ' + productXMLReq); productXMLReq = RICHFX.media.buildRequiredUrl(productXMLReq); RICHFX.jQuery.ajax({ url: productXMLReq, dataType: 'jsonp', jsonpCallback: callbackName, cache: true, context: this, success: function(data) { RICHFX.jQuery.proxy(this.handleSourceChange(data), this); }, error: function(jqXHR, textStatus, errorThrown) { RICHFX.jQuery.Console.Warn("pXml2 Ajax Error: ", errorThrown); } }); } }, handleProductXmlData: function (data) { if ( data != undefined && data != null ) { RICHFX.jQuery(this.oHeroElement).hide(); this.oJSONData = data; var imagesArr = data["product"]["images"]; this.embedZoomViewer(imagesArr); } else { //console.log('Empty Pxml data .. force cUrl load'); this.bStockImageLoad = true; // Aloow othe viewers to load //RICHFX.jQuery('#RICHFXViewerContainer_'+this.sViewerID).trigger('imagePanZoom.initialized'); RICHFX.helpers.getScripts([RICHFX.settings.sJsDepsUrl+"cujo/curl/src/curl.js"], this.curlLoadedHandler, this, {scope:this, config:this.config, data:data}); } }, handleSourceChange: function (data) { /* if ( this.bStockImageLoad ) { this.bStockImageLoad = false; //RICHFX.jQuery(this.oHeroElement).attr('src', data.src); this.embed(); } */ if ( data == undefined ) return; var imagesArr = data["product"]["images"]; var zoomSrc = imagesArr[0]["@path"]; var altText = imagesArr[0]["text"]; zoomSrc = RICHFX.media.buildRequiredUrl(zoomSrc); var initialSrc = zoomSrc.replace(/([&?]recipeId=)([0-9]+)([&]?.*$)/, "$1"+this.iSourceChangeRecipeId+"$3"); if ( this.hasBadgingRecipe ) { if ( this.badgingRecipeId != 0 ) { initialSrc += '&badgeRecipeId=' + this.badgingRecipeId; } else { initialSrc += '&badgeRecipeName=' + this.badgingRecipeName; } } // get a relevant z-index value var zIndexNumber = RICHFX.jQuery.topZIndex(); if ( RICHFX.jQuery('#RICHFXViewerContainer_' + this.sViewerID + '_cb') ) { zIndexNumber = RICHFX.jQuery('#RICHFXViewerContainer_' + this.sViewerID + '_cb').css("z-index") - 100; } // Choose which image to clone var fadeOutImg = RICHFX.jQuery('#RICHFXViewerContainer_' + this.sViewerID + '_initialImage'); if ( this.oZoomState != null && this.oZoomState.getZoomLevel() > 0 ) { fadeOutImg = RICHFX.jQuery('#RICHFXViewerContainer_' + this.sViewerID + '_zoomImage'); } var InitImg = RICHFX.jQuery('#RICHFXViewerContainer_' + this.sViewerID + '_initialImage'); this.updateDisplaySettings(); // Layer on the dummyCopy // set zindex, then create cloned dummImage RICHFX.jQuery(fadeOutImg).css("z-index", zIndexNumber); RICHFX.jQuery(InitImg).css("z-index", zIndexNumber + 10); RICHFX.jQuery(fadeOutImg).clone().appendTo('#RICHFXViewerContainer_'+this.sViewerID).attr('id', 'dummyInitImage').css({"position": "absolute", "top": "opx", "left": "opx", "z-index": (zIndexNumber + 50)}); // load zoom without fade RICHFX.jQuery('#RICHFXViewerContainer_' + this.sViewerID + '_zoomImage').attr('src', zoomSrc); if ( altText != undefined ) { RICHFX.jQuery('#RICHFXViewerContainer_' + this.sViewerID + '_zoomImage').attr('alt', altText); RICHFX.jQuery('#RICHFXViewerContainer_' + this.sViewerID + '_zoomImage').attr('title', altText); RICHFX.jQuery('#RICHFXViewerContainer_' + this.sViewerID + '_zoomImage').attr('aria-label', altText); } if ( this.oZoomState != null && this.oZoomState.getZoomLevel() > 0 ) { RICHFX.jQuery('#RICHFXViewerContainer_' + this.sViewerID).trigger("reset.zoombehavior"); } this.iFadeTime = 1200; if ( this.bFastTransition || !this.bUseFadeTransition ) this.iFadeTime = 10; // Start fadeOut RICHFX.jQuery(InitImg).load(RICHFX.jQuery.proxy(function(){ RICHFX.jQuery('#dummyInitImage').fadeOut(this.iFadeTime, RICHFX.jQuery.proxy(function(){ if ( this.bShowLoadingMessage ) { RICHFX.jQuery('.RICHFXImageSourceChange').remove(); } // remove dummy image RICHFX.jQuery('#dummyInitImage').css("z-index", (zIndexNumber-100)).remove(); RICHFX.jQuery('#RICHFXViewerContainer_'+this.sViewerID).trigger('image.change.complete'); this.bFastTransition = false; }, this)); }, this)); if ( altText != undefined ) { RICHFX.jQuery(InitImg).attr('alt', altText); RICHFX.jQuery(InitImg).attr('title', altText); RICHFX.jQuery(InitImg).attr('aria-label', altText); } RICHFX.jQuery(InitImg).attr("src", initialSrc).show(); // Make sure the Dragbox is above everything - IE 7 bug with z-indexes if ( RICHFX.jQuery.browser.msie && (RICHFX.jQuery.browser.version < 8) && RICHFX.settings.bColorChangeOverlayEnabled ) { RICHFX.helpers.refreshZIndexIE('RICHFXViewerContainer_'+this.sViewerID, 20000); } }, updateDisplaySettings: function(data) { var CTAImage = this.sCTAImageID; var CTATrigger = "zoomin.zoombehavior"; if ( this.oZoomState != null && this.oZoomState.getZoomLevel() > 0 ) { CTAImage = this.sCTAZoomImageID; CTATrigger = "zoomout.zoombehavior"; } if ( this.oZoomSpec != null ) { // update all relevant settings this.oZoomSpec.callToAction.setVisibility(this.sCallToActionType); this.oZoomSpec.callToAction.setMessageText(this.sCallToAction); this.oZoomSpec.callToAction.setCustomCTA(CTAImage, this.sCTATop, this.sCTALeft, CTATrigger); } }, embedZoomViewer: function(data) { var zoomWidth = data[0]["size"]["width"]; var zoomHeight = data[0]["size"]["height"]; var zoomPath = data[0]["@path"]; var imgAltText = data[0]["text"]; var maxStr = ""; if ( zoomWidth > 0 ) maxStr += 'max-width: '+zoomWidth+'px;'; if ( zoomHeight > 0 ) maxStr += ' max-height: '+zoomHeight+'px;'; var altText = ""; if (imgAltText != undefined && imgAltText != "") { //console.log("imageZoom - Setting altText with 'text' value - " + imgAltText); altText = 'alt="'+imgAltText+'" title="'+imgAltText+'" aria-label="'+imgAltText+'"'; } zoomPath = RICHFX.media.buildRequiredUrl(zoomPath); RICHFX.jQuery('').appendTo('#RICHFXViewerContainer_'+this.sViewerID); RICHFX.jQuery('').appendTo('#RICHFXViewerContainer_'+this.sViewerID); //console.log('Calling curlLoadedHandler'); // nathan.sweany removed this in favor of a callback that doesn't lose scope //RICHFX.helpers.getScripts([RICHFX.settings.sJsDepsUrl+"curl.curl.js"], curlLoaded); RICHFX.helpers.getScripts([RICHFX.settings.sJsDepsUrl+"cujo/curl/src/curl.js"], this.curlLoadedHandler, this, {scope:this, config:this.config, data:data}); }, curlLoadedHandler:function(cbObject){ //console.log('Entered curlLoadedHandler'); if ( this.iVWidth == 0 ) this.iVWidth = RICHFX.jQuery('#'+this.sElementID).width(); if ( this.iVHeight == 0 ) this.iVHeight = RICHFX.jQuery('#'+this.sElementID).height(); var zoomPath = RICHFX.jQuery(this.oHeroElement).attr('src'); if ( cbObject.data != undefined ) { zoomPath = cbObject.data[0]["@path"]; } if ( !this.bStockImageLoad ) { // configure the wire rootSpec var zoomWire = { initialWidth: this.iVWidth, initialHeight: this.iVHeight, dispatcher: {$ref: 'dom!RICHFXViewerContainer_'+this.sViewerID}, product: cbObject.data, state: cbObject.data, // tmp initialPath: RICHFX.jQuery('#'+this.sElementID).attr('src'), zoomPath: zoomPath, initialImage: {$ref: 'dom!RICHFXViewerContainer_'+this.sViewerID+'_initialImage'}, zoomImage: {$ref: 'dom!RICHFXViewerContainer_'+this.sViewerID+'_zoomImage'}, initialProxy: {$ref: 'dom!RICHFXViewerContainer_'+this.sViewerID+'_initialImage'}, //tmp ctaVisibility: this.sCallToActionType, ctaText: this.sCallToAction, ctaImageID: this.sCTAImageID, ctaLeft: this.sCTALeft, ctaTop: this.sCTATop, cbVisibility: this.bShowControlBar, vfVisibility: this.bViewFinder, handlePinchZoom: this.bHandlePinchZoom, zoomType: this.bZoomType, rotation: false, plugins:[ { module: 'cujo/wire/dom' } // Uncomment if cURL debug is required //{ module: 'cujo/wire/debug' } ] }; if ( window.wire ) { window.wire = RICHFX.jQuery.extend(true, window.wire, zoomWire); } else { window.wire = zoomWire; } // initialize curl and load the wire spec curl(this.config, ['wire!zoom/js/config/ImagePanZoom']).then( RICHFX.jQuery.proxy(function(imagePanZoomSpec){ //console.log('reached zoomspec'); this.oZoomSpec = imagePanZoomSpec; this.oZoomState = imagePanZoomSpec.state; //console.log('zoomSpec viewerID: ' + this.sViewerID); imagePanZoomSpec.zoomBehavior.setState(imagePanZoomSpec.state, this.sViewerID); imagePanZoomSpec.zoomBehavior.setInitialAsset(imagePanZoomSpec.initialAsset); imagePanZoomSpec.dragBehavior.setState(imagePanZoomSpec.state, this.sViewerID); imagePanZoomSpec.initialAsset.setState(imagePanZoomSpec.state, this.sViewerID); imagePanZoomSpec.viewFinder.setVisibility(this.bViewFinder); imagePanZoomSpec.viewFinder.setState(imagePanZoomSpec.state, this.sViewerID); imagePanZoomSpec.callToAction.setVisibility(this.sCallToActionType); imagePanZoomSpec.callToAction.setState(imagePanZoomSpec.state, this.sViewerID); //imagePanZoomSpec.callToAction.setMessageText(this.sCallToAction); imagePanZoomSpec.controlBar.setVisibility(this.bShowControlBar); imagePanZoomSpec.zoomProxy.setState(imagePanZoomSpec.state, this.sViewerID); imagePanZoomSpec.zoomProxy.pushMediaData(imagePanZoomSpec.product[0].size); imagePanZoomSpec.state.setMaxZoomLevel(this.maxClickLevel); imagePanZoomSpec.state.attachBindings(this.sViewerID); }, this), function(error){ RICHFX.jQuery.Console.Warn("error:", error); RICHFX.jQuery.Console.Warn("stack:", error.get_stack()); } ); } RICHFX.jQuery('#RICHFXViewerContainer_'+this.sViewerID).trigger('imagePanZoom.initialized'); this._initialized(); }, _initialized: function() { RICHFX.controller.register(this.sViewerID, this.oHeroElement, this.sName); this.bInitialized = true; RICHFX.jQuery('#RICHFXViewerContainer_'+this.sViewerID+'_imagePanZoom').topZIndex(); if ( RICHFX.settings.bColorChangeOverlayEnabled ) { var currTop = RICHFX.jQuery('#RICHFXViewerContainer_'+this.sViewerID+'_imagePanZoom').css("z-index"); currTop -= 10; RICHFX.jQuery('#RICHFXViewerContainer_'+this.sViewerID+'_imagePanZoom').css("z-index", currTop); } }, _unpackSettings: function(oSettings) { // Unpack other objects var settingsClone = RICHFX.jQuery.extend(true, {}, oSettings); for ( var setting in settingsClone ) { if ( typeof(settingsClone[setting]) == "object" ) { if ( setting == "element" ) { this.oUnPackedSettings["element"] = settingsClone[setting]; } else { var settingObj = settingsClone[setting]; for ( var subSetting in settingObj ) { this.oUnPackedSettings[subSetting] = settingObj[subSetting]; } } } else { this.oUnPackedSettings[setting] = settingsClone[setting]; } } }, _methods: function() { this.aExternalMethods = ['zoomIn', 'zoomOut', 'originalSize', 'changeSource', 'preload']; }, register: function() { RICHFX.media.aLoadedComponents['imagePanZoom'] = true; if (!RICHFX.media.aRegViewers[this.sElementID]) { RICHFX.media.aRegViewers[this.sElementID] = {}; } RICHFX.media.aRegViewers[this.sElementID][this.sViewerID+'_imagePanZoom'] = this; }, //id, the trigger event and the object loadData: function() { } };