Permalink
Browse files

Efficiency and quote updates

  • Loading branch information...
1 parent 99b834d commit f685e02651d483d9d74cb17b6734545742fd8086 @darkwing darkwing committed Mar 21, 2013
Showing with 34 additions and 39 deletions.
  1. +34 −39 media/js/mdn/demos.js
View
@@ -2,50 +2,50 @@
$(document).ready(function () {
// Handle commenting
- $(".comment_reply").each(function () {
+ $('.comment_reply').each(function () {
var $el = $(this),
- $form = $el.find("form");
+ $form = $el.find('form');
// Wire up reply form reveal link in threaded comments.
- $el.find(".show_reply").click(function () {
+ $el.find('.show_reply').click(function () {
$form.slideDown();
return false;
});
// Quick and dirty validation for non-empty comment form.
$form.submit(function () {
- return $(this).find("textarea").val().length;
+ return $(this).find('textarea').val().length;
});
});
// Ensure gallery works as needed
- var $gallery = $(".gallery");
- $gallery.addClass("js");
+ var $gallery = $('.gallery');
+ $gallery.addClass('js');
- $gallery.find(".demo").hoverIntent({
+ $gallery.find('.demo').hoverIntent({
interval: 250,
over: function() {
var $demo = $(this),
content = $demo.html(),
offs = $demo.offset(),
- $contentContainer = $("#content"),
+ $contentContainer = $('#content'),
fadeDuration = 200,
$demoHover;
// Prevent incorrect tooltip content (force removal)
- $contentContainer.find("div.demohover").remove();
+ $contentContainer.find('div.demohover').remove();
$contentContainer.prepend('<div class="demo demohover"><div class="in">'+content+'<\/div><\/div>');
- $demoHover = $contentContainer.find("div.demohover");
+ $demoHover = $contentContainer.find('div.demohover');
- if ($demo.parents("#featured-demos").length) {
- $demoHover.addClass("featured");
+ if ($demo.parents('#featured-demos').length) {
+ $demoHover.addClass('featured');
};
$demoHover
- .addClass( $(this).attr("class") )
+ .addClass( $(this).attr('class') )
.css({ left: offs.left, top: offs.top })
.fadeIn(fadeDuration)
.mouseleave(function() {
@@ -58,50 +58,45 @@ $(document).ready(function () {
});
/* Learn More popup */
- var $learnPop = $("#learn-pop"),
- $tagsList = $("#tags-list"),
- $tagsListLearnPop = $("#tags-list, #learn-pop");
+ var $learnPop = $('#learn-pop'),
+ $tagsList = $('#tags-list'),
+ $tagsListLearnPop = $('#tags-list, #learn-pop'),
+ slideSpeed = 150;
- $("#demos-head .learnmore .button").click(function(){
- $learnPop.slideToggle(150).removeAttr("aria-hidden");
+ $('#demos-head .learnmore .button').click(function(){
+ $learnPop.slideToggle(slideSpeed).removeAttr('aria-hidden');
$(this).blur();
- if ($tagsList.is(":visible")) {
- $tagsList.hide().attr("aria-hidden", "true");
+ if ($tagsList.is(':visible')) {
+ $tagsList.hide().attr('aria-hidden', 'true');
}
return false;
});
/* Browse by Tech menu */
- $("#demos-head .tags .button, #demo-tags .button").click(function() {
- $tagsList.slideToggle(150).removeAttr("aria-hidden");
+ $('#demos-head .tags .button, #demo-tags .button').click(function() {
+ $tagsList.slideToggle(slideSpeed).removeAttr('aria-hidden');
$(this).blur();
- if ($learnPop.is(":visible")) {
- $learnPop.hide().attr("aria-hidden", "true");
+ if ($learnPop.is(':visible')) {
+ $learnPop.hide().attr('aria-hidden', 'true');
}
return false;
});
$tagsListLearnPop.hover(
function() {
- $(this).show().removeAttr("aria-hidden");
+ $(this).show().removeAttr('aria-hidden');
},
function() {
- $(this).slideUp('fast').attr("aria-hidden", "true");
+ $(this).slideUp('fast').attr('aria-hidden', 'true');
}
);
- $(document).bind('click', function(e) {
- var $clicked = $(e.target);
- if (! $clicked.parents().hasClass("menu"))
- $tagsListLearnPop.hide().attr("aria-hidden", "true");
- });
-
- $("a, input, textarea, button").bind('focus', function(e) {
- var $focused = $(e.target);
- if (! $focused.parents().hasClass("menu"))
- $tagsListLearnPop.hide().attr("aria-hidden", "true");
- });
-
-
+ $(document).bind('click', hider);
+ $('a, input, textarea, button').bind('focus', hider);
+ function hider(e) {
+ var $element = $(e.target);
+ if (! $element.parents().hasClass('menu'))
+ $tagsListLearnPop.hide().attr('aria-hidden', 'true');
+ }
});

0 comments on commit f685e02

Please sign in to comment.