|
|
@ -1,24 +1,41 @@ |
|
|
|
/* Slider Slide |
|
|
|
/* Slider Slide |
|
|
|
================================================== */ |
|
|
|
================================================== */ |
|
|
|
if (typeof VMM.Slider != 'undefined') { |
|
|
|
if (typeof VMM.Slider != 'undefined') { |
|
|
|
// VMM.Slider.Slide(element, data)
|
|
|
|
|
|
|
|
VMM.Slider.Slide = function(d, _parent) { |
|
|
|
VMM.Slider.Slide = function(d, _parent) { |
|
|
|
|
|
|
|
|
|
|
|
var data = d; |
|
|
|
var $media, $text, $slide, $wrap, element, c, |
|
|
|
var slide = {}; |
|
|
|
data = d, |
|
|
|
var media = ""; |
|
|
|
slide = {}, |
|
|
|
var loaded = false; |
|
|
|
element = "", |
|
|
|
var preloaded = false; |
|
|
|
media = "", |
|
|
|
var is_skinny = false; |
|
|
|
loaded = false, |
|
|
|
var element = VMM.appendAndGetElement(_parent, "<div>", "slider-item"); |
|
|
|
preloaded = false, |
|
|
|
var c = {slide:"", text: "", media: "", media_element: "", layout: "content-container layout", has: { headline: false, text: false, media: false }}; |
|
|
|
is_skinny = false, |
|
|
|
var $media, $text, $slide, $wrap; |
|
|
|
_enqueue = true, |
|
|
|
|
|
|
|
_removeque = false, |
|
|
|
|
|
|
|
_id = "slide_", |
|
|
|
|
|
|
|
timer = {pushque:"", render:"", relayout:"", remove:"", skinny:false}, |
|
|
|
|
|
|
|
times = {pushque:500, render:100, relayout:100, remove:30000}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_id = _id + data.uniqueid; |
|
|
|
|
|
|
|
this.enqueue = _enqueue; |
|
|
|
|
|
|
|
this.id = _id; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
element = VMM.appendAndGetElement(_parent, "<div>", "slider-item"); |
|
|
|
|
|
|
|
c = {slide:"", text: "", media: "", media_element: "", layout: "content-container layout", has: { headline: false, text: false, media: false }}; |
|
|
|
|
|
|
|
|
|
|
|
/* PUBLIC |
|
|
|
/* PUBLIC |
|
|
|
================================================== */ |
|
|
|
================================================== */ |
|
|
|
this.show = function(skinny) { |
|
|
|
this.show = function(skinny) { |
|
|
|
|
|
|
|
_enqueue = false; |
|
|
|
|
|
|
|
timer.skinny = skinny; |
|
|
|
|
|
|
|
_removeque = false; |
|
|
|
|
|
|
|
clearTimeout(timer.remove); |
|
|
|
|
|
|
|
|
|
|
|
if (!loaded) { |
|
|
|
if (!loaded) { |
|
|
|
if (preloaded) { |
|
|
|
if (preloaded) { |
|
|
|
reLayout(skinny); |
|
|
|
clearTimeout(timer.relayout); |
|
|
|
|
|
|
|
timer.relayout = setTimeout(reloadLayout, times.relayout); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
render(skinny); |
|
|
|
render(skinny); |
|
|
|
} |
|
|
|
} |
|
|
@ -26,11 +43,20 @@ if (typeof VMM.Slider != 'undefined') { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
this.hide = function() { |
|
|
|
this.hide = function() { |
|
|
|
if (loaded) { |
|
|
|
if (loaded && !_removeque) { |
|
|
|
removeSlide(); |
|
|
|
_removeque = true; |
|
|
|
|
|
|
|
clearTimeout(timer.remove); |
|
|
|
|
|
|
|
timer.remove = setTimeout(removeSlide, times.remove); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.clearTimers = function() { |
|
|
|
|
|
|
|
//clearTimeout(timer.remove);
|
|
|
|
|
|
|
|
clearTimeout(timer.relayout); |
|
|
|
|
|
|
|
clearTimeout(timer.pushque); |
|
|
|
|
|
|
|
clearTimeout(timer.render); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
this.layout = function(skinny) { |
|
|
|
this.layout = function(skinny) { |
|
|
|
if (loaded && preloaded) { |
|
|
|
if (loaded && preloaded) { |
|
|
|
reLayout(skinny); |
|
|
|
reLayout(skinny); |
|
|
@ -86,39 +112,68 @@ if (typeof VMM.Slider != 'undefined') { |
|
|
|
/* PRIVATE |
|
|
|
/* PRIVATE |
|
|
|
================================================== */ |
|
|
|
================================================== */ |
|
|
|
var render = function(skinny) { |
|
|
|
var render = function(skinny) { |
|
|
|
buildSlide(skinny); |
|
|
|
trace("RENDER " + _id); |
|
|
|
|
|
|
|
|
|
|
|
loaded = true; |
|
|
|
loaded = true; |
|
|
|
preloaded = true; |
|
|
|
preloaded = true; |
|
|
|
var timer = setTimeout(VMM.ExternalAPI.pushQues, 500); |
|
|
|
timer.skinny = skinny; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buildSlide(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
clearTimeout(timer.pushque); |
|
|
|
|
|
|
|
clearTimeout(timer.render); |
|
|
|
|
|
|
|
timer.pushque = setTimeout(VMM.ExternalAPI.pushQues, times.pushque); |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var removeSlide = function() { |
|
|
|
var removeSlide = function() { |
|
|
|
//VMM.attachElement(element, "");
|
|
|
|
//VMM.attachElement(element, "");
|
|
|
|
|
|
|
|
trace("REMOVE SLIDE TIMER FINISHED"); |
|
|
|
loaded = false; |
|
|
|
loaded = false; |
|
|
|
} |
|
|
|
VMM.Lib.detach($text); |
|
|
|
|
|
|
|
VMM.Lib.detach($media); |
|
|
|
|
|
|
|
|
|
|
|
var reLayout = function(skinny) { |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var reloadLayout = function() { |
|
|
|
|
|
|
|
loaded = true; |
|
|
|
|
|
|
|
reLayout(timer.skinny, true); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var reLayout = function(skinny, reload) { |
|
|
|
if (c.has.text) { |
|
|
|
if (c.has.text) { |
|
|
|
if (skinny) { |
|
|
|
if (skinny) { |
|
|
|
if (!is_skinny) { |
|
|
|
if (!is_skinny || reload) { |
|
|
|
VMM.Lib.removeClass($slide, "pad-left"); |
|
|
|
VMM.Lib.removeClass($slide, "pad-left"); |
|
|
|
VMM.Lib.detach($text); |
|
|
|
VMM.Lib.detach($text); |
|
|
|
VMM.Lib.prepend($slide, $text); |
|
|
|
VMM.Lib.detach($media); |
|
|
|
|
|
|
|
VMM.Lib.append($slide, $text); |
|
|
|
|
|
|
|
VMM.Lib.append($slide, $media); |
|
|
|
is_skinny = true; |
|
|
|
is_skinny = true; |
|
|
|
}
|
|
|
|
}
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (is_skinny) { |
|
|
|
if (is_skinny || reload) { |
|
|
|
VMM.Lib.addClass($slide, "pad-left"); |
|
|
|
VMM.Lib.addClass($slide, "pad-left"); |
|
|
|
VMM.Lib.detach($text); |
|
|
|
VMM.Lib.detach($text); |
|
|
|
|
|
|
|
VMM.Lib.detach($media); |
|
|
|
|
|
|
|
VMM.Lib.append($slide, $media); |
|
|
|
VMM.Lib.append($slide, $text); |
|
|
|
VMM.Lib.append($slide, $text); |
|
|
|
is_skinny = false |
|
|
|
is_skinny = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else if (reload) { |
|
|
|
|
|
|
|
if (c.has.headline) { |
|
|
|
|
|
|
|
VMM.Lib.detach($text); |
|
|
|
|
|
|
|
VMM.Lib.append($slide, $text); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
VMM.Lib.detach($media); |
|
|
|
|
|
|
|
VMM.Lib.append($slide, $media); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var buildSlide = function(skinny) { |
|
|
|
var buildSlide = function() { |
|
|
|
|
|
|
|
trace("BUILDSLIDE"); |
|
|
|
$wrap = VMM.appendAndGetElement(element, "<div>", "content"); |
|
|
|
$wrap = VMM.appendAndGetElement(element, "<div>", "content"); |
|
|
|
$slide = VMM.appendAndGetElement($wrap, "<div>"); |
|
|
|
$slide = VMM.appendAndGetElement($wrap, "<div>"); |
|
|
|
|
|
|
|
|
|
|
@ -164,6 +219,12 @@ if (typeof VMM.Slider != 'undefined') { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* SLUG |
|
|
|
|
|
|
|
================================================== */ |
|
|
|
|
|
|
|
if (data.needs_slug) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* MEDIA |
|
|
|
/* MEDIA |
|
|
|
================================================== */ |
|
|
|
================================================== */ |
|
|
|
if (data.asset != null && data.asset != "") { |
|
|
|
if (data.asset != null && data.asset != "") { |
|
|
@ -179,7 +240,7 @@ if (typeof VMM.Slider != 'undefined') { |
|
|
|
if (c.has.media){ c.layout += "-media" }; |
|
|
|
if (c.has.media){ c.layout += "-media" }; |
|
|
|
|
|
|
|
|
|
|
|
if (c.has.text) { |
|
|
|
if (c.has.text) { |
|
|
|
if (skinny) { |
|
|
|
if (timer.skinny) { |
|
|
|
VMM.Lib.addClass($slide, c.layout); |
|
|
|
VMM.Lib.addClass($slide, c.layout); |
|
|
|
is_skinny = true; |
|
|
|
is_skinny = true; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|