browse-everything 1.0.0.rc1 → 1.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +4 -0
- data/.travis.yml +6 -0
- data/README.md +19 -3
- data/Rakefile +0 -9
- data/app/assets/javascripts/browse_everything/behavior.js +413 -0
- data/app/assets/stylesheets/_browse_everything_bootstrap3.scss +122 -0
- data/app/assets/stylesheets/_browse_everything_bootstrap4.scss +117 -0
- data/app/assets/stylesheets/browse_everything/_browse_everything.scss +2 -116
- data/app/views/browse_everything/_providers.html.erb +2 -1
- data/app/views/browse_everything/index.html.erb +3 -2
- data/browse-everything.gemspec +0 -3
- data/karma.conf.js +71 -0
- data/lib/browse-everything.rb +0 -2
- data/lib/browse_everything.rb +10 -5
- data/lib/browse_everything/version.rb +1 -1
- data/lib/generators/browse_everything/install_generator.rb +1 -7
- data/spec/javascripts/behavior_spec.js +1 -3
- data/spec/javascripts/helpers/jquery.js +11008 -0
- data/spec/javascripts/karma_spec.rb +16 -0
- data/spec/lib/browse_everything_spec.rb +7 -0
- data/spec/test_app_templates/Gemfile.extra +7 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +7 -1
- metadata +11 -56
- data/app/assets/javascripts/browse_everything/behavior.js.coffee +0 -342
- data/app/assets/stylesheets/browse_everything.scss +0 -6
- data/app/helpers/font_awesome_version_helper.rb +0 -17
- data/lib/generators/browse_everything/assets_generator.rb +0 -13
- data/lib/generators/browse_everything/templates/browse_everything.scss +0 -6
- data/spec/javascripts/jasmine_spec.rb +0 -21
- data/spec/javascripts/support/jasmine.yml +0 -124
- data/spec/javascripts/support/jasmine_helper.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 617d8d7a23fcee87c1b3fe38d99d060c23acdb0edb5181dbb0354d0df905a03e
|
4
|
+
data.tar.gz: 5726f28db0a5e000a87eb3de5055805d3b401334cd7100395d99550999ebcb5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1cd94b143e8ca8bbd126b37358aa8dfaef97399e90b81c4a34b870f491e4c50fe093aeeec4ac6192ae480a05fd2307628658b64bb8c8b0bd936b83d2f168a81
|
7
|
+
data.tar.gz: 131163303e6ab27cee2c92931898e44cf4f1a3d3f55ba1cc36e2046bf1b5eeea3971d5b540a1ef273871ce028f3c35e92524f986825cdc86ec29ca1959477ecf
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
@@ -10,6 +10,7 @@ cache:
|
|
10
10
|
before_install:
|
11
11
|
- gem update --system # https://docs.travis-ci.com/user/languages/ruby/#Upgrading-RubyGems
|
12
12
|
- gem install bundler
|
13
|
+
- npm install -g karma karma-jasmine karma-chrome-launcher
|
13
14
|
- google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost &
|
14
15
|
|
15
16
|
rvm:
|
@@ -19,9 +20,14 @@ rvm:
|
|
19
20
|
|
20
21
|
env:
|
21
22
|
global:
|
23
|
+
- CHROME_BIN=google-chrome-stable
|
22
24
|
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
|
23
25
|
matrix:
|
24
26
|
- "RAILS_VERSION=5.2.0"
|
27
|
+
- "RAILS_VERSION=5.2.0 TEST_BOOTSTRAP=3"
|
25
28
|
- "RAILS_VERSION=5.1.6"
|
29
|
+
- "RAILS_VERSION=5.1.6 TEST_BOOTSTRAP=3"
|
26
30
|
- "RAILS_VERSION=5.0.7"
|
31
|
+
- "RAILS_VERSION=5.0.7 TEST_BOOTSTRAP=3"
|
27
32
|
- "RAILS_VERSION=4.2.10"
|
33
|
+
- "RAILS_VERSION=4.2.10 TEST_BOOTSTRAP=3"
|
data/README.md
CHANGED
@@ -66,7 +66,7 @@ Or install it yourself as:
|
|
66
66
|
|
67
67
|
$ gem install browse-everything
|
68
68
|
|
69
|
-
|
69
|
+
## Configuring the gem in your host app
|
70
70
|
|
71
71
|
After installing the gem, run the generator
|
72
72
|
|
@@ -76,9 +76,15 @@ This generator will set up the _config/browse_everything_providers.yml_ file and
|
|
76
76
|
|
77
77
|
If you prefer not to use the generator, or need info on how to set up providers in the browse_everything_providers.yml, use the info on [Configuring browse-everything](https://github.com/samvera/browse-everything/wiki/Configuring-browse-everything).
|
78
78
|
|
79
|
-
|
79
|
+
Browse-everything depends on bootstrap, it can work with bootstrap 3 or bootstrap 4.
|
80
80
|
|
81
|
-
|
81
|
+
### CSS
|
82
|
+
|
83
|
+
**For bootstrap3 support**, your app should include the [bootstrap-sass](https://github.com/twbs/bootstrap-sass) gem in it's Gemfile, and following the install directions for bootstrap-sass, should have `@import 'bootstrap-sprockets'` and `@import 'bootstrap'` in it's application.scss. After those lines, add `@import "browse_everything_bootstrap3";` to your application.scss.
|
84
|
+
|
85
|
+
**For bootstrap4 support**, your app should include the [bootstrap](https://github.com/twbs/bootstrap-rubygem) gem in it's Gemfile, and following the install directions for that gem should have `@import "bootstrap";` in it's application.scss. After that line, add `@import 'browse_everything_bootstrap4'` to your application.scss.
|
86
|
+
|
87
|
+
### Javascript
|
82
88
|
|
83
89
|
In `app/assets/javascripts/application.js` include jquery and the BrowseEverything
|
84
90
|
|
@@ -87,6 +93,14 @@ In `app/assets/javascripts/application.js` include jquery and the BrowseEverythi
|
|
87
93
|
//= require browse_everything
|
88
94
|
```
|
89
95
|
|
96
|
+
(Same for bootstrap3 or bootstrap 4)
|
97
|
+
|
98
|
+
### Migration CSS inclusion from pre-1.0 (TODO: Is that the version this will be released with?)
|
99
|
+
|
100
|
+
If your app has installed a previous version of browse-everything, you may have a generated file at `./app/assets/stylesheets/browse_everything.scss`, which has a line in it `@import "browse_everything/browse_everything";`. That import should no longer be used; it can be changed to `@import "browse_everything_bootstrap3"` instead.
|
101
|
+
|
102
|
+
However, we also recommend merging the contents of this file into your main `application.scss` file, as documented in the current install instructions. With the separate generated file with bootstrap imports, you may likely be including bootstrap CSS in your generated CSS bundle twice, if you also have that import in your main application.scss already.
|
103
|
+
|
90
104
|
## Testing
|
91
105
|
This is a Rails Engine which is tested using the [engine_cart](https://github.com/cbeer/engine_cart) Gem. Test suites may be executed with the following invocation:
|
92
106
|
|
@@ -94,6 +108,8 @@ This is a Rails Engine which is tested using the [engine_cart](https://github.co
|
|
94
108
|
bundle exec rake
|
95
109
|
```
|
96
110
|
|
111
|
+
Tests by default will be run with bootstrap-4 integration. To test bootstrap-3 integration: `TEST_BOOTSTRAP=3 bundle exec rake`.
|
112
|
+
|
97
113
|
### Testing Problems
|
98
114
|
Should you attempt to execute the test suite and encounter the following error:
|
99
115
|
```bash
|
data/Rakefile
CHANGED
@@ -6,14 +6,5 @@ Dir.glob('tasks/*.rake').each { |r| import r }
|
|
6
6
|
|
7
7
|
require 'rspec/core/rake_task'
|
8
8
|
require 'engine_cart/rake_task'
|
9
|
-
require 'jasmine'
|
10
|
-
load 'jasmine/tasks/jasmine.rake'
|
11
|
-
|
12
|
-
# Set up the test application prior to running jasmine tasks.
|
13
|
-
task 'jasmine:require' => :setup_test_server
|
14
|
-
task :setup_test_server do
|
15
|
-
require 'engine_cart'
|
16
|
-
EngineCart.load_application!
|
17
|
-
end
|
18
9
|
|
19
10
|
task default: [:ci]
|
@@ -0,0 +1,413 @@
|
|
1
|
+
/*
|
2
|
+
* decaffeinate suggestions:
|
3
|
+
* DS102: Remove unnecessary code created because of implicit returns
|
4
|
+
* DS207: Consider shorter variations of null checks
|
5
|
+
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
6
|
+
*/
|
7
|
+
$(function() {
|
8
|
+
let dialog = $('div#browse-everything');
|
9
|
+
|
10
|
+
const initialize = function(obj,options) {
|
11
|
+
if ($('div#browse-everything').length === 0) {
|
12
|
+
// bootstrap 4 needs at least the inner class="modal-dialog" div, or it gets really
|
13
|
+
// confused and can't close the dialog.
|
14
|
+
dialog = $('<div tabindex="-1" id="browse-everything" class="ev-browser modal fade" aria-live="polite" role="dialog" aria-labelledby="beModalLabel">' +
|
15
|
+
'<div class="modal-dialog modal-lg" role="document"></div>' +
|
16
|
+
'</div>').hide().appendTo('body');
|
17
|
+
}
|
18
|
+
|
19
|
+
dialog.modal({
|
20
|
+
backdrop: 'static',
|
21
|
+
show: false
|
22
|
+
});
|
23
|
+
const ctx = {
|
24
|
+
opts: $.extend(true, {}, options),
|
25
|
+
callbacks: {
|
26
|
+
show: $.Callbacks(),
|
27
|
+
done: $.Callbacks(),
|
28
|
+
cancel: $.Callbacks(),
|
29
|
+
fail: $.Callbacks()
|
30
|
+
}
|
31
|
+
};
|
32
|
+
ctx.callback_proxy = {
|
33
|
+
show(func) { ctx.callbacks.show.add(func); return this; },
|
34
|
+
done(func) { ctx.callbacks.done.add(func); return this; },
|
35
|
+
cancel(func) { ctx.callbacks.cancel.add(func); return this; },
|
36
|
+
fail(func) { ctx.callbacks.fail.add(func); return this; }
|
37
|
+
};
|
38
|
+
$(obj).data('ev-state',ctx);
|
39
|
+
return ctx;
|
40
|
+
};
|
41
|
+
|
42
|
+
const toHiddenFields = function(data) {
|
43
|
+
const fields = $.param(data)
|
44
|
+
.split('&')
|
45
|
+
.map(t => t.replace(/\+/g,' ').split('=',2));
|
46
|
+
const elements = $(fields).map(function() {
|
47
|
+
return $("<input type='hidden'/>")
|
48
|
+
.attr('name',decodeURIComponent(this[0]))
|
49
|
+
.val(decodeURIComponent(this[1]))[0].outerHTML;
|
50
|
+
});
|
51
|
+
return $(elements.toArray().join("\n"));
|
52
|
+
};
|
53
|
+
|
54
|
+
const indicateSelected = () =>
|
55
|
+
$('input.ev-url').each(function() {
|
56
|
+
return $(`*[data-ev-location='${$(this).val()}']`).addClass('ev-selected');
|
57
|
+
})
|
58
|
+
;
|
59
|
+
|
60
|
+
const fileIsSelected = function(row) {
|
61
|
+
let result = false;
|
62
|
+
$('input.ev-url').each(function() {
|
63
|
+
if (this.value === $(row).data('ev-location')) {
|
64
|
+
return result = true;
|
65
|
+
}
|
66
|
+
});
|
67
|
+
return result;
|
68
|
+
};
|
69
|
+
|
70
|
+
const toggleFileSelect = function(row) {
|
71
|
+
row.toggleClass('ev-selected');
|
72
|
+
if (row.hasClass('ev-selected')) {
|
73
|
+
selectFile(row);
|
74
|
+
} else {
|
75
|
+
unselectFile(row);
|
76
|
+
}
|
77
|
+
return updateFileCount();
|
78
|
+
};
|
79
|
+
|
80
|
+
var selectFile = function(row) {
|
81
|
+
const target_form = $('form.ev-submit-form');
|
82
|
+
const file_location = row.data('ev-location');
|
83
|
+
const hidden_input = $("<input type='hidden' class='ev-url' name='selected_files[]'/>").val(file_location);
|
84
|
+
target_form.append(hidden_input);
|
85
|
+
if (!$(row).find('.ev-select-file').prop('checked')) {
|
86
|
+
return $(row).find('.ev-select-file').prop('checked', true);
|
87
|
+
}
|
88
|
+
};
|
89
|
+
|
90
|
+
var unselectFile = function(row) {
|
91
|
+
const target_form = $('form.ev-submit-form');
|
92
|
+
const file_location = row.data('ev-location');
|
93
|
+
$(`form.ev-submit-form input[value='${file_location}']`).remove();
|
94
|
+
if ($(row).find('.ev-select-file').prop('checked')) {
|
95
|
+
return $(row).find('.ev-select-file').prop('checked', false);
|
96
|
+
}
|
97
|
+
};
|
98
|
+
|
99
|
+
var updateFileCount = function() {
|
100
|
+
const count = $('input.ev-url').length;
|
101
|
+
const files = count === 1 ? "file" : "files";
|
102
|
+
return $('.ev-status').html(`${count} ${files} selected`);
|
103
|
+
};
|
104
|
+
|
105
|
+
const toggleBranchSelect = function(row) {
|
106
|
+
if (row.hasClass('collapsed')) {
|
107
|
+
const node_id = row.find('td.ev-file-name a.ev-link').attr('href');
|
108
|
+
return $('table#file-list').treetable('expandNode',node_id);
|
109
|
+
}
|
110
|
+
};
|
111
|
+
|
112
|
+
const selectAll = rows =>
|
113
|
+
rows.each(function() {
|
114
|
+
if ($(this).data('tt-branch')) {
|
115
|
+
const box = $(this).find('#select_all')[0];
|
116
|
+
$(box).prop('checked', true);
|
117
|
+
$(box).prop('value', "1");
|
118
|
+
return toggleBranchSelect($(this));
|
119
|
+
} else {
|
120
|
+
if (!fileIsSelected($(this))) { return toggleFileSelect($(this)); }
|
121
|
+
}
|
122
|
+
})
|
123
|
+
;
|
124
|
+
|
125
|
+
const selectChildRows = (row, action) =>
|
126
|
+
$('table#file-list tr').each(function() {
|
127
|
+
if ($(this).data('tt-parent-id')) {
|
128
|
+
const re = RegExp($(row).data('tt-id'), 'i');
|
129
|
+
if ($(this).data('tt-parent-id').match(re)) {
|
130
|
+
if ($(this).data('tt-branch')) {
|
131
|
+
const box = $(this).find('#select_all')[0];
|
132
|
+
$(box).prop('value', action);
|
133
|
+
if (action === "1") {
|
134
|
+
$(box).prop("checked", true);
|
135
|
+
const node_id = $(this).find('td.ev-file-name a.ev-link').attr('href');
|
136
|
+
return $('table#file-list').treetable('expandNode',node_id);
|
137
|
+
} else {
|
138
|
+
return $(box).prop("checked", false);
|
139
|
+
}
|
140
|
+
} else {
|
141
|
+
if (action === "1") {
|
142
|
+
$(this).addClass('ev-selected');
|
143
|
+
if (!fileIsSelected($(this))) { selectFile($(this)); }
|
144
|
+
} else {
|
145
|
+
$(this).removeClass('ev-selected');
|
146
|
+
unselectFile($(this));
|
147
|
+
}
|
148
|
+
return updateFileCount();
|
149
|
+
}
|
150
|
+
}
|
151
|
+
}
|
152
|
+
})
|
153
|
+
;
|
154
|
+
|
155
|
+
const tableSetup = function(table) {
|
156
|
+
table.treetable({
|
157
|
+
expandable: true,
|
158
|
+
onNodeCollapse() {
|
159
|
+
const node = this;
|
160
|
+
return table.treetable("unloadBranch", node);
|
161
|
+
},
|
162
|
+
onNodeExpand() {
|
163
|
+
const node = this;
|
164
|
+
startWait();
|
165
|
+
const size = $(node.row).find('td.ev-file-size').text().trim();
|
166
|
+
let start = 1;
|
167
|
+
let increment = 1;
|
168
|
+
if (size.indexOf("MB") >-1) {
|
169
|
+
start = 10;
|
170
|
+
increment = 5;
|
171
|
+
}
|
172
|
+
if (size.indexOf("KB") >-1) {
|
173
|
+
start = 50;
|
174
|
+
increment = 10;
|
175
|
+
}
|
176
|
+
setProgress(start);
|
177
|
+
const progressIntervalID = setInterval((function() {
|
178
|
+
start = start + increment;
|
179
|
+
if (start > 99) {
|
180
|
+
start = 99;
|
181
|
+
}
|
182
|
+
return setProgress(start);
|
183
|
+
}), 2000);
|
184
|
+
return setTimeout((() => loadFiles(node, table, progressIntervalID)), 10);
|
185
|
+
}
|
186
|
+
});
|
187
|
+
$("#file-list tr:first").focus();
|
188
|
+
return sizeColumns(table);
|
189
|
+
};
|
190
|
+
|
191
|
+
var sizeColumns = function(table) {
|
192
|
+
const full_width = $('.ev-files').width();
|
193
|
+
table.width(full_width);
|
194
|
+
const set_size = (selector, pct) => $(selector, table).width(full_width * pct).css('width',full_width * pct).css('max-width',full_width * pct);
|
195
|
+
set_size('.ev-file', 0.4);
|
196
|
+
set_size('.ev-container', 0.4);
|
197
|
+
set_size('.ev-size', 0.1);
|
198
|
+
set_size('.ev-kind', 0.3);
|
199
|
+
return set_size('.ev-date', 0.2);
|
200
|
+
};
|
201
|
+
|
202
|
+
var loadFiles = (node, table, progressIntervalID)=>
|
203
|
+
$.ajax({
|
204
|
+
async: true, // Must be false, otherwise loadBranch happens after showChildren?
|
205
|
+
url: $('a.ev-link',node.row).attr('href'),
|
206
|
+
data: {
|
207
|
+
parent: node.row.data('tt-id'),
|
208
|
+
accept: dialog.data('ev-state').opts.accept,
|
209
|
+
context: dialog.data('ev-state').opts.context
|
210
|
+
}}).done(function(html) {
|
211
|
+
setProgress('100');
|
212
|
+
clearInterval(progressIntervalID);
|
213
|
+
const rows = $('tbody tr',$(html));
|
214
|
+
table.treetable("loadBranch", node, rows);
|
215
|
+
$(node).show();
|
216
|
+
sizeColumns(table);
|
217
|
+
indicateSelected();
|
218
|
+
if ($(node.row).find('#select_all')[0].checked) {
|
219
|
+
return selectAll(rows);
|
220
|
+
}}).always(function() {
|
221
|
+
clearInterval(progressIntervalID);
|
222
|
+
return stopWait();
|
223
|
+
})
|
224
|
+
;
|
225
|
+
|
226
|
+
var setProgress = done=> $('.loading-text').text(done+'% complete');
|
227
|
+
|
228
|
+
const refreshFiles = () => $('.ev-providers select').change();
|
229
|
+
|
230
|
+
var startWait = function() {
|
231
|
+
$('.loading-progress').removeClass("hidden");
|
232
|
+
$('body').css('cursor','wait');
|
233
|
+
$("html").addClass("wait");
|
234
|
+
$(".ev-browser").addClass("loading");
|
235
|
+
return $('.ev-submit').attr('disabled', true);
|
236
|
+
};
|
237
|
+
|
238
|
+
var stopWait = function() {
|
239
|
+
$('.loading-progress').addClass("hidden");
|
240
|
+
$('body').css('cursor','default');
|
241
|
+
$("html").removeClass("wait");
|
242
|
+
$(".ev-browser").removeClass("loading");
|
243
|
+
return $('.ev-submit').attr('disabled', false);
|
244
|
+
};
|
245
|
+
|
246
|
+
$(window).on('resize', () => sizeColumns($('table#file-list')));
|
247
|
+
|
248
|
+
$.fn.browseEverything = function(options) {
|
249
|
+
let ctx = $(this).data('ev-state');
|
250
|
+
if ((ctx == null) && (options == null)) { options = $(this).data(); }
|
251
|
+
if (options != null) {
|
252
|
+
ctx = initialize(this[0], options);
|
253
|
+
$(this).click(function() {
|
254
|
+
dialog.data('ev-state',ctx);
|
255
|
+
return dialog.load(ctx.opts.route, function() {
|
256
|
+
setTimeout(refreshFiles, 500);
|
257
|
+
ctx.callbacks.show.fire();
|
258
|
+
return dialog.modal('show');
|
259
|
+
});
|
260
|
+
});
|
261
|
+
}
|
262
|
+
|
263
|
+
if (ctx) {
|
264
|
+
return ctx.callback_proxy;
|
265
|
+
} else {
|
266
|
+
return {
|
267
|
+
show() { return this; },
|
268
|
+
done() { return this; },
|
269
|
+
cancel() { return this; },
|
270
|
+
fail() { return this; }
|
271
|
+
};
|
272
|
+
}
|
273
|
+
};
|
274
|
+
|
275
|
+
$.fn.browseEverything.toggleCheckbox = function(box) {
|
276
|
+
if (box.value === "0") {
|
277
|
+
return $(box).prop('value', "1");
|
278
|
+
} else {
|
279
|
+
return $(box).prop('value', "0");
|
280
|
+
}
|
281
|
+
};
|
282
|
+
|
283
|
+
$(document).on('ev.refresh', event => refreshFiles());
|
284
|
+
|
285
|
+
$(document).on('click', 'button.ev-cancel', function(event) {
|
286
|
+
event.preventDefault();
|
287
|
+
dialog.data('ev-state').callbacks.cancel.fire();
|
288
|
+
return $('.ev-browser').modal('hide');
|
289
|
+
});
|
290
|
+
|
291
|
+
$(document).on('click', 'button.ev-submit', function(event) {
|
292
|
+
event.preventDefault();
|
293
|
+
$(this).button('loading');
|
294
|
+
startWait();
|
295
|
+
const main_form = $(this).closest('form');
|
296
|
+
const resolver_url = main_form.data('resolver');
|
297
|
+
const ctx = dialog.data('ev-state');
|
298
|
+
$(main_form).find('input[name=context]').val(ctx.opts.context);
|
299
|
+
return $.ajax(resolver_url, {
|
300
|
+
type: 'POST',
|
301
|
+
dataType: 'json',
|
302
|
+
data: main_form.serialize()
|
303
|
+
}).done(function(data) {
|
304
|
+
if (ctx.opts.target != null) {
|
305
|
+
const fields = toHiddenFields({selected_files: data});
|
306
|
+
$(ctx.opts.target).append($(fields));
|
307
|
+
}
|
308
|
+
return ctx.callbacks.done.fire(data);}).fail((xhr,status,error) => ctx.callbacks.fail.fire(status, error, xhr.responseText)).always(function() {
|
309
|
+
$('body').css('cursor','default');
|
310
|
+
$('.ev-browser').modal('hide');
|
311
|
+
return $('#browse-btn').focus();
|
312
|
+
});
|
313
|
+
});
|
314
|
+
|
315
|
+
$(document).on('click', '.ev-files .ev-container a.ev-link', function(event) {
|
316
|
+
event.stopPropagation();
|
317
|
+
event.preventDefault();
|
318
|
+
const row = $(this).closest('tr');
|
319
|
+
const action = row.hasClass('expanded') ? 'collapseNode' : 'expandNode';
|
320
|
+
const node_id = $(this).attr('href');
|
321
|
+
return $('table#file-list').treetable(action,node_id);
|
322
|
+
});
|
323
|
+
|
324
|
+
$(document).on('change', '.ev-providers select', function(event) {
|
325
|
+
event.preventDefault();
|
326
|
+
startWait();
|
327
|
+
return $.ajax({
|
328
|
+
url: $(this).val(),
|
329
|
+
data: {
|
330
|
+
accept: dialog.data('ev-state').opts.accept,
|
331
|
+
context: dialog.data('ev-state').opts.context
|
332
|
+
}}).done(function(data) {
|
333
|
+
$('.ev-files').html(data);
|
334
|
+
indicateSelected();
|
335
|
+
$('#provider_auth').focus();
|
336
|
+
return tableSetup($('table#file-list'));}).fail(function(xhr,status,error) {
|
337
|
+
if (xhr.responseText.indexOf("Refresh token has expired")>-1) {
|
338
|
+
return $('.ev-files').html("Your sessison has expired please clear your cookies.");
|
339
|
+
} else {
|
340
|
+
return $('.ev-files').html(xhr.responseText);
|
341
|
+
}}).always(() => stopWait());
|
342
|
+
});
|
343
|
+
|
344
|
+
$(document).on('click', '.ev-providers a', function(event) {
|
345
|
+
$('.ev-providers li').removeClass('ev-selected');
|
346
|
+
return $(this).closest('li').addClass('ev-selected');
|
347
|
+
});
|
348
|
+
|
349
|
+
$(document).on('click', '.ev-file a', function(event) {
|
350
|
+
event.preventDefault();
|
351
|
+
const target = $(this).closest('*[data-ev-location]');
|
352
|
+
return toggleFileSelect(target);
|
353
|
+
});
|
354
|
+
|
355
|
+
$(document).on('click', '.ev-auth', function(event) {
|
356
|
+
event.preventDefault();
|
357
|
+
const auth_win = window.open($(this).attr('href'));
|
358
|
+
var check_func = function() {
|
359
|
+
if (auth_win.closed) {
|
360
|
+
return $('.ev-providers .ev-selected a').click();
|
361
|
+
} else {
|
362
|
+
return window.setTimeout(check_func, 1000);
|
363
|
+
}
|
364
|
+
};
|
365
|
+
return check_func();
|
366
|
+
});
|
367
|
+
|
368
|
+
$(document).on('change', 'input.ev-select-all', function(event) {
|
369
|
+
event.stopPropagation();
|
370
|
+
event.preventDefault();
|
371
|
+
$.fn.browseEverything.toggleCheckbox(this);
|
372
|
+
const action = this.value;
|
373
|
+
const row = $(this).closest('tr');
|
374
|
+
const node_id = row.find('td.ev-file-name a.ev-link').attr('href');
|
375
|
+
if (row.hasClass('collapsed')) {
|
376
|
+
return $('table#file-list').treetable('expandNode',node_id);
|
377
|
+
} else {
|
378
|
+
return selectChildRows(row, action);
|
379
|
+
}
|
380
|
+
});
|
381
|
+
|
382
|
+
return $(document).on('change', 'input.ev-select-file', function(event) {
|
383
|
+
event.stopPropagation();
|
384
|
+
event.preventDefault();
|
385
|
+
return toggleFileSelect($(this).closest('tr'));
|
386
|
+
});
|
387
|
+
});
|
388
|
+
|
389
|
+
|
390
|
+
const auto_toggle = function() {
|
391
|
+
const triggers = $('*[data-toggle=browse-everything]');
|
392
|
+
if (typeof Rails !== 'undefined' && Rails !== null) {
|
393
|
+
$.ajaxSetup({
|
394
|
+
headers: { 'X-CSRF-TOKEN': (Rails || $.rails).csrfToken() || '' }
|
395
|
+
});
|
396
|
+
}
|
397
|
+
|
398
|
+
return triggers.each(function() {
|
399
|
+
const ctx = $(this).data('ev-state');
|
400
|
+
if (ctx == null) { return $(this).browseEverything($(this).data()); }
|
401
|
+
});
|
402
|
+
};
|
403
|
+
|
404
|
+
if ((typeof Turbolinks !== 'undefined' && Turbolinks !== null) && Turbolinks.supported) {
|
405
|
+
// Use turbolinks:load for Turbolinks 5, otherwise use the old way
|
406
|
+
if (Turbolinks.BrowserAdapter) {
|
407
|
+
$(document).on('turbolinks:load', auto_toggle);
|
408
|
+
} else {
|
409
|
+
$(document).on('page:change', auto_toggle);
|
410
|
+
}
|
411
|
+
} else {
|
412
|
+
$(document).ready(auto_toggle);
|
413
|
+
}
|