مدیاویکی:Common.js: تفاوت میان نسخه‌ها

۳٬۱۷۲ بایت اضافه‌شده ،  ‏۱۹ ژوئن ۲۰۲۱
بدون خلاصۀ ویرایش
بدون خلاصۀ ویرایش
بدون خلاصۀ ویرایش
خط ۱: خط ۱:
/* Any JavaScript here will be loaded for all users on every page load. */
/* Any JavaScript here will be loaded for all users on every page load. */
$('#mw-content-text').not(":has('#editform')").each(function(){
/* $('#mw-content-text').not(":has('#editform')").each(function(){
     $(this).html(farsi_number($(this).html()));
     $(this).html(farsi_number($(this).html()));
})
})
خط ۳۴: خط ۳۴:
     return string;
     return string;
}
}
 
*/


var autoCollapse = 2;
var autoCollapse = 2;
خط ۲۴۳: خط ۲۴۳:
}
}


function align_mp_box(){
function align_mp_box() {
return;
  var firstColumn = $('.first-column-container');
    $('.mp-box').each(function(index){
  var secondColumn = $('.second-column-container');
        if(index%2 === 0) {
 
            return;
  var firstColumnLastChild = firstColumn.children().last();
        }
  var secondColumnLastChild = secondColumn.children().last();
 
  var firstChildDataPaddingBottom = firstColumnLastChild.data('padding-bottom');
  var secondChildDataPaddingBottom = secondColumnLastChild.data('padding-bottom');
 
  if (typeof firstChildDataPaddingBottom == 'undefined') {
    firstChildDataPaddingBottom = Math.round(parseInt(firstColumnLastChild.css('padding-bottom')));
    firstColumnLastChild.data('padding-bottom', firstChildDataPaddingBottom);
  }
 
  if (typeof secondChildDataPaddingBottom == 'undefined') {
    secondChildDataPaddingBottom = Math.round(parseInt(secondColumnLastChild.css('padding-bottom')));
    secondColumnLastChild.data('padding-bottom', secondChildDataPaddingBottom);
  }
 
  firstColumnLastChild.css('padding-bottom', firstChildDataPaddingBottom)
  secondColumnLastChild.css('padding-bottom', secondChildDataPaddingBottom)
 
  var firstColumnHeight = firstColumn.height();
  var secondColumnHeight = secondColumn.height();
 
  var diff = Math.round(firstColumnHeight - secondColumnHeight);
 
 
  var lastChild = null;
  var lastChildPaddingBottom = null;
  if (diff > 0) {
    lastChild = secondColumn.children().last();
    lastChildPaddingBottom = secondChildDataPaddingBottom;
  } else {
    lastChild = firstColumn.children().last();
    lastChildPaddingBottom = firstChildDataPaddingBottom;
    diff = Math.abs(diff);
  }
 
  lastChild.css('padding-bottom', (lastChildPaddingBottom + diff));
}
 
function showModal() {
  var modalHtml = '<div class="modal fade" id="popUpOverlay">\n' +
    '  <div class="modal-dialog">\n' +
    '    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">\n' +
    '      <i class="fa fa-close"></i>\n' +
    '    </button>\n' +
    '    <a href="https://www.wikihussain.com/campaign" target="_blank">\n' +
    '      <img src="/assets/images/popup.png" class="img-responsive">\n' +
    '    </a>\n' +
    '  </div>\n' +
    '</div>\n';
 
  if (typeof(Storage) !== "undefined") {
    var showModal = localStorage.getItem("donatePopup");


        var that = $('.mp-box').eq(index-1);
    if (!showModal) {
        var that_height = that.outerHeight();
      jQuery('body').append(modalHtml);
        var this_height = $(this).outerHeight();
      jQuery('#popUpOverlay').modal('show');
      localStorage.setItem("donatePopup", "1");
    }
  }
}


        if(this_height > that_height) {
/*
            that.css('min-height', this_height);
function replaceText1(selector, text, newText) {
        } else {
    var matcher = new RegExp(text, 'g');
            $(this).css('min-height', that_height);
    jQuery(selector).each(function () {
         }
        var $this = jQuery(this);
        if($this.prop("tagName")!='STYLE' && $this.prop("tagName")!='SCRIPT' && $this.prop("tagName")!='IMG' && $this.prop("tagName")!='PRE' && !$this.children().length )
            $this.text($this.text().replace(matcher, newText));
          
     });
     });
}
}


function align_box(){
 
    $('.box-55').each(function(){
function replaceText2(searchText, replacement, searchNode) {
        var that = $(this).next('.box-45, .box-45-pic-mini');
  if (!searchText || typeof replacement === 'undefined') {
        var this_height = $(this).outerHeight();
      // Throw error here if you want...
        var that_height = that.outerHeight();
      return;
        if(this_height > that_height) {
  }
            that.css('min-height', this_height);
  var regex = typeof searchText === 'string' ?
        } else {
              new RegExp(searchText, 'g') : searchText,
            $(this).css('min-height', that_height);
      childNodes = (searchNode || document.body).childNodes,
        }
      cnLength = childNodes.length,
    });
      excludes = 'html,head,style,title,link,meta,script,object,iframe';
  while (cnLength--) {
      var currentNode = childNodes[cnLength];
      if (currentNode.nodeType === 1 &&
          (excludes + ',').indexOf(currentNode.nodeName.toLowerCase() + ',') === -1) {
          arguments.callee(searchText, replacement, currentNode);
      }
      if (currentNode.nodeType !== 3 || !regex.test(currentNode.data) ) {
          continue;
      }
      var parent = currentNode.parentNode,
          frag = (function(){
              var html = currentNode.data.replace(regex, replacement),
                  wrap = document.createElement('div'),
                  frag = document.createDocumentFragment();
              wrap.innerHTML = html;
              while (wrap.firstChild) {
                  frag.appendChild(wrap.firstChild);
              }
              return frag;
          })();
      parent.insertBefore(frag, currentNode);
      parent.removeChild(currentNode);
  }
}
}


$(createNavigationBarToggleButton);
function replaceText3(element, pattern, replacement) {
  for (let node of element.childNodes) {
      switch (node.nodeType) {
          case Node.ELEMENT_NODE:
              replaceText3(node, pattern, replacement);
              break;
          case Node.TEXT_NODE:
              node.textContent = node.textContent.replace(pattern, replacement);
              break;
          case Node.DOCUMENT_NODE:
              replaceText3(node, pattern, replacement);
      }
  }
}
*/
jQuery(document).ready(function () {


var mp_y_item_h = 50;
  align_mp_box();
$('.mp-yadbood-item').each(function(){
  // showModal();
  if($(this).height() > mp_y_item_h){
      mp_y_item_h = $(this).height();
  }
});
$('.mp-yadbood-item').height(mp_y_item_h);


$(document).ready(function(){
  if (
     $('.video-container[data-include-link]').each(function(){
     window.location.hostname != 'localhost'
        var that = $(this);
    && window.location.hostname != '127.0.0.1'
        var src = that.children('a').attr('href');
    && window.location.hostname != 'wiki'
        that.html('<video id="video-'+ Date.now() +'" controls preload="metadata"><source src="'+src+'" /></video>');
    && window.location.hostname != 'fa.wiki'
     })
    && window.location.hostname != 'en.wiki'
})
     && window.location.hostname != 'fr.wiki'
  ) {


$(document).ready(function(){
    (function (i, s, o, g, r, a, m) {
  align_mp_box();
      i['GoogleAnalyticsObject'] = r;
  align_box();
      i[r] = i[r] || function () {
        (i[r].q = i[r].q || []).push(arguments)
      }, i[r].l = 1 * new Date();
      a = s.createElement(o),
        m = s.getElementsByTagName(o)[0];
      a.async = 1;
      a.src = g;
      m.parentNode.insertBefore(a, m)
    })(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');


  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    ga('create', 'UA-85669311-1', 'auto');
   (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    ga('send', 'pageview');
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  }
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
 
  /*
 
   if(window.location.hostname == 'fa.wikihussain.com') {
    var faNum=['۰','۱','۲','۳','۴','۵','۶','۷','۸','۹'];
    for(k in faNum){
      replaceText1(document.body,k,faNum[k]);  
      //replaceText2(document.body,k,faNum[k]);   
      replaceText3(document.body,k,faNum[k]);  


  //$('.mp-footer').html("<img id='oeukjxlzfukzsizpwlao' style='cursor:pointer' onclick='window.open(\"https://logo.samandehi.ir/Verify.aspx?id=81694&p=mcsirfthgvkapfvlaods\", \"Popup\",\"toolbar=no, scrollbars=no, location=no, statusbar=no, menubar=no, resizable=0, width=450, height=630, top=30\")' alt='logo-samandehi' src='https://logo.samandehi.ir/logo.aspx?id=81694&p=aqgwnbpdwlbqbsiyshwl'/> ");
    }


   ga('create', 'UA-85669311-1', 'auto');
   }
   ga('send', 'pageview');
   */
});
});


$(window).on('resize', function(){
jQuery(window).on('load', function () {
    align_mp_box();
  align_mp_box();
    align_box();
});
});


$(window).on('load', function(){
jQuery(window).on('resize', function () {
   align_mp_box();
   align_mp_box();
  align_box();
});
});
$(function () {
    //$('#footer').prepend("<img id='oeukjxlzfukzsizpwlao' style='cursor:pointer' onclick='window.open(\"https://logo.samandehi.ir/Verify.aspx?id=81694&p=mcsirfthgvkapfvlaods\", \"Popup\",\"toolbar=no, scrollbars=no, location=no, statusbar=no, menubar=no, resizable=0, width=450, height=630, top=30\")' alt='logo-samandehi' src='https://logo.samandehi.ir/logo.aspx?id=81694&p=aqgwnbpdwlbqbsiyshwl'/>");
}());