]> git.parisson.com Git - telemeta.git/commitdiff
fixed popupdiv bugs (repositioning) and pointer mouse events
authorriccardo <riccardo@parisson.com>
Tue, 21 Jun 2011 11:21:33 +0000 (13:21 +0200)
committerriccardo <riccardo@parisson.com>
Tue, 21 Jun 2011 11:21:33 +0000 (13:21 +0200)
telemeta/htdocs/css/telemeta.css
telemeta/htdocs/js/playerLoader.js
telemeta/htdocs/js/popupdiv.js
telemeta/htdocs/timeside/js/player.js
telemeta/htdocs/timeside/js/ruler.js

index 3ff8bc2abd1a63b8c80821f78e9526b1fc41ca29..dcf3d59265dacb61cf8d8be07de741623add2c15 100644 (file)
@@ -1167,7 +1167,7 @@ a.image-link {
 /*focus on elements*/
 a:focus,div:focus{
     -moz-outline: 1px dotted #999  !important;
-    outline: #999 dotted 1px  !important;
+    outline: #999 dotted 1px;  /*!important;*/
 }
 input,textarea{
     outline: none !important;
index 33c2f0324333ddc18b96f0e923d34f7e10d5d0ef..3606cfe34ef513c6fd5da7bcd955afaaae0ca3e5 100644 (file)
@@ -371,9 +371,11 @@ function loadPlayer(analizerUrl, soundUrl, soundImgSize, itemId, visualizers, cu
                         //a number N means: popup stays maximum N seconds on the screen
                         if(POPUP_TIMEOUT){
                             var popupdiv = new PopupDiv({
-                                focusable: false,
+                                focusable: true,
                                 titleClass: 'markersdivTitle',
-                                showClose:true,
+                                //showClose:true,
+
+                                //boundsExact:true,
                                 bounds: {
                                     top:0.4,
                                     left:0.1,
@@ -430,31 +432,45 @@ function loadPlayer(analizerUrl, soundUrl, soundImgSize, itemId, visualizers, cu
                                 //consolelog(data.marker.title);
                             
                                 });
-                                //now bind mouse events
-                                player.bind('markerMouseEvent', function(data){
-                                    if(data.index<0){ //is the pointer
-                                        return;
-                                    }
-                                    if(popupTimeoutId !== undefined){
-                                        clearHidePopupTimeout(popupTimeoutId);
-                                    }
-                                    if(data.eventName === 'dragstart' || data.eventName === 'mouseleave'){
-                                        if(popupdiv.isShowing()){
-                                            popupdiv.close();
-                                        }
-                                        return;
-                                    }
-                                    if(data.eventName !== 'mouseenter'){
-                                        return;
-                                    }
-                                    popupShowFunction(data);
-                                    if(POPUP_TIMEOUT<0){
-                                        return;
-                                    }
-                                    popupTimeoutId = popupdiv.setTimeout('close',POPUP_TIMEOUT*1000);
-                                });
+                                
 
                             }
+                            var draggingSomeMarker = false;
+                            //now bind mouse events
+                            player.bind('markerMouseEvent', function(data){
+//                                if(data.index<0 || player.playState>0){ //is the pointer
+//                                    return;
+//                                }
+
+
+
+                                //                                if(popupTimeoutId !== undefined){
+                                //                                    clearHidePopupTimeout(popupTimeoutId);
+                                //                                }
+                                //                                if(data.eventName === 'dragstart'){ // || data.eventName === 'mouseleave'){
+                                //                                    if(popupdiv.isShowing()){
+                                //                                        popupdiv.close();
+                                //                                    }
+                                //                                    return;
+                                //                                }
+                                if(data.eventName === 'mouseenter'){
+                                    if(!draggingSomeMarker && data.index>=0 && player.playState===0){
+                                        popupShowFunction(data);
+                                        return;
+                                    }
+                                }else if(data.eventName === 'dragstart'){
+                                    draggingSomeMarker = true;
+                                }else if(data.eventName === 'mouseup'){
+                                    draggingSomeMarker = false;
+                                }
+                                if(popupdiv.isShowing()){
+                                    popupdiv.close();
+                                }
+                            //                                if(POPUP_TIMEOUT<0){
+                            //                                    return;
+                            //                                }
+                            //                                popupTimeoutId = popupdiv.setTimeout('close',POPUP_TIMEOUT*1000);
+                            });
                         }
                     }
 
index e8720ba22b84b6e545063fc7667b8ba425b1f8a3..c0ec49359b37d492f6008f5fcd36fe375e1e802b 100644 (file)
  *          }\r
  *      });\r
  */\r
-function PopupDiv(){\r
+function PopupDiv() {\r
     var $J = jQuery;\r
     var me = this;\r
-    var data = arguments.length && arguments[0] || {};\r
-\r
+    var data = {};\r
+    if(arguments.length && arguments[0]){\r
+        data= arguments[0];\r
+    }\r
     //var wdw = $J(window);\r
     var div  = $J('<div/>');\r
     //we use an input rather than a span for two reasons:\r
@@ -170,16 +172,17 @@ function PopupDiv(){
     }));\r
     //header.find('*').add(footer.find('*')).css('display','none');\r
     div.append(header).append(container).append(footer);\r
+\r
     //defining immediately the method getDiv (because it is used below)\r
     this.getDiv = function(){\r
         return div;\r
-    }\r
+    };\r
     //setting functions:\r
 \r
     var listeners = {};\r
     this.getListeners = function(){\r
         return listeners;\r
-    }\r
+    };\r
 \r
 \r
     //setting static properties, if any.\r
