airtable2 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +5 -0
- data/README.md +8 -2
- data/airtable.gemspec +1 -0
- data/docs/Airtable/Base.html +575 -0
- data/docs/Airtable/Client.html +506 -0
- data/docs/Airtable/Error.html +375 -0
- data/docs/Airtable/Record.html +327 -0
- data/docs/Airtable/Resource.html +451 -0
- data/docs/Airtable/Table.html +907 -0
- data/docs/Airtable.html +142 -0
- data/docs/_index.html +189 -0
- data/docs/class_list.html +54 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +503 -0
- data/docs/file.README.html +169 -0
- data/docs/file_list.html +59 -0
- data/docs/frames.html +22 -0
- data/docs/index.html +169 -0
- data/docs/js/app.js +344 -0
- data/docs/js/full_list.js +242 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +270 -0
- data/docs/top-level-namespace.html +110 -0
- data/lib/airtable/base.rb +11 -0
- data/lib/airtable/client.rb +32 -1
- data/lib/airtable/resource.rb +1 -0
- data/lib/airtable/table.rb +16 -1
- data/lib/airtable/version.rb +1 -1
- metadata +37 -1
data/docs/file_list.html
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html >
|
3
|
+
<head>
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
5
|
+
<meta charset="utf-8" />
|
6
|
+
|
7
|
+
<link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" />
|
8
|
+
|
9
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" />
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
14
|
+
|
15
|
+
<script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
|
16
|
+
|
17
|
+
|
18
|
+
<title>File List</title>
|
19
|
+
<base id="base_target" target="_parent" />
|
20
|
+
</head>
|
21
|
+
<body>
|
22
|
+
<div id="content">
|
23
|
+
<div class="fixed_header">
|
24
|
+
<h1 id="full_list_header">File List</h1>
|
25
|
+
<div id="full_list_nav">
|
26
|
+
|
27
|
+
<span><a target="_self" href="class_list.html">
|
28
|
+
Classes
|
29
|
+
</a></span>
|
30
|
+
|
31
|
+
<span><a target="_self" href="method_list.html">
|
32
|
+
Methods
|
33
|
+
</a></span>
|
34
|
+
|
35
|
+
<span><a target="_self" href="file_list.html">
|
36
|
+
Files
|
37
|
+
</a></span>
|
38
|
+
|
39
|
+
</div>
|
40
|
+
|
41
|
+
<div id="search">
|
42
|
+
<label for="search-class">Search:</label>
|
43
|
+
<input id="search-class" type="text" />
|
44
|
+
</div>
|
45
|
+
</div>
|
46
|
+
|
47
|
+
<ul id="full_list" class="file">
|
48
|
+
|
49
|
+
|
50
|
+
<li id="object_README" class="odd">
|
51
|
+
<div class="item"><span class="object_link"><a href="index.html" title="README">README</a></span></div>
|
52
|
+
</li>
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
</ul>
|
57
|
+
</div>
|
58
|
+
</body>
|
59
|
+
</html>
|
data/docs/frames.html
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>Documentation by YARD 0.9.37</title>
|
6
|
+
</head>
|
7
|
+
<script type="text/javascript">
|
8
|
+
var mainUrl = 'index.html';
|
9
|
+
try {
|
10
|
+
var match = decodeURIComponent(window.location.hash).match(/^#!(.+)/);
|
11
|
+
var name = match ? match[1] : mainUrl;
|
12
|
+
var url = new URL(name, location.href);
|
13
|
+
window.top.location.replace(url.origin === location.origin ? name : mainUrl);
|
14
|
+
} catch (e) {
|
15
|
+
window.top.location.replace(mainUrl);
|
16
|
+
}
|
17
|
+
</script>
|
18
|
+
<noscript>
|
19
|
+
<h1>Oops!</h1>
|
20
|
+
<h2>YARD requires JavaScript!</h2>
|
21
|
+
</noscript>
|
22
|
+
</html>
|
data/docs/index.html
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
File: README
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.37
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" />
|
16
|
+
|
17
|
+
<script type="text/javascript">
|
18
|
+
pathId = "README";
|
19
|
+
relpath = '';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="_index.html">Index</a> »
|
40
|
+
<span class="title">File: README</span>
|
41
|
+
|
42
|
+
</div>
|
43
|
+
|
44
|
+
<div id="search">
|
45
|
+
|
46
|
+
<a class="full_list_link" id="class_list_link"
|
47
|
+
href="class_list.html">
|
48
|
+
|
49
|
+
<svg width="24" height="24">
|
50
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
51
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
52
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
</svg>
|
54
|
+
</a>
|
55
|
+
|
56
|
+
</div>
|
57
|
+
<div class="clear"></div>
|
58
|
+
</div>
|
59
|
+
|
60
|
+
<div id="content"><div id='filecontents'>
|
61
|
+
<h1 id="label-Airtable+API+Wrapper+for+Ruby">Airtable API Wrapper for Ruby</h1>
|
62
|
+
|
63
|
+
<p>For when Airrecord is just too much.</p>
|
64
|
+
|
65
|
+
<h1 id="label-Note+on+library+status">Note on library status</h1>
|
66
|
+
|
67
|
+
<p>This is a fork of an abandoned <a href="https://github.com/nesquena/airtable-ruby">previous wrapper</a>. There’s still plenty to do to get it up to speed with the current Airtable API.</p>
|
68
|
+
|
69
|
+
<h2 id="label-Installation">Installation</h2>
|
70
|
+
|
71
|
+
<p>Add this line to your application’s Gemfile:</p>
|
72
|
+
|
73
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>airtable2</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>github:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>https://github.com/aseroff/airtable-ruby</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>branch:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>main</span><span class='tstring_end'>'</span></span>
|
74
|
+
</code></pre>
|
75
|
+
|
76
|
+
<p>And then execute:</p>
|
77
|
+
|
78
|
+
<pre class="code ruby"><code class="ruby">$ bundle
|
79
|
+
</code></pre>
|
80
|
+
|
81
|
+
<h2 id="label-Usage">Usage</h2>
|
82
|
+
|
83
|
+
<h3 id="label-Creating+a+Client">Creating a Client</h3>
|
84
|
+
|
85
|
+
<p>First, be sure to register for an <a href="https://airtable.com">airtable</a> account, setup a base, and create a token with the desired permissions for your base. Now, setup your Airtable client:</p>
|
86
|
+
|
87
|
+
<pre class="code ruby"><code class="ruby"><span class='comment'># Pass in api key to client
|
88
|
+
</span><span class='ivar'>@client</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Airtable.html" title="Airtable (module)">Airtable</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Airtable/Client.html" title="Airtable::Client (class)">Client</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Airtable/Client.html#initialize-instance_method" title="Airtable::Client#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>your.token.goes.here</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
89
|
+
</code></pre>
|
90
|
+
|
91
|
+
<h3 id="label-Accessing+Data">Accessing Data</h3>
|
92
|
+
|
93
|
+
<p>Now we can access our base</p>
|
94
|
+
|
95
|
+
<pre class="code ruby"><code class="ruby"><span class='ivar'>@base</span> <span class='op'>=</span> <span class='ivar'>@client</span><span class='period'>.</span><span class='id identifier rubyid_base'>base</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>appExAmPlE</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span>
|
96
|
+
</code></pre>
|
97
|
+
|
98
|
+
<p>and its tables</p>
|
99
|
+
|
100
|
+
<pre class="code ruby"><code class="ruby"><span class='ivar'>@tables</span> <span class='op'>=</span> <span class='ivar'>@base</span><span class='period'>.</span><span class='id identifier rubyid_tables'>tables</span>
|
101
|
+
</code></pre>
|
102
|
+
|
103
|
+
<p>and a table’s records, so you can navigate the has_many chain the way God intended:</p>
|
104
|
+
|
105
|
+
<pre class="code ruby"><code class="ruby"><span class='ivar'>@client</span><span class='period'>.</span><span class='id identifier rubyid_bases'>bases</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='period'>.</span><span class='id identifier rubyid_tables'>tables</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='period'>.</span><span class='id identifier rubyid_records'>records</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
|
106
|
+
</code></pre>
|
107
|
+
|
108
|
+
<h3 id="label-Manipulating+Tables">Manipulating Tables</h3>
|
109
|
+
|
110
|
+
<p>Create a new table with:</p>
|
111
|
+
|
112
|
+
<pre class="code ruby"><code class="ruby"><span class='ivar'>@table</span> <span class='op'>=</span> <span class='ivar'>@base</span><span class='period'>.</span><span class='id identifier rubyid_create_table'>create_table</span><span class='lparen'>(</span><span class='lbrace'>{</span> <span class='label'>name:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Names</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>description:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>A list of names</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>fields:</span> <span class='lbracket'>[</span><span class='lbrace'>{</span> <span class='label'>name:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>name</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>type:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>singleLineText</span><span class='tstring_end'>'</span></span> <span class='rbrace'>}</span><span class='rbracket'>]</span> <span class='rbrace'>}</span><span class='rparen'>)</span>
|
113
|
+
</code></pre>
|
114
|
+
|
115
|
+
<p>You can update at a table’s metadata with the <code>update</code> method:</p>
|
116
|
+
|
117
|
+
<pre class="code ruby"><code class="ruby"><span class='ivar'>@table</span><span class='period'>.</span><span class='id identifier rubyid_update'>update</span><span class='lparen'>(</span><span class='lbrace'>{</span> <span class='label'>description:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Updated description</span><span class='tstring_end'>'</span></span> <span class='rbrace'>}</span><span class='rparen'>)</span>
|
118
|
+
</code></pre>
|
119
|
+
|
120
|
+
<h3 id="label-Querying+Records">Querying Records</h3>
|
121
|
+
|
122
|
+
<p>Once you have access to a table from above, we can query a set of records in the table with:</p>
|
123
|
+
|
124
|
+
<pre class="code ruby"><code class="ruby"><span class='ivar'>@records</span> <span class='op'>=</span> <span class='ivar'>@table</span><span class='period'>.</span><span class='id identifier rubyid_records'>records</span>
|
125
|
+
</code></pre>
|
126
|
+
|
127
|
+
<h3 id="label-Inserting+Records">Inserting Records</h3>
|
128
|
+
|
129
|
+
<p>A single record or an array of records can be inserted using the <code>add_records</code> method on a table (max 10 at a time):</p>
|
130
|
+
|
131
|
+
<pre class="code ruby"><code class="ruby"><span class='ivar'>@table</span><span class='period'>.</span><span class='id identifier rubyid_add_records'>add_records</span><span class='lparen'>(</span><span class='lbrace'>{</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Name</span><span class='label_end'>':</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>name value</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>Age</span><span class='label_end'>':</span> <span class='int'>35</span> <span class='rbrace'>}</span><span class='rparen'>)</span>
|
132
|
+
</code></pre>
|
133
|
+
|
134
|
+
<h3 id="label-Deleting+Records">Deleting Records</h3>
|
135
|
+
|
136
|
+
<p>A single record or an array of records can be destroyed by passing their ids to the <code>delete_records</code> method on a table:</p>
|
137
|
+
|
138
|
+
<pre class="code ruby"><code class="ruby"><span class='ivar'>@record</span> <span class='op'>=</span> <span class='ivar'>@table</span><span class='period'>.</span><span class='id identifier rubyid_records'>records</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span>
|
139
|
+
<span class='ivar'>@table</span><span class='period'>.</span><span class='id identifier rubyid_delete_records'>delete_records</span><span class='lparen'>(</span><span class='ivar'>@record</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span><span class='rparen'>)</span>
|
140
|
+
</code></pre>
|
141
|
+
|
142
|
+
<p>Or as a convenience, you can delete all records with the <code>dump</code> method</p>
|
143
|
+
|
144
|
+
<pre class="code ruby"><code class="ruby"><span class='ivar'>@table</span><span class='period'>.</span><span class='id identifier rubyid_dump'>dump</span>
|
145
|
+
</code></pre>
|
146
|
+
|
147
|
+
<h2 id="label-Contributing">Contributing</h2>
|
148
|
+
<ol><li>
|
149
|
+
<p>Fork it ( <a href="https://github.com/aseroff/airtable-ruby/fork">github.com/aseroff/airtable-ruby/fork</a> )</p>
|
150
|
+
</li><li>
|
151
|
+
<p>Create your feature branch (<code>git checkout -b my-new-feature</code>)</p>
|
152
|
+
</li><li>
|
153
|
+
<p>Commit your changes (<code>git commit -am 'Add some feature'</code>)</p>
|
154
|
+
</li><li>
|
155
|
+
<p>Push to the branch (<code>git push origin my-new-feature</code>)</p>
|
156
|
+
</li><li>
|
157
|
+
<p>Create a new Pull Request</p>
|
158
|
+
</li></ol>
|
159
|
+
</div></div>
|
160
|
+
|
161
|
+
<div id="footer">
|
162
|
+
Generated on Fri Oct 25 21:49:50 2024 by
|
163
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
164
|
+
0.9.37 (ruby-3.3.5).
|
165
|
+
</div>
|
166
|
+
|
167
|
+
</div>
|
168
|
+
</body>
|
169
|
+
</html>
|
data/docs/js/app.js
ADDED
@@ -0,0 +1,344 @@
|
|
1
|
+
(function () {
|
2
|
+
var localStorage = {},
|
3
|
+
sessionStorage = {};
|
4
|
+
try {
|
5
|
+
localStorage = window.localStorage;
|
6
|
+
} catch (e) {}
|
7
|
+
try {
|
8
|
+
sessionStorage = window.sessionStorage;
|
9
|
+
} catch (e) {}
|
10
|
+
|
11
|
+
function createSourceLinks() {
|
12
|
+
$(".method_details_list .source_code").before(
|
13
|
+
"<span class='showSource'>[<a href='#' class='toggleSource'>View source</a>]</span>"
|
14
|
+
);
|
15
|
+
$(".toggleSource").toggle(
|
16
|
+
function () {
|
17
|
+
$(this).parent().nextAll(".source_code").slideDown(100);
|
18
|
+
$(this).text("Hide source");
|
19
|
+
},
|
20
|
+
function () {
|
21
|
+
$(this).parent().nextAll(".source_code").slideUp(100);
|
22
|
+
$(this).text("View source");
|
23
|
+
}
|
24
|
+
);
|
25
|
+
}
|
26
|
+
|
27
|
+
function createDefineLinks() {
|
28
|
+
var tHeight = 0;
|
29
|
+
$(".defines").after(" <a href='#' class='toggleDefines'>more...</a>");
|
30
|
+
$(".toggleDefines").toggle(
|
31
|
+
function () {
|
32
|
+
tHeight = $(this).parent().prev().height();
|
33
|
+
$(this).prev().css("display", "inline");
|
34
|
+
$(this).parent().prev().height($(this).parent().height());
|
35
|
+
$(this).text("(less)");
|
36
|
+
},
|
37
|
+
function () {
|
38
|
+
$(this).prev().hide();
|
39
|
+
$(this).parent().prev().height(tHeight);
|
40
|
+
$(this).text("more...");
|
41
|
+
}
|
42
|
+
);
|
43
|
+
}
|
44
|
+
|
45
|
+
function createFullTreeLinks() {
|
46
|
+
var tHeight = 0;
|
47
|
+
$(".inheritanceTree").toggle(
|
48
|
+
function () {
|
49
|
+
tHeight = $(this).parent().prev().height();
|
50
|
+
$(this).parent().toggleClass("showAll");
|
51
|
+
$(this).text("(hide)");
|
52
|
+
$(this).parent().prev().height($(this).parent().height());
|
53
|
+
},
|
54
|
+
function () {
|
55
|
+
$(this).parent().toggleClass("showAll");
|
56
|
+
$(this).parent().prev().height(tHeight);
|
57
|
+
$(this).text("show all");
|
58
|
+
}
|
59
|
+
);
|
60
|
+
}
|
61
|
+
|
62
|
+
function searchFrameButtons() {
|
63
|
+
$(".full_list_link").click(function () {
|
64
|
+
toggleSearchFrame(this, $(this).attr("href"));
|
65
|
+
return false;
|
66
|
+
});
|
67
|
+
window.addEventListener("message", function (e) {
|
68
|
+
if (e.data === "navEscape") {
|
69
|
+
$("#nav").slideUp(100);
|
70
|
+
$("#search a").removeClass("active inactive");
|
71
|
+
$(window).focus();
|
72
|
+
}
|
73
|
+
});
|
74
|
+
|
75
|
+
$(window).resize(function () {
|
76
|
+
if ($("#search:visible").length === 0) {
|
77
|
+
$("#nav").removeAttr("style");
|
78
|
+
$("#search a").removeClass("active inactive");
|
79
|
+
$(window).focus();
|
80
|
+
}
|
81
|
+
});
|
82
|
+
}
|
83
|
+
|
84
|
+
function toggleSearchFrame(id, link) {
|
85
|
+
var frame = $("#nav");
|
86
|
+
$("#search a").removeClass("active").addClass("inactive");
|
87
|
+
if (frame.attr("src") === link && frame.css("display") !== "none") {
|
88
|
+
frame.slideUp(100);
|
89
|
+
$("#search a").removeClass("active inactive");
|
90
|
+
} else {
|
91
|
+
$(id).addClass("active").removeClass("inactive");
|
92
|
+
if (frame.attr("src") !== link) frame.attr("src", link);
|
93
|
+
frame.slideDown(100);
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
function linkSummaries() {
|
98
|
+
$(".summary_signature").click(function () {
|
99
|
+
document.location = $(this).find("a").attr("href");
|
100
|
+
});
|
101
|
+
}
|
102
|
+
|
103
|
+
function summaryToggle() {
|
104
|
+
$(".summary_toggle").click(function (e) {
|
105
|
+
e.preventDefault();
|
106
|
+
localStorage.summaryCollapsed = $(this).text();
|
107
|
+
$(".summary_toggle").each(function () {
|
108
|
+
$(this).text($(this).text() == "collapse" ? "expand" : "collapse");
|
109
|
+
var next = $(this).parent().parent().nextAll("ul.summary").first();
|
110
|
+
if (next.hasClass("compact")) {
|
111
|
+
next.toggle();
|
112
|
+
next.nextAll("ul.summary").first().toggle();
|
113
|
+
} else if (next.hasClass("summary")) {
|
114
|
+
var list = $('<ul class="summary compact" />');
|
115
|
+
list.html(next.html());
|
116
|
+
list.find(".summary_desc, .note").remove();
|
117
|
+
list.find("a").each(function () {
|
118
|
+
$(this).html($(this).find("strong").html());
|
119
|
+
$(this).parent().html($(this)[0].outerHTML);
|
120
|
+
});
|
121
|
+
next.before(list);
|
122
|
+
next.toggle();
|
123
|
+
}
|
124
|
+
});
|
125
|
+
return false;
|
126
|
+
});
|
127
|
+
if (localStorage.summaryCollapsed == "collapse") {
|
128
|
+
$(".summary_toggle").first().click();
|
129
|
+
} else {
|
130
|
+
localStorage.summaryCollapsed = "expand";
|
131
|
+
}
|
132
|
+
}
|
133
|
+
|
134
|
+
function constantSummaryToggle() {
|
135
|
+
$(".constants_summary_toggle").click(function (e) {
|
136
|
+
e.preventDefault();
|
137
|
+
localStorage.summaryCollapsed = $(this).text();
|
138
|
+
$(".constants_summary_toggle").each(function () {
|
139
|
+
$(this).text($(this).text() == "collapse" ? "expand" : "collapse");
|
140
|
+
var next = $(this).parent().parent().nextAll("dl.constants").first();
|
141
|
+
if (next.hasClass("compact")) {
|
142
|
+
next.toggle();
|
143
|
+
next.nextAll("dl.constants").first().toggle();
|
144
|
+
} else if (next.hasClass("constants")) {
|
145
|
+
var list = $('<dl class="constants compact" />');
|
146
|
+
list.html(next.html());
|
147
|
+
list.find("dt").each(function () {
|
148
|
+
$(this).addClass("summary_signature");
|
149
|
+
$(this).text($(this).text().split("=")[0]);
|
150
|
+
if ($(this).has(".deprecated").length) {
|
151
|
+
$(this).addClass("deprecated");
|
152
|
+
}
|
153
|
+
});
|
154
|
+
// Add the value of the constant as "Tooltip" to the summary object
|
155
|
+
list.find("pre.code").each(function () {
|
156
|
+
console.log($(this).parent());
|
157
|
+
var dt_element = $(this).parent().prev();
|
158
|
+
var tooltip = $(this).text();
|
159
|
+
if (dt_element.hasClass("deprecated")) {
|
160
|
+
tooltip = "Deprecated. " + tooltip;
|
161
|
+
}
|
162
|
+
dt_element.attr("title", tooltip);
|
163
|
+
});
|
164
|
+
list.find(".docstring, .tags, dd").remove();
|
165
|
+
next.before(list);
|
166
|
+
next.toggle();
|
167
|
+
}
|
168
|
+
});
|
169
|
+
return false;
|
170
|
+
});
|
171
|
+
if (localStorage.summaryCollapsed == "collapse") {
|
172
|
+
$(".constants_summary_toggle").first().click();
|
173
|
+
} else {
|
174
|
+
localStorage.summaryCollapsed = "expand";
|
175
|
+
}
|
176
|
+
}
|
177
|
+
|
178
|
+
function generateTOC() {
|
179
|
+
if ($("#filecontents").length === 0) return;
|
180
|
+
var _toc = $('<ol class="top"></ol>');
|
181
|
+
var show = false;
|
182
|
+
var toc = _toc;
|
183
|
+
var counter = 0;
|
184
|
+
var tags = ["h2", "h3", "h4", "h5", "h6"];
|
185
|
+
var i;
|
186
|
+
var curli;
|
187
|
+
if ($("#filecontents h1").length > 1) tags.unshift("h1");
|
188
|
+
for (i = 0; i < tags.length; i++) {
|
189
|
+
tags[i] = "#filecontents " + tags[i];
|
190
|
+
}
|
191
|
+
var lastTag = parseInt(tags[0][1], 10);
|
192
|
+
$(tags.join(", ")).each(function () {
|
193
|
+
if ($(this).parents(".method_details .docstring").length != 0) return;
|
194
|
+
if (this.id == "filecontents") return;
|
195
|
+
show = true;
|
196
|
+
var thisTag = parseInt(this.tagName[1], 10);
|
197
|
+
if (this.id.length === 0) {
|
198
|
+
var proposedId = $(this).attr("toc-id");
|
199
|
+
if (typeof proposedId != "undefined") this.id = proposedId;
|
200
|
+
else {
|
201
|
+
var proposedId = $(this)
|
202
|
+
.text()
|
203
|
+
.replace(/[^a-z0-9-]/gi, "_");
|
204
|
+
if ($("#" + proposedId).length > 0) {
|
205
|
+
proposedId += counter;
|
206
|
+
counter++;
|
207
|
+
}
|
208
|
+
this.id = proposedId;
|
209
|
+
}
|
210
|
+
}
|
211
|
+
if (thisTag > lastTag) {
|
212
|
+
for (i = 0; i < thisTag - lastTag; i++) {
|
213
|
+
if (typeof curli == "undefined") {
|
214
|
+
curli = $("<li/>");
|
215
|
+
toc.append(curli);
|
216
|
+
}
|
217
|
+
toc = $("<ol/>");
|
218
|
+
curli.append(toc);
|
219
|
+
curli = undefined;
|
220
|
+
}
|
221
|
+
}
|
222
|
+
if (thisTag < lastTag) {
|
223
|
+
for (i = 0; i < lastTag - thisTag; i++) {
|
224
|
+
toc = toc.parent();
|
225
|
+
toc = toc.parent();
|
226
|
+
}
|
227
|
+
}
|
228
|
+
var title = $(this).attr("toc-title");
|
229
|
+
if (typeof title == "undefined") title = $(this).text();
|
230
|
+
curli = $('<li><a href="#' + this.id + '">' + title + "</a></li>");
|
231
|
+
toc.append(curli);
|
232
|
+
lastTag = thisTag;
|
233
|
+
});
|
234
|
+
if (!show) return;
|
235
|
+
html =
|
236
|
+
'<div id="toc"><p class="title hide_toc"><a href="#"><strong>Table of Contents</strong></a></p></div>';
|
237
|
+
$("#content").prepend(html);
|
238
|
+
$("#toc").append(_toc);
|
239
|
+
$("#toc .hide_toc").toggle(
|
240
|
+
function () {
|
241
|
+
$("#toc .top").slideUp("fast");
|
242
|
+
$("#toc").toggleClass("hidden");
|
243
|
+
$("#toc .title small").toggle();
|
244
|
+
},
|
245
|
+
function () {
|
246
|
+
$("#toc .top").slideDown("fast");
|
247
|
+
$("#toc").toggleClass("hidden");
|
248
|
+
$("#toc .title small").toggle();
|
249
|
+
}
|
250
|
+
);
|
251
|
+
}
|
252
|
+
|
253
|
+
function navResizeFn(e) {
|
254
|
+
if (e.which !== 1) {
|
255
|
+
navResizeFnStop();
|
256
|
+
return;
|
257
|
+
}
|
258
|
+
|
259
|
+
sessionStorage.navWidth = e.pageX.toString();
|
260
|
+
$(".nav_wrap").css("width", e.pageX);
|
261
|
+
$(".nav_wrap").css("-ms-flex", "inherit");
|
262
|
+
}
|
263
|
+
|
264
|
+
function navResizeFnStop() {
|
265
|
+
$(window).unbind("mousemove", navResizeFn);
|
266
|
+
window.removeEventListener("message", navMessageFn, false);
|
267
|
+
}
|
268
|
+
|
269
|
+
function navMessageFn(e) {
|
270
|
+
if (e.data.action === "mousemove") navResizeFn(e.data.event);
|
271
|
+
if (e.data.action === "mouseup") navResizeFnStop();
|
272
|
+
}
|
273
|
+
|
274
|
+
function navResizer() {
|
275
|
+
$("#resizer").mousedown(function (e) {
|
276
|
+
e.preventDefault();
|
277
|
+
$(window).mousemove(navResizeFn);
|
278
|
+
window.addEventListener("message", navMessageFn, false);
|
279
|
+
});
|
280
|
+
$(window).mouseup(navResizeFnStop);
|
281
|
+
|
282
|
+
if (sessionStorage.navWidth) {
|
283
|
+
navResizeFn({ which: 1, pageX: parseInt(sessionStorage.navWidth, 10) });
|
284
|
+
}
|
285
|
+
}
|
286
|
+
|
287
|
+
function navExpander() {
|
288
|
+
if (typeof pathId === "undefined") return;
|
289
|
+
var done = false,
|
290
|
+
timer = setTimeout(postMessage, 500);
|
291
|
+
function postMessage() {
|
292
|
+
if (done) return;
|
293
|
+
clearTimeout(timer);
|
294
|
+
var opts = { action: "expand", path: pathId };
|
295
|
+
document.getElementById("nav").contentWindow.postMessage(opts, "*");
|
296
|
+
done = true;
|
297
|
+
}
|
298
|
+
|
299
|
+
window.addEventListener(
|
300
|
+
"message",
|
301
|
+
function (event) {
|
302
|
+
if (event.data === "navReady") postMessage();
|
303
|
+
return false;
|
304
|
+
},
|
305
|
+
false
|
306
|
+
);
|
307
|
+
}
|
308
|
+
|
309
|
+
function mainFocus() {
|
310
|
+
var hash = window.location.hash;
|
311
|
+
if (hash !== "" && $(hash)[0]) {
|
312
|
+
$(hash)[0].scrollIntoView();
|
313
|
+
}
|
314
|
+
|
315
|
+
setTimeout(function () {
|
316
|
+
$("#main").focus();
|
317
|
+
}, 10);
|
318
|
+
}
|
319
|
+
|
320
|
+
function navigationChange() {
|
321
|
+
// This works around the broken anchor navigation with the YARD template.
|
322
|
+
window.onpopstate = function () {
|
323
|
+
var hash = window.location.hash;
|
324
|
+
if (hash !== "" && $(hash)[0]) {
|
325
|
+
$(hash)[0].scrollIntoView();
|
326
|
+
}
|
327
|
+
};
|
328
|
+
}
|
329
|
+
|
330
|
+
$(document).ready(function () {
|
331
|
+
navResizer();
|
332
|
+
navExpander();
|
333
|
+
createSourceLinks();
|
334
|
+
createDefineLinks();
|
335
|
+
createFullTreeLinks();
|
336
|
+
searchFrameButtons();
|
337
|
+
linkSummaries();
|
338
|
+
summaryToggle();
|
339
|
+
constantSummaryToggle();
|
340
|
+
generateTOC();
|
341
|
+
mainFocus();
|
342
|
+
navigationChange();
|
343
|
+
});
|
344
|
+
})();
|