App_PwxSlide = qs.createObject(); var appPwxSlide = null; App_PwxSlide.prototype = { options: null, form: null, initialize: function(options) { this.options = options; }, getForm: function() { if (this.form == null) { var formObj = $('form#' + this.options.formId); if ($(formObj).size()) { this.form = formObj; } else { alert('Form "' + this.options.formId + '" is not found.'); } } return this.form; }, changeLinkType: function() { var linkType = $('#linkType', this.getForm()).val(); var type = $('#type', this.getForm()).val(); this.hide(['url', 'pageId', 'linkText'], true); if ('none' != linkType) { var elements = []; if ('html' == type) { elements.push('linkText') } if (linkType == 'url') { elements.push('url'); } else if (linkType == 'cms') { elements.push('pageId'); } this.hide(elements, false); } }, hide: function(elements, value) { for (var i in elements) { if (value) { $('#' + elements[i] + '-label').hide(); $('#' + elements[i] + '-element').hide(); } else { $('#' + elements[i] + '-label').show(); $('#' + elements[i] + '-element').show(); } } } }; function initappPwxSlide(options) { appPwxSlide = new App_PwxSlide(options); var formObj = appPwxSlide.getForm(); if (formObj) { $('#linkType', formObj).bind('change', function() { appPwxSlide.changeLinkType(); }); appPwxSlide.changeLinkType(); } }