]> git.parisson.com Git - telemeta.git/commitdiff
fixed cleartimeout in popup automatic close
authorriccardo <riccardo@parisson.com>
Tue, 7 Jun 2011 11:54:15 +0000 (13:54 +0200)
committerriccardo <riccardo@parisson.com>
Tue, 7 Jun 2011 11:54:15 +0000 (13:54 +0200)
telemeta/htdocs/js/playerLoader.js
telemeta/htdocs/js/popupdiv.js
telemeta/templates/telemeta_default/mediaitem_detail.html

index 78de7ace6a258696866591b82569359c2bc50c3a..d530364f5032cbf5b90309d7902692e8d97de304 100644 (file)
@@ -56,27 +56,32 @@ function togglePlayerMaximization() {
     }
 }
 
-//end(''): clears loading span, if any
-//end('msg') if loading span is there, clear loading span. If loading span is there, display alert msg
 
-function end(optionalErrorMsg){
-    var $ = jQuery;
-    $(window).ready(function(){
-        var elm = $('#loading_span');
-        if(elm.length<1){
-            return;
-        }
-        elm.empty().remove();
-        if(optionalErrorMsg){
-            $('#rightcol').hide();
-            alert(optionalErrorMsg);
-        }
-    });
-}
 
 function loadPlayer(analizerUrl, soundUrl, itemId, visualizers, currentUserName, isStaffOrSuperuser){
     var $J = jQuery;
     var wdw = window;
+
+
+    //end(''): clears loading span, if any
+    //end('msg') if loading span is there, clear loading span. If loading span is there, display alert msg
+
+    function end(optionalErrorMsg){
+        //var $J = jQuery;
+        $J(wdw).ready(function(){
+            var elm = $J('#loading_span');
+            if(elm.length<1){
+                return;
+            }
+            elm.empty().remove();
+            if(optionalErrorMsg){
+                $J('#rightcol').hide();
+                alert(optionalErrorMsg);
+            }
+        });
+    }
+
+
     //grab the case of soundManager init errors:
     soundManager.onerror = function() {
         end('SoundManager error. If your browser does not support HTML5, Flash player (version '+soundManager.flashVersion+'+) must be installed.\nIf flash is installed, try to:\n - Reload the page\n - Empty the cache (see browser preferences/options/tools) and reload the page\n - Restart the browser');
@@ -373,17 +378,24 @@ function loadPlayer(analizerUrl, soundUrl, itemId, visualizers, currentUserName,
                             invoker: player.getContainer().find('.ts-wave'),
                             defaultCloseOperation: 'hide'
                         });
+                        var closeTimeout = undefined;
+                        var ci = clearTimeout;
                         player.bind('markerCrossed',function(data){
+                            if(closeTimeout !== undefined){
+                                cl(closeTimeout);
+                            }
+                            closeTimeout=undefined;
                             popupdiv.refresh(data.marker.desc,data.marker.title);
+                            if(!popupdiv.isShowing()){
+                                popupdiv.show();
+                            }
                             var index = data.index;
                             if(index+1 == map.length || map.toArray()[index+1].offset-data.marker.offset>3){
-                                popupdiv.closeLater(3000);
+                                closeTimeout = popupdiv.setTimeout('close',3000);
                             }
                             //consolelog('firing markercrossed');
                             //consolelog(data.marker.title);
-                            if(!popupdiv.isShowing()){
-                                popupdiv.show();
-                            }
+                            
                         });
                     }
 
