| author | cavaliet |
| Mon, 16 Sep 2013 13:12:57 +0200 | |
| changeset 90 | 33a7b2a4af87 |
| parent 86 | 4effe076e087 |
| child 95 | 594f79a5706b |
| permissions | -rw-r--r-- |
|
37
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
1 |
/* semantictree.js : We suppose that jquery, jquery ui, tag-it, jstree and smoothness theme have been loaded */ |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
2 |
function init_autocomplete() |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
3 |
{ |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
4 |
// Wikipedia search management (new tag) |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
5 |
$(".semantic-tree").autocomplete({ |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
6 |
source: function( request, response ) { |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
7 |
// We use "this" because there can be several autocomplete in the same form. |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
8 |
// this.element[0] is the input. |
| 86 | 9 |
var the_input = $(this.element[0]); |
10 |
var reg = the_input.val(); |
|
11 |
var url = the_input.attr("data-url"); |
|
12 |
var query = the_input.attr("data-query"); |
|
|
37
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
13 |
$.ajax({ |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
14 |
url : url, |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
15 |
data: { |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
16 |
query: query, |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
17 |
$reg: '"'+reg+'"', |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
18 |
$language: '"fr"' |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
19 |
}, |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
20 |
headers: { |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
21 |
Accept: "application/sparql-results+json;charset=UTF-8" |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
22 |
}, |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
23 |
success: function( data ) { |
| 86 | 24 |
// build response |
|
37
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
25 |
response( $.map( data["results"]["bindings"], function( item ) { |
| 38 | 26 |
//console.log(item["uri"]["value"] + " = " + item["label"]["value"]); |
|
37
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
27 |
return { |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
28 |
label: item["label"]["value"], |
| 38 | 29 |
value: item["label"]["value"] + " (" + item["uri"]["value"] + ")" |
|
37
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
30 |
} |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
31 |
})); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
32 |
} |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
33 |
}); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
34 |
}, |
| 38 | 35 |
select: function(event, ui) { |
36 |
// We use "this" because there can be several autocomplete in the same form. |
|
37 |
// this is the input. |
|
38 |
// addSubjectText is like "label (uri)" so we get the chars inner the last brackets |
|
39 |
uri = ui.item.value.match(/\(([^)]*)\)[^(]*$/)[1] |
|
40 |
// First we update the uri/label dict |
|
41 |
angular.element(this).scope().updateUriLabelDict(uri, ui.item.label); |
|
42 |
// Angular does not listen to val() event so we update the model value manually: |
|
43 |
angular.element(this).controller('ngModel').$setViewValue(uri); |
|
|
37
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
44 |
}, |
| 38 | 45 |
minLength: 2 |
|
37
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
46 |
}); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
47 |
} |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
48 |
|
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
49 |
|
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
50 |
function init_browse() { |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
51 |
|
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
52 |
$( ".dialog-link" ).each(function() { |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
53 |
var input_name = this.id.substr(12); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
54 |
|
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
55 |
// Link to open the dialog |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
56 |
$( '#dialog-link-'+input_name ).click(function( event ) { |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
57 |
event.preventDefault(); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
58 |
var input_name = this.id.substr(12); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
59 |
$( '#dialog-'+input_name ).dialog( "open" ); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
60 |
}); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
61 |
|
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
62 |
$( '#dialog-'+input_name ).dialog({ |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
63 |
autoOpen: false, |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
64 |
width: 400, |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
65 |
height: "auto", |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
66 |
maxHeight: 800, |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
67 |
resizable: false, |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
68 |
position: {my: "left top", at:"left bottom+5", of:$("#dialog-link-container-"+input_name), collision: 'none'}, |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
69 |
open: function(event, ui) { |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
70 |
// this is the span with class="dialog" and id="dialog-inputname" |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
71 |
var input_name = this.id.substr(7); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
72 |
var url = $("#id_"+input_name).attr("data-url"); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
73 |
var root_query = $("#id_"+input_name).attr("data-root-query"); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
74 |
var childs_query = $("#id_"+input_name).attr("data-childs-query"); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
75 |
var child_count_query = $("#id_"+input_name).attr("data-child-count-query"); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
76 |
$('#term-tree-'+input_name) |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
77 |
.jstree({ |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
78 |
themes: { |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
79 |
theme: "apple", |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
80 |
dots: true, |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
81 |
icons: true |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
82 |
}, |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
83 |
json_data: { |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
84 |
ajax: { |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
85 |
url : url, |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
86 |
data: function(node){ |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
87 |
var res = {}; |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
88 |
if(node.data) { |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
89 |
res.query = childs_query; |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
90 |
res.$root = node.data('uri'); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
91 |
} |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
92 |
else{ |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
93 |
res.query = root_query; |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
94 |
} |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
95 |
res.$language = '"fr"'; |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
96 |
return res; |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
97 |
}, |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
98 |
headers: { |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
99 |
Accept: "application/sparql-results+json;charset=UTF-8" |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
100 |
}, |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
101 |
success: function(json) { |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
102 |
var b = json["results"]["bindings"]; |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
103 |
var mytree = []; |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
104 |
var l = b.length; |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
105 |
for(var i=0;i<l;i++){ |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
106 |
var uri = b[i]["uri"]["value"]; |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
107 |
// We test if the uri has childs. |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
108 |
var nb = 0; |
| 61 | 109 |
if(child_count_query && child_count_query!=""){ |
110 |
$.ajax({ |
|
111 |
url:url, |
|
112 |
data:{ |
|
113 |
query: child_count_query, |
|
114 |
$root: "<"+uri+">" |
|
115 |
}, |
|
| 90 | 116 |
headers: { |
| 61 | 117 |
Accept: "application/sparql-results+json;charset=UTF-8" |
118 |
}, |
|
119 |
async: false, |
|
120 |
success:function(json_count){ |
|
121 |
nb = parseInt(json_count["results"]["bindings"][0]["nb"]["value"]); |
|
122 |
} |
|
123 |
}); |
|
124 |
} |
|
| 90 | 125 |
// Test if the node is a collection and not selectable |
126 |
var attr = {'rel':'default'}; |
|
127 |
if("type" in b[i]){ |
|
128 |
type_uri = b[i]["type"]["value"]; |
|
129 |
// type uri in kind of http://www[...]#Concept or http://www[...]#Collection |
|
130 |
if(type_uri.substr(type_uri.indexOf("#") + 1).toLowerCase()=="collection"){ |
|
131 |
attr = {'rel':'leaf'}; |
|
132 |
} |
|
133 |
} |
|
|
37
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
134 |
// nb of child > 0 : state closed if yes, no state if not. |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
135 |
if(nb>0){ |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
136 |
mytree.push({ |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
137 |
"data" : { |
|
43
829d9d4111da
semantic tree browser works and queries in settings dict
cavaliet
parents:
38
diff
changeset
|
138 |
"title" : b[i]["label"]["value"] + " (" + nb + ") " |
|
37
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
139 |
}, |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
140 |
"state" : "closed", |
| 90 | 141 |
"metadata" : {uri: "<"+uri+">", label:b[i]["label"]["value"]}, |
142 |
"attr": attr |
|
|
37
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
143 |
}); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
144 |
} |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
145 |
else{ |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
146 |
mytree.push({ |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
147 |
"data" : { |
|
43
829d9d4111da
semantic tree browser works and queries in settings dict
cavaliet
parents:
38
diff
changeset
|
148 |
"title" : b[i]["label"]["value"] |
|
37
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
149 |
}, |
| 90 | 150 |
"metadata" : {uri: "<"+uri+">", label:b[i]["label"]["value"]}, |
151 |
"attr": attr |
|
|
37
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
152 |
}); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
153 |
} |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
154 |
} |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
155 |
return mytree; |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
156 |
}, |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
157 |
error: function() { |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
158 |
console.log("FAIL"); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
159 |
$(".jstree-loading").removeClass("jstree-loading").addClass("jstree-error").html("Error when loading tree"); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
160 |
} |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
161 |
}, |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
162 |
progressive_render: true |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
163 |
}, |
| 90 | 164 |
types : { |
165 |
types: { |
|
166 |
"leaf" : { |
|
167 |
'hover_node' : false, |
|
168 |
'select_node': function () {return false;} |
|
169 |
} |
|
170 |
} |
|
171 |
}, |
|
172 |
plugins : [ "themes", "json_data", "ui", "types"] |
|
|
37
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
173 |
}); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
174 |
}, |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
175 |
close: function( event, ui ) { |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
176 |
//console.log("close"); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
177 |
// this is the span with class="dialog" and id="dialog-inputname" |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
178 |
var input_name = this.id.substr(7); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
179 |
$.jstree._reference($('#term-tree-'+input_name)).destroy(); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
180 |
}, |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
181 |
buttons: [ |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
182 |
{ |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
183 |
text: "Ok", |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
184 |
click: function() { |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
185 |
// this is the span with id="dialog-inputname" |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
186 |
var input_name = this.id.substr(7); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
187 |
selected = $.jstree._reference($('#term-tree-'+input_name)).get_selected(); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
188 |
if(selected.length) { |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
189 |
selected_node = $(selected[0]); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
190 |
// Update text input : val() if classical input, add tag to tagit instance if necessary |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
191 |
if($('#id_'+input_name).hasClass("semantic-tree-tagit")){ |
|
43
829d9d4111da
semantic tree browser works and queries in settings dict
cavaliet
parents:
38
diff
changeset
|
192 |
// #TODO : update when we add tag-it for real |
|
37
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
193 |
$('#id_'+input_name).tagit("createTag", selected_node.data('label')); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
194 |
} |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
195 |
else{ |
|
43
829d9d4111da
semantic tree browser works and queries in settings dict
cavaliet
parents:
38
diff
changeset
|
196 |
// First we update the uri/label dict |
|
829d9d4111da
semantic tree browser works and queries in settings dict
cavaliet
parents:
38
diff
changeset
|
197 |
uri = selected_node.data('uri'); |
| 57 | 198 |
// We remove the <> from the uri |
| 58 | 199 |
uri = uri.slice(1,-1); |
|
43
829d9d4111da
semantic tree browser works and queries in settings dict
cavaliet
parents:
38
diff
changeset
|
200 |
label = selected_node.data('label'); |
|
829d9d4111da
semantic tree browser works and queries in settings dict
cavaliet
parents:
38
diff
changeset
|
201 |
angular.element($('#id_'+input_name)[0]).scope().updateUriLabelDict(uri, label); |
|
829d9d4111da
semantic tree browser works and queries in settings dict
cavaliet
parents:
38
diff
changeset
|
202 |
// Angular does not listen to val() event so we update the model value manually: |
|
829d9d4111da
semantic tree browser works and queries in settings dict
cavaliet
parents:
38
diff
changeset
|
203 |
angular.element($('#id_'+input_name)[0]).controller('ngModel').$setViewValue(uri); |
|
829d9d4111da
semantic tree browser works and queries in settings dict
cavaliet
parents:
38
diff
changeset
|
204 |
// And update the text field val |
|
829d9d4111da
semantic tree browser works and queries in settings dict
cavaliet
parents:
38
diff
changeset
|
205 |
$('#id_'+input_name).val(label + " (" + uri + ")"); |
|
37
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
206 |
} |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
207 |
//$('#thesaurus_tree').data('term_tree_node',selected_node.data('term_tree_node')); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
208 |
//$('#thesaurus_tree').val(selected_node.data('term_tree_node').id).trigger('change'); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
209 |
} |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
210 |
$( this ).dialog( "close" ); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
211 |
} |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
212 |
}, |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
213 |
{ |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
214 |
text: "Cancel", |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
215 |
click: function() { |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
216 |
$(this).dialog( "close" ); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
217 |
} |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
218 |
} |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
219 |
] |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
220 |
}); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
221 |
}); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
222 |
} |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
223 |
|
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
224 |
function init_tagit_autocomplete() |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
225 |
{ |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
226 |
// Semantic search management with tag-it feature |
|
43
829d9d4111da
semantic tree browser works and queries in settings dict
cavaliet
parents:
38
diff
changeset
|
227 |
/*$(".semantic-tree-tagit").tagit({ |
|
37
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
228 |
tagSource: function(request, response) { |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
229 |
// We use "this" because there can be several autocomplete in the same form. |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
230 |
// this.element[0] is the input. |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
231 |
var url = $(this.element[0]).attr("data-url"); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
232 |
var query = $(this.element[0]).attr("data-query"); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
233 |
$.ajax({ |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
234 |
url : url, |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
235 |
data: { |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
236 |
query: query, |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
237 |
$reg: '"'+request.term+'"', |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
238 |
$language: '"fr"' |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
239 |
}, |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
240 |
headers: { |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
241 |
Accept: "application/sparql-results+json;charset=UTF-8" |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
242 |
}, |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
243 |
success: function( data ) { |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
244 |
response( $.map( data["results"]["bindings"], function( item ) { |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
245 |
return { |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
246 |
label: item["label"]["value"], |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
247 |
value: item["uri"]["value"] |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
248 |
} |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
249 |
})); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
250 |
} |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
251 |
}); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
252 |
}, |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
253 |
allowSpaces: true |
|
43
829d9d4111da
semantic tree browser works and queries in settings dict
cavaliet
parents:
38
diff
changeset
|
254 |
});*/ |
|
37
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
255 |
} |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
256 |
|
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
257 |
|
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
258 |
$(document).ready(function(){ |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
259 |
init_autocomplete(); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
260 |
init_browse(); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
261 |
init_tagit_autocomplete(); |
|
7ff73789a851
first step of js/css semantic tree, just to save. it will not be used as this in this project.
cavaliet
parents:
diff
changeset
|
262 |
}); |