This repository has been archived by the owner on Jan 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.html
315 lines (261 loc) · 12.7 KB
/
index.html
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Visual jQuery</title>
<style type="text/css" media="screen">
<!--
BODY { margin: 10px; padding: 0; font: 1em "Trebuchet MS", verdana, arial, sans-serif; font-size: 100%; }
H1 { margin-bottom: 2px; }
DIV.container { margin: auto; width: 90%; margin-bottom: 10px;}
TEXTAREA { width: 80%;}
FIELDSET { border: 1px solid #ccc; padding: 1em; margin: 0; }
LEGEND { color: #ccc; font-size: 120%; }
INPUT, TEXTAREA { font-family: Arial, verdana; font-size: 125%; padding: 7px; border: 1px solid #999; }
LABEL { display: block; margin-top: 10px; }
IMG { margin: 5px; }
-->
</style>
<link rel="stylesheet" href="new_vjq.css" type="text/css" />
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script type="text/javascript">
<!--
$(document).bind('api-load-complete', function () {
// cache the original
window._jquerydocs = jquerydocs;
// version notices
$('#version').html(jquerydocs.version);
document.title += ' ' + jquerydocs.version;
// sort out alpha
updateAlpha();
loadCategories();
});
function updateAlpha() {
if (!updateAlpha.letters) updateAlpha.letters = jquerydocs.letters;
var alphaEl = $('#alpha').click(function (ev) {
if (ev.target.nodeName == 'A') {
$('#query').val(ev.target.innerHTML);
queryDocs();
return false;
}
}).empty();
var letters = [];
for (var i = 0; i < jquerydocs.letters.length; i++) {
letters.push('<li><a href="#?q=' + jquerydocs.letters[i] + '">' + jquerydocs.letters[i].toUpperCase() + '</a></li>');
}
alphaEl.append(letters.join(''));
}
$(function () {
var timer = null;
var last = '';
$('#query').focus().keyup(function () {
if (this.value != last) {
if (timer) clearTimeout(timer);
last = this.value;
timer = setTimeout(queryDocs, 250);
}
});
});
function queryDocs() {
if (jquerydocs == null) return;
jquerydocs = _jquerydocs; // reset
// the query trimmed
var q = $('#query').val().toLowerCase().replace( /^\s+|\s+$/g,"");
if (q == '') {
loadCategories();
return;
}
jquerydocs = jquerydocs.find(q);
loadCategories();
showFunctions(jquerydocs, $('#wrapper')); // function because we get reused.
}
function loadCategories() {
var html = [];
var categories = jquerydocs.categories;
for (var i = 0; i < categories.length; i++) {
html.push('<dt id="' + i + '">' + categories[i].name + '</dt>');
}
var $wrapper = $('#wrapper').html('<dl id="categories">' + html.join('') + '</dl>'),
$categories = $('#categories'),
$path = $('#current-path'),
blank_iframe = '/index-blank.html';
$wrapper.click(function (event) {
categories = jquerydocs.categories;
var dt = (event.target.nodeName == 'DT'),
$selected = $(event.target),
step = 210,
i, j, // loop indices
q = $selected.text(), // search term
items, // matches
item, // specific function
argsA = [],
args = '',
html = [],
offset, size; // required for sliding effect
if (dt) {
$selected.parent().find('dt').removeClass('active');
$selected.addClass('active');
// sliding effect from original Visual jquery
offset = $selected.offset();
// if ((offset.left + offset.width) > $('body').offset().width) jQuery.visual.slideRight();
size = (-1 * ($("#wrapper > dl, #wrapper > dd").length));
if ((offset.width < 350 || (offset.left + offset.width) > $("body").offset().width) && ($.visual.pane - 1) > size) {
$.visual.slideRight(1);
}
if ($selected.parents('#categories').length) { // category selected
var category = $selected.attr('id');
$categories.find('dt').removeClass('active');
$selected.addClass('active');
$wrapper.find('> dl:not(#categories), dd').remove();
if (jquerydocs.categories[category].subcategories && jquerydocs.categories[category].subcategories.length) {
for (i = 0; i < categories[category].subcategories.length; i++) {
html.push('<dt>' + categories[category].subcategories[i] + '</dt>');
}
step = (200 * $wrapper.find('dl').length) + 10;
$wrapper.append('<dl id="subcategories" class="absolute" style="left: ' + step + 'px;">' + html.join('') + '</dl>');
}
} else if ($selected.parents('#subcategories').length) { // subcategory selected
items = jquerydocs.find(q, 'subcategory');
showFunctions(items, $wrapper); // function because we get reused.
} else if ($selected.parents('#functions').length) { // function selected
item = jquerydocs.data[$selected.attr('id')];
$wrapper.find('> #function').remove();
html.push('<p class="cheat" />');
html.push('<h1>' + q + '</h1>');
html.push(item.longdesc || '<p>' + item.desc + '</p>'); // longdesc is usally HTML
html.push('<h2>Returns</h2>');
html.push('<p>' + item['return'] + '</p>');
if (item.params.length) {
html.push('<h2>Parameters</h2>');
html.push('<ul>');
for (i = 0; i < item.params.length; i++) {
html.push('<li><strong>' + item.params[i].name + '</strong> ');
if (item.params[i].type) {
html.push('(' + item.params[i].type + ')');
}
html.push(': ' + item.params[i].desc + '</li>');
}
html.push('</ul>');
}
for (i = 0; i < item.examples.length; i++) {
html.push('<h2>Example</h2>');
if (item.examples[i].desc) html.push('<p>' + item.examples[i].desc + '</p>');
html.push('<h3>jQuery Code</h3>');
html.push('<pre>' + item.examples[i].htmlCode + '</pre>');
// this is special code that will convert in to a real running example once run through 'runExample(item)'
if (item.examples[i].html) {
html.push('<div style="position: relative;"><iframe id="' + item.examples[i].exampleId + '" class="example" src="' + blank_iframe + '"></iframe></div>');
}
}
step = (200 * $wrapper.find('dl').length) + 10;
$wrapper.append('<dd id="function" class="text absolute" style="left: ' + step + 'px;">' + html.join('') + '</dd>');
fixLinks($wrapper.find('dd')); // makes links to more docs absolute rather than relative (should do in the api-docs.js)
runExample(item);
}
$path.html($.map($('dt.active'), function(i) { return i.innerHTML; }).join("/"));
$.visual.setArrows();
}
});
}
function showFunctions(items, $wrapper) {
var argsA = [],
args,
html = [],
step,
i, j;
$wrapper.find('> #functions, dd').remove();
for (i = 0; i < items.length; i++) {
argsA = [];
args = '';
if (items[i].params.length) {
for (j = 0; j < items[i].params.length; j++) {
argsA.push(items[i].params[j].name);
}
args = argsA.join(', ');
}
html.push('<dt id="' + items[i].searchname + items[i].id + '" class="direct">' + items[i].name + '(' + args + ')</dt>');
}
step = (200 * $wrapper.find('dl').length) + 10;
$wrapper.append('<dl id="functions" class="absolute" style="left: ' + step + 'px;">' + html.join('') + '</dl>');
}
// original Visual jQuery effects code
$(function () {
$.visual = { pane: 0 };
$.visual.slideRight = function(again) {
if(!$.visual.allRight()) {
$("#wrapper > dl, #wrapper > dd").each(function () {
var $el = $(this);
$el.animate({
left: parseInt($el.css("left")) - 201
}, 500, function() {
if (!$el.is(".absolute")) {
var size = (-1 * ($("#wrapper > dl, #wrapper > dd").length));
if (($("dd.text:visible").length != 0) && $("dd.text:visible").offset().width < 350 && (($.visual.pane - 1) > size) && again) {
$.visual.slideRight(1);
}
}
});
});
$.visual.pane -= 1;
}
$.visual.setArrows();
};
$.visual.slideLeft = function() {
if(!$.visual.allLeft()) {
var c = $("dd.text:visible");
if ((c.length != 0) && ($("dd.text:visible").offset().width - 200) < 200) {
$("dd.text:visible").remove();
$("#wrapper > dl:visible:last dt.active").removeClass("active");
$("#current-path").html($.map($("dt.active:visible"), function(i) { return i.innerHTML; }).join("/"));
}
$("#wrapper > dl, #wrapper > dd").each(function () {
var $this = $(this);
$this.animate({
left: parseInt($this.css("left")) + 201
},500);
});
$.visual.pane += 1;
}
$.visual.setArrows();
};
$.visual.setArrows = function() {
$("#left-button").css("display", $.visual.allLeft() ? "none" : "");
$("#right-button").css("display", $.visual.allRight() ? "none" : "");
};
$.visual.allLeft = function() {
return ($.visual.pane == 0);
};
$.visual.allRight = function() {
return ($.visual.pane - 1) == (-1 * ($("#wrapper > dl, #wrapper > dd").length));
};
$("a#left-button").click($.visual.slideLeft);
$("a#right-button").click($.visual.slideRight);
$.visual.setArrows();
$(document).keydown( function(e) {
var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
switch(key) {
case 37:
if (e.ctrlKey) $.visual.slideLeft();
break;
case 39:
if (e.ctrlKey) $.visual.slideRight();
break;
}
});
});
//-->
</script>
</head>
<body>
<div id="footer">
<a id="left-button" style="display: none;"><img src="images/arrow-back_16.gif"/></a><a id="right-button" style="display: none;"><img src="images/arrow-forward_16.gif"/></a><p id="header">jQuery <span id="version"></span> (Updated by <a href="http://remysharp.com">Remy Sharp</a> originally by <a href="http://yehudakatz.com/">Yehuda Katz</a>)</p>
<p id="current-path"></p>
</div>
<div id="search">
<label for="query">Filter:</label> <input type="text" name="q" id="query" size="15" />
<ul id="alpha"></ul>
</div>
<div id="wrapper"></div>
<script src="api-loader.js" type="text/javascript"></script>
<script src="api-docs-1.3.js" type="text/javascript"></script>
</body>
</html>