/** * @requires $ jQuery */ qs.defineNS('app'); app.sanityCheck = app.sanityCheck || {}; app.sanityCheck.ParseFields = qs.createObject(); app.sanityCheck.ParseFields.prototype = { initialize: function () { this.legendSwitch = $('[data-role="legendSwitch"]'); this.legendSwitch.on('click', $.proxy(this.onLegendSwitchClick, this)); this.warningSwitch = $('[data-role="warningSwitch"]'); this.warningSwitch.on('click', $.proxy(this.onWarningSwitchClick, this)); return this; }, onLegendSwitchClick: function (e) { e.preventDefault(); var legend = $('[data-role="legend"]'); if (legend.is(':visible')) { this.legendSwitch.text('show legend'); legend.hide(); } else { this.legendSwitch.text('hide legend'); legend.show(); } return null; }, onWarningSwitchClick: function (e) { e.preventDefault(); var report = $('[data-role="report"]'), classes = $('tbody', report), fields = $('[data-role="field"]', report), warnings = $('[data-error="low"]', report), warningsHidden = report.data('warningsHidden'); if (true === warningsHidden) { report.data('warningsHidden', false); this.warningSwitch.text('hide warnings'); fields.show(); warnings.show(); classes.show(); } else { warnings.hide(); fields.filter(function () { return 0 == $('[data-error="high"]', this).length; }).hide(); classes.filter(function () { return 0 == $('[data-error="high"]', this).length; }).hide(); report.data('warningsHidden', true); this.warningSwitch.text('show warnings'); } return null; } };