'
});
*/
sb.swf.prototype = {
getInterface : function(){
var movieName = this.id;
if (navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName];
} else {
return document.getElementById(movieName);
}
},
/**
@Name: sb.swf.prototype.toHTML
@Description: Converts the sb.swf into the appropriate swf code for the browser being used by the client
@Return: String The HTML code required to embed the flash swf into the DOM, can be used as the innerHTML of another element
@Example:
var string = mySwf.toHTML();
//on embed style browsers returns
//on explorer returns
*/
toHTML : function(){
var html='';
if(this.version > sb.swf.version){
return this.alt;
}
if(sb.swf.format=='embed'){
html = '';
} else if(sb.swf.format=='object'){
html = '';
}
return html;
},
/**
@Name: sb.swf.prototype.embed
@Description: Converts the sb.swf into the appropriate swf code for the browser being used by the client and inserts that code into the element specified
@Param: element el Either an object reference to a dom element or a string reference that can be passed through sb.$ e.g. use the elements id '#someElement'
@Return: String The HTML code required to embed the flash swf into the DOM, can be used as the innerHTML of another element
@Example:
mySwf.embed('#someElement');
*/
embed : function(el){
el = $(el);
el.innerHTML = this.toHTML();
return el;
}
};
sb.swf.infuse = sb.objects.infuse;
sb.swf.infuse({
/**
@Name: sb.swf.version
@Description: Used Internally
*/
version : 4,
/**
@Name: sb.swf.swfs
@Description: Used Internally
*/
swfs : [],
/**
@Name: sb.swf.instanceId
@Description: Used Internally
*/
instanceId : 0,
/**
@Name: sb.swf.check
@Description: Used Internally
*/
check : function(){
var version, description;
try{
version = new RegExp("\\d{1}\.\\d{0,5}", "i");
if(window.navigator.plugins["Shockwave Flash"]){
description = window.navigator.plugins["Shockwave Flash"].description;
if(description.match(version)){
sb.swf.version = description.match(version);
}
}
} catch(e){sb.swf.version=0;}
return sb.swf.version;
},
/**
@Name: sb.swf.testIe
@Description: Used Internally
*/
testIe : function(){
try{
if(new window.ActiveXObject("ShockwaveFlash.ShockwaveFlash." + sb.swf.version)){
return false;
}
} catch(e){return true;}
},
/**
@Name: sb.swf.ieCheck
@Description: Used Internally
*/
ieCheck : function(){
try{
//THERE MUST BE A BETTER SOLUTION
while(!sb.swf.testIe()){
sb.swf.version++;
}
sb.swf.version--;
return sb.swf.version;
} catch(e){
return true;
}
},
/**
@Name: sb.swf.cleanup
@Description: Used Internally
*/
cleanup : function() {
try{
sb.$('object').forEach(function(obj){
obj.style.display='none';
for(var prop in obj){
if(typeof obj == 'function'){obj[prop] = function(){};}
}
});
}catch(e){}
},
/**
@Name: sb.swf.unload
@Description: Used Internally
*/
unload : function() {
__flash_unloadHandler = function(){};
__flash_savedUnloadHandler = function(){};
window.attachEvent( "onunload", sb.swf.cleanup );
},
/**
@Name: sb.swf.detect
@Description: Used Internally
*/
detect : function(){
for(var x=0;x>2] >> ((i%4)*8+4)) & 0xF) +
hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
}
return str;
},
/**
@Description: Used Internally.
*/
hex : function(s){
return this.binl2hex(this.core(this.str2binl(s), s.length * this.chrsz));
},
/**
@Description: Used Internally.
*/
b64 : function(s){
return this.binl2b64(this.core(this.str2binl(s), s.length * this.chrsz));
},
/**
@Description: Used Internally.
*/
str : function(s){
return this.binl2str(this.core(this.str2binl(s), s.length * this.chrsz));
},
/**
@Description: Used Internally.
*/
hex_hmac : function(key, data){
return this.binl2hex(this.core_hmac(key, data));
},
/**
@Description: Used Internally.
*/
b64_hmac : function(key, data) {
return this.binl2b64(this.core_hmac(key, data));
},
/**
@Description: Used Internally.
*/
str_hmac : function(key, data) {
return this.binl2str(this.core_hmac(key, data));
},
/**
@Description: Used Internally. Calculate the MD5 of an array of little-endian words, and a bit length
*/
core : function(x, len){
/* append padding */
x[len >> 5] |= 0x80 << ((len) % 32);
x[(((len + 64) >>> 9) << 4) + 14] = len;
var a = 1732584193;
var b = -271733879;
var c = -1732584194;
var d = 271733878;
for(var i = 0; i < x.length; i += 16){
var olda = a;
var oldb = b;
var oldc = c;
var oldd = d;
a = this.ff(a, b, c, d, x[i+ 0], 7 , -680876936);
d = this.ff(d, a, b, c, x[i+ 1], 12, -389564586);
c = this.ff(c, d, a, b, x[i+ 2], 17, 606105819);
b = this.ff(b, c, d, a, x[i+ 3], 22, -1044525330);
a = this.ff(a, b, c, d, x[i+ 4], 7 , -176418897);
d = this.ff(d, a, b, c, x[i+ 5], 12, 1200080426);
c = this.ff(c, d, a, b, x[i+ 6], 17, -1473231341);
b = this.ff(b, c, d, a, x[i+ 7], 22, -45705983);
a = this.ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
d = this.ff(d, a, b, c, x[i+ 9], 12, -1958414417);
c = this.ff(c, d, a, b, x[i+10], 17, -42063);
b = this.ff(b, c, d, a, x[i+11], 22, -1990404162);
a = this.ff(a, b, c, d, x[i+12], 7 , 1804603682);
d = this.ff(d, a, b, c, x[i+13], 12, -40341101);
c = this.ff(c, d, a, b, x[i+14], 17, -1502002290);
b = this.ff(b, c, d, a, x[i+15], 22, 1236535329);
a = this.gg(a, b, c, d, x[i+ 1], 5 , -165796510);
d = this.gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
c = this.gg(c, d, a, b, x[i+11], 14, 643717713);
b = this.gg(b, c, d, a, x[i+ 0], 20, -373897302);
a = this.gg(a, b, c, d, x[i+ 5], 5 , -701558691);
d = this.gg(d, a, b, c, x[i+10], 9 , 38016083);
c = this.gg(c, d, a, b, x[i+15], 14, -660478335);
b = this.gg(b, c, d, a, x[i+ 4], 20, -405537848);
a = this.gg(a, b, c, d, x[i+ 9], 5 , 568446438);
d = this.gg(d, a, b, c, x[i+14], 9 , -1019803690);
c = this.gg(c, d, a, b, x[i+ 3], 14, -187363961);
b = this.gg(b, c, d, a, x[i+ 8], 20, 1163531501);
a = this.gg(a, b, c, d, x[i+13], 5 , -1444681467);
d = this.gg(d, a, b, c, x[i+ 2], 9 , -51403784);
c = this.gg(c, d, a, b, x[i+ 7], 14, 1735328473);
b = this.gg(b, c, d, a, x[i+12], 20, -1926607734);
a = this.hh(a, b, c, d, x[i+ 5], 4 , -378558);
d = this.hh(d, a, b, c, x[i+ 8], 11, -2022574463);
c = this.hh(c, d, a, b, x[i+11], 16, 1839030562);
b = this.hh(b, c, d, a, x[i+14], 23, -35309556);
a = this.hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
d = this.hh(d, a, b, c, x[i+ 4], 11, 1272893353);
c = this.hh(c, d, a, b, x[i+ 7], 16, -155497632);
b = this.hh(b, c, d, a, x[i+10], 23, -1094730640);
a = this.hh(a, b, c, d, x[i+13], 4 , 681279174);
d = this.hh(d, a, b, c, x[i+ 0], 11, -358537222);
c = this.hh(c, d, a, b, x[i+ 3], 16, -722521979);
b = this.hh(b, c, d, a, x[i+ 6], 23, 76029189);
a = this.hh(a, b, c, d, x[i+ 9], 4 , -640364487);
d = this.hh(d, a, b, c, x[i+12], 11, -421815835);
c = this.hh(c, d, a, b, x[i+15], 16, 530742520);
b = this.hh(b, c, d, a, x[i+ 2], 23, -995338651);
a = this.ii(a, b, c, d, x[i+ 0], 6 , -198630844);
d = this.ii(d, a, b, c, x[i+ 7], 10, 1126891415);
c = this.ii(c, d, a, b, x[i+14], 15, -1416354905);
b = this.ii(b, c, d, a, x[i+ 5], 21, -57434055);
a = this.ii(a, b, c, d, x[i+12], 6 , 1700485571);
d = this.ii(d, a, b, c, x[i+ 3], 10, -1894986606);
c = this.ii(c, d, a, b, x[i+10], 15, -1051523);
b = this.ii(b, c, d, a, x[i+ 1], 21, -2054922799);
a = this.ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
d = this.ii(d, a, b, c, x[i+15], 10, -30611744);
c = this.ii(c, d, a, b, x[i+ 6], 15, -1560198380);
b = this.ii(b, c, d, a, x[i+13], 21, 1309151649);
a = this.ii(a, b, c, d, x[i+ 4], 6 , -145523070);
d = this.ii(d, a, b, c, x[i+11], 10, -1120210379);
c = this.ii(c, d, a, b, x[i+ 2], 15, 718787259);
b = this.ii(b, c, d, a, x[i+ 9], 21, -343485551);
a = this.safe_add(a, olda);
b = this.safe_add(b, oldb);
c = this.safe_add(c, oldc);
d = this.safe_add(d, oldd);
}
return [a, b, c, d];
},
/**
@Description: Used Internally.
*/
cmn : function(q, a, b, x, s, t){
return this.safe_add(this.bit_rol(this.safe_add(this.safe_add(a, q), this.safe_add(x, t)), s),b);
},
/**
@Description: Used Internally.
*/
ff : function(a, b, c, d, x, s, t){
return this.cmn((b & c) | ((~b) & d), a, b, x, s, t);
},
/**
@Description: Used Internally.
*/
gg : function(a, b, c, d, x, s, t){
return this.cmn((b & d) | (c & (~d)), a, b, x, s, t);
},
/**
@Description: Used Internally.
*/
hh : function(a, b, c, d, x, s, t){
return this.cmn(b ^ c ^ d, a, b, x, s, t);
},
/**
@Description: Used Internally.
*/
ii : function(a, b, c, d, x, s, t){
return this.cmn(c ^ (b | (~d)), a, b, x, s, t);
},
/**
@Description: Used Internally. Calculate the HMAC-MD5, of a key and some data
*/
core_hmac : function(key, data){
var bkey = this.str2binl(key);
if(bkey.length > 16) {
bkey = this.core(bkey, key.length * this.chrsz);
}
var ipad = new Array(16), opad = new Array(16);
for(var i = 0; i < 16; i++){
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
var hash = this.core(ipad.concat(this.str2binl(data)), 512 + data.length * this.chrsz);
return this.core(opad.concat(hash), 512 + 128);
},
/**
@Description: Used Internally. Add integers, wrapping at 2^32. This uses 16-bit operations internally * to work around bugs in some JS interpreters.
*/
safe_add : function (x, y){
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
},
/**
@Description: Used Internally. Bitwise rotate a 32-bit number to the left.
*/
bit_rol : function(num, cnt){
return (num << cnt) | (num >>> (32 - cnt));
},
/**
@Description: Used Internally. Convert a string to an array of little-endian words. If this.chrsz is ASCII, characters >255 have their hi-byte silently ignored.
*/
str2binl : function (str){
var bin = [];
var mask = (1 << this.chrsz) - 1;
for(var i = 0; i < str.length * this.chrsz; i += this.chrsz){
bin[i>>5] |= (str.charCodeAt(i / this.chrsz) & mask) << (i%32);
}
return bin;
},
/**
@Description: Used Internally. Convert an array of little-endian words to a string
*/
binl2str : function (bin){
var str = "";
var mask = (1 << this.chrsz) - 1;
for(var i = 0; i < bin.length * 32; i += this.chrsz){
str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
}
return str;
},
/**
@Description: Used Internally. Convert an array of little-endian words to a base-64 string
*/
binl2b64 : function(binarray){
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var str = "";
for(var i = 0; i < binarray.length * 4; i += 3){
var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16) |(((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 ) | ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
for(var j = 0; j < 4; j++){
if(i * 8 + j * 6 > binarray.length * 32) {
str += sb.md5.b64pad;
} else {
str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
}
}
return str;
}
}
};
/**
@Name: String.prototype.md5
@Description: This string prototype allow you to easily convert any string to md5
@Example:
'hello world'.md5(); //return the md5 of the string 'hello world'
*/
String.prototype.md5 = function(){
return sb.md5.hex(this);
};
//effect.js
/**
@Package: surebert.effects
@Description: If you are going to be using color effects make sure to include sb.colors.js by adding a script tag or using sb.include('colors'); or adding it to your surebert cache
@Version: v3.11
*/
/**
@Name: sb.effect
@Type: constructor
@Description: Used to create time based style effects
@Params: object params
.el = The element to work with
.begin = the beginning value
.change = the change from the beginning value. E.g. if the begin value is 10 and you want it to interate through to 20, change would be 10. If you wanted it to interate through to 0, change would be -10
.duration = the duration to use, 2 is the default, higher is slower, lower is faster.
.onChange = the function that run for each iteration. It has reference to all of the "this" properties of the effect in addition to this.value which is the current value based on begin and change
.onStop = a function which fires when the effect is complete
.onEnd = a function which fires when the effect is stopped
@Example:
//set the DOM el we want to work with
var myDiv = $('#accord');
//create an custom effect
var myEffect = new sb.effect({
el : myDiv,
begin : 10,
change : 12,
duration : 120,
onChange : function(c){
this.el.style.fontSize = this.value+'px';
},
onEnd : function(){
//do something
},
onStop : function(){
//do soemthing
}
});
myEffect.start();
*/
sb.effect = function(params){
this.setParams(params ||{});
sb.effects.register(this);
};
/**
@Name: sb.effect.prototype
@Type: prototype
@Description: prototype methods and properties for a sb.effect instance
*/
sb.effect.prototype = {
/**
@Name: sb.effect.time
@Type: integer
@Description: used internally
*/
time : 0,
/**
@Name: sb.effect.duration
@Type: integer
@Description: The duration of teh effect from begin to end. Default is 24. Lower numbers are faster, higher numbers are slower.
*/
duration : 24,
/**
@Name: sb.effect.count
@Type: integer
@Description: The number of times the effect has iterated so far between begin and end. You have reference to this in your effect onChange as this.count
*/
count : 0,
/**
@Name: sb.effect.tween
@Type: string
@Description: The type of tweening used, see sb.tween
*/
tween : 'inQuart',
/**
@Name: sb.effect.setParams()
@Type: method
@Description: applies properties from an additional params object with the same structure as the one used in the constructor
@Example:
myEffect.setParams();
*/
setParams : function(params){
sb.objects.infuse(params, this);
if(typeof params.el !='undefined'){
this.el = $(this.el);
}
},
/**
@Name: sb.effect.start()
@Type: method
@Description: starts the effect to run the effect
@Example:
myEffect.start();
*/
start : function(){
var t=this;
this.repeater = window.setInterval(
function(){
if(t.time < t.duration){
t.time++;
t.value = sb.effects.tween[t.tween](t.time,t.begin,t.change,t.duration);
t.valueRounded = Math.round(t.value);
t.onChange();
} else {
t.count++;
t.stop();
if(typeof t.onEnd =='function'){t.onEnd();}
}
}, 12);
},
/**
@Name: sb.effect.stop()
@Type: method
@Description: stops the effect from running. Also fires the effects onStop method if you have specified one
@Example:
myEffect.stop();
*/
stop : function(){
if(typeof this.onStop == 'function'){this.onStop();}
window.clearInterval(this.repeater);
},
/**
@Name: sb.effect.reset()
@Type: method
@Description: reset the effect to count and time to 0 and resets value and valueRounded to this.begin an. Also fires the effects onReset method if you have pecified one
@Example:
myEffect.reset();
*/
reset : function(){
if(typeof this.onReset == 'function'){this.onReset();}
this.count=0;
this.value = this.begin;
this.valueRounded = this.begin;
this.time=0;
this.stop();
},
/**
@Name: sb.effect.restart()
@Type: method
@Description: restarts the effect. run this.reset() and this.start()
@Example:
myEffect.restart();
*/
restart : function(){
if(typeof this.onRestart == 'function'){this.onRestart();}
this.reset();
this.start();
}
};
/**
@Name: sb.effects
@Type: object
@Description: A reference to all effects registered ont he page
*/
sb.effects = {
/**
@Name: sb.registered
@Type: array
@Description: Used Internally. A array reference to all effects registered on the page
*/
registered : [],
/**
@Name: sb.register()
@Type: method
@Description: Used internally. Registers an effect on the page
*/
register : function(effect){
this.registered.push(effect);
},
/**
@Name: sb.stopAll()
@Type: method
@Description: Stops all the effects on the page
*/
stopAll : function(){
sb.effects.registered.forEach(function(v){v.stop();});
},
/**
@Name: sb.startAll()
@Type: method
@Description: Starts all the effects on the page
*/
startAll : function(){
sb.effects.registered.forEach(function(v){v.start();});
}
};
/**
@Name: surebert.effects.tween
@Type: object
@Description: If you are going to be using color effects make sure to include sb.colors.js by adding a script tag or using sb.include('colors.getTweenColor'); or adding it to your surebert cache .Tweens Math adapted from http://www.synthesisters.com/hypermail/max-msp/Nov05/34305.html
*/
sb.effects.tween = {
/**
@Name: surebert.effects.tween.linear
@Type: method
@Description: A method for interpolating between two values over time
@Param float t time (elapsed since tween began)
@Param float b beginning (value)
@Param float b change (in value)
@Param float d duration
@Example:
var myValue = sb.effects.tween.linear(100, 0, 50, 5);
*/
linear : function(t,b,c,d) {
return c*t/d + b;
},
/**
@Name: surebert.effects.tween.outQuint
@Type: method
@Description: A method for interpolating between two values over time
@Param float t time (elapsed since tween began)
@Param float b beginning (value)
@Param float b change (in value)
@Param float d duration
@Example:
var myValue = sb.effects.tween.outQuint(100, 0, 50, 5);
*/
outQuint : function(t,b,c,d) {
return c*(Math.pow(t/d-1,5)+1)+b;
},
/**
@Name: surebert.effects.tween.inOutQuint
@Type: method
@Description: A method for interpolating between two values over time
@Param float t time (elapsed since tween began)
@Param float b beginning (value)
@Param float b change (in value)
@Param float d duration
@Example:
var myValue = sb.effects.tween.inOutQuint(100, 0, 50, 5);
*/
inOutQuint : function(t,b,c,d) {
if ((t/=d/2)<1){
return c/2*Math.pow(t,5)+b;
}
return c/2*(Math.pow(t-2,5)+2)+b;
},
/**
@Name: surebert.effects.tween.inQuad
@Type: method
@Description: A method for interpolating between two values over time
@Param float t time (elapsed since tween began)
@Param float b beginning (value)
@Param float b change (in value)
@Param float d duration
@Example:
var myValue = sb.effects.tween.inQuad(100, 0, 50, 5);
*/
inQuad : function(t,b,c,d) {
return c*(t/=d)*t + b;
},
/**
@Name: surebert.effects.tween.outQuad
@Type: method
@Description: A method for interpolating between two values over time
@Param float t time (elapsed since tween began)
@Param float b beginning (value)
@Param float b change (in value)
@Param float d duration
@Example:
var myValue = sb.effects.tween.outQuad(100, 0, 50, 5);
*/
outQuad : function(t,b,c,d) {
return -c*(t/=d)*(t-2) + b;
},
/**
@Name: surebert.effects.tween.inOutQuad
@Type: method
@Description: A method for interpolating between two values over time
@Param float t time (elapsed since tween began)
@Param float b beginning (value)
@Param float b change (in value)
@Param float d duration
@Example:
var myValue = sb.effects.tween.inOutQuad(100, 0, 50, 5);
*/
inOutQuad : function(t,b,c,d) {
if ((t/=d/2) < 1) {
return c/2*t*t + b;
}
return -c/2 * ((--t)*(t-2)-1)+b;
},
/**
@Name: surebert.effects.tween.inCubic
@Type: method
@Description: A method for interpolating between two values over time
@Param float t time (elapsed since tween began)
@Param float b beginning (value)
@Param float b change (in value)
@Param float d duration
@Example:
var myValue = sb.effects.tween.inCubic(100, 0, 50, 5);
*/
inCubic : function(t,b,c,d) {
return c*Math.pow(t/d,3)+b;
},
/**
@Name: surebert.effects.tween.outCubic
@Type: method
@Description: A method for interpolating between two values over time
@Param float t time (elapsed since tween began)
@Param float b beginning (value)
@Param float b change (in value)
@Param float d duration
@Example:
var myValue = sb.effects.tween.outCubic(100, 0, 50, 5);
*/
outCubic : function(t,b,c,d) {
return c*(Math.pow(t/d-1,3)+1)+b;
},
/**
@Name: surebert.effects.tween.inOutCubic
@Type: method
@Description: A method for interpolating between two values over time
@Param float t time (elapsed since tween began)
@Param float b beginning (value)
@Param float b change (in value)
@Param float d duration
@Example:
var myValue = sb.effects.tween.inOutCubic(100, 0, 50, 5);
*/
inOutCubic : function(t,b,c,d) {
if ((t/=d/2)<1){
return c/2*Math.pow(t,3)+b;
}
return c/2*(Math.pow(t-2,3)+2)+b;
},
/**
@Name: surebert.effects.tween.inQuart
@Type: method
@Description: A method for interpolating between two values over time
@Param float t time (elapsed since tween began)
@Param float b beginning (value)
@Param float b change (in value)
@Param float d duration
@Example:
var myValue = sb.effects.tween.inQuart(100, 0, 50, 5);
*/
inQuart : function(t,b,c,d) {
return c* Math.pow(t/d,4) + b;
},
/**
@Name: surebert.effects.tween.outQuart
@Type: method
@Description: A method for interpolating between two values over time
@Param float t time (elapsed since tween began)
@Param float b beginning (value)
@Param float b change (in value)
@Param float d duration
@Example:
var myValue = sb.effects.tween.outQuart(100, 0, 50, 5);
*/
outQuart : function(t,b,c,d) {
return -c*(Math.pow(t/d-1,4)-1)+b;
},
/**
@Name: surebert.effects.tween.inOutQuart
@Type: method
@Description: A method for interpolating between two values over time
@Param float t time (elapsed since tween began)
@Param float b beginning (value)
@Param float b change (in value)
@Param float d duration
@Example:
var myValue = sb.effects.tween.inOutQuart(100, 0, 50, 5);
*/
inOutQuart : function(t,b,c,d) {
if ((t/=d/2)<1){
return c/2*Math.pow(t,4)+b;
}
return -c/2*(Math.pow(t-2,4)-2)+b;
},
/**
@Name: surebert.effects.tween.inSine
@Type: method
@Description: A method for interpolating between two values over time
@Param float t time (elapsed since tween began)
@Param float b beginning (value)
@Param float b change (in value)
@Param float d duration
@Example:
var myValue = sb.effects.tween.inSine(100, 0, 50, 5);
*/
inSine : function(t,b,c,d) {
return c* (1 - Math.cos(t/d*(Math.PI/2))) + b;
},
/**
@Name: surebert.effects.tween.outSine
@Type: method
@Description: A method for interpolating between two values over time
@Param float t time (elapsed since tween began)
@Param float b beginning (value)
@Param float b change (in value)
@Param float d duration
@Example:
var myValue = sb.effects.tween.outSine(100, 0, 50, 5);
*/
outSine : function(t,b,c,d) {
return c* Math.sin(t/d*(Math.PI/2)) + b;
},
/**
@Name: surebert.effects.tween.inOutSine
@Type: method
@Description: A method for interpolating between two values over time
@Param float t time (elapsed since tween began)
@Param float b beginning (value)
@Param float b change (in value)
@Param float d duration
@Example:
var myValue = sb.effects.tween.inOutSine(100, 0, 50, 5);
*/
inOutSine : function(t,b,c,d) {
return c/2* (1-Math.cos(Math.PI*t/d)) +b;
},
/**
@Name: surebert.effects.tween.inExpo
@Type: method
@Description: A method for interpolating between two values over time
@Param float t time (elapsed since tween began)
@Param float b beginning (value)
@Param float b change (in value)
@Param float d duration
@Example:
var myValue = sb.effects.tween.inExpo(100, 0, 50, 5);
*/
inExpo : function(t,b,c,d) {
return c* Math.pow(2,10*(t/d - 1)) +b;
},
/**
@Name: surebert.effects.tween.outExpo
@Type: method
@Description: A method for interpolating between two values over time
@Param float t time (elapsed since tween began)
@Param float b beginning (value)
@Param float b change (in value)
@Param float d duration
@Example:
var myValue = sb.effects.tween.outExpo(100, 0, 50, 5);
*/
outExpo : function(t,b,c,d) {
return c* (-Math.pow(2,-10*t/d) + 1) + b;
},
/**
@Name: surebert.effects.tween.inOutExpo
@Type: method
@Description: A method for interpolating between two values over time
@Param float t time (elapsed since tween began)
@Param float b beginning (value)
@Param float b change (in value)
@Param float d duration
@Example:
var myValue = sb.effects.tween.inOutExpo(100, 0, 50, 5);
*/
inOutExpo : function(t,b,c,d) {
if ((t/=d/2) < 1){
return c/2 * Math.pow(2, 10*(t-1))+b;
}
return c/2 * (-Math.pow(2, -10 * --t) + 2) +b;
},
/**
@Name: surebert.effects.tween.inCirc
@Type: method
@Description: A method for interpolating between two values over time
@Param float t time (elapsed since tween began)
@Param float b beginning (value)
@Param float b change (in value)
@Param float d duration
@Example:
var myValue = sb.effects.tween.inCirc(100, 0, 50, 5);
*/
inCirc : function(t,b,c,d) {
return c* (1-Math.sqrt(1- (t/=d)*t)) + b;
},
/**
@Name: surebert.effects.tween.outCirc
@Type: method
@Description: A method for interpolating between two values over time
@Param float t time (elapsed since tween began)
@Param float b beginning (value)
@Param float b change (in value)
@Param float d duration
@Example:
var myValue = sb.effects.tween.outCirc(100, 0, 50, 5);
*/
outCirc : function(t,b,c,d) {
return c* Math.sqrt(1-(t=t/d-1)*t) + b;
},
/**
@Name: surebert.effects.tween.inOutCirc
@Type: method
@Description: A method for interpolating between two values over time
@Param float t time (elapsed since tween began)
@Param float b beginning (value)
@Param float b change (in value)
@Param float d duration
@Example:
var myValue = sb.effects.tween.inOutCirc(100, 0, 50, 5);
*/
inOutCirc : function(t,b,c,d) {
if ((t/=d/2) < 1){
return c/2 * (1-Math.sqrt(1-t*t))+b;
}
return c/2 * (Math.sqrt(1- (t-=2)*t)+1) +b;
},
/**
@Name: surebert.effects.infuse
@Type: method
@Example:
var myValue = sb.effects.tween.infuse({
inOutCirc : function(t,b,c,d) {
if ((t/=d/2) < 1){
return c/2 * (1-Math.sqrt(1-t*t))+b;
}
return c/2 * (Math.sqrt(1- (t-=2)*t)+1) +b;
}
});
*/
infuse : sb.objects.infuse
};
//browser/getScrollPosition.js
/**
@Name: sb.browser.getScrollPosition
@Description: Gets the window scroll data It is automatically populated on window.onscroll.
@Return Array Returns the an array of x and y scroll pos.
@Example:
var pos = sb.browser.getScrollPosition();
//pos = [400, 300]
*/
sb.browser.getScrollPosition = function(){
var x=0,y=0;
if(window.pageYOffset){
y = window.pageYOffset;
} else if (document.documentElement && document.documentElement.scrollTop){
y= document.documentElement.scrollTop;
}
sb.browser.scrollY = y;
if(window.pageXSOffset){
x = window.pageXOffset;
} else if (document.documentElement && document.documentElement.scrollLeft){
x = document.documentElement.scrollLeft;
}
sb.browser.scrollX = x;
return [sb.browser.scrollX, sb.browser.scrollY];
};
sb.events.add(window, 'scroll', sb.browser.getScrollPosition);
//sound.js
sb.include('flashGate');
/**
@Name: sb.sound
@Author: Paul Visco
@Description: A constructor for creating new sound object instances. Allows javascript to load, play and stop mp3 sounds.
@Param String url The url of the file to play
@Example:
var yellow = new sb.sound(
url : 'yellow.mp3',
debug : true,
onID3 : function(){},
onProgress : function(){}
);
yellow.play();
*/
sb.sound = function(params){
if(!params.url){
throw('You must pass a url to the sb.sound');
}
for(var prop in params){
this[prop] = params[prop];
}
this.id = sb.flashGate.getInterface().sound_create(this.url, this.debug);
sb.sound.sounds[this.id] = this;
};
/**
@Name: sb.sound.sounds
@Description: Used Internally
*/
sb.sound.sounds = [];
/**
@Name: sb.sound.stopAll
@Description: Stops all sounds playing on the page
@Param String url Optional The url of the file to stop
@Example:
sb.sound.stopAll();
//or
sb.sound.stopAll('yellow.mp3');
*/
sb.sound.stopAll = function(url){
url = url || '';
sb.flashGate.getInterface().sounds_stop_all(url);
};
/**
@Name: sb.sound.stopAll
@Description: Sets the global volume of all sounds
@Param Float A float between 0 and 1
@Example:
sb.sound.setGlobalVolume(0.5);
*/
sb.sound.setGlobalVolume = function(volume){
sb.flashGate.getInterface().sounds_set_global_volume(volume);
};
/**
@Name: sb.sound.muteAll
@Description: Mutes all sounds playing on the page
@Param String url Optional The url of the file to mute
@Example:
sb.sound.muteAll();
//or
sb.sound.muteAll('yellow.mp3');
*/
sb.sound.muteAll = function(){
sb.flashGate.getInterface().sounds_mute_all();
};
/**
@Name: sb.sound.muted
@Description: When set to 1, sounds will not play
@Example:
sb.sound.mute = 1;
*/
sb.sound.muted = 0;
/**
@Name: sb.sound.prototype
@Description: The methods of sb.sound instances
*/
sb.sound.prototype = {
duration : -1,
/**
@Name: sb.sound.prototype.url
@Description: String The url of the mp3 file
*/
url : '',
/**
@Name: sb.sound.prototype.id
@Description: Used Internally
*/
id : 0,
/**
@Name: sb.sound.prototype.play
@Param Number position The position to start the file at in milliseconds
@Param Number loops The number of times to repeat the sound
@Description: Plays the sound file
@Example:
mySound.play();
*/
play : function(position, loops){
if(!sb.sound.muted){
position = position || 0;
loops = loops || 0;
return sb.flashGate.getInterface().sound_play(this.id, position, loops);
}
},
/**
@Name: sb.sound.prototype.stop
@Description: Stops the sound file
@Example:
mySound.play();
*/
stop : function(){
return sb.flashGate.getInterface().sound_stop(this.id);
},
/**
@Name: sb.sound.prototype.getPosition
@Description: Gets the current position in milliseconds
@Return: Number return the current position in milliseconds
@Example:
mySound.getPosition();
*/
getPosition : function(){
return sb.flashGate.getInterface().sound_get_position(this.id);
},
/**
@Name: sb.sound.prototype.setPositionPercent
@Description: Moves the playhead to a certain position in percent of total
@Example:
mySound.setPositionPercent(40);
*/
setPositionPercent : function(percent){
return sb.flashGate.getInterface().sound_set_position_percent(this.id, percent);
},
/**
@Name: sb.sound.prototype.getPositionPercent
@Description: Gets the current position in percent of total
@Return: Number return the current position in percent of total
@Example:
mySound.getPositionPercent();
*/
getPositionPercent : function(){
return sb.flashGate.getInterface().sound_get_position_percent(this.id);
},
/**
@Name: sb.sound.prototype.setPosition
@Description: Moves the playhead to a certain position in milliseconds
@Example:
mySound.setPosition(4135);
*/
setPosition : function(position){
return sb.flashGate.getInterface().sound_set_position(this.id, position);
},
/**
@Name: sb.sound.prototype.getVolume
@Description: Gets the current volume
@Return: float between 0 and 1
@Example:
mySound.getVolume();
*/
getVolume : function(volume){
return sb.flashGate.getInterface().sound_get_volume(this.id);
},
/**
@Name: sb.sound.prototype.getVolume
@Description: Gets the current volume
@Param: Float volume between 0 and 1
@Example:
mySound.setVolume(0.5);
*/
setVolume : function(volume){
sb.flashGate.getInterface().sound_set_volume(this.id, volume);
},
/**
@Name: sb.sound.prototype.getPan
@Description: Gets the current pan position
@Return: float between -1 (left) and 1 (right)
@Example:
mySound.getPan();
*/
getPan : function(){
return sb.flashGate.getInterface().sound_get_pan(this.id);
},
/**
@Name: sb.sound.prototype.setPan
@Description: sets the current pan position
@Param: float pan between -1 (left) and 1 (right)
@Example:
mySound.setPan(0.5);
*/
setPan : function(pan){
sb.flashGate.getInterface().sound_set_pan(this.id, pan);
},
/**
@Name: sb.sound.prototype.mute
@Description: sets the volume to zero for this sound but keeps playing
@Example:
mySound.mute();
*/
mute : function(){
this.setVolume(0);
},
//tags.album, tags.year, tags.artist, tags.songName, tags.comment, tags.track, tags.genre
onID3 : function(){},
//song.sizeK, song.bytesLoaded, song.bytesTotal
onLoad : function(){},
//message
onError : function(){},
//song.position, song.length, song.percent
onProgress : function(data){}
};
//uploadButton.js
if(typeof sb.swf =='undefined'){
sb.include('swf');
}
/*
@Name: sb.uploadButton
@Description: Instantiates a new upload
@Example:
var uploader = new sb.uploadButton({
debug : true,
maxFiles : 5,
maxFileSizeK : 5000000,
url : 'http://frameworkdev.sv/uploads/test',
data : {
friend : 'tim',
nano : "Hello there timmy's dog"
},
onReturnData : function(file){
sb.objects.alert(file);
},
onBeforeBrowse : function(){
return true;
},
onSelect : function(filenames){
return true;
},
onExceedsMaxFiles : function(){},
onExceedsMaxFileSizeK : function(file){},
onError : function(data){
alert(data.message);
},
styles : {
backgroundColor : '0x00FF00',
backgroundColorRoll : '0xFFFF00',
borderColor : '0xFF0000',
color : '0xFF0000',
cornerRadius : '15',
borderThickness : '0',
fontSize : 16,
width : 62,
height : 24,
fontSize : 16,
font : 'Tahoma'
}
});
uploader.embed('#chicken');
*/
sb.uploadButton = function(parameters){
this.id = sb.uploadButton.uploads.length;
for(var prop in parameters){
this[prop] = parameters[prop];
}
sb.uploadButton.uploads.push(this);
//create swf and associate call to thei sb.uploadButton for event handling
this.swf = new sb.swf({
src : sb.base+"/UploadButton.swf?id="+this.id,
width : this.styles.width || 62,
height : this.styles.height || 24,
id : 'upload'+this.id,
bgcolor : '#000000',
wmode: 'transparent',
flashvars : {
debug : (this.debug != null) ? this.debug : true,
innerHTML : this.innerHTML || 'upload',
debugLevel : this.debugLevel || 1
},
version : 9,
alt : parameters.alt || '
'
});
this.load_params = function(){
this.swf.getInterface().create_upload(this.id);
};
};
/**
@Name: sb.uploadButton.uploads
@Description: Used Internally
*/
sb.uploadButton.uploads = [];
sb.uploadButton.prototype = {
styles : {},
/**
* Returns the HTML of the swf for testing
*/
toHTML : function(){
return this.swf.toHTML();
},
/**
* Embeds the button into another element
*/
embed : function(el){
this.swf.embed(el);
},
/**
@Name: sb.uploadButton.prototype.setStyles
@Description: Sets the MXML CSS styles for the button
@Param: styles Object Hash of css properties
@Example:
this.setStyles(
letterSpacing : '20'
);
*/
setStyles : function(styles){
this.swf.getInterface().set_button_styles(styles);
},
/**
@Name: sb.uploadButton.prototype.cancels
@Description: Cancels all file uploads for this instance
@Name: string name optionally cancels only for files that match the file name given
*/
cancel : function(name){
name = name || '';
this.swf.getInterface().upload_cancel(name);
},
/**
@Name: sb.uploadButton.prototype.id
@Description: Used Internally
*/
id: 0,
/**
@Name: sb.uploadButton.prototype.maxFiles
@Description: The maximum number of files the user can select in the browser before it throws an error and fires onMaxFilesExceeded
*/
maxFiles : 5,
/**
@Name: sb.uploadButton.prototype.maxFileSizeK
@Description: The maximum file size per file that the user can upload before it throws an error and fires onMaxFileSizeExceeded
*/
maxFileSizeK : 1024,
/**
@Name: sb.uploadButton.prototype.acceptedFileTypes
@Description: The file types to accept for upload
*/
acceptedFileTypes : '*.*',
/**
@Name: sb.uploadButton.prototype.method
@Description: The default method to send data
*/
method : 'post',
/**
@Name: sb.uploadButton.prototype.url
@Description: The URL to upload the data to
*/
url : '',
/**
@Name: sb.uploadButton.prototype.data
@Description: Additional data objectw hich is url encoded into post data and sent with the files
*/
data : {},
/**
@Name: sb.uploadButton.prototype.debug
@Description: Determines if file upload debug info is traced to the flash debug player
*/
debug : true,
/**
* The verbosity level of the debug data sent to flash debug log - 1 - reports actions, 2 - reports data loaded and sent to js
*/
debugLevel : 1,
/**
@Name: sb.uploadButton.prototype.onBeforeBrowse
@Description: Fires when the user presses the browse button, but before the file browser opens
@Return: boolean true opens file browser, false cancels file browser opening. It does not fire oncancel, you can call it directly before issuing false return if you would like
*/
onBeforeBrowse : function(data){return true;},
/**
@Name: sb.uploadButton.prototype.onSelect
@Description: Fires when the user selects files from the browse box that pops up from pressing the button
@Param: array names the file names selected
@Return: boolean true uploads, false cancels upload before it starts. It does not fire oncancel, you can call it directly before issuing false return if you would like
*/
onSelect : function(data){return true;},
/**
@Name: sb.uploadButton.prototype.onExceedsMaxFileSizeK
@Description: Fires when a file exceeds the maximum file size specified and is therefore not uplaoded
@Param: object file file.name, file.size, file.sizeK, file.exceededBy, file.limit, file.message
*/
onExceedsMaxFileSizeK : function(file){},
/**
@Name: sb.uploadButton.prototype.onExceedsMaxFiles
@Description: Fires when a user selects too many files
@Param: object files.chosen, files.limit, files.message
*/
onExceedsMaxFiles : function(files){},
/**
@Name: sb.uploadButton.prototype.onError
@Description: Fires if the upload is canceled due to an error
@Param: object file.name, file.size, file.sizeK, file.type, file.error
*/
onError : function(file){},
/**
@Name: sb.uploadButton.prototype.onOpen
@Description: Fires when the file is opened for upload on the client's computer
@Param: object file.name, file.size, file.sizeK, file.type
*/
onOpen : function(file){},
/**
@Name: sb.uploadButton.prototype.onReturnData
@Description: Fires when the data is returned from the server, , must beturn something from the serer for this to fire, can be a simple space
@Param: object file.name, file.size, file.sizeK, file.type, file.data
*/
onReturnData : function(file){},
/**
@Name: sb.uploadButton.prototype.onAllComplete
@Description: Fires when all uploads for this upload instance are complete
@Param: object files.total
*/
onAllComplete : function(files){},
/**
@Name: sb.uploadButton.prototype.onComplete
@Description: Fires when a file is done uploading, must beturn something from the serer for this to fire, can be a simple space
@Param: object file.name, file.size, file.sizeK, file.type
*/
onComplete : function(files){},
/**
@Name: sb.uploadButton.prototype.onAllProgress
@Description: Fires each time one more file is uploaded until the que is empty
@Param: object files.total, files.remaining
*/
onAllProgress : function(files){},
/**
@Name: sb.uploadButton.prototype.onProgress
@Description: Fires periodically as a file uploads alerting you of the progress in percent, deosn't seem to fire for really quick uploads on local server, must return something from the serer for this to fire, can be a simple space
@Param: object file.name, file.size, file.sizeK, file.type, file.bytesLoaded, file.bytesTotal, file.percent
*/
onProgress : function(files){},
//files.remaining
/**
@Name: sb.uploadButton.prototype.onCancelBrowse
@Description: Fires when the user hits cancel in the file browser
*/
onCancelBrowse : function(){},
/**
@Name: sb.uploadButton.prototype.onCancelAll
@Description: Fires once when the upload que is canceled using upload.cancel();
*/
onCancelAll : function(){},
/**
@Name: sb.uploadButton.prototype.onCancelFile
@Description: Fires when one file in the que is canceled by filename with upload.cancel(file.name); or once per file when upload.cancel()l is fired without a name specified
@Param: object file.name
*/
onCancelFile : function(){}
};
//sharedObject.js
sb.include('flashGate');
/**
@Name: sb.sharedObject
@Author: Paul Visco
@Description: gives javascript access to the flash storage
*/
sb.sharedObject = {
/**
@Name: sb.sharedObject.load
@Description: loads data from the sharedObject
@Param: string key The name of the stored data
@Example:
sb.sharedObject.load('friend');
*/
load : function(key){
return sb.flashGate.getInterface().storage_engine_get(key);
},
/**
@Name: sb.sharedObject.save
@Description: saves data in the sharedObject
@Param: string key The name of the stored data
@Param: string val The value to store
@Example:
sb.sharedObject.save('friend', 'paul');
*/
save : function(key, val){
sb.flashGate.getInterface().storage_engine_set(key, val);
},
/**
@Name: sb.sharedObject.clear
@Description: clears data for a specific key in the sharedObject
@Param: string key The name of the stored data
@Example:
sb.sharedObject.clear('friend');
*/
clear : function(key){
this.save(key, '');
},
/**
@Name: sb.sharedObject.clearAll
@Description: clears all data stored in the sharedObject
@Example:
sb.sharedObject.clearAll();
*/
clearAll : function(){
sb.flashGate.getInterface().storage_engine_clear_all();
}
};
//browser/$_GET.js
/**
@Name: sb.browser.$_GET
@Description: An array of all query params e.g. url?name=paul -> $_GET['name'] = 'paul'. There is a global reference to this name $_GET. Keys that are not foudn return false;
@Example:
//if the url of the page was http://www.surebert.com?name=paul you could reference that query data like this
if($_GET['name'] =='paul){
alert('hello paul');
}
*/
sb.browser.$_GET = [];
$_GET = sb.browser.$_GET;
/**
@Name: sb.browser.populateGET
@Description: Used Internally
*/
sb.browser.populateGET = function (){
var i,s,val,key;
var q = window.location.search.substring(1);
var v = q.split("&");
for (i=0;i::link:: is a great javascript toolkit';
*/
String.prototype.linkify = function(target){
target = target || '_blank';
var match_url = new RegExp("(\s|\n|)([a-z]+?):\/\/([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+)", "i");
return this.replace(match_url, "::link::");
};
//String/prototype/basename.js
/**
@Name: String.prototype.basename
@Author: Paul Visco
@Version: 1.0 11/19/07
@Description: Grabs the basename from a url
@Return: String The filename part of the original string
@Example:
var myString = 'http://www.google.com/logo.gif';
var newString = myString.basename();
//newString = 'logo.gif';
*/
String.prototype.basename = function(){
var re = new RegExp("/\\/", "g");
var str = this.replace(re, "/");
var filename=str.split("/");
return filename[(filename.length - 1)];
};
//String/prototype/toElement.js
/**
@Name: String.prototype.toElement
@Description: Converts a string of HTML code to a sb.element for dom manipulation
@Param: String parentNodeType The nodetype of the parent element returned if there is not already a single parent element for all elements contained in the html string - see example two - defaults to span if it is not given
@Example:
//would return div as the element with all its children
sb.dom.HTMLToElement('
hey there
');
//would return all elements grouped under a span because they have no comment parent
sb.dom.HTMLToElement('
hey there
hey there2
');
*/
String.prototype.toElement = function(parentNodeType){
parentNodeType = parentNodeType || 'span';
var temp = new sb.element({
nodeName : parentNodeType,
innerHTML : this
});
if(temp.childNodes.length > 1){
return $(temp);
} else {
return $(temp.firstChild);
}
};
//Array/prototype/iteration.js
/**
@Name: Array.prototype.iteration
@Description: Can be used to iterate arrays with next, rewind, forward,
*/
Array.prototype.iteration = function(){
if(this.pointer == -1){
this.point = 0;
}
};
/**
@Name: Array.prototype.pointer
@Description: Used to keep track of the array key we are referenceing with next, prev, end, current, rewind
*/
Array.prototype.pointer = -1;
/**
@Name: Array.prototype.current
@Description: Returns the array value of the key we are currently on as referenced by the pointer. Starts at 0 and chanegs base don use of next(), prev(), rewind(), end()
@Example:
var myArray = [1,10,2,3,4,5];
myArray.current(); //returns 1 at first
//after manipulations it changes reference based on the pointer
myArray.next();
//now it is the next one
myArray.current(); //returns 10
*/
Array.prototype.current = function(){
this.iteration();
return this[this.pointer];
};
/**
@Name: Array.prototype.end
@Description: Returns the array value of the last key and sets the array's pointer to that key
@Example:
var myArray = [1,10,2,3,4,5];
myArray.end(); //sets the pointer to the last array key and returns the value, in this case 5
*/
Array.prototype.end = function(){
this.iteration();
this.pointer = this.length-1;
return this[this.pointer];
};
/**
@Name: Array.prototype.first
@Description: Returns the first value in the array without moving the pointer.
@Example:
var myArray = [1,10,2,3,4,5];
myArray.first(); //returns 1
*/
Array.prototype.first = function(){
this.iteration();
return this[0];
};
/**
@Name: Array.prototype.last
@Description: Returns the last value of the array without moving the pointer.
@Example:
var myArray = [1,10,2,3,4,5];
myArray.last(); //returns 5
*/
Array.prototype.last = function(){
this.iteration();
return this[this.length-1];
};
/**
@Name: Array.prototype.next
@Description: Returns the next value of the array and moves the pointer forward to it.
@Example:
var myArray = [1,10,2,3,4,5];
myArray.current(); //returns 1
myArray.next(); //returns 10
myArray.current(); //returns 10
*/
Array.prototype.next = function(){
this.iteration();
this.pointer +=1;
return this[this.pointer];
};
/**
@Name: Array.prototype.rewind
@Description: Returns the first value of the array and moves the pointer back to the beginning.
@Example:
var myArray = [1,10,2,3,4,5];
myArray.rewind(); //returns 1
*/
Array.prototype.rewind = function(){
this.iteration();
this.pointer=0;
return this[this.pointer];
};
/**
@Name: Array.prototype.prev
@Description: Returns the next value of the array and moves the pointer forward to it.
@Example:
var myArray = [1,10,2,3,4,5];
myArray.end(); //returns 5
myArray.prev(); //returns 4
myArray.current(); //returns 4
*/
Array.prototype.prev = function(){
this.iteration();
this.pointer -=1;
return this[this.pointer];
};
/**
@Name: Array.prototype.cycle
@Author: Paul Visco
@Version: 1.1 11/19/07
@Description: Cycles through an array by incrememtning its pointer and reseting it back to the beginng (0) when it gets to the end.
@Param: Number direction Accepts either 1 for ascending order or -1 for decending order. If not specified that ascending order is the default.
@Return: Array Returns The array sorted naturally.
@Example:
var myArray = [1,10,2,3,4,5];
var answer = myArray.cycle();
alert(myArray.cycle());
*/
Array.prototype.cycle = function(){
this.iteration();
if(!this.sb_beginCycle){
this.sb_beginCycle =1;
var val = this.first();
} else {
var val = this.next();
}
if(typeof val == 'undefined'){
return this.rewind();
} else {
return val;
}
};
//Element/prototype/cssTransition.js
sb.include('effect');
/**
@Name: Element.prototype.cssTransition()
@Type: constructor
@Description: Easily handles a multitude of css transitions for S$ elements and sb.elements. This is what most people will probably use for all effects they create.
@Example:
sb.include('colors.getTweenColor');
var body = $('body');
var transitions = body.cssTransition([
{
prop : 'backgroundColor',
begin : 'FF0000',
end : '00FF00',
onEnd : function(){
//alert('done');
}
},
{
prop : 'fontSize',
begin : 10,
change : 40,
duration : 48 //this is optional it defualts to the global duration (constructor's second argument or 24 if not neither is defined)
}
], 120);
transitions.start();
*/
Element.prototype.cssTransition = function(changes, duration){
var transition = new sb.effect.cssTransition(this, changes, duration);
return transition;
};
/**
@Name: Element.prototype.cssTransition()
@Description: Used Internally
*/
sb.effect.cssTransition = function(el, changes, duration){
this.el = el;
this.effects = [];
var self = this;
changes.forEach(function(change){
var effect = new sb.effect({
el : el
});
effect.prop = change.prop;
effect.unit = change.unit ||'';
effect.duration = change.duration || duration || 24;
effect.tween = change.tween || 'outQuad';
if(change.prop =='backgroundColor' || change.prop =='color'){
sb.include('colors.getTweenColor');
effect.beginColor = change.begin;
effect.endColor = change.end;
effect.begin = 0;
effect.change = 100;
effect.end = change.end;
} else {
effect.begin = change.begin;
effect.change = change.change;
}
effect.onEnd = change.onEnd || 0;
if(typeof change.onChange =='function'){
effect.onChange = function(){
change.onChange.call(effect);
};
} else {
effect.onChange = function(){
//fix stupid IE height 0px prob
if (this.prop =='height' && sb.browser.ie6 && this.value<1){
this.value=1;
}
if(this.prop =='backgroundColor' || this.prop =='color'){
this.el.style[change.prop] = sb.colors.getTweenColor(this.beginColor, this.endColor, this.value);
} else {
try{
this.el.setStyle(change.prop, String(this.value.toFixed(2))+this.unit);
} catch(e){}
}
};
}
self.effects.push(effect);
});
};
sb.effect.cssTransition.prototype = {
/**
@Name: Element.prototype.cssTransition.effects()
@Type: array
@Description: an array of all effects in the cssTransition
*/
effects : [],
/**
@Name: Element.prototype.cssTransition.start()
@Type: method
@Description: starts the transition
@Example:
myTransition.start();
*/
start : function(){
this.effects.forEach(function(effect){
effect.start();
});
},
/**
@Name: Element.prototype.cssTransition.stop()
@Type: method
@Description: stops the transition
@Example:
myTransition.stop();
*/
stop : function(){
this.effects.forEach(function(effect){
effect.stop();
});
},
/**
@Name: Element.prototype.cssTransition.reset()
@Type: method
@Description: reset the transition
@Example:
myTransition.reset();
*/
reset : function(){
this.effects.forEach(function(effect){
effect.reset();
});
},
/**
@Name: Element.prototype.cssTransition.restart()
@Type: method
@Description: reset the transition
@Example:
myTransition.restart();
*/
restart : function(){
this.effects.forEach(function(effect){
effect.restart();
});
}
};
//Element/prototype/markText.js
/**
@Name: Element.prototype.markText
@Author: Paul Visco
@Version: 2.0 11/17/07
@Description: The method allows you to mark text string within a DOM element. Great for use with search utility. It automically puts the foudn text in a tag and adds either the className you specify or sb_hiliteText by default
@Param Object o
o.find String The string to match and mark
o.className String The className to use for marking
o.matchExact Boolean 1=matches exactly, 0=matches like etc will mark chicken within chickens, if chicken is the find word
o.caseSensitive Will only match case sensitive
*/
Element.prototype.markText = function(o){
var allTags = $(this.id +' *');
var textNodes =[];
var className = o.className || 'sb_markText';
var find = o.find || '';
var matchExact = o.matchExact || 0;
var caseSensitive = (o.caseSensitive) ? "" : "i";
allTags.forEach(function(node){
for(x=0;x'+"$1"+'');
}
});
sp.replace(node);
sp=null;
});
};
//Element/prototype/isDescendantOf.js
/**
@Name: Element.prototype.isDescendantOf
@Description: Checks to see if the element is a child of whatever element it is passed. DOES NOT RETURN ITSELF LIKE OTHER Element.prototypes
@Param: Object/String of You can specify the parent element as an id string e.g. #parent or as an element object reference
@Return: Boolean True is the element is a child of the parent specified and false if it is not
@Example:
myElement.isDescendantOf('#parent');
*/
Element.prototype.isDescendantOf = function(el){
return $(el).$('*').nodes.inArray(this);
};
//Element/prototype/getNextSibling.js
/**
@Name: Element.prototype.getNextSibling
@Description: Finds the next sibling element of the element on which this is called
@Return: Element A DOM element reference to the next sibling
@Example:
myElement.getNextSibling();
*/
Element.prototype.getNextSibling = function(){
var node = this;
while((node = node.nextSibling) && node.nodeType != 1){}
return $(node);
};
//Element/prototype/getDimensions.js
/**
@Name: Element.prototype.getDimensions
@Description: calculates and assigns width and height properties to an to an element
@Example:
myElement.getDimensions();
alert(myElement.width);
*/
Element.prototype.getDimensions = function() {
var display = this.getStyle('display');
// Safari bug
if (display != 'none' && display !== null) {
this.width = this.offsetWidth;
this.height = this.offsetHeight;
} else {
// All *Width and *Height properties give 0 on els with display none,so enable the el temporarily
var origStyles = {
visibility : this.style.visibility,
position : this.style.position,
display : this.style.display
};
this.styles({
visibility : 'hidden',
position : 'absolute',
display : 'block'
});
this.width = this.clientWidth;
this.height = this.clientHeight;
this.styles(origStyles);
}
return this;
};
//Element/prototype/getPosition.js
sb.include('Element.prototype.getDimensions');
sb.include('browser.getScrollPosition');
/**
@Name: Element.prototype.getPosition
@Description: Used to calculate the bounds top, right, bottom, left, h, and w of a DOM node. h and w are height and width. Attaches those properties to the element itself
@Return: Object An object with top, right, bottom, left, h, and w properties
@Return: returns itself
@Example:
var pos = myElement.getPosition();
alert(pos.left);
myElement.getPosition({pos : 'rel'});
myElement.getPosition({accountForScroll : 1});
*/
Element.prototype.getPosition = function(params){
params = params || {};
var orig = this;
var el=this;
orig.top =0;
orig.left =0;
do{
orig.top += el.offsetTop;
orig.left += el.offsetLeft;
if(params.pos =='rel'){
el = false;
} else{
try{el = el.offsetParent;}catch(e){el = false;}
}
} while(el);
if(params.accountForScrollBar){
sb.browser.getScrollPosition();
if(sb.browser.scrollY){
orig.top -=sb.browser.scrollY;
}
if(sb.browser.scrollX){
orig.left -=sb.browser.scrollX;
}
}
orig.getDimensions();
//alias for w and h
orig.w = orig.width;
orig.h = orig.height;
orig.bottom = orig.top+orig.width;
orig.right = orig.left+orig.height;
return orig;
};
//Element/prototype/resizeTo.js
sb.include('effect');
sb.include('Element.prototype.cssTransition');
sb.include('String.prototype.toNumber');
/**
@Name: Element.prototype.resizeTo
@Author: Paul Visco
@Version: 1.0 11/19/07
@Description: This effect resizes an element dynamically
@Param: integer width The width to resize to
@Param: integer height The height to resize to
@Param: integer duration The time milliseconds to fade over
Example: div.resizeTo({height:700, width:700});
*/
Element.prototype.resizeTo = function(o){
var border = this.getStyle('border').toNumber();
var padding = this.getStyle('padding').toNumber();
this.style.overflow='hidden';
var transitions = [];
if(o.width !== undefined){
var width = this.offsetWidth;
transitions.push({
prop : 'width',
begin : width,
change : o.width-width,
onEnd : o.onWidthChanged || 0
});
}
if(o.height !== undefined){
var height = this.offsetHeight;
transitions.push({
prop : 'height',
begin : height,
change : o.height-height,
onEnd : o.onHeightChanged || 0
});
}
if(this.resizing){
this.resizing.stop();
}
this.resizing = this.cssTransition(transitions, o.duration || 48);
this.resizing.start();
return this.resizing;
};
//Element/prototype/hide.js
/**
@Name: Element.prototype.hide
@Description: Sets the display of the element to none, removing its from being displayed on the page
@Return: returns itself
@Example:
myElement.hide();
*/
Element.prototype.hide = function(){
this.style.display = 'none';
return this;
};
//Element/prototype/show.js
/**
@Name: Element.prototype.show
@Description: Switches an elements display back to whatever its default was. Tis is the reciprocal method for myElement.hide();
@Return: returns itself
@Example:
myElement.show();
*/
Element.prototype.show = function(){
try{
this.style.display = (this.getStyle('display')=='none') ? 'block' : this.getStyle('display');
} catch(e){
this.style.display='block';
}
return this;
};
//Element/prototype/toggle.js
/**
@Name: Element.prototype.toggle
@Description: Switches an object's display between hidden and default
@Return: returns itself
@Example:
myElement.toggle();
*/
Element.prototype.toggle = function(){
if(this.style){
this.style.display = (this.getStyle('display') ==='none') ? '' : 'none';
}
return this;
};
//widget/flipBook.js
sb.include('Array.prototype.iteration');
sb.include('effect');
sb.include('Element.prototype.cssTransition');
/**
@Name: sb.flipBook
@Type: constructor
@Description: Loops through a series of images on an interval, each one which open a new site, such as with advertisments
@Param: object params
.interval integer The interval between flips in milliseconds
.images array An array of image objects with src and href properties, see example
.onFlip function A custom function which fires each time during the flip
.onClick function A custom function which fires when the user clicks on the image before the new window loads. If it returns false, the window doesn't open
.onMouseOver
.onMouseOut
@Return object An sb.flipbook instance
@Example:
var flipper = new sb.widget.flipBook({
images : [
{ src : 'estrip.jpg', url : 'http://www.estrip.org', alt : 'blog your life'},
{ src : 'yahoo.jpg', url : 'http://www.yahoo.com', alt : 'yahoo'},
{ src : 'cnn.jpg', url : 'http://www.cnn.com', alt : 'watch the new'},
{ src : 'roswellpark.jpg', url : 'http://www.roswellpark.org', alt : 'cure cancer'}]
});
flipper.image.appendTo('#advertisement');
*/
sb.widget.flipBook = function(params){
this.images = params.images || new sb.nodeList();
this.interval = params.interval || 3000;
this.createImage();
var t= this;
this.flipper = window.setInterval(function(){
t.flip();
}, this.interval);
};
sb.widget.flipBook.prototype = {
add : function(img){
this.images.push(img);
},
flip : function(){
this.image.style.cursor='';
if(typeof this.onFlip == 'function'){
this.onFlip();
}
var t=this;
this.image.cssTransition([{
prop : 'opacity',
type: 'outQuart',
begin : 100,
change : -100,
onEnd : function(){
t.image.cssTransition([{
prop : 'opacity',
type: 'inQuart',
begin : 0,
change : 100
}], 48).start();
var img = t.images.cycle();
if(typeof img.alt !='undefined'){
t.image.alt = img.alt;
t.image.title = img.alt;
}
t.image.src = img.src;
if(typeof img.url != 'undefined' && img.url !==''){
t.image.style.cursor='pointer';
t.image.url = img.url;
}
}
}], 48).start();
},
createImage : function(){
this.image = new sb.element({
tag :'img',
src : this.images[0].src || '',
alt : this.images[0].alt || '',
title : this.images[0].title || '',
flipper : this,
events : {
click : function(){
var flip = 1;
if(typeof this.onFlip == 'function'){
flip = this.onFlip();
}
if(flip){
window.location = this.url;
}
},
mouseover : function(){
if(typeof this.flipper.onMouseOver == 'function'){
this.flipper.onMouseOver();
}
},
mouseout : function(){
if(typeof this.flipper.onMouseOut == 'function'){
this.flipper.onMouseOut();
}
}
}
});
if(typeof this.images[0].url !='undefined' && this.images[0].url !==''){
this.image.style.cursor='pointer';
this.image.url = this.images[0].url;
}
}
};