]> git.parisson.com Git - telemeta.git/commitdiff
till work in progress
authorriccardo <riccardo@parisson.com>
Wed, 9 Feb 2011 14:27:33 +0000 (15:27 +0100)
committerriccardo <riccardo@parisson.com>
Wed, 9 Feb 2011 14:27:33 +0000 (15:27 +0100)
telemeta/htdocs/js/player.js [deleted file]
telemeta/htdocs/timeside/src/controller.js
telemeta/htdocs/timeside/src/core.js
telemeta/htdocs/timeside/src/marker.js
telemeta/htdocs/timeside/src/player.js
telemeta/htdocs/timeside/src/ruler.js
telemeta/htdocs/timeside/src/timeside.js
telemeta/templates/telemeta_default/mediaitem_detail.html

diff --git a/telemeta/htdocs/js/player.js b/telemeta/htdocs/js/player.js
deleted file mode 100644 (file)
index 4ff463d..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-var sound = null;
-var soundUrl = null;
-var soundEngineReady = false;
-var map;
-var provider;
-var player;
-var player_image_url = null;
-
-function togglePlayerMaximization() {
-    var view = $('#player');
-    $('#player_maximized, #player_minimized').css('display', 'none');
-    var ctr;
-    if (view.parents('#player_maximized').length) {
-        ctr = $('#player_minimized').append(view);
-    } else {
-        ctr = $('#player_maximized').append(view);
-    }
-    ctr.css({opacity: 0, display: 'block'});
-    if (player)
-        player.resize();
-    ctr.animate({opacity: 1}, 100);
-}
-
-function load_sound() {
-    if (!sound && soundUrl && soundEngineReady) {
-        sound = soundManager.createSound({
-            id: 'sound',
-            url: soundUrl
-        });
-        
-        TimeSide.load(function() {
-            provider.setSource(sound);
-        });
-        // sound.load(); // Auto-loading overloads the Django test server
-    }
-}
-
-function change_visualizer() {
-    set_player_image_url($('#visualizer_id').get(0).value);
-    if (player)
-        player.refreshImage();
-    return false;
-}
-
-function load_player(duration) {
-    $(document).ready(function () {
-        if (!$('#player').length)
-            return;
-
-        soundUrl = $('.ts-wave a').attr('href');
-
-        $('.ts-wave a img').insertAfter('.ts-wave a');
-        $('.ts-wave a').remove();
-
-        TimeSide.load(function() {
-            map = new TimeSide.MarkerMap();
-            provider = new TimeSide.SoundProvider({duration: duration});
-            player = new TimeSide.Player('#player', {
-                image: get_player_image_src
-            });
-            controller = new TimeSide.Controller({
-                player: player,
-                soundProvider: provider, 
-                map: map
-            });
-            change_visualizer();
-            player.resize();
-        });
-
-        $('#visualizer_id').change(change_visualizer);
-        $('#visualizer_id_form').submit(change_visualizer);
-
-        $('#player_maximized .toggle, #player_minimized .toggle').click(function() {
-            togglePlayerMaximization();
-            this.blur();
-            return false;
-        });
-
-        load_sound();
-    });    
-
-    soundManager.onload = function() {
-        soundEngineReady = true;
-        load_sound();
-    }
-
-}
-
-function set_player_image_url(str) {
-    player_image_url = str;
-}
-
-function get_player_image_src(width, height) {
-    var src = null;
-    if (player_image_url && (width || height)) {
-        src = player_image_url.replace('WIDTH', width + '').replace('HEIGHT', height + '');
-    }
-    return src;
-}
-
-
-
index 0ed4989f6d8a774215cc6d3ee6434bec857a5c6f..ff056256e0c183283df2d9a39a5eac3b3090cdd1 100644 (file)
@@ -33,16 +33,11 @@ TimeSide(function($N) {
             .observe('move', this.attach(this._onMove))
             .observe('markeradd', this.attach(this._onMarkerAdd))
             .observe('markermove', this.attach(this._onMarkerMove))
-            .observe('markeradd2',this.attach(this._onMarkerAdd2))
+            
             .draw();
             
         },
 
-        _onMarkerAdd2: function(e,data){
-            if (this.cfg.map) {
-                alert(this.cfg.map._toString());
-            }
-        },
 
         _onMove: function(e, data) {
             this.cfg.soundProvider.seek(data.offset);
@@ -77,6 +72,7 @@ TimeSide(function($N) {
                 this.refreshMarkersText(this.cfg.map);
                 this.cfg.map.add(data.offset, '');
                 this.updateMarkersDiv(this.cfg.map, data.offset);
+
             }
         },
         
index 02c9ab4a6c3984bd7f8f2381dd545cb386e034c0..e86b691766f0e2a521fd0ccdfdb9c9f4d65bec51 100644 (file)
@@ -93,7 +93,7 @@ TimeSide(function($N, $J) {
             function klass() {
                 this.initialize.apply(this, arguments);
             }
-    
+            //Merge the contents of $N.Class.Methods into klass:
             $N.extend(klass, $N.Class.Methods);
             klass.__name__ = className;
             klass.__super__ = parent;
index c6759162d2686633a2c993c53b2f7bba87899854..2a904b73103aecfc7918056dcb55c8b3475d722f 100644 (file)
@@ -7,55 +7,55 @@
 
 TimeSide(function($N, $J) {
 
-$N.Class.create("Marker", $N.Core, {
-    id: null,
-    painter: null,
-    visible: false,
-    position: 0,
-    label: null,
-    blinking: false,
-    nodes: null,
-    mouseDown: false,
-    blinkAnimation: null,
-
-    initialize: function($super, cfg) {
-        $super();
-        this.configure(cfg, {
-            rulerLayout: [null, 'required'],
-            viewer: [null, 'required'],
-            fontSize: 10,
-            zIndex: null,
-            className: [null, 'required'],
-            id: null,
-            tooltip: null
-        });
-        this.cfg.rulerLayout = $J(this.cfg.rulerLayout);
-        this.cfg.viewer = $J(this.cfg.viewer);
-
-        this.id = cfg.id;
-        this.width = this.cfg.viewer.width();
-        this.painter = new jsGraphics(this.cfg.viewer.get(0));
-        this._create();
-        this._observeMouseEvents();
-    },
-
-    free: function($super) {
-        this.cfg.rulerLayout = null;
-        this.cfg.viewer = null;
-        $super();
-    },
-
-    clear: function() {
-        this.painter.clear();
-        $J(this.painter.cnv).remove();
-        this.label.remove();
-        return this;
-    },
-
-    _create: function() {
-        this.debug('create marker');
-        var y = this.cfg.rulerLayout.find('.' + $N.cssPrefix + 'label').outerHeight();
-        this.label = $J('<a/>')
+    $N.Class.create("Marker", $N.Core, {
+        id: null,
+        painter: null,
+        visible: false,
+        position: 0,
+        label: null,
+        blinking: false,
+        nodes: null,
+        mouseDown: false,
+        blinkAnimation: null,
+
+        initialize: function($super, cfg) {
+            $super();
+            this.configure(cfg, {
+                rulerLayout: [null, 'required'],
+                viewer: [null, 'required'],
+                fontSize: 10,
+                zIndex: null,
+                className: [null, 'required'],
+                id: null,
+                tooltip: null
+            });
+            this.cfg.rulerLayout = $J(this.cfg.rulerLayout);
+            this.cfg.viewer = $J(this.cfg.viewer);
+
+            this.id = cfg.id;
+            this.width = this.cfg.viewer.width();
+            this.painter = new jsGraphics(this.cfg.viewer.get(0));
+            this._create();
+            this._observeMouseEvents();
+        },
+
+        free: function($super) {
+            this.cfg.rulerLayout = null;
+            this.cfg.viewer = null;
+            $super();
+        },
+
+        clear: function() {
+            this.painter.clear();
+            $J(this.painter.cnv).remove();
+            this.label.remove();
+            return this;
+        },
+
+        _create: function() {
+            this.debug('create marker');
+            var y = this.cfg.rulerLayout.find('.' + $N.cssPrefix + 'label').outerHeight();
+            this.label = $J('<a/>')
             .css({
                 display: 'block',
                 width: '10px', 
@@ -70,155 +70,178 @@ $N.Class.create("Marker", $N.Core, {
             .append('<span />')
             .hide();
 
-        if (this.cfg.tooltip)
-            this.label.attr('title', this.cfg.tooltip);
-
-        this.cfg.rulerLayout.append(this.label);
-
-        var height = this.cfg.viewer.height();
-        var x = 0;
-        this.painter.drawLine(x, 0, x, height);
-        x     = [-4, 4, 0];
-        var y = [0, 0, 4];
-        this.painter.fillPolygon(x, y);
-        this.painter.paint();
-        this.nodes = $J(this.painter.cnv).children();
-
-        var style = {};
-        if (this.cfg.zIndex) {
-            style.zIndex = this.cfg.zIndex;
-            this.label.css(style);
-        }
-        style.backgroundColor = '';
+            if (this.cfg.tooltip){
+                this.label.attr('title', this.cfg.tooltip);
+            }
+            this.cfg.rulerLayout.append(this.label);
+
+            var height = this.cfg.viewer.height();
+            var x = 0;
+            this.painter.drawLine(x, 0, x, height);
+            x     = [-4, 4, 0];
+            var y = [0, 0, 4];
+            this.painter.fillPolygon(x, y);
+            this.painter.paint();
+            this.nodes = $J(this.painter.cnv).children();
+
+            var style = {};
+            if (this.cfg.zIndex) {
+                style.zIndex = this.cfg.zIndex;
+                this.label.css(style);
+            }
+            style.backgroundColor = '';
 
-        this.nodes.hide().css(style).addClass($N.cssPrefix + this.cfg.className)
+            this.nodes.hide().css(style).addClass($N.cssPrefix + this.cfg.className)
             .each(function(i, node) {
                 node.originalPosition = parseInt($J(node).css('left'));
             });
-    },
-
-    setText: function(text) {
-        if (this.label) {
-            text += '';
-            var labelWidth = this._textWidth(text, this.cfg.fontSize) + 10;
-            labelWidth += 'px';
-            if (this.label.css('width') != labelWidth) {
-                this.label.css({ width: labelWidth });
+        },
+
+        setText: function(text) {
+            if (this.label) {
+                text += '';
+                var labelWidth = this._textWidth(text, this.cfg.fontSize) + 10;
+                labelWidth += 'px';
+                if (this.label.css('width') != labelWidth) {
+                    this.label.css({
+                        width: labelWidth
+                    });
+                }
+                this.label.find('span').html(text);
             }
-            this.label.find('span').html(text);
-        }
-        return this;
-    },
-
-    move: function(pixelOffset) {
-        if (this.position != pixelOffset) {
-            if (pixelOffset < 0) {
-                pixelOffset = 0;
-            } else if (pixelOffset >= this.width) {
-                pixelOffset = this.width - 1;
+            return this;
+        },
+
+        move: function(pixelOffset) {
+            if (this.position != pixelOffset) {
+                if (pixelOffset < 0) {
+                    pixelOffset = 0;
+                } else if (pixelOffset >= this.width) {
+                    pixelOffset = this.width - 1;
+                }
+                this.nodes.each(function(i, node) {
+                    $J(node).css('left', Math.round(node.originalPosition + pixelOffset) + 'px');
+                });
+                var labelWidth = this.label.width();
+                var labelPixelOffset = pixelOffset - labelWidth / 2;
+                if (labelPixelOffset < 0)
+                    labelPixelOffset = 0;
+                else if (labelPixelOffset + labelWidth > this.width)
+                    labelPixelOffset = this.width - labelWidth;
+                this.label.css({
+                    left: Math.round(labelPixelOffset) + 'px'
+                    });
+                this.position = pixelOffset;
             }
-            this.nodes.each(function(i, node) { 
-                $J(node).css('left', Math.round(node.originalPosition + pixelOffset) + 'px');
-            });
-            var labelWidth = this.label.width();
-            var labelPixelOffset = pixelOffset - labelWidth / 2;
-            if (labelPixelOffset < 0)
-                labelPixelOffset = 0;
-            else if (labelPixelOffset + labelWidth > this.width) 
-                labelPixelOffset = this.width - labelWidth;
-            this.label.css({left: Math.round(labelPixelOffset) + 'px'});            
-            this.position = pixelOffset;
-        }
-        return this;
-    },
-
-    show: function(offset) {
-        if (!this.visible) {
-            this.nodes.show();
-            this.label.show();
-            this.visible = true;
-        }
-        return this;
-    },
-
-    hide: function() {
-        this.nodes.hide();
-        this.label.hide();
-        this.visible = false;
-        return this;
-    },
-
-    isVisible: function() {
-        return this.visible;
-    },
-
-    blink: function(state) {
-        var speed = 200;
-        if (this.label && this.blinking != state) {
-            var span = this.label.find('span');
-
-            span.stop();
-
-            function fade(on) {
-                if (on) {
-                    span.animate({opacity: 1}, speed, null, 
-                        function() { fade(false) });
+            return this;
+        },
+
+        show: function(offset) {
+            if (!this.visible) {
+                this.nodes.show();
+                this.label.show();
+                this.visible = true;
+            }
+            return this;
+        },
+
+        hide: function() {
+            this.nodes.hide();
+            this.label.hide();
+            this.visible = false;
+            return this;
+        },
+
+        isVisible: function() {
+            return this.visible;
+        },
+
+        blink: function(state) {
+            var speed = 200;
+            if (this.label && this.blinking != state) {
+                var span = this.label.find('span');
+
+                span.stop();
+
+                function fade(on) {
+                    if (on) {
+                        span.animate({
+                            opacity: 1
+                        }, speed, null,
+                        function() {
+                            fade(false)
+                        });
+                    } else {
+                        span.animate({
+                            opacity: 0.4
+                        }, speed, null,
+                        function() {
+                            fade(true)
+                        })
+                    }
+                }
+
+                if (state) {
+                    fade();
                 } else {
-                    span.animate({opacity: 0.4}, speed, null, 
-                        function() { fade(true) })
+                    span.animate({
+                        opacity: 1
+                    }, speed);
                 }
-            }
 
-            if (state) {
-                fade();
-            } else {
-                span.animate({opacity: 1}, speed);
+                this.blinking = state;
             }
+            return this;
+        },
 
-            this.blinking = state;
-        }
-        return this;
-    },
-
-    _onMouseDown: function(evt) {
-        this.mouseDown = true;
-        this._onMouseMove(evt);
-        return false;
-    },
-
-    _onMouseMove: function(evt) {
-        if (this.mouseDown) {
-            var offset = (evt.pageX - this.cfg.rulerLayout.offset().left);
-            this.move(offset);
-            this.fire('move', {offset: this.position, finish: false});
+        _onMouseDown: function(evt) {
+            this.mouseDown = true;
+            this._onMouseMove(evt);
             return false;
-        }
-    },
+        },
+
+        _onMouseMove: function(evt) {
+            if (this.mouseDown) {
+                var offset = (evt.pageX - this.cfg.rulerLayout.offset().left);
+                this.move(offset);
+                this.fire('move', {
+                    offset: this.position,
+                    finish: false
+                });
+                return false;
+            }
+        },
+
+        _onMouseUp: function(evt) {
+            if (this.mouseDown) {
+                this.mouseDown = false;
+                this.fire('move', {
+                    id: this.id,
+                    offset: this.position,
+                    finish: true
+                });
+                return false;
+            }
+        },
 
-    _onMouseUp: function(evt) {
-        if (this.mouseDown) {
-            this.mouseDown = false;
-            this.fire('move', {id: this.id, offset: this.position, finish: true});
-            return false;
+        _observeMouseEvents: function() {
+            this.label.mousedown(this.attachWithEvent(this._onMouseDown))
+            .bind('click dragstart', function() {
+                return false;
+            });
+            this.cfg.rulerLayout.mousemove(this.attachWithEvent(this._onMouseMove));
+            this.cfg.rulerLayout.mouseup(this.attachWithEvent(this._onMouseUp));
+            $J(document).mouseup(this.attachWithEvent(this._onMouseUp));
         }
-    },
-
-    _observeMouseEvents: function() {
-        this.label.mousedown(this.attachWithEvent(this._onMouseDown))
-            .bind('click dragstart', function() {return false;});
-        this.cfg.rulerLayout.mousemove(this.attachWithEvent(this._onMouseMove));
-        this.cfg.rulerLayout.mouseup(this.attachWithEvent(this._onMouseUp));
-        $J(document).mouseup(this.attachWithEvent(this._onMouseUp));
-    }
 
-//    _toString: function() {
-//        return "<marker id="+id+" position="+position+" description=\""+
-//            +description+"\"/>";
-//    }
+    //    _toString: function() {
+    //        return "<marker id="+id+" position="+position+" description=\""+
+    //            +description+"\"/>";
+    //    }
 
 
-});
+    });
 
-$N.notifyScriptLoad();
+    $N.notifyScriptLoad();
 
 });
index a43baec312e1a00f178dd39a0aa416357210ebfe..e82bc19c8815ec178f5aed3488f7633b810d974c 100644 (file)
@@ -7,82 +7,82 @@
 
 TimeSide(function($N, $J) {
 
-$N.Class.create("Player", $N.Core, {
-    skeleton: {
-        'div.viewer': {
-            'div.ruler': {}, 
-            'div.wave': {
-                'div.image-canvas': {},
-                'div.image-container': ['img.image']
-            }
-        },
-        'div.control': {
-            'div.layout': {
-                'div.playback': ['a.play', 'a.pause', 'a.rewind', 'a.forward', 'a.set-marker', 'a.set-marker2']
+    $N.Class.create("Player", $N.Core, {
+        skeleton: {
+            'div.viewer': {
+                'div.ruler': {},
+                'div.wave': {
+                    'div.image-canvas': {},
+                    'div.image-container': ['img.image']
+                }
+            },
+            'div.control': {
+                'div.layout': {
+                    'div.playback': ['a.play', 'a.pause', 'a.rewind', 'a.forward', 'a.set-marker', 'a.set-marker2']
                 //,'input.textMarker']
-            }
-        }/*,
+                }
+            }/*,
         'div.marker-control': ['a.set-marker']*/
-    },
-    defaultContents: {
-        play: 'Play',
-        pause: 'Pause',
-        rewind: 'Rewind',
-        forward: 'Forward',
-        'set-marker': 'Set marker',
-        'set-marker2': 'Set marker2'
+        },
+        defaultContents: {
+            play: 'Play',
+            pause: 'Pause',
+            rewind: 'Rewind',
+            forward: 'Forward',
+            'set-marker': 'Set marker'
         //,'text-marker' : 'textmarker'
-    },
-    elements: {},
-    ruler: null,
-    soundProvider: null,
-    map: null,
-    container: null,
-    imageWidth: null,
-    imageHeight: null,
-
-    initialize: function($super, container, cfg) {
-        $super();
-        if (!container)
-            throw new $N.RequiredArgumentError(this, 'container');
-        this.container = $J(container);
-        this.configure(cfg, {
-            image: null
-        });
-    },
+        },
+        elements: {},
+        ruler: null,
+        soundProvider: null,
+        map: null,
+        container: null,
+        imageWidth: null,
+        imageHeight: null,
+
+        initialize: function($super, container, cfg) {
+            $super();
+            if (!container)
+                throw new $N.RequiredArgumentError(this, 'container');
+            this.container = $J(container);
+            this.configure(cfg, {
+                image: null
+            });
+        },
 
-    free: function($super) {
-        this.elements = null;
-        this.container = null;
-        $super();
-    },
+        free: function($super) {
+            this.elements = null;
+            this.container = null;
+            $super();
+        },
 
-    setSoundProvider: function(soundProvider) {
-        this.soundProvider = soundProvider;
-        return this;
-    },
+        setSoundProvider: function(soundProvider) {
+            this.soundProvider = soundProvider;
+            return this;
+        },
 
-    setMarkerMap: function(map) {
-        this.map = map;
-        return this;
-    },
+        setMarkerMap: function(map) {
+            this.map = map;
+            return this;
+        },
 
-    setImage: function(expr) {
-        this.cfg.image = expr;
-        this.refreshImage();
-    },
+        setImage: function(expr) {
+            this.cfg.image = expr;
+            this.refreshImage();
+        },
 
-    refreshImage: function() {
-        var src = null;
-        if (typeof this.cfg.image == 'function') {
-            src = this.cfg.image(this.imageWidth, this.imageHeight);
-        } else if (typeof this.cfg.image == 'string') {
-            src = this.cfg.image;
-        }
+        refreshImage: function() {
+            var src = null;
+            if (typeof this.cfg.image == 'function') {
+                src = this.cfg.image(this.imageWidth, this.imageHeight);
+            } else if (typeof this.cfg.image == 'string') {
+                src = this.cfg.image;
+            }
 
-        if (src) 
-            this.elements.image.attr('src', src);
-    },
+            if (src) {
+                this.elements.image.attr('src', src);
+            }
+        },
 
     draw: function() {
         this.debug('drawing');
@@ -96,42 +96,51 @@ $N.Class.create("Player", $N.Core, {
         // IE apparently doesn't send the second mousedown on double click:
         var jump = $J.browser.msie ? 'mousedown dblclick' : 'mousedown';
         this.elements.rewind.attr('href', '#').bind(jump, this.attach(this._onRewind))
-            .click(function() {return false;});
+        .click(function() {
+            return false;
+        });
         this.elements.forward.attr('href', '#').bind(jump, this.attach(this._onForward))
-            .click(function() {return false;});
+        .click(function() {
+            return false;
+        });
         this.elements.pause.attr('href', '#').bind('click', this.attach(this._onPause));
         this.elements.play.attr('href', '#').bind('click', this.attach(this._onPlay));
         
         //assigning title string to all anchors???????
         this.elements.control.find('a').add(this.elements.setMarker)
-            .attr('href', '#')
-            .each(function(i, a){
-                a = $J(a);
-                if (!a.attr('title'))
-                    a.attr('title', a.text());
-            });
+        .attr('href', '#')
+        .each(function(i, a){
+            a = $J(a);
+            if (!a.attr('title'))
+                a.attr('title', a.text());
+        });
             
         //this.elements.markerControl.find('a').attr('href', '#');
         if (this.map) {
             //configureMarkersDiv();
             this.elements.setMarker.bind('click', this.attach(this._onSetMarker));
-            this.elements.setMarker2.bind('click', this.attach(this._onSetMarker2));
-            //this.elements.textMarker.attr('type', 'text');
-            //this.elements.textMarker.bind('click', this.attach(this._onSetMarker2));
+        //this.elements.setMarker2.bind('click', this.attach(this._onSetMarker2));
+        //this.elements.textMarker.attr('type', 'text');
+        //this.elements.textMarker.bind('click', this.attach(this._onSetMarker2));
           
         } else {
             this.elements.setMarker.remove();
         }
+        //creating the ruler
         this.ruler = new $N.Ruler({
             viewer: this.elements.viewer,
             map: this.map,
             soundProvider: this.soundProvider
         });
+        //bind events to the ruler (see function observe in core.js, I guess,
+        //which overrides jQuery bind function):
+        //the first arg is basically the event name, the second
+        //arg is a function to execute each time the event is triggered
         this.ruler
-            .observe('markermove', this.forwardEvent)
-            .observe('markeradd', this.forwardEvent)
-            .observe('move', this.forwardEvent)
-            .draw();
+        .observe('markermove', this.forwardEvent)
+        .observe('markeradd', this.forwardEvent)
+        .observe('move', this.forwardEvent)
+        .draw();
         this.refreshImage();
         this.resize();
         var resizeTimer = null;
@@ -140,14 +149,7 @@ $N.Class.create("Player", $N.Core, {
                 clearTimeout(resizeTimer);
             resizeTimer = setTimeout(this.attach(this.resize), 100);
         }));
-        //this.container.resize(this.attach(this.resize)); // Can loop ?
-    },
-
-    _onSetMarker2: function() {
-        if (this.map) {
-            this.fire('markeradd2', {offset: this.soundProvider.getPosition()});
-        }
-        return false;
+    //this.container.resize(this.attach(this.resize)); // Can loop ?
     },
 
     resize: function(overrideHeight) {
@@ -169,8 +171,8 @@ $N.Class.create("Player", $N.Core, {
         }
 
         var elements = this.elements.image
-            .add(this.elements.imageContainer)
-            .add(this.elements.imageCanvas);
+        .add(this.elements.imageContainer)
+        .add(this.elements.imageCanvas);
 
         elements.css('width', 'auto'); // for IE6
 
@@ -200,7 +202,9 @@ $N.Class.create("Player", $N.Core, {
                 offset = marker.offset;
             }
         }
-        this.fire('move', {offset: offset});
+        this.fire('move', {
+            offset: offset
+        });
         return false;
     },
 
@@ -212,7 +216,9 @@ $N.Class.create("Player", $N.Core, {
                 offset = marker.offset;
             }
         }
-        this.fire('move', {offset: offset});
+        this.fire('move', {
+            offset: offset
+        });
         return false;
     },
 
@@ -228,12 +234,14 @@ $N.Class.create("Player", $N.Core, {
 
     _onSetMarker: function() {
         if (this.map) {
-            this.fire('markeradd', {offset: this.soundProvider.getPosition()});
+            this.fire('markeradd', {
+                offset: this.soundProvider.getPosition()
+                });
         }
         return false;
     }
-});
+    });
 
 $N.notifyScriptLoad();
 
-});
+    });
index 5932c431ef3791faca96ca1a118a1b505de0c4b0..7ed9e64f5cff6a3bdcff0ad194b5f5e9fd95b996 100644 (file)
 
 TimeSide(function($N, $J) {
 
-$N.Class.create("Ruler", $N.Core, {
+    $N.Class.create("Ruler", $N.Core, {
 
-    fullSectionDuration: 60,
-    sectionSubDivision: 10,
-    sectionSteps: [[5, 1], [10, 1], [20, 2], [30, 5], [60, 10], [120, 20], [300, 30], 
+        fullSectionDuration: 60,
+        sectionSubDivision: 10,
+        sectionSteps: [[5, 1], [10, 1], [20, 2], [30, 5], [60, 10], [120, 20], [300, 30],
         [600, 60], [1800, 300], [3600, 600]],
-    sectionsNum: 0,
-    timeLabelWidth: 0,
-    pointerPos: 0,
-    layout: null,
-    width: null,
-    mouseDown: false,
-    pointer: null,
-    markers: new Array(),
-    duration: 0,
-    container: null,
-    waveContainer: null,
-
-    initialize: function($super, cfg) {
-        $super();
-        this.configure(cfg, {
-            viewer: [null, 'required'],
-            fontSize: 10,
-            map: null,
-            soundProvider: [null, 'required']
-        });
-        this.cfg.viewer = $J(this.cfg.viewer);
-        this.container = this.cfg.viewer.find('.' + $N.cssPrefix + 'ruler');
-        this.waveContainer = this.cfg.viewer.find('.' + $N.cssPrefix + 'image-canvas');
-        this._setDuration(this.cfg.soundProvider.getDuration());
-        var imgContainer = this.cfg.viewer.find('.' + $N.cssPrefix + 'image-container'); // for IE
-        this._observeMouseEvents(this.waveContainer.add(imgContainer));
-        if (this.cfg.map) {
-            this.cfg.map
+        sectionsNum: 0,
+        timeLabelWidth: 0,
+        pointerPos: 0,
+        layout: null,
+        width: null,
+        mouseDown: false,
+        pointer: null,
+        markers: new Array(),
+        duration: 0,
+        container: null,
+        waveContainer: null,
+
+        initialize: function($super, cfg) {
+            $super();
+            this.configure(cfg, {
+                viewer: [null, 'required'],
+                fontSize: 10,
+                map: null,
+                soundProvider: [null, 'required']
+            });
+            this.cfg.viewer = $J(this.cfg.viewer);
+            this.container = this.cfg.viewer.find('.' + $N.cssPrefix + 'ruler');
+            this.waveContainer = this.cfg.viewer.find('.' + $N.cssPrefix + 'image-canvas');
+            this._setDuration(this.cfg.soundProvider.getDuration());
+            var imgContainer = this.cfg.viewer.find('.' + $N.cssPrefix + 'image-container'); // for IE
+            this._observeMouseEvents(this.waveContainer.add(imgContainer));
+            if (this.cfg.map) {
+                this.cfg.map
                 .observe('add', this.attach(this._onMapAdd))
                 .observe('remove', this.attach(this._onMapRemove))
                 .observe('indexchange', this.attach(this._onMapIndexChange));
-        }
-        this.cfg.soundProvider.observe('update', this.attach(this._onSoundProviderUpdate));
-    },
-
-    free: function($super) {
-        this.layout = null;
-        this.container = null;
-        this.waveContainer = null;
-        this.cfg.viewer = null;
-        $super();
-    },
-
-    _computeLayout: function() {
-        this.width = this.waveContainer.width();
+            }
+            this.cfg.soundProvider.observe('update', this.attach(this._onSoundProviderUpdate));
+        },
+
+        free: function($super) {
+            this.layout = null;
+            this.container = null;
+            this.waveContainer = null;
+            this.cfg.viewer = null;
+            $super();
+        },
+
+        _computeLayout: function() {
+            this.width = this.waveContainer.width();
                 
-        this.debug('container width: ' + this.width);
-        var i, ii = this.sectionSteps.length;
-        this.timeLabelWidth = this._textWidth('00:00', this.cfg.fontSize);
-        for (i = 0; i < ii; i++) {
-            var duration = this.sectionSteps[i][0];
-            var subDivision = this.sectionSteps[i][1];
-            var labelsNum = Math.floor(this.duration / duration);
-            if ((i == ii - 1) || (this.width / labelsNum > this.timeLabelWidth * 2)) {
-                this.fullSectionDuration = duration;
-                this.sectionSubDivision = subDivision;
-                this.sectionsNum = Math.floor(this.duration / this.fullSectionDuration);
-                break;
+            this.debug('container width: ' + this.width);
+            var i, ii = this.sectionSteps.length;
+            this.timeLabelWidth = this._textWidth('00:00', this.cfg.fontSize);
+            for (i = 0; i < ii; i++) {
+                var duration = this.sectionSteps[i][0];
+                var subDivision = this.sectionSteps[i][1];
+                var labelsNum = Math.floor(this.duration / duration);
+                if ((i == ii - 1) || (this.width / labelsNum > this.timeLabelWidth * 2)) {
+                    this.fullSectionDuration = duration;
+                    this.sectionSubDivision = subDivision;
+                    this.sectionsNum = Math.floor(this.duration / this.fullSectionDuration);
+                    break;
+                }
             }
-        }
-    },
+        },
 
-    getUnitDuration: function() {
-        return this.sectionSubDivision;
-    },
+        getUnitDuration: function() {
+            return this.sectionSubDivision;
+        },
 
-    resize: function() {
-        var pointerVisible = this.pointer && this.pointer.isVisible();
-        this._computeLayout();
-        this.draw();
-        if (pointerVisible) {
-            this.setPosition(this.cfg.soundProvider.getPosition());
-            this.setBuffering(this.cfg.soundProvider.isBuffering() && this.cfg.soundProvider.isPlaying());
-            this.pointer.show();
-        }            
-    },
-
-    _setDuration: function(duration) {
-        this.duration = duration;
-        this._computeLayout();
-    },
-
-    setDuration: function(duration) {
-        if (duration == 0)
-            duration = 60;
-        if (this.duration != duration) {
-            this._setDuration(duration);
+        resize: function() {
+            var pointerVisible = this.pointer && this.pointer.isVisible();
+            this._computeLayout();
             this.draw();
-        }
-    },
+            if (pointerVisible) {
+                this.setPosition(this.cfg.soundProvider.getPosition());
+                this.setBuffering(this.cfg.soundProvider.isBuffering() && this.cfg.soundProvider.isPlaying());
+                this.pointer.show();
+            }
+        },
+
+        _setDuration: function(duration) {
+            this.duration = duration;
+            this._computeLayout();
+        },
+
+        setDuration: function(duration) {
+            if (duration == 0)
+                duration = 60;
+            if (this.duration != duration) {
+                this._setDuration(duration);
+                this.draw();
+            }
+        },
 
-    _createSection: function(timeOffset, pixelWidth) {
-        var section = $J('<div/>')
+        _createSection: function(timeOffset, pixelWidth) {
+            var section = $J('<div/>')
             .addClass($N.cssPrefix + 'section')
             .css({
                 fontSize: this.cfg.fontSize + 'px', 
@@ -115,167 +115,179 @@ $N.Class.create("Ruler", $N.Core, {
             })
             .append($J('<div />').addClass($N.cssPrefix + 'canvas'));
 
-        var topDiv = $J('<div/>')
+            var topDiv = $J('<div/>')
             .addClass($N.cssPrefix + 'label')
             .appendTo(section);
-        var bottomDiv = $J('<div/>')
+            var bottomDiv = $J('<div/>')
             .addClass($N.cssPrefix + 'lines')
             .appendTo(section);
-        var empty = $J('<span/>').css({visibility: 'hidden'}).text('&nbsp;');
-        if (pixelWidth > this.timeLabelWidth) {
-            var text = $J('<span/>')
+            var empty = $J('<span/>').css({
+                visibility: 'hidden'
+            }).text('&nbsp;');
+            if (pixelWidth > this.timeLabelWidth) {
+                var text = $J('<span/>')
                 .text($N.Util.makeTimeLabel(timeOffset))
-                .bind('mousedown selectstart', function() {return false;});
-        } else {
-            var text = empty.clone();
-        }
-        topDiv.append(text);
-        bottomDiv.append(empty);
-        return section;
-    },
-
-    _drawSectionRuler: function(section, drawFirstMark) {
-        var j;
-        var jg = new jsGraphics(section.find('.' + $N.cssPrefix + 'canvas').get(0));
-        jg.setColor(this.layout.find('.' + $N.cssPrefix + 'lines').css('color'));
-        var height = section.height();
-        var ypos;
-        for (j = 0; j < section.duration; j += this.sectionSubDivision) {
-            if (j == 0) {
-                if (drawFirstMark) {
-                    ypos = 0;
+                .bind('mousedown selectstart', function() {
+                    return false;
+                });
+            } else {
+                var text = empty.clone();
+            }
+            topDiv.append(text);
+            bottomDiv.append(empty);
+            return section;
+        },
+
+        _drawSectionRuler: function(section, drawFirstMark) {
+            var j;
+            var jg = new jsGraphics(section.find('.' + $N.cssPrefix + 'canvas').get(0));
+            jg.setColor(this.layout.find('.' + $N.cssPrefix + 'lines').css('color'));
+            var height = section.height();
+            var ypos;
+            for (j = 0; j < section.duration; j += this.sectionSubDivision) {
+                if (j == 0) {
+                    if (drawFirstMark) {
+                        ypos = 0;
+                    } else {
+                        continue;
+                    }
                 } else {
-                    continue;
+                    ypos = (j == section.duration / 2) ? 1/2 + 1/8 : 3/4;
                 }
-            } else {
-                ypos = (j == section.duration / 2) ? 1/2 + 1/8 : 3/4;
+                var x = j / this.duration * this.width;
+                jg.drawLine(x, height * ypos, x, height - 1);
             }
-            var x = j / this.duration * this.width;
-            jg.drawLine(x, height * ypos, x, height - 1);
-        }
-        jg.paint();
-    },
+            jg.paint();
+        },
 
-    getHeight: function() {
-        return this.container.find('' + $N.cssPrefix + '.section').height();
-    },
+        getHeight: function() {
+            return this.container.find('' + $N.cssPrefix + '.section').height();
+        },
 
-    draw: function() {
-        if (!this.duration) {
-            this.debug("Can't draw ruler with a duration of 0");
-            return;
-        }
-        this.debug("draw ruler, duration: " + this.duration);
-        if (this.layout)
-            this.layout.remove();
-        this.layout = $J('<div/>')
+        draw: function() {
+            if (!this.duration) {
+                this.debug("Can't draw ruler with a duration of 0");
+                return;
+            }
+            this.debug("draw ruler, duration: " + this.duration);
+            if (this.layout)
+                this.layout.remove();
+            this.layout = $J('<div/>')
             .addClass($N.cssPrefix + 'layout')
-            .css({position: 'relative'}) // bugs on IE when resizing
+            .css({
+                position: 'relative'
+            }) // bugs on IE when resizing
             .bind('dblclick', this.attachWithEvent(this._onDoubleClick))
             //.bind('resize', this.attachWithEvent(this.resize)) // Can loop ?
             .appendTo(this.container);
 
-        //this.container.html(this.layout);
+            //this.container.html(this.layout);
 
-        var sections = new Array();
-        var currentWidth = 0;
-        var i;
-        for (i = 0; i <= this.sectionsNum; i++) {
-            if (i < this.sectionsNum) {
-                var duration = this.fullSectionDuration;
-                var width = Math.floor(duration / this.duration * this.width);
-            } else {
-                var duration = this.duration - i * this.fullSectionDuration;
-                var width = this.width - currentWidth;
+            var sections = new Array();
+            var currentWidth = 0;
+            var i;
+            for (i = 0; i <= this.sectionsNum; i++) {
+                if (i < this.sectionsNum) {
+                    var duration = this.fullSectionDuration;
+                    var width = Math.floor(duration / this.duration * this.width);
+                } else {
+                    var duration = this.duration - i * this.fullSectionDuration;
+                    var width = this.width - currentWidth;
 
-            }               
-            var section = this._createSection(i * this.fullSectionDuration, width);
-            if (i > 0) {
-                section.css({left: currentWidth, top: 0, position: 'absolute'});
+                }
+                var section = this._createSection(i * this.fullSectionDuration, width);
+                if (i > 0) {
+                    section.css({
+                        left: currentWidth,
+                        top: 0,
+                        position: 'absolute'
+                    });
+                }
+                section.duration = duration;
+                this.layout.append(section);
+                currentWidth += section.width();
+                sections[i] = section;
             }
-            section.duration = duration;
-            this.layout.append(section);
-            currentWidth += section.width();
-            sections[i] = section;
-        }
 
-        for (i = 0; i <= this.sectionsNum; i++) {
-            this._drawSectionRuler(sections[i], (i > 0));
-        }
+            for (i = 0; i <= this.sectionsNum; i++) {
+                this._drawSectionRuler(sections[i], (i > 0));
+            }
 
-        this._createPointer();
-        this._drawMarkers();
-    },
+            this._createPointer();
+            this._drawMarkers();
+        },
 
-    _createPointer: function() {
-        if (this.pointer) {
-            this.pointer.clear();
-        }
-        this.pointer = new $N.Marker({
-            rulerLayout: this.layout.get(0),
-            viewer: this.waveContainer,
-            fontSize: this.cfg.fontSize,
-            zIndex: 1000,
-            className: 'pointer',
-            tooltip: 'Move head'
-        });
-        this.pointer
+        _createPointer: function() {
+            if (this.pointer) {
+                this.pointer.clear();
+            }
+            this.pointer = new $N.Marker({
+                rulerLayout: this.layout.get(0),
+                viewer: this.waveContainer,
+                fontSize: this.cfg.fontSize,
+                zIndex: 1000,
+                className: 'pointer',
+                tooltip: 'Move head'
+            });
+            this.pointer
             .setText($N.Util.makeTimeLabel(0))
             .observe('move', this.attach(this._onPointerMove));
-    },
-
-    _drawMarkers: function() {
-        if (this.cfg.map) {
-            $J(this.markers).each(function(i, m) {m.clear();});
-            this.markers = new Array();
-            this.cfg.map.each(this.attach(function(i, m) {
-                this.markers.push(this._drawMarker(m, i));
-            }));
-        }
-    },
+        },
+
+        _drawMarkers: function() {
+            if (this.cfg.map) {
+                $J(this.markers).each(function(i, m) {
+                    m.clear();
+                });
+                this.markers = new Array();
+                this.cfg.map.each(this.attach(function(i, m) {
+                    this.markers.push(this._drawMarker(m, i));
+                }));
+            }
+        },
 
-    _movePointer: function(offset) {
-        if (offset < 0)
-            offset = 0;
-        else if (offset > this.duration)
-            offset = this.duration;
+        _movePointer: function(offset) {
+            if (offset < 0)
+                offset = 0;
+            else if (offset > this.duration)
+                offset = this.duration;
             
-        pixelOffset = offset / this.duration * this.width;
-        if (this.pointer) {
-            this.pointer.move(pixelOffset);
-            this.pointer.setText($N.Util.makeTimeLabel(offset));
-        }            
-        this.pointerPos = offset;
-    },
+            pixelOffset = offset / this.duration * this.width;
+            if (this.pointer) {
+                this.pointer.move(pixelOffset);
+                this.pointer.setText($N.Util.makeTimeLabel(offset));
+            }
+            this.pointerPos = offset;
+        },
 
-    _setPosition: function(offset) {
-        this._movePointer(offset);
-        if (this.pointer) {
-            this.pointer.show();
-        }            
-    },
+        _setPosition: function(offset) {
+            this._movePointer(offset);
+            if (this.pointer) {
+                this.pointer.show();
+            }
+        },
 
-    setPosition: function(offset) {
-        if (!this.mouseDown) {
-            this._setPosition(offset);
-        }
-    },
+        setPosition: function(offset) {
+            if (!this.mouseDown) {
+                this._setPosition(offset);
+            }
+        },
 
-    shiftPosition: function(delta) {
-        this.setPosition(this.pointerPos + delta);
-    },
+        shiftPosition: function(delta) {
+            this.setPosition(this.pointerPos + delta);
+        },
 
-    hidePointer: function() {
-        if (this.pointer)
-            this.pointer.hide();
-    },
+        hidePointer: function() {
+            if (this.pointer)
+                this.pointer.hide();
+        },
 
-    setBuffering: function(state) {
-        if (this.pointer) {
-            this.pointer.blink(state);
-        }
-    },
-/*
+        setBuffering: function(state) {
+            if (this.pointer) {
+                this.pointer.blink(state);
+            }
+        },
+        /*
     _onClick: function(evt) {
         var offset = (evt.pageX - this.container.offset().left) 
             / this.width * this.duration;
@@ -283,116 +295,128 @@ $N.Class.create("Ruler", $N.Core, {
         this.fire('move', {offset: offset});
     },
 */
-    _onMouseDown: function(evt) {
-        this.mouseDown = true;
-        this._onMouseMove(evt);
-        evt.preventDefault();
-    },
-
-    _onPointerMove: function(evt, data) {
-        this.mouseDown = true;
-        this._setPosition(data.offset / this.width * this.duration);
-        if(data.finish) {
-            this.fire('move', {offset: this.pointerPos});
-            this.mouseDown = false;
-        }
-        return false;
-    },
-
-    _onMouseMove: function(evt) {
-        if (this.mouseDown) {
-            var pixelOffset = evt.pageX - this.container.offset().left;
-            this._setPosition(pixelOffset / this.width * this.duration);
+        _onMouseDown: function(evt) {
+            this.mouseDown = true;
+            this._onMouseMove(evt);
+            evt.preventDefault();
+        },
+
+        _onPointerMove: function(evt, data) {
+            this.mouseDown = true;
+            this._setPosition(data.offset / this.width * this.duration);
+            if(data.finish) {
+                this.fire('move', {
+                    offset: this.pointerPos
+                    });
+                this.mouseDown = false;
+            }
             return false;
-        }
-    },
+        },
 
-    _onMouseUp: function(evt) {
-        if (this.mouseDown) {
-            this.mouseDown = false;
-            this.fire('move', {offset: this.pointerPos});
-            return false;
-        }
-    },
+        _onMouseMove: function(evt) {
+            if (this.mouseDown) {
+                var pixelOffset = evt.pageX - this.container.offset().left;
+                this._setPosition(pixelOffset / this.width * this.duration);
+                return false;
+            }
+        },
+
+        _onMouseUp: function(evt) {
+            if (this.mouseDown) {
+                this.mouseDown = false;
+                this.fire('move', {
+                    offset: this.pointerPos
+                    });
+                return false;
+            }
+        },
 
-    _observeMouseEvents: function(element) {
-        element
-            .bind('click dragstart', function() {return false;})
+        _observeMouseEvents: function(element) {
+            element
+            .bind('click dragstart', function() {
+                return false;
+            })
             .bind('mousedown', this.attachWithEvent(this._onMouseDown))
             .bind('mousemove', this.attachWithEvent(this._onMouseMove))
             .bind('mouseup', this.attachWithEvent(this._onMouseUp));
-        $J(document)
+            $J(document)
             .bind('mousemove', this.attachWithEvent(this._onMouseMove));
-    },
+        },
 
-    _drawMarker: function(marker, index) {
-        if (marker.offset < 0)
-            marker.offset = 0;
-        else if (marker.offset > this.duration)
-            marker.offset = this.duration;
+        _drawMarker: function(marker, index) {
+            if (marker.offset < 0){
+                marker.offset = 0;
+            }else if (marker.offset > this.duration){
+                marker.offset = this.duration;
+            }
             
-        pixelOffset = marker.offset / this.duration * this.width;
-
-        m = new $N.Marker({
-            rulerLayout: this.layout.get(0),
-            viewer: this.waveContainer,
-            fontSize: this.cfg.fontSize,
-            className: 'marker',
-            id: marker.id,
-            tooltip: 'Move marker'
-        });
-        m.observe('move', this.attach(this._onMarkerMove))
+            pixelOffset = marker.offset / this.duration * this.width;
+
+            m = new $N.Marker({
+                rulerLayout: this.layout.get(0),
+                viewer: this.waveContainer,
+                fontSize: this.cfg.fontSize,
+                className: 'marker',
+                id: marker.id,
+                tooltip: 'Move marker'
+            });
+            m.observe('move', this.attach(this._onMarkerMove))
             .setText(index + 1)
             .move(pixelOffset)
             .show();
-        return m;
-    },
+            return m;
+        },
+
+        _onMarkerMove: function(e, data) {
+            if (data.finish) {
+                var offset = data.offset / this.width * this.duration;
+                this.fire('markermove', {
+                    id: data.id,
+                    offset: offset
+                });
+            }
+        },
 
-    _onMarkerMove: function(e, data) {
-        if (data.finish) {
-            var offset = data.offset / this.width * this.duration;
-            this.fire('markermove', {id: data.id, offset: offset});
-        }
-    },
+        _onMapAdd: function(e, data) {
+            this.markers.push(this._drawMarker(data.marker, data.index));
+        },
 
-    _onMapAdd: function(e, data) {
-        this.markers.push(this._drawMarker(data.marker, data.index));
-    },
 
+        _onMapRemove: function(e, data) {
+            $J(this.markers).each(this.attach(function(i, m) {
+                if (m.id == data.marker.id) {
+                    m.clear();
+                    this.markers.splice(i, 1);
+                }
+            }));
+        },
 
-    _onMapRemove: function(e, data) {
-        $J(this.markers).each(this.attach(function(i, m) {
-            if (m.id == data.marker.id) {
-                m.clear();
-                this.markers.splice(i, 1);
-            }
-        }));
-    },
+        _onMapIndexChange: function(e, data) {
+            $J(this.markers).each(this.attach(function(i, m) {
+                if (m.id == data.marker.id) {
+                    m.setText(data.index + 1);
+                    return false;
+                }
+            }));
+        },
 
-    _onMapIndexChange: function(e, data) {
-        $J(this.markers).each(this.attach(function(i, m) {
-            if (m.id == data.marker.id) {
-                m.setText(data.index + 1);
-                return false;
+        _onDoubleClick: function(evt) {
+            if (this.cfg.map) {
+                var offset = (evt.pageX - this.container.offset().left)
+                / this.width * this.duration;
+                this.fire('markeradd', {
+                    offset: offset
+                });
             }
-        }));
-    },
+        },
 
-    _onDoubleClick: function(evt) {
-        if (this.cfg.map) {
-            var offset = (evt.pageX - this.container.offset().left) 
-                / this.width * this.duration;
-            this.fire('markeradd', {offset: offset});
+        _onSoundProviderUpdate: function(e) {
+            this.setDuration(this.cfg.soundProvider.getDuration());
+            this.setPosition(this.cfg.soundProvider.getPosition());
+            this.setBuffering(this.cfg.soundProvider.isBuffering() && this.cfg.soundProvider.isPlaying());
         }
-    },
-
-    _onSoundProviderUpdate: function(e) {
-        this.setDuration(this.cfg.soundProvider.getDuration());
-        this.setPosition(this.cfg.soundProvider.getPosition());
-        this.setBuffering(this.cfg.soundProvider.isBuffering() && this.cfg.soundProvider.isPlaying());
-    }
-});
+    });
 
-$N.notifyScriptLoad();
+    $N.notifyScriptLoad();
 
 });
index 95b0f517aaf96397d99695d0d4df4dc1e1e2c1a0..dffefa183c84401660b4cbccb5bb82a851b9d37f 100644 (file)
  * License: GNU General Public License version 2.0
  */
 
-var TimeSide = function() { 
+//this global variable SEEMS to do a check on the variable jQuery, then
+//simply executes the argument (which is a function)
+var TimeSide = function() {
+    //arguments is an array-like object corresponding to the arguments passed to a function
     if (arguments[0]) {
         var toolkit = null;
-        if (typeof jQuery != 'undefined')
+        if (typeof jQuery != 'undefined'){
             toolkit = jQuery;
+        }
+        //call arguments[0] (a function) with arguments this and jQuery
         (arguments[0])(TimeSide, toolkit)
     }
 };
-
+//this is the first function instantiated. It SEEMS to check the document status and
+//load synchronously all the scripts
 TimeSide(function($N, $J) {
 
-$N.isDomLoaded = false;
-$N.isLoaded = false;
-$N.isLoading = false;
-$N.onLoadCallbacks = [];
-$N.cssPrefix = 'ts-';
-$N.debugging = false;
-
-$J(document).ready(function () {
-    $N.isDomLoaded = true;
-});
+    $N.isDomLoaded = false;
+    $N.isLoaded = false;
+    $N.isLoading = false;
+    $N.onLoadCallbacks = [];
+    $N.cssPrefix = 'ts-';
+    $N.debugging = false;
 
-$N.domReady = function(callback) {
-    // simply calling jQuery.ready() *after* the DOM is loaded doesn't work reliably,
-    // at least with jQuery 1.2.6
-    if ($N.isDomLoaded) 
-        callback();
-    else
-        $J(document).ready(callback);
-}
-
-$N.instances = [];
-$N.registerInstance = function(obj) {
-    $N.instances.push(obj);
-}
-
-$N.free = function() {
-    $J($N.instances).each(function(i, obj) {
-        obj.free();
+    $J(document).ready(function () {
+        $N.isDomLoaded = true;
     });
-}
 
-$J(window).unload($N.free);
+    $N.domReady = function(callback) {
+        // simply calling jQuery.ready() *after* the DOM is loaded doesn't work reliably,
+        // at least with jQuery 1.2.6
+        if ($N.isDomLoaded) {
+            callback();
+        } else{
+            $J(document).ready(callback);
+        }
+    }
 
-$N.loadScriptsNum = 0;
-$N.loadScriptsCallback = null;
-$N.loadScripts = function(root, scripts, callback) {
-    if ($N.loadScriptsCallback) {
-        throw "Timeside loader error: concurrent script loading";
+    $N.instances = [];
+    $N.registerInstance = function(obj) {
+        $N.instances.push(obj);
     }
 
-    $N.loadScriptsNum = scripts.length;
-    $N.loadScriptsCallback = callback;
+    $N.free = function() {
+        $J($N.instances).each(function(i, obj) {
+            obj.free();
+        });
+    }
+
+    $J(window).unload($N.free);
+
+    $N.loadScriptsNum = 0;
+    $N.loadScriptsCallback = null;
+    $N.loadScripts = function(root, scripts, callback) {
+        if ($N.loadScriptsCallback) {
+            throw "Timeside loader error: concurrent script loading";
+        }
+
+        $N.loadScriptsNum = scripts.length;
+        $N.loadScriptsCallback = callback;
 
-    var head= document.getElementsByTagName('head')[0];
-    for (i = 0; i < scripts.length; i++) {
+        var head= document.getElementsByTagName('head')[0];
+        for (i = 0; i < scripts.length; i++) {
 
-        var script = document.createElement('script');
-        script.type = 'text/javascript';
-        var debug = $N.debugging ? '?rand=' + Math.random() : '';
-        script.src = root + scripts[i] + debug;
-        head.appendChild(script);
+            var script = document.createElement('script');
+            script.type = 'text/javascript';
+            var debug = $N.debugging ? '?rand=' + Math.random() : '';
+            script.src = root + scripts[i] + debug;
+            head.appendChild(script);
+        }
     }
-}
 
-$N.notifyScriptLoad = function() {
-    if (--$N.loadScriptsNum == 0 && $N.loadScriptsCallback) {
-        var callback = $N.loadScriptsCallback;
-        $N.loadScriptsCallback = null;
-        callback();
+    $N.notifyScriptLoad = function() {
+        if (--$N.loadScriptsNum == 0 && $N.loadScriptsCallback) {
+            var callback = $N.loadScriptsCallback;
+            $N.loadScriptsCallback = null;
+            callback();
+        }
     }
-}
-
-$N.debug = function(state) {
-    $N.debugging = state;
-}
-
-$N.load = function(callback) {
-    $N.domReady(function() {
-        if ($N.isLoaded) {
-            if (callback) 
-                callback();
-        } else {
-            if (callback) 
-                $N.onLoadCallbacks.push(callback);
-
-            if (!$N.isLoading) {
-                $N.isLoading = true;
-                var re = /(.*)timeside.js/;
-                var root = '';
-                $J('head script').each(function(i, e) {
-                    if (match = re.exec(e.src)) {
-                        root = match[1];
-                    }
-                });
-
-                $N.loadScripts(root, ['core.js'], function() {
-                    $N.loadScripts(root, ['util.js'], function() {
-                        var scripts = ['controller.js', 'marker.js', 'markerlist.js', 
-                                       'markermap.js', 'player.js', 'ruler.js', 
-                                       'soundprovider.js'];
+
+    $N.debug = function(state) {
+        $N.debugging = state;
+    }
+
+    $N.load = function(callback) {
+        $N.domReady(function() {
+            if ($N.isLoaded) {
+                if (callback)
+                    callback();
+            } else {
+                if (callback)
+                    $N.onLoadCallbacks.push(callback);
+
+                if (!$N.isLoading) {
+                    $N.isLoading = true;
+                    var re = /(.*)timeside.js/;
+                    var root = '';
+                    $J('head script').each(function(i, e) {
+                        if ((match = re.exec(e.src))) {
+                            root = match[1];
+                        }
+                    });
+
+                    $N.loadScripts(root, ['core.js'], function() {
+                        $N.loadScripts(root, ['util.js'], function() {
+                            var scripts = ['controller.js', 'marker.js', 'markerlist.js',
+                            'markermap.js', 'player.js', 'ruler.js',
+                            'soundprovider.js'];
                                                        
-                        $N.loadScripts(root, scripts, function() {
-                            $N.isLoaded = true;
-                            $N.isLoading = false;
-                            $J($N.onLoadCallbacks).each(function(i, callback) {
-                                callback();
+                            $N.loadScripts(root, scripts, function() {
+                                $N.isLoaded = true;
+                                $N.isLoading = false;
+                                $J($N.onLoadCallbacks).each(function(i, callback) {
+                                    callback();
+                                });
                             });
                         });
                     });
-                });
+                }
             }
-        }
-    });
-}
+        });
+    }
 
 });
index 188bd537b8da3955f506b0f4713e04408fc25dfd..974b6b181498570b71ccc54e2cfdfbeec55e2311 100644 (file)
@@ -7,23 +7,23 @@
 {% block stylesheets %}\r
 {{ block.super }}\r
 <link rel="stylesheet" type="text/css" href="{% url telemeta-timeside "css/timeside.css" %}" />\r
-<link rel="stylesheet" type="text/css" href="{% url telemeta-timeside "skins/lab/style.css" %}" />\r
-<link rel="stylesheet" type="text/css" href="{% url telemeta-css "player.css" %}" />\r
-{% endblock %}\r
-{% block extra_javascript %}\r
+      <link rel="stylesheet" type="text/css" href="{% url telemeta-timeside "skins/lab/style.css" %}" />\r
+      <link rel="stylesheet" type="text/css" href="{% url telemeta-css "player.css" %}" />\r
+      {% endblock %}\r
+      {% block extra_javascript %}\r
 \r
 <script src="{% url telemeta-js "wz_jsgraphics.js" %}" type="text/javascript"></script>\r
 <script src="{% url telemeta-js "soundmanager2.js" %}" type="text/javascript"></script>\r
 <script src="{% url telemeta-timeside "src/timeside.js" %}" type="text/javascript"></script>\r
-<script src="{% url telemeta-js "player.js" %}" type="text/javascript"></script>\r
+<script src="{% url telemeta-js "playerUtils.js" %}" type="text/javascript"></script>\r
 \r
 <script type="text/javascript">\r
-soundManager.url = '{% url telemeta-swf "./" %}';\r
-soundManager.flashVersion = 9;\r
-soundManager.useMovieStar = true; // enable MP4/M4A/AAC\r
-soundManager.debugMode = false;\r
-set_player_image_url('{% url telemeta-item-visualize item.public_id,visualizer_id,"WIDTH","HEIGHT" %}');\r
-load_player({{ item.approx_duration.as_seconds }});\r
+    soundManager.url = '{% url telemeta-swf "./" %}';\r
+    soundManager.flashVersion = 9;\r
+    soundManager.useMovieStar = true; // enable MP4/M4A/AAC\r
+    soundManager.debugMode = false;\r
+    set_player_image_url('{% url telemeta-item-visualize item.public_id,visualizer_id,"WIDTH","HEIGHT" %}');\r
+    load_player({{ item.approx_duration.as_seconds }});\r
 </script>\r
 \r
 {% endblock %}\r
@@ -31,10 +31,10 @@ load_player({{ item.approx_duration.as_seconds }});
 \r
 {% if item %}\r
 {% block submenu %}\r
-    <div>\r
+<div>\r
     <a href="{% url telemeta-item-detail-edit item.public_id %}"><button>EDIT</button></a>\r
     <a href="{% url telemeta-item-dublincore item.public_id %}">Dublin Core</a>\r
-    </div>\r
+</div>\r
 {% endblock %}\r
 \r
 {% block content %}\r
@@ -42,31 +42,33 @@ load_player({{ item.approx_duration.as_seconds }});
 <h3>Item : {{ item }}</h3>\r
 <div class="{% if item.file %}with-rightcol{% endif %}">\r
 \r
-{% if item.file %}\r
+    {% if item.file %}\r
     <div id="player_maximized" class="ts-skin-lab">\r
         <a href="#" class="toggle">Minimize</a>\r
         <div class="wazing"></div>\r
     </div>\r
     <div id="rightcol">\r
         <div id="player_minimized" class="ts-skin-lab">\r
-        <a href="#" class="toggle">Maximize</a>\r
-        <div class="wazing"></div>\r
-        <div id="player" class="ts-player">\r
-            <div class="ts-viewer">\r
-                <div class="ts-wave">\r
-                    <div class="ts-image-container">\r
-                        <a href="{% url telemeta-item-export item.public_id,"mp3" %}">\r
-                        <img class="ts-image" src="{% url telemeta-item-visualize item.public_id,visualizer_id,360,130 %}"\r
-                          alt="" /></a>\r
+            <a href="#" class="toggle">Maximize</a>\r
+            <div class="wazing"></div>\r
+            <div id="player" class="ts-player">\r
+                <div class="ts-viewer">\r
+                    <div class="ts-wave">\r
+                        <div class="ts-image-container">\r
+                            <a href="{% url telemeta-item-export item.public_id,"mp3" %}">\r
+                               <img class="ts-image" src="{% url telemeta-item-visualize item.public_id,visualizer_id,360,130 %}"\r
+                                 alt="" /></a>\r
+                        </div>\r
                     </div>\r
                 </div>\r
             </div>\r
         </div>\r
-        </div>\r
\r
+\r
         <div class="markers_div" id="markers_div_id"></div>\r
         <div id="item_edit">\r
-            <div class="item_visualization">\r
+            <div class="item_visualization" id="item_markers_id">\r
+            </div>\r
+            <div class="item_visualization" id="item_visualization_id">\r
                 <form id="visualizer_id_form" method="get" action="#">\r
                     <!--\r
                     <select name="visualizer_id" onchange="this.form.submit()">\r
@@ -124,17 +126,17 @@ load_player({{ item.approx_duration.as_seconds }});
         {% if audio_export_enabled %}\r
         <div class="exporter">\r
             <p>{% trans "Download:" %}\r
-            {% for format in export_formats %}\r
-            <a href="{% url telemeta-item-export item.public_id,format.extension %}">{{ format.name }}</a>\r
-            {% endfor %}</p>\r
+                {% for format in export_formats %}\r
+                <a href="{% url telemeta-item-export item.public_id,format.extension %}">{{ format.name }}</a>\r
+                {% endfor %}</p>\r
         </div>\r
         {% endif %}\r
 \r
     </div>\r
-{% endif %}\r
+    {% endif %}\r
 \r
     <div class="infos">\r
-    {% block general_info %}\r
+        {% block general_info %}\r
         <dl class="listing">\r
             {% dl_field item "title" %}\r
             {% dl_field item "alt_title" %}\r
@@ -142,20 +144,20 @@ load_player({{ item.approx_duration.as_seconds }});
             <dt>{% field_label item "collection" %}</dt>\r
             <dd><a href="{% url telemeta-collection-detail item.collection.public_id %}">{{ item.collection }}</a></dd>\r
             {% if item.recorded_from_date %}\r
-                <dt>{% trans "Recording date" %}</dt>\r
-                <dd>{{ item.recorded_from_date }} {{ item.recorded_to_date|prepend:" - "  }}</dd>\r
+            <dt>{% trans "Recording date" %}</dt>\r
+            <dd>{{ item.recorded_from_date }} {{ item.recorded_to_date|prepend:" - "  }}</dd>\r
             {% endif %}\r
         </dl>\r
-    {% endblock general_info %}\r
+        {% endblock general_info %}\r
     </div>\r
     <div class="extraInfos">\r
-    {% block geoethnic_data %}\r
+        {% block geoethnic_data %}\r
         <div>\r
             <h4><a href="#">{% trans "Geographic and cultural informations" %}</a></h4>\r
             <dl class="listing">\r
                 {% if item.location %}\r
-                    <dt>{% trans "Location" %}</dt>\r
-                    <dd>{{ item.location.fullnames|join:"<br/>" }}</dd>\r
+                <dt>{% trans "Location" %}</dt>\r
+                <dd>{{ item.location.fullnames|join:"<br/>" }}</dd>\r
                 {% endif %}\r
                 {% dl_field item "location_comment" %}\r
                 {% dl_field item "cultural_area" %}\r
@@ -164,10 +166,10 @@ load_player({{ item.approx_duration.as_seconds }});
                 {% dl_field item "keywords" join with ", " %}\r
             </dl>\r
         </div>\r
-    {% endblock geoethnic_data %}\r
+        {% endblock geoethnic_data %}\r
     </div>\r
     <div class="extraInfos">\r
-    {% block musical_data %}\r
+        {% block musical_data %}\r
         <div>\r
             <h4><a href="#">{% trans "Musical informations" %}</a></h4>\r
             <dl class="listing">\r
@@ -178,32 +180,32 @@ load_player({{ item.approx_duration.as_seconds }});
             {% if item.performances %}\r
             <div class="instruments">\r
                 <table class="instruments">\r
-                <thead>\r
-                    <tr>\r
-                        <td>{% field_label "MediaItemPerformance" "instruments_num" %}</td>\r
-                        <td>{% field_label "MediaItemPerformance" "instrument" %}</td>\r
-                        <td>{% field_label "MediaItemPerformance" "alias" %}</td>\r
-                        <td>{% field_label "MediaItemPerformance" "musicians" %}</td>\r
-                    </tr>\r
-                </thead>\r
-                <tbody>\r
-                    {% for performance in item.performances.all %}\r
-                    <tr>\r
-                        <td>{{ performance.instruments_num }}</td>\r
-                        <td>{{ performance.instrument|default:"" }}</td>\r
-                        <td>{{ performance.alias|default:"" }}</td>\r
-                        <td>{{ performance.musicians }}</td>\r
-                    </tr>\r
-                    {% endfor %}\r
-                </tbody>\r
+                    <thead>\r
+                        <tr>\r
+                            <td>{% field_label "MediaItemPerformance" "instruments_num" %}</td>\r
+                            <td>{% field_label "MediaItemPerformance" "instrument" %}</td>\r
+                            <td>{% field_label "MediaItemPerformance" "alias" %}</td>\r
+                            <td>{% field_label "MediaItemPerformance" "musicians" %}</td>\r
+                        </tr>\r
+                    </thead>\r
+                    <tbody>\r
+                        {% for performance in item.performances.all %}\r
+                        <tr>\r
+                            <td>{{ performance.instruments_num }}</td>\r
+                            <td>{{ performance.instrument|default:"" }}</td>\r
+                            <td>{{ performance.alias|default:"" }}</td>\r
+                            <td>{{ performance.musicians }}</td>\r
+                        </tr>\r
+                        {% endfor %}\r
+                    </tbody>\r
                 </table>\r
             </div>\r
             {% endif %}\r
         </div>\r
-    {% endblock musical_data %}\r
+        {% endblock musical_data %}\r
     </div>\r
     <div class="extraInfos">\r
-    {% block general_data %}\r
+        {% block general_data %}\r
         <div>\r
             <h4><a href="#">{% trans "General informations" %}</a></h4>\r
             <dl class="listing">\r
@@ -211,10 +213,10 @@ load_player({{ item.approx_duration.as_seconds }});
                 {% dl_field item "collector_selection" %}\r
             </dl>\r
         </div>\r
-    {% endblock general_data %}\r
+        {% endblock general_data %}\r
     </div>\r
     <div class="extraInfos">\r
-    {% block archive_data %}\r
+        {% block archive_data %}\r
         <div>\r
             <h4><a href="#">{% trans "Archiving data" %}</a></h4>\r
             <dl class="listing">\r
@@ -226,10 +228,10 @@ load_player({{ item.approx_duration.as_seconds }});
                 {% dl_field item "public_access_label" %}\r
             </dl>\r
         </div>\r
-    {% endblock archive_data %}\r
+        {% endblock archive_data %}\r
     </div>\r
     <div class="extraInfos">\r
-    {% block technical_data %}\r
+        {% block technical_data %}\r
         <div>\r
             <h4><a href="#">{% trans "Technical data" %}</a></h4>\r
             <div>\r
@@ -239,12 +241,12 @@ load_player({{ item.approx_duration.as_seconds }});
                 </dl>\r
             </div>\r
         </div>\r
-    {% endblock technical_data %}\r
+        {% endblock technical_data %}\r
     </div>\r
 \r
 </div> <!-- with-rightcol -->\r
 \r
 {% endblock %}\r
 {% else %}\r
-    <p>No such item</p>\r
+<p>No such item</p>\r
 {% endif %}\r