PageSourceSearch

https://www.thechristianleft.org/templates/shaper_helix3/js/frontend-edit.js

js thechristianleft.org collected 2026-10-02 12:46:38 UTC 7,853 bytes, 258 lines download raw bytes

1/**
2 * @package Helix3 Framework
3 * @author JoomShaper https://www.joomshaper.com
4 * @copyright (c) 2010 - 2026 JoomShaper
5 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or later
6 */
7
8(function ($) {
9  $.fn.extend({
10    /**
11     * This jQuery custom method makes the elements absolute, and with true argument moves them to end of body to avoid CSS inheritence
12     *
13     * @param   rebase boolean
14     * @returns {jQuery}
15     */
16    jEditMakeAbsolute: function (rebase) {
17      return this.each(function () {
18        var el = $(this);
19        var pos;
20
21        if (rebase) {
22          pos = el.offset();
23        } else {
24          pos = el.position();
25        }
26
27        el.css({
28          position: "absolute",
29          marginLeft: 0,
30          marginTop: 0,
31          top: pos.top,
32          left: pos.left,
33          bottom: "auto",
34          right: "auto",
35        });
36
37        if (rebase) {
38          el.detach().appendTo("body");
39        }
40      });
41    },
42  });
43
44  $(document).ready(function () {
45    $(".jmoddiv").on({
46      mouseenter: function () {
47        // Get module editing URL and tooltip for module edit:
48        var moduleEditUrl = $(this).data("jmodediturl");
49        var moduleTip = $(this).data("jmodtip");
50        var moduleTarget = $(this).data("target");
51
52        // Stop timeout on previous tooltip and remove it:
53        $("body>.btn.jmodedit").clearQueue().tooltip("dispose").remove();
54
55        // Add editing button with tooltip:
56        $(this)
57          .addClass("jmodinside")
58          .prepend(
59            '<a class="btn btn-secondary btn-sm jmodedit" href="#" target="' +
60              moduleTarget +
61              '"><span class="fas fa-edit" aria-hidden="true"></span></a>',
62          )
63          .children(":first")
64          .attr("href", moduleEditUrl)
65          .attr("title", moduleTip)
66          .tooltip({ html: true, placement: "top" })
67          .jEditMakeAbsolute(true);
68
69        $(".btn.jmodedit").on({
70          mouseenter: function () {
71            // Stop delayed removal programmed by mouseleave of .jmoddiv or of this one:
72            $(this).clearQueue();
73          },
74          mouseleave: function () {
75            // Delay remove editing button if not hovering it:
76            $(this)
77              .delay(500)
78              .queue(function (next) {
79                $(this).tooltip("dispose").remove();
80                next();
81              });
82          },
83        });
84      },
85      mouseleave: function () {
86        // Delay remove editing button if not hovering it:
87        $("body>.btn.jmodedit")
88          .delay(500)
89          .queue(function (next) {
90            $(this).tooltip("dispose").remove();
91            next();
92          });
93      },
94    });
95
96    // Menu items edit icons:
97
98    var activePopover = null;
99
100    $(
101      ".jmoddiv[data-jmenuedittip] .nav li,.jmoddiv[data-jmenuedittip].nav li,.jmoddiv[data-jmenuedittip] .nav .nav-child li,.jmoddiv[data-jmenuedittip].nav .nav-child li",
102    ).on({
103      mouseenter: function () {
104        // Get menu ItemId from the item-nnn class of the li element of the menu:
105        var itemids = /\bitem-(\d+)\b/.exec($(this).attr("class"));
106        if (typeof itemids[1] == "string") {
107          // Find module editing URL from enclosing module:
108          var enclosingModuleDiv = $(this).closest(".jmoddiv");
109          var moduleEditUrl = enclosingModuleDiv.data("jmodediturl");
110          // Transform module editing URL into Menu Item editing url:
111          var menuitemEditUrl = moduleEditUrl.replace(
112            /\/index.php\?option=com_config&controller=config.display.modules([^\d]+).+$/,
113            "/administrator/index.php?option=com_menus&view=item&layout=edit$1" +
114              itemids[1],
115          );
116        }
117
118        // Get tooltip for menu items from enclosing module
119        var menuEditTip = enclosingModuleDiv
120          .data("jmenuedittip")
121          .replace("%s", itemids[1]);
122
123        var content = $(
124          '<div><a class="btn jfedit-menu" href="#" target="_blank" rel="noopener noreferrer"><span class="icon-edit"></span></a></div>',
125        );
126        content
127          .children("a.jfedit-menu")
128          .prop("href", menuitemEditUrl)
129          .prop("title", menuEditTip);
130
131        if (activePopover) {
132          $(activePopover).popover("hide");
133        }
134        $(this)
135          .popover({
136            html: true,
137            content: content.html(),
138            container: "body",
139            trigger: "manual",
140            animation: false,
141            placement: "bottom",
142          })
143          .popover("show");
144        activePopover = this;
145
146        $("body>div.popover")
147          .on({
148            mouseenter: function () {
149              if (activePopover) {
150                $(activePopover).clearQueue();
151              }
152            },
153            mouseleave: function () {
154              if (activePopover) {
155                $(activePopover).popover("hide");
156              }
157            },
158          })
159          .find("a.jfedit-menu")
160          .tooltip({ html: true, placement: "bottom" });
161      },
162      mouseleave: function () {
163        $(this)
164          .delay(1500)
165          .queue(function (next) {
166            $(this).popover("hide");
167            next();
168          });
169      },
170    });
171  });
172
173  $(document).ready(function () {
174    // Turn radios into btn-group
175    $(".radio.btn-group label").addClass("btn btn-outline-secondary");
176    $(".btn-group label:not(.active)").click(function () {
177      var label = $(this);
178      var input = $("#" + label.attr("for"));
179
180      if (!input.prop("checked")) {
181        label
182          .closest(".btn-group")
183          .find("label")
184          .removeClass(
185            "active btn-outline-success btn-outline-danger btn-outline-primary",
186          );
187        if (input.val() == "") {
188          label.addClass("active btn-outline-primary");
189        } else if (input.val() == 0) {
190          label.addClass("active btn-outline-danger");
191        } else {
192          label.addClass("active btn-outline-success");
193        }
194        input.prop("checked", true);
195      }
196    });
197
198    $(".btn-group input[checked=checked]").each(function () {
199      if ($(this).val() == "") {
200        $("label[for=" + $(this).attr("id") + "]").addClass(
201          "active btn-outline-primary",
202        );
203      } else if ($(this).val() == 0) {
204        $("label[for=" + $(this).attr("id") + "]").addClass(
205          "active btn-outline-danger",
206        );
207      } else {
208        $("label[for=" + $(this).attr("id") + "]").addClass(
209          "active btn-outline-success",
210        );
211      }
212    });
213  });
214
215  if (typeof MooTools != "undefined") {
216    var mHide = Element.prototype.hide;
217    Element.implement({
218      hide: function () {
219        if ($(".hasPopover") && $(".hasPopover").attr("data-original-title")) {
220          return this;
221        }
222        mHide.apply(this, arguments);
223      },
224    });
225  }
226
227  // MooTools issue with Joomla 3
228  if (typeof jQuery != "undefined" && typeof MooTools != "undefined") {
229    $(document).ready(function () {
230      $(".carousel").each(function (index, element) {
231        $(this)[index].slide = null;
232      });
233    });
234
235    window.addEvent("domready", function () {
236      Element.prototype.hide = function () {};
237    });
238  }
239
240  // collapse
241  // $.fn.collapse = function (option) {
242  // 	return this.each(function () {
243  // 		var $this = $(this),
244  // 			data = $this.data("collapse"),
245  // 			options = $.extend({}, $.fn.collapse.defaults, $this.data(), typeof option == "object" && option);
246  // 		console.log("data", data);
247  // 		console.log(options);
248  // 		if (!data) {
249  // 			$this.data("collapse", (data = new bootstrap.Collapse(this, options)));
250  // 		}
251  // 		if (typeof option == "string") data[option]();
252  // 	});
253  // };
254
255  // $.fn.collapse.defaults = {
256  // 	toggle: true,
257  // };
258})(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.