📄 allcatepop_b.js
字号:
var popY = oHotspot.abstop;
var nHAdj = this.nHAdjust;
var nVAdj = this.nVAdjust;
if (nVAdj == 'c') {
nVAdj = parseInt(oHotspot.height/2 - this.height/2);
} else if (nVAdj == 'b') {
nVAdj = oHotspot.height-this.height;
}
this._doLocate (popX + nHAdj, popY + nVAdj);
};
N2SimplePopover.prototype._locateBelowLink = function (oHotspot) {
var popX = oHotspot.absleft;
var popY = oHotspot.abstop + oHotspot.height;
var nHAdj = this.nHAdjust;
var nVAdj = this.nVAdjust;
if (nHAdj == 'c') {
nHAdj = parseInt(oHotspot.width*0/2 - this.width*0/2);
} else if (nHAdj == 'r') {
nHAdj = oHotspot.width-this.width;
}
this._doLocate (popX + nHAdj, popY + nVAdj);
};
N2SimplePopover.prototype._locateAboveLink = function (oHotspot) {
var popX = oHotspot.absleft;
var popY = oHotspot.abstop - this.height;
var nHAdj = this.nHAdjust;
var nVAdj = this.nVAdjust;
if (nHAdj == 'c') {
nHAdj = parseInt(oHotspot.width/2 - this.width/2);
} else if (nHAdj == 'r') {
nHAdj = oHotspot.width-this.width;
}
this._doLocate (popX + nHAdj, popY + nVAdj);
};
N2SimplePopover.prototype._locateLinkBelowAbove = function (oHotspot) {
var popX;
var popY;
var nXOffset = 100;
var nXOffsetL = 20;
var totalAvailFromLinkLeft = oHotspot.availRight + oHotspot.width;
if (this.width < (totalAvailFromLinkLeft - nXOffset) ) {
this.expandsH ='r';
} else {
this.expandsH ='l';
}
this.availDown = oHotspot.availUnder + oHotspot.height;
this.availUp = oHotspot.availAbove;
if (this.availUp < this.availDown - this.height ) {
this.expandsV = 'd';
} else {
this.expandsV = 'u';
}
if (this.expandsH == 'l') {
if (this.width + this.nHotPad < oHotspot.availLeft) {
popX = oHotspot.absleft - this.width - this.nHotPad + nXOffsetL;
} else {
popX = this.nEdgePad;
}
} else {
if (oHotspot.width >120) {
popX = oHotspot.absleft + nXOffset;
} else {
popX = oHotspot.absleft + oHotspot.width - nXOffsetL;
}
}
var totalAvailFromLinkTop = oHotspot.height + oHotspot.availUnder;
if (this.height <= oHotspot.availUnder) {
popY = oHotspot.abstop + oHotspot.height + this.nHotPad;
} else {
popY = oHotspot.abstop - (this.height-totalAvailFromLinkTop+this.nEdgePad);
if (oHotspot.width < 120) {
if (this.expandsH == 'r') {
popX = oHotspot.absleft + oHotspot.width + this.nHotPad;
} else {
popX = oHotspot.absleft - this.width - this.nHotPad;
}
}
}
this._doLocate(popX, popY);
};
N2SimplePopover.prototype._locateWindowCenter = function (oHotspot) {
var popX = Math.max(document.body.scrollLeft+((goN2U.getInsideWindowWidth()-this.width)/2), this.nEdgePad);
var popY = Math.max(document.body.scrollTop+((goN2U.getInsideWindowHeight()-this.height)/2), this.nEdgePad);
this._doLocate(popX, popY);
};
N2SimplePopover.prototype.createPopHTML = function (id, objectID, content) {
var gp = '';
gp+='<span id="' + id + '" class="n2Pop" style="display:none; left:0px; top:0px;"';
gp+='onMouseOver="' + objectID + '.mouseOver();" onMouseOut="' + objectID + '.mouseOut(event);"';
gp+='onMouseMove="' + objectID + '.mouseMove(event);">';
gp+='<span class="n2">';
if (content) {
gp+=content;
} else {
gp+='-- CONTENT GOES HERE (simple)--';
}
gp+='</span>';
gp+='</span>';
var spanEl = document.createElement("span");
spanEl.innerHTML = gp;
//if(typeof(document.body.childNodes[0])=="object"){
//alert(document.body.childNodes[0].tagName);}
document.body.insertBefore(spanEl,document.body.childNodes[0]);
};
N2SimplePopover.prototype.saveCurrentElementData = function() { };
N2SimplePopover.prototype._defaultPopulate = function(sAction, sID, sType, sParams, sLinkID, sHref, sLinkText) {
;
if (this.bLADSupported) {
if (!this.isDataAvailable(sAction, sID, sType, sParams, sLinkID, sHref, sLinkText)) {
return false;
}
}
switch (sType) {
case 'he': // id of an HTML element
this.populateUsingElementContents(sID);
break;
case 'ak': // array key
this.populateUsingArrayContents(sID);
break;
case 'a':
case 'am':
case 'n':
case 's':
case 'l':
break;
default:
;
}
if (this.bLADLoading) {
this.sizeOrPositionChanged();
}
return true;
};
N2SimplePopover.prototype.populate = N2SimplePopover.prototype._defaultPopulate;
N2SimplePopover.prototype.populateUsingElementContents = function(id, type, linkID, href, linkText) {
;
;
var eElem = goN2U.getRawObject(id);
if (eElem) {
this.setContent(eElem.innerHTML);
if (this.bMoveHEContent) {
this.sCurrentContent = eElem.innerHTML;
this.sCurrentHeID = id;
eElem.innerHTML = '';
}
} else {
;
}
};
N2SimplePopover.prototype.populateUsingArrayContents = function(id, type, linkID, href, linkText) {
;
;
if (goN2U.isDefined(this.aDataArray) ) {
if (goN2U.isDefined(this.aDataArray[id])) {
this.setContent(this.aDataArray[id]);
} else {
;
}
}
else {
;
}
};
N2SimplePopover.prototype.isDataAvailable = function(sAction, sID, sType, sParams, sLinkID, sHref, sLinkText) {
;
;
if ( this._isDataAvailable (sAction, sID, sType, sParams, sLinkID,
this.sLADKey, this.sLADField) ) {
return true;
} else {
if (--this.nLADRetries && this.isVisible()) {
if (!this.bLADLoading) {
this.setContent(this.sLADLoadingMessage);
this.bLADLoading = true;
}
setTimeout (new Function("", this.objectName + ".populate(" +
"'" + (sAction ? sAction : 'null') + "'," +
"'" + (sID ? sID : 'null') + "'," +
"'" + (sType ? sType : 'null') + "'," +
"'" + (sParams ? sParams : 'null') + "'," +
"'" + (sLinkID ? sLinkID : 'null') + "'," +
"'" + (sHref ? sHref : 'null') + "'," +
"'" + (sLinkText ? sLinkText : 'null') + "'" +
");"),
this.nLADRetryMs);
} else {
;
this.setContent(this.sLADTimeoutMessage);
}
return false;
}
};
N2SimplePopover.prototype._isDataAvailable = function(sAction, sID, sType, sParams, sLinkID,
sKey, sField) {
;
;
var bIsAvailable = true;
switch(sType) {
case 'he': // id of an HTML element
if ( sKey && goN2U.getRawObject(sKey)=== null ) {
bIsAvailable = false;
} else if ( goN2U.getRawObject(sID)=== null ) {
bIsAvailable = false;
}
break;
case 'ak': // array key
if (this.aDataArray) {
if ( sKey && goN2U.isUndefined(this.aDataArray[sKey]) ) {
bIsAvailable = false;
} else if ( goN2U.isUndefined(this.aDataArray[sID]) ) {
bIsAvailable = false;
}
}
break;
case 'a': // key is an ASIN (which means that the aDataArray should usually point ot gaTD)
case 'am':
var sTDKey = sType+sID;
if (this.aDataArray) {
if ( // an entry for this key
goN2U.isUndefined(this.aDataArray[sTDKey]) ||
( sField && goN2U.isUndefined(this.aDataArray[sTDKey][sField]) ) ||
( sKey && goN2U.isUndefined(this.aDataArray[sKey]) ) ||
( sKey && sField && goN2U.isUndefined(this.aDataArray[sKey][sField]) )) {
bIsAvailable = false;
}
}
break;
}
;
return bIsAvailable;
};
N2SimplePopover.prototype.sizeOrPositionChanged = function () {
if (this.myFeatureChangedCallback) {
this.myFeatureChangedCallback(this);
}
};
N2SimplePopover.prototype.updateLocation = function (flag){
var po = this.popObj;
this.left = goN2U.getObjectLeft(po);
this.top = goN2U.getObjectTop(po);
this.width = goN2U.getObjectWidth(po);
this.height = goN2U.getObjectHeight(po);
this.right = this.left + this.width;
this.bottom = this.top + this.height;
};
N2SimplePopover.prototype.mouseOver = function () {
if (this.initialMouseOver) {
;
this.initialMouseOver = false;
var ret = true;
if (this.myMouseOverCallback) {
;
ret = this.myMouseOverCallback(this);
}
if (ret) {
}
}
};
N2SimplePopover.prototype.mouseMove = function (evt) {
if (this.initialMouseOver) {
this.mouseOver();
}
};
N2SimplePopover.prototype.mouseOut = function (evt) {
var inPop = true;
evt = (evt) ? evt : ((window.event) ? window.event : null);
if (evt) {
if (goN2U.bIsIE) {
inPop = goN2U.elementIsContainedBy(evt.toElement, this.popObj);
} else {
var x = evt.pageX;
var y = evt.pageY;
var po = this.popObj;
var left = goN2U.getPageElementLeft(po);
var top = goN2U.getPageElementTop(po);
if ( (x <= left) || ( y <= top+1) ||
(x > left + this.width) ||
(y > top + this.height) ) {
inPop = false;
}
}
}
if (!inPop && !this.cursorCanLeavePopover && !this.buttonIsDown) {
;
this.initialMouseOver = true;
var ret = true;
if (this.myMouseOutCallback) {
;
ret = this.myMouseOutCallback(this);
;
}
if (ret) {
;
this.hide();
}
}
};
N2SimplePopover.prototype._hideTooltip = function (oLink) {
var firstChild = oLink.firstChild;
if (firstChild && firstChild.alt) {
this.sImgAlt = firstChild.alt;
firstChild.alt = '';
}
};
N2SimplePopover.prototype.hookEvents = function () { };
N2SimplePopover.prototype.unhookEvents = function () { };
if (window.goN2LibMon) { goN2LibMon.endLoad('simplePopover'); }
} // END library code wrapper
n2RunIfLoaded("events", n2SimplePopoverInitLibrary, "simplepopover");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -