From: riccardo Date: Tue, 21 Jun 2011 11:21:33 +0000 (+0200) Subject: fixed popupdiv bugs (repositioning) and pointer mouse events X-Git-Tag: 1.1~94 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=e4330f7b275f21b1efb2cfd811141847139dc1fb;p=telemeta.git fixed popupdiv bugs (repositioning) and pointer mouse events --- diff --git a/telemeta/htdocs/css/telemeta.css b/telemeta/htdocs/css/telemeta.css index 3ff8bc2a..dcf3d592 100644 --- a/telemeta/htdocs/css/telemeta.css +++ b/telemeta/htdocs/css/telemeta.css @@ -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; diff --git a/telemeta/htdocs/js/playerLoader.js b/telemeta/htdocs/js/playerLoader.js index 33c2f032..3606cfe3 100644 --- a/telemeta/htdocs/js/playerLoader.js +++ b/telemeta/htdocs/js/playerLoader.js @@ -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); + }); } } diff --git a/telemeta/htdocs/js/popupdiv.js b/telemeta/htdocs/js/popupdiv.js index e8720ba2..c0ec4935 100644 --- a/telemeta/htdocs/js/popupdiv.js +++ b/telemeta/htdocs/js/popupdiv.js @@ -148,11 +148,13 @@ * } * }); */ -function PopupDiv(){ +function PopupDiv() { var $J = jQuery; var me = this; - var data = arguments.length && arguments[0] || {}; - + var data = {}; + if(arguments.length && arguments[0]){ + data= arguments[0]; + } //var wdw = $J(window); var div = $J('
'); //we use an input rather than a span for two reasons: @@ -170,16 +172,17 @@ function PopupDiv(){ })); //header.find('*').add(footer.find('*')).css('display','none'); div.append(header).append(container).append(footer); + //defining immediately the method getDiv (because it is used below) this.getDiv = function(){ return div; - } + }; //setting functions: var listeners = {}; this.getListeners = function(){ return listeners; - } + }; //setting static properties, if any. @@ -197,10 +200,10 @@ function PopupDiv(){ //but it assures cross browser compatibility var k; - var staticProps = undefined; + var staticProps; for(k in PopupDiv){ var f = PopupDiv[k]; - if(typeof f !== 'function'){ //do not assign functions (PopupDiv.function... might be used in future as + if(PopupDiv.hasOwnProperty(k) && (typeof f !== 'function')){ //do not assign functions (PopupDiv.function... might be used in future as //static functions accessible from outside if(!staticProps){ staticProps = {}; @@ -212,7 +215,7 @@ function PopupDiv(){ var remove = true; var proto = undefined; if ( typeof Object.getPrototypeOf !== "function" ) { - if ( typeof this.__proto__ === "object" ) { + if (typeof this.__proto__ === "object" ) { proto = this.__proto__; } else { // May break if the constructor has been tampered with: @@ -225,21 +228,25 @@ function PopupDiv(){ proto = Object.getPrototypeOf(this); } for(k in staticProps){ - proto[k] = staticProps[k]; - if(remove){ - delete PopupDiv[k]; + if(staticProps.hasOwnProperty(k)){ + proto[k] = staticProps[k]; + if(remove){ + delete PopupDiv[k]; + } } } } //setting instance-specific properties: for(k in data){ - if(k == 'onOk' || k == 'onShow' || k == 'onClose'){ - this.bind(k.substring(2).toLowerCase(),data[k]); - }else if(k == 'content'){ - this.setContent(data[k]); - }else { - this[k] = data[k]; + if(data.hasOwnProperty(k)){ + if(k === 'onOk' || k === 'onShow' || k === 'onClose'){ + this.bind(k.substring(2).toLowerCase(),data[k]); + }else if(k == 'content'){ + this.setContent(data[k]); + }else { + this[k] = data[k]; + } } } @@ -300,8 +307,8 @@ function PopupDiv(){ p.closeButtonTitle = 'x'; p.defaultCloseOperation = 'hide'; p.focusable = false; - p.fadInTime = 'fast', - p.fadeOutTime = 0, + p.fadInTime = 'fast'; + p.fadeOutTime = 0; p.shadowOpacity = 0.25; p.zIndex = 10000; p.listItemClass = ''; @@ -326,7 +333,7 @@ function PopupDiv(){ p.setTitle = function(title){ this.getDiv().children().eq(0).find(':title').eq(0).val(title); - } + }; //methods: p.find = function(argumentAsInJQueryFind){ @@ -335,7 +342,7 @@ function PopupDiv(){ p.bind = function(eventName, callback){ //eventname: show, close or ok var listeners = this.getListeners(); - if(eventName in listeners){ + if(listeners.hasOwnProperty(eventName)){ listeners[eventName].push(callback); }else{ listeners[eventName] = [callback]; @@ -345,11 +352,13 @@ function PopupDiv(){ p.unbind = function(eventName){ var listeners = this.getListeners(); - if(eventName && eventName in listeners){ + if(eventName && listeners.hasOwnProperty(eventName)){ delete listeners[eventName]; }else if(!eventName){ for(var k in listeners){ - delete listeners[k]; + if(listeners.hasOwnProperty(k)){ + delete listeners[k]; + } } } }; @@ -357,7 +366,7 @@ function PopupDiv(){ p.trigger = function(eventName){ var listeners = this.getListeners(); var me = this; - if(eventName in listeners){ + if(listeners.hasOwnProperty(eventName)){ var callbacks = listeners[eventName]; var i = 0; if(eventName == 'ok'){ @@ -406,7 +415,7 @@ function PopupDiv(){ var listItems = $([]); for(var h=0; h').attr('href','#').html(""+item); + var a = $('').attr('href','#').html(""+item).css('whiteSpace','nowrap'); listItems = listItems.add(a); setEvents(h,a,input); container.append(a); @@ -443,43 +452,45 @@ function PopupDiv(){ leftElements = leftElements.add(e1); container.append(lineDiv.append(e1).append(e2)); return lineDiv; - } + }; var title, component; var max = Math.max; //instantiate once var lineDiv = undefined; var lineDivs = $([]); for(var k in content){ - var val = content[k]; - if(typeof val == 'string' || typeof val == 'number'){ - title = $('').html(k); - maxw[0] = max(maxw[0],k.length); - maxw[1] = max(maxw[1],val.length); - component = $('').attr('type','text').val(val).attr(att,k); - lineDivs = lineDivs.add(insert(title,component)); - }else if(val === true || val === false){ - var id = this.getId()+"_checkbox"; - title = $('').attr('type','checkbox').attr(att,k).attr('id',id); - if(val){ - title.attr('checked','checked'); - }else{ - title.removeAttr('checked'); + if(content.hasOwnProperty(k)){ + var val = content[k]; + if(typeof val == 'string' || typeof val == 'number'){ + title = $('').html(k); + maxw[0] = max(maxw[0],k.length); + maxw[1] = max(maxw[1],val.length); + component = $('').attr('type','text').val(val).attr(att,k); + lineDivs = lineDivs.add(insert(title,component)); + }else if(val === true || val === false){ + var id = this.getId()+"_checkbox"; + title = $('').attr('type','checkbox').attr(att,k).attr('id',id); + if(val){ + title.attr('checked','checked'); + }else{ + title.removeAttr('checked'); + } + component = $('