DevWiki Articles Unterschied: MediaWiki:Common.js

Unterschied: MediaWiki:Common.js

MediaWiki interface page
 
(11 dazwischenliegende Versionen von 2 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
/* Das folgende JavaScript wird für alle Benutzer geladen. */
/* Das folgende JavaScript wird für alle Benutzer geladen. */


// grabbing sections
$(window).scroll(function() {
const ele = document.getElementsByClassName('mw-changeslist')[0];
     if ($(this).scrollTop() > 20) {
let pos = { top: 0, left: 0, x: 0, y: 0 };
$('#searchform').addClass('fadeOut');
 
$('#search-toggle').addClass('fadeOut');
function mouseDownHandler(e) {
$('#search-toggle-icon').addClass('fadeOut');
     pos = {
    } else {
        // The current scroll
$('#searchform').removeClass('fadeOut');
        left: ele.scrollLeft,
$('#search-toggle').removeClass('fadeOut');
        top: ele.scrollTop,
$('#search-toggle-icon').removeClass('fadeOut');
        // Get the current mouse position
     }
        x: e.clientX,
});
        y: e.clientY,
    };
 
    document.addEventListener('mousemove', mouseMoveHandler);
    document.addEventListener('mouseup', mouseUpHandler);
}
 
ele.addEventListener('keydown', mouseDownHandler);
 
function mouseMoveHandler(e) {
    // Change the cursor and prevent user from selecting the text
    ele.style.cursor = 'grabbing';
    ele.style.userSelect = 'none';
   
    // How far the mouse has been moved
    const dx = e.clientX - pos.x;
    const dy = e.clientY - pos.y;
 
     // Scroll the element
    ele.scrollTop = pos.top - dy;
    ele.scrollLeft = pos.left - dx;
}


function mouseUpHandler() {
// check checkbox on click label
    ele.style.cursor = 'grab';
$('.formedit t').on('click', function(e) {
    ele.style.removeProperty('user-select');
  var checkbox = $(e.target).parent().find('.oo-ui-checkboxInputWidget input');
}
  checkbox.click();
})


//set random
//set random
if ($('.puzzle').length) {
/*if ($('.puzzle').length) {
var puzzleHeight = $('.puzzle').css('height').replace('px','') - $('.draggable').css('height').replace('px','');
var puzzleHeight = $('.puzzle').css('height').replace('px','') - $('.draggable').css('height').replace('px','');
var puzzleWidth = $('.puzzle').css('width').replace('px','') - $('.draggable').css('width').replace('px','');
var puzzleWidth = $('.puzzle').css('width').replace('px','') - $('.draggable').css('width').replace('px','');
Zeile 51: Zeile 30:
$( this ).css("left", randomLeft);
$( this ).css("left", randomLeft);
});
});
}
}*/


/**
/**
Zeile 60: Zeile 39:
  */
  */


if ({ edit:1, submit:1 }[mw.config.get('wgAction')]) {
/*if ({ edit:1, submit:1 }[mw.config.get('wgAction')]) {
mw.loader.using('mediawiki.action.edit', function () {
mw.loader.using('mediawiki.action.edit', function () {
if (mw.toolbar) {
if (mw.toolbar) {
Zeile 85: Zeile 64:
}
}
});
});
}
}*/


if (window.location.pathname == '/view/BibleWiki') {
if (window.location.pathname == '/view/BibleWiki_Articles') {
window.history.replaceState({}, '', '/');
window.history.replaceState({}, '', '/');
}
}
Zeile 99: Zeile 78:
$(inputs[i]).attr('placeholder', placeholder);
$(inputs[i]).attr('placeholder', placeholder);
}*/
}*/
 
/*
// interact.js
// interact.js
$( ".draggable a" ).removeAttr("href").removeClass("image");
$( ".draggable a" ).removeAttr("href").removeClass("image");
Zeile 142: Zeile 121:
    
    
   // on the front
   // on the front
   $('.puzzle .draggable').css('z-index', 0);
   $('.puzzle .draggable').css('z-index', 2);
   $(target).css('z-index', 9);
   $(target).css('z-index', 9);
}
}


// this function is used later in the resizing and gesture demos
// this function is used later in the resizing and gesture demos
window.dragMoveListener = dragMoveListener
window.dragMoveListener = dragMoveListener*/

Aktuelle Version vom 22. April 2022, 16:27 Uhr

/* Das folgende JavaScript wird für alle Benutzer geladen. */

$(window).scroll(function() {
    if ($(this).scrollTop() > 20) {
		$('#searchform').addClass('fadeOut');
		$('#search-toggle').addClass('fadeOut');
		$('#search-toggle-icon').addClass('fadeOut');
    } else {
		$('#searchform').removeClass('fadeOut');
		$('#search-toggle').removeClass('fadeOut');
		$('#search-toggle-icon').removeClass('fadeOut');
    }
});

// check checkbox on click label
$('.formedit t').on('click', function(e) {
  var checkbox = $(e.target).parent().find('.oo-ui-checkboxInputWidget input');
  checkbox.click();
})

//set random
/*if ($('.puzzle').length) {
	var puzzleHeight = $('.puzzle').css('height').replace('px','') - $('.draggable').css('height').replace('px','');
	var puzzleWidth = $('.puzzle').css('width').replace('px','') - $('.draggable').css('width').replace('px','');
	$( ".draggable" ).each(function(e) {
		var randomTop = Math.floor(Math.random() * puzzleHeight) + 1;
		var randomLeft = Math.floor(Math.random() * puzzleWidth) + 1;
		
		$( this ).css("top", randomTop);
		$( this ).css("left", randomLeft);
	});
}*/

/**
 * Add custom buttons in the toolbar
 *
 * @source: https://www.mediawiki.org/wiki/Snippets/Custom_buttons_in_the_toolbar
 * @rev: 2
 */

/*if ({ edit:1, submit:1 }[mw.config.get('wgAction')]) {
	mw.loader.using('mediawiki.action.edit', function () {
		if (mw.toolbar) {

			// Wikitable
			mw.toolbar.addButton(
				'//upload.wikimedia.org/wikipedia/commons/0/04/Button_array.png',
				'Insert a table',
				'{| class="wikitable"\n|-\n',
				'\n|}',
				'! header 1\n! header 2\n! header 3\n|-\n| row 1, cell 1\n| row 1, cell 2\n| row 1, cell 3\n|-\n| row 2, cell 1\n| row 2, cell 2\n| row 2, cell 3',
				'mw-editbutton-wikitable'
			);

			// Redirect
			mw.toolbar.addButton(
				'//upload.wikimedia.org/wikipedia/en/c/c8/Button_redirect.png',
				'Redirect',
				'#REDIRECT [[',
				']]',
				'Insert text',
				'mw-editbutton-redirect'
			);
		}
	});
}*/

if (window.location.pathname == '/view/BibleWiki_Articles') {
	window.history.replaceState({}, '', '/');
}
if (window.location.href.includes('redlink=1')) {
	$('.page-actions').hide();
}

/*var inputs = $(".formedit .oo-ui-comboBoxInputWidget-field input");
for (var i=0; i<inputs.length; i++) {
	var placeholder = $(inputs[i]).parent().parent().parent().parent().parent().find('.placeholder').text();
	$(inputs[i]).attr('placeholder', placeholder);
}*/
/*
// interact.js
$( ".draggable a" ).removeAttr("href").removeClass("image");

// target elements with the "draggable" class
interact('.draggable')
  .draggable({
    // enable inertial throwing
    inertia: true,
    // keep the element within the area of it's parent
    modifiers: [
      interact.modifiers.restrictRect({
        restriction: 'parent',
        endOnly: true
      })
    ],
    // enable autoScroll
    autoScroll: true,

    listeners: {
      // call this function on every dragmove event
      move: dragMoveListener
    }
  })
  .on('doubletap', function (event) {
    event.currentTarget.classList.toggle('rotate')
    event.preventDefault()
  })

function dragMoveListener (event) {
  var target = event.target
  // keep the dragged position in the data-x/data-y attributes
  var x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx
  var y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy

  // translate the element
  target.style.transform = 'translate(' + x + 'px, ' + y + 'px)'

  // update the posiion attributes
  target.setAttribute('data-x', x)
  target.setAttribute('data-y', y)
  
  // on the front
  $('.puzzle .draggable').css('z-index', 2);
  $(target).css('z-index', 9);
}

// this function is used later in the resizing and gesture demos
window.dragMoveListener = dragMoveListener*/
Cookies helfen uns bei der Bereitstellung von DevWiki Articles. Durch die Nutzung von DevWiki Articles erklärst du dich damit einverstanden, dass wir Cookies speichern.