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
207 lines (173 loc) · 6.19 KB
/
Copy pathux.js
File metadata and controls
207 lines (173 loc) · 6.19 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
$(function () {
'use strict';
var baseTitle = document.title,
// base (general) part of title
pathName = window.location.pathname,
fileName = pathName.substring(window.location.pathname.lastIndexOf("/") + 1);
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 currentVersion = $('#currentVersion').text();
var url = "https://www.google.com/search?q=" + encodeURIComponent("site:ace.ajax.org/api" + " " + query);
window.open(url);
}
return false;
};
}
var fileNameRE = new RegExp("^" + fileName, "i");
$('a.menuLink').each(function (index) {
if ($(this).attr("href").match(fileNameRE)) {
$(this).addClass("currentItem");
return false;
}
});
// init search
$('#search')
// prevent from form submit
.on('submit', function () {
return false;
}).find('input');
// init prettyprint
$('pre > code').addClass('prettyprint');
prettyPrint();
});
$(document).ready(function () {
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 position = $(this).position();
var $classContent = $(this).closest('.classContent');
$(this).scrollspy({
min: $classContent.position().top - 35,
max: $classContent.position().top + $classContent.height(),
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,
'top': 33
}).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, h3.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);
});
$('.brand').parent('.dropdown').hover(
function () {
$(this).addClass('open');
}, function () {
clearMenus();
});
$('.versions').hover(
function () {
$(this).addClass('open');
}, function () {
clearMenus();
});
function showMethodContent() {
if (!location.hash) return;
var $clickerEl = $('span#' + location.hash.replace(/^#/, '').replace(/\./g, '\\.'));
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) {
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"
});
}
}