Commit d4cee57c5b6993eba59fcf6b46c91e51f5ac3035

Authored by Bartłomiej Nitoń
1 parent 3f5a8f4e

Added alternative schema based examples preview to "Semantyka" tab.

semantics/static/js/semantics_schemas.js
... ... @@ -93,7 +93,7 @@ function schemaTable(schema){
93 93 function schemaHeader(schema, alternates){
94 94 var schema_header = '';
95 95  
96   - schema_header += '<tr><td class="ColumnHeader">Schemat:</td><td class="schema_' + schema.schema_id + '_" id="schema_' + schema.schema_id + '_" colspan="' + schema.colspan + '">';
  96 + schema_header += '<tr><td class="ColumnHeader">Schemat:</td><td class="schema_' + schema.schema_id + '_" id="schema_' + schema.schema_id + '_" onclick="selectSchema(' + schema.schema_id + ')" colspan="' + schema.colspan + '">';
97 97 schema_header += '<span class="Opinion">' + schema.grade + ' [' + schema.schema_id + ']</span>';
98 98 if (alternates && control == "connect") {
99 99 schema_header += '<span><button type="button" onclick="duplicateSchema(' + schema.schema_id + ')" style="float: right">Autoalternacja</button></span>';
... ...
semantics/static/js/semantics_view.js
... ... @@ -688,7 +688,7 @@ function removeFromFrame() {
688 688 function frameClick(clicked_id) {
689 689  
690 690 if (clicked_id == "") {
691   - deselect(highlighted_id);
  691 + deselect();
692 692 highlighted_id = "";
693 693 semantics_selected_id = "";
694 694 return;
... ... @@ -698,7 +698,7 @@ function frameClick(clicked_id) {
698 698 var frame_id = clicked_id.split('_')[1]
699 699  
700 700 if (highlighted_id != "") {
701   - deselect(highlighted_id);
  701 + deselect();
702 702 }
703 703  
704 704 if (semantics_selected_id == frame_id) {
... ... @@ -714,7 +714,7 @@ function frameClick(clicked_id) {
714 714 var frame_id = clicked_id.split('_')[1];
715 715  
716 716 if (highlighted_id != "") {
717   - deselect(highlighted_id);
  717 + deselect();
718 718 }
719 719 if (semantics_selected_id == clicked_id) {
720 720 highlighted_id = "";
... ... @@ -740,7 +740,7 @@ function frameClick(clicked_id) {
740 740 frame_id = clicked_id.split('_')[1]
741 741  
742 742 if (highlighted_id != "") {
743   - deselect(highlighted_id);
  743 + deselect();
744 744 }
745 745 if (semantics_selected_id == clicked_id) {
746 746 highlighted_id = "";
... ... @@ -784,13 +784,14 @@ function select(frame_id, clicked_id) {
784 784  
785 785 }
786 786  
787   -function deselect(frame_id) {
  787 +function deselect() {
788 788  
789 789 redrawSchemas();
790 790 displayed_examples = [];
791 791 clearExampleArgumentsSelection();
792 792 displayExamples();
793 793 deselectFrame();
  794 + deselectSchema();
794 795 brightenSchemas();
795 796  
796 797 }
... ... @@ -1069,6 +1070,34 @@ function schemaClick(class_id) {
1069 1070 }
1070 1071 }
1071 1072  
  1073 +function selectSchema(schema_id) {
  1074 + deselect();
  1075 + $("#schema_" + schema_id + "_").css('background-color', 'LightSteelBlue');
  1076 + $("#schema_" + schema_id + "_").css('border-width', '5px');
  1077 + getSchemaExamples(schema_id);
  1078 + displayExamples();
  1079 +}
  1080 +
  1081 +function deselectSchema() {
  1082 + $('[class^=schema_]').each(function(){
  1083 + $(this).css('background-color', "");
  1084 + $(this).css('background', "");
  1085 + $(this).css('border-width', '');
  1086 + });
  1087 +}
  1088 +
  1089 +function getSchemaExamples(schema_id) {
  1090 +
  1091 + displayed_examples = [];
  1092 + for(var i=0; i<window.examples.length; i++) {
  1093 + var exampleSchemaId = schemaId(window.examples[i].arguments[0].id);
  1094 + if(exampleSchemaId == schema_id) {
  1095 + displayed_examples.push(window.examples[i]);
  1096 + }
  1097 + }
  1098 +
  1099 +}
  1100 +
1072 1101 var exampleSelectionColor = "rgb(176,196,222)";
1073 1102  
1074 1103 function showExampleArguments(id) {
... ...