Rebuild API
This commit is contained in:
parent
8698b13c8b
commit
2a716dc668
59 changed files with 18876 additions and 0 deletions
185
api/resources/javascripts/ux.js
Normal file
185
api/resources/javascripts/ux.js
Normal file
|
|
@ -0,0 +1,185 @@
|
|||
$(function () {
|
||||
'use strict';
|
||||
|
||||
var pagePath = document.location.pathname.substring(document.location.pathname.lastIndexOf("/") + 1);
|
||||
|
||||
// select current page in sidenav and set up prev/next links if they exist
|
||||
var $selNavLink = $('#sidebar').find('a[href="' + pagePath + '"]');
|
||||
if ($selNavLink.length) {
|
||||
//$selListItem = $selNavLink.closest('li');
|
||||
|
||||
$selNavLink.addClass('currentItem');
|
||||
}
|
||||
|
||||
if (window.addEventListener) window.addEventListener('load', loadCallback, true);
|
||||
else window.attachEvent('load', loadCallback, true);
|
||||
|
||||
function loadCallback(evt) {
|
||||
var form = document.getElementById("searchbox");
|
||||
var input = form.query;
|
||||
form.onsubmit = function (evt) {
|
||||
var query = input.value;
|
||||
if (query) {
|
||||
input.value = "";
|
||||
input.blur();
|
||||
var url = "https://www.google.com/search?q=" + encodeURIComponent("site:ace.ajax.org" + " " + query);
|
||||
window.open(url);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
// init search
|
||||
$('#search')
|
||||
// prevent from form submit
|
||||
.on('submit', function () {
|
||||
return false;
|
||||
}).find('input');
|
||||
});
|
||||
|
||||
function ux() {
|
||||
var d = 'a.menu, .dropdown-toggle'
|
||||
|
||||
function clearMenus() {
|
||||
$(d).parent('li').each(function () {
|
||||
$(this).removeClass('open')
|
||||
});
|
||||
}
|
||||
|
||||
var s, sx;
|
||||
|
||||
// scrolling offset calculation via www.quirksmode.org
|
||||
if (window.pageYOffset || window.pageXOffset) {
|
||||
s = window.pageYOffset;
|
||||
sx = window.pageXOffset;
|
||||
}
|
||||
else if (document.documentElement && (document.documentElement.scrollTop || document.documentElement.scrollLeft)) {
|
||||
s = document.documentElement.scrollTop;
|
||||
sx = document.documentElement.scrollLeft;
|
||||
}
|
||||
else if (document.body) {
|
||||
s = document.body.scrollTop;
|
||||
sx = document.body.scrollLeft;
|
||||
}
|
||||
|
||||
if (document.documentElement.offsetWidth < 1010) {
|
||||
if (sx <= 0) sx = 0;
|
||||
else if (sx + document.documentElement.offsetWidth > 1010) sx = 1010 - document.documentElement.offsetWidth;
|
||||
}
|
||||
else sx = 0;
|
||||
|
||||
$('.members').each(function (i) {
|
||||
var $classContent = $(this).closest('.classContent');
|
||||
|
||||
$(this).scrollspy({
|
||||
min: $classContent.position().top + 5,
|
||||
max: $classContent.position().top + $classContent.height() - 35,
|
||||
onEnter: function (element, position) {
|
||||
var $pagination = $(element);
|
||||
var $paginationContent = $('.membersContent pos' + i);
|
||||
var $tabs = $('.tabs pos' + i);
|
||||
|
||||
$paginationContent.css('left', -1 * sx);
|
||||
$paginationContent.css('top', 0);
|
||||
|
||||
$pagination.addClass('shadow').stop().css({
|
||||
height: 31
|
||||
}).closest('.classContent').addClass('srolled');
|
||||
|
||||
$tabs.addClass('tabsSansBorder');
|
||||
},
|
||||
onLeave: function (element, position) {
|
||||
var $pagination = $(element);
|
||||
var $paginationContent = $('.membersContent pos' + i);
|
||||
var $tabs = $('.tabs pos' + i);
|
||||
|
||||
$paginationContent.stop().css({
|
||||
top: 11
|
||||
});
|
||||
$pagination.css({
|
||||
'position': 'absolute',
|
||||
'top': 193
|
||||
});
|
||||
$pagination.stop().removeClass('shadow').css({
|
||||
height: 42
|
||||
});
|
||||
|
||||
$paginationContent.css('left', 0);
|
||||
// setTimeout(function () {
|
||||
$paginationContent.css({
|
||||
'top': ''
|
||||
});
|
||||
$pagination.css({
|
||||
'position': '',
|
||||
'top': ''
|
||||
});
|
||||
$paginationContent.css('left', 0);
|
||||
$pagination.closest('.classContent').removeClass('srolled')
|
||||
$tabs.removeClass('tabsSansBorder');
|
||||
// }, 300);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('span.methodClicker, article.article, i.methodClicker').each(function () {
|
||||
var a = $(this);
|
||||
var constructorPos = a.attr("id").indexOf("new ");
|
||||
|
||||
var objName = a.attr("id");
|
||||
if (constructorPos >= 0) {
|
||||
objName = objName.substring(constructorPos + 4);
|
||||
objName += ".new";
|
||||
}
|
||||
|
||||
a.attr("id", objName);
|
||||
});
|
||||
|
||||
function showMethodContent() {
|
||||
var locationHash = location.hash.replace(/^#/, '').replace(/\./g, '\\.');
|
||||
var equalsPos = location.hash.indexOf("=");
|
||||
|
||||
if (equalsPos >=0) {
|
||||
locationHash = locationHash.substring(0, location.hash.indexOf("="));
|
||||
}
|
||||
|
||||
var $clickerEl = $('span#' + locationHash);
|
||||
if ($clickerEl.length > 0 && $clickerEl.hasClass('methodClicker')) {
|
||||
var p = $clickerEl.parent();
|
||||
p[0].force = true;
|
||||
p.trigger('click');
|
||||
p[0].force = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (location.hash.indexOf("section") >= 1) {
|
||||
showMethodContent();
|
||||
var data = location.hash;
|
||||
scrollTo(null, data.substr(1));
|
||||
}
|
||||
|
||||
window.onhashchange = function () {
|
||||
showMethodContent();
|
||||
}
|
||||
};
|
||||
|
||||
function scrollTo(el, data) {
|
||||
if (!data) {
|
||||
data = el.getAttribute("data-id");
|
||||
//location.hash = data;
|
||||
}
|
||||
var el = $("span#" + data.replace(/\./g, "\\."))[0];
|
||||
if (!el) return;
|
||||
|
||||
var article = $(el).closest('.article')[0];
|
||||
|
||||
var top = article.offsetTop - 100;
|
||||
|
||||
if (document.body.scrollTop > top || document.body.scrollTop != top && document.body.scrollTop + (window.innerHeight || document.documentElement.offsetHeight) < top + article.offsetHeight) {
|
||||
$('body').animate({
|
||||
scrollTop: top
|
||||
}, {
|
||||
duration: 200,
|
||||
easing: "swing"
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue