This repository was archived by the owner on Jun 5, 2026. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathlibanswers.js
More file actions
342 lines (275 loc) · 13 KB
/
Copy pathlibanswers.js
File metadata and controls
342 lines (275 loc) · 13 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
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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
/* This file contains breakpoint.js and custom code for the UCSC Libguides site. Add this in the Custom JS/CSS box here: https://ucsc.libanswers.com/admin/sysset?m=look, wrapped in <script></script> tags. This is pasted after the css code.
*/
/*
Breakpoints.js
version 1.0
Creates handy events for your responsive design breakpoints
Copyright 2011 XOXCO, Inc
http://xoxco.com/
Documentation for this plugin lives here:
http://xoxco.com/projects/code/breakpoints
Licensed under the MIT license:
http://www.opensource.org/licenses/mit-license.php
*/
(function($) {
var lastSize = 0;
var interval = null;
$.fn.resetBreakpoints = function() {
$(window).unbind('resize');
if (interval) {
clearInterval(interval);
}
lastSize = 0;
};
$.fn.setBreakpoints = function(settings) {
var options = jQuery.extend({
distinct: true,
breakpoints: new Array(320,480,768,1024)
},settings);
interval = setInterval(function() {
var w = $(window).width();
var done = false;
for (var bp in options.breakpoints.sort(function(a,b) { return (b-a) })) {
// fire onEnter when a browser expands into a new breakpoint
// if in distinct mode, remove all other breakpoints first.
if (!done && w >= options.breakpoints[bp] && lastSize < options.breakpoints[bp]) {
if (options.distinct) {
for (var x in options.breakpoints.sort(function(a,b) { return (b-a) })) {
if ($('body').hasClass('breakpoint-' + options.breakpoints[x])) {
$('body').removeClass('breakpoint-' + options.breakpoints[x]);
$(window).trigger('exitBreakpoint' + options.breakpoints[x]);
}
}
done = true;
}
$('body').addClass('breakpoint-' + options.breakpoints[bp]);
$(window).trigger('enterBreakpoint' + options.breakpoints[bp]);
}
// fire onExit when browser contracts out of a larger breakpoint
if (w < options.breakpoints[bp] && lastSize >= options.breakpoints[bp]) {
$('body').removeClass('breakpoint-' + options.breakpoints[bp]);
$(window).trigger('exitBreakpoint' + options.breakpoints[bp]);
}
// if in distinct mode, fire onEnter when browser contracts into a smaller breakpoint
if (
options.distinct && // only one breakpoint at a time
w >= options.breakpoints[bp] && // and we are in this one
w < options.breakpoints[bp-1] && // and smaller than the bigger one
lastSize > w && // and we contracted
lastSize >0 && // and this is not the first time
!$('body').hasClass('breakpoint-' + options.breakpoints[bp]) // and we aren't already in this breakpoint
) {
$('body').addClass('breakpoint-' + options.breakpoints[bp]);
$(window).trigger('enterBreakpoint' + options.breakpoints[bp]);
}
}
// set up for next call
if (lastSize != w) {
lastSize = w;
}
},250);
};
})(jQuery);
/* Spencer.js scripts */
jQuery( document ).ready(function() {
/* search form placeholder text */
jQuery('form.google-cse input.form-text').attr("placeholder", "Search this Site");
//replace sidebar with link for mobile
jQuery( '<h2 class="hours-link"><a href="http://guides.library.ucsc.edu/libraryhours">Today\'s Hours</a></h2>' ).insertBefore( 'body.front #block-multisearch-multisearch' );
jQuery ( 'body.front #sidebar' ).addClass('hidden');
jQuery ( 'body.front .navbar' ).addClass('hidden');
var viewportWidth = jQuery(window).width();
if (viewportWidth > 767) {
jQuery( 'body.front #sidebar' ).removeClass('hidden');
jQuery( 'body.front .navbar' ).removeClass('hidden');
jQuery ( 'body.front h2.hours-link' ).addClass('hidden');
jQuery('.view-news').addClass('view-news-767plus');
}
//add classes to body
jQuery('body').addClass('mobile');
// modify the html of the secondary menu
var menuButton = '<div class="menubutton">Menu</div>';
jQuery( menuButton ).insertBefore( '.header-secondary-menu ul.menu' );
jQuery('.menubutton').click(function (e) {
e.preventDefault();
jQuery('.header-secondary-menu ul.menu').toggle();
});
jQuery('.menu-toggle').siblings('.mega-hook').hide();
jQuery('.research.menu-toggle').click(function () {
jQuery('.header-secondary-menu .mega-research').toggle();
});
jQuery('.services.menu-toggle').click(function () {
jQuery('.header-secondary-menu .mega-services').toggle();
});
jQuery('.collections.menu-toggle').click(function () {
jQuery('.header-secondary-menu .mega-collections').toggle();
});
jQuery('.about.menu-toggle').click(function () {
jQuery('.header-secondary-menu .mega-about').toggle();
});
if (viewportWidth > 860) {
jQuery('.view-news').addClass('view-news-860plus');
//remove mobile class to body
jQuery('body').removeClass('mobile');
jQuery('body').addClass('notmobile');
//modify secondary menu
jQuery('.header-secondary-menu ul.menu a.mainlink').removeClass('menu-toggle');
jQuery('div.mega-hook').addClass('mega-menu');
jQuery('.header-secondary-menu a.research').html('<span>Research</span><img src="https://library.ucsc.edu/sites/default/files/external/images/header-menu-arrow.png" alt="navigation arrow"><br>Tools & Help');
jQuery('.header-secondary-menu a.services').html('<span>Services</span><img src="https://library.ucsc.edu/sites/default/files/external/images/header-menu-arrow.png" alt="navigation arrow"><br>Borrowing & Spaces');
jQuery('.header-secondary-menu a.collections').html('<span>Collections</span><img src="https://library.ucsc.edu/sites/default/files/external/images/header-menu-arrow.png" alt="navigation arrow"><br>& Scholarly Communication');
jQuery('.header-secondary-menu a.about').html('<span>About</span><img src="https://library.ucsc.edu/sites/default/files/external/images/header-menu-arrow.png" alt="navigation arrow"><br>Visit & Contact');
}
//modify the html of the site search text field
//jQuery('.header-main-menu .form-type-textfield').html('<input type="text" id="edit-search-block-form--2" name="search_block_form" value="" size="15" maxlength="128" class="form-text" /><img class="search" src="https://library.ucsc.edu/sites/default/files/external/images/header-search.png">');
// toggle the visibility of the site search text field when the spyglass graphic is clicked
//jQuery ('.header-main-sitesearch form .form-text').addClass('form-hide');
//jQuery('.header-main-sitesearch form .search').click(function (e) {
//e.preventDefault();
//jQuery('.header-main-sitesearch form .form-text').toggle('fast');
//});
// collapse the sidebar on mobile
jQuery('[data-toggle=offcanvas]').click(function() {
jQuery('.row-offcanvas').toggleClass('active');
});
});
$(window).setBreakpoints({
distinct: true,
breakpoints: [
767,
860,
1000,
1350
]
});
jQuery(window).bind('enterBreakpoint767',function() {
jQuery('.view-news').addClass('view-news-767plus');
jQuery( 'body.front #sidebar' ).removeClass('hidden');
jQuery( 'body.front .navbar' ).removeClass('hidden');
jQuery ( 'body.front h2.hours-link' ).addClass('hidden');
});
jQuery(window).bind('exitBreakpoint767',function() {
//jQuery('.view-news').removeClass('view-news-767plus');
jQuery ( 'body.front h2.hours-link' ).removeClass('hidden');
});
//changes to secondary menu
jQuery(window).bind('enterBreakpoint860',function() {
jQuery('.view-news').addClass('view-news-860plus');
jQuery( 'body.front #sidebar' ).removeClass('hidden');
jQuery( 'body.front .navbar' ).removeClass('hidden');
jQuery ( 'body.front h2.hours-link' ).addClass('hidden');
//remove mobile class from body
jQuery('body').removeClass('mobile');
jQuery('body').addClass('notmobile');
//changes to secondary menu
jQuery('.header-secondary-menu ul.menu a.mainlink').removeClass('menu-toggle');
jQuery('div.mega-hook').addClass('mega-menu');
jQuery( '.header-secondary-menu ul' ).show();
jQuery('.header-secondary-menu a.research').html('<span>Research</span><img src="https://library.ucsc.edu/sites/default/files/external/images/header-menu-arrow.png" alt="navigation arrow"><br>Tools & Help');
jQuery('.header-secondary-menu a.services').html('<span>Services</span><img src="https://library.ucsc.edu/sites/default/files/external/images/header-menu-arrow.png" alt="navigation arrow"><br>Borrowing & Spaces');
jQuery('.header-secondary-menu a.collections').html('<span>Collections</span><img src="https://library.ucsc.edu/sites/default/files/external/images/header-menu-arrow.png" alt="navigation arrow"><br>& Scholarly Communication');
jQuery('.header-secondary-menu a.about').html('<span>About</span><img src="https://library.ucsc.edu/sites/default/files/external/images/header-menu-arrow.png" alt="navigation arrow"><br>Visit & Contact');
});
jQuery(window).bind('enterBreakpoint1000',function() {
jQuery( 'body.front #sidebar' ).removeClass('hidden');
jQuery( 'body.front .navbar' ).removeClass('hidden');
jQuery ( 'body.front h2.hours-link' ).addClass('hidden');
//remove mobile class from body
jQuery('body').removeClass('mobile');
jQuery('body').addClass('notmobile');
//changes to secondary menu
jQuery('.header-secondary-menu ul.menu a.mainlink').removeClass('menu-toggle');
jQuery('div.mega-hook').addClass('mega-menu-mid');
jQuery('div.mega-hook').removeClass('mega-menu-wide');
jQuery('div.mega-hook').addClass('mega-menu');
jQuery( '.header-secondary-menu ul' ).show();
jQuery('.header-secondary-menu a.research').html('<span>Research</span><img src="https://library.ucsc.edu/sites/default/files/external/images/header-menu-arrow.png" alt="navigation arrow"><br>Tools & Help');
jQuery('.header-secondary-menu a.services').html('<span>Services</span><img src="https://library.ucsc.edu/sites/default/files/external/images/header-menu-arrow.png" alt="navigation arrow"><br>Borrowing & Spaces');
jQuery('.header-secondary-menu a.collections').html('<span>Collections</span><img src="https://library.ucsc.edu/sites/default/files/external/images/header-menu-arrow.png" alt="navigation arrow"><br>& Scholarly Communication');
jQuery('.header-secondary-menu a.about').html('<span>About</span><img src="https://library.ucsc.edu/sites/default/files/external/images/header-menu-arrow.png" alt="navigation arrow"><br>Visit & Contact');
});
jQuery(window).bind('exitBreakpoint1000',function() {
jQuery('.view-news').addClass('view-news-860plus');
jQuery('div.mega-hook').removeClass('mega-menu-mid');
});
jQuery(window).bind('exitBreakpoint860',function() {
jQuery('.view-news').removeClass('view-news-860plus');
jQuery('div.mega-hook').removeClass('mega-menu-mid');
//add mobile class to body
jQuery('body').addClass('mobile');
jQuery('body').removeClass('notmobile');
//mega menu scripts
jQuery('.mega-research').hide();
jQuery('.mega-services').hide();
jQuery('.mega-collections').hide();
jQuery('.mega-about').hide();
//changes to secondary menu
jQuery('.header-secondary-menu ul.menu a.mainlink').addClass('menu-toggle');
jQuery('div.mega-hook').removeClass('mega-menu');
jQuery('.header-secondary-menu ul.menu').hide();
jQuery('.header-secondary-menu a.research').html('Research');
jQuery('.header-secondary-menu a.services').html('Services');
jQuery('.header-secondary-menu a.collections').html('Collections');
jQuery('.header-secondary-menu a.about').html('About');
});
jQuery(window).bind('enterBreakpoint1350',function() {
jQuery('.view-news').addClass('view-news-860plus');
jQuery('div.mega-hook').removeClass('mega-menu-mid');
jQuery('div.mega-hook').addClass('mega-menu-wide');
});
jQuery(window).bind('exitBreakpoint1350',function() {
});
jQuery( document ).ready(function() {
//mega-menu scripts
jQuery( "li.research" ).mouseover(function() {
if ($('body').hasClass('notmobile')) {
jQuery('.mega-research').show();
}
});
jQuery( "li.services" ).mouseover(function() {
if ($('body').hasClass('notmobile')) {
jQuery('.mega-services').show();
}
});
jQuery( "li.collections" ).mouseover(function() {
if ($('body').hasClass('notmobile')) {
jQuery('.mega-collections').show();
}
});
jQuery( "li.about" ).mouseover(function() {
if ($('body').hasClass('notmobile')) {
jQuery('.mega-about').show();
}
});
});
(function ($) {
$(function () {
var googleCSEWatermark = function (id) {
var f = $(id)[0];
if (f && (f.query || f['edit-search-block-form--2'] || f['edit-keys'])) {
var q = f.query ? f.query : (f['edit-search-block-form--2'] ? f['edit-search-block-form--2'] : f['edit-keys']);
var n = navigator;
var l = location;
if (n.platform == 'Win32') {
q.style.cssText = 'border: 1px solid #7e9db9; padding: 2px;';
}
var b = function () {
if (q.value == '') {
q.style.background = '#FFFFFF url(https://cse.google.com/cse/intl//images/google_custom_search_watermark.gif) left no-repeat';
}
};
var f = function () {
q.style.background = '#ffffff';
};
q.onfocus = f;
q.onblur = b;
// if (!/[&?]query=[^&]/.test(l.search)) {
b();
// }
}
};
googleCSEWatermark('#search-block-form.google-cse');
googleCSEWatermark('#search-form.google-cse');
googleCSEWatermark('#google-cse-results-searchbox-form');
});
})(jQuery);