Alexander Nazarov (nfokz) wrote in changelog,
Alexander Nazarov
nfokz
changelog

[ljcom] r12448: LJSUP-13255: Code clean up

Committer: anazarov
LJSUP-13255: Code clean up
U   trunk/htdocs/js/jquery/jquery.lj.basicWidget.js
Modified: trunk/htdocs/js/jquery/jquery.lj.basicWidget.js
===================================================================
--- trunk/htdocs/js/jquery/jquery.lj.basicWidget.js	2012-08-09 14:23:52 UTC (rev 12447)
+++ trunk/htdocs/js/jquery/jquery.lj.basicWidget.js	2012-08-10 07:26:01 UTC (rev 12448)
@@ -7,24 +7,25 @@
  * @name $.lj.basicWidget
  * @requires $.ui.core, $.ui.widget
  * @class Base widget for all livejournal widgets.<br />
- *	Basic widget adds pub/sub system to the widget hierarchy. By convention widgets add prefix equal
- *	to the widget name of the most parent element who fires it. E.g. if someWidget and subSomeWidget
- *	that extends someWidget do fire open event, it should be prefixed with someWidget - someWidget/open.
+ * Basic widget adds pub/sub system to the widget hierarchy. By convention widgets add prefix equal
+ * to the widget name of the most parent element who fires it. E.g. if someWidget and subSomeWidget
+ * that extends someWidget do fire open event, it should be prefixed with someWidget - someWidget/open.
  *
  */
-( function( $ ) {
+(function($) {
+	'use strict';
 
 	var __callbacks = {},
 
 		//these events we set once and for all widget instances
 		globalEvents = {
 			documentClick: false
-		}
+		};
 
 	/** @lends $.lj.basicWidget.prototype */
 	$.widget( 'lj.basicWidget', {
 
-		/** 
+		/**
 		 * Default options for widgets.
 		 * @type Object
 		 * @private
@@ -84,7 +85,6 @@
 				case 'templates':
 					this.options[name] = $.extend(this.options[name], val);
 					return;
-					break;
 			}
 
 			$.Widget.prototype._setOption.apply(this, arguments);
@@ -117,7 +117,7 @@
 		_one: function( type, callback ) {
 			this._on( type, callback );
 			__callbacks[ type ][ __callbacks[ type ].length - 1 ].once = true;
-		}, 
+		},
 
 		/**
 		 * Remove subscription on the event.
@@ -161,7 +161,7 @@
 					cbs[ i ].fn.apply( null, args );
 				}
 
-				//we delete supressed event flag only after firing event because 
+				//we delete supressed event flag only after firing event because
 				//widget can subscribe more than one callback
 				while(cbs[ --i ]) {
 					if( type in cbs[ i ].owner.__suppressedEvents ) {
@@ -187,12 +187,14 @@
 		 *     also caled.
 		 */
 		_destroy: function() {
-			var cbs;
-			for( var type in __callbacks ) {
-				cbs = __callbacks[ type ];
-				for( var i = 0; i < cbs.length; ++i ) {
-					if( cbs[i].owner === this ) {
-						cbs.splice( i--, 1 )
+			var cbs, type, i;
+			for (type in __callbacks) {
+				if (__callbacks.hasOwnProperty(type)) {
+					cbs = __callbacks[type];
+					for (i = 0; i < cbs.length; ++i) {
+						if (cbs[i].owner === this) {
+							cbs.splice(i--, 1);
+						}
 					}
 				}
 			}
@@ -210,7 +212,9 @@
 
 			ctx = ctx || this.element;
 
-			if (!this[method]) { this[method] = ctx.find(this.options.selectors[name]); };
+			if (!this[method]) {
+				this[method] = ctx.find(this.options.selectors[name]);
+			}
 
 			return this[method];
 		},
@@ -252,9 +256,9 @@
 		 * @param {Object=} options Options to pass to the mixin.
 		 */
 		_use: function(name, options) {
-			var module;
+			var module = LJ.UI.mixin(name);
 
-			if (module = LJ.UI.mixin(name)) {
+			if (module) {
 				if (this.__modules.hasOwnProperty(name)) {
 					LJ.console.log('Warn: Module ', name, ' has already been registered for ', this.widgetName);
 					return;
@@ -296,4 +300,4 @@
 		 */
 		locked: function() { return this._locked; }
 	} );
-} )( jQuery );
+}(jQuery));

Tags: anazarov, js, ljcom, nfokz
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments