25f258c7fdfbdf417a917fcd00fff78d698def9b chmalee Fri Aug 30 12:01:24 2024 -0700 Big run through of changes to accomodate jquery 3.7.1 upgrade. Most of the changes are replacing the event methods with a change to .on(event, function(..)). A couple more changes are removing calls to jquery.type(). Also fixes various plugins and styles diff --git src/hg/js/jquery.watermark.js src/hg/js/jquery.watermark.js index efbbc15..f38c827 100644 --- src/hg/js/jquery.watermark.js +++ src/hg/js/jquery.watermark.js @@ -370,95 +370,73 @@ $input.data( dataText, hasText? text : "" ); $input.data( dataClass, options.className ); $input.data( dataFlag, 1 ); // Flag indicates watermark was initialized // Special processing for password type if ( ( $input.attr( "type" ) || "" ) === "password" ) { var $wrap = $input.wrap( "<span>" ).parent(), $wm = $( $wrap.html().replace( /type=["']?password["']?/i, 'type="text"' ) ); $wm.data( dataText, $input.data( dataText ) ); $wm.data( dataClass, $input.data( dataClass ) ); $wm.data( dataFlag, 1 ); $wm.attr( "maxLength", text.length ); - $wm.focus( - function () { + $wm.on("focus", function () { $.watermark._hide( $wm, true ); - } - ).bind( "dragenter", - function () { + }).on("dragenter", function () { $.watermark._hide( $wm ); - } - ).bind( "dragend", - function () { + }).on("dragend", function () { window.setTimeout( function () { $wm.blur(); }, 1 ); - } - ); + }); - $input.blur( - function () { + $input.on("blur", function () { $.watermark._show( $input ); - } - ).bind( "dragleave", - function () { + }).on("dragleave", function () { $.watermark._show( $input ); - } - ); + }); $wm.data( dataPassword, $input ); $input.data( dataPassword, $wm ); } else { - $input.focus( - function () { + $input.on("focus", function () { $input.data( dataFocus, 1 ); $.watermark._hide( $input, true ); - } - ).blur( - function () { + }).on("blur", function () { $input.data( dataFocus, 0 ); $.watermark._show( $input ); - } - ).bind( "dragenter", - function () { + }).on( "dragenter", function () { $.watermark._hide( $input ); - } - ).bind( "dragleave", - function () { + }).on( "dragleave", function () { $.watermark._show( $input ); - } - ).bind( "dragend", - function () { + }).on( "dragend", function () { window.setTimeout( function () { $.watermark._show($input); }, 1 ); - } - ).bind( "drop", + }).on( "drop", function ( evt ) { // Firefox makes this lovely function necessary because the dropped text // is merged with the watermark before the drop event is called. - function ( evt ) { var elem = $input[ 0 ], dropText = evt.originalEvent.dataTransfer.getData( "Text" ); if ( ( elem.value || "" ).replace( rreturn, "" ).replace( dropText, "" ) === $input.data( dataText ) ) { elem.value = dropText; } - $input.focus(); - } - ); + $input.trigger("focus"); + }); } // In order to reliably clear all watermarks before form submission, // we need to replace the form's submit function with our own // function. Otherwise watermarks won't be cleared when the form // is submitted programmatically. if ( this.form ) { var form = this.form, $form = $( form ); if ( !$form.data( dataFormSubmit ) ) { $form.submit( function () { return $.watermark.hideAll.apply( this, options.clearAllFormsOnSubmit? [] : [ form ] ); } ); // form.submit exists for all browsers except Google Chrome // (see "else" below for explanation)