Make WordPress Core

Changeset 56252


Ignore:
Timestamp:
07/17/2023 10:01:08 PM (10 months ago)
Author:
audrasjb
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/vendor/farbtastic.js

    r43309 r56252  
    11/*!
    22 * Farbtastic: jQuery color picker plug-in v1.3u
     3 * https://github.com/mattfarina/farbtastic
    34 *
    45 * Licensed under the GPL license:
    56 *   http://www.gnu.org/licenses/gpl.html
    67 */
     8/**
     9 * Modified for WordPress: replaced deprecated jQuery methods.
     10 * See https://core.trac.wordpress.org/ticket/57946.
     11 */
     12
    713(function($) {
    814
     
    5056    // Unbind previous nodes
    5157    if (typeof fb.callback == 'object') {
    52       $(fb.callback).unbind('keyup', fb.updateValue);
     58      $(fb.callback).off('keyup', fb.updateValue);
    5359    }
    5460
     
    6268    else if (typeof callback == 'object' || typeof callback == 'string') {
    6369      fb.callback = $(callback);
    64       fb.callback.bind('keyup', fb.updateValue);
     70      fb.callback.on('keyup', fb.updateValue);
    6571      if (fb.callback.get(0).value) {
    6672        fb.setColor(fb.callback.get(0).value);
     
    117123    // Capture mouse
    118124    if (!document.dragging) {
    119       $(document).bind('mousemove', fb.mousemove).bind('mouseup', fb.mouseup);
     125      $(document).on('mousemove', fb.mousemove).on('mouseup', fb.mouseup);
    120126      document.dragging = true;
    121127    }
     
    156162  fb.mouseup = function () {
    157163    // Uncapture mouse
    158     $(document).unbind('mousemove', fb.mousemove);
    159     $(document).unbind('mouseup', fb.mouseup);
     164    $(document).off('mousemove', fb.mousemove);
     165    $(document).off('mouseup', fb.mouseup);
    160166    document.dragging = false;
    161167  };
     
    263269
    264270  // Install mousedown handler (the others are set on the document on-demand)
    265   $('*', e).mousedown(fb.mousedown);
     271  $('*', e).on('mousedown', fb.mousedown);
    266272
    267273    // Init color
Note: See TracChangeset for help on using the changeset viewer.