+
+ function init_canvas(canvas, custom) {
+ var cur_frame = 0;
+ var last_frame = canvas.find(".sws-pause").length;
+ //Add all regular elements to the frame list
+ var slide = $(canvas.find(".sws-slide")[0]);
+
+ var callbacks = { at_slide : new Array(),
+ at_frame : new Array() }
+
+ if (SWS.Utils.isUndefined(custom)) {
+ custom = new Array ();
+ };
+
+ for (var i = 0; i < custom.length; i++) {
+ if (isFinite(custom[i].frame)){
+ var num = +(custom[i].frame);
+ if (num > last_frame) last_frame = num;
+ SWS.Utils.push2(callbacks.at_frame, num, custom[i].fn);
+ } else if (custom[i].frame == "slide")
+ callbacks.at_slide.push(custom[i].fn);
+ else {
+ var frame_set = SWS.Utils.parseFrameSpec(custom[i].frame);
+ for(var f in frame_set){
+ if (f > last_frame) last_frame = f;
+ SWS.Utils.push2(callbacks.at_frame, +(f), custom[i].fn);
+ };
+ }
+ };
+
+ var specials = null;
+
+ slide.find('*[class*="sws-onframe-"]').each(function(_){
+ var cls = $(this).attr('class');
+ var idx = cls.indexOf("sws-onframe-");
+ if (idx >= 0) {
+ var end = cls.indexOf(" ", idx);
+ end = (end == -1) ? cls.length : end;
+ var spec = cls.substring(idx+12, end);
+ var o = SWS.Utils.parseFrameSpec(spec);
+ for(var f in o)
+ if (f > last_frame) last_frame = f;
+ $(this).find("*").andSelf().each(function(_){
+ if (!SWS.Utils.isEmpty(o))
+ $(this).data("sws-frame-set", o);
+ if (specials)
+ specials.add($(this));
+ else
+ specials = $(this);
+ });
+ };
+ });
+
+ slide.find("*").andSelf().not(specials).each(function(i) {
+ if ($(this).hasClass("sws-pause")) cur_frame++;
+ var o = {};
+ for (var j = cur_frame; j <= last_frame; j++)
+ o[ j ] = true;
+ if (!SWS.Utils.isEmpty(o))
+ $(this).data("sws-frame-set", o);
+ });
+
+ canvas.data("sws-frame-info", { current: 0,
+ last: (last_frame - 0), // force cast to integer
+ callbacks: callbacks
+ });
+
+ };
+
+ /* Forces redrawing the page without reloading */
+ self.redraw = function (f) {
+ if (SWS.Utils.isUndefined(f))
+ $("body").hide().show(400, function () {
+ $("body").css("display","block");
+ if (!SWS.Utils.isUndefined(f))
+ f();
+ });
+ };
+ self.changeAspect = function() {
+ $("html").removeClass("sws-aspect-4-3")
+ .removeClass("sws-aspect-16-9")
+ .removeClass("sws-aspect-16-10")
+ .addClass($("#sws-aspect-select").val());
+ self.redraw();
+ };
+
+ self.getCurrentTheme = function () {
+ var l = $("link.sws-theme[rel='stylesheet']")[0];
+
+ if (l) {
+ return l.title;
+ } else
+ return ""