/** * @requires $ jQuery * @requires _ UnderscoreJS */ (function (/* Object */ ns) { "use strict"; ns.Form = function (options) { qs.FormNode.apply(this, arguments); this.init(options); }; var proto = ns.Form.prototype = Object.create(qs.FormNode.prototype); proto.init = function (options) { this.PAYMENT_METHOD_CHECK = options.PAYMENT_METHOD_CHECK; this.dialog = new app.termsDialog.Dialog(options.dialog); this.dialog.node.on('agree', this.onDialogAgree.bind(this)); Qs_Form.setFormOption(this.node.prop('id'), 'onSuccessCallback', _.bind(this.onSuccessCallback, this)); this.get('checkType').on('change', _.bind(this.checkTypeOnChange, this)); this.get('checkTips').fancybox(); }; proto.onSuccessCallback = function () { if (this.get('paymentMethod').val() === this.PAYMENT_METHOD_CHECK) { this.dialog.show(); } else { this.submit(); } }; proto.onDialogAgree = function () { this.submit(); return false; }; proto.checkTypeOnChange = function () { var checkType = this.get('checkType'); var checkTypeValue = checkType.val(); this.get('checkTips').each(function () { $(this).toggleClass('hidden', $(this).data('check-type') !== checkTypeValue); }); }; proto.submit = function () { this.node.get(0).submit(); }; })(qs.defineNS('app.payment'));