Difference between revisions of "MediaWiki:Common.js"

Jump to: navigation, search

Difference between revisions of "MediaWiki:Common.js"

 
(89 intermediate revisions by 2 users not shown)
Line 1: Line 1:
var monthNames = ["January", "February", "March", "April", "May", "June",
+
// Terms Modal
  "July", "August", "September", "October", "November", "December"
+
$(document).ready(function() {
];
 
  
var CurrentDate = new Date();
+
  setTimeout(function() {
CurrentDate.setMonth(CurrentDate.getMonth() + 3);
+
    const termsModal = $('#termsModal');
x = CurrentDate.getMonth();
 
  
var y = ' || ' + x.getFullYear() + '-' + monthNames[x] + '-' + x.getDate() + ' }}';
+
    if (termsModal.length) {
 +
      // Check if the "rpmTermsAgreement" cookie is present
 +
      if (!document.cookie.includes('rpmTermsAgreement')) {
 +
        // Show the Bootstrap modal
 +
        termsModal.modal({
 +
          backdrop: "static"
 +
        });
 +
      }
  
jQuery.fn.visible = function() {
+
      // Agree button click event to set the "rpm" cookie
    return this.css('visibility', 'visible');
+
      $('#agreeTermsButton').click(function() {
};
+
        termsModal.modal('hide');
 
+
       
jQuery.fn.invisible = function() {
+
        // Set the "rpmTermsAgreement" cookie with expiration date five years from now
    return this.css('visibility', 'hidden');
+
        var expirationDate = new Date();
};
+
        expirationDate.setFullYear(expirationDate.getFullYear() + 5);
 
+
         document.cookie = "rpmTermsAgreement=true; expires=" + expirationDate.toUTCString() + "; path=/";
jQuery.fn.visibilityToggle = function() {
+
      });
    return this.css('visibility', function(i, visibility) {
+
    }
         return (visibility == 'visible') ? 'hidden' : 'visible';
+
  }, 200);
    });
 
};
 
  
$.ajax({
+
  /* MailChimp Form */
url: 'https://meta.wikimedia.org/w/index.php?title=User:Krinkle/Scripts/InsertWikiEditorButton.js&action=raw&ctype=text/javascript',
 
dataType: 'script',
 
cache: true
 
}).done(function () {
 
  
krInsertWikiEditorButton({
+
  var mailchimpFormHTML =
id: "mw-customeditbutton-policies",
+
    '<div id="mc_embed_signup">' +
icon: "//rpm3.rcabc.org/resources/assets/policies.png",
+
    '    <form action="https://rcabc.us21.list-manage.com/subscribe/post?u=aa570610c198792349997a983&amp;id=91bc758592&amp;f_id=000857e1f0" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_self">' +
label: 'Guiding Principles',
+
    '       <div id="mc_embed_signup_scroll">' +
insertBefore: '<div class="principles">',
+
    '           <div class="mc-field-group form-group">' +
insertAfter: '</div>',
+
    '               <label for="mce-EMAIL">Email Address</label>' +
sampleText: 'Guiding Principles'
+
    '               <input type="email" value="" name="EMAIL" class="required email form-control" id="mce-EMAIL" required>' +
});
+
    '                <span id="mce-EMAIL-HELPERTEXT" class="helper_text"></span>' +
+
    '            </div>' +
krInsertWikiEditorButton({
+
    '            <div id="mce-responses" class="clear foot">' +
id: 'mw-customeditbutton-recommended',
+
    '                <div class="response" id="mce-error-response" style="display:none"></div>' +
icon: '//rpm3.rcabc.org/resources/assets/recommendations.png',
+
    '               <div class="response" id="mce-success-response" style="display:none"></div>' +
label: 'Recommended',
+
    '           </div>' +
insertBefore: '<div class="recommended">',
+
    '            <div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_aa570610c198792349997a983_91bc758592" tabindex="-1" value=""></div>' +
insertAfter: '</div>',
+
    '           <input type="submit" value="Subscribe To RPM Updates" name="subscribe" id="mc-embedded-subscribe" class="btn btn-primary">' +
sampleText: 'Recommended'
+
    '       </div>' +
});
+
    '   </form>' +
 +
    '</div>';
  
        krInsertWikiEditorButton({
+
  $('#mailchimpForm').html(mailchimpFormHTML);
id: 'mw-customeditbutton-reference',
 
icon: '//rpm3.rcabc.org/resources/assets/reference.png',
 
label: 'Reference',
 
insertBefore: '<div class="reference">',
 
insertAfter: '</div>',
 
sampleText: 'Reference'
 
});
 
       
 
        krInsertWikiEditorButton({
 
id: 'mw-customeditbutton-tabgroup',
 
icon: '//rpm3.rcabc.org/resources/assets/tabstart.png',
 
label: 'Create Tab Group',
 
insertBefore: '<tabs>',
 
insertAfter: '</tabs>'
 
});
 
        krInsertWikiEditorButton({
 
id: 'mw-customeditbutton-tab',
 
icon: '//rpm3.rcabc.org/resources/assets/tab.png',
 
label: 'Create Tab',
 
insertBefore: '<tab name="CHANGE ME">',
 
insertAfter: '</tab>'
 
});
 
        krInsertWikiEditorButton({
 
id: "mw-customeditbutton-hilite",
 
icon: "//upload.wikimedia.org/wikipedia/commons/3/3f/Button_attendre.png",
 
label: 'Highlight with Date',
 
insertBefore: '{{hilite | ',
 
insertAfter: y,
 
sampleText: 'Highlight this'
 
});
 
        krInsertWikiEditorButton({
 
id: "mw-customeditbutton-hilite",
 
icon: "//upload.wikimedia.org/wikipedia/commons/0/08/VisualEditor_-_Icon_-_Strikethrough-a.svg",
 
label: 'Strike with Date',
 
insertBefore: '{{strike| ',
 
insertAfter: y,
 
sampleText: 'Strike this'
 
});
 
 
});
 
});

