Unterschied: MediaWiki:Common.js
MediaWiki interface page
Ansichten
Aktionen
Namensräume
Varianten
Werkzeuge
Admin (Diskussion | Beiträge) |
Admin (Diskussion | Beiträge) |
||
Zeile 10: | Zeile 10: | ||
$(inputs[i]).attr('placeholder', placeholder); | $(inputs[i]).attr('placeholder', placeholder); | ||
}*/ | }*/ | ||
// interact.js | |||
// 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, | |||
// call this function on every dragend event | |||
end (event) { | |||
var textEl = event.target.querySelector('p') | |||
textEl && (textEl.textContent = | |||
'moved a distance of ' + | |||
(Math.sqrt(Math.pow(event.pageX - event.x0, 2) + | |||
Math.pow(event.pageY - event.y0, 2) | 0)) | |||
.toFixed(2) + 'px') | |||
} | |||
} | |||
}) | |||
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) | |||
} | |||
// this function is used later in the resizing and gesture demos | |||
window.dragMoveListener = dragMoveListener |
Version vom 24. Juni 2021, 07:38 Uhr
/* Das folgende JavaScript wird für alle Benutzer geladen. */
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
// 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,
// call this function on every dragend event
end (event) {
var textEl = event.target.querySelector('p')
textEl && (textEl.textContent =
'moved a distance of ' +
(Math.sqrt(Math.pow(event.pageX - event.x0, 2) +
Math.pow(event.pageY - event.y0, 2) | 0))
.toFixed(2) + 'px')
}
}
})
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)
}
// this function is used later in the resizing and gesture demos
window.dragMoveListener = dragMoveListener