/** * @requires $ jQuery * @requires _ UnderscoreJS */ (function (/* Object */ ns) { "use strict"; ns.Dialog = function (options) { qs.FormNode.apply(this, arguments); this.setOptions(options); this.init(); }; var proto = ns.Dialog.prototype = Object.create(qs.FormNode.prototype); proto.setOptions = function (options) { this.hiddenInputName = options.hiddenInputName; }; proto.init = function () { this.get('agreeButton').on('click', _.bind(this.agreeOnClick, this)); }; proto.show = function () { this.node.modal('show').on('shown', _.bind(this.onShown, this)); }; proto.onShown = function () { if (this.get('dialogBody').get(0).scrollHeight > this.get('dialogBody').outerHeight()) { this.get('dialogBody').scroll(_.bind(this.onScroll, this)); } else { this.get('agreeButton').removeClass('disabled'); } }; proto.onScroll = function () { var body = this.get('dialogBody'); if (body.outerHeight() + Math.ceil(body.scrollTop()) >= body.prop('scrollHeight')) { this.get('agreeButton').removeClass('disabled'); this.get('dialogBody').unbind('scroll'); } }; proto.agreeOnClick = function () { if (this.get('agreeButton').hasClass('disabled')) { return false; } this.get('form').append(''); this.node.trigger('agree'); return false; }; })(qs.defineNS('app.termsDialog'));