Latest revision as of 22:13, 19 June 2023

// Terms Modal
$(document).ready(function() {

  setTimeout(function() {
    const termsModal = $('#termsModal');

    if (termsModal.length) {
      // Check if the "rpmTermsAgreement" cookie is present
      if (!document.cookie.includes('rpmTermsAgreement')) {
        // Show the Bootstrap modal
        termsModal.modal({
          backdrop: "static"
        });
      }

      // Agree button click event to set the "rpm" cookie
      $('#agreeTermsButton').click(function() {
        termsModal.modal('hide');
        
        // Set the "rpmTermsAgreement" cookie with expiration date five years from now
        var expirationDate = new Date();
        expirationDate.setFullYear(expirationDate.getFullYear() + 5);
        document.cookie = "rpmTermsAgreement=true; expires=" + expirationDate.toUTCString() + "; path=/";
      });
    }
  }, 200);

  /* MailChimp Form */

  var mailchimpFormHTML =
    '<div id="mc_embed_signup">' +
    '    <form action="https://rcabc.us21.list-manage.com/subscribe/post?u=aa570610c198792349997a983&amp;id=91bc758592&amp;f_id=000857e1f0" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_self">' +
    '        <div id="mc_embed_signup_scroll">' +
    '            <div class="mc-field-group form-group">' +
    '                <label for="mce-EMAIL">Email Address</label>' +
    '                <input type="email" value="" name="EMAIL" class="required email form-control" id="mce-EMAIL" required>' +
    '                <span id="mce-EMAIL-HELPERTEXT" class="helper_text"></span>' +
    '            </div>' +
    '            <div id="mce-responses" class="clear foot">' +
    '                <div class="response" id="mce-error-response" style="display:none"></div>' +
    '                <div class="response" id="mce-success-response" style="display:none"></div>' +
    '            </div>' +
    '            <div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_aa570610c198792349997a983_91bc758592" tabindex="-1" value=""></div>' +
    '            <input type="submit" value="Subscribe To RPM Updates" name="subscribe" id="mc-embedded-subscribe" class="btn btn-primary">' +
    '        </div>' +
    '    </form>' +
    '</div>';

  $('#mailchimpForm').html(mailchimpFormHTML);
});