various optimisations
authorcavaliet
Fri, 13 Sep 2013 18:33:07 +0200
changeset 86 4effe076e087
parent 84 caafe38298d7
child 87 9f456eb41602
various optimisations
src/p4l/settings.py
src/p4l/static/p4l/css/semantictree.css
src/p4l/static/p4l/js/semantictree.js
--- a/src/p4l/settings.py	Fri Sep 13 16:24:31 2013 +0200
+++ b/src/p4l/settings.py	Fri Sep 13 18:33:07 2013 +0200
@@ -208,6 +208,7 @@
     FILTER (lang(?label) = %s). 
     FILTER NOT EXISTS { [skos:member ?uri] }
 }
+ORDER BY ?label
 """,
 "childs" : """
 PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
@@ -223,6 +224,7 @@
   ?uri skos:prefLabel|rdfs:label ?label.
   FILTER (lang(?label) = %s).
 }
+ORDER BY ?label
 """,
 "child-count" : """
 PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
@@ -269,6 +271,7 @@
     FILTER (lang(?label) = %s). 
     FILTER NOT EXISTS { [skos:member ?uri] }
 }
+ORDER BY ?label
 """,
 'childs' : """
 PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
@@ -284,6 +287,7 @@
   ?uri skos:prefLabel|rdfs:label ?label.
   FILTER (lang(?label) = %s).
 }
+ORDER BY ?label
 """,
 'child-count' : """
 PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
@@ -330,6 +334,7 @@
     FILTER (lang(?label) = %s). 
     FILTER NOT EXISTS { [skos:narrower ?uri] }
 }
+ORDER BY ?label
 """,
 'childs' : """
 PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
@@ -345,6 +350,7 @@
   ?uri skos:prefLabel|rdfs:label ?label.
   FILTER (lang(?label) = %s).
 }
+ORDER BY ?label
 """,
 'child-count' : """
 PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
@@ -391,6 +397,7 @@
     FILTER (lang(?label) = %s). 
     FILTER NOT EXISTS { [skos:narrower ?uri] }
 }
+ORDER BY ?label
 """
 }
 SPARQL_PROJECT_QUERIES = {
@@ -422,6 +429,7 @@
     skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/Projects> ;    
     skos:prefLabel ?label .
 }
+ORDER BY ?label
 """
 }
 SPARQL_ORGANIZATION_QUERIES = {
@@ -453,6 +461,7 @@
     skos:inScheme <http://www.iiep.unesco.org/plan4learning/scheme/Organizations> ;    
     skos:prefLabel ?label .
 }
+ORDER BY ?label
 """
 }
 SPARQL_TYPE_QUERIES = {
@@ -488,6 +497,7 @@
     FILTER (lang(?label) = %s). 
     FILTER NOT EXISTS { [skos:narrower ?uri] }
 }
+ORDER BY ?label
 """
 }
 
--- a/src/p4l/static/p4l/css/semantictree.css	Fri Sep 13 16:24:31 2013 +0200
+++ b/src/p4l/static/p4l/css/semantictree.css	Fri Sep 13 18:33:07 2013 +0200
@@ -11,6 +11,14 @@
     overflow-x: hidden;
     overflow-y: auto;
 }
+.ui-autocomplete { max-height: 200px; overflow-y: scroll; overflow-x: hidden;}
+.ui-autocomplete .ui-menu-item a {
+    font-size: 0.9em;
+    padding: 0 0.4em;
+}
+ul .ui-autocomplete {
+    max-height: 300px;
+}
 /*
 .ng-scope {
     border: 1px dashed red;
--- a/src/p4l/static/p4l/js/semantictree.js	Fri Sep 13 16:24:31 2013 +0200
+++ b/src/p4l/static/p4l/js/semantictree.js	Fri Sep 13 18:33:07 2013 +0200
@@ -6,9 +6,10 @@
         source: function( request, response ) {
         	// We use "this" because there can be several autocomplete in the same form.
         	// this.element[0] is the input.
-            var reg = $(this.element[0]).val();
-            var url = $(this.element[0]).attr("data-url");
-            var query = $(this.element[0]).attr("data-query");
+        	var the_input = $(this.element[0]);
+            var reg = the_input.val();
+            var url = the_input.attr("data-url");
+            var query = the_input.attr("data-query");
             $.ajax({
             	url : url,
                 data: {
@@ -20,6 +21,7 @@
                     Accept: "application/sparql-results+json;charset=UTF-8"
             	},
                 success: function( data ) {
+                	// build response
                 	response( $.map( data["results"]["bindings"], function( item ) {
                 		//console.log(item["uri"]["value"] + " = " + item["label"]["value"]);
                 		return {