PageSourceSearch

https://territoiresetprojets.fr/tools/templates/libs/yeswiki-base.js

js territoiresetprojets.fr collected 2026-10-08 20:23:26 UTC 8,839 bytes, 321 lines download raw bytes

1/* Author: Florian Schmitt <[email protected]> under GPL licence */
2
3// polyfill placeholder
4(function($) {
5  // gestion des classes actives pour les menus
6  $("a.active-link")
7    .parent()
8    .addClass("active-list")
9    .parents("ul")
10    .prev("a")
11    .addClass("active-parent-link")
12    .parent()
13    .addClass("active-list");
14
15  // fenetres modales
16  function openModal(e) {
17    e.stopPropagation();
18    e.preventDefault();
19    var $this = $(this);
20    var text = $this.attr("title") || $this.text();
21    var size = " " + $this.data("size");
22    var iframe = $this.data("iframe");
23    if (text.length > 0) {
24      text = "<h3>" + $.trim(text) + "</h3>";
25    } else {
26      text = "<h3></h3>";
27    }
28
29    $("body").append(
30      '<div class="modal fade" id="YesWikiModal">' +
31        '<div class="modal-dialog' +
32        size +
33        '">' +
34        '<div class="modal-content">' +
35        '<div class="modal-header">' +
36        '<button type="button" class="close" data-dismiss="modal">&times;</button>' +
37        text +
38        "</div>" +
39        '<div class="modal-body">' +
40        "</div>" +
41        "</div>" +
42        "</div>" +
43        "</div>"
44    );
45
46    var link = $this.attr("href");
47    var $modal = $("#YesWikiModal");
48    if (/\.(gif|jpg|jpeg|tiff|png)$/i.test(link)) {
49      $modal
50        .find(".modal-body")
51        .html(
52          '<img class="center-block img-responsive" src="' +
53            link +
54            '" alt="image" />'
55        );
56    } else if (iframe === 1) {
57      $modal
58        .find(".modal-body")
59        .html(
60          '<span id="yw-modal-loading" class="throbber"></span>' +
61            '<iframe id="yw-modal-iframe" src="' +
62            link +
63            '""></iframe>'
64        );
65      $("#yw-modal-iframe").on("load", function() {
66        $("#yw-modal-loading").hide();
67      });
68    } else {
69      $modal
70        .find(".modal-body")
71        .load(link + " .page", function(response, status, xhr) {
72          return false;
73        });
74    }
75    $modal
76      .modal({
77        keyboard: false
78      })
79      .modal("show")
80      .on("hidden hidden.bs.modal", function() {
81        $modal.remove();
82      });
83
84    return false;
85  }
86  $(document).on("click", "a.modalbox, .modalbox a", openModal);
87
88  // on change l'icone de l'accordeon
89  $(".accordion-trigger").on("click", function() {
90    if (
91      $(this)
92        .next()
93        .find(".collapse")
94        .hasClass("in")
95    ) {
96      $(this)
97        .find(".arrow")
98        .html("&#9658;");
99    } else {
100      $(this)
101        .find(".arrow")
102        .html("&#9660;");
103    }
104  });
105
106  // on enleve la fonction doubleclic dans des cas ou cela pourrait etre indesirable
107  $(".no-dblclick, form, .page a, button, .dropdown-menu").on(
108    "dblclick",
109    function(e) {
110      return false;
111    }
112  );
113
114  // deplacer les fenetres modales en bas de body pour eviter que des styles s'appliquent
115  $(".modal").appendTo(document.body);
116
117  // Pour l'apercu des themes, on recharge la page avec le theme selectionne
118  $("#form_theme_selector select").on("change", function() {
119    if ($(this).attr("id") === "changetheme") {
120      // On change le theme dynamiquement
121      var val = $(this).val();
122
123      // pour vider la liste
124      var squelette = $("#changesquelette")[0];
125      squelette.options.length = 0;
126      var i;
127      for (i = 0; i < tab1[val].length; i++) {
128        o = new Option(tab1[val][i], tab1[val][i]);
129        squelette.options[squelette.options.length] = o;
130      }
131
132      var style = $("#changestyle")[0];
133      style.options.length = 0;
134      for (i = 0; i < tab2[val].length; i++) {
135        o = new Option(tab2[val][i], tab2[val][i]);
136        style.options[style.options.length] = o;
137      }
138    }
139
140    var url = window.location.toString();
141    var urlAux = url.split("&theme=");
142    window.location =
143      urlAux[0] +
144      "&theme=" +
145      $("#changetheme").val() +
146      "&squelette=" +
147      $("#changesquelette").val() +
148      "&style=" +
149      $("#changestyle").val();
150  });
151
152  /* tooltips */
153  $("[data-toggle='tooltip']").tooltip();
154
155  // detecte quand on scrolle en dessus de la barre horizontale, afin de la fixer en haut
156  var $topnav = $("#yw-topnav.fixable");
157  if ($topnav.length > 0) {
158    var topoffset = $topnav.data("offset") || $topnav.offset().top;
159    $topnav.affix({
160      offset: topoffset
161    });
162  }
163
164  // moteur de recherche utilisé dans un template
165  $('a[href="#search"]').on("click", function(e) {
166    e.preventDefault();
167    $("#search").addClass("open");
168    $("#search .search-query").focus();
169  });
170
171  $("#search, #search button.close-search").on("click keyup", function(e) {
172    if (
173      e.target == this ||
174      $(e.target).hasClass("close-search") ||
175      e.keyCode == 27
176    ) {
177      $(this).removeClass("open");
178    }
179  });
180
181  // se souvenir des tabs navigués
182  $.fn.historyTabs = function() {
183    var that = this;
184    window.addEventListener("popstate", function(event) {
185      if (event.state) {
186        $(that)
187          .filter('[href="' + event.state.url + '"]')
188          .tab("show");
189      }
190    });
191    return this.each(function(index, element) {
192      $(element).on("show.bs.tab", function() {
193        var stateObject = {
194          url: $(this).attr("href")
195        };
196
197        if (window.location.hash && stateObject.url !== window.location.hash) {
198          window.history.pushState(
199            stateObject,
200            document.title,
201            window.location.pathname +
202              window.location.search +
203              $(this).attr("href")
204          );
205        } else {
206          window.history.replaceState(
207            stateObject,
208            document.title,
209            window.location.pathname +
210              window.location.search +
211              $(this).attr("href")
212          );
213        }
214      });
215      if (!window.location.hash && $(element).is(".active")) {
216        // Shows the first element if there are no query parameters.
217        $(element).tab("show");
218      } else if ($(this).attr("href") === window.location.hash) {
219        $(element).tab("show");
220      }
221    });
222  };
223  $('a[data-toggle="tab"]').historyTabs();
224
225  // double clic
226  $(".navbar").on("dblclick", function(e) {
227    e.stopPropagation();
228    $("body").append(
229      '<div class="modal fade" id="YesWikiModal">' +
230        '<div class="modal-dialog">' +
231        '<div class="modal-content">' +
232        '<div class="modal-header">' +
233        '<button type="button" class="close" data-dismiss="modal">&times;</button>' +
234        "<h3>Editer une zone du menu horizontal</h3>" +
235        "</div>" +
236        '<div class="modal-body">' +
237        "</div>" +
238        "</div>" +
239        "</div>" +
240        "</div>"
241    );
242
243    var $editmodal = $("#YesWikiModal");
244    $(this)
245      .find(".include")
246      .each(function() {
247        var href = $(this)
248          .attr("ondblclick")
249          .replace("document.location='", "")
250          .replace("';", "");
251        var pagewiki = href
252          .replace("/edit", "")
253          .replace("http://yeswiki.dev/wakka.php?wiki=", "");
254        $editmodal
255          .find(".modal-body")
256          .append(
257            '<a href="' +
258              href +
259              '" class="btn btn-default btn-block">' +
260              '<i class="glyphicon glyphicon-pencil"></i> Editer la page ' +
261              pagewiki +
262              "</a>"
263          );
264      });
265
266    $editmodal
267      .find(".modal-body")
268      .append(
269        '<a href="#" data-dismiss="modal" class="btn btn-warning btn-xs btn-block">' +
270          "En fait, je ne voulais pas double-cliquer...</a>"
271      );
272
273    $editmodal
274      .modal({
275        keyboard: true
276      })
277      .modal("show")
278      .on("hidden hidden.bs.modal", function() {
279        $editmodal.remove();
280      });
281
282    return false;
283  });
284
285  // AUTO RESIZE IFRAME
286  var iframes = $("iframe.auto-resize");
287  if (iframes.length > 0) {
288    $.getScript("tools/templates/libs/vendor/iframeResizer.min.js")
289      .done(function(script, textStatus) {
290        iframes.iFrameResize();
291      })
292      .fail(function(jqxhr, settings, exception) {
293        console.log(
294          "Error getting script tools/templates/libs/vendor/iframeResizer.min.js",
295          exception
296        );
297      });
298  }
299
300  // get the html from a yeswiki page
301  function getText(url, link) {
302    var html;
303    $.get(url, function(data) {
304      html = data;
305    }).done(function() {
306      link.attr("data-content", html);
307    });
308  }
309
310  $(".modalbox-hover").each(function(index) {
311    getText($(this).attr("href") + "/html", $(this));
312  });
313  $(".modalbox-hover").popover({
314    trigger: "hover",
315    html: true, // permet d'utiliser du html
316    placement: "right" // position de la popover (top ou bottom ou left ou right)
317  });
318
319  // ouvrir les liens dans une nouvelle fenetre
320  $(".new-window").attr("target", "_blank");
321})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.