prismic.io 1.4.3 → 1.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +2 -2
  3. data/docs/Prismic/API/BadPrismicResponseError.html +44 -43
  4. data/docs/Prismic/API/OAuth.html +99 -98
  5. data/docs/Prismic/API/PrismicWSAuthError.html +67 -66
  6. data/docs/Prismic/API/PrismicWSConnectionError.html +51 -50
  7. data/docs/Prismic/API.html +434 -280
  8. data/docs/Prismic/BasicNullCache.html +49 -48
  9. data/docs/Prismic/DefaultHTTPClient.html +85 -79
  10. data/docs/Prismic/Document.html +279 -83
  11. data/docs/Prismic/Error.html +52 -51
  12. data/docs/Prismic/Experiment.html +60 -59
  13. data/docs/Prismic/Experiments.html +61 -60
  14. data/docs/Prismic/Field.html +54 -53
  15. data/docs/Prismic/Form.html +70 -69
  16. data/docs/Prismic/Fragments/Color.html +60 -59
  17. data/docs/Prismic/Fragments/Date.html +52 -51
  18. data/docs/Prismic/Fragments/DocumentLink.html +78 -76
  19. data/docs/Prismic/Fragments/Embed.html +60 -59
  20. data/docs/Prismic/Fragments/FileLink.html +58 -57
  21. data/docs/Prismic/Fragments/Fragment.html +49 -48
  22. data/docs/Prismic/Fragments/GeoPoint.html +54 -53
  23. data/docs/Prismic/Fragments/Group.html +65 -63
  24. data/docs/Prismic/Fragments/GroupDocument.html +57 -55
  25. data/docs/Prismic/Fragments/Image/View.html +64 -63
  26. data/docs/Prismic/Fragments/Image/ViewDoesNotExistException.html +44 -43
  27. data/docs/Prismic/Fragments/Image.html +69 -68
  28. data/docs/Prismic/Fragments/ImageLink.html +50 -49
  29. data/docs/Prismic/Fragments/Link.html +53 -52
  30. data/docs/Prismic/Fragments/Multiple.html +58 -57
  31. data/docs/Prismic/Fragments/Number.html +54 -53
  32. data/docs/Prismic/Fragments/Select.html +52 -51
  33. data/docs/Prismic/Fragments/Separator.html +54 -53
  34. data/docs/Prismic/Fragments/Slice.html +58 -57
  35. data/docs/Prismic/Fragments/SliceZone.html +54 -53
  36. data/docs/Prismic/Fragments/StructuredText/Block/Embed.html +52 -51
  37. data/docs/Prismic/Fragments/StructuredText/Block/Heading.html +52 -51
  38. data/docs/Prismic/Fragments/StructuredText/Block/Image.html +66 -65
  39. data/docs/Prismic/Fragments/StructuredText/Block/ListItem.html +52 -51
  40. data/docs/Prismic/Fragments/StructuredText/Block/Paragraph.html +47 -46
  41. data/docs/Prismic/Fragments/StructuredText/Block/Preformatted.html +47 -46
  42. data/docs/Prismic/Fragments/StructuredText/Block/Text.html +68 -64
  43. data/docs/Prismic/Fragments/StructuredText/Block.html +47 -46
  44. data/docs/Prismic/Fragments/StructuredText/BlockGroup.html +54 -53
  45. data/docs/Prismic/Fragments/StructuredText/Span/Em.html +47 -46
  46. data/docs/Prismic/Fragments/StructuredText/Span/Hyperlink.html +53 -52
  47. data/docs/Prismic/Fragments/StructuredText/Span/Label.html +52 -51
  48. data/docs/Prismic/Fragments/StructuredText/Span/Strong.html +47 -46
  49. data/docs/Prismic/Fragments/StructuredText/Span.html +52 -51
  50. data/docs/Prismic/Fragments/StructuredText.html +59 -58
  51. data/docs/Prismic/Fragments/Text.html +54 -53
  52. data/docs/Prismic/Fragments/Timestamp.html +52 -51
  53. data/docs/Prismic/Fragments/WebLink.html +50 -49
  54. data/docs/Prismic/Fragments.html +39 -39
  55. data/docs/Prismic/HtmlSerializer.html +57 -56
  56. data/docs/Prismic/JsonParser.html +145 -143
  57. data/docs/Prismic/LinkResolver.html +73 -72
  58. data/docs/Prismic/LruCache.html +70 -69
  59. data/docs/Prismic/Predicates.html +261 -209
  60. data/docs/Prismic/Ref.html +86 -85
  61. data/docs/Prismic/Response.html +75 -73
  62. data/docs/Prismic/SearchForm/AuthenticationException.html +44 -43
  63. data/docs/Prismic/SearchForm/AuthorizationException.html +44 -43
  64. data/docs/Prismic/SearchForm/FormSearchException.html +44 -43
  65. data/docs/Prismic/SearchForm/NoRefSetException.html +44 -43
  66. data/docs/Prismic/SearchForm/RefNotFoundException.html +44 -43
  67. data/docs/Prismic/SearchForm/UnsupportedFormKind.html +44 -43
  68. data/docs/Prismic/SearchForm.html +97 -96
  69. data/docs/Prismic/Variation.html +57 -56
  70. data/docs/Prismic/WithFragments.html +115 -113
  71. data/docs/Prismic.html +91 -93
  72. data/docs/_index.html +32 -35
  73. data/docs/class_list.html +24 -27
  74. data/docs/css/full_list.css +32 -31
  75. data/docs/css/style.css +244 -91
  76. data/docs/file.README.html +39 -74
  77. data/docs/file_list.html +26 -26
  78. data/docs/frames.html +7 -16
  79. data/docs/index.html +39 -74
  80. data/docs/js/app.js +101 -77
  81. data/docs/js/full_list.js +170 -132
  82. data/docs/method_list.html +1995 -1189
  83. data/docs/top-level-namespace.html +34 -36
  84. data/lib/prismic/api.rb +10 -1
  85. data/lib/prismic/fragments/link.rb +3 -2
  86. data/lib/prismic/json_parsers.rb +14 -0
  87. data/lib/prismic/version.rb +1 -1
  88. data/lib/prismic.rb +47 -5
  89. data/spec/cache_spec.rb +2 -2
  90. data/spec/fragments_spec.rb +8 -1
  91. data/spec/json_parsers_spec.rb +13 -1
  92. data/spec/prismic_spec.rb +14 -7
  93. data/spec/responses_mocks/document.json +13 -0
  94. data/spec/simple_search_spec.rb +9 -0
  95. metadata +2 -2
