[livejournal] r22804: LJSUP-13402: Implement settings page for...
Committer: aasriyan
LJSUP-13402: Implement settings page for turning on/off journal promo serviceU trunk/htdocs/js/settings.js
Modified: trunk/htdocs/js/settings.js
===================================================================
--- trunk/htdocs/js/settings.js 2012-09-04 10:34:54 UTC (rev 22803)
+++ trunk/htdocs/js/settings.js 2012-09-04 13:08:54 UTC (rev 22804)
@@ -166,3 +166,67 @@
LiveJournal.register_hook('page_load', function () {
LiveJournal.run_hook('init_settings', jQuery);
});
+
+
+
+/**
+ * @requires $.ui.core, $.ui.widget, $.lj.basicWidget
+ * @class Toggle setting controls on checkbox change in my ads tab
+ * @fileoverview journalpromo
+ * @extends $.lj.basicWidget
+ * @author armen.asriyan@sup.com (Armen Asriyan)
+ */
+
+(function ($, window) {
+ 'use strict';
+
+ /** @lends $.lj.journalpromo.prototype */
+ $.widget('lj.journalpromo', $.lj.basicWidget, {
+ options: {
+ classNames: {
+ settingsHidden: 'journalpromo-options-on'
+ },
+
+ selectors: {
+ checkbox: '#hidden-journalpromo-enable-input',
+ panel: '#hidden-journalpromo'
+ }
+ },
+
+ _create: function () {
+ $.lj.basicWidget.prototype._create.apply(this);
+
+ this._el('checkbox');
+ this._el('panel');
+
+ if ( this._checkbox.is(':checked') ) {
+ this.show();
+ }
+
+ this._bindControls();
+ },
+
+ _bindControls: function () {
+ $.lj.basicWidget.prototype._bindControls.apply(this);
+
+ var that = this;
+
+ this._checkbox.on('change', function() {
+
+ that[ $(this).is(':checked') ? 'show' : 'hide' ]();
+ });
+ },
+ /**
+ * Show settings panel
+ */
+ show: function() {
+ this._panel.addClass( this._cl('settingsHidden') );
+ },
+ /**
+ * Hide settings panel
+ */
+ hide: function() {
+ this._panel.removeClass( this._cl('settingsHidden') );
+ }
+ });
+}(jQuery, window));
