הבדלים בין גרסאות בדף "מדיה ויקי:Common.js"
קפיצה לניווט
קפיצה לחיפוש
(86 גרסאות ביניים של 4 משתמשים אינן מוצגות) | |||
שורה 1: | שורה 1: | ||
+ | /* סינון מונחון */ | ||
+ | $(function() { | ||
+ | var $input = $("input[name='keyword']"), | ||
+ | $context = $("#context ul li"); | ||
+ | $outofcontext = $("#context h3 "), | ||
+ | $input.on("input", function() { | ||
+ | var term = $(this).val(); | ||
+ | $context.show().unmark(); | ||
+ | if (term) { | ||
+ | $context.mark(term, { | ||
+ | "separateWordSearch": false, | ||
+ | done: function() { | ||
+ | $context.not(":has(mark)").hide(); | ||
+ | $outofcontext.hide(); | ||
+ | } | ||
+ | }); | ||
+ | } else { | ||
+ | $outofcontext.show(); | ||
+ | } | ||
+ | }); | ||
+ | }); | ||
+ | //download links for svg diagrams toggle | ||
+ | $(".download-toggle").click(function() { | ||
+ | $(this).find(".download-links") | ||
+ | .toggleClass("visible"); | ||
+ | }); | ||
//DISABLE REDLINKS | //DISABLE REDLINKS | ||
− | if ($('#pt-logout').length == 0) { | + | if ($('#pt-logout').length === 0) { |
$("a[class=new]").removeAttr('href').removeAttr('title'); | $("a[class=new]").removeAttr('href').removeAttr('title'); | ||
} | } | ||
שורה 10: | שורה 36: | ||
// Append the cloned element to TOC with id="toctitle" | // Append the cloned element to TOC with id="toctitle" | ||
− | if ($(' | + | if ($('.toctitle').length > 0) { |
− | + | $('.toctitle').get(0).appendChild(clnPageHead); | |
// toc laggy sticky - based over contained sticky scroll: http://blog.echoenduring.com/2010/11/27/making-of-the-contained-sticky-scroll-jquery-plugin/ | // toc laggy sticky - based over contained sticky scroll: http://blog.echoenduring.com/2010/11/27/making-of-the-contained-sticky-scroll-jquery-plugin/ | ||
+ | |||
+ | |||
(function( $ ){ | (function( $ ){ | ||
− | |||
$.fn.containedStickyScroll = function( options ) { | $.fn.containedStickyScroll = function( options ) { | ||
שורה 63: | שורה 90: | ||
})( jQuery ); | })( jQuery ); | ||
− | jQuery('#toc').containedStickyScroll(); | + | jQuery('#toc').containedStickyScroll({oSelector:'#toc'}); |
} | } | ||
} | } | ||
שורה 85: | שורה 112: | ||
var clnBreadCrumbs = BreadCrumbs.cloneNode(true); | var clnBreadCrumbs = BreadCrumbs.cloneNode(true); | ||
$( "#breadcrumbs2" ).remove(); | $( "#breadcrumbs2" ).remove(); | ||
− | document.getElementById(" | + | document.getElementById("image-banner").appendChild(clnBreadCrumbs); |
} | } | ||
שורה 124: | שורה 151: | ||
$(".filehistory a").html(FileLinkText); | $(".filehistory a").html(FileLinkText); | ||
− | /* | + | |
− | $ | + | //Smooth scrolling with links |
− | + | /* Fix scroll with fixed nav bar */ | |
− | + | (function($, window) { | |
− | + | var adjustAnchor = function() { | |
− | + | ||
− | + | var $anchor = $(':target'), | |
− | $ | + | fixedElementHeight = 48; |
− | + | ||
− | + | if ($anchor.length > 0) { | |
− | + | ||
− | + | $('html, body') | |
− | + | .stop() | |
+ | .animate({ | ||
+ | scrollTop: $anchor.offset().top - fixedElementHeight | ||
+ | }, 200); | ||
+ | |||
+ | } | ||
+ | |||
+ | }; | ||
+ | |||
+ | $(window).on('hashchange load', function() { | ||
+ | adjustAnchor(); | ||
+ | }); | ||
+ | })(jQuery, window); | ||
+ | |||
+ | |||
+ | $('#toc a').on('click', function(event) { | ||
+ | $(this).parent().find('a').removeClass('active'); | ||
+ | $(this).addClass('active'); | ||
+ | }); | ||
+ | |||
+ | $(window).on('scroll', function() { | ||
+ | $('.mw-headline').each(function() { | ||
+ | if($(window).scrollTop() >= $(this).position().top) { | ||
+ | var id = $(this).attr('id'); | ||
+ | $('#toc a').removeClass('active'); | ||
+ | $('#toc a[href="#' + id + '"]').addClass('active'); | ||
} | } | ||
− | }); | + | }); |
− | } | + | }); |
− | + | ||
+ | // Function to submit the form | ||
+ | function submitForm(event) { | ||
+ | event.preventDefault(); | ||
+ | var emailInput = document.getElementById("email-input"); | ||
+ | var email = emailInput.value; | ||
+ | |||
+ | // Add your Mailchimp API key and list ID here | ||
+ | |||
+ | var data = { | ||
+ | members: [ | ||
+ | { | ||
+ | email_address: email, | ||
+ | status: "subscribed" | ||
+ | } | ||
+ | ] | ||
+ | }; | ||
+ | |||
+ | fetch('https://us9.api.mailchimp.com/3.0/lists/429493/members', { | ||
+ | method: "POST", | ||
+ | headers: { | ||
+ | "Content-Type": "application/json" | ||
+ | }, | ||
+ | body: JSON.stringify(data) | ||
+ | }) | ||
+ | .then(function(response) { | ||
+ | if (response.ok) { | ||
+ | console.log("Email subscribed successfully"); | ||
+ | } else { | ||
+ | console.log("Error subscribing email"); | ||
} | } | ||
+ | dismissPopup(); | ||
+ | }) | ||
+ | .catch(function(error) { | ||
+ | console.log("Error subscribing email:", error); | ||
+ | dismissPopup(); | ||
}); | }); | ||
+ | } | ||
+ | |||
+ | //Mailchimp popup | ||
+ | |||
+ | $(document).ready(function() { | ||
+ | // Update Mailchimp form parameters | ||
+ | $(document).ready(function() { | ||
+ | var pageValue = window.wgTitle || ""; // Extract the value of wgTitle | ||
+ | var categoryValue = window.wgCategories ? window.wgCategories.join(",") : ""; // Extract the value of wgCategories | ||
+ | |||
+ | // Set the values in the hidden fields | ||
+ | $(".mc-page").val(pageValue); | ||
+ | $(".mc-category").val(categoryValue); | ||
}); | }); | ||
+ | var formActionUrl = "https://doalogue.us9.list-manage.com/subscribe/post?u=75d7d0b31bc5688c8ae6a9e15&id=54881cf257&f_id=00b719e1f0"; | ||
+ | var emailInputId = "mce-EMAIL"; | ||
− | var | + | // Update form action URL |
− | + | $(".mc-embedded-subscribe-form").attr("action", formActionUrl); | |
+ | var emailInput = $("#" + emailInputId); | ||
+ | |||
+ | // Update email input ID | ||
+ | |||
+ | // Check if the popup should be shown | ||
+ | if (!getCookie("popupDismissed")) { | ||
+ | // Wait for 5 seconds before showing the popup | ||
+ | setTimeout(showPopup, 5000); | ||
+ | } | ||
+ | }); | ||
+ | |||
+ | // Function to show the popup | ||
+ | function showPopup() { | ||
+ | var popup = $("#popup"); | ||
+ | popup.addClass("show"); | ||
+ | } | ||
+ | |||
+ | // Function to dismiss the popup | ||
+ | function dismissPopup() { | ||
+ | var popup = $("#popup"); | ||
+ | popup.removeClass("show"); | ||
+ | // Set a cookie to remember that the popup has been dismissed | ||
+ | setCookie("popupDismissed", "true", 30); | ||
+ | |||
+ | // Trigger GA4 event for dismissal | ||
+ | ga('send', 'event', 'Popup', 'Dismiss'); | ||
+ | } | ||
+ | |||
+ | // Function to set a cookie | ||
+ | function setCookie(name, value, days) { | ||
+ | var expires = ""; | ||
+ | if (days) { | ||
+ | var date = new Date(); | ||
+ | date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); | ||
+ | expires = "; expires=" + date.toUTCString(); | ||
+ | } | ||
+ | document.cookie = name + "=" + value + expires + "; path=/"; | ||
+ | } | ||
+ | |||
+ | // Function to get a cookie | ||
+ | function getCookie(name) { | ||
+ | var nameEQ = name + "="; | ||
+ | var ca = document.cookie.split(';'); | ||
+ | for (var i = 0; i < ca.length; i++) { | ||
+ | var c = ca[i]; | ||
+ | while (c.charAt(0) == ' ') { | ||
+ | c = c.substring(1, c.length); | ||
+ | } | ||
+ | if (c.indexOf(nameEQ) == 0) { | ||
+ | return c.substring(nameEQ.length, c.length); | ||
+ | } | ||
+ | } | ||
+ | return null; | ||
+ | } | ||
+ | |||
+ | // Handle form submission | ||
+ | $(".mc-embedded-subscribe-form").submit(function(e) { | ||
+ | var form = $(this); | ||
+ | var thankYouMessage = $("#thank-you-message"); | ||
+ | var errorMessage = $("#error-message"); | ||
+ | |||
+ | // Display thank you message and hide form | ||
+ | thankYouMessage.show(); | ||
+ | form.hide(); | ||
+ | |||
+ | // Trigger GA4 event for successful subscription | ||
+ | ga('send', 'event', 'Popup', 'Subscription'); | ||
+ | |||
+ | |||
+ | |||
+ | // Prevent the default form submission | ||
+ | e.preventDefault(); | ||
+ | |||
+ | // Submit the form using AJAX to the Mailchimp address | ||
+ | $.ajax({ | ||
+ | url: form.attr('action'), | ||
+ | type: 'POST', | ||
+ | data: form.serialize(), | ||
+ | dataType: 'jsonp', | ||
+ | success: function(response) { | ||
+ | // Handle success response (if needed) | ||
+ | if (response.result === 'success') { | ||
+ | // Successful signup, dismiss the popup and set the cookie | ||
+ | dismissPopup(); | ||
+ | setCookie("popupDismissed", "true", 30); | ||
+ | } | ||
+ | }, | ||
+ | error: function(xhr, status, error) { | ||
+ | // Handle error response (if needed) | ||
+ | } | ||
+ | }); | ||
+ | }); |
גרסה אחרונה מ־13:04, 10 ביולי 2023
/* סינון מונחון */
$(function() {
var $input = $("input[name='keyword']"),
$context = $("#context ul li");
$outofcontext = $("#context h3 "),
$input.on("input", function() {
var term = $(this).val();
$context.show().unmark();
if (term) {
$context.mark(term, {
"separateWordSearch": false,
done: function() {
$context.not(":has(mark)").hide();
$outofcontext.hide();
}
});
} else {
$outofcontext.show();
}
});
});
//download links for svg diagrams toggle
$(".download-toggle").click(function() {
$(this).find(".download-links")
.toggleClass("visible");
});
//DISABLE REDLINKS
if ($('#pt-logout').length === 0) {
$("a[class=new]").removeAttr('href').removeAttr('title');
}
// TOC title: Get the element
if ($(window).width() > 1200) {
var PageHead = document.getElementById("firstHeading");
// Copy the <li> element and its child nodes
var clnPageHead = PageHead.cloneNode(true);
// Append the cloned element to TOC with id="toctitle"
if ($('.toctitle').length > 0) {
$('.toctitle').get(0).appendChild(clnPageHead);
// toc laggy sticky - based over contained sticky scroll: http://blog.echoenduring.com/2010/11/27/making-of-the-contained-sticky-scroll-jquery-plugin/
(function( $ ){
$.fn.containedStickyScroll = function( options ) {
var defaults = {
oSelector : this.selector,
unstick : true,
easing: 'linear',
duration: 0,
queue: false,
closeChar: '',
closeTop: 3,
baroffset: 80,
closeRight: 3
};
var options = $.extend(defaults, options);
if(options.unstick === true){
this.append('<a class="scrollFixIt" title="נעיצה תוכן העניינים בראש העמוד"><i class="fa fa-thumb-tack"></i>' + options.closeChar + '</a>');
jQuery(options.oSelector + ' .scrollFixIt').css('position','absolute');
jQuery(options.oSelector + ' .scrollFixIt').css('top',options.closeTop + 'px');
jQuery(options.oSelector + ' .scrollFixIt').css('right',options.closeTop + 'px');
jQuery(options.oSelector + ' .scrollFixIt').css('cursor','pointer');
jQuery(options.oSelector + ' .scrollFixIt').click(function() {
getObject = options.oSelector;
jQuery(getObject).animate({ top: "0px" },
{ queue: options.queue, easing: options.easing, duration: options.duration });
jQuery(window).unbind();
jQuery('.scrollFixIt').remove();
});
}
jQuery(window).scroll(function() {
getObject = options.oSelector;
if(jQuery(window).scrollTop() > (jQuery(getObject).parent().offset().top - options.baroffset) &&
(jQuery(getObject).parent().height() + jQuery(getObject).parent().position().top - options.baroffset) > (jQuery(window).scrollTop() + jQuery(getObject).height())){
jQuery(getObject).animate({ top: (jQuery(window).scrollTop() - jQuery(getObject).parent().offset().top) + 80 + "px" },
{ queue: options.queue, easing: options.easing, duration: options.duration });
}
else if(jQuery(window).scrollTop() < (jQuery(getObject).parent().offset().top)){
jQuery(getObject).animate({ top: "0px" },
{ queue: options.queue, easing: options.easing, duration: options.duration });
}
});
};
})( jQuery );
jQuery('#toc').containedStickyScroll({oSelector:'#toc'});
}
}
//mobile menu
var $hideMenu = $('#nav .hideMenu');
var $menuTrigger = $('#nav');
$menuTrigger.on( "tap", function(e) {
$hideMenu.toggle();
e.preventDefault();
});
$("a[href='#.D7.9C.D7.97.D7.A6.D7.95_.D7.9B.D7.90.D7.9F_.D7.9C.D7.A7.D7.91.D7.99.D7.A2.D7.AA_.D7.A4.D7.92.D7.99.D7.A9.D7.AA_.D7.A2.D7.91.D7.95.D7.93.D7.94_.D7.91.D7.A0.D7.95.D7.A9.D7.90_.D7.96.D7.94']").css( "display", "none" );
// banner
if ($('#image-banner').length > 0) {
// replace Breadcrumbs
if ($('#breadcrumbs2').length == 1) {
var BreadCrumbs = document.getElementById("breadcrumbs2");
var clnBreadCrumbs = BreadCrumbs.cloneNode(true);
$( "#breadcrumbs2" ).remove();
document.getElementById("image-banner").appendChild(clnBreadCrumbs);
}
$('#image-banner').css('background-image', 'url(' + $('.image img').attr('src') + ')').css('opacity', '1');
var PageHead = document.getElementById("firstHeading");
// Copy the element and its child nodes
var clnPageHead = PageHead.cloneNode(true);
var PageHeader = document.getElementById("image-banner");
var clnPageHeader = PageHeader.cloneNode(true);
if ($('.image').length > 0) {
document.getElementById("image-banner").remove();
$("#header").after(clnPageHeader);
$('#firstHeading').css('display', 'none');
document.getElementById("newHeading").appendChild(clnPageHead);
$('#newHeading #firstHeading').removeAttr('id');
}
}
if ($('#image-banner').length > 0) {
$('#p-logo').addClass("banner");
$('#image-banner').css('opacity', '1');
//$('#fullScreen').attr("href", $('a.image:first').attr('href'));
$( "a.image:first" ).appendTo( "#fullScreen" );
}
/* mobile menu */
if ($(window).width() < 890) {
$("#nav ul").click(function(){
$("#nav ul").toggleClass("active");
});
}
/* Media PAge */
var FileLinkText = $("#firstHeading").text();
$(".filehistory a").html(FileLinkText);
//Smooth scrolling with links
/* Fix scroll with fixed nav bar */
(function($, window) {
var adjustAnchor = function() {
var $anchor = $(':target'),
fixedElementHeight = 48;
if ($anchor.length > 0) {
$('html, body')
.stop()
.animate({
scrollTop: $anchor.offset().top - fixedElementHeight
}, 200);
}
};
$(window).on('hashchange load', function() {
adjustAnchor();
});
})(jQuery, window);
$('#toc a').on('click', function(event) {
$(this).parent().find('a').removeClass('active');
$(this).addClass('active');
});
$(window).on('scroll', function() {
$('.mw-headline').each(function() {
if($(window).scrollTop() >= $(this).position().top) {
var id = $(this).attr('id');
$('#toc a').removeClass('active');
$('#toc a[href="#' + id + '"]').addClass('active');
}
});
});
// Function to submit the form
function submitForm(event) {
event.preventDefault();
var emailInput = document.getElementById("email-input");
var email = emailInput.value;
// Add your Mailchimp API key and list ID here
var data = {
members: [
{
email_address: email,
status: "subscribed"
}
]
};
fetch('https://us9.api.mailchimp.com/3.0/lists/429493/members', {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(data)
})
.then(function(response) {
if (response.ok) {
console.log("Email subscribed successfully");
} else {
console.log("Error subscribing email");
}
dismissPopup();
})
.catch(function(error) {
console.log("Error subscribing email:", error);
dismissPopup();
});
}
//Mailchimp popup
$(document).ready(function() {
// Update Mailchimp form parameters
$(document).ready(function() {
var pageValue = window.wgTitle || ""; // Extract the value of wgTitle
var categoryValue = window.wgCategories ? window.wgCategories.join(",") : ""; // Extract the value of wgCategories
// Set the values in the hidden fields
$(".mc-page").val(pageValue);
$(".mc-category").val(categoryValue);
});
var formActionUrl = "https://doalogue.us9.list-manage.com/subscribe/post?u=75d7d0b31bc5688c8ae6a9e15&id=54881cf257&f_id=00b719e1f0";
var emailInputId = "mce-EMAIL";
// Update form action URL
$(".mc-embedded-subscribe-form").attr("action", formActionUrl);
var emailInput = $("#" + emailInputId);
// Update email input ID
// Check if the popup should be shown
if (!getCookie("popupDismissed")) {
// Wait for 5 seconds before showing the popup
setTimeout(showPopup, 5000);
}
});
// Function to show the popup
function showPopup() {
var popup = $("#popup");
popup.addClass("show");
}
// Function to dismiss the popup
function dismissPopup() {
var popup = $("#popup");
popup.removeClass("show");
// Set a cookie to remember that the popup has been dismissed
setCookie("popupDismissed", "true", 30);
// Trigger GA4 event for dismissal
ga('send', 'event', 'Popup', 'Dismiss');
}
// Function to set a cookie
function setCookie(name, value, days) {
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + value + expires + "; path=/";
}
// Function to get a cookie
function getCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1, c.length);
}
if (c.indexOf(nameEQ) == 0) {
return c.substring(nameEQ.length, c.length);
}
}
return null;
}
// Handle form submission
$(".mc-embedded-subscribe-form").submit(function(e) {
var form = $(this);
var thankYouMessage = $("#thank-you-message");
var errorMessage = $("#error-message");
// Display thank you message and hide form
thankYouMessage.show();
form.hide();
// Trigger GA4 event for successful subscription
ga('send', 'event', 'Popup', 'Subscription');
// Prevent the default form submission
e.preventDefault();
// Submit the form using AJAX to the Mailchimp address
$.ajax({
url: form.attr('action'),
type: 'POST',
data: form.serialize(),
dataType: 'jsonp',
success: function(response) {
// Handle success response (if needed)
if (response.result === 'success') {
// Successful signup, dismiss the popup and set the cookie
dismissPopup();
setCookie("popupDismissed", "true", 30);
}
},
error: function(xhr, status, error) {
// Handle error response (if needed)
}
});
});