data/docs/js/app.js CHANGED
@@ -1,3 +1,9 @@
1
+ (function() {
2
+
3
+ var localStorage = {}, sessionStorage = {};
4
+ try { localStorage = window.localStorage; } catch (e) { }
5
+ try { sessionStorage = window.sessionStorage; } catch (e) { }
6
+
1
7
  function createSourceLinks() {
2
8
  $('.method_details_list .source_code').
3
9
  before("<span class='showSource'>[<a href='#' class='toggleSource'>View source</a>]</span>");
@@ -16,7 +22,7 @@ function createDefineLinks() {
16
22
  $('.defines').after(" <a href='#' class='toggleDefines'>more...</a>");
17
23
  $('.toggleDefines').toggle(function() {
18
24
  tHeight = $(this).parent().prev().height();
19
- $(this).prev().show();
25
+ $(this).prev().css('display', 'inline');
20
26
  $(this).parent().prev().height($(this).parent().height());
21
27
  $(this).text("(less)");
22
28
  },
@@ -42,29 +48,39 @@ function createFullTreeLinks() {
42
48
  });
43
49
  }
44
50
 
45
- function fixBoxInfoHeights() {
46
- $('dl.box dd.r1, dl.box dd.r2').each(function() {
47
- $(this).prev().height($(this).height());
48
- });
49
- }
50
-
51
- function searchFrameLinks() {
51
+ function searchFrameButtons() {
52
52
  $('.full_list_link').click(function() {
53
53
  toggleSearchFrame(this, $(this).attr('href'));
54
54
  return false;
55
55
  });
56
+ window.addEventListener('message', function(e) {
57
+ if (e.data === 'navEscape') {
58
+ $('#nav').slideUp(100);
59
+ $('#search a').removeClass('active inactive');
60
+ $(window).focus();
61
+ }
62
+ });
63
+
64
+ $(window).resize(function() {
65
+ if ($('#search:visible').length === 0) {
66
+ $('#nav').removeAttr('style');
67
+ $('#search a').removeClass('active inactive');
68
+ $(window).focus();
69
+ }
70
+ });
56
71
  }
57
72
 
58
73
  function toggleSearchFrame(id, link) {
59
- var frame = $('#search_frame');
74
+ var frame = $('#nav');
60
75
  $('#search a').removeClass('active').addClass('inactive');
61
- if (frame.attr('src') == link && frame.css('display') != "none") {
76
+ if (frame.attr('src') === link && frame.css('display') !== "none") {
62
77
  frame.slideUp(100);
63
78
  $('#search a').removeClass('active inactive');
64
79
  }
65
80
  else {
66
81
  $(id).addClass('active').removeClass('inactive');
67
- frame.attr('src', link).slideDown(100);
82
+ if (frame.attr('src') !== link) frame.attr('src', link);
83
+ frame.slideDown(100);
68
84
  }
69
85
  }
70
86
 
@@ -74,43 +90,10 @@ function linkSummaries() {
74
90
  });
75
91
  }
76
92
 
77
- function framesInit() {
78
- if (hasFrames) {
79
- document.body.className = 'frames';
80
- $('#menu .noframes a').attr('href', document.location);
81
- try {
82
- window.top.document.title = $('html head title').text();
83
- } catch(error) {
84
- // some browsers will not allow this when serving from file://
85
- // but we don't want to stop the world.
86
- }
87
- }
88
- else {
89
- $('#menu .noframes a').text('frames').attr('href', framesUrl);
90
- }
91
- }
92
-
93
- function keyboardShortcuts() {
94
- if (window.top.frames.main) return;
95
- $(document).keypress(function(evt) {
96
- if (evt.altKey || evt.ctrlKey || evt.metaKey || evt.shiftKey) return;
97
- if (typeof evt.target !== "undefined" &&
98
- (evt.target.nodeName == "INPUT" ||
99
- evt.target.nodeName == "TEXTAREA")) return;
100
- switch (evt.charCode) {
101
- case 67: case 99: $('#class_list_link').click(); break; // 'c'
102
- case 77: case 109: $('#method_list_link').click(); break; // 'm'
103
- case 70: case 102: $('#file_list_link').click(); break; // 'f'
104
- default: break;
105
- }
106
- });
107
- }
108
-
109
93
  function summaryToggle() {
110
- $('.summary_toggle').click(function() {
111
- if (localStorage) {
112
- localStorage.summaryCollapsed = $(this).text();
113
- }
94
+ $('.summary_toggle').click(function(e) {
95
+ e.preventDefault();
96
+ localStorage.summaryCollapsed = $(this).text();
114
97
  $('.summary_toggle').each(function() {
115
98
  $(this).text($(this).text() == "collapse" ? "expand" : "collapse");
116
99
  var next = $(this).parent().parent().nextAll('ul.summary').first();
@@ -132,18 +115,9 @@ function summaryToggle() {
132
115
  });
133
116
  return false;
134
117
  });
135
- if (localStorage) {
136
- if (localStorage.summaryCollapsed == "collapse") {
137
- $('.summary_toggle').first().click();
138
- }
139
- else localStorage.summaryCollapsed = "expand";
140
- }
141
- }
142
-
143
- function fixOutsideWorldLinks() {
144
- $('a').each(function() {
145
- if (window.location.host != this.host) this.target = '_parent';
146
- });
118
+ if (localStorage.summaryCollapsed == "collapse") {
119
+ $('.summary_toggle').first().click();
120
+ } else { localStorage.summaryCollapsed = "expand"; }
147
121
  }
148
122
 
149
123
  function generateTOC() {
@@ -185,7 +159,7 @@ function generateTOC() {
185
159
  lastTag = thisTag;
186
160
  });
187
161
  if (!show) return;
188
- html = '<div id="toc"><p class="title"><a class="hide_toc" href="#"><strong>Table of Contents</strong></a> <small>(<a href="#" class="float_toc">left</a>)</small></p></div>';
162
+ html = '<div id="toc"><p class="title hide_toc"><a href="#"><strong>Table of Contents</strong></a></p></div>';
189
163
  $('#content').prepend(html);
190
164
  $('#toc').append(_toc);
191
165
  $('#toc .hide_toc').toggle(function() {
@@ -197,23 +171,73 @@ function generateTOC() {
197
171
  $('#toc').toggleClass('hidden');
198
172
  $('#toc .title small').toggle();
199
173
  });
200
- $('#toc .float_toc').toggle(function() {
201
- $(this).text('float');
202
- $('#toc').toggleClass('nofloat');
203
- }, function() {
204
- $(this).text('left');
205
- $('#toc').toggleClass('nofloat');
174
+ }
175
+
176
+ function navResizeFn(e) {
177
+ if (e.which !== 1) {
178
+ navResizeFnStop();
179
+ return;
180
+ }
181
+
182
+ sessionStorage.navWidth = e.pageX.toString();
183
+ $('.nav_wrap').css('width', e.pageX);
184
+ $('.nav_wrap').css('-ms-flex', 'inherit');
185
+ }
186
+
187
+ function navResizeFnStop() {
188
+ $(window).unbind('mousemove', navResizeFn);
189
+ window.removeEventListener('message', navMessageFn, false);
190
+ }
191
+
192
+ function navMessageFn(e) {
193
+ if (e.data.action === 'mousemove') navResizeFn(e.data.event);
194
+ if (e.data.action === 'mouseup') navResizeFnStop();
195
+ }
196
+
197
+ function navResizer() {
198
+ $('#resizer').mousedown(function(e) {
199
+ e.preventDefault();
200
+ $(window).mousemove(navResizeFn);
201
+ window.addEventListener('message', navMessageFn, false);
206
202
  });
203
+ $(window).mouseup(navResizeFnStop);
204
+
205
+ if (sessionStorage.navWidth) {
206
+ navResizeFn({which: 1, pageX: parseInt(sessionStorage.navWidth, 10)});
207
+ }
207
208
  }
208
209
 
209
- $(framesInit);
210
- $(createSourceLinks);
211
- $(createDefineLinks);
212
- $(createFullTreeLinks);
213
- $(fixBoxInfoHeights);
214
- $(searchFrameLinks);
215
- $(linkSummaries);
216
- $(keyboardShortcuts);
217
- $(summaryToggle);
218
- $(fixOutsideWorldLinks);
219
- $(generateTOC);
210
+ function navExpander() {
211
+ var done = false, timer = setTimeout(postMessage, 500);
212
+ function postMessage() {
213
+ if (done) return;
214
+ clearTimeout(timer);
215
+ var opts = { action: 'expand', path: pathId };
216
+ document.getElementById('nav').contentWindow.postMessage(opts, '*');
217
+ done = true;
218
+ }
219
+
220
+ window.addEventListener('message', function(event) {
221
+ if (event.data === 'navReady') postMessage();
222
+ return false;
223
+ }, false);
224
+ }
225
+
226
+ function mainFocus() {
227
+ $('#main')[0].focus();
228
+ }
229
+
230
+ $(document).ready(function() {
231
+ navResizer();
232
+ navExpander();
233
+ createSourceLinks();
234
+ createDefineLinks();
235
+ createFullTreeLinks();
236
+ searchFrameButtons();
237
+ linkSummaries();
238
+ summaryToggle();
239
+ generateTOC();
240
+ mainFocus();
241
+ });
242
+
243
+ })();
data/docs/js/full_list.js CHANGED
@@ -1,8 +1,8 @@
1
- var inSearch = null;
2
- var searchIndex = 0;
1
+ (function() {
2
+
3
+ var $clicked = $(null);
4
+ var searchTimeout = null;
3
5
  var searchCache = [];
4
- var searchString = '';
5
- var regexSearchString = '';
6
6
  var caseSensitiveMatch = false;
7
7
  var ignoreKeyCodeMin = 8;
8
8
  var ignoreKeyCodeMax = 46;
@@ -12,167 +12,205 @@ RegExp.escape = function(text) {
12
12
  return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
13
13
  }
14
14
 
15
- function fullListSearch() {
16
- // generate cache
17
- searchCache = [];
18
- $('#full_list li').each(function() {
19
- var link = $(this).find('.object_link a');
20
- if (link.length === 0) return;
21
- var fullName = link.attr('title').split(' ')[0];
22
- searchCache.push({name:link.text(), fullName:fullName, node:$(this), link:link});
15
+ function escapeShortcut() {
16
+ $(document).keydown(function(evt) {
17
+ if (evt.which == 27) {
18
+ window.parent.postMessage('navEscape', '*');
19
+ }
23
20
  });
21
+ }
24
22
 
25
- $('#search input').keyup(function(event) {
26
- if ((event.keyCode > ignoreKeyCodeMin && event.keyCode < ignoreKeyCodeMax)
27
- || event.keyCode == commandKey)
28
- return;
29
- searchString = this.value;
30
- caseSensitiveMatch = searchString.match(/[A-Z]/) != null;
31
- regexSearchString = RegExp.escape(searchString);
32
- if (caseSensitiveMatch) {
33
- regexSearchString += "|" +
34
- $.map(searchString.split(''), function(e) { return RegExp.escape(e); }).
35
- join('.+?');
36
- }
37
- if (searchString === "") {
38
- clearTimeout(inSearch);
39
- inSearch = null;
40
- $('ul .search_uncollapsed').removeClass('search_uncollapsed');
41
- $('#full_list, #content').removeClass('insearch');
42
- $('#full_list li').removeClass('found').each(function() {
43
-
44
- var link = $(this).find('.object_link a');
45
- if (link.length > 0) link.text(link.text());
23
+ function navResizer() {
24
+ $(window).mousemove(function(e) {
25
+ window.parent.postMessage({
26
+ action: 'mousemove', event: {pageX: e.pageX, which: e.which}
27
+ }, '*');
28
+ }).mouseup(function(e) {
29
+ window.parent.postMessage({action: 'mouseup'}, '*');
30
+ });
31
+ window.parent.postMessage("navReady", "*");
32
+ }
33
+
34
+ function clearSearchTimeout() {
35
+ clearTimeout(searchTimeout);
36
+ searchTimeout = null;
37
+ }
38
+
39
+ function enableLinks() {
40
+ // load the target page in the parent window
41
+ $('#full_list li').on('click', function(evt) {
42
+ $('#full_list li').removeClass('clicked');
43
+ $clicked = $(this);
44
+ $clicked.addClass('clicked');
45
+ evt.stopPropagation();
46
+
47
+ if (evt.target.tagName === 'A') return true;
48
+
49
+ var elem = $clicked.find('> .item .object_link a')[0];
50
+ var e = evt.originalEvent;
51
+ var newEvent = new MouseEvent(evt.originalEvent.type);
52
+ newEvent.initMouseEvent(e.type, e.canBubble, e.cancelable, e.view, e.detail, e.screenX, e.screenY, e.clientX, e.clientY, e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, e.button, e.relatedTarget);
53
+ elem.dispatchEvent(newEvent);
54
+ evt.preventDefault();
55
+ return false;
56
+ });
57
+ }
58
+
59
+ function enableToggles() {
60
+ // show/hide nested classes on toggle click
61
+ $('#full_list a.toggle').on('click', function(evt) {
62
+ evt.stopPropagation();
63
+ evt.preventDefault();
64
+ $(this).parent().parent().toggleClass('collapsed');
65
+ highlight();
66
+ });
67
+ }
68
+
69
+ function populateSearchCache() {
70
+ $('#full_list li .item').each(function() {
71
+ var $node = $(this);
72
+ var $link = $node.find('.object_link a');
73
+ if ($link.length > 0) {
74
+ searchCache.push({
75
+ node: $node,
76
+ link: $link,
77
+ name: $link.text(),
78
+ fullName: $link.attr('title').split(' ')[0]
46
79
  });
47
- if (clicked) {
48
- clicked.parents('ul').each(function() {
49
- $(this).removeClass('collapsed').prev().removeClass('collapsed');
50
- });
51
- }
52
- highlight();
53
80
  }
54
- else {
55
- if (inSearch) clearTimeout(inSearch);
56
- searchIndex = 0;
57
- lastRowClass = '';
58
- $('#full_list, #content').addClass('insearch');
59
- $('#noresults').text('');
60
- searchItem();
81
+ });
82
+ }
83
+
84
+ function enableSearch() {
85
+ $('#search input').keyup(function(event) {
86
+ if (ignoredKeyPress(event)) return;
87
+ if (this.value === "") {
88
+ clearSearch();
89
+ } else {
90
+ performSearch(this.value);
61
91
  }
62
92
  });
63
93
 
64
- $('#search input').focus();
65
- $('#full_list').after("<div id='noresults'></div>");
94
+ $('#full_list').after("<div id='noresults' style='display:none'></div>");
95
+ }
96
+
97
+ function ignoredKeyPress(event) {
98
+ if (
99
+ (event.keyCode > ignoreKeyCodeMin && event.keyCode < ignoreKeyCodeMax) ||
100
+ (event.keyCode == commandKey)
101
+ ) {
102
+ return true;
103
+ } else {
104
+ return false;
105
+ }
106
+ }
107
+
108
+ function clearSearch() {
109
+ clearSearchTimeout();
110
+ $('#full_list .found').removeClass('found').each(function() {
111
+ var $link = $(this).find('.object_link a');
112
+ $link.text($link.text());
113
+ });
114
+ $('#full_list, #content').removeClass('insearch');
115
+ $clicked.parents().removeClass('collapsed');
116
+ highlight();
117
+ }
118
+
119
+ function performSearch(searchString) {
120
+ clearSearchTimeout();
121
+ $('#full_list, #content').addClass('insearch');
122
+ $('#noresults').text('').hide();
123
+ partialSearch(searchString, 0);
66
124
  }
67
125
 
68
- var lastRowClass = '';
69
- function searchItem() {
70
- for (var i = 0; i < searchCache.length / 50; i++) {
71
- var item = searchCache[searchIndex];
126
+ function partialSearch(searchString, offset) {
127
+ var lastRowClass = '';
128
+ var i = null;
129
+ for (i = offset; i < Math.min(offset + 50, searchCache.length); i++) {
130
+ var item = searchCache[i];
72
131
  var searchName = (searchString.indexOf('::') != -1 ? item.fullName : item.name);
73
- var matchString = regexSearchString;
132
+ var matchString = buildMatchString(searchString);
74
133
  var matchRegexp = new RegExp(matchString, caseSensitiveMatch ? "" : "i");
75
134
  if (searchName.match(matchRegexp) == null) {
76
135
  item.node.removeClass('found');
136
+ item.link.text(item.link.text());
77
137
  }
78
138
  else {
79
- item.node.css('padding-left', '10px').addClass('found');
80
- item.node.parents().addClass('search_uncollapsed');
139
+ item.node.addClass('found');
81
140
  item.node.removeClass(lastRowClass).addClass(lastRowClass == 'r1' ? 'r2' : 'r1');
82
141
  lastRowClass = item.node.hasClass('r1') ? 'r1' : 'r2';
83
142
  item.link.html(item.name.replace(matchRegexp, "<strong>$&</strong>"));
84
143
  }
85
-
86
- if (searchCache.length === searchIndex + 1) {
87
- searchDone();
88
- return;
89
- }
90
- else {
91
- searchIndex++;
92
- }
93
144
  }
94
- inSearch = setTimeout('searchItem()', 0);
145
+ if(i == searchCache.length) {
146
+ searchDone();
147
+ } else {
148
+ searchTimeout = setTimeout(function() {
149
+ partialSearch(searchString, i);
150
+ }, 0);
151
+ }
95
152
  }
96
153
 
97
154
  function searchDone() {
98
- highlight(true);
155
+ searchTimeout = null;
156
+ highlight();
99
157
  if ($('#full_list li:visible').size() === 0) {
100
158
  $('#noresults').text('No results were found.').hide().fadeIn();
101
- }
102
- else {
103
- $('#noresults').text('');
159
+ } else {
160
+ $('#noresults').text('').hide();
104
161
  }
105
162
  $('#content').removeClass('insearch');
106
- clearTimeout(inSearch);
107
- inSearch = null;
108
- }
109
-
110
- clicked = null;
111
- function linkList() {
112
- $('#full_list li, #full_list li a:last').click(function(evt) {
113
- if ($(this).hasClass('toggle')) return true;
114
- if (this.tagName.toLowerCase() == "li") {
115
- if ($(this).find('.object_link a').length === 0) {
116
- $(this).children('a.toggle').click();
117
- return false;
118
- }
119
- var toggle = $(this).children('a.toggle');
120
- if (toggle.size() > 0 && evt.pageX < toggle.offset().left) {
121
- toggle.click();
122
- return false;
123
- }
124
- }
125
- if (clicked) clicked.removeClass('clicked');
126
- var win = window.top.frames.main ? window.top.frames.main : window.parent;
127
- if (this.tagName.toLowerCase() == "a") {
128
- clicked = $(this).parents('li').addClass('clicked');
129
- win.location = this.href;
130
- }
131
- else {
132
- clicked = $(this).addClass('clicked');
133
- win.location = $(this).find('a:last').attr('href');
134
- }
135
- return false;
136
- });
137
163
  }
138
164
 
139
- function collapse() {
140
- if (!$('#full_list').hasClass('class')) return;
141
- $('#full_list.class a.toggle').click(function() {
142
- $(this).parent().toggleClass('collapsed').next().toggleClass('collapsed');
143
- highlight();
144
- return false;
145
- });
146
- $('#full_list.class ul').each(function() {
147
- $(this).addClass('collapsed').prev().addClass('collapsed');
148
- });
149
- $('#full_list.class').children().removeClass('collapsed');
150
- highlight();
165
+ function buildMatchString(searchString, event) {
166
+ caseSensitiveMatch = searchString.match(/[A-Z]/) != null;
167
+ var regexSearchString = RegExp.escape(searchString);
168
+ if (caseSensitiveMatch) {
169
+ regexSearchString += "|" +
170
+ $.map(searchString.split(''), function(e) { return RegExp.escape(e); }).
171
+ join('.+?');
172
+ }
173
+ return regexSearchString;
151
174
  }
152
175
 
153
- function highlight(no_padding) {
154
- var n = 1;
155
- $('#full_list li:visible').each(function() {
156
- var next = n == 1 ? 2 : 1;
157
- $(this).removeClass("r" + next).addClass("r" + n);
158
- if (!no_padding && $('#full_list').hasClass('class')) {
159
- $(this).css('padding-left', (10 + $(this).parents('ul').size() * 15) + 'px');
160
- }
161
- n = next;
176
+ function highlight() {
177
+ $('#full_list li:visible').each(function(n) {
178
+ $(this).removeClass('even odd').addClass(n % 2 == 0 ? 'odd' : 'even');
162
179
  });
163
180
  }
164
181
 
165
- function escapeShortcut() {
166
- $(document).keydown(function(evt) {
167
- if (evt.which == 27) {
168
- $('#search_frame', window.top.document).slideUp(100);
169
- $('#search a', window.top.document).removeClass('active inactive');
170
- $(window.top).focus();
171
- }
172
- });
182
+ /**
183
+ * Expands the tree to the target element and its immediate
184
+ * children.
185
+ */
186
+ function expandTo(path) {
187
+ var $target = $(document.getElementById('object_' + path));
188
+ $target.addClass('clicked');
189
+ $target.removeClass('collapsed');
190
+ $target.parentsUntil('#full_list', 'li').removeClass('collapsed');
191
+ if($target[0]) {
192
+ window.scrollTo(window.scrollX, $target.offset().top - 250);
193
+ highlight();
194
+ }
195
+ }
196
+
197
+ function windowEvents(event) {
198
+ var msg = event.data;
199
+ if (msg.action === "expand") {
200
+ expandTo(msg.path);
201
+ }
202
+ return false;
173
203
  }
174
204
 
175
- $(escapeShortcut);
176
- $(fullListSearch);
177
- $(linkList);
178
- $(collapse);
205
+ window.addEventListener("message", windowEvents, false);
206
+
207
+ $(document).ready(function() {
208
+ escapeShortcut();
209
+ navResizer();
210
+ enableLinks();
211
+ enableToggles();
212
+ populateSearchCache();
213
+ enableSearch();
214
+ });
215
+
216
+ })();