sideSlider.clickbind = false;
sideSlider.fromLeft = true;
sideSlider.appendTo = null;
sideSlider._html = '
' +
'Ładowanie ... ' +
'';
sideSlider.element = null;
sideSlider.state = 0;
sideSlider.progress = function(p){
return p;
};
sideSlider.quad = function(progress) {
return Math.pow(progress, 2);
};
sideSlider.timer = null;
sideSlider.ongoing_animation = false;
sideSlider.animate = function (opts) {
sideSlider.ongoing_animation = true;
var start = new Date;
sideSlider.interval = setInterval(function() {
var timePassed = new Date - start;
var progress = timePassed / opts.duration;
if (progress > 1) progress = 1;
var delta = opts.delta(progress);
opts.step(delta);
if (progress == 1) {
clearInterval(sideSlider.interval);
sideSlider.state = 0;
sideSlider.ongoing_animation = false;
}
}, opts.delay || 10)
};
sideSlider.stateManager = function(){
if(!sideSlider.clickbind){
sideSlider.element.onmouseover = function(){
if(!sideSlider.state){
sideSlider.run(this,sideSlider.quad,true);
}
};
sideSlider.element.onmouseout = function(event){
event = event || window.event;
e = event.toElement || event.relatedTarget;
if (e == null || e.parentNode == this ||
e == this) {
return;
}
if(sideSlider.ongoing_animation && sideSlider.state != 3){
sideSlider.state = 2;
}
sideSlider.run(this,sideSlider.quad,false);
}
}
else{
var clicked = false;
sideSlider.element.onclick = function(){
clicked = !clicked;
sideSlider.run(this,sideSlider.quad,clicked);
}
}
};
sideSlider.run = function (element, delta, open, duration) {
var fromLeft = true;
fromLeft = fromLeft ? 'left' : 'right';
var state = parseInt(element.style[fromLeft]) == 0 ;
var from = -Math.abs(element.offsetWidth);
var to = Math.abs(element.offsetWidth);
if( !state == open || sideSlider.state == 2 ){
if(state){
from = 0;
to = -to;
}
if(sideSlider.state == 2){
from = 0;
to = -to;
clearInterval(sideSlider.interval);
sideSlider.ongoing_animation = false;
sideSlider.state = 3;
}
else{
sideSlider.state = 1;
}
this.animate({
delay: 1,
duration: duration || 500,
delta: delta,
step: function(delta) {
element.style[fromLeft] = from + to*delta + "px";
}
})
}
};
sideSlider.append = function(){
var html = document.createElement('div');
html.setAttribute("id", "_opineo_container");
html.setAttribute("style", "z-index:2147483647; position:fixed;width: 208px; height 354px; top:180px; left:-208px; overflow:visible;");
html.innerHTML = sideSlider._html;
if (sideSlider.append != null) {
sideSlider.appendTo = document.getElementById(sideSlider.appendTo);
if (sideSlider.appendTo != null)
sideSlider.appendTo.appendChild(html);
else
document.body.appendChild(html);
} else {
document.body.appendChild(html);
}
sideSlider.element = html;
};
sideSlider.get = function(){
sideSlider.append();
sideSlider.stateManager();
};
sideSlider.pin = function (){
if (document.addEventListener) {
document.addEventListener ("DOMContentLoaded", function(){
document.removeEventListener("DOMContentLoaded", arguments.callee, false);
sideSlider.get();
}, false);
} else if (document.attachEvent) {
document.attachEvent("onreadystatechange", function(){
if (document.readyState === "complete") {
document.detachEvent("onreadystatechange", arguments.callee);
sideSlider.get();
}
});
}
}
function sideSlider(){
sideSlider.fromLeft = true;
sideSlider.clickbind = false;
sideSlider.appendTo = null;
/* OpineoSlider.rawHTML = false; */
sideSlider.pin();
};
sideSlider();