var CSlideMan = {
slides : [
{
"img":"test-0.jpg",
"bg-color":"yellow",
"bg-size":"contain",
"bg-pos":"center",
"verb":"bounce",
"coru":"u",
"dir":"down",
"ttime":"2",
"ptime":"2"
},
{
"img":"test-1.jpg",
"bg-color":"gold",
"bg-size":"cover",
"bg-pos":"left",
"verb":"gate",
"coru":"c",
"dir":"hori",
"ttime":"0.6",
"easing":"ease",
"ptime":"2"
},
{
"img":"test-2.jpg",
"bg-color":"rgba(0,0,0,0.5)",
"bg-size":"cover",
"bg-pos":"center",
"verb":"slice",
"coru":"c",
"dir":"down",
"nos":10,
"ttime":"1",
"easing":"ease",
"ptime":"2"
},
{
"img":"test-3.jpg",
"bg-color":"rgba(255,200,200,0.5)",
"bg-size":"cover",
"bg-pos":"center",
"verb":"scroll",
"dir":"right",
"ttime":"0.5",
"easing":"ease",
"ptime":"2"
},
],
/*
"verb":"zoom",
"coru":"u",
"ttime":".8",
"easing":"ease-out"
"verb":"kenburns",
"dir":"br",
"ttime":"4",
"easing":"linear"
"verb":"scroll",
"dir":"right",
"ttime":"0.5",
"easing":"ease"
"verb":"fade",
"ttime":"4",
"easing":"linear"
"verb":"blind",
"coru":"u",
"dir":"up",
"nos":13,
"ttime":"1",
"easing":"ease"
"verb":"slice",
"coru":"c",
"dir":"down",
"nos":10,
"ttime":"1",
"easing":"ease"
"verb":"turn",
"dir":"right",
"ttime":".5",
"easing":"ease"
"verb":"uncover",
"dir":"right",
"ttime":"1",
"easing":"linear"
*/
setup : function() {
},
getSlide : function(idx) {
return this.slides[idx];
},
getCount : function() {
return this.slides.length;
},
create : function(idx,base_class) {
var cls = "slide-base" + ( base_class ? "-"+base_class:"" );
var rec = this.getSlide(idx);
return $("
")
.addClass(cls)
.css({
"background-image":"url('img/"+rec["img"]+"')",
"background-color":rec["bg-color"],
"background-size":rec["bg-size"],
"background-position":rec["bg-pos"],
"background-repeat":"no-repeat"
});
},
};
var CPBar = {
abort : function() {
sshow.jqo_info_panel
.find(".sigxyz-progressbar")
.remove();
},
run : function(pbtype,rec,b_reverse) {
if ( b_reverse == undefined ) {
b_reverse = false;
}
this.abort();
var css = {
opacity:0.5
};
var pos = "top";
var height = 10;
var color = "red";
var dura,pos,height,color;
switch( pbtype ) {
case "t":
dura = rec["ttime"];
pos = "top";
height = 10;
color = "red";
break;
case "p":
dura = rec["ptime"];
pos = "bottom";
height = 14;
color = "yellow";
break;
}
switch ( pos ) {
case "top": css.top = 0; break;
case "bottom": css.bottom = 0; break;
}
$("
")
.attr("class","sigxyz-progressbar")
.css(css)
.html($("
")
.css({
width:0,
height:height+"px",
"background-color":color
})
.css({
"animation-name":"sigxyz-kf-progressbar",
"animation-duration":dura+"s",
"animation-timing-function":"ease",
"animation-iteration-count":1,
"animation-fill-mode":"none",
"animation-direction":!b_reverse?"normal":"reverse"
})
)
.appendTo(sshow.jqo_info_panel);
}
};
var CTfxMan = {
run : function(idx_tfx,idx_f,idx_t,b_reverse) {
var tfx = {
idx:{
"f":idx_f,
"t":idx_t
},
init:{},
kf:{},
b_reverse:b_reverse
};
var rec = CSlideMan.getSlide(idx_tfx);
for ( var key in rec ) {
tfx[key] = rec[key];
}
var tfx_func_run = tfx_handlers[rec["verb"]];
tfx_func_run.call(tfx);
CPBar.run("t",rec,b_reverse);
return rec;
}
};
var sshow = {
getSlideSize : function() {
return {
w:this.jqo_slide_w.width(),
h:this.jqo_slide_w.height()
};
},
show : function() {
this.jqo_slide_w.html(CSlideMan.create(this.cidx));
},
clear : function() {
this.jqo_slide_w.html("");
},
doTrans : function(idx_t_inp) {
var _this = this;
if ( !this.max_slide ) {
return;
}
var b_reverse = false;
var idx_f = this.cidx;
if ( idx_t_inp === true ) {
idx_t = idx_f+1;
if ( idx_t >= this.max_slide ) {
idx_t = 0;
}
} else if ( idx_t_inp === false ) {
b_reverse = true;
idx_t = idx_f-1;
if ( idx_t < 0 ) {
idx_t = this.max_slide-1;
}
} else {
idx_t = idx_t_inp % this.max_slide;
if ( idx_t == this.cidx ) {
return;
}
}
var idx_next = idx_t;
if ( b_reverse ) {
var idx_tfx = idx_f;
var temp = idx_f;
idx_f = idx_t;
idx_t = temp;
} else {
var idx_tfx = idx_t;
}
this.abort();
this.cidx = idx_next;
this.tfx_rec = CTfxMan.run(idx_tfx,idx_f,idx_t,b_reverse);
},
setTransFlag : function(ttime_id) {
this.ttime_id = ttime_id;
console.log("ttime_id",ttime_id);
},
isInTrans : function() {
return ( this.ttime_id != null );
},
setPauseFlag : function(ptime_id) {
this.ptime_id = ptime_id;
console.log("ptime_id",ptime_id);
},
isInPause : function() {
return ( this.ptime_id != null );
},
abort : function() {
if ( this.isInPause() ) {
clearTimeout(this.ptime_id);
this.setPauseFlag(null);
}
if ( this.isInTrans() ) {
clearTimeout(this.ttime_id);
this.setTransFlag(null);
}
this.clear();
CPBar.abort();
},
shouldRun : function() {
return true;
},
onPauseBegin : function() {
this.show();
if ( this.shouldRun() ) {
this.tfx_rec = CSlideMan.getSlide(this.cidx);
CPBar.run("p",this.tfx_rec);
var _this = this;
this.setPauseFlag(setTimeout(function(){
_this.onPauseEnd();
},this.tfx_rec["ptime"]*1000));
}
},
onPauseEnd : function() {
this.setPauseFlag(null);
this.onTransBegin();
},
onTransBegin : function(idx) {
if ( idx == undefined ) { idx = true; }
this.doTrans(idx);
CPBar.run("t",this.tfx_rec);
var _this = this;
this.setTransFlag(setTimeout(function(){
_this.onTransEnd();
},this.tfx_rec["ttime"]*1000));
},
onTransEnd : function() {
this.setTransFlag(null);
this.onPauseBegin();
},
onResized : function() {
this.abort();
this.onPauseBegin();
console.log("onResized");
},
goto : function(idx) {
this.onTransBegin(idx);
},
setup : function() {
var _this = this;
this.cidx = 0;
this.setPauseFlag(null);
this.setTransFlag(null);
this.jqo_info_panel = $(".info-panel");
this.jqo_slide_w = $(".slide-work");
this.jqo_pagebtn = $(".ctar-pagebtn");
this.jqo_inp_panel = $(".inp-panel");
this.max_slide = CSlideMan.getCount();
for(var i=0; i")
.attr("class","btn-page")
.attr("data-idx",i)
.appendTo(this.jqo_pagebtn)
.click(function(){
_this.goto(parseInt($(this).attr("data-idx")));
});
}
$(".btn-next").click(function(){
_this.goto(true);
});
$(".btn-prev").click(function(){
_this.goto(false);
});
$( window ).bind( "resize", function() {
_this.onResized();
});
console.log(this.jqo_inp_panel.length);
this.jqo_inp_panel.bind("mouseenter",function(){
_this.abort();
_this.onPauseBegin();
});
this.onPauseBegin();
}
};