[livejournal] r18940: LJSUP-7240: control strip bubbles
Committer: szhirkov
LJSUP-7240: control strip bubblesU trunk/htdocs/js/controlstrip.js U trunk/htdocs/js/jquery_fn.js
Modified: trunk/htdocs/js/controlstrip.js
===================================================================
--- trunk/htdocs/js/controlstrip.js 2011-04-21 08:28:58 UTC (rev 18939)
+++ trunk/htdocs/js/controlstrip.js 2011-04-21 08:30:27 UTC (rev 18940)
@@ -1,108 +1,8 @@
-jQuery(function($){
- !document.getElementById('lj_controlstrip') &&
- !document.getElementById('lj_controlstrip_new') &&
- $.get(LiveJournal.getAjaxUrl('controlstrip'),
- { user: Site.currentJournal },
- function(data)
- {
+jQuery(function ($) {
+ if (!document.getElementById('lj_controlstrip') && !document.getElementById('lj_controlstrip_new')) {
+ $.get(LiveJournal.getAjaxUrl('controlstrip'), { user: Site.currentJournal }, function (data) {
$(data).appendTo(document.body).ljAddContextualPopup();
}
- );
-});
-
-(function( $, top ) {
-
-var ControlStrip = top.ControlStrip = {};
-
-var CONFIG = {
- rootSelector: ".w-cs",
- overlaysSelectors: [".w-cs-share", ".w-cs-filter", ".w-cs-i-calendar", ".w-cs-i-like"],
- showOverlayClass: "w-cs-hover",
- calendarSelector: ".w-cs-i-calendar"
-}
-
-var options, elements;
-
-ControlStrip.init = function( o ) {
- options = $.extend( {}, CONFIG, o );
-
- elements = {
- root: $( options.rootSelector ),
- calendar: $( options.calendarSelector ),
- overlays: $( options.overlaysSelectors.join(',') )
+ );
}
-
- elements.root.find('input')
- .filter('[type=\'text\']').labeledPlaceholder().end()
- .filter('[type=\'password\']').labeledPlaceholder().end();
-
- ControlStrip.initOverlays( elements.overlays );
- if( elements.calendar.size() > 0 ) {
- var d = new Date().setFullYear( 2010, 7, 15 );
- ControlStrip.Calendar.call( elements.calendar );
- }
-}
-
-ControlStrip.initOverlays = function( nodes ) {
- nodes.removeClass( options.showOverlayClass );
-
- nodes.each( function() {
- var $this = $( this ),
- outTimer = null;
-
- $this.mouseover( function() {
- nodes.removeClass( options.showOverlayClass );
- $this.addClass( options.showOverlayClass );
- clearTimeout( outTimer );
- } )
- .mouseout( function() {
- outTimer = setTimeout( function() {
- $this.removeClass( options.showOverlayClass );
- }, 600 );
- } );
-
- $this.mousedown( function( ev ) {
- ev.stopPropagation();
- } );
-
- $this.children( 'a' ).click( function( ev ) {
- ev.stopPropagation();
- ev.preventDefault();
- } );
-
- } );
-
- jQuery( document ).mousedown(function( ev ) {
- nodes.removeClass( options.showOverlayClass );
- ev.stopPropagation();
- } );
-};
-
-ControlStrip.Calendar = function( o ) {
- o = o || {};
-
- if( ControlStrip.Calendar.MonthNames ) {
- o.monthNames = ControlStrip.Calendar.MonthNames;
- }
-
- if( ControlStrip.Calendar.StartAtSunday ) {
- o.startAtSunday = ControlStrip.Calendar.StartAtSunday;
- }
-
- /*
- var onFetch = function( onload ) {
- jQuery.getJSON( LiveJournal.getAjaxUrl('get_posting_days'),
- { journal: Site.currentJournal }, onload );
- }
- */
- this.calendar( {
- //onFetch: onFetch,
- dayRef: Site.remoteJournalBase + "/friends/?date=%Y-%M-%D",
- allRefs: true,
- activeUntil: new Date(),
- startMonth: new Date( 1999, 3, 1 ),
- endMonth: new Date()
- } );
-};
-
-}( jQuery, window ));
+});
Modified: trunk/htdocs/js/jquery_fn.js
===================================================================
--- trunk/htdocs/js/jquery_fn.js 2011-04-21 08:28:58 UTC (rev 18939)
+++ trunk/htdocs/js/jquery_fn.js 2011-04-21 08:30:27 UTC (rev 18940)
@@ -224,72 +224,3 @@
return this;
}
-
-/** jQuery overlay plugin
- * After creation overlay visibility can be toggled with
- * $( '#selector' ).overlay( 'show' ) and $( '#selector' ).overlay( 'hide' )
-*/
-jQuery.fn.overlay = function( opts ) {
- var options = {
- hideOnInit: true,
- hideOnClick: true
- };
-
- function Overlay( layer, options) {
- this.layer = jQuery( layer );
- this.options = options;
- this.updateState( this.options.hideOnInit );
- this.bindEvents();
- }
-
- Overlay.prototype.bindEvents = function() {
- var overlay = this;
-
- if( this.options.hideOnClick ) {
- overlay.layer.mousedown( function( ev ) {
- ev.stopPropagation();
- } );
-
- jQuery( document ).mousedown(function( ev ) {
- overlay.updateState( true );
- ev.stopPropagation();
- } );
- }
- };
-
- Overlay.prototype.updateState = function( hide ) {
- this.layerVisible = !hide;
- if( this.layerVisible ) {
- this.layer.show();
- } else {
- this.layer.hide();
- }
- }
-
- Overlay.prototype.proccessCommand = function ( cmd ) {
- switch( cmd ) {
- case 'show' :
- this.updateState( false );
- break;
- case 'hide' :
- this.updateState( true );
- break;
- }
- }
-
- var cmd;
- if( typeof opts === "string" ) {
- cmd = opts;
- }
-
- return this.each( function() {
- if( !this.overlay ) {
- var o = jQuery.extend( {}, options, opts || {} );
- this.overlay = new Overlay( this, o );
- }
-
- if( cmd.length > 0 ) {
- this.overlay.proccessCommand( opts )
- }
- });
-}