index 50b46888fe7a4486cd388a0941d326a651b5689b..ad5c39b416ac7fbe7f44ba6bf6d172544eef484d 100644 (file)
@@ -612,16 +612,16 @@ function PopupDiv(){
         //set title and close button to span whole width, if necessary\r
         //closeButton.outerWidth should be zero if this.showClose = false\r
         //titleInput.outerWidth(true) should be equal to titleInput.width(), as margins borders and padding are zero, however we want to calculate it safely\r
-//        if(this.showClose || this.title){\r
-//            var topDiv = this.getDiv().children().eq(0);\r
-//            var closeBtn = topDiv.find('a').eq(0);\r
-//            var titleInput = topDiv.find(':text').eq(0);\r
-//            var titleW = topDiv.width() - closeBtn.outerWidth(true) - (titleInput.outerWidth(true)-titleInput.width());\r
-//            titleInput.css({\r
-//                'maxWidth':'',\r
-//                'width':(titleW)+'px'\r
-//            });\r
-//        }\r
+        //        if(this.showClose || this.title){\r
+        //            var topDiv = this.getDiv().children().eq(0);\r
+        //            var closeBtn = topDiv.find('a').eq(0);\r
+        //            var titleInput = topDiv.find(':text').eq(0);\r
+        //            var titleW = topDiv.width() - closeBtn.outerWidth(true) - (titleInput.outerWidth(true)-titleInput.width());\r
+        //            titleInput.css({\r
+        //                'maxWidth':'',\r
+        //                'width':(titleW)+'px'\r
+        //            });\r
+        //        }\r
 \r
         this.shadow(); //updates shadow\r
         if(focusable){\r
@@ -644,16 +644,16 @@ function PopupDiv(){
             node.nodeValue = title;\r
         }\r
 \r
-//        var titleIpt = subdiv.find(':text').hide();\r
-//        var titleSpan = subdiv.find('span').css({'display':'inline-block','float':'left'});\r
-//        if(title){\r
-//            titleSpan.html(title);\r
-//        }else{\r
-//            titleSpan.hide();\r
-//        }\r
-//        var titleSpanWidth = titleSpan.html(title).width();\r
-//        titleIpt.val(title).css('width',titleSpanWidth+'px');\r
-//        titleSpan.html('').css('display','none');\r
+    //        var titleIpt = subdiv.find(':text').hide();\r
+    //        var titleSpan = subdiv.find('span').css({'display':'inline-block','float':'left'});\r
+    //        if(title){\r
+    //            titleSpan.html(title);\r
+    //        }else{\r
+    //            titleSpan.hide();\r
+    //        }\r
+    //        var titleSpanWidth = titleSpan.html(title).width();\r
+    //        titleIpt.val(title).css('width',titleSpanWidth+'px');\r
+    //        titleSpan.html('').css('display','none');\r
     }\r
 \r
     p.isShowing = function(){\r
@@ -714,7 +714,8 @@ function PopupDiv(){
 \r
             if(this.showClose){\r
                 closeBtn.css('marginLeft','0.5em').attr('class',this.closeButtonClass).html(this.closeButtonTitle).css({\r
-                    'display':'inline-block','float':'right'\r
+                    'display':'inline-block',\r
+                    'float':'right'\r
                 //warning: do NOT use real numbers such as 0.5ex cause browsers round it in a different manner\r
                 //inline-block in order to retrieve/set width and height on the element\r
                 });\r
@@ -722,17 +723,17 @@ function PopupDiv(){
                 closeBtn.hide(); //margin:0 is to be sure, as afterwards we must span the title the whole popup width\r
             }\r
             //in any case, show titleElement cause even if title="", titleElement is used to position close on the right\r
-//            titleInput.css({\r
-//                'backgroundColor':'transparent',\r
-//                'padding': '0px',\r
-//                'margin':'0px',\r
-//                'border':'0px'\r
-//            }).attr('readonly','readonly').attr('class',this.titleClass).css({\r
-//                'display':'inline-block','float':'left'\r
-//            //it is too tricky to set the width of the input spanning the whole title (in case of long titles)\r
-//            //we experienced problems in vertical align with the close button, as stated somewhere above.\r
-//            //we will use a span (see setTitle below)\r
-//            });\r
+            //            titleInput.css({\r
+            //                'backgroundColor':'transparent',\r
+            //                'padding': '0px',\r
+            //                'margin':'0px',\r
+            //                'border':'0px'\r
+            //            }).attr('readonly','readonly').attr('class',this.titleClass).css({\r
+            //                'display':'inline-block','float':'left'\r
+            //            //it is too tricky to set the width of the input spanning the whole title (in case of long titles)\r
+            //            //we experienced problems in vertical align with the close button, as stated somewhere above.\r
+            //            //we will use a span (see setTitle below)\r
+            //            });\r
             this.setTitle(this.title);\r
         }\r
 \r
@@ -755,18 +756,18 @@ function PopupDiv(){
             bottomDiv.hide();\r
         }\r
 \r
-//        var centralDiv = $(subdiv[1]);\r
-//        //reset properties of the central div\r
-//        centralDiv.css({\r
-//            'overflow':'auto',\r
-//            'maxHeight':'',\r
-//            'maxWidth':'',\r
-//            'minHeight':'',\r
-//            'minWidth':'',\r
-//            'height':'',\r
-//            'width':'',\r
-//            'visibility':'visible'\r
-//        }).show();\r
+        //        var centralDiv = $(subdiv[1]);\r
+        //        //reset properties of the central div\r
+        //        centralDiv.css({\r
+        //            'overflow':'auto',\r
+        //            'maxHeight':'',\r
+        //            'maxWidth':'',\r
+        //            'minHeight':'',\r
+        //            'minWidth':'',\r
+        //            'height':'',\r
+        //            'width':'',\r
+        //            'visibility':'visible'\r
+        //        }).show();\r
 \r
 \r
         var invoker = this.invoker;\r
@@ -806,31 +807,31 @@ function PopupDiv(){
             this.setBoundsInside(invoker, this.bounds, this.boundsExact, true);\r
         }\r
 \r
-//        //set title and close button to span whole width, if necessary\r
-//        //closeButton.outerWidth should be zero if this.showClose = false\r
-//        //titleInput.outerWidth(true) should be equal to titleInput.width(), as margins borders and padding are zero, however we want to calculate it safely\r
-//        if(this.showClose || this.title){\r
-//            var titleW = topDiv.width() - closeBtn.outerWidth(true) - (titleInput.outerWidth(true)-titleInput.width());\r
-//            titleInput.css({\r
-//                'maxWidth':'',\r
-//                'width':(titleW)+'px'\r
-//            });\r
-//        }\r
-//\r
-//        //set central div max height ONLY IF NECESSARY (overflow). Until here, the main popup is sized and placed\r
-//        //but the central div might overflow\r
-//        var height = centralDiv.height();\r
-//        var maxHeight = (div.height()-topDiv.outerHeight(true)-bottomDiv.outerHeight(true)-\r
-//            (centralDiv.outerHeight(true)-centralDiv.height()));\r
-//        if(maxHeight<height){\r
-//            centralDiv.css('maxHeight',maxHeight+'px');\r
-//        }\r
-//        //same for width:\r
-//        var maxWidth = div.width();\r
-//        var width = centralDiv.outerWidth(true);\r
-//        if(maxWidth<width){\r
-//            centralDiv.css('maxWidth',maxWidth+'px');\r
-//        }\r
+        //        //set title and close button to span whole width, if necessary\r
+        //        //closeButton.outerWidth should be zero if this.showClose = false\r
+        //        //titleInput.outerWidth(true) should be equal to titleInput.width(), as margins borders and padding are zero, however we want to calculate it safely\r
+        //        if(this.showClose || this.title){\r
+        //            var titleW = topDiv.width() - closeBtn.outerWidth(true) - (titleInput.outerWidth(true)-titleInput.width());\r
+        //            titleInput.css({\r
+        //                'maxWidth':'',\r
+        //                'width':(titleW)+'px'\r
+        //            });\r
+        //        }\r
+        //\r
+        //        //set central div max height ONLY IF NECESSARY (overflow). Until here, the main popup is sized and placed\r
+        //        //but the central div might overflow\r
+        //        var height = centralDiv.height();\r
+        //        var maxHeight = (div.height()-topDiv.outerHeight(true)-bottomDiv.outerHeight(true)-\r
+        //            (centralDiv.outerHeight(true)-centralDiv.height()));\r
+        //        if(maxHeight<height){\r
+        //            centralDiv.css('maxHeight',maxHeight+'px');\r
+        //        }\r
+        //        //same for width:\r
+        //        var maxWidth = div.width();\r
+        //        var width = centralDiv.outerWidth(true);\r
+        //        if(maxWidth<width){\r
+        //            centralDiv.css('maxWidth',maxWidth+'px');\r
+        //        }\r
 \r
        \r
 \r
@@ -888,7 +889,7 @@ function PopupDiv(){
         isSizable = true;\r
 \r
         var div = this.getDiv();\r
-//        var oldCss= isSizable ?  undefined : this.setSizable();\r
+        //        var oldCss= isSizable ?  undefined : this.setSizable();\r
 \r
         var shadowOffset = this.shadowOffset;\r
         var windowRectangle = this.getBoundsOf(wdw); //returns the window rectangle\r
@@ -930,12 +931,12 @@ function PopupDiv(){
 \r
         this.postSizeFcn();\r
 \r
-//        if(oldCss){\r
-//            div.css({\r
-//                'display':oldCss['display'],\r
-//                'visibility':oldCss['visibility']\r
-//            });\r
-//        }\r
+    //        if(oldCss){\r
+    //            div.css({\r
+    //                'display':oldCss['display'],\r
+    //                'visibility':oldCss['visibility']\r
+    //            });\r
+    //        }\r
 \r
     };\r
     //places and resize the popupdiv inside parent\r
@@ -946,7 +947,7 @@ function PopupDiv(){
     p.setBoundsInside = function(parent, pd, boundsExact, isSizable){\r
 \r
         var div = this.getDiv();\r
-//        var oldCss = isSizable ?  undefined : this.setSizable();\r
+        //        var oldCss = isSizable ?  undefined : this.setSizable();\r
         \r
         this.preSizeFcn();\r
         isSizable = true;\r
@@ -1019,12 +1020,12 @@ function PopupDiv(){
 \r
         this.postSizeFcn();\r
 \r
-//        if(oldCss){\r
-//            div.css({\r
-//                'display':oldCss['display'],\r
-//                'visibility':oldCss['visibility']\r
-//            });\r
-//        }\r
+    //        if(oldCss){\r
+    //            div.css({\r
+    //                'display':oldCss['display'],\r
+    //                'visibility':oldCss['visibility']\r
+    //            });\r
+    //        }\r
     };\r
     p.preSizeFcn = function(){\r
         this.setSizable();\r
@@ -1060,16 +1061,16 @@ function PopupDiv(){
         //we must set a width:100% on the topDiv in order to stretch the whole HEIGHT (having two elements inside it with float:left and right)\r
         //however, we might have here a width LOWER than the actual div width, so stretch it more if it's lower:\r
         \r
-//        if(this.showClose || this.title){\r
-//            var closeBtn = topDiv.find('a').eq(0);\r
-//            var titleInput = topDiv.find(':text').eq(0);\r
-//            var span = topDiv.find('span').eq(0).hide();\r
-//            var titleW = topDiv.width() - closeBtn.outerWidth(true) - (titleInput.outerWidth(true)-titleInput.width());\r
-//            titleInput.html(span.html()).css({\r
-//                'maxWidth':'',\r
-//                'width':(titleW)+'px'\r
-//            });\r
-//        }\r
+        //        if(this.showClose || this.title){\r
+        //            var closeBtn = topDiv.find('a').eq(0);\r
+        //            var titleInput = topDiv.find(':text').eq(0);\r
+        //            var span = topDiv.find('span').eq(0).hide();\r
+        //            var titleW = topDiv.width() - closeBtn.outerWidth(true) - (titleInput.outerWidth(true)-titleInput.width());\r
+        //            titleInput.html(span.html()).css({\r
+        //                'maxWidth':'',\r
+        //                'width':(titleW)+'px'\r
+        //            });\r
+        //        }\r
 \r
         var topBottom = $([]);\r
         if(this.showClose || this.title){\r
@@ -1078,7 +1079,10 @@ function PopupDiv(){
         if(this.showOk){\r
             topBottom = topBottom.add(subdivs.eq(2));\r
         }\r
-        topBottom.css({'overflow':'hidden', 'width':'100%'}); //to span the whole width\r
+        topBottom.css({\r
+            'overflow':'hidden',\r
+            'width':'100%'\r
+        }); //to span the whole width\r
 \r
 \r
         var centralDiv = subdivs.eq(1);\r
@@ -1250,11 +1254,20 @@ function PopupDiv(){
 \r
     };\r
 \r
-    p.closeLater = function(millseconds){\r
+    //sets a t=timeout and returns t. eventName can be 'show' or 'close'\r
+    p.setTimeout = function(eventName, millseconds){\r
         var me = this;\r
-        setTimeout(function(){\r
-            me.close();\r
-        },millseconds);\r
+        var t=undefined;\r
+        if(eventName == 'show'){\r
+            t=setTimeout(function(){\r
+                me.show();\r
+            },millseconds);\r
+        }else if(eventName == 'close'){\r
+            t=setTimeout(function(){\r
+                me.close();\r
+            },millseconds);\r
+        }\r
+        return t;\r
     },\r
 \r
     p.setSizable = function(){\r
index f08f9e460a0f64a7b53b6883bdaa92cbf4168057..22855d0da29d728b0748385041ab27befd8b4111 100644 (file)
@@ -61,7 +61,6 @@
     loadPlayer('{% url telemeta-item-analyze-xml item.public_id %}',
     "{% url telemeta-item-export item.public_id,"mp3" %}", '{{item.id}}', visualizers, CURRENT_USER_NAME, superuser);
 
-    var g = 9;
 </script>
 {% endif %}
 {% endblock %}