/
sufia.js
167 lines (143 loc) · 4.97 KB
/
sufia.js
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
//= require jquery-ui-1.9.2/jquery.ui.core
//= require jquery-ui-1.9.2/jquery.ui.widget
//= require jquery-ui-1.9.2/jquery.ui.menu
//= require jquery-ui-1.9.2/jquery.ui.autocomplete
//= require jquery-ui-1.9.2/jquery.ui.position
//= require jquery-ui-1.9.2/jquery.ui.effect
//= require jquery-ui-1.9.2/jquery.ui.effect-highlight
//= require bootstrap/dropdown
//= require bootstrap/button
//= require bootstrap/modal
//= require bootstrap/collapse
//= require bootstrap/tooltip
//= require bootstrap/popover
//= require bootstrap/tab
//= require video
//= require audio.min
//= require jquery.validate
//= require swfobject
//= require ZeroClipboard.min
//= require select2
//= require flot/excanvas
//= require flot/jquery.flot
//= require flot/jquery.flot.time
//= require flot/jquery.flot.selection
//= require batch_edit
//= require terms_of_service
//= require notifications_check
//
//= require sufia/app
//= require sufia/fileupload
//= require sufia/permissions
//= require sufia/trophy
//= require sufia/featured_works
//= require sufia/featured_researcher
//= require sufia/batch_select_all
//= require sufia/edit_metadata
//= require sufia/single_use_link
//= require sufia/audio
//= require sufia/search
//= require sufia/editor
//= require sufia/ga_events
//= require sufia/tabs
//= require sufia/user_search
//= require sufia/transfers
//= require sufia/proxy_rights
//= require hydra/batch_select
//= require sufia/dashboard_actions
//= require sufia/batch
//= require hydra_collections
//= require hydra-editor/hydra-editor
//
// For Browse-everything until https://github.com/projecthydra-labs/browse-everything/issues/85 is resolved:
//= require jquery.treetable
//= require browse_everything/behavior
//
//= require nestable
// this needs to be after batch_select so that the form ids get setup correctly
//= require sufia/batch_edit
//over ride the blacklight default to submit
//form when sort by or show per page change
Blacklight.do_select_submit = function() {
$(Blacklight.do_select_submit.selector).each(function() {
var select = $(this);
select.closest("form").find("input[type=submit]").show();
select.bind("change", function() {
return false;
});
});
};
Blacklight.do_select_submit.selector = "form.sort select, form.per_page select";
function notify_update_link() {
$('#notify_update_link').click();
}
Blacklight.onLoad(function() {
// set up global batch edit options to override the ones in the gem
window.batch_edits_options = { checked_label: "",unchecked_label: "",progress_label: "",status_label: "",css_class: "batch_toggle"};
// bootstrap alerts are closed this function
$(document).on('click', '.alert .close' , function(){
$(this).parent().hide();
});
$.fn.selectRange = function(start, end) {
return this.each(function() {
if (this.setSelectionRange) {
this.focus();
this.setSelectionRange(start, end);
} else if (this.createTextRange) {
var range = this.createTextRange();
range.collapse(true);
range.moveEnd('character', end);
range.moveStart('character', start);
range.select();
}
});
};
// initialize popover helpers
$("a[data-toggle=popover]").popover({ html: true })
.click(function() { return false; });
/*
* facets lists
*/
$("li.expandable").click(function(){
$(this).next("ul").slideToggle();
$(this).find('i').toggleClass("glyphicon-chevron-right glyphicon-chevron-down");
});
$("li.expandable_new").click(function(){
$(this).find('i').toggleClass("glyphicon-chevron-right glyphicon-chevron-down");
});
$(".sorts-dash").click(function(){
var itag =$(this).find('i');
toggle_icon(itag);
sort = itag.attr('class') == "caret" ? itag.attr('id')+' desc' : itag.attr('id') +' asc';
$('#sort').val(sort).selected = true;
$("#dashboard_sort_submit").click();
});
$(".sorts").click(function(){
var itag =$(this).find('i');
toggle_icon(itag);
sort = itag.attr('class') == "caret up" ? itag.attr('id')+' desc': itag.attr('id');
$('input[name="sort"]').attr('value', sort);
$("#user_submit").click();
});
}); //closing function at the top of the page
/*
* begin functions
*/
function toggle_icon(itag){
itag.toggleClass("caret");
itag.toggleClass("caret up");
}
function preg_quote( str ) {
// http://kevin.vanzonneveld.net
// + original by: booeyOH
// + improved by: Ates Goral (http://magnetiq.com)
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + bugfixed by: Onno Marsman
// * example 1: preg_quote("$40");
// * returns 1: '\$40'
// * example 2: preg_quote("*RRRING* Hello?");
// * returns 2: '\*RRRING\* Hello\?'
// * example 3: preg_quote("\\.+*?[^]$(){}=!<>|:");
// * returns 3: '\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!\<\>\|\:'
return (str+'').replace(/([\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!\<\>\|\:])/g, "\\$1");
}