Sha256: c25f94062635a2e0547f9f8c40286c4e282e4b3f89a0a12c668d0fc6bd5f7b8f
Contents?: true
Size: 1.66 KB
Versions: 5
Compression:
Stored size: 1.66 KB
Contents
//TODO: get some more standardized Oven Bits javascript in here // clear inputs with starter values new function($) { $.fn.prefilledInput = function() { var focus = function () { $(this).removeClass('prefilled'); if (this.value == this.prefilledValue) { this.value = ''; } }; var blur = function () { if (this.value == '') { $(this).addClass('prefilled').val(this.prefilledValue); } else if (this.value != this.prefilledValue) { $(this).removeClass('prefilled'); } }; var extractPrefilledValue = function () { if (this.title) { this.prefilledValue = this.title; this.title = ''; } else if (this.id) { this.prefilledValue = $('label[for=' + this.id + ']').hide().text(); } if (this.prefilledValue) { this.prefilledValue = this.prefilledValue.replace(/\*$/, ''); } }; var initialize = function (index) { if (!this.prefilledValue) { this.extractPrefilledValue = extractPrefilledValue; this.extractPrefilledValue(); $(this).trigger('blur'); } }; return this.filter(":input"). focus(focus). blur(blur). each(initialize); }; var clearPrefilledInputs = function () { var form = this.form || this; $(form).find("input.prefilled, textarea.prefilled").val(""); }; var prefilledSetup = function () { $('input.prefilled, textarea.prefilled').prefilledInput(); $('form').submit(clearPrefilledInputs); $('input:submit, button:submit').click(clearPrefilledInputs); }; $(document).ready(prefilledSetup); $(document).ajaxComplete(prefilledSetup); }(jQuery);
Version data entries
5 entries across 5 versions & 1 rubygems