Sha256: e5898d294015a969bd9b326976c392e87b6fe46427c16c3050f548f7b720b24e
Contents?: true
Size: 902 Bytes
Versions: 6
Compression:
Stored size: 902 Bytes
Contents
//= require jquery.maskMoney.min $(function() { var getUnmaskedMoneyCents, updateSiblingHiddenFieldValueOf, syncUnmaskedValueWithHiddenField, $applyMaskMoneyTo, setupMaskMoney, EVENTS_TO_SYNC = 'change keyup paste'; getUnmaskedMoneyCents = function($el) { return $el.maskMoney('unmasked')[0] * 100; }; updateSiblingHiddenFieldValueOf = function($el, getNewValue) { $el.siblings('[type="hidden"]').val( getNewValue($el) ); }; syncUnmaskedValueWithHiddenField = function() { updateSiblingHiddenFieldValueOf($(this), getUnmaskedMoneyCents); }; $applyMaskMoneyTo = function(el) { return $(el).maskMoney().trigger('mask'); }; setupMaskMoney = function() { $applyMaskMoneyTo(this) .on( EVENTS_TO_SYNC, syncUnmaskedValueWithHiddenField ); }; $('[data-maskmoney]').each(setupMaskMoney); });
Version data entries
6 entries across 6 versions & 1 rubygems