X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=simpleWebSlides.js;h=b526992e24c1c3ba09c4f473b5d2e53277f7241a;hb=1c7fb91b0660f9094fc5b387417134865f2cf2c9;hp=134369c23216e99dd7119b30a6e13f33192b3bcb;hpb=d0dbcbd2b3d2020d41e929b17368d1a3ba388937;p=hacks%2FsimpleWebSlides.git diff --git a/simpleWebSlides.js b/simpleWebSlides.js index 134369c..b526992 100644 --- a/simpleWebSlides.js +++ b/simpleWebSlides.js @@ -1,8 +1,10 @@ var SimpleWebSlides = new function () { + var _self = this; var _total_slides; var _defered_custom = new Array(); var _initialized = false; + var _animations_running = false; function push_following(t, i, v) { if ((typeof t[i]) == 'undefined') { @@ -28,13 +30,13 @@ var SimpleWebSlides = new function () { var cur_frame = 0; canvas.find("*").each(function(i) { - if ($(this).hasClass("pause")) cur_frame++; + if ($(this).hasClass("sws-pause")) cur_frame++; push_following(frames, cur_frame, $(this)); }); - canvas.data("frames", { frames: frames, - current: 0, - custom: new Array() }); + canvas.data("sws-frames", { frames: frames, + current: 0, + custom: new Array() }); }; @@ -47,8 +49,8 @@ var SimpleWebSlides = new function () { //on partial doms var scripts = document.getElementsByTagName("script"); var current = scripts[scripts.length-1]; - console.log(current); - var slide = $(current).parents(".slide"); + + var slide = $(current).parents(".sws-slide"); if (slide.length == 0) { console.log("no parent ?"); return; @@ -83,27 +85,28 @@ var SimpleWebSlides = new function () { }; _self.firstSlide = function () { return 0; }; _self.lastSlide = function () { return _self.getNumSlides() - 1; }; + _self.refresh = function () { + var cur = _self.getCurrentSlide(); - $(".canvas").each (function (i) { + $(".sws-canvas").each (function (i) { if (i == cur){ - $(this).removeClass("other_slides").addClass("current_slide"); - var info = $(this).data("frames"); + $(this).removeClass("sws-inactive-slide").addClass("sws-active-slide"); + var info = $(this).data("sws-frames"); var frames = info.frames; var upto = info.current; var custom = info.custom; for(var j = 0; j < Math.max(frames.length, custom.length); j++) { for (var k = 0; k < frames[j].length; k++) { - if (j < upto || frames[j][k].hasClass("footer")){ - - frames[j][k].removeClass("inactive_frame").addClass("active_frame"); - - } else if (j == upto) { - - frames[j][k].removeClass("inactive_frame").addClass("current_frame"); + if (j <= upto || frames[j][k].hasClass("sws-footer")){ + frames[j][k] + .removeClass("sws-inactive-frame") + .addClass("sws-active-frame"); } else { - frames[j][k].removeClass("active_frame").removeClass("current_frame").addClass("inactive_frame"); + frames[j][k] + .removeClass("sws-active-frame") + .addClass("sws-inactive-frame"); }; }; var callbacks; @@ -113,11 +116,16 @@ var SimpleWebSlides = new function () { }; }; - } else if ($(this).hasClass("current_slide")) { - $(this).removeClass("current_slide").addClass("other_slides"); + _animation_running = true; + $(this).find("*").promise().done(function() { + _animation_running = false; + }); + } else if ($(this).hasClass("sws-active-slide")) { + $(this).removeClass("sws-active-slide").addClass("sws-inactive-slide"); }; - }); + + }); }; _self.nextSlide = function () { @@ -133,8 +141,8 @@ var SimpleWebSlides = new function () { _self.getFrameInfo = function () { var i = _self.getCurrentSlide(); - var canvas = $($(".canvas")[i]); - var infos = canvas.data("frames"); + var canvas = $($(".sws-canvas")[i]); + var infos = canvas.data("sws-frames"); return infos; }; _self.getCurrentFrame = function () { return _self.getFrameInfo().current; }; @@ -170,7 +178,7 @@ var SimpleWebSlides = new function () { _self.keyboardHandler = function (event) { - + if (_animation_running) return; switch (event.which) { case 36:/* Home */ _self.firstSlide(); @@ -204,28 +212,32 @@ var SimpleWebSlides = new function () { }; var _init = function () { - _total_slides = $(".slide").length; + _total_slides = $(".sws-slide").length; $(document).keydown(_self.keyboardHandler); $(document).mousedown(_self.keyboardHandler); var cur = _self.getCurrentSlide(); - $(".slide").each (function (i) { - var elem = '