can3p (can3p) wrote in changelog,
can3p
can3p
changelog

[ljcom] r12141: LJSUP-12373: Tabs do not work (iPad).

Committer: dpetrov
LJSUP-12373: Tabs do not work (iPad).
U   trunk/htdocs/js/s2.js
Modified: trunk/htdocs/js/s2.js
===================================================================
--- trunk/htdocs/js/s2.js	2012-06-20 08:05:53 UTC (rev 12140)
+++ trunk/htdocs/js/s2.js	2012-06-20 08:41:10 UTC (rev 12141)
@@ -1,33 +1,72 @@
-LiveJournal.register_hook('page_load', function() {
-	jQuery( '.sidebar-cal' ).inlineCalendar( {
-		selectors: {
-			month: '.sbar-cal-nav-month',
-			year:  '.sbar-cal-nav-year',
+;(function (window, $) {
+	"use strict";
 
-			prevMonth: '.sbar-cal-nav-month .sbar-cal-nav-prev',
-			nextMonth: '.sbar-cal-nav-month .sbar-cal-nav-next',
-			prevYear:  '.sbar-cal-nav-year .sbar-cal-nav-prev',
-			nextYear:  '.sbar-cal-nav-year .sbar-cal-nav-next',
+	LiveJournal.register_hook('page_load', function() {
+		$('.sidebar-cal' ).inlineCalendar( {
+			selectors: {
+				month: '.sbar-cal-nav-month',
+				year:  '.sbar-cal-nav-year',
 
-			monthLabel: '.sbar-cal-nav-month .sbar-cal-month',
-			yearLabel: '.sbar-cal-nav-year .sbar-cal-year'
-		},
-		classNames: {
-			current  : 'today',
-			nextDisabled : 'disabled',
-			prevDisabled : 'disabled'
-		},
-		dayRef: Site.currentJournalBase + '/%Y/%M/%D',
-		monthRef: Site.currentJournalBase + '/%Y/%M',
-		yearRef: Site.currentJournalBase + '/%Y',
-		endMonth: new Date,
-		startAtSunday: true
-	}).bind('daySelected', function (event) {
-		event.preventDefault();
-	} ).calendarEvents( { calendarType: "inlineCalendar" } );
-});
+				prevMonth: '.sbar-cal-nav-month .sbar-cal-nav-prev',
+				nextMonth: '.sbar-cal-nav-month .sbar-cal-nav-next',
+				prevYear:  '.sbar-cal-nav-year .sbar-cal-nav-prev',
+				nextYear:  '.sbar-cal-nav-year .sbar-cal-nav-next',
 
-(function() {
+				monthLabel: '.sbar-cal-nav-month .sbar-cal-month',
+				yearLabel: '.sbar-cal-nav-year .sbar-cal-year'
+			},
+			classNames: {
+				current  : 'today',
+				nextDisabled : 'disabled',
+				prevDisabled : 'disabled'
+			},
+			dayRef: Site.currentJournalBase + '/%Y/%M/%D',
+			monthRef: Site.currentJournalBase + '/%Y/%M',
+			yearRef: Site.currentJournalBase + '/%Y',
+			endMonth: new Date(),
+			startAtSunday: true
+		}).bind('daySelected', function (event) {
+			event.preventDefault();
+		}).calendarEvents( { calendarType: "inlineCalendar" });
+	});
+
+	LiveJournal.register_hook('page_load', function () {
+		var className = 'hover',
+			tabElements = $('.sidebar dl'),
+			tabHeaders = $('.sidebar dt'),
+			preventClose = false;
+
+		if ($('.sidebar-friendstimes').length === 0) { return; }
+
+		if (LJ.Support.touch) {
+			tabHeaders.on('touchstart', function () {
+				$(this).parent()
+					.toggleClass(className)
+					.siblings()
+					.removeClass(className);
+			});
+			tabElements.on('touchstart', function () {
+				preventClose = true;
+			});
+			$(document).on('touchstart', function () {
+				if (preventClose) {
+					preventClose = false;
+				} else {
+					tabElements.removeClass(className);
+				}
+			});
+		} else {
+			tabElements.on({
+				'mouseenter': function () {
+					$(this).addClass('hover');
+				},
+				'mouseleave': function () {
+					$(this).removeClass('hover');
+				}
+			});
+		}
+	});
+
 	var urls_cache  = {};
 
 	function removeRepost(url) {
@@ -41,13 +80,13 @@
 	}
 
 	function initPopup(node, onconfirm) {
-		jQuery(node).confirmbubble({
+		$(node).confirmbubble({
 			confirmText: LJ.ml('repost.confirm.delete'),
-			confirm: onconfirm || jQuery.noop
+			confirm: onconfirm || $.noop
 		});
 	}
 
 	LiveJournal.register_hook('repost.requestRemove', function(node, url) {
 		initPopup(node, removeRepost.bind(null, url));
 	});
-}());
+}(window, jQuery));

Tags: can3p, dpetrov, js, ljcom
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