forked from ajaxorg/ace
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathux.js
More file actions
135 lines (111 loc) · 3.98 KB
/
Copy pathux.js
File metadata and controls
135 lines (111 loc) · 3.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
$(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");
if (form) {
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;
$('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"
});
}
}