UNPKG

12.7 kBJavaScriptView Raw
1(function ($) {
2 $(document).ready(function() {
3 window.index = lunr(function () {
4 this.field('title', {boost: 10});
5 this.field('body');
6 this.ref('href');
7 });
8 window.index.pipeline.reset();
9
10 window.index.add({
11 href: 'http://materializecss.com/about.html',
12 title: 'About',
13 body: 'Created and designed by Google, Material Design is a design language that combines the classic principles of successful design along with innovation and technology. Google"s goal is to develop a system of design that allows for a unified user experience across all their products on any platform.'
14 });
15
16 window.index.add({
17 href: 'http://materializecss.com/badges.html',
18 title: 'Badges',
19 body: 'Badges can notify you that there are new or unread messages or notifications.'
20 });
21
22 window.index.add({
23 href: 'http://materializecss.com/buttons.html',
24 title: 'Buttons',
25 body: 'There are 3 main button types described in material design. The raised button is a standard button that signify actions and seek to give depth to a mostly flat page. The floating circular action button is meant for very important functions. Flat buttons are usually used within elements that already have depth like cards or modals.'
26 });
27
28 window.index.add({
29 href: 'http://materializecss.com/cards.html',
30 title: 'Cards',
31 body: 'Cards are a convenient means of displaying content composed of different types of objects. They’re also well-suited for presenting similar objects whose size or supported actions can vary considerably, like photos with captions of variable length.'
32 });
33
34 window.index.add({
35 href: 'http://materializecss.com/chips.html',
36 title: 'Chips',
37 body: 'Chips can be used to represent small blocks of information. They are most commonly used either for contacts or for tags.'
38 });
39
40 window.index.add({
41 href: 'http://materializecss.com/collapsible.html',
42 title: 'Collapsible',
43 body: 'Collapsibles are accordion elements that expand when clicked on. They allow you to hide content that is not immediately relevant to the user.'
44 });
45
46 window.index.add({
47 href: 'http://materializecss.com/collections.html',
48 title: 'Collections',
49 body: 'Collections allow you to group list objects together.'
50 });
51
52 window.index.add({
53 href: 'http://materializecss.com/color.html',
54 title: 'Color',
55 body: 'Here is a color palette based on the material design base colors. Each of these colors is defined with a base color class and an optional lighten or darken class.'
56 });
57
58 window.index.add({
59 href: 'http://materializecss.com/dialogs.html',
60 title: 'dialogs tooltips toasts',
61 body: 'Dialogs are content that are not original visible on a page but show up with extra information if needed. The transitions should make the appearance of the dialog make sense and not jarring to the user.'
62 });
63
64 window.index.add({
65 href: 'http://materializecss.com/dropdown.html',
66 title: 'dropdown',
67 body: 'Add a dropdown list to any button.'
68 });
69
70 window.index.add({
71 href: 'http://materializecss.com/footer.html',
72 title: 'footer',
73 body: 'Footers are a great way to organize a lot of site navigation and information at the end of a page. This is where the user will look once hes finished scrolling through the current page or is looking for additional information about your website.'
74 });
75
76 window.index.add({
77 href: 'http://materializecss.com/forms.html',
78 title: 'forms select radio checkbox switch range textarea',
79 body: 'Forms are the standard way to receive user inputted data. The transitions and smoothness of these elements are very important because of the inherent user interaction associated with forms.'
80 });
81
82 window.index.add({
83 href: 'http://materializecss.com/fullscreen-slider-demo.html',
84 title: 'Fullscreen slider demo',
85 body: 'Fullscreen slider demo'
86 });
87
88 window.index.add({
89 href: 'http://materializecss.com/getting-started.html',
90 title: 'Getting Started',
91 body: 'Learn how to easily start using Materialize in your website.'
92 });
93
94 window.index.add({
95 href: 'http://materializecss.com/grid.html',
96 title: 'Grid',
97 body: 'We are using a standard 12 column fluid responsive grid system. The grid helps you layout your page in an ordered, easy fashion.'
98 });
99
100 window.index.add({
101 href: 'http://materializecss.com/helpers.html',
102 title: 'Helpers',
103 body: 'helper classes'
104 });
105
106 window.index.add({
107 href: 'http://materializecss.com/icons.html',
108 title: 'icons',
109 body: 'We have included 740 Material Design Icons courtesy of Google'
110 });
111
112 window.index.add({
113 href: 'http://materializecss.com/media-css.html',
114 title: 'Media CSS',
115 body: 'Media CSS classes'
116 });
117
118 window.index.add({
119 href: 'http://materializecss.com/media.html',
120 title: 'Media JavaScript slider materialbox',
121 body: 'Media components include things that have to do with large media objects like Images, Video, Audio, etc.'
122 });
123
124 window.index.add({
125 href: 'http://materializecss.com/mobile.html',
126 title: 'Mobile',
127 body: 'Mobile only interactive components.'
128 });
129
130 window.index.add({
131 href: 'http://materializecss.com/modals.html',
132 title: 'modals',
133 body: 'Use a modal for dialog boxes, confirmation messages, or other content that can be called up.'
134 });
135
136 window.index.add({
137 href: 'http://materializecss.com/navbar.html',
138 title: 'navbar',
139 body: 'The navbar is fully contained by an HTML5 Nav tag. Inside a recommended container div, there are 2 main parts of the navbar. A logo or brand link, and the navigations links. You can align these links to the left or right.'
140 });
141
142 window.index.add({
143 href: 'http://materializecss.com/pagination.html',
144 title: 'pagination',
145 body: 'Add pagination links to help split up your long content into shorter, easier to understand blocks.'
146 });
147
148 window.index.add({
149 href: 'http://materializecss.com/parallax.html',
150 title: 'parallax',
151 body: 'Parallax is an effect where the background content or image in this case, is moved at a different speed than the foreground content while scrolling.'
152 });
153
154 window.index.add({
155 href: 'http://materializecss.com/preloader.html',
156 title: 'preloader',
157 body: 'If you have content that will take a long time to load, you should give the user feedback. For this reason we provide a number activity + progress indicators.'
158 });
159
160 window.index.add({
161 href: 'http://materializecss.com/pushpin.html',
162 title: 'Pushpin',
163 body: 'Pushpin is our fixed positioning plugin. You can check out our live examples: the fixed Table of Contents on the right.'
164 });
165
166 window.index.add({
167 href: 'http://materializecss.com/sass.html',
168 title: 'Sass',
169 body: 'When using Sass, you can change the color scheme of your site extremely quickly.'
170 });
171
172 window.index.add({
173 href: 'http://materializecss.com/scrollfire.html',
174 title: 'scrollFire',
175 body: 'ScrollFire is a jQuery Plugin that executes callback functions depending on how far into the page you"ve scrolled.'
176 });
177
178 window.index.add({
179 href: 'http://materializecss.com/scrollspy.html',
180 title: 'scrollspy',
181 body: 'Scrollspy is a jQuery plugin that tracks certain elements and which element the users screen is currently centered on.'
182 });
183
184 window.index.add({
185 href: 'http://materializecss.com/shadow.html',
186 title: 'shadow',
187 body: 'In material design, everything should have a certain z-depth that determines how far raised or close to the page the element is.'
188 });
189
190 window.index.add({
191 href: 'http://materializecss.com/showcase.html',
192 title: 'showcase',
193 body: 'Here is our showcase of websites that use materialize.'
194 });
195
196 window.index.add({
197 href: 'http://materializecss.com/side-nav.html',
198 title: 'sideNav side Nav',
199 body: 'This is a slide out menu. You can add a dropdown to your sidebar by using our collapsible component.'
200 });
201
202 window.index.add({
203 href: 'http://materializecss.com/table.html',
204 title: 'table',
205 body: 'Tables are a nice way to organize a lot of data. We provide a few utility classes to help you style your table as easily as possible.'
206 });
207
208 window.index.add({
209 href: 'http://materializecss.com/tabs.html',
210 title: 'tabs',
211 body: 'The tabs structure consists of an unordered list of tabs that have hashes corresponding to tab ids. Then when you click on each tab, only the container with the corresponding tab id will become visible.'
212 });
213
214 window.index.add({
215 href: 'http://materializecss.com/transitions.html',
216 title: 'transitions animation',
217 body: 'Weve made some custom animation functions that will transition your content.'
218 });
219
220 window.index.add({
221 href: 'http://materializecss.com/typography.html',
222 title: 'Typography',
223 body: 'font, headers, blockquotes, flow text.'
224 });
225
226 window.index.add({
227 href: 'http://materializecss.com/waves.html',
228 title: 'waves',
229 body: 'Waves is an external library that weve included in Materialize to allow us to create the ink effect outlined in Material Design'
230 });
231
232 // icon click
233 $('ul#nav-mobile li.search .search-wrapper i.material-icons').click(function() {
234 if ($('.search-results .focused').length) {
235 $('.search-results .focused').first()[0].click();
236 } else if ($('.search-results').children().length) {
237 $('.search-results').children().first()[0].click();
238 }
239 });
240
241 var renderResults = function(results) {
242 var resultsContainer = $('.search-results');
243 resultsContainer.empty();
244 Array.prototype.forEach.call(results, function(result) {
245 var resultDiv = $('<a href=' + result[1] + '>' + result[0] + '</a>');
246 resultsContainer.append(resultDiv);
247 });
248 };
249
250 var debounce = function (fn) {
251 var timeout;
252 return function () {
253 var args = Array.prototype.slice.call(arguments),
254 ctx = this;
255
256 clearTimeout(timeout);
257 timeout = setTimeout(function () {
258 fn.apply(ctx, args);
259 }, 100);
260 };
261 };
262
263 $('input#search').focus(function() { $(this).parent().addClass('focused'); });
264 $('input#search').blur(function() {
265 if (!$(this).val()) {
266 $(this).parent().removeClass('focused');
267 }
268 });
269
270 $('input#search').bind('keyup', debounce(function (e) {
271 if ($(this).val() < 2) {
272 renderResults([]);
273 return;
274 }
275
276 if (e.which === 38 || e.which === 40 || e.keyCode === 13) return;
277
278 var query = $(this).val();
279 var results = window.index.search(query).slice(0, 6).map(function (result) {
280 var href = result.ref.split('http://materializecss.com/')[1];
281 return [href.charAt(0).toUpperCase() + href.slice(1), result.ref];
282 });
283 renderResults(results);
284 }));
285
286
287 $('input#search').bind('keydown', debounce(function (e) {
288 // Escape.
289 if (e.keyCode === 27) {
290 $(this).val('');
291 $(this).blur();
292 renderResults([]);
293 return;
294 } else if (e.keyCode === 13) {
295 // enter
296 if ($('.search-results .focused').length) {
297 $('.search-results .focused').first()[0].click();
298 } else if ($('.search-results').children().length) {
299 $('.search-results').children().first()[0].click();
300 }
301 return;
302 }
303
304 // Arrow keys.
305 var focused;
306 switch(e.which) {
307 case 38: // up
308 if ($('.search-results .focused').length) {
309 focused = $('.search-results .focused');
310 focused.removeClass('focused');
311 focused.prev().addClass('focused');
312 }
313 break;
314
315 case 40: // down
316 if (!$('.search-results .focused').length) {
317 focused = $('.search-results').children().first();
318 focused.addClass('focused');
319 } else {
320 focused = $('.search-results .focused');
321 if (focused.next().length) {
322 focused.removeClass('focused');
323 focused.next().addClass('focused');
324 }
325 }
326 break;
327
328 default: return; // exit this handler for other keys
329 }
330 e.preventDefault();
331 }));
332
333
334
335 });
336}( jQuery ));
\No newline at end of file