/* FWDMMarker */
(function (window){
var FWDMMarker = function(
markerId,
normalImagePath,
selectedImagePath,
type,
regPoint,
toolTipLabel,
id,
originalX,
originalY,
width,
height,
showAfterScale,
toolTipOffsetX,
hasContent_bl,
useVectroIcons){
var _s = this;
var prototype = FWDMMarker.prototype;
_s.n_do;
_s.s_do;
_s.markerId = markerId;
_s.normalImagePath_str = normalImagePath;
_s.selectedImagePath_str = selectedImagePath;
_s.type_str = type;
_s.toolTipLabel_str = toolTipLabel;
_s.innerHTML_str;
_s.link_str;
_s.target_str;
_s.regPoint_str = regPoint;
_s.vectorClassN = 'fwdm-skin-vector-marker-button';
_s.vectorClassS = 'fwdm-skin-vector-marker-button selected';
_s.id = id;
_s.toolTipOffsetX = toolTipOffsetX;
_s.toolTipWindowId;
_s.width = width;
_s.height = height;
_s.originalX = originalX;
_s.originalY = originalY;
_s.finalX;
_s.finalY;
_s.offsetX;
_s.offsetY;
_s.toolTipWindowMaxWidth;
_s.showAfterScale = showAfterScale;
_s.hasHTMLContent_bl = hasContent_bl;
_s.isDisabled_bl = false;
_s.hasToolTip_bl = true;
_s.isDisabled_bl = false;
_s.isHiddenFinal_bl = false;
_s.isShowed_bl = true;
_s.isMobile_bl = FWDMUtils.isMobile;
_s.hasPointerEvent_bl = FWDMUtils.hasPointerEvent;
//##########################################//
/* initialize _s */
//##########################################//
_s.init = function(){
_s.setOverflow("visible");
if(_s.type_str == "tooltip" || !_s.toolTipLabel_str) _s.hasToolTip_bl = false;
_s.setWidth(_s.width);
_s.setHeight(_s.height);
_s.setupMainContainers();
if(_s.regPoint_str == "center"){
_s.offsetX = -(parseInt(_s.width/2));
_s.offsetY = -(parseInt(_s.height/2));
}else if(_s.regPoint_str == "centertop"){
_s.offsetX = -(parseInt(_s.width/2));
_s.offsetY = 0;
}else if(_s.regPoint_str == "centerbottom"){
_s.offsetX = -(parseInt(_s.width/2));
_s.offsetY = -_s.height;
_s.n_do.getStyle().transformOrigin = '50% 100%';
if(_s.s_do) _s.n_do.getStyle().transformOrigin = '50% 100%';
}else if(_s.regPoint_str == "leftbottom"){
_s.offsetX = 0;
_s.offsetY = -_s.height;
_s.n_do.getStyle().transformOrigin = '0% 100%';
if(_s.s_do) _s.n_do.getStyle().transformOrigin = '0% 100%';
}
_s.hide();
};
//##########################################//
/* setup main containers */
//##########################################//
_s.setupMainContainers = function(){
_s.setOverflow('visible');
if(useVectroIcons){
var content = ''
if(normalImagePath.indexOf('marker1') != -1){
content = '';
}else if(normalImagePath.indexOf('marker2') != -1){
content = '';
}else if(normalImagePath.indexOf('marker3') != -1){
content = '';
}else if(normalImagePath.indexOf('marker4') != -1){
content = '';
}
_s.n_do = new FWDMTransformDisplayObject("div");
_s.n_do.setOverflow("visible");
_s.n_do.getStyle().lineHeight = 0;
_s.n_do.screen.className = 'fwdm-marker';
_s.icnHolder = new FWDMDisplayObject("div", 'relative');
_s.icnHolder.setOverflow("visible");
_s.icnHolder.getStyle().boxSizing = 'border-box';
_s.icnHolder.getStyle().display = 'flex';
_s.icnHolder.getStyle().alignItems = 'center';
_s.icnHolder.getStyle().justifyContent = 'center';
_s.icnHolder.setWidth(_s.width);
_s.icnHolder.setHeight(_s.width);
_s.icnHolder.setInnerHTML(content);
_s.setNormalState()
_s.n_do.addChild(_s.icnHolder);
_s.addChild(_s.n_do);
_s.dumy = new FWDMDisplayObject('div');
_s.dumy.getStyle().width = '100%';
_s.dumy.getStyle().height = '100%';
_s.addChild(_s.dumy);
}else{
var img;
var img2;
_s.n_do = new FWDMTransformDisplayObject("img");
img = new Image();
img.src = _s.normalImagePath_str;
_s.n_do.setScreen(img);
_s.n_do.screen.className = 'fwdm-png-marker';
_s.n_do.setWidth(_s.width);
_s.n_do.setHeight(_s.height);
_s.w = _s.n_do.w;
_s.h = _s.n_do.h;
_s.s_do = new FWDMTransformDisplayObject("img");
img2 = new Image();
img2.src = _s.selectedImagePath_str;
_s.s_do.setScreen(img2);
_s.s_do.setWidth(_s.width);
_s.s_do.setHeight(_s.height);
_s.s_do.setAlpha(0);
_s.addChild(_s.n_do);
_s.addChild(_s.s_do);
}
_s.setWidth(_s.width);
_s.setHeight(_s.height);
_s.setButtonMode(true);
if(_s.isMobile_bl){
if(_s.hasPointerEvent_bl){
_s.screen.addEventListener("MSPointerDown", _s.onMouseDown);
_s.screen.addEventListener("MSPointerUp", _s.onClick);
_s.screen.addEventListener("MSPointerOver", _s.onMouseOver);
_s.screen.addEventListener("MSPointerOut", _s.onMouseOut);
}else{
_s.screen.addEventListener("touchstart", _s.onMouseDown);
}
}else if(_s.screen.addEventListener){
_s.screen.addEventListener("mouseover", _s.onMouseOver);
_s.screen.addEventListener("mouseout", _s.onMouseOut);
_s.screen.addEventListener("mousedown", _s.onMouseDown);
_s.screen.addEventListener("click", _s.onClick);
}else if(_s.screen.attachEvent){
_s.screen.attachEvent("onmouseover", _s.onMouseOver);
_s.screen.attachEvent("onmouseout", _s.onMouseOut);
_s.screen.attachEvent("onmousedown", _s.onMouseDown);
_s.screen.attachEvent("onclick", _s.onClick);
}
};
_s.onMouseOver = function(e){
if(_s.isDisabled_bl) return;
if(!e.pointerType || e.pointerType == e.MSPOINTER_TYPE_MOUSE){
FWDAnimation.killTweensOf(_s.s_do);
FWDAnimation.killTweensOf(_s.n_do);
if(_s.isHtml5_bl){
_s.n_do.setScale2(1);
if(_s.s_do) _s.s_do.setScale2(1);
}else{
_s.n_do.setWidth(_s.width);
_s.n_do.setHeight(_s.height);
if(_s.s_do){
_s.s_do.setWidth(_s.width);
_s.s_do.setHeight(_s.height);
}
}
_s.setSelectedState(true);
_s.dispatchEvent(FWDMMarker.MOUSE_OVER, {e:e});
}
};
_s.onMouseOut = function(e){
if(_s.isDisabled_bl) return;
if(!e.pointerType || e.pointerType == e.MSPOINTER_TYPE_MOUSE){
_s.dispatchEvent(FWDMMarker.MOUSE_OUT, {_s:_s});
if(_s.type_str != "tooltip" && _s.type_str != "tooltip-plus" && _s.type_str != "tooltip-play") _s.setNormalState();
}
};
_s.onClick = function(e){
if(_s.isDisabled_bl) return;
if(_s.type_str == "link"){
window.open(_s.link_str, _s.target_str);
_s.dispatchEvent(FWDMMarker.MOUSE_OUT, {_s:_s});
}
_s.dispatchEvent(FWDMMarker.CLICK, {_s:_s});
};
_s.onMouseDown = function(e){
if(e.preventDefault) e.preventDefault();
if(_s.isDisabled_bl) return;
if(_s.isMobile_bl && !_s.hasPointerEvent_bl){
if(_s.type_str == "link"){
window.open(_s.link_str, _s.target_str);
_s.dispatchEvent(FWDMMarker.MOUSE_OUT, {_s:_s});
}
}
_s.dispatchEvent(FWDMMarker.MOUSE_DOWN, {_s:_s});
};
_s.setNormalState = function(anim){
if(useVectroIcons){
_s.icnHolder.screen.className = _s.vectorClassN;
}else{
FWDAnimation.killTweensOf(_s.s_do);
FWDAnimation.to(_s.s_do, .5, {alpha:0, ease:Expo.easeOut});
}
}
_s.setSelectedState = function(anim){
if(useVectroIcons){
_s.icnHolder.screen.className = _s.vectorClassS;
}else{
FWDAnimation.killTweensOf(_s.s_do);
FWDAnimation.to(_s.s_do, .5, {alpha:1, delay:.1, ease:Expo.easeOut});
}
}
//##############################//
// hide / show.
//##############################//
_s.hide = function(){
if(!_s.isShowed_bl) return;
FWDAnimation.killTweensOf(_s);
FWDAnimation.killTweensOf(_s.n_do);
FWDAnimation.killTweensOf(_s.s_do);
_s.setX(-5000);
_s.isShowed_bl = false;
};
_s.show = function(){
if(_s.isShowed_bl || _s.isHiddenFinal_bl) return;
FWDAnimation.killTweensOf(_s);
FWDAnimation.killTweensOf(_s.n_do);
FWDAnimation.killTweensOf(_s.s_do);
_s.setX(_s.finalX);
_s.setY(_s.finalY);
_s.isShowed_bl = true;
if(_s.isHtml5_bl){
_s.n_do.setScale2(0);
FWDAnimation.to(_s.n_do, .9, {scale:1, delay:.1, ease:Elastic.easeOut});
if(_s.s_do){
FWDAnimation.to(_s.s_do, .9, {scale:1, delay:.1, ease:Elastic.easeOut});
_s.s_do.setScale2(0);
}
}else{
_s.n_do.setWidth(0);
_s.n_do.setHeight(0);
if(_s.s_do){
_s.s_do.setWidth(0);
_s.s_do.setHeight(0);
FWDAnimation.to(_s.s_do, .9, {w:_s.width, h:_s.height, delay:.1, ease:Elastic.easeOut});
}
FWDAnimation.to(_s.n_do, .9, {w:_s.width, h:_s.height, delay:.1, ease:Elastic.easeOut});
}
};
//##############################//
/* destroy */
//##############################//
_s.destroy = function(){
if(_s.isMobile_bl){
_s.screen.removeEventListener("touchstart", _s.onMouseDown);
}else if(_s.screen.addEventListener){
_s.screen.removeEventListener("mouseover", _s.onMouseOver);
_s.screen.removeEventListener("mouseout", _s.onMouseOut);
_s.screen.removeEventListener("mousedown", _s.onMouseDown);
_s.screen.removeEventListener("click", _s.onClick);
}else if(_s.screen.detachEvent){
_s.screen.detachEvent("onmouseover", _s.onMouseOver);
_s.screen.detachEvent("onmouseout", _s.onMouseOut);
_s.screen.detachEvent("onmousedown", _s.onMouseDown);
_s.screen.detachEvent("onclick", _s.onClick);
}
FWDAnimation.killTweensOf(_s.n_do);
_s.n_do.src = null;
_s.n_do.destroy();
if(_s.s_do){
FWDAnimation.killTweensOf(_s.s_do);
_s.s_do.src = null;
_s.s_do.destroy();
}
_s.n_do = null;
_s.s_do = null;
_s.markerId = null;
_s.normalImagePath_str = null;
_s.selectedImagePath_str = null;
_s.type_str = null;
_s.toolTipLabel_str = null;
_s.innerHTML_str = null;
_s.link_str = null;
_s.target_str = null;
_s.regPoint_str = null;
markerId = null;
normalImagePath = null;
selectedImagePath = null;
type = null;
regPoint = null;
toolTipLabel = null;
_s.setInnerHTML("");
prototype.destroy();
_s = null;
prototype = null;
FWDMMarker.prototype = null;
};
_s.init();
};
/* set prototype */
FWDMMarker.setPrototype = function(){
FWDMMarker.prototype = new FWDMDisplayObject("div");
};
FWDMMarker.CLICK = "onClick";
FWDMMarker.MOUSE_OVER = "onMouseOver";
FWDMMarker.MOUSE_OUT = "onMouseOut";
FWDMMarker.MOUSE_DOWN = "onMouseDown";
FWDMMarker.prototype = null;
window.FWDMMarker = FWDMMarker;
}(window));