Subversion Repository Public Repository

Nextrek

Diff Revisions 769 vs 774 for /legal-map/js/articolo.js

Diff revisions: vs.
  @@ -1,3 +1,88 @@
1 + function reduceTab(clicked, folder, filename) {
2 + var parentEl = clicked.parent();
3 + var articoloEl = clicked.closest("articolo");
4 + var tabRef = parentEl.attr("tab-ref");
5 +
6 + $("#articolo-"+folder+"_"+filename+" ."+tabRef+"-tab").removeClass("selected");
7 + $("#articolo-"+folder+"_"+filename+" ."+tabRef).css("display", "none");
8 +
9 + /*if (tabRef == "originale" || tabRef == "ristrutturato") {
10 +
11 + } else if (tabRef == "schema") {
12 +
13 + }*/
14 + }
15 +
16 + function expandTab(clicked, folder, filename) {
17 + var parentEl = clicked.parent();
18 + var tabRef = parentEl.attr("tab-ref");
19 +
20 + if (parentEl.hasClass("selected")) { //espandi al 100% se è tab già selezionato
21 + var containerIndex = parentEl.parent().index();
22 + var otherSelected = $("#articolo-"+folder+"_"+filename+" .tab-container").not(":eq("+(containerIndex-1)+")").find(".selected");
23 + otherSelected.removeClass("selected");
24 +
25 + otherSelected.each(function() { //e nascondi gli altri
26 + var otherTabRef = $(this).attr("tab-ref");
27 + $("#articolo-"+folder+"_"+filename+" ."+otherTabRef).css("display", "none");
28 + });
29 +
30 + } else { //semplicemente fai apparire il container
31 + changeTabArticolo(parentEl, folder, filename);
32 + }
33 + }
34 +
35 + function changeTabArticolo(clicked, folder, filename) {
36 + if (!clicked.hasClass("selected")) { //nel caso in cui il tab non sia stato già selezionato
37 + if (clicked.hasClass("originale-tab")) { //cliccato tab "Testo originale"
38 + clicked.addClass("selected");
39 + $("#articolo-"+folder+"_"+filename+" .ristrutturato-tab").removeClass("selected");
40 + $("#articolo-"+folder+"_"+filename+" .ristrutturato").css("display", "none");
41 + $("#articolo-"+folder+"_"+filename+" .originale").css("display", "table-cell");
42 + } else if (clicked.hasClass("ristrutturato-tab")) { //cliccato tab "Testo ristrutturato"
43 +
44 + function showRistrutturatoTab() {
45 + clicked.addClass("selected");
46 + $("#articolo-"+folder+"_"+filename+" .originale-tab").removeClass("selected");
47 + $("#articolo-"+folder+"_"+filename+" .originale").css("display", "none");
48 + $("#articolo-"+folder+"_"+filename+" .ristrutturato").css("display", "table-cell");
49 + }
50 +
51 + function ajaxShowRistrutturatoTab(data) {
52 + $("#articolo-"+folder+"_"+filename+" .ristrutturato").append(data);
53 + showRistrutturatoTab();
54 + }
55 +
56 + if ($("#articolo-"+folder+"_"+filename+" .ristrutturato").children().length > 0) {
57 + showRistrutturatoTab();
58 + } else {
59 + $.ajax({ //caricamento visuali (tab "Schema")
60 + url: "./ajax/openArticle.php",
61 + data: {
62 + html: folder+"/"+filename+"_R.htm"
63 + },
64 + dataType: "HTML",
65 + type: "GET",
66 + success: function(data) {
67 + ajaxShowRistrutturatoTab(data);
68 + },
69 + error: function(request) {
70 + if (request.status == 404) {
71 + ajaxShowRistrutturatoTab("File non trovato");
72 + } else {
73 + ajaxShowRistrutturatoTab("Errore nell'apertura dell'articolo");
74 + }
75 + }
76 + });
77 + }
78 +
79 + } else if (clicked.hasClass("schema-tab")) {
80 + clicked.addClass("selected");
81 + $("#articolo-"+folder+"_"+filename+" .schema").css("display", "table-cell");
82 + }
83 + }
84 + }
85 +
1 86 function VisualizzaArticolo(clicked, folder, filename, p4, p5) { //p4 e p5 attualmente sono uguali rispettivamente a "dls" e null
2 87
3 88 function ajaxVisualizzaArticolo(data, type) {
  @@ -15,7 +100,26 @@
15 100
16 101 $("#articolo-"+folder+"_"+filename+" .close-article").click(function() {
17 102 $(this).closest(".articolo").hide();
18 - })
103 + });
104 +
105 + $("#articolo-"+folder+"_"+filename+" .reduce-icon").click(function(e) {
106 + if ($(this).parent().hasClass("selected")) {
107 + reduceTab($(this), folder, filename);
108 + e.stopPropagation();
109 + }
110 + });
111 +
112 + $("#articolo-"+folder+"_"+filename+" .expand-icon").click(function(e) {
113 + if ($(this).parent().hasClass("selected")) {
114 + expandTab($(this), folder, filename);
115 + e.stopPropagation();
116 + }
117 + });
118 +
119 + $("#articolo-"+folder+"_"+filename+" .tab-container .tab").click(function (e) {
120 + e.stopImmediatePropagation();
121 + changeTabArticolo($(this), folder, filename);
122 + });
19 123 }
20 124
21 125 if ($("#articolo-"+folder+"_"+filename).length > 0) {
  @@ -30,14 +134,14 @@
30 134
31 135 htmlToAppend += "<ul class='tab-container'>";
32 136
33 - htmlToAppend += "<li class='originale-tab tab selected'>";
137 + htmlToAppend += "<li class='originale-tab tab selected' tab-ref='originale'>";
34 138 htmlToAppend += "<div class='originale-icon'></div>";
35 139 htmlToAppend += "<div class='tab-text'>Testo originale</div>";
36 140 htmlToAppend += "<div class='reduce-icon'></div>";
37 141 htmlToAppend += "<div class='expand-icon'></div>";
38 142 htmlToAppend += "</li>";
39 143
40 - htmlToAppend += "<li class='ristrutturato-tab tab'>";
144 + htmlToAppend += "<li class='ristrutturato-tab tab' tab-ref='ristrutturato'>";
41 145 htmlToAppend += "<div class='ristrutturato-icon'></div>";
42 146 htmlToAppend += "<div class='tab-text'>Testo ristrutturato</div>";
43 147 htmlToAppend += "<div class='reduce-icon'></div>";
  @@ -46,7 +150,7 @@
46 150
47 151 htmlToAppend += "<ul class='tab-container'>";
48 152
49 - htmlToAppend += "<li class='schema-tab tab selected'>";
153 + htmlToAppend += "<li class='schema-tab tab selected' tab-ref='schema'>";
50 154 htmlToAppend += "<div class='schema-icon'></div>";
51 155 htmlToAppend += "<div class='tab-text'>Schema</div>";
52 156 htmlToAppend += "<div class='reduce-icon'></div>";