Posted by malatestapunk Fri 2nd Mar 2007 10:15 - Syntax is JavaScript - 73 views
Download | New Post | Modify | Hide line numbers
Download | New Post | Modify | Hide line numbers
Description:
twangoRotator twidget. See https://pastebin.co.uk/11288 for example usage.
twangoRotator twidget. See https://pastebin.co.uk/11288 for example usage.
-
function rotatorTwidget (prefs) {
-
-
var divID = "twangoRotator";
-
var imgOutDiv;
-
var outDiv;
-
var twangoImages = new Array();
-
-
var _imgWidth = 100;
-
var _imgHeight = 100;
-
var _divHeight = 0;
-
var _divWidth = 0;
-
var _scrollerHeight = 10;
-
var _scrollerUpBg = false;
-
var _scrollerDnBg = false;
-
var _onAction = "onclick";
-
-
var initDivs = function () {
-
_divHeight = (_divHeight) ? _divHeight : _imgHeight + (2*_scrollerHeight);
-
_divWidth = (_divWidth) ? _divWidth : _imgWidth;
-
-
outDiv.style.position = "relative";
-
outDiv.style.width = _divWidth + "px";
-
outDiv.style.height = _divHeight + 'px';
-
outDiv.style.overflow = "hidden";
-
-
imgOutDiv = document.createElement ('div');
-
upDiv = document.createElement ('div');
-
dnDiv = document.createElement ('div');
-
-
upDiv.style.position = "absolute";
-
upDiv.style.top = "0";
-
upDiv.style.left = "0";
-
if (_scrollerUpBg) {
-
upDiv.style.width = _divWidth + "px";
-
upDiv.style.height = _scrollerHeight + "px";
-
upDiv.style.backgroundImage = "url(" + _scrollerUpBg + ")";
-
upDiv.style.backgroundPosition = ((_divWidth-_imgWidth)/2) + 'px 0px';
-
upDiv.style.backgroundRepeat = "no-repeat";
-
} else {
-
upDiv.style.width = "0px";
-
upDiv.style.height = "0px";
-
upDiv.style.borderStyle = "solid";
-
upDiv.style.borderTopStyle = "none";
-
upDiv.style.borderLeftWidth = _divWidth/2 + 'px';
-
upDiv.style.borderLeftColor = 'transparent';
-
upDiv.style.borderRightWidth = _divWidth/2 + 'px';
-
upDiv.style.borderRightColor = 'transparent';
-
upDiv.style.borderBottomColor = "#dddddd";
-
upDiv.style.borderBottomWidth = _scrollerHeight + "px";
-
}
-
upDiv[_onAction] = getPrev;
-
-
dnDiv.style.position = "absolute";
-
dnDiv.style.top = _divHeight - _scrollerHeight + "px";
-
dnDiv.style.left = "0";
-
if (_scrollerDnBg) {
-
dnDiv.style.width = _divWidth + "px";
-
dnDiv.style.height = _scrollerHeight + "px";
-
dnDiv.style.backgroundImage = "url(" + _scrollerDnBg + ")";
-
dnDiv.style.backgroundPosition = (_divWidth-_imgWidth)/2 + 'px bottom';
-
dnDiv.style.backgroundRepeat = "no-repeat";
-
} else {
-
dnDiv.style.width = "0px";
-
dnDiv.style.height = "0px";
-
dnDiv.style.borderStyle = "solid";
-
dnDiv.style.borderBottomStyle = "none";
-
dnDiv.style.borderLeftWidth = _divWidth/2 + 'px';
-
dnDiv.style.borderLeftColor = 'transparent';
-
dnDiv.style.borderRightWidth = _divWidth/2 + 'px';
-
dnDiv.style.borderRightColor = 'transparent';
-
dnDiv.style.borderTopColor = "#dddddd";
-
dnDiv.style.borderTopWidth = _scrollerHeight + "px";
-
}
-
dnDiv[_onAction] = getNext;
-
-
outDiv.appendChild(upDiv);
-
outDiv.appendChild(imgOutDiv);
-
outDiv.appendChild(dnDiv);
-
-
__current = 0;
-
}
-
-
var getNext = function () {
-
if (__current+1 >= twangoImages.length) return false;
-
__current++;
-
putImageThumb(__current-1);
-
}
-
-
var getPrev = function () {
-
if (__current == 0) return false;
-
__current--;
-
putImageThumb(__current+1);
-
}
-
-
var putImageThumb = function (old) {
-
if (old !== false) imgOutDiv.removeChild(twangoImages[old]);
-
imgOutDiv.appendChild(twangoImages[__current]);
-
}
-
-
var init = function () {
-
if (twangoImage_array.length <= 0) return false;
-
outDiv = document.getElementById(divID);
-
outDiv.innerHTML = '';
-
initDivs();
-
var im, alink;
-
for (i=0; i
length; i++) { -
alink = document.createElement ('a');
-
alink.href = "http://www.twango.com/media/"+channelName+"/" + twangoImage_array[i][0];
-
alink.target = "_blank";
-
im = new Image();
-
im.style.border = "none";
-
im.id = twangoImage_array[i][0];
-
im.alt = twangoImage_array[i][0];
-
im.title = twangoImage_array[i][0];
-
im.src = twangoImage_array[i][1];
-
im.style.position = "absolute";
-
im.style.top = (((_divHeight - _imgHeight)/2) > _scrollerHeight) ?
-
((_divHeight - _imgHeight)/2) + 'px' : _scrollerHeight + "px";
-
im.style.left = (_divWidth-_imgWidth)/2 + 'px';
-
alink.appendChild(im);
-
twangoImages[i] = alink;
-
}
-
putImageThumb(false);
-
}
-
-
var parsePrefs = function () {
-
if (!prefs) return false;
-
if (prefs['divID']) divID = prefs['divID'];
-
if (prefs['onAction']) _onAction = prefs['onAction'];
-
if (prefs['width']) _divWidth = prefs['width'];
-
if (prefs['height']) _divHeight = prefs['height'];
-
if (prefs['scrollerUpBg']) _scrollerUpBg = prefs['scrollerUpBg'];
-
if (prefs['scrollerDnBg']) _scrollerDnBg = prefs['scrollerDnBg'];
-
if (prefs['scrollerHeight']) _scrollerHeight = prefs['scrollerHeight'];
-
}
-
-
parsePrefs ();
-
init();
-
}
PermaLink to this entry https://pastebin.co.uk/11289
Posted by malatestapunk Fri 2nd Mar 2007 10:15 - Syntax is JavaScript - 73 views
Download | New Post | Modify | Hide line numbers
Download | New Post | Modify | Hide line numbers
Comments: 1
Very cool! Do you have a page with this script running?