+/*
+ Namespace object.
+*/
+
+var SWS = {};
+
+
+
+SWS.Utils = new function () {
+ var self = this;
+
+ self.isUndefined = function (o) { return typeof o == "undefined"; };
+ self.push2 = function (t, i, v) {
+ if ((typeof t[i]) == 'undefined') {
+ t[i] = new Array();
+ };
+ var l = t[i].length;
+ t[i][l] = v;
+ };
+
+ self.isEmpty = function (o) {
+ for(var _ in o) return false;
+ return true;
+ };
+
+ self.parseFrameSpec = function (s) {
+ var elems = s.split("_");
+ var result = {};
+ var min_last = 10000;
+ var max_value = -1;
+ for(var i = 0; i < elems.length; i++){
+ var bounds = elems[i].split("-");
+ if (bounds.length > 2 || bounds.length == 0) return {};
+ if (bounds.length == 1) bounds[1] = bounds[0];
+ var a = parseInt(bounds[0]);
+ var b = parseInt(bounds[1])
+ if (!isFinite(a) || !isFinite(b)) return {};
+ a = Math.min(a, 1000); // don't allow more than 1000 frames/slide
+ b = Math.min(b, 1000);
+ if (b > max_value) max_value = b;
+ for (var j = a; j <= b; j++)
+ result[j] = true;
+ };
+ return result;
+ };
+
+
+};
+
+
+
+
+SWS.Templates = new function () {
+ var self = this;
+ self.slideActivate = function (o) {
+ if (!(o.hasClass("sws-active-slide"))){
+ o.removeClass("sws-inactive-slide").addClass("sws-active-slide");
+ };
+ };
+
+ self.slideDeactivate = function (o) {
+ if (!(o.hasClass("sws-inactive-slide"))){
+ o.removeClass("sws-active-slide").addClass("sws-inactive-slide");
+ };
+ };
+
+ self.slideChange = function (from, to) {
+ var canvas = $(".sws-canvas");
+ self.slideDeactivate($(canvas[from]));
+ self.slideActivate($(canvas[to]));
+ };
+
+ self.objectActivate = function (o) {
+ if (!(o.hasClass("sws-active-object"))){
+ o.removeClass("sws-inactive-object").addClass("sws-active-object");
+ o.css({'visibility':'visible'});
+ return true;
+ };
+ return false;
+ };
+
+ self.objectDeactivate = function (o) {
+ if (!(o.hasClass("sws-inactive-object"))){
+ o.addClass("sws-inactive-object").removeClass("sws-active-object");
+ return true;
+ };
+ return false;
+ };
+
+ self.updateFooter = function (o) {
+ var footer = o.find(".sws-footer");
+ if (footer.length && (footer.children("*").length == 0)) {
+ var i = SWS.Presentation.getCurrentSlide();
+ var cur = $( "<span class='sws-current-slide-number'>"
+ + (i + 1)
+ +"</span>");
+ var sep = $( "<span class='sws-slide-num-sep' />");
+ var tot = $( "<span class='sws-current-slide-number'>"
+ + (SWS.Presentation.getNumSlides())
+ +"</span>");
+ footer.append(cur).append(sep).append(tot);
+ };
+ };
+ self.updateHeader = function (o) {};
+};
+SWS.ConfigBuilder = function () {
+ var self = this;
+ self['sws-object-activate'] = SWS.Templates.objectActivate;
+ self['sws-object-deactivate'] = SWS.Templates.objectDeactivate;
+ self['sws-slide-change'] = SWS.Templates.slideChange;
+ self['sws-update-footer'] = SWS.Templates.updateFooter;
+ self['sws-update-header'] = SWS.Templates.updateHeader;
+};
+
+SWS.Defaults = new SWS.ConfigBuilder ();
+
+SWS.Config = new SWS.ConfigBuilder ();
+
+
+SWS.Effects = new function () {
+ var self = this;
+
+ self.objectDeactivateFadeOut = function (o) {
+ o.animate({'opacity': '0'}, 150,
+ function () { SWS.Templates.objectDeactivate(o)});
+ };
+
+ self.objectActivateFadeIn = function (o) {
+
+ if (SWS.Templates.objectActivate(o)){
+ o.animate({'opacity': '1' }, 150);
+ };
+
+ };
+
+ self.slideChangeHorizontalFlip = function (from, to){
+ var f = SWS.Presentation.getSlide(from);
+ var t = SWS.Presentation.getSlide(to);
+ f.animate({ 'left': '50%', 'width': '0pt', 'opacity':'0' }, 150,
+ function () {
+ SWS.Templates.slideDeactivate(f);
+ f.css({'left':'0%', 'width': '100%'});
+ t.css({ 'left': '50%', 'width': '0pt','opacity':'0' });
+ SWS.Templates.slideActivate(t);
+ t.animate({'left':'0%', 'width': '100%','opacity':'1'});
+ });
+ };
+ self.slideChangeFadeOutIn = function (from, to) {
+ var f = SWS.Presentation.getSlide(from);
+ var t = SWS.Presentation.getSlide(to);
+ f.animate({ 'opacity': '0'}, 150,
+ function () { SWS.Templates.slideDeactivate(f);
+ SWS.Templates.slideActivate(t);
+ t.css('opacity', '0');
+ t.animate({ 'opacity': '1'}, 150);
+ });
+ };
+ self.slideChangeHorizontalSlide = function (from, to) {
+ var f = SWS.Presentation.getSlide(from);
+ var t = SWS.Presentation.getSlide(to);
+ if (from < to) {
+ t.css('left', '100%');
+ SWS.Templates.slideActivate(t);
+ f.animate({ 'left': '-100%' }, 250, function () { SWS.Templates.slideDeactivate(f); });
+ t.animate({ 'left': '0%' }, 250);
+ } else {
+ t.css('left', '-100%');
+ SWS.Templates.slideActivate(t);
+ f.animate({ 'left': '100%' }, 250, function () { SWS.Templates.slideDeactivate(f); });
+ t.animate({ 'left': '0%' }, 250);
+ };
+ };
+
+
+ self.slideChangeVerticalSlide = function (from, to) {
+ var f = SWS.Presentation.getSlide(from);
+ var t = SWS.Presentation.getSlide(to);
+ if (from < to) {
+ t.css('top', '100%');
+ SWS.Templates.slideActivate(t);
+ f.animate({ 'top': '-100%' }, 250, function () { SWS.Templates.slideDeactivate(f); });
+ t.animate({ 'top': '0%' }, 250);
+ } else {
+ t.css('top', '-100%');
+ SWS.Templates.slideActivate(t);
+ f.animate({ 'top': '100%' }, 250, function () { SWS.Templates.slideDeactivate(f); });
+ t.animate({ 'top': '0%' }, 250);
+ };
+ };
+
+};
+
+SWS.Presentation = new function () {
+
+
+ var self = this;
+
+ //TODO move outside of the Presentation object
+
+