1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-12 09:44:38 +02:00

Update lots of core .js files for jQuery 3.6.4 support

This commit is contained in:
Ryan Cramer
2023-04-14 11:54:28 -04:00
parent f11843562a
commit bd0253477e
68 changed files with 300 additions and 330 deletions

View File

@@ -261,7 +261,7 @@ var Inputfields = {
var $tabButton = jQuery('#_' + $tabContent.attr('id'));
if($tabButton.length) {
$tabContent.show();
setTimeout(function() { $tabButton.click(); }, 25);
setTimeout(function() { $tabButton.trigger('click'); }, 25);
}
}
// inputfield is not visible likely due to parents being hidden
@@ -287,7 +287,7 @@ var Inputfields = {
// if ajax loaded, force InputfieldStates() click handler to open this one
if(isCollapsed && isAjax && !$inputfield.hasClass('InputfieldStateWasCollapsed')) {
$toggleIcon.click();
$toggleIcon.trigger('click');
return $inputfield;
}
@@ -413,7 +413,7 @@ var Inputfields = {
InputfieldColumnWidths();
// jQuery(document).trigger('redrawInputfields', null);
}
jQuery(window).resize(); // trigger for FormBuilder or similar
jQuery(window).trigger('resize'); // trigger for FormBuilder or similar
}, delay);
},
@@ -777,7 +777,7 @@ var Inputfields = {
var $header = $inputfield.children('.InputfieldHeader');
if(!$header.length) return '';
label = $header.text();
if(label.length) label = jQuery.trim(label);
if(label.length) label = label.toString().trim();
return label;
},
@@ -1006,7 +1006,7 @@ function InputfieldDependencies($target) {
*
*/
function trimValue(value) {
value = jQuery.trim(value);
value = value.toString().trim();
var first = value.substring(0,1);
var last = value.substring(value.length-1, value.length);
if((first == '"' || first == "'") && first == last) value = value.substring(1, value.length-1);
@@ -1046,9 +1046,14 @@ function InputfieldDependencies($target) {
*/
function parseValue(str, str2) {
str = jQuery.trim(str);
if(str.length > 0 && !jQuery.isNumeric(str)) {
return str;
str = str.toString().trim();
if(str.length > 0) {
if(/^-?[\d.]+$/.test(str)) {
// isNumeric
} else {
return str;
}
}
if(str.length == 0) {
@@ -1212,7 +1217,7 @@ function InputfieldDependencies($target) {
var $checkbox = $checkboxes.eq(cn);
var $label = $checkbox.closest('label');
if($label.length) {
var label = jQuery.trim($label.text());
var label = $label.text().trim();
if(label == _conditionValue) {
consoleLog('Matching checked label found: ' + _conditionValue);
value.push(label);
@@ -1570,7 +1575,7 @@ function InputfieldDependencies($target) {
// attach change event to dependency inputfield
if($inputfield.length) {
consoleLog('Attaching change event for: ' + $inputfield.attr('name'));
$inputfield.change(function() {
$inputfield.on('change', function() {
inputfieldChange(conditions, $fieldToShow);
});
} else {
@@ -1904,7 +1909,7 @@ function InputfieldFormBeforeUnloadEvent(e) {
name = $(this).find(':input').attr('name');
}
}
if(name.length) msg += "\n• " + $.trim(name);
if(name.length) msg += "\n• " + name.trim();
});
(e || window.event).returnValue = msg; // Gecko and Trident
return msg; // Gecko and WebKit
@@ -2060,7 +2065,7 @@ function InputfieldStates($target) {
if(isTab) {
$header.effect('highlight', 500);
} else if(Inputfields.toggleBehavior < 1) {
$header.click();
$header.trigger('click');
}
}, 500);
}, 'html');
@@ -2073,14 +2078,14 @@ function InputfieldStates($target) {
// use different icon for open and closed
var $icon = $(".Inputfields .InputfieldStateCollapsed > .InputfieldHeader i.toggle-icon, .Inputfields .InputfieldStateCollapsed > .ui-widget-header i.toggle-icon", $target);
$icon.toggleClass($icon.attr('data-to'));
if($icon.length && typeof $icon.attr('data-to') !== 'undefined') $icon.toggleClass($icon.attr('data-to'));
// display a detail with the HTML field name when the toggle icon is hovered
if(typeof ProcessWire != "undefined") {
var config = ProcessWire.config;
}
if(typeof config !== "undefined" && config.debug) {
$('.InputfieldHeader > i.toggle-icon', $target).hover(function() {
$('.InputfieldHeader > i.toggle-icon', $target).on('mouseenter', function() {
var $label = $(this).parent('label');
if($label.length == 0) return;
var forId = $label.attr('for');
@@ -2093,7 +2098,7 @@ function InputfieldStates($target) {
$label.append($tip);
}
}, function() {
}).on('mouseleave', function() {
var $label = $(this).parent('label');
if($label.length == 0) return;
$label.find('.InputfieldNameTip').remove();
@@ -2135,7 +2140,7 @@ function InputfieldStates($target) {
Inputfields.toggle($li, null, duration);
} else if(Inputfields.toggleBehavior === 1) {
// open/close implied by header label click
$icon.click();
$icon.trigger('click');
} else {
// Inputfield not collapsible unless toggle icon clicked, so pulsate the toggle icon and focus any inputs
if(typeof jQuery.ui != 'undefined') {
@@ -2240,7 +2245,7 @@ function InputfieldIntentions() {
var numButtons = null;
var $input = null;
$form.submit(function() {
$form.on('submit', function() {
if(!$(this).hasClass('nosubmit')) return;
if(!$input) return;
@@ -2404,9 +2409,9 @@ jQuery(document).ready(function($) {
setTimeout('InputfieldWindowResizeActions2()', 2000);
};
$(window).resize(windowResized);
$(window).on('resize', windowResized);
$("ul.WireTabs > li > a").click(function() {
$("ul.WireTabs > li > a").on('click', function() {
if(InputfieldWindowResizeQueued) return;
InputfieldWindowResizeQueued = true;
setTimeout('InputfieldWindowResizeActions1()', 250);

File diff suppressed because one or more lines are too long

View File

@@ -19,7 +19,7 @@ var ProcessWireAdmin = {
},
setupNotices: function() {
$(".pw-notice-group-toggle").click(function() {
$(".pw-notice-group-toggle").on('click', function() {
var $parent = $(this).closest('.pw-notice-group-parent');
var $children = $parent.nextUntil('.pw-notice-group-parent');
if($parent.hasClass('pw-notice-group-open')) {
@@ -46,7 +46,7 @@ var ProcessWireAdmin = {
my: "center bottom", // bottom-20
at: "center top"
}
}).hover(function() {
}).on('mouseenter', function() {
var $a = $(this);
if($a.is('a')) {
$a.addClass('ui-state-hover');
@@ -56,7 +56,7 @@ var ProcessWireAdmin = {
}
$a.addClass('pw-tooltip-hover');
$a.css('cursor', 'pointer');
}, function() {
}).on('mouseleave', function() {
var $a = $(this);
$a.removeClass('pw-tooltip-hover ui-state-hover');
if(!$a.is('a')) {
@@ -135,7 +135,7 @@ var ProcessWireAdmin = {
if($a.is('button')) {
if($a.find('.ui-button-text').length == 0) $a.button();
if($a.attr('type') == 'submit') {
$a.click(function() {
$a.on('click', function() {
$a.addClass('pw-dropdown-disabled');
setTimeout(function() {
$a.removeClass('pw-dropdown-disabled');
@@ -147,7 +147,7 @@ var ProcessWireAdmin = {
}
// hide nav when an item is selected to avoid the whole nav getting selected
$ul.find('a').click(function() {
$ul.find('a').on('click', function() {
$ul.hide();
return true;
});
@@ -171,10 +171,10 @@ var ProcessWireAdmin = {
$a.removeClass('hover pw-dropdown-toggle-open');
}, 1000);
}
$ul.mouseleave(mouseleaver);
$a.mouseleave(mouseleaver);
$ul.on('mouseleave', mouseleaver);
$a.on('mouseleave', mouseleaver);
} else {
$ul.mouseleave(function() {
$ul.on('mouseleave', function() {
//if($a.is(":hover")) return;
//if($a.filter(":hover").length) return;
$ul.hide();
@@ -202,7 +202,7 @@ var ProcessWireAdmin = {
$('.pw-dropdown-toggle-open').each(function() {
var $a = $(this);
var $ul = $a.data('pw-dropdown-ul');
$ul.mouseleave();
$ul.trigger('mouseleave');
});
$a.addClass('pw-dropdown-toggle-open');
/*
@@ -408,14 +408,14 @@ var ProcessWireAdmin = {
if(typeof href != "undefined" && href.length > 1) {
return true;
} else {
$item.mouseleave();
$item.trigger('mouseleave');
}
} else {
var datafrom = $item.attr('data-from');
if(typeof datafrom == "undefined") var datafrom = '';
if(datafrom.indexOf('topnav') > -1) {
var from = datafrom.replace('topnav-', '') + '-';
$("a.pw-dropdown-toggle.hover:not('." + from + "')").attr('data-touchCnt', 0).mouseleave();
$("a.pw-dropdown-toggle.hover:not('." + from + "')").attr('data-touchCnt', 0).trigger('mouseleave');
}
$item.mouseenter();
}

File diff suppressed because one or more lines are too long