var App_AppFile = qs.create(); App_AppFile.prototype = { idForm: null, form: null, init: function (options) { new App_AppFile(options); }, initialize: function (options) { this.setOptions(options); if (this.form) { this.initFrom(); } return true; }, initFrom: function () { this.initShowOnPage(); return true; }, setOptions: function (options) { if (typeof options == 'object') { for (var field in options) { var value = options[field]; if (typeof value == 'string' && !value.length) { continue; } switch (field) { case 'idForm': this.setIdForm(value); break; default: this[field] = value; } } } return true; }, setIdForm: function (id) { this.form = $('#' + id); if ($(this.form).size()) { this.idForm = id; return true } this.form = null; alert('App_AppFile: Can not find form element'); return false; }, initShowOnPage: function () { var checkbox = $('#showOnPage'); var obj = this; if ($(checkbox).size()) { $(checkbox).click(function () { obj.processShowOnPage(this); }); this.processShowOnPage(checkbox); } return true; }, processShowOnPage: function (checkbox) { var element = $('#idPage-element'); var label = $('#idPage-label'); if ($(element).size() && $(label).size()) { if ($(checkbox).attr('checked')) { $(label).show(); $(element).show(); } else { $(label).hide(); $(element).hide(); } } return true; } }