var basePath = getBaseUri(location.pathname);
var SITE_ROOT = toRoot + basePath.substring(1,basePath.indexOf("/",1));
var GOOGLE_DATA; // combined data for google service apis, used for search suggest
-
+
// Ensure that all ajax getScript() requests allow caching
$.ajaxSetup({
cache: true
toggleFullscreen(false);
}
});
-
+
// initialize the divs with custom scrollbars
$('.scroll-pane').jScrollPane( {verticalGutter:0} );
-
+
// add HRs below all H2s (except for a few other h2 variants)
$('h2').not('#qv h2').not('#tb h2').not('.sidebox h2').not('#devdoc-nav h2').not('h2.norule').css({marginBottom:0}).after('<hr/>');
});
// Set up quicknav
- var quicknav_open = false;
+ var quicknav_open = false;
$("#btn-quicknav").click(function() {
if (quicknav_open) {
$(this).removeClass('active');
expand();
}
})
-
+
var expand = function() {
$('#header-wrap').addClass('quicknav');
$('#quicknav').stop().show().animate({opacity:'1'});
}
-
+
var collapse = function() {
$('#quicknav').stop().animate({opacity:'0'}, 100, function() {
$(this).hide();
$('#header-wrap').removeClass('quicknav');
});
}
-
-
+
+
//Set up search
$("#search_autocomplete").focus(function() {
$("#search-container").addClass('active');
}
})
-
+
// prep nav expandos
var pagePath = document.location.pathname;
// account for intl docs by removing the intl/*/ path
// set up prev links
var $prevLink = [];
var $prevListItem = $selListItem.prev('li');
-
+
var crossBoundaries = ($("body.design").length > 0) || ($("body.guide").length > 0) ? true :
false; // navigate across topic boundaries only in design docs
if ($prevListItem.length) {
// jump to this section's index page (if it exists)
var $parentListItem = $selListItem.parents('li');
$prevLink = $selListItem.parents('li').find('a');
-
+
// except if cross boundaries aren't allowed, and we're at the top of a section already
// (and there's another parent)
- if (!crossBoundaries && $parentListItem.hasClass('nav-section')
+ if (!crossBoundaries && $parentListItem.hasClass('nav-section')
&& $selListItem.hasClass('nav-section')) {
$prevLink = [];
}
var startClass = false;
var training = $(".next-class-link").length; // decides whether to provide "next class" link
var isCrossingBoundary = false;
-
+
if ($selListItem.hasClass('nav-section')) {
// we're on an index page, jump to the first topic
$nextLink = $selListItem.find('ul:eq(0)').find('a:eq(0)');
// then set the landing page "start link" text to be the first doc title
$('.topic-start-link').text($nextLink.text().toUpperCase());
}
-
+
// If the selected page has a description, then it's a class or article homepage
if ($selListItem.find('a[description]').length) {
// this means we're on a class landing page
if (startClass) {
$('.start-class-link').attr('href', $nextLink.attr('href')).removeClass("hide");
- // if there's no training bar (below the start button),
+ // if there's no training bar (below the start button),
// then we need to add a bottom border to button
if (!$("#tb").length) {
$('.start-class-link').css({'border-bottom':'1px solid #DADADA'});
$('.next-page-link').attr('href','')
.removeClass("hide").addClass("disabled")
.click(function() { return false; });
-
+
$('.next-class-link').attr('href',$nextLink.attr('href'))
.removeClass("hide").append($nextLink.html());
$('.next-class-link').find('.new').empty();
} else {
$('.prev-page-link').attr('href', $prevLink.attr('href')).removeClass("hide");
}
- }
+ }
// If this is a training 'article', there should be no prev/next nav
// ... if the grandparent is the "nav" ... and it has no child list items...
$('.next-page-link,.prev-page-link').attr('href','').addClass("disabled")
.click(function() { return false; });
}
-
+
}
-
-
-
+
+
+
// Set up the course landing pages for Training with class names and descriptions
if ($('body.trainingcourse').length) {
var $classLinks = $selListItem.find('ul li a').not('#nav .nav-section .nav-section ul a');
var $classDescriptions = $classLinks.attr('description');
-
+
var $olClasses = $('<ol class="class-list"></ol>');
var $liClass;
var $imgIcon;
$liClass = $('<li></li>');
$h2Title = $('<a class="title" href="'+$(this).attr('href')+'"><h2>' + $(this).html()+'</h2><span></span></a>');
$pSummary = $('<p class="description">' + $(this).attr('description') + '</p>');
-
+
$olLessons = $('<ol class="lesson-list"></ol>');
-
+
$lessons = $(this).closest('li').find('ul li a');
-
+
if ($lessons.length) {
- $imgIcon = $('<img src="'+toRoot+'assets/images/resource-tutorial.png" alt=""/>');
+ $imgIcon = $('<img src="'+toRoot+'assets/images/resource-tutorial.png" '
+ + ' width="64" height="64" alt=""/>');
$lessons.each(function(index) {
$olLessons.append('<li><a href="'+$(this).attr('href')+'">' + $(this).html()+'</a></li>');
});
} else {
- $imgIcon = $('<img src="'+toRoot+'assets/images/resource-article.png" alt=""/>');
+ $imgIcon = $('<img src="'+toRoot+'assets/images/resource-article.png" '
+ + ' width="64" height="64" alt=""/>');
$pSummary.addClass('article');
}
// first hide all other siblings
var $others = $('li.nav-section.expanded', $(this).closest('ul'));
$others.removeClass('expanded').children('ul').slideUp(250);
-
+
// now expand me
section.closest('li').addClass('expanded');
section.children('ul').slideDown(250, function() {
});
}
});
-
+
$(".scroll-pane").scroll(function(event) {
event.preventDefault();
return false;
// from a scrollable div and so there's no need to make adjustments to our layout
return;
}
- var scrollTop = $(window).scrollTop();
+ var scrollTop = $(window).scrollTop();
var headerHeight = $('#header').outerHeight();
var subheaderHeight = $('#nav-x').outerHeight();
- var searchResultHeight = $('#searchResults').is(":visible") ?
+ var searchResultHeight = $('#searchResults').is(":visible") ?
$('#searchResults').outerHeight() : 0;
var totalHeaderHeight = headerHeight + subheaderHeight + searchResultHeight;
// we set the navbar fixed when the scroll position is beyond the height of the site header...
if ($("#doc-col").height() < $("#side-nav").height()) {
navBarShouldBeFixed = false;
}
-
+
var scrollLeft = $(window).scrollLeft();
// When the sidenav is fixed and user scrolls horizontally, reposition the sidenav to match
if (navBarIsFixed && (scrollLeft != prevScrollLeft)) {
updateSideNavPosition();
prevScrollLeft = scrollLeft;
}
-
- // Don't continue if the header is sufficently far away
+
+ // Don't continue if the header is sufficently far away
// (to avoid intensive resizing that slows scrolling)
if (navBarIsFixed && navBarShouldBeFixed) {
return;
}
-
+
if (navBarIsFixed != navBarShouldBeFixed) {
if (navBarShouldBeFixed) {
// make it fixed
.prependTo('#body-content');
// add neato "back to top" button
$('#devdoc-nav a.totop').css({'display':'block','width':$("#nav").innerWidth()+'px'});
-
+
// update the sidenaav position for side scrolling
updateSideNavPosition();
} else {
$('#devdoc-nav a.totop').hide();
}
navBarIsFixed = navBarShouldBeFixed;
- }
-
+ }
+
resizeNav(250); // pass true in order to delay the scrollbar re-initialization for performance
});
-
+
var navBarLeftPos;
if ($('#devdoc-nav').length) {
setNavBarLeftPos();
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
- // Revise the sidenav widths to make room for the scrollbar
+ // Revise the sidenav widths to make room for the scrollbar
// which avoids the visible width from changing each time the bar appears
var $sidenav = $("#side-nav");
var sidenav_width = parseInt($sidenav.innerWidth());
-
+
$("#devdoc-nav #nav").css("width", sidenav_width - 4 + "px"); // 4px is scrollbar width
$(".scroll-pane").removeAttr("tabindex"); // get rid of tabindex added by jscroller
-
+
if ($(".scroll-pane").length > 1) {
// Check if there's a user preference for the panel heights
var cookieHeight = readCookie("reference_height");
restoreHeight(cookieHeight);
}
}
-
+
resizeNav();
/* init the language selector based on user cookie for lang */
// Find this page's <li> in sidenav and set selected
$selListItem = $selNavLink.closest('li');
$selListItem.addClass('selected');
-
+
// Traverse up the tree and expand all parent nav-sections
$selNavLink.parents('li.nav-section').each(function() {
$(this).addClass('expanded');
$('#devdoc-nav').css({left: -newLeft});
$('#devdoc-nav .totop').css({left: -(newLeft - parseInt($('#side-nav').css('margin-left')))});
}
-
+
var $nav = $("#devdoc-nav");
var $window = $(window);
var navHeight;
-
+
// Get the height of entire window and the total header height.
// Then figure out based on scroll position whether the header is visible
var windowHeight = $window.height();
var headerHeight = $('#header').outerHeight();
var subheaderHeight = $('#nav-x').outerHeight();
var headerVisible = (scrollTop < (headerHeight + subheaderHeight));
-
- // get the height of space between nav and top of window.
+
+ // get the height of space between nav and top of window.
// Could be either margin or top position, depending on whether the nav is fixed.
- var topMargin = (parseInt($nav.css('margin-top')) || parseInt($nav.css('top'))) + 1;
+ var topMargin = (parseInt($nav.css('margin-top')) || parseInt($nav.css('top'))) + 1;
// add 1 for the #side-nav bottom margin
-
+
// Depending on whether the header is visible, set the side nav's height.
if (headerVisible) {
// The sidenav height grows as the header goes off screen
// Once header is off screen, the nav height is almost full window height
navHeight = windowHeight - topMargin;
}
-
-
-
+
+
+
$scrollPanes = $(".scroll-pane");
if ($scrollPanes.length > 1) {
// subtract the height of the api level widget and nav swapper from the available nav height
navHeight -= ($('#api-nav-header').outerHeight(true) + $('#nav-swap').outerHeight(true));
-
+
$("#swapper").css({height:navHeight + "px"});
if ($("#nav-tree").is(":visible")) {
$("#nav-tree").css({height:navHeight});
}
-
- var classesHeight = navHeight - parseInt($("#resize-packages-nav").css("height")) - 10 + "px";
+
+ var classesHeight = navHeight - parseInt($("#resize-packages-nav").css("height")) - 10 + "px";
//subtract 10px to account for drag bar
-
- // if the window becomes small enough to make the class panel height 0,
+
+ // if the window becomes small enough to make the class panel height 0,
// then the package panel should begin to shrink
if (parseInt(classesHeight) <= 0) {
$("#resize-packages-nav").css({height:navHeight - 10}); //subtract 10px for drag bar
$("#packages-nav").css({height:navHeight - 10});
}
-
+
$("#classes-nav").css({'height':classesHeight, 'margin-top':'10px'});
$("#classes-nav .jspContainer").css({height:classesHeight});
-
-
+
+
} else {
$nav.height(navHeight);
}
-
+
if (delay) {
updateFromResize = true;
delayedReInitScrollbars(delay);
} else {
reInitScrollbars();
}
-
+
}
var updateScrollbars = false;
updateFromResize = false;
return;
}
-
+
// We're scheduled for an update and the update request came from this method's setTimeout
if (updateScrollbars && !updateFromResize) {
reInitScrollbars();
var api = $(this).data('jsp');
if (!api) { setTimeout(reInitScrollbars,300); return;}
api.reinitialise( {verticalGutter:0} );
- });
+ });
$(".scroll-pane").removeAttr("tabindex"); // get rid of tabindex added by jscroller
}
-/** Scroll the jScrollPane to make the currently selected item visible
+/** Scroll the jScrollPane to make the currently selected item visible
This is called when the page finished loading. */
function scrollIntoView(nav) {
var $nav = $("#"+nav);
date.setTime(date.getTime()+(10*365*24*60*60*1000)); // default expiration is one week
expiration = date.toGMTString();
}
- var cookieValue = cookie_namespace + section + cookie + "=" + val
+ var cookieValue = cookie_namespace + section + cookie + "=" + val
+ "; expires=" + expiration+"; path=/";
document.cookie = cookieValue;
}
$("#panel-link").toggle();
$("#nav-tree").toggle();
$("#tree-link").toggle();
-
+
resizeNav();
// Gross nasty hack to make tree view show up upon first swap by setting height manually
.css({'height':$("#nav-tree .jspContainer .jspPane").height() +'px'});
// Another nasty hack to make the scrollbar appear now that we have height
resizeNav();
-
+
if ($("#nav-tree").is(':visible')) {
scrollIntoView("nav-tree");
} else {
function changeLangPref(lang, submit) {
var date = new Date();
- expires = date.toGMTString(date.setTime(date.getTime()+(10*365*24*60*60*1000)));
+ expires = date.toGMTString(date.setTime(date.getTime()+(10*365*24*60*60*1000)));
// keep this for 50 years
//alert("expires: " + expires)
writeCookie("pref_lang", lang, null, expires);
toggleMe.slideDown();
$(".toggle-content-text", obj).toggle();
div.removeClass("closed").addClass("open");
- $(".toggle-content-img", div).attr("title", "hide").attr("src", toRoot
+ $(".toggle-content-img", div).attr("title", "hide").attr("src", toRoot
+ "assets/images/triangle-opened.png");
} else { // if it's open, close it
toggleMe.slideUp('fast', function() { // Wait until the animation is done before closing arrow
$(".toggle-content-text", obj).toggle();
div.removeClass("open").addClass("closed");
- $(".toggle-content-img", div).attr("title", "show").attr("src", toRoot
+ $(".toggle-content-img", div).attr("title", "show").attr("src", toRoot
+ "assets/images/triangle-closed.png");
});
}
-/*
+/*
* Slideshow 1.0
* Used on /index.html and /develop/index.html for carousel
*
(function($) {
$.fn.dacSlideshow = function(o) {
-
+
//Options - see above
o = $.extend({
btnPrev: null,
pagination: true
}, o || {});
-
- //Set up a carousel for each
+
+ //Set up a carousel for each
return this.each(function() {
var running = false;
var div = $(this);
var ul = $("ul", div);
var tLi = $("li", ul);
- var tl = tLi.size();
+ var tl = tLi.size();
var timer = null;
var li = $("li", ul);
ul.css(sizeCss, ulSize+"px").css(animCss, -(curr*liSize));
div.css(sizeCss, divSize+"px");
-
+
//Pagination
if (o.pagination) {
var pagination = $("<div class='pagination'></div>");
div.append(pagination);
}
}
-
+
//Previous button
if(o.btnPrev)
$(o.btnPrev).click(function(e) {
pauseRotateTimer();
}
});
-
+
//Auto rotation
if(o.auto) startRotateTimer();
-
+
function startRotateTimer() {
clearInterval(timer);
timer = setInterval(function() {
if (curr == tl-1) {
go(0);
} else {
- go(curr+o.scroll);
- }
+ go(curr+o.scroll);
+ }
}, o.autoTime);
$(o.btnPause).removeClass('paused');
}
[]
).addClass("disabled");
-
+
var nav_items = $('li', pagination);
nav_items.removeClass('active');
nav_items.eq(to).addClass('active');
-
+
}
if(o.auto) startRotateTimer();
})(jQuery);
-/*
+/*
* dacSlideshow 1.0
* Used on develop/index.html for side-sliding tabs
*
*/
(function($) {
$.fn.dacTabbedList = function(o) {
-
+
//Options - see above
o = $.extend({
speed : 250,
nav_id: null,
frame_id: null
}, o || {});
-
- //Set up a carousel for each
+
+ //Set up a carousel for each
return this.each(function() {
var curr = 0;
var animCss = "margin-left";
var sizeCss = "width";
var div = $(this);
-
+
var nav = $(o.nav_id, div);
var nav_li = $("li", nav);
- var nav_size = nav_li.size();
+ var nav_size = nav_li.size();
var frame = div.find(o.frame_id);
var content_width = $(frame).find('ul').width();
//Buttons
$(nav_li).click(function(e) {
go($(nav_li).index($(this)));
})
-
+
//Go to an item
function go(to) {
if(!running) {
}
);
-
+
nav_li.removeClass('active');
nav_li.eq(to).addClass('active');
-
+
}
return false;
* otherwise invokes search suggestions on key-up event.
* @param e The JS event
* @param kd True if the event is key-down
- * @param toroot A string for the site's root path
+ * @param toroot A string for the site's root path
* @returns True if the event should bubble up
*/
function search_changed(e, kd, toroot)
if ($($("li", $selectedUl)[gSelectedIndex]).hasClass("header")) {
gSelectedIndex++;
}
- // set item selected
+ // set item selected
$('li:nth-child('+(gSelectedIndex+1)+')', $selectedUl).addClass('jd-selected');
return false;
}
if ($($("li", $selectedUl)[gSelectedIndex]).hasClass("header")) {
gSelectedIndex++;
}
- // set item selected
+ // set item selected
$('li:nth-child('+(gSelectedIndex+1)+')', $selectedUl).addClass('jd-selected');
return false;
}
function search_focus_changed(obj, focused)
{
- if (!focused) {
+ if (!focused) {
if(obj.value == ""){
$(".search .close").addClass("hide");
}
$("#searchResults").slideUp();
$(".search .close").addClass("hide");
location.hash = '';
-
+
$("#search_autocomplete").val("").blur();
-
+
// reset the ajax search callback to nothing, so results don't appear unless ENTER
searchControl.setSearchStartingCallback(this, function(control, searcher, query) {});
setTimeout(function() {
// remove any residual page numbers
$('#searchResults .gsc-tabsArea .gsc-cursor-box.gs-bidi-start-align').remove();
- // move the page numbers to the left position; make a clone,
+ // move the page numbers to the left position; make a clone,
// because the element is drawn to the DOM only once
- // and because we're going to remove it (previous line),
- // we need it to be available to move again as the user navigates
+ // and because we're going to remove it (previous line),
+ // we need it to be available to move again as the user navigates
$('#searchResults .gsc-webResult .gsc-cursor-box.gs-bidi-start-align:visible')
.clone().appendTo('#searchResults .gsc-tabsArea');
}, 200);
var maxLevel = 1;
/******* SIDENAV DIMENSIONS ************/
-
+
function initSidenavHeightResize() {
// Change the drag bar size to nicely fit the scrollbar positions
var $dragBar = $(".ui-resizable-s");
$dragBar.css({'width': $dragBar.parent().width() - 5 + "px"});
-
- $( "#resize-packages-nav" ).resizable({
+
+ $( "#resize-packages-nav" ).resizable({
containment: "#nav-panels",
handles: "s",
alsoResize: "#packages-nav",
resize: function(event, ui) { resizeNav(); }, /* resize the nav while dragging */
stop: function(event, ui) { saveNavPanels(); } /* once stopped, save the sizes to cookie */
});
-
+
}
-
+
function updateSidenavFixedWidth() {
if (!navBarIsFixed) return;
$('#devdoc-nav').css({
'margin' : $('#side-nav').css('margin')
});
$('#devdoc-nav a.totop').css({'display':'block','width':$("#nav").innerWidth()+'px'});
-
+
initSidenavHeightResize();
}
'margin' : $('#side-nav').css('margin')
});
$('#devdoc-nav .totop').css({'left': 'inherit'});
-
+
initSidenavHeightResize();
}
if (apiLevelNum > selectedLevelNum) {
obj.addClass("absent").attr("title","Requires API Level \""
+ apiLevel + "\" or higher");
- }
+ }
else obj.removeClass("absent").removeAttr("title");
});
}
node.expanded = false;
}
}
-
+
node.children_ul = null;
node.get_children_ul = function() {
get_node(me, node);
if ($(node.label_div).hasClass("absent")) {
$(node.get_children_ul()).addClass("absent");
- }
+ }
$(node.get_children_ul()).slideDown("fast");
}
node.plus_img.src = me.toroot + "assets/images/triangle-opened-small.png";
init_navtree("tree-list", toroot, NAVTREE_DATA);
}
});
-
+
// perform api level toggling because because the whole tree is new to the DOM
var selectedLevel = $("#apiLevelSelector option:selected").val();
toggleVisisbleApis(selectedLevel, "#side-nav");
node.depth = mom.depth + 1;
node.get_children_ul = function() {
if (!node.children_ul) {
- node.children_ul = document.createElement("ul");
- node.children_ul.className = "tree-list-children";
+ node.children_ul = document.createElement("ul");
+ node.children_ul.className = "tree-list-children";
node.li.appendChild(node.children_ul);
}
return node.children_ul;
node.li = document.createElement("li");
mom.get_children_ul().appendChild(node.li);
-
-
+
+
if(link) {
child = document.createElement("a");
if (children_data != null) {
node.li.className="nav-section";
node.label_div = document.createElement("div");
- node.label_div.className = "nav-section-header-ref";
+ node.label_div.className = "nav-section-header-ref";
node.li.appendChild(node.label_div);
get_google_node(me, node);
node.label_div.appendChild(child);