# HG changeset patch # User cavaliet # Date 1378309518 -7200 # Node ID 7ff73789a85119d03885afa495b139ec30a95700 # Parent 08cffedf6e60500e192d1c1404eae2eb6834882e first step of js/css semantic tree, just to save. it will not be used as this in this project. diff -r 08cffedf6e60 -r 7ff73789a851 src/p4l/static/p4l/css/semantictree.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/p4l/static/p4l/css/semantictree.css Wed Sep 04 17:45:18 2013 +0200 @@ -0,0 +1,300 @@ +.semantic-tree{ + background: #a85063; /* Old browsers */ + background: -moz-linear-gradient(left, #a85063 0%, #ffffff 55%, #a85063 100%); /* FF3.6+ */ + background: -webkit-gradient(linear, left top, right top, color-stop(0%,#a85063), color-stop(55%,#ffffff), color-stop(100%,#a85063)); /* Chrome,Safari4+ */ + background: -webkit-linear-gradient(left, #a85063 0%,#ffffff 55%,#a85063 100%); /* Chrome10+,Safari5.1+ */ + background: -o-linear-gradient(left, #a85063 0%,#ffffff 55%,#a85063 100%); /* Opera 11.10+ */ + background: -ms-linear-gradient(left, #a85063 0%,#ffffff 55%,#a85063 100%); /* IE10+ */ + background: linear-gradient(to right, #a85063 0%,#ffffff 55%,#a85063 100%); /* W3C */ + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a85063', endColorstr='#a85063',GradientType=1 ); /* IE6-9 */ +} +@charset "UTF-8"; + + +#home_links +{ + line-height: 150% +} + +#search_form_div { + text-align: center; + padding: 10px; + margin: 10px 10px; + margin-bottom: 30px; + background-color:#ececec; + border: 1px solid #7E7E7E +} + +#search_form ul { + list-style-type: none; + margin: 0; + padding: 0; +} + +#search_form ul li { + display: inline; +} + +#toolbar { + margin-top: 2px; + margin-bottom: 2px; + border-bottom: 2px solid #707070; + padding-top : 0px; + padding-bottom : 0px; +} +#toolbar ul{ + padding-left : 0px; + padding-right : 0px; + padding-top : 0px; + padding-bottom : 0px; + margin-left : 0px; + margin-right : 0px; + margin-top: 5px; + margin-bottom: 5px; +} +#toolbar ul li{ + display: inline; + padding-left : 10px; + padding-right : 10px; + padding-top : 0px; + padding-bottom : 0px; +} + +#inner_content { + padding: 5px 0px 50px 0px; +} + + + +.large_25 { + width: 25px; +} +.text_centered { + text-align: center; +} +.text_left_aligned { + text-align: left; +} +.text_right_aligned { + text-align: right; +} + + +.unsemantized { + color: #ba0000; +} + +#tags_actions span { + margin-left: 5px; +} + +#loginform_div { + margin-left: 10px; +} + +#login_fields_list, #submitcontent-buttons-login { + margin: 10px 0px; +} + +#search_results { + margin-left: 10px; +} + +.result_counter { + color: #C6C6C6; +} + +#search_prev_next { + margin-top: 20px; +} + +#page_number { + text-align: right; +} + +#term-list-table td { + padding: 2px; +} + +#term-list-table th { + text-align: center; +} + +.term-list-label { + width : 500px; +} + + +#inner_content { + padding-left: 30px; +} + +#term-filter-field-list { + list-style-type: none; + padding-left: 10px; +} + +#term-filter-field-list li +{ + display: inline-block; + list-style-type: none; + padding-right: 5px; + font-weight: bold; + color: gray; +} + +#term-filter-field-list label { + display: block; +} + + + +#wrapper { + width:1280px; + margin:0 auto 0 0; +} + +#term-filter-top-container { + margin-bottom: 20px; +} + +#term-explorer-container { + width: 580px; + float: left; + padding:10px; +} + +#term-detail-container { + width: 660px; + float: right; + padding:10px; +} + +#tags_commands { + margin-bottom: 10px; +} + +#term-table > tr > td:first-child { + padding-right:10px; +} + +#edition-wk > td > span { + margin-right:10px; +} + +#info-wk > td > span { + margin-right:10px; +} + +.searchmatch { + color: #c000c0; +} + +#wp-infobox { + position: absolute; + top: 0px; + left: 0px; + cursor: default; + max-width: 300px; + padding: 0 10px 10px 10px; +} + +.wp-infobox-wp-link { + margin-bottom: 1em; +} + +#wp-infobox a { + color: rgb(80, 164, 163); +} + +.wp-img { + float: left; + max-width: 80px; + max-height: 60px; + margin: 5px 2px 2px 0px; + padding-right: 5px; +} + +.wp-missing-img { + background: #ffffff url('../img/Wikipedia-logo-v2-fr.png') no-repeat; + width: 57px; + height: 60px; +} + +#prev-next-prev-link { + float: left; +} + +#prev-next-next-link { + float: right; +} + +#prev-next-clear { + clear: both; +} + +#prev-next { + height: 25px; + padding-right: 256px; +} + +.notice-outer-container > table { + border-collapse: separate; +} + +.notice-container { + border: thin solid black; + vertical-align: top; + padding: 4px; +} + +.notice-img { + width: 85px; + height: 128px; +/* border: thin solid red; */ + float:left; +} + +.notice-img > img { + max-width: 85px; + max-height: 128px; +} + +.notice-desc { + float:right; + width: 170px; +} + +.notice-field-title { + text-align: right; + color: rgb(10, 115, 144); + width: 30px; +} +.notice-field-val { + text-align: left; + padding-left: 5px; + max-width: 140px; +} + +.jstree-error { + font-weight: bold; + color: red; +} + +#dialog-link-container { + min-width: 100px; + height: 18px; + padding: 1px 1px 0px 1px; + vertical-align: center; +} + +#term-filter-field-list #label { + padding-top : 0px; + padding-bottom: 0px; +} + +#dialog-deselect { + float: right; + margin-left: 5px; + cursor: pointer; +} \ No newline at end of file diff -r 08cffedf6e60 -r 7ff73789a851 src/p4l/static/p4l/js/semantictree.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/p4l/static/p4l/js/semantictree.js Wed Sep 04 17:45:18 2013 +0200 @@ -0,0 +1,249 @@ +/* semantictree.js : We suppose that jquery, jquery ui, tag-it, jstree and smoothness theme have been loaded */ +function init_autocomplete() +{ + // Wikipedia search management (new tag) + $(".semantic-tree").autocomplete({ + 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"); + $.ajax({ + url : url, + data: { + query: query, + $reg: '"'+reg+'"', + $language: '"fr"' + }, + headers: { + Accept: "application/sparql-results+json;charset=UTF-8" + }, + success: function( data ) { + response( $.map( data["results"]["bindings"], function( item ) { + return { + label: item["label"]["value"], + value: item["label"]["value"] + } + })); + } + }); + }, + select: function(event, ui) { + // Since the event still did not update wp_search's val, we force it. + //$("#wp_search").val(ui.item.label); + //select_done = true; + //$("#ok_search").click(); + }, + minLength: 2, + open: function() { + //$( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" ); + }, + close: function() { + /*$( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" ); + setTimeout(function(){$("#wp-infobox").hide();},500); + var request = $("#wp_search").data('request'); + var chained = $("#wp_search").data('chained'); + if(request) { + request.abort(); + } + if(chained && typeof(chained.abort) === typeof(Function)) { + chained.abort(); + }*/ + } + }); +} + + +function init_browse() { + + $( ".dialog-link" ).each(function() { + var input_name = this.id.substr(12); + + // Link to open the dialog + $( '#dialog-link-'+input_name ).click(function( event ) { + event.preventDefault(); + var input_name = this.id.substr(12); + console.log("input_name 2 = " + input_name); + console.log($( '#dialog-'+input_name )); + $( '#dialog-'+input_name ).dialog( "open" ); + //if(! $('#thesaurus_tree').is(":disabled")) { + // $( ".dialog" ).dialog( "open" ); + //} + }); + + $( '#dialog-'+input_name ).dialog({ + autoOpen: false, + width: 400, + height: "auto", + maxHeight: 800, + resizable: false, + position: {my: "left top", at:"left bottom+5", of:$("#dialog-link-container-"+input_name), collision: 'none'}, + open: function(event, ui) { + // this is the span with class="dialog" and id="dialog-inputname" + var input_name = this.id.substr(7); + var url = $("#id_"+input_name).attr("data-url"); + var root_query = $("#id_"+input_name).attr("data-root-query"); + var childs_query = $("#id_"+input_name).attr("data-childs-query"); + var child_count_query = $("#id_"+input_name).attr("data-child-count-query"); + $('#term-tree-'+input_name) + .jstree({ + themes: { + theme: "apple", + dots: true, + icons: true + }, + json_data: { + ajax: { + url : url, + data: function(node){ + var res = {}; + if(node.data) { + res.query = childs_query; + res.$root = node.data('uri'); + } + else{ + res.query = root_query; + } + res.$language = '"fr"'; + return res; + }, + headers: { + Accept: "application/sparql-results+json;charset=UTF-8" + }, + success: function(json) { + var b = json["results"]["bindings"]; + var mytree = []; + var l = b.length; + for(var i=0;i" + }, + headers: { + Accept: "application/sparql-results+json;charset=UTF-8" + }, + async: false, + success:function(json_count){ + nb = parseInt(json_count["results"]["bindings"][0]["nb"]["value"]); + } + }); + // nb of child > 0 : state closed if yes, no state if not. + if(nb>0){ + mytree.push({ + "data" : { + "title" : b[i]["label"]["value"] + " (" + nb + ") " + uri.substr(uri.lastIndexOf("/")+1), + }, + "state" : "closed", + "metadata" : {uri: "<" + uri + ">", label:b[i]["label"]["value"]} + //"language" : "en" + }); + } + else{ + mytree.push({ + "data" : { + "title" : b[i]["label"]["value"] + " " + uri.substr(uri.lastIndexOf("/")+1), + }, + "metadata" : {uri: "<" + uri + ">", label:b[i]["label"]["value"]} + }); + } + } + return mytree; + }, + error: function() { + console.log("FAIL"); + $(".jstree-loading").removeClass("jstree-loading").addClass("jstree-error").html("Error when loading tree"); + } + }, + progressive_render: true + }, + ui : { + select_limit: 1, + initially_select: $('#thesaurus_tree').val()?['node-term-'+$('#thesaurus_tree').val()]:[] + }, + plugins : [ "themes", "json_data", "ui"] + }); + }, + close: function( event, ui ) { + //console.log("close"); + // this is the span with class="dialog" and id="dialog-inputname" + var input_name = this.id.substr(7); + $.jstree._reference($('#term-tree-'+input_name)).destroy(); + }, + buttons: [ + { + text: "Ok", + click: function() { + // this is the span with id="dialog-inputname" + var input_name = this.id.substr(7); + selected = $.jstree._reference($('#term-tree-'+input_name)).get_selected(); + if(selected.length) { + selected_node = $(selected[0]); + // Update text input : val() if classical input, add tag to tagit instance if necessary + if($('#id_'+input_name).hasClass("semantic-tree-tagit")){ + $('#id_'+input_name).tagit("createTag", selected_node.data('label')); + } + else{ + $('#id_'+input_name).val(selected_node.data('label')); + } + //$('#thesaurus_tree').data('term_tree_node',selected_node.data('term_tree_node')); + //$('#thesaurus_tree').val(selected_node.data('term_tree_node').id).trigger('change'); + } + $( this ).dialog( "close" ); + } + }, + { + text: "Cancel", + click: function() { + $(this).dialog( "close" ); + } + } + ] + }); + }); +} + +function init_tagit_autocomplete() +{ + // Semantic search management with tag-it feature + $(".semantic-tree-tagit").tagit({ + tagSource: function(request, response) { + // We use "this" because there can be several autocomplete in the same form. + // this.element[0] is the input. + var url = $(this.element[0]).attr("data-url"); + var query = $(this.element[0]).attr("data-query"); + $.ajax({ + url : url, + data: { + query: query, + $reg: '"'+request.term+'"', + $language: '"fr"' + }, + headers: { + Accept: "application/sparql-results+json;charset=UTF-8" + }, + success: function( data ) { + response( $.map( data["results"]["bindings"], function( item ) { + return { + label: item["label"]["value"], + value: item["uri"]["value"] + } + })); + } + }); + }, + allowSpaces: true + }); +} + + +$(document).ready(function(){ + init_autocomplete(); + init_browse(); + init_tagit_autocomplete(); +}); \ No newline at end of file