Sha256: 45eeafedeede328f3eab74773e59ba9808ad71ffba2e090a1e250e9fc9a54492
Contents?: true
Size: 1.53 KB
Versions: 2
Compression:
Stored size: 1.53 KB
Contents
pageflow.inputView = { ui: { labelText: 'label .name', inlineHelp: 'label .inline_help' }, onRender: function() { this.$el.addClass(this.model.modelName + '_' + this.options.propertyName); this.ui.labelText.text(this.localizedAttributeName()); this.ui.inlineHelp.text(this.inlineHelpText()); if (!this.inlineHelpText()) { this.ui.inlineHelp.hide(); } this.updateDisabled(); this.setupVisibleBinding(); }, localizedAttributeName: function() { return I18n.t('activerecord.attributes.' + this.model.i18nKey + '.' + this.options.propertyName); }, inlineHelpText: function() { var key = 'editor.inline_help.' + this.model.i18nKey + '.' + this.options.propertyName; var text = I18n.t(key, {defaultValue: ''}); if (this.options.disabled) { text = I18n.t(key + '_disabled', {defaultValue: text}); } return text; }, updateDisabled: function() { if (this.ui.input) { this.updateDisabledAttribute(this.ui.input); } }, updateDisabledAttribute: function(element) { if (this.options.disabled) { element.attr('disabled', true); } else { element.removeAttr('disabled'); } }, setupVisibleBinding: function() { var view = this; if (this.options.visibleBinding) { this.listenTo(this.model, 'change:' + this.options.visibleBinding, updateVisible); updateVisible(this.model, this.model.get(this.options.visibleBinding)); } function updateVisible(model, value) { view.$el.toggle(!!value); } } };
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pageflow-0.4.0 | app/assets/javascripts/pageflow/editor/views/input_view.js |
pageflow-0.3.0 | app/assets/javascripts/pageflow/editor/views/input_view.js |