Committer: dpetrov
LJSUP-9126: Friends times. Hiding users, filters. Add some comments.U trunk/htdocs/js/jquery/jquery.lj.basicWidget.js U trunk/htdocs/js/jquery/jquery.lj.sidePane.js
Modified: trunk/htdocs/js/jquery/jquery.lj.basicWidget.js =================================================================== --- trunk/htdocs/js/jquery/jquery.lj.basicWidget.js 2011-08-02 10:33:11 UTC (rev 10789) +++ trunk/htdocs/js/jquery/jquery.lj.basicWidget.js 2011-08-03 01:37:28 UTC (rev 10790) @@ -5,6 +5,9 @@ * * http://docs.jquery.com/UI * + * Depends: + * jquery.ui.core.js + * jquery.ui.widget.js * * @overview Base widget for all livejournal widgets. * @@ -23,6 +26,25 @@ $.widget( 'lj.basicWidget', { + options: { + /** + * Object contains strings with class names that are used within widget. + */ + classNames: {}, + /** + * Object contains strings with selectors that are used to find nodes within widget. + */ + selectors: {}, + /** + * Object contains translation strings for a widget. Widget should not contain hardcoded strings. + */ + ml: {}, + /** + * Object contains strings with templates, that are used to build content within widget. + */ + tmpl: {} + }, + /** * Bind common events for the widget */ Modified: trunk/htdocs/js/jquery/jquery.lj.sidePane.js =================================================================== --- trunk/htdocs/js/jquery/jquery.lj.sidePane.js 2011-08-02 10:33:11 UTC (rev 10789) +++ trunk/htdocs/js/jquery/jquery.lj.sidePane.js 2011-08-03 01:37:28 UTC (rev 10790) @@ -1,5 +1,23 @@ +/*! + * LiveJournal sidepane + * + * Copyright 2011, dmitry.petrov@sup.com + * + * http://docs.jquery.com/UI + * + * Depends: + * jquery.ui.core.js + * jquery.ui.widget.js + * jquery.lj.basicWidget.js + * + * @overview Widget represents the panel that is placed on the edge of the screen + * and slides out if user clicks on the pane button. Only one pane can be opened + * at time. + * + */ (function( $ ) { + //@TODO: move this to the external file. var transitionsSupported = function() { var div = document.createElement('div'); @@ -10,8 +28,6 @@ return cssTransitionsSupported; }(); - var panes = jQuery(); - $.widget( 'lj.sidePane', $.lj.basicWidget, { options: { selectors: { @@ -21,14 +37,23 @@ classNames: { open: 'w-friendstimes-opened' }, + + /** + * Options shows whether widget is visible or not. + * The field has two values: visible and hidden + */ visibility: 'visible', state: 'closed' }, + /** @private */ + _create: function() { $.lj.basicWidget.prototype._create.call( this ); this._inner = this.element.find( this.options.selectors.inner ); this._setOptions( this.options ); + + //panel will not close if user clicks in the area within panel contents this._preventClose = false; this._bindControls(); @@ -93,22 +118,35 @@ } }, + /** @public */ + + /** + * Show panel. + */ show: function() { this.element.show(); this.options.visibility = 'visible'; }, + /** + * Hide panel. + */ hide: function() { this.element.hide(); this.options.visibility = 'hidden'; }, + /** + * Open panel. + */ open: function() { var widget = this; this.show(); if( transitionsSupported ) { this.element.addClass( this.options.classNames.open ); } else { + //if transitions are not supported we show program animation. + //Css options below were taken from the css file. this.element.css( { overflow: 'visible', zoom: 1, @@ -130,9 +168,13 @@ } this.options.state = 'open'; + //all other panes should be closed if this pane is opened. this._fire( 'sidePane/close' ); }, + /** + * Close panel. + */ close: function() { var widget = this; @@ -143,6 +185,8 @@ if( transitionsSupported ) { this.element.removeClass( this.options.classNames.open ); } else { + //if transitions are not supported we show program animation. + //Css options below were taken from the css file. this._inner.animate( { left: "100%", marginLeft: "-47px"