]> git.parisson.com Git - telemeta.git/commitdiff
fix drop down menu highlight
authoryomguy <yomguy@parisson.com>
Tue, 31 Jan 2012 15:24:50 +0000 (16:24 +0100)
committeryomguy <yomguy@parisson.com>
Tue, 31 Jan 2012 15:24:50 +0000 (16:24 +0100)
telemeta/htdocs/css/telemeta.css
telemeta/htdocs/js/application.js
telemeta/templates/telemeta/base.html
telemeta/urls.py
telemeta/views/base.py

index 4bec0d50a76aa286819897cdf809c6088bd50952..e1db6f333bc648e8d63fba77b27006f6da70108c 100644 (file)
@@ -460,6 +460,7 @@ form.login .submit {
     background-color: #FFF;
     color: #6a0307;
 }
+
 #menu .darkblue { border-bottom-color: #0f3179; }
 #menu .blue { border-bottom-color:  #4f628a; }
 #menu .green { border-bottom-color:  #92b220; }
@@ -545,10 +546,6 @@ color:#FFF;
     color: #6a0307 ;
 }
 
-#nav ul a:active{
-    background-color: #FFF;
-    color: #6a0307 ;
-}
 
 
 
index 9ddf1971e2b1a0d38bed8975c57a6b718af8d263..bde5903c7249c69cc9fd882c8f1e01b9ab2cdbb7 100644 (file)
-/*\r
- * Copyright (C) 2007-2011 Parisson\r
- * Copyright (c) 2011 Riccardo Zaccarelli <riccardo.zaccarelli@gmail.com>\r
- * Copyright (c) 2010 Olivier Guilyardi <olivier@samalyse.com>\r
- *\r
- * This file is part of TimeSide.\r
- *\r
- * TimeSide is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * TimeSide is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with TimeSide.  If not, see <http://www.gnu.org/licenses/>.\r
- *\r
- * Authors: Riccardo Zaccarelli <riccardo.zaccarelli@gmail.com>\r
- *          Olivier Guilyardi <olivier@samalyse.com>\r
- */\r
-\r
-/**\r
- * Class for telemeta global functions.\r
- * Note that the dollar sign is a reserved keyword in some browsers\r
- * (see http://davidwalsh.name/dollar-functions)\r
- * which might be in conflict with jQuery dollar sign.\r
- */\r
-\r
-//returns the full path of the current url location removing the last slash '/' followed by one or more '#', if any\r
-function urlNormalized(){\r
-    var sPath = window.location.href;\r
-    sPath = sPath.replace(/\/#*$/,"");\r
-    return sPath;\r
-}\r
-/**\r
- *sets up few stuff when the page is ready (see functions below it)\r
- */\r
-jQuery(document).ready(function() {\r
-    foldInfoBlocks();\r
-    setSelectedMenu();\r
-});\r
-\r
-/**\r
- *function inherited from old code, never touched. Guess fixes the click on the left data table, if any\r
- */\r
-function foldInfoBlocks() {\r
-    var $J = jQuery;\r
-    var extra = $J('.extraInfos');\r
-    extra.find('.folded dl, .folded table').css('display', 'none');\r
-    extra.find('h4').click(function() {\r
-        $J(this).parents('.extraInfos').children().toggleClass('folded').find('dl, table').toggle(100);\r
-        //toggle toggles the visibility of elements\r
-        return false;\r
-    });\r
-}\r
-\r
-/**\r
- * Global telemeta function which sets the current selected menu according to the current url\r
- */\r
-function setSelectedMenu(){\r
-    var $J = jQuery;\r
-    var menus = $J('#menu a');\r
-    //build collections/items from http:/site/collections/items,\r
-    //being http:/site/ = window.location.origin\r
-    \r
-    //function for normalizing paths (removes last n occurrences of the slash)\r
-    var normalize = function(str){\r
-        return str.replace(/\/+#*$/,"");\r
-    }\r
-    \r
-    var host = window.location.host;\r
-    var protocol = window.location.protocol\r
-    var href = normalize(window.location.href);\r
-     \r
-    if(!(host) || !(protocol) || !(href)){\r
-        return;\r
-    }\r
-\r
-    //var pageOrigin = normalize(window.location.origin); //does not exist in FF, so:\r
-    var pageOrigin = normalize(protocol+"//"+host);\r
-    var pageHref = normalize(href);\r
-\r
-    menus.each(function(){\r
-        ///if we are at home, the window location href corresponds to window location origin,\r
-        //so we select only links whose link points EXACTLY to the origin (home link)\r
-        var linkHref = normalize(this.href);\r
-        var elm = $J(this);\r
-        if(pageOrigin===pageHref){\r
-            if(pageHref == linkHref){\r
-                elm.addClass('active');\r
-            }else{\r
-                elm.removeClass('active');\r
-            }\r
-        }else{\r
-            //here, on the other hand, we select if a link points to a page or super page\r
-            //of the current page\r
-            if(linkHref!=pageOrigin && pageHref.match("^"+linkHref+".*")){\r
-                elm.addClass('active');\r
-            }else{\r
-                elm.removeClass('active');\r
-            }\r
-        }\r
-        \r
-    })\r
-}\r
-\r
-\r
-\r
-\r
-/*****************************************************************************\r
- * json(param, method, onSuccesFcn(data, textStatus, jqXHR), onErrorFcn(jqXHR, textStatus, errorThrown))\r
- * global function to senbd/retrieve data with the server\r
- *\r
- * param: the data to be sent or retrieved.\r
- *   param will be converted to string, escaping quotes newlines and backslashes if necessary.\r
- *   param can be a javascript string, boolean, number, dictionary and array.\r
- *       If dictionary or array, it must contain only the above mentioned recognized types.\r
- *       So, eg, {[" a string"]} is fine, {[/asd/]} not\r
- *\r
- * method: the json method, eg "telemeta.update_marker". See base.py\r
- *\r
- * onSuccesFcn(data, textStatus, jqXHR) OPTIONAL --IF MISSING, NOTHING HAPPENS --\r
- *    A function to be called if the request succeeds with the same syntax of jQuery's ajax onSuccess function.\r
- *    The function gets passed three arguments\r
- *       The data returned from the server, formatted according to the dataType parameter;\r
- *       a string describing the status;\r
- *       and the jqXHR (in jQuery 1.4.x, XMLHttpRequest) object\r
- *\r
- * onErrorFcn(jqXHR, textStatus, errorThrown) OPTIONAL. --IF MISSING, THE DEFAULT ERROR DIALOG IS SHOWN--\r
- *     A function to be called if the request fails with the same syntax of jQuery ajax onError function..\r
- *     The function receives three arguments:\r
- *       The jqXHR (in jQuery 1.4.x, XMLHttpRequest) object,\r
- *       a string describing the type of error that occurred and\r
- *       an optional exception object, if one occurred.\r
- *       Possible values for the second argument (besides null) are "timeout", "error", "abort", and "parsererror".\r
- * ****************************************************************************/\r
-\r
-var json = function(param,method,onSuccessFcn,onErrorFcn){\r
-    //this function converts a javascript object to a string\r
-    var toString_ = function(string){\r
-        if(typeof string == "string"){\r
-            //escapes newlines quotes and backslashes\r
-            string = string.replace(/\\/g,"\\\\")\r
-            .replace(/\n/g,"\\n")\r
-            .replace(/"/g,"\\\"");\r
-        }\r
-        var array; //used for arrays and objects (see below)\r
-        if(typeof string == "boolean" || typeof string== "number" || typeof string == "string"){\r
-            string = '"'+string+'"';\r
-        }else if(string instanceof Array){\r
-            array = [];\r
-            for(var i = 0;i <string.length ; i++){\r
-                array.push(toString_(string[i])); //recursive invocation\r
-            }\r
-            string='[';\r
-            string+=array.join(",");\r
-            string+=']';\r
-        }else{\r
-            array = [];\r
-            for(var k in string){\r
-                array.push(toString_(k)+":"+toString_(string[k])); //recursive invocation\r
-            }\r
-            string='{';\r
-            string+=array.join(",");\r
-            string+='}';\r
-        }\r
-        return string;\r
-    };\r
-    \r
-    //creating the string to send. \r
-    var param2string = toString_(param);\r
-    var data2send = '{"id":"jsonrpc", "params":';\r
-    data2send+=param2string;\r
-    data2send+=', "method":"'\r
-    data2send+=method;\r
-    data2send+='","jsonrpc":"1.0"}';\r
-    \r
-    var $J = jQuery;\r
-    $J.ajax({\r
-        type: "POST",\r
-        url: 'json/',\r
-        contentType: "application/json",\r
-        data: data2send,\r
-        dataType: "json",\r
-        success: function(data, textStatus, jqXHR){\r
-            if(onSuccessFcn){\r
-                onSuccessFcn(data, textStatus, jqXHR);\r
-            }\r
-        },\r
-        error: function(jqXHR, textStatus, errorThrown){\r
-            if(onErrorFcn){\r
-                onErrorFcn(jqXHR, textStatus, errorThrown);\r
-                return;\r
-            }\r
-            //default:\r
-            var details = "\n(no further info available)";\r
-            if(jqXHR) {\r
-                details="\nThe server responded witha status of "+jqXHR.status+" ("+\r
-                jqXHR.statusText+")\n\nDetails (request responseText):\n"+jqXHR.responseText;\r
-            }\r
-            alert("ERROR: Failed to save"+details);\r
-            \r
-        }\r
-    });\r
-\r
-};\r
-\r
-/**\r
- * function for writing to the console. Catches errors, if any (eg, console == undefined) and does nothing in case\r
- */\r
-function consolelog(text){\r
-    if(typeof console != 'undefined'){\r
-        var c = console;\r
-        if (c.log) {\r
-            c.log(text);\r
-        }\r
-    }\r
-}\r
-\r
-// Drop down menus\r
-\r
-$(document).ready(function () {\r
-     \r
-    $('#nav li').hover(\r
-        function () {\r
-            //show its submenu\r
-            $('ul', this).slideDown(200);\r
\r
-        },\r
-        function () {\r
-            //hide its submenu\r
-            $('ul', this).slideUp(100);        \r
-        }\r
-    );\r
-     \r
+/*
+ * Copyright (C) 2007-2012 Guillaume Pellerin, Parisson
+ * Copyright (c) 2011 Riccardo Zaccarelli <riccardo.zaccarelli@gmail.com>
+ * Copyright (c) 2010 Olivier Guilyardi <olivier@samalyse.com>
+ *
+ * This file is part of TimeSide.
+ *
+ * TimeSide is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * TimeSide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with TimeSide.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors: Riccardo Zaccarelli <riccardo.zaccarelli@gmail.com>
+ *          Olivier Guilyardi <olivier@samalyse.com>
+ */
+
+/**
+ * Class for telemeta global functions.
+ * Note that the dollar sign is a reserved keyword in some browsers
+ * (see http://davidwalsh.name/dollar-functions)
+ * which might be in conflict with jQuery dollar sign.
+ */
+
+//returns the full path of the current url location removing the last slash '/' followed by one or more '#', if any
+function urlNormalized(){
+    var sPath = window.location.href;
+    sPath = sPath.replace(/\/#*$/,"");
+    return sPath;
+}
+/**
+ *sets up few stuff when the page is ready (see functions below it)
+ */
+jQuery(document).ready(function() {
+    foldInfoBlocks();
+    setSelectedMenu();
+});
+
+/**
+ *function inherited from old code, never touched. Guess fixes the click on the left data table, if any
+ */
+function foldInfoBlocks() {
+    var $J = jQuery;
+    var extra = $J('.extraInfos');
+    extra.find('.folded dl, .folded table').css('display', 'none');
+    extra.find('h4').click(function() {
+        $J(this).parents('.extraInfos').children().toggleClass('folded').find('dl, table').toggle(100);
+        //toggle toggles the visibility of elements
+        return false;
+    });
+}
+
+/**
+ * Global telemeta function which sets the current selected menu according to the current url
+ */
+function setSelectedMenu(){
+    var $J = jQuery;
+    var menus = $J('#menu a');
+    //build collections/items from http:/site/collections/items,
+    //being http:/site/ = window.location.origin
+    
+    //function for normalizing paths (removes last n occurrences of the slash)
+    var normalize = function(str){
+        return str.replace(/\/+#*$/,"");
+    }
+    
+    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)
+        var linkHref = normalize(this.href);
+        var elm = $J(this);
+
+        if(linkHref.indexOf("#") != -1){
+            var reg = new RegExp("[#]+", "g");
+            var baseHref = linkHref.split(reg);
+            linkHref = pageOrigin + "/" + baseHref[1]
+        }
+
+        if(pageOrigin===pageHref){
+            if(pageHref == linkHref){
+                elm.addClass('active');
+            }else{
+                elm.removeClass('active');
+            }
+        }else{
+            //here, on the other hand, we select if a link points to a page or super page
+            //of the current page
+            if(linkHref!=pageOrigin && pageHref.match("^"+linkHref+".*")){
+                elm.addClass('active');
+            }else{
+                elm.removeClass('active');
+            }
+        }
+        
+    })
+}
+
+
+
+
+/*****************************************************************************
+ * json(param, method, onSuccesFcn(data, textStatus, jqXHR), onErrorFcn(jqXHR, textStatus, errorThrown))
+ * global function to senbd/retrieve data with the server
+ *
+ * param: the data to be sent or retrieved.
+ *   param will be converted to string, escaping quotes newlines and backslashes if necessary.
+ *   param can be a javascript string, boolean, number, dictionary and array.
+ *       If dictionary or array, it must contain only the above mentioned recognized types.
+ *       So, eg, {[" a string"]} is fine, {[/asd/]} not
+ *
+ * method: the json method, eg "telemeta.update_marker". See base.py
+ *
+ * onSuccesFcn(data, textStatus, jqXHR) OPTIONAL --IF MISSING, NOTHING HAPPENS --
+ *    A function to be called if the request succeeds with the same syntax of jQuery's ajax onSuccess function.
+ *    The function gets passed three arguments
+ *       The data returned from the server, formatted according to the dataType parameter;
+ *       a string describing the status;
+ *       and the jqXHR (in jQuery 1.4.x, XMLHttpRequest) object
+ *
+ * onErrorFcn(jqXHR, textStatus, errorThrown) OPTIONAL. --IF MISSING, THE DEFAULT ERROR DIALOG IS SHOWN--
+ *     A function to be called if the request fails with the same syntax of jQuery ajax onError function..
+ *     The function receives three arguments:
+ *       The jqXHR (in jQuery 1.4.x, XMLHttpRequest) object,
+ *       a string describing the type of error that occurred and
+ *       an optional exception object, if one occurred.
+ *       Possible values for the second argument (besides null) are "timeout", "error", "abort", and "parsererror".
+ * ****************************************************************************/
+
+var json = function(param,method,onSuccessFcn,onErrorFcn){
+    //this function converts a javascript object to a string
+    var toString_ = function(string){
+        if(typeof string == "string"){
+            //escapes newlines quotes and backslashes
+            string = string.replace(/\\/g,"\\\\")
+            .replace(/\n/g,"\\n")
+            .replace(/"/g,"\\\"");
+        }
+        var array; //used for arrays and objects (see below)
+        if(typeof string == "boolean" || typeof string== "number" || typeof string == "string"){
+            string = '"'+string+'"';
+        }else if(string instanceof Array){
+            array = [];
+            for(var i = 0;i <string.length ; i++){
+                array.push(toString_(string[i])); //recursive invocation
+            }
+            string='[';
+            string+=array.join(",");
+            string+=']';
+        }else{
+            array = [];
+            for(var k in string){
+                array.push(toString_(k)+":"+toString_(string[k])); //recursive invocation
+            }
+            string='{';
+            string+=array.join(",");
+            string+='}';
+        }
+        return string;
+    };
+    
+    //creating the string to send. 
+    var param2string = toString_(param);
+    var data2send = '{"id":"jsonrpc", "params":';
+    data2send+=param2string;
+    data2send+=', "method":"'
+    data2send+=method;
+    data2send+='","jsonrpc":"1.0"}';
+    
+    var $J = jQuery;
+    $J.ajax({
+        type: "POST",
+        url: 'json/',
+        contentType: "application/json",
+        data: data2send,
+        dataType: "json",
+        success: function(data, textStatus, jqXHR){
+            if(onSuccessFcn){
+                onSuccessFcn(data, textStatus, jqXHR);
+            }
+        },
+        error: function(jqXHR, textStatus, errorThrown){
+            if(onErrorFcn){
+                onErrorFcn(jqXHR, textStatus, errorThrown);
+                return;
+            }
+            //default:
+            var details = "\n(no further info available)";
+            if(jqXHR) {
+                details="\nThe server responded witha status of "+jqXHR.status+" ("+
+                jqXHR.statusText+")\n\nDetails (request responseText):\n"+jqXHR.responseText;
+            }
+            alert("ERROR: Failed to save"+details);
+            
+        }
+    });
+
+};
+
+/**
+ * function for writing to the console. Catches errors, if any (eg, console == undefined) and does nothing in case
+ */
+function consolelog(text){
+    if(typeof console != 'undefined'){
+        var c = console;
+        if (c.log) {
+            c.log(text);
+        }
+    }
+}
+
+// Drop down menus
+
+$(document).ready(function () {
+     
+    $('#nav li').hover(
+        function () {
+            //show its submenu
+            $('ul', this).slideDown(200);
+        },
+        function () {
+            //hide its submenu
+            $('ul', this).slideUp(100);        
+        }
+    );
+     
 });
\ No newline at end of file
index d62557613b58e4907f5aa1bc799923d5b2f7694d..442b5c5c8133346a577973f72d1531fb2cf04306 100644 (file)
@@ -74,7 +74,7 @@
 </form>
 </div>
 
-<div id="menu" class="nav">
+<div id="menu">
 {% block menu %}
 
 {# spaces between li and a elements breaks layout #}
 
 <ul id="nav">
  {% if user.is_authenticated %}
-  <li><a href="{% url telemeta-lists %}" class="blue">{% trans "Desk" %}</a>
+  <li><a href="#desk#" class="blue">{% trans "Desk" %}</a></span>
    <ul>
-    <li><a href="{% url telemeta-lists %}">{% trans "Lists" %}</a></li>
-    <li><a href="{% url telemeta-profile-detail user.username %}">{% trans "Profile" %}</a></li>
-    <li><a href="{% url telemeta-home %}">{% trans "Home" %}</a></li>
+    <li><a href="{% url telemeta-desk-lists %}">{% trans "Lists" %}</a></li>
+    <li><a href="{% url telemeta-desk-profile user.username %}">{% trans "Profile" %}</a></li>
+    <li><a href="{% url telemeta-desk-home %}">{% trans "Home" %}</a></li>
    </ul>
   </li>
  {% else %}
   <li><a href="{% url telemeta-home %}" class="blue">{% trans "Home" %}</a></li>
  {% endif %}
- <li><a href="{% url telemeta-archives %}" class="green">{% trans "Archives" %}</a>
+ <li><a href="#archives#" class="green">{% trans "Archives" %}</a>
   <ul>
-     <li><a href="{% url telemeta-fonds %}">{% trans "Fonds" %}</a></li>
-     <li><a href="{% url telemeta-corpus %}">{% trans "Corpus" %}</a></li>
-     <li><a href="{% url telemeta-collections %}">{% trans "Collections" %}</a></li>
-     <li><a href="{% url telemeta-items %}">{% trans "Items" %}</a></li>
+    <li><a href="{% url telemeta-fonds %}">{% trans "Fonds" %}</a></li>
+    <li><a href="{% url telemeta-corpus %}">{% trans "Corpus" %}</a></li>
+    <li><a href="{% url telemeta-collections %}">{% trans "Collections" %}</a></li>
+    <li><a href="{% url telemeta-items %}">{% trans "Items" %}</a></li>
   </ul>
   <div class="clear"></div>
  </li>
index 643e872eb0fcdcd1dea72bb572c3087e6ef1cac1..fb29a7700ba7b61e1ebe01ad37f13d2df03991fa 100644 (file)
@@ -74,12 +74,6 @@ htdocs = os.path.dirname(__file__) + '/htdocs'
 
 urlpatterns = patterns('',
     url(r'^$', general_view.index, name="telemeta-home"),
-    url(r'^lists/$', general_view.lists, name="telemeta-lists"),
-
-    # archives
-    # TODO: make a real archives tree view
-    url(r'^archives/$', redirect_to, {'url': '/archives/collections/'},
-        name="telemeta-archives"),
 
     # items
     url(r'^archives/items/$', 'django.views.generic.list_detail.object_list',
@@ -295,10 +289,16 @@ urlpatterns = patterns('',
     # Users
     url(r'^users/$', general_view.users, name="telemeta-users"),
 
+    # Desk
+    url(r'^desk/lists/$', general_view.lists, name="telemeta-desk-lists"),
+    url(r'^desk/profile/(?P<username>[A-Za-z0-9._-]+)/$', profile_view.profile_detail, name="telemeta-desk-profile"),
+    url(r'^desk/home/$', general_view.index, name="telemeta-desk-home"),
+
     # Profiles
     url(r'^users/(?P<username>[A-Za-z0-9._-]+)/profile/$', profile_view.profile_detail, name="telemeta-profile-detail"),
     url(r'^users/(?P<username>[A-Za-z0-9._-]+)/profile/edit/$', profile_view.profile_edit, name="telemeta-profile-edit"),
 
+
     # Registration
     url(r'^accounts/password_change/$', 'django.contrib.auth.views.password_change', {'template_name': 'telemeta/registration/password_change_form.html'}, name="telemeta-password-change"),
     url(r'^accounts/password_change_done/$', 'django.contrib.auth.views.password_change_done', {'template_name': 'telemeta/registration/password_change_done.html'}, name="telemeta-password-change-done"),
index a0c35b27df544377509b5673a79adc9c61abd8d6..68c1e0ca54287e1dc71ab612b0ce2d142f483964 100644 (file)
@@ -213,7 +213,7 @@ class GeneralView(object):
 
     def index(self, request):
         """Render the index page"""
-        
+
         template = loader.get_template('telemeta/index.html')
 
         sound_items = MediaItem.objects.sound()
@@ -244,7 +244,7 @@ class GeneralView(object):
 
     def lists(self, request):
         """Render the home page"""
-        
+
         if request.user.is_authenticated():
             template='telemeta/home.html'
             playlists = get_playlists(request)
@@ -255,11 +255,11 @@ class GeneralView(object):
         else:
             template = 'telemeta/messages.html'
             mess = ugettext('Access not allowed')
-            title = ugettext('Lists') + ' : ' + request.user + ' : ' + mess
+            title = ugettext('Lists') + ' : ' + mess
             description = ugettext('Please login or contact the website administator to get a private access.')
             messages.error(request, title)
             return render(request, template, {'description' : description})
-    
+
     def edit_search(self, request, criteria=None):
         year_min, year_max = MediaCollection.objects.all().recording_year_range()
         rec_years = year_min and year_max and range(year_min, year_max + 1) or []
@@ -693,7 +693,7 @@ class ItemView(object):
                 return HttpResponseRedirect('/archives/items/'+code)
         else:
             form = MediaItemForm(instance=item)
-            
+
 
         return render(request, template, {'item': item, 'form': form})