]> git.parisson.com Git - telemeta.git/commitdiff
added confirm window when unsaved markers present, added click on divmarker index...
authorriccardo <riccardo@parisson.com>
Wed, 11 May 2011 16:03:03 +0000 (18:03 +0200)
committerriccardo <riccardo@parisson.com>
Wed, 11 May 2011 16:03:03 +0000 (18:03 +0200)
telemeta/htdocs/css/telemeta.css
telemeta/htdocs/js/application.js
telemeta/htdocs/timeside/src/divmarker.js
telemeta/htdocs/timeside/src/markermap.js
telemeta/templates/telemeta_default/mediaitem_detail.html

index c40c8c880f606085c56df3fe4b6800975acf1c63..e3350b1e7a275843672197579772b2b7de31f3f6 100644 (file)
@@ -984,6 +984,10 @@ a.image-link {
     display: inline-block; /*otherwise width and height do not work*/
     background-repeat: no-repeat;
     text-decoration: none;
+
+}
+.markerdiv .markersdivOffset, .markerdiv .markersdivOffset:hover, .markerdiv .markersdivOffset:visited{
+    color: #000;
 }
 .markerdiv .ts-marker, .markerdiv .ts-marker:hover, .markerdiv .ts-marker:visited{
     font-family: monospace; background: #e65911;color: #FFF;padding-left: .3ex; padding-right:.3ex;
index 8838c91155c69f8e012d868abf6e5018cab7c4df..737a1b59f723e3b8a1c351d47cc2bbe2ebdb100d 100644 (file)
@@ -213,310 +213,6 @@ var uniqid = function() {
     return new String(d.getTime() + '' + Math.floor(Math.random() * 1000000)).substr(0, 18);\r
 };\r
 \r
-var popup={\r
-    _cfg_:{\r
-        jQuery:jQuery,\r
-        div: function(){\r
-            var div = this.jQuery('<div/>').css({ //this is _cfg_\r
-                position: 'absolute',\r
-                overflow:'auto', //necessary to properly display the content\r
-                display: 'none',\r
-                border: '1px solid #e1e1e1',\r
-                zIndex:1000\r
-            });\r
-            if(this.className){\r
-                div.addClass(this.className);\r
-            }\r
-            return div;\r
-        },\r
-        className: 'component',\r
-        //        mouseDownNamespace : "mousedown.popup__",\r
-        //        keyDownNamespace : "keydown.popup__",\r
-\r
-        //namespace: 'popup__', //used for namespaces when binding click to document\r
-        handlersToRestore: [],\r
-        event: null,\r
-        divsToDelete:null,\r
-        toggleBind: function(element, functionE){\r
-            var clickNamespace = "click.popup__";\r
-            var keydownNamespace =  "keyup.popup__";\r
-            element.unbind(clickNamespace);\r
-            element.unbind(keydownNamespace);\r
-            if(functionE){\r
-                element.bind(clickNamespace, functionE);\r
-                element.bind(keydownNamespace,functionE);\r
-            }\r
-        }\r
-    },\r
-    \r
-    isShowing: function(){\r
-        return this._cfg_.divsToDelete ? true : false;\r
-    },\r
-\r
-\r
-    hide: function(){\r
-        var toggleBind = this._cfg_.toggleBind;\r
-       \r
-        var $J = this._cfg_.jQuery;\r
-\r
-        toggleBind($J(document));\r
-        if(this._cfg_.divsToDelete){\r
-            for(var i=0; i < this._cfg_.divsToDelete.length; i++){\r
-                this._cfg_.divsToDelete[i].empty().remove();\r
-            }\r
-        }\r
-        if(this._cfg_.event && this._cfg_.handlersToRestore){\r
-            var type = this._cfg_.event.type; //which should be the same as h.type below, without namespaces?\r
-            var invokerElement = this._cfg_.event.target;\r
-            if(invokerElement){\r
-                var e = $J(invokerElement);\r
-                toggleBind(e);\r
-                if(type){\r
-                    //e.unbind(type);\r
-                    for(var i=0; i<this._cfg_.handlersToRestore.length; i++){\r
-                        var h = this._cfg_.handlersToRestore[i];\r
-                        var functionCode = h.handler;\r
-                        var namespace = ""+h.namespace;\r
-                        if(namespace.length>0){\r
-                            namespace="."+namespace;\r
-                        }\r
-                        var what = h.type+ namespace;\r
-                        e.bind(what, functionCode);\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        this._cfg_.event=null;\r
-        this._cfg_.handlersToRestore=null;\r
-    },\r
-\r
-    show:function(content, optionalEvent){\r
-        //if showing, hide\r
-        if(this.isShowing()){\r
-            this.hide();\r
-        }\r
-\r
-        var $J = this._cfg_.jQuery;\r
-        var div = this._cfg_.div();\r
-        //toggleBind sets the functions to hiding/keep shown the popup when clicking or\r
-        //using the keyboard keys\r
-        var toggleBind = this._cfg_.toggleBind;\r
-\r
-        //remove the callback on invoker so that clicking on invoker does nothing\r
-        //moreover, toggleBind on invoker so that clicking invoker doesn't hide the popup\r
-        this.oldCallback = undefined;\r
-        var oldHandlers=[];\r
-        var invokerElement = optionalEvent && optionalEvent.target ? $J(optionalEvent.target) : undefined;\r
-        if(invokerElement){\r
-            optionalEvent.stopPropagation(); //othewrwise the popup hides immediately\r
-            //cause the event is catched from the document click (added later, see below)\r
-            // but apparently as soon as we add it it catches even the current event)\r
-            var type = optionalEvent.type;\r
-            var clickEvents =invokerElement.data("events")[type];\r
-            $J.each(clickEvents, function(key, value) {\r
-                oldHandlers.push(value);\r
-            })\r
-            invokerElement.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
-            toggleBind(invokerElement,function(e){ //add bindings to stop cancel the popup in case the invoker is clicked again\r
-                e.stopPropagation();\r
-                return false;\r
-            });\r
-        }\r
-        //store the functions removed from invoker, if any, to restore them in this.hide\r
-        this._cfg_.handlersToRestore = oldHandlers;\r
-        this._cfg_.event = optionalEvent;\r
-        \r
-        //toggleBind on each child of content so that clicking and pressing keys on\r
-        //a child doesn't hide the popup\r
-        var children = $J(content).find('*');\r
-        $J(children).each(function(){\r
-            toggleBind($(this),function(e){\r
-                e.stopPropagation();\r
-                return false;\r
-            });\r
-        });\r
-        //showing\r
-        var doc = $J(document);\r
-        $J('body').append(div);\r
-        \r
-        content.css('position','static'); //this is really important to place the content in the normal flow\r
-        //within the div. static is the default\r
-        content.show(); //in case the div is display:none\r
-        div.append(content);\r
-\r
-        //positioning div: center of the screen if no invoker, below the invoker otherwise\r
-        var wdow = $J(window); //reference the window object (doing it once speeds up a bit performances)\r
-        var windowH = wdow.height();\r
-        var windowW = wdow.width();\r
-        var position = div.offset();\r
-        var shadowOffset=5;\r
-        var size = {\r
-            width:div.outerWidth(true)+shadowOffset,\r
-            height:div.outerHeight(true)+shadowOffset\r
-        };\r
-        if(invokerElement){\r
-            position = invokerElement.offset();\r
-            position.top+=  invokerElement.outerHeight(true);\r
-        }else{\r
-            position.top = wdow.scrollTop()+ (windowH-size.height)/2;\r
-            position.left = wdow.scrollLeft()+(windowW-size.width)/2;\r
-        }\r
-        //position div. This must be done immediately cause here below we want to get the div  offset\r
-        //(div position in absolute - ie, document's - coordinates)\r
-        div.css({\r
-            'top': position.top,\r
-            'left': position.left,\r
-            'right': 'auto', //in case right has been set by some css class rule\r
-            'bottom': 'auto' //see above...\r
-        });\r
-        //set the maximum size\r
-        //due to overflow:auto a scrollbar will automatically appear\r
-        var max = Math.max; //reference max immediately (speeds up performances a bit)\r
-        var maxSize = {\r
-            width: max(20,windowW +  wdow.scrollLeft() -position.left-shadowOffset),\r
-            height: max(20, (windowH + wdow.scrollTop() -position.top- shadowOffset))\r
-        }\r
-        //position div and size:\r
-        var divPadding = {\r
-            left: div.outerWidth()-div.width(),\r
-            top:div.outerHeight()-div.height()\r
-        }; //setting width on a div means the width(),\r
-        //but calculations here are made according to outerWidth(true), so we need this variable (se below)\r
-\r
-        //the shadow in the background will be created according to the actual div size\r
-        //However, since we do not specify neither width nor height, the calculation of the div size\r
-        //works if maxWidth and maxHeight do set a width and height. In order to do so, they\r
-        //must be lower or equal to the actual div width and height. That's why the "min" here below:'\r
-        div.css({\r
-            'maxWidth': Math.min(div.width(), maxSize.width-divPadding.left),\r
-            'maxHeight': Math.min(div.height(), maxSize.height-divPadding.top)\r
-        });\r
-\r
-        //last thing: if invoker element exist, set width at least invoker element width\r
-        if(invokerElement){\r
-            var iEw = invokerElement.outerWidth(); //no margins considered\r
-            if(iEw<maxSize.width && iEw>div.outerWidth()){\r
-                div.css({\r
-                    'minWidth':iEw-divPadding.left\r
-                });\r
-            }\r
-        }\r
-        //now we can build the divShadow\r
-        var divShadow = div.clone(false,false).empty().css({\r
-            'zIndex':999,\r
-            'borderColor':'#000',\r
-            'display':'none',\r
-            'backgroundColor':'#000'\r
-        }).insertAfter(div);\r
-        //store the divs to be removed\r
-        this._cfg_.divsToDelete = [div,divShadow];\r
-        //add a listener to the document. If one of the content children is clicked/keypressed,\r
-        //we won't come here. Otherwise hide popup\r
-        var me = this;\r
-        var hide = this.hide;\r
-        toggleBind(doc,function(e){\r
-            hide.apply(me);\r
-            e.stopPropagation();\r
-        });\r
-        div.show(300, function(){ //basically in between fast (200) and slow (600)\r
-            //position div shadow:\r
-            divShadow.show();\r
-            \r
-            //set focus to the first input component, if any. Otherwise try with anchors, otherwise do nothing\r
-            var inputs = $J(div).find(':input');\r
-            if(inputs && inputs[0]){\r
-                inputs[0].focus();\r
-            }else{\r
-                inputs = $J(div).find('a');\r
-                if(inputs && inputs[0]){\r
-                    inputs[0].focus();\r
-                }\r
-            }\r
-\r
-            divShadow.fadeTo(0,0.4, function(){\r
-                divShadow.css({\r
-                    'top': (position.top+shadowOffset),\r
-                    'left': (position.left+shadowOffset),\r
-                    'width': div.outerWidth(true),\r
-                    'height': div.outerHeight(true)\r
-                });\r
-\r
-            });\r
-        });\r
-        return false; //to avoid scrolling if we clicked on an anchor\r
-    },\r
-\r
-    //field must be a dictionary of label:defaultValues (both strings)\r
-    //callbackOnOk is the callback to be executed on ok, if null ok will simply hide the dialog\r
-    createDivDialog : function(field,callbackOnOk){\r
-\r
-        var $J = this._cfg_.jQuery;\r
-        var table = $J('<table/>');\r
-        var fieldElms = {};\r
-        for(var label in field){\r
-            var input = $('<input/>')\r
-            .attr('type','text').val(field[label]).attr("name",label);\r
-            table.append($J('<tr/>')\r
-                .append($J('<td/>').html(label))\r
-                .append($J('<td/>').append(input)));\r
-            fieldElms[label]=input;\r
-        }\r
-\r
-        var p = this;\r
-        var onCancel= function(){\r
-            p.hide();\r
-            return false;\r
-        };\r
-       \r
-        var onOk= function(){\r
-            if(callbackOnOk){\r
-                var ret = {};\r
-                var inputs = table.find("input");\r
-                $J.each(inputs, function(key,value){\r
-                    var v = $J(value);\r
-                    ret[v.attr('name')] = v.val();\r
-                });\r
-                callbackOnOk(ret);\r
-                return false;\r
-            }else{\r
-                return onCancel();\r
-            }\r
-        };\r
-        var subdiv = $J('<div/>').css({\r
-            'padding':'1ex',\r
-            'float':'right'\r
-        }).\r
-        append(\r
-            $J('<a/>').\r
-            html('Ok').\r
-            addClass('component_icon').\r
-            addClass('button').\r
-            addClass('icon_ok').\r
-            attr('href','#').\r
-            click(function(){\r
-                return onOk();\r
-            })\r
-            );\r
-        if(callbackOnOk){\r
-            subdiv.append(\r
-                $J('<a/>').\r
-                html('Cancel').\r
-                addClass('component_icon').\r
-                addClass('button').\r
-                addClass('icon_cancel').\r
-                attr('href','#').\r
-                click(function(){\r
-                    return onCancel();\r
-                })\r
-                );\r
-        }\r
-        //popupDialog(element,table,onOk);\r
-        return $J('<div/>').append(table).append(subdiv);\r
-    }\r
-}\r
-\r
 /**\r
  * Loads scripts asynchronously\r
  * can take up to four arguments:\r
@@ -678,6 +374,7 @@ function PopupDiv(){
 \r
 }\r
 \r
+\r
 (function(p){\r
     //private static variables\r
     var $ = jQuery;\r
@@ -690,7 +387,7 @@ function PopupDiv(){
 \r
     //in the functions below, this refers to the new Popup instance, not to the prototype\r
 \r
-    \r
+\r
 \r
     p.isClickElement = function(element){\r
         return element && element.length==1 && element instanceof $ && element[0] !== w_ && element[0] !== d_ &&\r
@@ -706,7 +403,7 @@ function PopupDiv(){
         return div.attr('id');\r
     };\r
 \r
-    \r
+\r
     //default properties which can be overridden\r
     p.shadowOffset = 4;\r
     p.invoker = wdw;\r
@@ -733,7 +430,7 @@ function PopupDiv(){
     p.shadowOpacity = 0.25;\r
     p.zIndex = 10000;\r
    // p.listItemClass = '';\r
-    \r
+\r
     p.getFormData = function(){\r
         var elms = this.find('input,select,textarea');\r
         var ret = {};\r
@@ -777,7 +474,7 @@ function PopupDiv(){
             }\r
         }\r
     };\r
-    \r
+\r
     p.trigger = function(eventName){\r
         var listeners = this.getListeners();\r
         var me = this;\r
@@ -814,7 +511,7 @@ function PopupDiv(){
         var container =   $($(div).children()[1]);\r
         //div.appendTo('body'); //necessary to properly display the div size\r
         container.empty();\r
-      \r
+\r
         if(content instanceof $){\r
             container.append(content);\r
         }else if(content instanceof Array){\r
@@ -975,9 +672,9 @@ function PopupDiv(){
                 this.invoker.attr('tabindex',0).attr(focusAttr,'true');\r
             }\r
         var doc_ = d_; //closure (see nested function below)\r
-        \r
+\r
         //now all elements (including header and footer)\r
-        \r
+\r
         var me = this;\r
         //bind the blur to each focusable element:\r
         elementsWithFocus.each(function(i,e){\r
@@ -995,7 +692,7 @@ function PopupDiv(){
                         //timeout should execute\r
                         return;\r
                     }\r
-                    \r
+\r
                     me.close();\r
                 },200)\r
             }); //set here another time delay. 300 seems to be the good compromise between visual hide and safetiness that\r
@@ -1011,8 +708,8 @@ function PopupDiv(){
     p.show = function(){\r
         var div = this.getDiv();\r
         var me = this;\r
-        \r
-        \r
+\r
+\r
         var cssModified = (this.popupClass || this.popupCss);\r
         if(this.popupClass){\r
             //which might be the prototype\r
@@ -1042,7 +739,7 @@ function PopupDiv(){
 //            this.listItemClass = "";\r
 //        }\r
 //        elms.css('display','block');\r
-        \r
+\r
 \r
         this.setFocusCycleRoot(this.focusable);\r
         this.setSizable();//this means the popupdiv is display: !none and visibility:hidden, so every element\r
@@ -1092,7 +789,7 @@ function PopupDiv(){
         //do the same as above, ok must exist and be visible, otherwise is undefined\r
         var okButton = bottomDiv.find('a');\r
         okButton = okButton.length ? $(okButton.get(0)) : undefined;\r
-        \r
+\r
         //see note above about why we dont use okButton.is(':visible')\r
         if(this.showok){\r
             bottomDiv.css('paddingTop','0.5ex').show(); //add padding to bottom\r
@@ -1121,9 +818,9 @@ function PopupDiv(){
             'width':''\r
         });\r
 \r
-        \r
+\r
         var invoker = this.invoker;\r
-        \r
+\r
         var sizeAsPopup = false;\r
         if(this.isClickElement(invoker)){\r
             this.setBoundsAsPopup(invoker, true);\r
@@ -1161,7 +858,7 @@ function PopupDiv(){
             this.setBoundsInside(invoker, this.bounds, this.boundsexact, true);\r
         }\r
 \r
-        \r
+\r
 \r
         //set central div max height ONLY IF NECESSARY:\r
         var maxHeight = (div.height()-topDiv.outerHeight(true)-bottomDiv.outerHeight(true)-\r
@@ -1207,7 +904,7 @@ function PopupDiv(){
         attr('id',this.getShadowDivId()) //for use in hide\r
         .insertAfter(div);\r
 \r
-        \r
+\r
         var postShowFcn = function(){\r
             me.trigger('show');\r
             var rect = me.getBounds.apply(me);\r
@@ -1225,32 +922,45 @@ function PopupDiv(){
         }\r
 \r
         div.hide().css('visibility','visible').show(this.fadInTime,function(){\r
-            \r
+\r
             postShowFcn();\r
-            \r
-            \r
+\r
+\r
         });\r
     };\r
-    \r
+\r
     p.setBoundsAsPopup = function(popupInvoker, isSizable){\r
         var invoker = popupInvoker;\r
         var div = this.getDiv();\r
         var oldCss= isSizable ?  undefined : this.setSizable();\r
-        \r
+\r
         var windowRectangle = this.getBoundsOf(wdw); //returns the window rectangle\r
 \r
         var invokerOffset = invoker.offset();\r
         var invokerOuterHeight = invoker.outerHeight();\r
 \r
+        //first set the maxwidth,so that we can compute the height according to it:\r
+        this.setMaxSize({\r
+            width: wdw.scrollLeft()+wdw.width()-invokerOffset.left\r
+        },isSizable);\r
+\r
+\r
         var spaceAbove = invokerOffset.top - windowRectangle.y;\r
         var spaceBelow = windowRectangle.height - invokerOuterHeight - spaceAbove;\r
 \r
+        var placeAbove = spaceAbove > spaceBelow && div.outerHeight(true) > spaceBelow;\r
+        //note that div.outerHeight() should be  == div.outerHeight(true), as we set margins =0\r
+\r
+//        alert(div.outerHeight(true)+' '+spaceAbove+' '+spaceBelow);\r
+//        div.css('visibility','');\r
+//        return;\r
+\r
         this.setMaxSize({\r
-            height : spaceAbove>spaceBelow ? spaceAbove : spaceBelow,\r
-            width: wdw.scrollLeft()+wdw.width()-invokerOffset.left\r
+            height : (placeAbove ? spaceAbove : spaceBelow)\r
         },isSizable); //width will be ignored (for the moment)\r
-        \r
-        \r
+        //decrement of one pixel cause when the popup has to be reduced and the shadows bounds "touch" the window right or bottom sides,\r
+        //the window scrolls (and it shouldn't)\r
+\r
         //setting the minimum size to the invoker width, minheight the same as maxHeight (see above)\r
         this.setMinSize({\r
             width: invoker.outerWidth()+this.shadowOffset //workaround to NOT consider the shadow, as offset below substracts the shadow\r
@@ -1263,7 +973,7 @@ function PopupDiv(){
         //must have been computed according to the height set above...\r
         this.offset({\r
             'left': invokerOffset.left,\r
-            'top': (spaceAbove > spaceBelow ? invokerOffset.top -  div.outerHeight(true) :\r
+            'top': (placeAbove ? invokerOffset.top -  div.outerHeight(true) :\r
                 invokerOffset.top + invokerOuterHeight)\r
         },isSizable);\r
         if(oldCss){\r
@@ -1284,21 +994,21 @@ function PopupDiv(){
         var oldCss = isSizable ?  undefined : this.setSizable();\r
 \r
         var bounds = this.getBoundsOf(parent);\r
-        \r
+\r
         var x=bounds.x;\r
         var y = bounds.y;\r
         var w = bounds.width\r
         var h = bounds.height;\r
         var pInt = parseInt;\r
         //rebuilding:\r
-        \r
+\r
         var padding = {\r
             top: pd['top'],\r
             left:pd['left'],\r
             bottom:pd['bottom'],\r
             right:pd['right']\r
         };\r
-        \r
+\r
         for(var k in padding){\r
             if(padding[k]<=0){\r
                 padding[k]=0;\r
@@ -1313,13 +1023,13 @@ function PopupDiv(){
             'width':w-padding['left']-padding['right']+this.shadowOffset,\r
             'height':h-padding['top']-padding['bottom']+this.shadowOffset\r
         };\r
-            \r
+\r
         var vvvv ={\r
             width:maxSize.width,\r
             height:maxSize.height\r
         };\r
         this._convertSize(div, vvvv);\r
-           \r
+\r
         if(boundsExact){\r
             this.setMinSize({\r
                 width:maxSize.width,\r
@@ -1329,7 +1039,7 @@ function PopupDiv(){
                 width:maxSize.width,\r
                 height:maxSize.height\r
             }, isSizable); //a copy cause the argument will be modified\r
-            \r
+\r
             this.offset({\r
                 'left':x + padding['left'],\r
                 'top': y + padding['top']\r
@@ -1348,7 +1058,7 @@ function PopupDiv(){
 \r
         }\r
         //convert to percentage in order to keep same dimensions when zooming\r
-        \r
+\r
 \r
         if(oldCss){\r
             div.css({\r
@@ -1441,7 +1151,7 @@ function PopupDiv(){
             'width': div.outerWidth(true)-div.width(),\r
             'height':div.outerHeight(true)-div.height()\r
         };\r
-        \r
+\r
         if('width' in size){\r
             size.width -= (eD.width + this.shadowOffset);\r
         }\r
@@ -1454,7 +1164,7 @@ function PopupDiv(){
         var div = this.getDiv();\r
         var oldCss= isSizable?  undefined : this.setSizable();\r
         //offset does NOT consider margins. Do we have top and left?\r
-        \r
+\r
         this.getDiv().offset(offs);\r
         if(oldCss){\r
             div.css({\r
@@ -1478,13 +1188,13 @@ function PopupDiv(){
         var me = this;\r
         var remove = this.defaultCloseOperation == 'remove';\r
         div.hide(this.fadeOutTime, function(){\r
-            \r
+\r
             if(remove){\r
                 div.remove();\r
             //this is because all bindings will be removed, including blur events\r
             //we remove this.getFocusAttr() to reupdate focus cycle root when calling show again\r
             }\r
-            \r
+\r
             //restore event data on invoker, if any\r
             var id = '_tmpHandlers'+me.getId();\r
             if(me[id]){\r
@@ -1500,7 +1210,7 @@ function PopupDiv(){
             me.isClosing = false;\r
             me.trigger('close');\r
         });\r
-        \r
+\r
     };\r
 \r
 \r
@@ -1542,28 +1252,5 @@ function PopupDiv(){
         return this.getId()+"_focus";\r
     }\r
 \r
-//    p.getListItemName = function(){\r
-//        return this.getId()+"_listitem";\r
-//    }\r
-\r
-    \r
-})(PopupDiv.prototype);\r
-\r
-////default PopupDiv properties in telemeta\r
-////PopupDiv.listItemClass = 'component_icon list_item icon_playlist';\r
-//PopupDiv.shadowOffset = 4;\r
-//PopupDiv.popupClass = 'control component';\r
-//PopupDiv.popupCss = {\r
-//    'border':'1px solid #666',\r
-//    'padding':'1ex'\r
-//};\r
-//PopupDiv.okButtonTitle =  'Ok';\r
-//PopupDiv.okButtonClass =  'component_icon button icon_ok';\r
-//PopupDiv.closeButtonTitle =  '';\r
-//PopupDiv.closeButtonClass =  'markersdivDelete';\r
-//PopupDiv.fadInTime = 'fast',\r
-//    PopupDiv.fadeOutTime = 0,\r
-//    PopupDiv.shadowOpacity = 0.3;\r
-\r
-\r
 \r
+})(PopupDiv.prototype);
\ No newline at end of file
index f9cfd0511135f955aba3bd7a2538bad5d5d40c62..1245ad184440ddd4f5d52afd76f7ba7d682b2e32 100644 (file)
@@ -115,7 +115,6 @@ var MarkerMapDiv = TimesideArray.extend({
             return;
         }
         var e_okButton = div.find('.markersdivSave');
-       
         var e_descriptionText = div.find('.markersdivDescription');
         var e_titleText = div.find('.markersdivTitle');
         if(value){
@@ -134,10 +133,15 @@ var MarkerMapDiv = TimesideArray.extend({
             editButton.show();
             div.css('backgroundColor','');
         }
+
+        //var e_addplaylistButton = div.find('.markersdivAddPlaylist');
+
         this.setFocus(index,value);
         this.stretch(e_titleText);
     },
 
+    
+
     setFocus: function(index,value){
     //        this.each(function(i,div){
     //            if(i==index && value){
@@ -153,17 +157,14 @@ var MarkerMapDiv = TimesideArray.extend({
         //div.attr('id','_markerdiv'+index);
         div.find('.ts-marker').html(index+1);
         var me = this;
-        div.find('.markersdivDescription').unbind('focus').focus(function(){
-            me.setFocus(index,true);
-            me.fire('focus', {
-                'index': index
-            });
-        });
-        div.find('.markersdivTitle').unbind('focus').focus(function(){
+        var e_indexLabel = div.find('.ts-marker');
+        var e_offsetLabel =div.find('.markersdivOffset');
+        e_indexLabel.add(e_offsetLabel).unbind('click').click(function(){
             me.setFocus(index,true);
             me.fire('focus', {
                 'index': index
             });
+            return false;
         });
         div.find('.markersdivEdit').unbind('click').click( function(){
             me.setEditMode(index);
@@ -195,8 +196,8 @@ var MarkerMapDiv = TimesideArray.extend({
         //for the moment we set the style manually, remove
         //TODO: table width with CSS?
         var div = this.$J('<div/>').attr('tabindex','0').addClass("markerdiv").html('<div>'+
-            '<a class="ts-marker"></a>'+
-            '<span class="markersdivOffset" type="text"></span>'+
+            '<a href=# class="ts-marker"></a>'+
+            '<a href=# class="markersdivOffset" type="text"></a>'+
             '<input class="markersdivTitle" type="text"/>'+
             '<a class="markersdivAddPlaylist" title="add to playlist"></a>'+
             '<a class="markersdivEdit" title="edit">EDIT</a>'+
@@ -242,24 +243,28 @@ var MarkerMapDiv = TimesideArray.extend({
 
         //add to playlist always visible, provided that it is saved on server AND current user is logged
         //(getCurrentUserName evaluates to true)
-        if(!marker.isSavedOnServer || !this.getCurrentUserName()){
-            e_addplaylistButton.hide();
-        }else{
-            e_addplaylistButton.unbind('click').bind('click',function(evtObj_){
-                if(!marker.isSavedOnServer){
-                    return false;
-                }
-                //make a request to the server to get the pk (id)
-                //note that marker.id (client side) is marker.public_id (server side)
-                json([marker.id],"telemeta.get_marker_id", function(data){
-                    consolelog('received');
-                    consolelog(data);
-                    var id = data.result;
-                    playlistUtils.showAddResourceToPlaylist(e_addplaylistButton,'marker',""+id,gettrans('marker added to the selected playlist'));
-                });
+        //        if(!marker.isSavedOnServer || !this.getCurrentUserName()){
+        //            e_addplaylistButton.hide();
+        //        }else{
+        e_addplaylistButton.unbind('click').bind('click',function(evtObj_){
+            if(!marker.isSavedOnServer){
                 return false;
+            }
+            //make a request to the server to get the pk (id)
+            //note that marker.id (client side) is marker.public_id (server side)
+            json([marker.id],"telemeta.get_marker_id", function(data){
+                consolelog('received');
+                consolelog(data);
+                var id = data.result;
+                playlistUtils.showAddResourceToPlaylist(e_addplaylistButton,'marker',""+id,gettrans('marker added to the selected playlist'));
             });
-        }
+            return false;
+        });
+
+
+
+
+
         if(!marker.isEditable){ //marker is editable means that author == getCurrentUserName(). addToPlaylist
             //visibility is skipped because it depends on other circumstances (see above)
             e_editButton.hide();
index 2d3df74de110d818078cdcbcc1aad4dc92886784..000d7cba305705dce568bb839adae7077fb95c44 100644 (file)
@@ -18,6 +18,23 @@ var MarkerMap = TimesideArray.extend({
         this.getCurrentUserName = function(){
             return currentUserName;
         }
+
+        var me = this;
+        var confirmExit = function(){
+            var markerUnsaved=0;
+            me.each(function(i,marker){
+                if(!marker.isSavedOnServer){
+                    markerUnsaved++;
+                }
+            });
+            consolelog(markerUnsaved);
+            if(markerUnsaved>0){
+                return 'There ' + (markerUnsaved==1 ? 'is ' : 'are ') + markerUnsaved+ ' unsaved marker'+
+                    (markerUnsaved==1 ? '' : 's') + '. If you exit the page you will loose your changes';
+            }
+                
+        };
+        window.onbeforeunload = confirmExit;
     },
 
     //overridden
@@ -119,12 +136,12 @@ var MarkerMap = TimesideArray.extend({
         var functionOnSuccess = function(){
             superRemove.apply(me,[idx]);
             me.fire('remove',{
-                    'index':idx
-                })
+                'index':idx
+            })
         }
 
         if(marker.isSavedOnServer){
-             //json(param,method,onSuccessFcn,onErrorFcn){
+            //json(param,method,onSuccessFcn,onErrorFcn){
             json([marker.id], "telemeta.del_marker",functionOnSuccess);
         }else{
             functionOnSuccess();
@@ -158,7 +175,7 @@ var MarkerMap = TimesideArray.extend({
                 marker.isSavedOnServer = true;
                 marker.isModified = false;
             }
-             me.fire('save',{
+            me.fire('save',{
                 'index':idx
             });
         };
@@ -168,11 +185,11 @@ var MarkerMap = TimesideArray.extend({
     },
 
     //TODO: there is no need of a public method
-//    removeHTTP: function(marker){
-//        var public_id = marker.id
-//        //json(param,method,onSuccessFcn,onErrorFcn){
-//        json([public_id], "telemeta.del_marker");
-//    },
+    //    removeHTTP: function(marker){
+    //        var public_id = marker.id
+    //        //json(param,method,onSuccessFcn,onErrorFcn){
+    //        json([public_id], "telemeta.del_marker");
+    //    },
 
     //overridden method
     move: function(markerIndex, newOffset){
@@ -239,8 +256,8 @@ var MarkerMap = TimesideArray.extend({
                 }
             }
             return 0;
-            //var ret = a < b ? -1 : (a>b ? 1 : (markerInMap.id === newMarker.id ? 0 : -1));
-            //return ret;
+        //var ret = a < b ? -1 : (a>b ? 1 : (markerInMap.id === newMarker.id ? 0 : -1));
+        //return ret;
         };
         if(!(typeof object == 'object')){
             var offset;
index d226bb075603e3f94fec25cd0cb4681c4e494946..d896608eb9b030dfb9e485b531524e01c2dd3d7b 100644 (file)
@@ -21,7 +21,7 @@
     soundManager.url = '{% url telemeta-swf "./" %}';
     soundManager.flashVersion = 9;
     soundManager.useMovieStar = true; // enable MP4/M4A/AAC
-    soundManager.debugMode = true;
+    soundManager.debugMode = false;
     soundManager.allowPolling = true;
 
     var setupPlaylist = function(){