Make WordPress Core

Ticket #57946: 57946.1.patch

File 57946.1.patch, 2.0 KB (added by sabernhardt, 14 months ago)

replace old jQuery methods and add documentation notes

  • src/js/_enqueues/vendor/farbtastic.js

     
    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
    915$.fn.farbtastic = function (options) {
     
    4955  fb.linkTo = function (callback) {
    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
    5561    // Reset color
     
    6167    }
    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);
    6773      }
     
    116122  fb.mousedown = function (event) {
    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    }
    122128
     
    155161   */
    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  };
    162168
     
    262268  };
    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
    268274  fb.setColor('#000000');