External Libraries: Update deprecated jQuery code in Farbtastic lib.

This changeset updates some deprecated jQuery code in the Farbtastic external library. As this vendor script is not maintained anymore, this changeset 
also adds a docblock to specify that the library has been "adopted" by WP Core.

Props Malae, sabernhardt, SergeyBiryukov, Presskopp, mrinal013, peterwilsoncc, oglekler, jorbin.
Fixes #57946.



Built from https://develop.svn.wordpress.org/trunk@56252


git-svn-id: http://core.svn.wordpress.org/trunk@55764 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
audrasjb 2023-07-17 22:03:26 +00:00
parent b48154ae63
commit 5b3bd2c704
2 changed files with 13 additions and 7 deletions

View File

@ -1,9 +1,15 @@
/*! /*!
* Farbtastic: jQuery color picker plug-in v1.3u * Farbtastic: jQuery color picker plug-in v1.3u
* https://github.com/mattfarina/farbtastic
* *
* Licensed under the GPL license: * Licensed under the GPL license:
* http://www.gnu.org/licenses/gpl.html * http://www.gnu.org/licenses/gpl.html
*/ */
/**
* Modified for WordPress: replaced deprecated jQuery methods.
* See https://core.trac.wordpress.org/ticket/57946.
*/
(function($) { (function($) {
$.fn.farbtastic = function (options) { $.fn.farbtastic = function (options) {
@ -49,7 +55,7 @@ $._farbtastic = function (container, callback) {
fb.linkTo = function (callback) { fb.linkTo = function (callback) {
// Unbind previous nodes // Unbind previous nodes
if (typeof fb.callback == 'object') { if (typeof fb.callback == 'object') {
$(fb.callback).unbind('keyup', fb.updateValue); $(fb.callback).off('keyup', fb.updateValue);
} }
// Reset color // Reset color
@ -61,7 +67,7 @@ $._farbtastic = function (container, callback) {
} }
else if (typeof callback == 'object' || typeof callback == 'string') { else if (typeof callback == 'object' || typeof callback == 'string') {
fb.callback = $(callback); fb.callback = $(callback);
fb.callback.bind('keyup', fb.updateValue); fb.callback.on('keyup', fb.updateValue);
if (fb.callback.get(0).value) { if (fb.callback.get(0).value) {
fb.setColor(fb.callback.get(0).value); fb.setColor(fb.callback.get(0).value);
} }
@ -116,7 +122,7 @@ $._farbtastic = function (container, callback) {
fb.mousedown = function (event) { fb.mousedown = function (event) {
// Capture mouse // Capture mouse
if (!document.dragging) { if (!document.dragging) {
$(document).bind('mousemove', fb.mousemove).bind('mouseup', fb.mouseup); $(document).on('mousemove', fb.mousemove).on('mouseup', fb.mouseup);
document.dragging = true; document.dragging = true;
} }
@ -155,8 +161,8 @@ $._farbtastic = function (container, callback) {
*/ */
fb.mouseup = function () { fb.mouseup = function () {
// Uncapture mouse // Uncapture mouse
$(document).unbind('mousemove', fb.mousemove); $(document).off('mousemove', fb.mousemove);
$(document).unbind('mouseup', fb.mouseup); $(document).off('mouseup', fb.mouseup);
document.dragging = false; document.dragging = false;
}; };
@ -262,7 +268,7 @@ $._farbtastic = function (container, callback) {
}; };
// Install mousedown handler (the others are set on the document on-demand) // Install mousedown handler (the others are set on the document on-demand)
$('*', e).mousedown(fb.mousedown); $('*', e).on('mousedown', fb.mousedown);
// Init color // Init color
fb.setColor('#000000'); fb.setColor('#000000');

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.3-beta4-56251'; $wp_version = '6.3-beta4-56252';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.