Final for now

This commit is contained in:
C9 2012-09-17 00:48:19 -04:00
commit 801a5b63df
53 changed files with 2047 additions and 621 deletions

View file

@ -1,12 +1,13 @@
var editor;
var embedded_editor;
$(function() {
this.isApi = location.href.indexOf("/api") >= 0;
if (!this.isApi) {
hljs.initHighlighting();
editor = ace.edit("ace_editor_demo");
var javascriptMode = require("ace/mode/javascript").Mode;
editor.getSession().setMode(new javascriptMode());
}
hljs.initHighlighting();
editor = ace.edit("ace_editor_demo");
embedded_editor = ace.edit("embedded_ace_code");
var javascriptMode = require("ace/mode/javascript").Mode;
var htmlMode = require("ace/mode/html").Mode;
editor.getSession().setMode(new javascriptMode());
embedded_editor.getSession().setMode(new htmlMode());
$("ul.menu-list li").click(function(e) {
if (e.target.tagName === "LI") {
@ -18,21 +19,67 @@ $(function() {
window.location = anchor.attr("href");
}
});
// used when page is access directly
function magicClickInterceptor(e) {
e.preventDefault();
var state = {};
state.api = $(this).attr("href").substring(6, $(this).attr("href").length - 5);
$.bbq.pushState(state);
$("#apiHolder").removeClass("apiIntro").removeClass("span8");
$("#apiHolder").load($(this).attr("href") + " #documentation", function(){
ux();
setupClicker();
// handles dropping in from new link
var section = $.bbq.getState("section");
if (section) {
$("li#dropdown_" + section.replace(/\./g, '\\.') + " a").triggerHandler('click');
}
setupDisqus();
});
}
$('.menu-item a').click(magicClickInterceptor);
$('a.argument').click(function (e) {
e.preventDefault();
var state = {};
state.api = $(this).attr("href").substring(6, $(this).attr("href").length - 5);
$.bbq.pushState(state);
$("#apiHolder").load($(this).attr("href") + " #documentation", function(){
$("#apiHolder").removeClass("apiIntro").removeClass("span8");
ux();
setupClicker();
// handles dropping in from new link
var section = $.bbq.getState("section");
if (section) {
$("li#dropdown_" + section.replace(/\./g, '\\.') + " a").triggerHandler('click');
}
setupDisqus();
});
});
var tabs = $("#tabnav"),
tab_a_selector = "a";
var firstLoad = true;
var _self = this;
tabs.find(tab_a_selector).click(function(e) {
if (_self.isApi || $(this).attr("href").indexOf("/api/") >= 0) {
window.location = $(this).attr("href");
}
tabs.find(tab_a_selector).click(function(e) {
e.preventDefault();
embedded_editor.resize();
editor.resize();
if ($(this).attr("href") === "/")
return;
if ($(this).attr("href") === "#api") {
if ($(this).attr("href").indexOf("#api") === 0) {
$("#top_container").addClass("collapse");
scrollIntoPosition(null, 0);
}
else if ($(this).is(":visible")) {
if (firstLoad) {
@ -48,28 +95,36 @@ $(function() {
}
}
function scrollIntoPosition(el) {
if ($("body").scrollTop() > 345) {
function scrollIntoPosition(el, overridePosition) {
if (typeof overridePosition !== "undefined") {
$("body").stop().animate({
scrollTop: overridePosition
}, 400);
}
else if ($("body").scrollTop() > 345) {
$("body").stop().animate({
scrollTop: ($(el).offset().top - 15)
}, 400);
}
}
$(this).tab("show");
var state = {};
state["nav"] = $(this).attr("href").substr(1);
state.nav = $(this).attr("href").substr(1);
$.bbq.pushState(state);
});
if (!this.isApi) {
$(window).on("hashchange", function(e) {
tabs.each(function() {
var idx = $.bbq.getState("nav") || "about";
$(this).find(tab_a_selector + "[href='#" + idx + "']").triggerHandler('click');
});
}).trigger("hashchange");
}
$(window).on("hashchange", function(e) {
tabs.each(function() {
var idx = $.bbq.getState("nav") || "about";
$(this).find(tab_a_selector + "[href='#" + idx + "']").triggerHandler('click');
// handles dropping in from new link
var api = $.bbq.getState("api");
if (api) {
$(tab_a_selector + "[href='./api/" + api + ".html']").triggerHandler('click');
}
});
}).trigger("hashchange");
});