JSFiddle - React, Tailwind, and code Playground
by esbenp
JavaScript
var beaverforms = beaverforms || {};
(function($){
$.fn.maxWidthAndHeight = function(options) {
var defaults = {
maxWidth: 300,
maxHeight: 300
}
var options = $.extend(defaults, options);
obj = $(this);
var width = obj.width();
var height = obj.height();
var scale = (width > height) ? height/width : width/height;
if (width > defaults.maxWidth || height > defaults.maxHeight) {
if (width > height) {
obj.css({
'height': (defaults.maxHeight*scale),
'width': defaults.maxWidth
});
} else {
obj.css({
'height': defaults.maxHeight,
'width': (defaults.maxWidth*scale)
});
}
}
}
})(jQuery);
/*
* CAPTURING AUTOFILL PLUGIN BY FURRYBRAINS.COM
* EDITED TO PREVENT EVENT ON FILE INPUTS!
*/
(function($) {
$.fn.listenForChange = function(options) {
settings = $.extend({
interval: 200 // in microseconds
}, options);
var jquery_object = this;
var current_focus = null;
jquery_object.filter(":input[type!=file]").add(":input[type!=file]", jquery_object).focus( function() {
current_focus = this;
}).blur( function() {
current_focus = null;
});
setInterval(function() {
// allow
jquery_object.filter(":input[type!=file]").add(":input[type!=file]", jquery_object).each(function() {
// set data cache on element to input value if not yet set
if ($(this).data('change_listener') == undefined) {
$(this).data('change_listener', $(this).val());
return;
}
// return if the value matches the cache
if ($(this).data('change_listener') == $(this).val()) {
return;
}
// ignore if element is in focus (since change event...