/** * @requires $ jQuery * @requires _ UnderscoreJS * @requires qs */ (function (/* Object */ ns) { 'use strict'; /** * @alias app.tradeShow.attendee.admin.Form * @param {Object} options * @constructor */ var Form = function (options) { this.construct.apply(this, arguments); }; Form.prototype.construct = function (options) { this.options = $.extend({ nodeIds: { paymentType: undefined, amount: undefined } }, options); this.node = {}; if (this.options.nodeIds.paymentType) { this.initPaymentType(); } }; Form.prototype.initPaymentType = function () { this.node.$paymentType = $('#' + this.options.nodeIds.paymentType); this.node.$amount = $('#' + this.options.nodeIds.amount); this.node.$paymentType.on('change', _.bind(this.onPaymentTypeChange, this)); this.onPaymentTypeChange(); }; Form.prototype.onPaymentTypeChange = function () { if ('comp' === this.node.$paymentType.val()) { this.node.$amount.val('0'); this.node.$amount.prop('readOnly', true); } else { if (this.node.$amount.prop('readOnly')) { this.node.$amount.prop('readOnly', false); this.node.$amount.val(''); } } }; ns.Form = Form; })(qs.defineNS('app.tradeShow.attendee.admin'));