Difference between revisions of "MediaWiki:Common.js"

From Dashboard samenwerking Wijchen
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
/* 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. */
 
  
 
/* Ignore upload warnings - box checked by default  */
 
/* Ignore upload warnings - box checked by default  */
 
+
if (mw.config.get('wgPageName') == 'Special:Upload') {
if ( mw.config.get ( 'wgPageName' ) == 'Special:Upload') {
+
    (function ($) {
  ( function( $ ) {
+
        $('#wpIgnoreWarning').prop('checked', true);
    $( '#wpIgnoreWarning' ).prop( 'checked', true );
+
    }(jQuery));
  }( jQuery ) );
 
 
}
 
}
 
  
 
$(document).ready(function () {
 
$(document).ready(function () {
 
     // Disable fields with class 'disabled'
 
     // Disable fields with class 'disabled'
    $('.disabled').attr('readonly', true);
+
    $('.disabled').attr('readonly', true);
  
 
     //Initialize tooltips
 
     //Initialize tooltips
 
     //$('.nav-tabs > li a[title]').tooltip();
 
     //$('.nav-tabs > li a[title]').tooltip();
   
+
 
 
     //Wizard
 
     //Wizard
 
     $('a[data-toggle="tab"]').on('show.bs.tab', function (e) {
 
     $('a[data-toggle="tab"]').on('show.bs.tab', function (e) {
  
 
         var $target = $(e.target);
 
         var $target = $(e.target);
   
+
 
 
         if ($target.parent().hasClass('disabled')) {
 
         if ($target.parent().hasClass('disabled')) {
 
             return false;
 
             return false;
Line 28: Line 25:
 
     });
 
     });
  
     $(".next-step").click(function (e) {
+
     $('.next-step').click(function (e) {
  
 
         var $active = $('.wizard .nav-tabs li.active');
 
         var $active = $('.wizard .nav-tabs li.active');
Line 35: Line 32:
  
 
     });
 
     });
     $(".prev-step").click(function (e) {
+
     $('.prev-step').click(function (e) {
  
 
         var $active = $('.wizard .nav-tabs li.active');
 
         var $active = $('.wizard .nav-tabs li.active');
Line 43: Line 40:
 
});
 
});
  
function nextTab(elem) {
+
function nextTab(elem)
 +
{
 
     $(elem).next().find('a[data-toggle="tab"]').click();
 
     $(elem).next().find('a[data-toggle="tab"]').click();
 
}
 
}
function prevTab(elem) {
+
 
 +
function prevTab(elem)
 +
{
 
     $(elem).prev().find('a[data-toggle="tab"]').click();
 
     $(elem).prev().find('a[data-toggle="tab"]').click();
 
}
 
}
  
(function($){
+
(function ($) {
$.fn.extend({
+
    $.fn.extend({
percentcircle: function(options) {
+
        percentcircle: function (options) {
var defaults = {
+
            var defaults = {
    animate: true,
+
                animate: true,
bgColor: '#FFFFFF',
+
                bgColor: '#FFFFFF',
fillColor: '#12ACF6',
+
                fillColor: '#12ACF6',
};
+
            };
 +
 
 +
            var that = this,
 +
                template = '<div class="radial-wrap"><div class="radial-circle"><div class="radial-inner-circle"><span class="radial-percentage">{{percentage}}</span></div></div></div>',
 +
                options = $.extend(defaults, options);
  
var that = this,
+
            function init()
template = '<div class="radial-wrap"><div class="radial-circle"><div class="radial-inner-circle"><span class="radial-percentage">{{percentage}}</span></div></div></div>',
+
            {
options = $.extend(defaults, options)
+
                that.each(function () {
 +
                    var $this = $(this),
 +
                        parentWidth = $(this).parent().width(),
 +
                        diameter = parentWidth,
 +
                        guage = Math.round(parentWidth / 25.6),
 +
                        percentSize = Math.round(parentWidth / 3.9) + 'px',
 +
                        styles = {
 +
                            cirContainer: {
 +
                                'width': diameter,
 +
                                'height': diameter
 +
                            },
 +
                            cir: {
 +
                                'width': diameter,
 +
                                'height': diameter,
 +
                                'background-color': defaults.fillColor,
 +
                                'background-image': 'linear-gradient(91deg, transparent 50%, ' + defaults.bgColor + ' 50%), linear-gradient(90deg, ' + defaults.bgColor + ' 50%, transparent 50%)'
 +
                            },
 +
                            cirCover: {
 +
                                'top': guage,
 +
                                'left': guage,
 +
                                'width': diameter - (guage * 2),
 +
                                'height': diameter - (guage * 2)
 +
                            },
 +
                            percent: {
 +
                                'width': diameter - (guage * 2),
 +
                                'height': diameter - (guage * 2),
 +
                                'line-height': diameter - (guage * 2) + 'px',
 +
                                'font-size': percentSize
 +
                            }
 +
                        },
 +
                        now = Math.round($this.attr('aria-valuenow')),
 +
                        min = Math.round($this.attr('aria-valuemin')),
 +
                        max = Math.round($this.attr('aria-valuemax')),
 +
                        deg = now * (360 / (max - min)),
 +
                        perc = Math.round(now / (max - min) * 100),
 +
                        stop = options.animate ? 0 : deg,
 +
                        $chart = $(template.replace('{{percentage}}', perc + '%'));
  
function init(){
+
                    $('.radial-wrap', $chart).css(styles.cirContainer);
that.each(function(){
+
                    $('.radial-circle', $chart).css(styles.cir);
var $this = $(this),
+
                    $('.radial-inner-circle', $chart).css(styles.cirCover);
parentWidth = $(this).parent().width(),
+
                    $('.radial-percentage', $chart).css(styles.percent);
diameter = parentWidth,
+
                    $this.append($chart);
guage = Math.round(parentWidth / 25.6),
 
percentSize = Math.round(parentWidth / 3.9) + 'px',
 
styles = {
 
    cirContainer : {
 
  'width':diameter,
 
'height':diameter
 
},
 
cir : {
 
    'width': diameter,
 
    'height': diameter,
 
    'background-color': defaults.fillColor,
 
    'background-image' : 'linear-gradient(91deg, transparent 50%, '+defaults.bgColor+' 50%), linear-gradient(90deg, '+defaults.bgColor+' 50%, transparent 50%)'
 
},
 
cirCover: {
 
    'top': guage,
 
    'left': guage,
 
    'width': diameter - (guage * 2),
 
    'height': diameter - (guage * 2)
 
},
 
percent: {
 
'width': diameter - (guage * 2),
 
    'height': diameter - (guage * 2),
 
    'line-height': diameter - (guage * 2) + 'px',
 
    'font-size': percentSize
 
      }
 
},
 
now = Math.round($this.attr('aria-valuenow')),
 
min = Math.round($this.attr('aria-valuemin')),
 
max = Math.round($this.attr('aria-valuemax')),
 
deg = now * (360 / (max-min)),
 
perc = Math.round(now / (max-min) * 100),
 
stop = options.animate ? 0 : deg,
 
$chart = $(template.replace('{{percentage}}',perc+'%'));
 
  
$('.radial-wrap',$chart).css(styles.cirContainer);
+
                    setTimeout(function () {
$('.radial-circle', $chart).css(styles.cir);
+
                        animateChart(deg, parseInt(stop), $('.radial-circle', $chart));
$('.radial-inner-circle', $chart).css(styles.cirCover);
+
                    }, 250);
$('.radial-percentage', $chart).css(styles.percent);
+
                });
$this.append($chart);
+
            }
  
setTimeout(function(){
+
            var animateChart = function (stop, curr, $elm) {
animateChart(deg,parseInt(stop),$('.radial-circle', $chart));
+
                var deg = curr;
},250)
+
                if (curr <= stop) {
    });
+
                    if (deg <= 180) {
}
+
                        $elm.css('background-image', 'linear-gradient(' + (90 + deg) + 'deg, transparent 50%, ' + options.bgColor + ' 50%),linear-gradient(90deg, ' + options.bgColor + ' 50%, transparent 50%)');
 +
                    } else {
 +
                        $elm.css('background-image', 'linear-gradient(' + (deg - 90) + 'deg, transparent 50%, ' + options.fillColor + ' 50%),linear-gradient(90deg, ' + options.bgColor + ' 50%, transparent 50%)');
 +
                    }
 +
                    curr++;
 +
                    setTimeout(function () {
 +
                        animateChart(stop, curr, $elm);
 +
                    }, 1);
 +
                }
 +
            };
 +
 
 +
            init();
 +
        }
 +
    });
  
var animateChart = function (stop,curr,$elm){
 
var deg = curr;
 
if(curr <= stop){
 
if (deg<=180){
 
$elm.css('background-image','linear-gradient(' + (90+deg) + 'deg, transparent 50%, '+options.bgColor+' 50%),linear-gradient(90deg, '+options.bgColor+' 50%, transparent 50%)');
 
      }else{
 
    $elm.css('background-image','linear-gradient(' + (deg-90) + 'deg, transparent 50%, '+options.fillColor+' 50%),linear-gradient(90deg, '+options.bgColor+' 50%, transparent 50%)');
 
    }
 
curr ++;
 
setTimeout(function(){
 
animateChart(stop,curr,$elm);
 
},1);
 
}
 
};
 
 
init();
 
  }
 
});
 
 
 
})(jQuery);
 
})(jQuery);
  
 
$('.radial-progress').percentcircle();
 
$('.radial-progress').percentcircle();
 
 
  
 
/***********************************************
 
/***********************************************
* Cool DHTML tooltip script- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
+
* Cool DHTML tooltip script- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* Please keep this notice intact
+
* Please keep this notice intact
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
+
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
+
***********************************************/
  
var offsetxpoint=-60 //Customize x offset of tooltip
+
var offsetxpoint = -60; //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
+
var offsetypoint = 20; //Customize y offset of tooltip
var ie=document.all
+
var ie = document.all;
var ns6=document.getElementById && !document.all
+
var ns6 = document.getElementById && !document.all;
var enabletip=false
+
var enabletip = false;
if (ie||ns6){
+
var tipobj = '';
  var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""
+
if (ie){
  document.body.appendChild(tipobj)
+
    tipobj = document.all['dhtmltooltip'];
 +
} else if (ns6){
 +
    tipobj = document.getElementById('dhtmltooltip');
 +
}
 +
if(tipobj){
 +
    document.body.appendChild(tipobj);
 
}
 
}
  
function ietruebody(){
+
function ietruebody()
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
+
{
 +
    return (document.compatMode && document.compatMode != 'BackCompat') ? document.documentElement : document.body;
 
}
 
}
  
function ddrivetip(thetext, thecolor, thewidth){
+
function ddrivetip(thetext, thecolor, thewidth)
if (ns6||ie){
+
{
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
+
    if (ns6 || ie) {
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
+
        if (typeof thewidth != 'undefined') tipobj.style.width = thewidth + 'px';
tipobj.innerHTML=thetext
+
        if (typeof thecolor != 'undefined' && thecolor != '') tipobj.style.backgroundColor = thecolor;
enabletip=true
+
        tipobj.innerHTML = thetext;
return false
+
        enabletip = true;
}
+
        return false;
 +
    }
 
}
 
}
  
function positiontip(e){
+
function positiontip(e)
if (enabletip){
+
{
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
+
    if (enabletip) {
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
+
        var curX = (ns6) ? e.pageX : event.clientX + ietruebody().scrollLeft;
 +
        var curY = (ns6) ? e.pageY : event.clientY + ietruebody().scrollTop;
 
//Find out how close the mouse is to the corner of the window
 
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
+
        var rightedge = ie && !window.opera ? ietruebody().clientWidth - event.clientX - offsetxpoint : window.innerWidth - e.clientX - offsetxpoint - 20;
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20
+
        var bottomedge = ie && !window.opera ? ietruebody().clientHeight - event.clientY - offsetypoint : window.innerHeight - e.clientY - offsetypoint - 20;
  
var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000
+
        var leftedge = (offsetxpoint < 0) ? offsetxpoint * (-1) : -1000;
  
 
//if the horizontal distance isn't enough to accomodate the width of the context menu
 
//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth)
+
        if (rightedge < tipobj.offsetWidth)
 
//move the horizontal position of the menu to the left by it's width
 
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
+
            tipobj.style.left = ie ? ietruebody().scrollLeft + event.clientX - tipobj.offsetWidth + 'px' : window.pageXOffset + e.clientX - tipobj.offsetWidth + 'px';
else if (curX<leftedge)
+
        else if (curX < leftedge)
tipobj.style.left="5px"
+
            tipobj.style.left = '5px';
else
+
        else
 
//position the horizontal position of the menu where the mouse is positioned
 
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetxpoint+"px"
+
            tipobj.style.left = curX + offsetxpoint + 'px';
  
 
//same concept with the vertical position
 
//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
+
        if (bottomedge < tipobj.offsetHeight)
tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
+
            tipobj.style.top = ie ? ietruebody().scrollTop + event.clientY - tipobj.offsetHeight - offsetypoint + 'px' : window.pageYOffset + e.clientY - tipobj.offsetHeight - offsetypoint + 'px';
else
+
        else
tipobj.style.top=curY+offsetypoint+"px"
+
            tipobj.style.top = curY + offsetypoint + 'px';
tipobj.style.visibility="visible"
+
        tipobj.style.visibility = 'visible';
 +
    }
 
}
 
}
 +
 +
function hideddrivetip()
 +
{
 +
    if (ns6 || ie) {
 +
        enabletip = false;
 +
        tipobj.style.visibility = 'hidden';
 +
        tipobj.style.left = '-1000px';
 +
        tipobj.style.backgroundColor = '';
 +
        tipobj.style.width = '';
 +
    }
 
}
 
}
  
function hideddrivetip(){
+
document.onmousemove = positiontip;
if (ns6||ie){
 
enabletip=false
 
tipobj.style.visibility="hidden"
 
tipobj.style.left="-1000px"
 
tipobj.style.backgroundColor=''
 
tipobj.style.width=''
 
}
 
}
 
  
document.onmousemove=positiontip
+
// ----------------------------------------------- Add script
 +
var script = document.createElement('script');
 +
script.src = '/skin/pfUploadWindowToSelect2Fix.js';
 +
script.id = 'pfUploadWindowToSelect2Fix';
 +
document.body.appendChild(script);

Latest revision as of 09:38, 16 June 2021

/* Any JavaScript here will be loaded for all users on every page load. */

/* Ignore upload warnings - box checked by default  */
if (mw.config.get('wgPageName') == 'Special:Upload') {
    (function ($) {
        $('#wpIgnoreWarning').prop('checked', true);
    }(jQuery));
}

$(document).ready(function () {
    // Disable fields with class 'disabled'
    $('.disabled').attr('readonly', true);

    //Initialize tooltips
    //$('.nav-tabs > li a[title]').tooltip();

    //Wizard
    $('a[data-toggle="tab"]').on('show.bs.tab', function (e) {

        var $target = $(e.target);

        if ($target.parent().hasClass('disabled')) {
            return false;
        }
    });

    $('.next-step').click(function (e) {

        var $active = $('.wizard .nav-tabs li.active');
        $active.next().removeClass('disabled');
        nextTab($active);

    });
    $('.prev-step').click(function (e) {

        var $active = $('.wizard .nav-tabs li.active');
        prevTab($active);

    });
});

function nextTab(elem)
{
    $(elem).next().find('a[data-toggle="tab"]').click();
}

function prevTab(elem)
{
    $(elem).prev().find('a[data-toggle="tab"]').click();
}

(function ($) {
    $.fn.extend({
        percentcircle: function (options) {
            var defaults = {
                animate: true,
                bgColor: '#FFFFFF',
                fillColor: '#12ACF6',
            };

            var that = this,
                template = '<div class="radial-wrap"><div class="radial-circle"><div class="radial-inner-circle"><span class="radial-percentage">{{percentage}}</span></div></div></div>',
                options = $.extend(defaults, options);

            function init()
            {
                that.each(function () {
                    var $this = $(this),
                        parentWidth = $(this).parent().width(),
                        diameter = parentWidth,
                        guage = Math.round(parentWidth / 25.6),
                        percentSize = Math.round(parentWidth / 3.9) + 'px',
                        styles = {
                            cirContainer: {
                                'width': diameter,
                                'height': diameter
                            },
                            cir: {
                                'width': diameter,
                                'height': diameter,
                                'background-color': defaults.fillColor,
                                'background-image': 'linear-gradient(91deg, transparent 50%, ' + defaults.bgColor + ' 50%), linear-gradient(90deg, ' + defaults.bgColor + ' 50%, transparent 50%)'
                            },
                            cirCover: {
                                'top': guage,
                                'left': guage,
                                'width': diameter - (guage * 2),
                                'height': diameter - (guage * 2)
                            },
                            percent: {
                                'width': diameter - (guage * 2),
                                'height': diameter - (guage * 2),
                                'line-height': diameter - (guage * 2) + 'px',
                                'font-size': percentSize
                            }
                        },
                        now = Math.round($this.attr('aria-valuenow')),
                        min = Math.round($this.attr('aria-valuemin')),
                        max = Math.round($this.attr('aria-valuemax')),
                        deg = now * (360 / (max - min)),
                        perc = Math.round(now / (max - min) * 100),
                        stop = options.animate ? 0 : deg,
                        $chart = $(template.replace('{{percentage}}', perc + '%'));

                    $('.radial-wrap', $chart).css(styles.cirContainer);
                    $('.radial-circle', $chart).css(styles.cir);
                    $('.radial-inner-circle', $chart).css(styles.cirCover);
                    $('.radial-percentage', $chart).css(styles.percent);
                    $this.append($chart);

                    setTimeout(function () {
                        animateChart(deg, parseInt(stop), $('.radial-circle', $chart));
                    }, 250);
                });
            }

            var animateChart = function (stop, curr, $elm) {
                var deg = curr;
                if (curr <= stop) {
                    if (deg <= 180) {
                        $elm.css('background-image', 'linear-gradient(' + (90 + deg) + 'deg, transparent 50%, ' + options.bgColor + ' 50%),linear-gradient(90deg, ' + options.bgColor + ' 50%, transparent 50%)');
                    } else {
                        $elm.css('background-image', 'linear-gradient(' + (deg - 90) + 'deg, transparent 50%, ' + options.fillColor + ' 50%),linear-gradient(90deg, ' + options.bgColor + ' 50%, transparent 50%)');
                    }
                    curr++;
                    setTimeout(function () {
                        animateChart(stop, curr, $elm);
                    }, 1);
                }
            };

            init();
        }
    });

})(jQuery);

$('.radial-progress').percentcircle();

/***********************************************
 * Cool DHTML tooltip script- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
 * Please keep this notice intact
 * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
 ***********************************************/

var offsetxpoint = -60; //Customize x offset of tooltip
var offsetypoint = 20; //Customize y offset of tooltip
var ie = document.all;
var ns6 = document.getElementById && !document.all;
var enabletip = false;
var tipobj = '';
if (ie){
    tipobj = document.all['dhtmltooltip'];
} else if (ns6){
    tipobj = document.getElementById('dhtmltooltip');
}
if(tipobj){
    document.body.appendChild(tipobj);
}

function ietruebody()
{
    return (document.compatMode && document.compatMode != 'BackCompat') ? document.documentElement : document.body;
}

function ddrivetip(thetext, thecolor, thewidth)
{
    if (ns6 || ie) {
        if (typeof thewidth != 'undefined') tipobj.style.width = thewidth + 'px';
        if (typeof thecolor != 'undefined' && thecolor != '') tipobj.style.backgroundColor = thecolor;
        tipobj.innerHTML = thetext;
        enabletip = true;
        return false;
    }
}

function positiontip(e)
{
    if (enabletip) {
        var curX = (ns6) ? e.pageX : event.clientX + ietruebody().scrollLeft;
        var curY = (ns6) ? e.pageY : event.clientY + ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
        var rightedge = ie && !window.opera ? ietruebody().clientWidth - event.clientX - offsetxpoint : window.innerWidth - e.clientX - offsetxpoint - 20;
        var bottomedge = ie && !window.opera ? ietruebody().clientHeight - event.clientY - offsetypoint : window.innerHeight - e.clientY - offsetypoint - 20;

        var leftedge = (offsetxpoint < 0) ? offsetxpoint * (-1) : -1000;

//if the horizontal distance isn't enough to accomodate the width of the context menu
        if (rightedge < tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
            tipobj.style.left = ie ? ietruebody().scrollLeft + event.clientX - tipobj.offsetWidth + 'px' : window.pageXOffset + e.clientX - tipobj.offsetWidth + 'px';
        else if (curX < leftedge)
            tipobj.style.left = '5px';
        else
//position the horizontal position of the menu where the mouse is positioned
            tipobj.style.left = curX + offsetxpoint + 'px';

//same concept with the vertical position
        if (bottomedge < tipobj.offsetHeight)
            tipobj.style.top = ie ? ietruebody().scrollTop + event.clientY - tipobj.offsetHeight - offsetypoint + 'px' : window.pageYOffset + e.clientY - tipobj.offsetHeight - offsetypoint + 'px';
        else
            tipobj.style.top = curY + offsetypoint + 'px';
        tipobj.style.visibility = 'visible';
    }
}

function hideddrivetip()
{
    if (ns6 || ie) {
        enabletip = false;
        tipobj.style.visibility = 'hidden';
        tipobj.style.left = '-1000px';
        tipobj.style.backgroundColor = '';
        tipobj.style.width = '';
    }
}

document.onmousemove = positiontip;

// ----------------------------------------------- Add script
var script = document.createElement('script');
script.src = '/skin/pfUploadWindowToSelect2Fix.js';
script.id = 'pfUploadWindowToSelect2Fix';
document.body.appendChild(script);