From 101029b8a32e185c924ed3969193e56b405f150a Mon Sep 17 00:00:00 2001 From: riccardo Date: Fri, 18 Mar 2011 20:26:05 +0100 Subject: [PATCH] still to fix popup div and add2playlist. playlist addnew and delete work --- telemeta/htdocs/css/telemeta.css | 4 +- telemeta/htdocs/js/application.js | 122 +++++++++++++++++- telemeta/htdocs/timeside/src/playlist.js | 4 +- .../telemeta_default/mediaitem_detail.html | 14 +- 4 files changed, 134 insertions(+), 10 deletions(-) diff --git a/telemeta/htdocs/css/telemeta.css b/telemeta/htdocs/css/telemeta.css index 23f7cc96..ca9df22b 100644 --- a/telemeta/htdocs/css/telemeta.css +++ b/telemeta/htdocs/css/telemeta.css @@ -978,7 +978,7 @@ a.image-link { .mediaitem_button, .mediaitem_button:visited, .mediaitem_button:link{ - padding:5px 10px 5px 26px; /*top right bottom left - last value depends on the icon size (default=16)*/ + padding:4px 8px 4px 26px; /*top right bottom left - last value depends on the icon size (default=16)*/ border-top: 1px solid #DDD; border-left: 1px solid #DDD; border-bottom: 1px solid #666; @@ -998,7 +998,7 @@ a.image-link { text-decoration: none; } .mediaitem_button_no_icon{ - padding:5px 10px 5px 10px !important; + padding:4px 8px 4px 8px !important; } .mediaitem_button_edit{ background-image: url('/images/edit_page.png'); diff --git a/telemeta/htdocs/js/application.js b/telemeta/htdocs/js/application.js index 2e6df83e..bc0a49d7 100644 --- a/telemeta/htdocs/js/application.js +++ b/telemeta/htdocs/js/application.js @@ -53,10 +53,21 @@ function setSelectedMenu(){ //function for normalizing paths (removes last n occurrences of the slash) var normalize = function(str){ - return str.replace(/\/+$/,""); + return str.replace(/\/+#*$/,""); } - var pageOrigin = normalize(window.location.origin); - var pageHref = normalize(window.location.href); + + var host = window.location.host; + var protocol = window.location.protocol + var href = normalize(window.location.href); + + if(!(host) || !(protocol) || !(href)){ + return; + } + + //var pageOrigin = normalize(window.location.origin); //does not exist in FF, so: + var pageOrigin = normalize(protocol+"//"+host); + var pageHref = normalize(href); + menus.each(function(){ ///if we are at home, the window location href corresponds to window location origin, //so we select only links whose link points EXACTLY to the origin (home link) @@ -242,10 +253,111 @@ popupDialog = function(invokerElement,divContent,callbackOnOk){ height:div.outerHeight(), left: (left + 5)+'px', top:(top+5)+"px" - }); + }); div.fadeIn('fast', function() { divShadow.insertAfter(div); divShadow.fadeTo(0,0.4); cancelB.focus(); }); -} \ No newline at end of file +} +popup={ + id: '_popup_id__', + isFocused:false, + hide: function(){ + var $J = jQuery; + $J(document).unbind('click'); + $J(document).unbind('keydown'); + var popupdiv = $J(this.id); + if(popupdiv){ + popupdiv.remove(); + this.isFocused = false; + } + }, + show:function(invokerElement,divContent){ + var popupId = this.id; + var createDiv = function(){ + return jQuery("
").append(jQuery("
").css({ + 'backgroundColor':'#000', + position:'absolute', + bottom:0, + right:0, + top:'5px', + left:'5px' + })) + .append( + jQuery("
").css({ + position: 'absolute', + top:0, + left:0, + padding: '1ex', + border: '1px solid #DDD', + backgroundColor:'#eee' + })).attr('id',popupId).css({ + display: 'none', + position: 'absolute', + zIndex:1000 + }); + } + var $J = jQuery; + var div = createDiv() + + //adding + div.insertBefore(invokerElement); + + var mainDiv = $J(div.children()[1]).append(divContent); + var me = this; + var hide = this.hide; + + var children = $J(divContent).find('*'); + $(children).each(function(){ + $J(this).focus(function(){ + me.isFocused = true; + }); + $J(this).blur(function(){ + me.isFocused = false; + }); + }); + + //setting positions: + var pos = invokerElement.position(); + var top = (invokerElement.outerHeight(true)+pos.top); + var left = pos.left; + div.css({ + left: left + 'px', + top:top+"px" + }); + + + //showing + div.fadeIn('fast', function() { + //now that is displayed, set the parent div size (which affects the shadow, too) + var w = mainDiv.outerWidth(); + var h = mainDiv.outerHeight(); + div.css({ + width:(w+5)+'px', + height:(h+5)+'px' + }); + //show the shadow + $J(div.children()[0]).fadeTo(0,0.4); + var inputs = $J(divContent).find(':input'); + me.isFocused=false; + if(inputs && inputs[0]){ + inputs[0].focus(); + //me.isFocused=true; + } + jQuery(document).bind('click', function(){ + if(me.isFocused){ + return; + } + hide.apply(me); + }); + jQuery(document).bind('keydown', function(){ + if(me.isFocused){ + return; + } + hide.apply(me); + }); + }); + } + +} diff --git a/telemeta/htdocs/timeside/src/playlist.js b/telemeta/htdocs/timeside/src/playlist.js index d8c093fd..0a280f3c 100644 --- a/telemeta/htdocs/timeside/src/playlist.js +++ b/telemeta/htdocs/timeside/src/playlist.js @@ -28,8 +28,8 @@ var playlist = { window.location.reload(); },true); }; - popupDialog(element,table,onOk); - + //popupDialog(element,table,onOk); + popup.show(element,table); }, remove: function(id){ diff --git a/telemeta/templates/telemeta_default/mediaitem_detail.html b/telemeta/templates/telemeta_default/mediaitem_detail.html index 7a494558..6d904317 100644 --- a/telemeta/templates/telemeta_default/mediaitem_detail.html +++ b/telemeta/templates/telemeta_default/mediaitem_detail.html @@ -39,7 +39,19 @@ {% trans "Copy" %} {% endif %} {% if user.is_authenticated %} - {% trans "Add to playlist" %} + + + + + + + {% endif %} {% trans "Previous" %} {% trans "Next" %} -- 2.39.5