@@ -197,10 +200,10 @@ function PopupDiv(){
     //but it assures cross browser compatibility\r
 \r
     var k;\r
-    var staticProps = undefined;\r
+    var staticProps;\r
     for(k in PopupDiv){\r
         var f = PopupDiv[k];\r
-        if(typeof f !== 'function'){ //do not assign functions (PopupDiv.function... might be used in future as\r
+        if(PopupDiv.hasOwnProperty(k) && (typeof f !== 'function')){ //do not assign functions (PopupDiv.function... might be used in future as\r
             //static functions accessible from outside\r
             if(!staticProps){\r
                 staticProps = {};\r
@@ -212,7 +215,7 @@ function PopupDiv(){
         var remove = true;\r
         var proto = undefined;\r
         if ( typeof Object.getPrototypeOf !== "function" ) {\r
-            if ( typeof this.__proto__ === "object" ) {\r
+            if (typeof this.__proto__ === "object" ) {\r
                 proto = this.__proto__;\r
             } else {\r
                 // May break if the constructor has been tampered with:\r
@@ -225,21 +228,25 @@ function PopupDiv(){
             proto = Object.getPrototypeOf(this);\r
         }\r
         for(k in staticProps){\r
-            proto[k] = staticProps[k];\r
-            if(remove){\r
-                delete PopupDiv[k];\r
+            if(staticProps.hasOwnProperty(k)){\r
+                proto[k] = staticProps[k];\r
+                if(remove){\r
+                    delete PopupDiv[k];\r
+                }\r
             }\r
         }\r
     }\r
 \r
     //setting instance-specific properties:\r
     for(k in data){\r
-        if(k == 'onOk' || k == 'onShow' || k == 'onClose'){\r
-            this.bind(k.substring(2).toLowerCase(),data[k]);\r
-        }else if(k == 'content'){\r
-            this.setContent(data[k]);\r
-        }else {\r
-            this[k] = data[k];\r
+        if(data.hasOwnProperty(k)){\r
+            if(k === 'onOk' || k === 'onShow' || k === 'onClose'){\r
+                this.bind(k.substring(2).toLowerCase(),data[k]);\r
+            }else if(k == 'content'){\r
+                this.setContent(data[k]);\r
+            }else {\r
+                this[k] = data[k];\r
+            }\r
         }\r
     }\r
 \r
@@ -300,8 +307,8 @@ function PopupDiv(){
     p.closeButtonTitle =  'x';\r
     p.defaultCloseOperation = 'hide';\r
     p.focusable = false;\r
-    p.fadInTime = 'fast',\r
-    p.fadeOutTime = 0,\r
+    p.fadInTime = 'fast';\r
+    p.fadeOutTime = 0;\r
     p.shadowOpacity = 0.25;\r
     p.zIndex = 10000;\r
     p.listItemClass = '';\r
@@ -326,7 +333,7 @@ function PopupDiv(){
 \r
     p.setTitle = function(title){\r
         this.getDiv().children().eq(0).find(':title').eq(0).val(title);\r
-    }\r
+    };\r
 \r
     //methods:\r
     p.find = function(argumentAsInJQueryFind){\r
@@ -335,7 +342,7 @@ function PopupDiv(){
 \r
     p.bind = function(eventName, callback){ //eventname: show, close or ok\r
         var listeners = this.getListeners();\r
-        if(eventName in listeners){\r
+        if(listeners.hasOwnProperty(eventName)){\r
             listeners[eventName].push(callback);\r
         }else{\r
             listeners[eventName] = [callback];\r
@@ -345,11 +352,13 @@ function PopupDiv(){
 \r
     p.unbind = function(eventName){\r
         var listeners = this.getListeners();\r
-        if(eventName && eventName in listeners){\r
+        if(eventName && listeners.hasOwnProperty(eventName)){\r
             delete listeners[eventName];\r
         }else if(!eventName){\r
             for(var k in listeners){\r
-                delete listeners[k];\r
+                if(listeners.hasOwnProperty(k)){\r
+                    delete listeners[k];\r
+                }\r
             }\r
         }\r
     };\r
@@ -357,7 +366,7 @@ function PopupDiv(){
     p.trigger = function(eventName){\r
         var listeners = this.getListeners();\r
         var me = this;\r
-        if(eventName in listeners){\r
+        if(listeners.hasOwnProperty(eventName)){\r
             var callbacks = listeners[eventName];\r
             var i = 0;\r
             if(eventName == 'ok'){\r
@@ -406,7 +415,7 @@ function PopupDiv(){
             var listItems = $([]);\r
             for(var h=0; h<content.length; h++){\r
                 var item = content[h];\r
-                var a = $('<a/>').attr('href','#').html(""+item);\r
+                var a = $('<a/>').attr('href','#').html(""+item).css('whiteSpace','nowrap');\r
                 listItems = listItems.add(a);\r
                 setEvents(h,a,input);\r
                 container.append(a);\r
@@ -443,43 +452,45 @@ function PopupDiv(){
                 leftElements = leftElements.add(e1);\r
                 container.append(lineDiv.append(e1).append(e2));\r
                 return lineDiv;\r
-            }\r
+            };\r
             var title, component;\r
 \r
             var max = Math.max; //instantiate once\r
             var lineDiv = undefined;\r
             var lineDivs = $([]);\r
             for(var k in content){\r
-                var val = content[k];\r
-                if(typeof val == 'string' || typeof val == 'number'){\r
-                    title = $('<span/>').html(k);\r
-                    maxw[0] = max(maxw[0],k.length);\r
-                    maxw[1] = max(maxw[1],val.length);\r
-                    component = $('<input/>').attr('type','text').val(val).attr(att,k);\r
-                    lineDivs = lineDivs.add(insert(title,component));\r
-                }else if(val === true || val === false){\r
-                    var id = this.getId()+"_checkbox";\r
-                    title = $('<input/>').attr('type','checkbox').attr(att,k).attr('id',id);\r
-                    if(val){\r
-                        title.attr('checked','checked');\r
-                    }else{\r
-                        title.removeAttr('checked');\r
+                if(content.hasOwnProperty(k)){\r
+                    var val = content[k];\r
+                    if(typeof val == 'string' || typeof val == 'number'){\r
+                        title = $('<span/>').html(k);\r
+                        maxw[0] = max(maxw[0],k.length);\r
+                        maxw[1] = max(maxw[1],val.length);\r
+                        component = $('<input/>').attr('type','text').val(val).attr(att,k);\r
+                        lineDivs = lineDivs.add(insert(title,component));\r
+                    }else if(val === true || val === false){\r
+                        var id = this.getId()+"_checkbox";\r
+                        title = $('<input/>').attr('type','checkbox').attr(att,k).attr('id',id);\r
+                        if(val){\r
+                            title.attr('checked','checked');\r
+                        }else{\r
+                            title.removeAttr('checked');\r
+                        }\r
+                        component = $('<label/>').attr('for',id).html(k);\r
+                        maxw[1] = max(maxw[1],k.length);\r
+                        lineDivs = lineDivs.add(insert($('<span/>').append(title),component));\r
+                    }else if(val instanceof Array){\r
+                        title = $('<span/>').html(k);\r
+                        maxw[0] = max(maxw[0],k.length);\r
+                        component = $('<select/>').attr('size',1).attr(att,k);\r
+                        for(var i=0; i< val.length; i++){\r
+                            component.append($('<option/>').val(val[i]).html(val[i]));\r
+                            maxw[1] = max(maxw[1],val[i].length);\r
+                        }\r
+                        lineDivs = lineDivs.add(insert(title,component));\r
                     }\r
-                    component = $('<label/>').attr('for',id).html(k);\r
-                    maxw[1] = max(maxw[1],k.length);\r
-                    lineDivs = lineDivs.add(insert($('<span/>').append(title),component));\r
-                }else if(val instanceof Array){\r
-                    title = $('<span/>').html(k);\r
-                    maxw[0] = max(maxw[0],k.length);\r
-                    component = $('<select/>').attr('size',1).attr(att,k);\r
-                    for(var i=0; i< val.length; i++){\r
-                        component.append($('<option/>').val(val[i]).html(val[i]));\r
-                        maxw[1] = max(maxw[1],val[i].length);\r
+                    if(lineDiv){\r
+                        lineDiv.css('marginBottom','1ex');\r
                     }\r
-                    lineDivs = lineDivs.add(insert(title,component));\r
-                }\r
-                if(lineDiv){\r
-                    lineDiv.css('marginBottom','1ex');\r
                 }\r
             }\r
             lineDivs.css({\r
@@ -524,7 +535,9 @@ function PopupDiv(){
         var bottomDiv = $(children_[2]);\r
         var elementsWithFocus =  centralDiv.find('input[type!=hidden],select,textarea,a'); //input:not(:hidden),select,textarea,a,\r
 \r
-        var ret = elementsWithFocus.length ? $(elementsWithFocus[0]) : popup;\r
+        //set the element with focus by default if there is no focusable element inside the popup\r
+        var ret = elementsWithFocus.length ? $(elementsWithFocus[0]) : centralDiv;\r
+\r
         if(this.showClose){\r
             elementsWithFocus =elementsWithFocus.add(topDiv.find('a'));\r
         }\r
@@ -534,7 +547,13 @@ function PopupDiv(){
                 elementsWithFocus = elementsWithFocus.add(bottomDiv.find('a'));\r
             }\r
         }\r
-        elementsWithFocus = elementsWithFocus.add(popup);\r
+        popup.add(centralDiv).css('outline','#FFF none 0px'); //DO NOT SHOW BORDER FOCUS FOR DIVS (NICER)\r
+        elementsWithFocus = elementsWithFocus.add(popup).add(centralDiv);\r
+        //we add the popup div cause in case of padding clicking on the popup padding should NOT hide the popup\r
+        //we add the centralDiv cause, if scrollbars are present, then moving the scrollbars sets the focus to the\r
+        //centralDiv in IE and therefore the popup would hide\r
+\r
+        \r
         var focusNameSpace = "blur."+this.getId();\r
         if(!value){\r
             elementsWithFocus.each(function(i,elm){\r
@@ -542,7 +561,7 @@ function PopupDiv(){
             });\r
             this.getFirstFocusableElement = function(){\r
                 return undefined;\r
-            }\r
+            };\r
             if(invokerIsClickable){\r
                 this.invoker.removeAttr('tabindex').removeAttr(focusAttr);\r
             }\r
@@ -566,6 +585,7 @@ function PopupDiv(){
                 //otherwise execute callback\r
                 setTimeout(function(){\r
                     var v = doc_.activeElement;\r
+                    consolelog(v.tagName+' ' +$(v).attr(focusAttr));\r
                     //console.log(v);\r
                     if((v && $(v).attr(focusAttr)) || me.__isClosing){\r
                         //if we are closing, we will call back this method which removes the focus attributes, bt meanwhile the\r
@@ -612,11 +632,11 @@ function PopupDiv(){
             this.setBoundsInside(invoker, this.bounds, this.boundsExact);\r
         }\r
         \r
-        this.shadow(); //updates shadow\r
+        //this.shadow(); //updates shadow\r
         if(focusable){\r
             this.getFirstFocusableElement().focus();\r
         }\r
-    }\r
+    };\r
 \r
     p.setTitle= function(title){\r
         var subdiv = this.getDiv().children().eq(0);\r
@@ -638,10 +658,10 @@ function PopupDiv(){
         } else if (node.nodeValue) {\r
             node.nodeValue = title;\r
         }\r
-//        consolelog('"'+ title+'"');\r
-//        consolelog(text);\r
-//        consolelog(node);\r
-    }\r
+    //        consolelog('"'+ title+'"');\r
+    //        consolelog(text);\r
+    //        consolelog(node);\r
+    };\r
 \r
     p.isShowing = function(){\r
         return this.getDiv().is(':visible');\r
@@ -672,7 +692,8 @@ function PopupDiv(){
 \r
         if(this.showClose || this.title){\r
             topDiv.css({\r
-                'paddingBottom':'0.25em'\r
+                'paddingBottom':'0.25em',\r
+                'whiteSpace':'nowrap'\r
             }); //add padding to bottom\r
             //warning: do NOT use real numbers such as 0.5ex cause browsers round it in a different manner\r
             //whiteSpace is FUNDAMENTAL in calculating the popup div in case the title is the longest (max width) element\r
@@ -719,8 +740,8 @@ function PopupDiv(){
         }\r
 \r
         var invoker = this.invoker;\r
-\r
-        if(this.isClickElement(invoker)){\r
+        var isClickElement = this.isClickElement(invoker);\r
+        if(isClickElement){\r
             this.setBoundsAsPopup(invoker);\r
             //storing click events, when showing clicking on an event must give the focus to the popup\r
             //old handlers will be restored in close()\r
@@ -732,7 +753,7 @@ function PopupDiv(){
                 var clickEvents =invoker.data("events")[type];\r
                 $.each(clickEvents, function(key, value) {\r
                     oldHandlers.push(value);\r
-                })\r
+                });\r
                 invoker.unbind(type); //remove (temporarily) the binding to the event.\r
                 //for instance, if we show the popup by clicking invoker, when the popup is shown do nothing\r
                 //on clicking invoker until popup.hide is called\r
@@ -757,7 +778,27 @@ function PopupDiv(){
 \r
        \r
         var shadow = this.shadow();\r
+        var place = isClickElement ? this.placeAsPopup : this.placeInside;\r
         var postShowFcn = function(){\r
+            //adding window resize interval to track window changes\r
+            var w = wdw.width();\r
+            var h = wdw.height();\r
+            me._resizeTimeInterval = setInterval(function(){\r
+                var w2 = wdw.width();\r
+                var h2 = wdw.height();\r
+                if(w2!==w || h2 !==h){\r
+                    setTimeout(function(){\r
+                        if(!me.isShowing() || me.__isClosing){\r
+                            return;\r
+                        }\r
+                        if(wdw.width()===w2 && wdw.height()===h2){\r
+                            place.apply(me);\r
+                        }\r
+                    },100);\r
+                }\r
+            },200);\r
+\r
+\r
             me.trigger('show');\r
             shadow.fadeTo(me.fadInTime,me.shadowOpacity, function(){\r
                 var v = me.getFirstFocusableElement();\r
@@ -765,7 +806,7 @@ function PopupDiv(){
                     v.focus();\r
                 }\r
             });\r
-        }\r
+        };\r
 \r
         div.show(this.fadInTime,function(){\r
             postShowFcn();\r
@@ -801,7 +842,7 @@ function PopupDiv(){
             });\r
         }\r
         return shadow;\r
-    }\r
+    };\r
 \r
     p.setBoundsAsPopup = function(popupInvoker){\r
         var invoker = popupInvoker;\r
@@ -825,6 +866,7 @@ function PopupDiv(){
         var spaceLeft = invokerOffset.left + invokerOuterWidth - windowRectangle.x;\r
         var placeLeft = spaceLeft > spaceRight && div.outerWidth(false) + shadowOffset > spaceRight;\r
 \r
+        \r
         this.setMaxSize({\r
             height : (placeAbove ? spaceAbove : spaceBelow),\r
             width: (placeLeft ? spaceLeft : spaceRight)\r
@@ -840,14 +882,7 @@ function PopupDiv(){
         //however, we want CH to change even if a new maxHeight greater than CH is set\r
         });\r
 \r
-        //setting the top and left. This must be done at last because popupDiv.outerHeight(true)\r
-        //must have been computed according to the height set above...\r
-        this.offset({\r
-            'left': placeLeft ? invokerOffset.left+ invokerOuterWidth - div.outerWidth(true)-shadowOffset : invokerOffset.left,\r
-            'top': (placeAbove ? invokerOffset.top -  div.outerHeight(true) :\r
-                invokerOffset.top + invokerOuterHeight)\r
-        });\r
-\r
+        \r
         this.postSizeFcn();\r
 \r
     };\r
@@ -863,12 +898,14 @@ function PopupDiv(){
         this.preSizeFcn();\r
         \r
         var bounds = this.getBoundsOf(parent);\r
-        \r
+       \r
         \r
         var x=bounds.x;\r
         var y = bounds.y;\r
-        var w = bounds.width\r
+        var w = bounds.width;\r
         var h = bounds.height;\r
+\r
+        \r
         var pInt = parseInt;\r
         //rebuilding:\r
 \r
@@ -880,12 +917,14 @@ function PopupDiv(){
         };\r
 \r
         for(var k in padding){\r
-            if(padding[k]<=0){\r
-                padding[k]=0;\r
-            }else if(padding[k]<=1){\r
-                padding[k] = k=='top' || k =='bottom' ? h*padding[k] : w*padding[k];\r
-            }else{\r
-                padding[k] = pInt(padding[k]);\r
+            if(padding.hasOwnProperty(k)){\r
+                if(padding[k]<=0){\r
+                    padding[k]=0;\r
+                }else if(padding[k]<=1){\r
+                    padding[k] = k=='top' || k =='bottom' ? h*padding[k] : w*padding[k];\r
+                }else{\r
+                    padding[k] = pInt(padding[k]);\r
+                }\r
             }\r
         }\r
 \r
@@ -893,38 +932,17 @@ function PopupDiv(){
             'width':w-padding['left']-padding['right']+this.shadowOffset,\r
             'height':h-padding['top']-padding['bottom']+this.shadowOffset\r
         };\r
-\r
-        var vvvv ={\r
-            width:maxSize.width,\r
-            height:maxSize.height\r
-        };\r
-        this._convertSize(div, vvvv);\r
-\r
-        if(boundsExact){\r
-            this.setMinSize({\r
-                width:maxSize.width,\r
-                height:maxSize.height\r
-            }); //a copy cause the argument will be modified\r
+        \r
             this.setMaxSize({\r
                 width:maxSize.width,\r
                 height:maxSize.height\r
             }); //a copy cause the argument will be modified\r
 \r
-            this.offset({\r
-                'left':x + padding['left'],\r
-                'top': y + padding['top']\r
-            });\r
-        }else{\r
-            this.setMaxSize({\r
+        if(boundsExact){\r
+            this.setMinSize({\r
                 width:maxSize.width,\r
                 height:maxSize.height\r
             }); //a copy cause the argument will be modified\r
-            var spanLeft = maxSize.width - div.outerWidth(true);\r
-            var spanTop = maxSize.height - div.outerHeight(true);\r
-            this.offset({\r
-                'left':x + padding['left'] + (spanLeft > 0 ? spanLeft/2 : 0),\r
-                'top': y + padding['top'] +(spanTop > 0 ? spanTop/2 : 0)\r
-            });\r
 \r
         }\r
 \r
@@ -932,7 +950,8 @@ function PopupDiv(){
     };\r
     p.preSizeFcn = function(){\r
         var div = this.getDiv();\r
-        var subdivs = div.children().hide();\r
+        var subdivs = div.children();\r
+        subdivs.css('display','none');\r
         var subdivsshow = subdivs.eq(1);\r
         if(this.showClose || this.title){\r
             subdivsshow = subdivsshow.add(subdivs.eq(0));\r
@@ -940,25 +959,70 @@ function PopupDiv(){
         if(this.showOk){\r
             subdivsshow = subdivsshow.add(subdivs.eq(2));\r
         }\r
-        \r
-        subdivsshow.add(div).css({\r
-            'maxHeight':'none',\r
-            'maxWidth':'none',\r
-            'minHeight':'none',\r
-            'minWidth':'none',\r
-            'height':'auto',\r
-            'width':'auto',\r
+\r
+        subdivsshow = subdivsshow.add(div);\r
+        subdivsshow.css({\r
             'display':'block',\r
-            'overflow':'visible',\r
-            'float':'none'\r
+            'float':'',\r
+            'overflow' : 'visible'\r
         });\r
 \r
+\r
+        //reset properties:\r
+        subdivsshow.css({\r
+            'maxHeight':'',\r
+            'maxWidth':'',\r
+            'minHeight':'',\r
+            'minWidth':'',\r
+            'height':'',\r
+            'width':'',\r
+            'overflow':'',\r
+            'visibility' : 'visible',\r
+            'float':''\r
+        });\r
+        //        subdivsshow.css({\r
+        //            'height':'',\r
+        //            'width':''\r
+        //        });\r
+\r
+        //subdivs.eq(0).css('width','');\r
+\r
+        //        subdivsshow.add(div).css({\r
+        //            'maxHeight':'none',\r
+        //            'maxWidth':'none',\r
+        //            'minHeight':'none',\r
+        //            'minWidth':'none',\r
+        //            'height':'auto',\r
+        //            'width':'auto',\r
+        //            'display':'block',\r
+        //            'overflow':'visible',\r
+        //            'float':'none'\r
+        //        });\r
+\r
+\r
         div.css({\r
             'margin':'0px',\r
             'zIndex':this.zIndex,\r
             'position':'absolute'\r
         });\r
-    }\r
+\r
+\r
+        //place the div in the upperleft corner of the window\r
+        var bounds = this.getBoundsOf(); //returns the window rectangle\r
+        div.css({\r
+            'left':bounds.x+'px',\r
+            'top':bounds.y+'px'\r
+            });\r
+\r
+    //        var topDiv =subdivs.eq(0);\r
+    //        var centralDiv = subdivs.eq(1);\r
+    //        var bottomDiv = subdivs.eq(2);\r
+    //        consolelog('presize');\r
+    //        consolelog('width: '+ topDiv.width()+' css-minWidth: ' +topDiv.css('minWidth')+' css-width: ' +topDiv.css('width')+' css-maxWidth: ' +topDiv.css('maxWidth'));\r
+    //        consolelog('width: '+centralDiv.width()+' css-minWidth: ' +centralDiv.css('minWidth')+' css-width: ' +centralDiv.css('width')+' css-maxWidth: ' +centralDiv.css('maxWidth'));\r
+    //        consolelog('width: '+bottomDiv.width()+' css-minWidth: ' +bottomDiv.css('minWidth')+' css-width: ' +bottomDiv.css('width')+' css-maxWidth: ' +bottomDiv.css('maxWidth'));\r
+    //        consolelog(' ' );\r
+    };\r
     \r
     p.postSizeFcn = function(){\r
         //set title and close button to span whole width, if necessary\r
@@ -969,7 +1033,7 @@ function PopupDiv(){
         var topDiv = subdivs.eq(0);\r
 \r
         var centralDiv = subdivs.eq(1);\r
-        centralDiv.css('overflow','auto');\r
+        //\r
         var bottomDiv = subdivs.eq(2);\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
@@ -979,20 +1043,154 @@ function PopupDiv(){
         //same for width:\r
         var maxWidth = div.width();\r
         var width = centralDiv.outerWidth(true);\r
-\r
+            \r
         if(maxHeight<=0 || maxWidth<=0){\r
-            centralDiv.hide();\r
+            //centralDiv.hide();\r
             return;\r
         }\r
         \r
-        if(maxHeight<height){\r
-            centralDiv.css('maxHeight',maxHeight+'px');\r
+        //        if(maxHeight<height){\r
+        //            centralDiv.css('maxHeight',maxHeight+'px');\r
+        //        }\r
+\r
+        //setting centralDiv maxHeight is buggy and not the same behaviour in all browsers\r
+        //so we set a height, which will be reset in preSizeFcn\r
+        centralDiv.css('height',maxHeight+'px');\r
+        //same for width\r
+        centralDiv.css('width',maxWidth+'px');\r
+\r
+        //TODO: check padding margins border or set them to zero in preSizeFcn!!!!!!\r
+\r
+\r
+        //        centralDiv.css('width',maxWidth+'px');\r
+        //        if(maxWidth<width){\r
+        //            centralDiv.css('maxWidth',maxWidth+'px');\r
+        //        }\r
+\r
+        //to be put AT THE END otherwise bug in IE7\r
+        centralDiv.css('overflow','auto');\r
+        //after the command above, centralDiv.hegith is set to zero in IE7.\r
+        //It might be a refresh problem cause if we display an alert then the size is properly set.\r
+        //However:\r
+        //if(centralDiv.height()==0 && maxHeight>0){\r
+        //consolelog('buggy: '+maxHeight);\r
+        //centralDiv.css('height',maxHeight);\r
+        //}\r
+\r
+        //last thing: the subelements width property seems to be handles in different ways across browsers:\r
+        //in preSizeFcn, we set a width to auto. Curiously, when resizing the parent div (this.getDiv()), subelements are assigned\r
+        //a specified width property\r
+        //IE does what it is expected (werird enogh...), ie sets a maxWidth and\r
+\r
+        //        consolelog('postsize');\r
+        //        consolelog('width: '+ topDiv.width()+' css-minWidth: ' +topDiv.css('minWidth')+' css-width: ' +topDiv.css('width')+' css-maxWidth: ' +topDiv.css('maxWidth'));\r
+        //        consolelog('width: '+centralDiv.width()+' css-minWidth: ' +centralDiv.css('minWidth')+' css-width: ' +centralDiv.css('width')+' css-maxWidth: ' +centralDiv.css('maxWidth'));\r
+        //        consolelog('width: '+bottomDiv.width()+' css-minWidth: ' +bottomDiv.css('minWidth')+' css-width: ' +bottomDiv.css('width')+' css-maxWidth: ' +bottomDiv.css('maxWidth'));\r
+        //        consolelog(' ' );\r
+        if(this.isClickElement(this.invoker)){\r
+            this.placeAsPopup();\r
+        }else{\r
+            this.placeInside();\r
         }\r
+\r
+    };\r
+\r
+    p.placeAsPopup = function(){\r
+        var div = this.getDiv();\r
+\r
+        var shadowOffset = this.shadowOffset;\r
+        var windowRectangle = this.getBoundsOf(wdw); //returns the window rectangle\r
+        var invoker = this.invoker;\r
+        var invokerOffset = invoker.offset();\r
+\r
+        var invokerOuterHeight = invoker.outerHeight();\r
+        var spaceAbove = invokerOffset.top - windowRectangle.y;\r
+        var spaceBelow = windowRectangle.height - invokerOuterHeight - spaceAbove;\r
+        var placeAbove = spaceAbove > spaceBelow && div.outerHeight(false) + shadowOffset > spaceBelow;\r
+\r
+        var invokerOuterWidth = invoker.outerWidth();\r
+        var spaceRight = windowRectangle.x + windowRectangle.width - invokerOffset.left ;\r
+        var spaceLeft = invokerOffset.left + invokerOuterWidth - windowRectangle.x;\r
+        var placeLeft = spaceLeft > spaceRight && div.outerWidth(false) + shadowOffset > spaceRight;\r
+\r
+\r
+\r
+        //setting the top and left. This must be done at last because popupDiv.outerHeight(true)\r
+        //must have been computed according to the height set above...\r
+        var offs = {\r
+            'left': placeLeft ? invokerOffset.left+ invokerOuterWidth - div.outerWidth(true)-shadowOffset : invokerOffset.left,\r
+            'top': (placeAbove ? invokerOffset.top -  div.outerHeight(true) :\r
+                invokerOffset.top + invokerOuterHeight)\r
+        };\r
+        div.css({\r
+            'top':offs.top+'px',\r
+            'left':offs.left+'px'\r
+            });\r
+            this.shadow(); //replace the shadow\r
+    };\r
+\r
+    p.placeInside = function(){\r
+       \r
+        var div = this.getDiv();\r
+\r
         \r
-        if(maxWidth<width){\r
-            centralDiv.css('maxWidth',maxWidth+'px');\r
+        var parent = this.invoker;\r
+        var bounds = this.getBoundsOf(parent);\r
+        var pd = this.bounds;\r
+\r
+        var x=bounds.x;\r
+        var y = bounds.y;\r
+        var w = bounds.width;\r
+        var h = bounds.height;\r
+\r
+\r
+        var pInt = parseInt;\r
+        //rebuilding:\r
+\r
+        var padding = {\r
+            top: pd['top'],\r
+            left:pd['left'],\r
+            bottom:pd['bottom'],\r
+            right:pd['right']\r
+        };\r
+\r
+        for(var k in padding){\r
+            if(padding.hasOwnProperty(k)){\r
+                if(padding[k]<=0){\r
+                    padding[k]=0;\r
+                }else if(padding[k]<=1){\r
+                    padding[k] = k=='top' || k =='bottom' ? h*padding[k] : w*padding[k];\r
+                }else{\r
+                    padding[k] = pInt(padding[k]);\r
+                }\r
+            }\r
+        }\r
+\r
+        var maxSize = {\r
+            'width':w-padding['left']-padding['right']+this.shadowOffset,\r
+            'height':h-padding['top']-padding['bottom']+this.shadowOffset\r
+        };\r
+        //we add shadowOffset cause in convertSize below we will substract the shadow. However, in this case the shadow is NOT\r
+        //counted in the size\r
+\r
+        var ww = div.outerWidth(true);\r
+        var hh = div.outerHeight(true);\r
+\r
+        var spanLeft = 0;\r
+        var spanTop = 0;\r
+        if(ww<maxSize.width){\r
+            spanLeft = (maxSize.width-ww)/2;\r
+        }\r
+        if(hh < maxSize.height){\r
+            spanTop = (maxSize.height-hh)/2;\r
         }\r
 \r
+        div.css({\r
+            'left':(x+padding['left']+spanLeft)+'px',\r
+            'top':(y+padding['top']+spanTop)+'px'\r
+            });\r
+\r
+            this.shadow(); //replace the shadow\r
     };\r
 \r
     p.getBounds = function(){\r
@@ -1026,11 +1224,17 @@ function PopupDiv(){
         var div = this.getDiv();\r
         \r
         this._convertSize(div, size);\r
-        var css = {};\r
-        if('width' in size){\r
+        var css;\r
+        if(size.hasOwnProperty('width')){\r
+            if(!css){\r
+                css = {};\r
+            }\r
             css.maxWidth = size.width+'px';\r
         }\r
-        if('height' in size){\r
+        if(size.hasOwnProperty('height')){\r
+            if(!css){\r
+                css = {};\r
+            }\r
             css.maxHeight = size.height+'px';\r
         }\r
         if(css){\r
@@ -1043,11 +1247,17 @@ function PopupDiv(){
         var div = this.getDiv();\r
         \r
         this._convertSize(div, size);\r
-        var css = {};\r
-        if('width' in size){\r
+        var css;\r
+        if(size.hasOwnProperty('width')){\r
+            if(!css){\r
+                css = {};\r
+            }\r
             css.minWidth = size.width+'px';\r
         }\r
-        if('height' in size){\r
+        if(size.hasOwnProperty('height')){\r
+            if(!css){\r
+                css = {};\r
+            }\r
             css.minHeight = size.height+'px';\r
         }\r
         if(css){\r
@@ -1062,10 +1272,10 @@ function PopupDiv(){
             'height':div.outerHeight(true)-div.height()\r
         };\r
 \r
-        if('width' in size){\r
+        if(size.hasOwnProperty('width')){\r
             size.width -= (eD.width + this.shadowOffset);\r
         }\r
-        if('height' in size){\r
+        if(size.hasOwnProperty('height')){\r
             size.height -= (eD.height + this.shadowOffset);\r
         }\r
     };\r
@@ -1077,6 +1287,10 @@ function PopupDiv(){
 \r
     p.close = function(){\r
         this.__isClosing = true;\r
+        if(this._resizeTimeInterval!==undefined){\r
+            clearInterval(this._resizeTimeInterval);\r
+            this._resizeTimeInterval = undefined;\r
+        }\r
         this.setFocusCycleRoot(false);\r
         var div = this.getDiv();\r
         var shadow = $('#'+this.getShadowDivId());\r
@@ -1111,28 +1325,28 @@ function PopupDiv(){
     p.setTimeout = function(eventName, millseconds){\r
         var me = this;\r
         var t=undefined;\r
-        if(eventName == 'show'){\r
+        if(eventName === 'show'){\r
             t=setTimeout(function(){\r
                 me.show();\r
             },millseconds);\r
-        }else if(eventName == 'close'){\r
+        }else if(eventName === 'close'){\r
             t=setTimeout(function(){\r
                 me.close();\r
             },millseconds);\r
         }\r
         return t;\r
-    },\r
+    };\r
 \r
     p.getShadowDivId = function(){\r
         return this.getId()+"_shadow";\r
-    }\r
+    };\r
 \r
     p.getFocusAttr = function(){\r
         return this.getId()+"_focus";\r
-    }\r
+    };\r
 \r
     p.getFormDataAttrName = function(){\r
         return this.getId()+"_data";\r
-    }\r
+    };\r
 \r
 })(PopupDiv.prototype);
\ No newline at end of file
index dccd78450cf2c3898f4964a0e639f98e33fe0b60..18e239230069a91fbb045239d9d256a8a05ab77c 100644 (file)
@@ -295,8 +295,6 @@ Timeside.classes.Player = Timeside.classes.TimesideClass.extend({
         }
         //bind mouse events:
         ruler.bind('markermouseevent', function(data){
-           consolelog(data.eventName);
-           consolelog(data);
            var idx = data.index;
            data.marker = idx > -1 ? me.getMarker(idx) : undefined;
            me.fire('markerMouseEvent',data);
index cf884672c763226ebc5450a04312d986b2a83625..41c86b13cc515e7de19e597cfb7a2d26ccb881a1 100644 (file)
@@ -396,72 +396,69 @@ Timeside.classes.Ruler = Timeside.classes.TimesideArray.extend({
         });
 
         lbl.bind('mousedown.'+eventId,function(evt) {
-            pointerOrMarker.isMovedByMouse = true;
-
-           
-            //            if(markerClass=='pointer'){
-            //                me.isPointerMovingFromMouse = true;
-            //            }
-
-            var launchDragStart = true;
+            if(evt.which===1){
+                pointerOrMarker.isMovedByMouse = true;
+                //consolelog('w '+evt.which);
+            
+                var launchDragStart = true;
 
-            var startX = evt.pageX; //lbl.position().left-container.position().left;
-            var startPos = lbl.position().left+lbl.width()/2;
+                var startX = evt.pageX; //lbl.position().left-container.position().left;
+                var startPos = lbl.position().left+lbl.width()/2;
             
-            evt.stopPropagation(); //dont notify the ruler or other elements;
-            var newPos = startPos;
-            doc.bind('mousemove.'+eventId, function(evt_){
-                var x = evt_.pageX;
-                newPos = startPos+(x-startX);
-                pointerOrMarker.move(newPos);
-                //update the text if pointer
-                if(markerClass=='pointer'){
-                    pointerOrMarker.setText(me.makeTimeLabel(me.toSoundPosition(newPos)));
-                }
-
-                if(launchDragStart){
-                    launchDragStart = false;
+                evt.stopPropagation(); //dont notify the ruler or other elements;
+                var newPos = startPos;
+                doc.bind('mousemove.'+eventId, function(evt_){
+                    var x = evt_.pageX;
+                    newPos = startPos+(x-startX);
+                    pointerOrMarker.move(newPos);
+                    //update the text if pointer
+                    if(markerClass=='pointer'){
+                        pointerOrMarker.setText(me.makeTimeLabel(me.toSoundPosition(newPos)));
+                    }
+
+                    if(launchDragStart){
+                        launchDragStart = false;
+                        me.fire(mme,{
+                            eventName: 'dragstart',
+                            eventObj: evt_,
+                            index: markerClass=='pointer' ? -1 : pointerOrMarker.getIndex()
+                        });
+                    }
+                    return false;
+                
+                });
+                //to avoid scrolling
+                ////TODO: check IE bug on mouseup on the ruler (pointer is moving too)
+                //TODO: what happens if the user releases the mouse OUTSIDE the browser???? check bug in IE (mouse release)
+                var mouseup = function(evt_){
+                    doc.unbind('mousemove.'+eventId);
+                    doc.unbind('mouseup.'+eventId);
+                    evt_.stopPropagation();
+                    if(newPos == startPos){
+                        return false;
+                    }
+                    var data = {
+                        'markerElement':pointerOrMarker,
+                        'soundPosition': me.toSoundPosition.apply(me,[newPos]),
+                        'markerClass':markerClass
+                    };
+                    me.fire('markermoved',data);
+
+                    pointerOrMarker.isMovedByMouse = false;
+                    //                if(markerClass=='pointer'){
+                    //                    me.isPointerMovingFromMouse = false;
+                    //                }
+
                     me.fire(mme,{
-                        eventName: 'dragstart',
+                        eventName: 'mouseup',
                         eventObj: evt_,
                         index: markerClass=='pointer' ? -1 : pointerOrMarker.getIndex()
                     });
-                }
-                return false;
-                
-            });
-            //to avoid scrolling
-            ////TODO: check IE bug on mouseup on the ruler (pointer is moving too)
-            //TODO: what happens if the user releases the mouse OUTSIDE the browser???? check bug in IE (mouse release)
-            var mouseup = function(evt_){
-                doc.unbind('mousemove.'+eventId);
-                doc.unbind('mouseup.'+eventId);
-                evt_.stopPropagation();
-                if(newPos == startPos){
+
                     return false;
-                }
-                var data = {
-                    'markerElement':pointerOrMarker,
-                    'soundPosition': me.toSoundPosition.apply(me,[newPos]),
-                    'markerClass':markerClass
                 };
-                me.fire('markermoved',data);
-
-                pointerOrMarker.isMovedByMouse = false;
-                //                if(markerClass=='pointer'){
-                //                    me.isPointerMovingFromMouse = false;
-                //                }
-
-                me.fire(mme,{
-                    eventName: 'mouseup',
-                    eventObj: evt_,
-                    index: markerClass=='pointer' ? -1 : pointerOrMarker.getIndex()
-                });
-
-                return false;
-            };
-            doc.bind('mouseup.'+eventId, mouseup);
-
+                doc.bind('mouseup.'+eventId, mouseup);
+            }
 
             me.fire(mme,{
                 eventName: 'mousedown',