browse-everything 1.0.0.rc2 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +93 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +43 -35
- data/CONTRIBUTING.md +3 -3
- data/Gemfile +3 -6
- data/LICENSE.txt +205 -22
- data/README.md +17 -15
- data/app/assets/javascripts/browse_everything/behavior.js +201 -158
- data/app/assets/javascripts/treetable.webpack.js +687 -0
- data/app/assets/stylesheets/browse_everything.scss +0 -0
- data/app/assets/stylesheets/{_browse_everything_bootstrap3.scss → browse_everything/_browse_everything_bootstrap3.scss} +6 -5
- data/app/assets/stylesheets/{_browse_everything_bootstrap4.scss → browse_everything/_browse_everything_bootstrap4.scss} +0 -0
- data/app/controllers/browse_everything_controller.rb +60 -60
- data/app/helpers/browse_everything_helper.rb +4 -0
- data/app/views/browse_everything/_files.html.erb +4 -2
- data/browse-everything.gemspec +8 -7
- data/lib/browse_everything.rb +2 -1
- data/lib/browse_everything/auth/google/credentials.rb +5 -5
- data/lib/browse_everything/auth/google/request_parameters.rb +38 -38
- data/lib/browse_everything/driver/base.rb +14 -14
- data/lib/browse_everything/driver/box.rb +62 -55
- data/lib/browse_everything/driver/dropbox.rb +37 -21
- data/lib/browse_everything/driver/file_system.rb +30 -18
- data/lib/browse_everything/driver/google_drive.rb +40 -39
- data/lib/browse_everything/driver/s3.rb +61 -45
- data/lib/browse_everything/file_entry.rb +1 -1
- data/lib/browse_everything/retriever.rb +72 -67
- data/lib/browse_everything/version.rb +1 -1
- data/lib/generators/browse_everything/templates/browse_everything_providers.yml.example +1 -0
- data/spec/features/test_compiling_stylesheets_spec.rb +1 -1
- data/spec/lib/browse_everything/browser_spec.rb +5 -3
- data/spec/lib/browse_everything/driver/dropbox_spec.rb +20 -1
- data/spec/lib/browse_everything/driver_spec.rb +43 -3
- data/spec/spec_helper.rb +9 -2
- data/spec/support/capybara.rb +0 -5
- data/spec/test_app_templates/Gemfile.extra +9 -0
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +56 -5
- metadata +72 -39
- data/.travis.yml +0 -33
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Code:
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/browse-everything.png)](http://badge.fury.io/rb/browse-everything)
|
5
|
-
[![
|
5
|
+
[![CircleCI](https://circleci.com/gh/samvera/browse-everything.svg?style=svg)](https://circleci.com/gh/samvera/browse-everything)
|
6
6
|
[![Coverage Status](https://coveralls.io/repos/samvera/browse-everything/badge.svg?branch=master&service=github)](https://coveralls.io/github/samvera/browse-everything?branch=master)
|
7
7
|
|
8
8
|
Docs:
|
@@ -39,17 +39,15 @@ what this means can be found
|
|
39
39
|
|
40
40
|
## Supported Ruby Releases
|
41
41
|
Currently, the following releases of Ruby are supported:
|
42
|
-
- 2.
|
43
|
-
- 2.
|
44
|
-
- 2.
|
45
|
-
- Please note that this is the last release in the 2.3.x series, and support is [scheduled to be withdrawn](https://www.ruby-lang.org/en/news/2018/03/28/ruby-2-3-7-released/). We would strongly recommend that one upgrades from 2.3.7 in response to this.
|
42
|
+
- 2.6.3
|
43
|
+
- 2.5.5
|
44
|
+
- 2.4.6
|
46
45
|
|
47
46
|
## Supported Rails Releases
|
48
|
-
|
49
|
-
-
|
50
|
-
- 5.
|
51
|
-
-
|
52
|
-
- The supported Rail releases follow those specified by [the security policy of the Rails Community](https://rubyonrails.org/security/). As is the case with the supported Ruby releases, it is recommended that one upgrades from any Rails release no longer receiving security updates.
|
47
|
+
The supported Rail releases follow those specified by [the security policy of the Rails Community](https://rubyonrails.org/security/). As is the case with the supported Ruby releases, it is recommended that one upgrades from any Rails release no longer receiving security updates.
|
48
|
+
- 6.0.3
|
49
|
+
- 5.2.3
|
50
|
+
- 5.1.7
|
53
51
|
|
54
52
|
## Installation
|
55
53
|
|
@@ -80,9 +78,9 @@ Browse-everything depends on bootstrap, it can work with bootstrap 3 or bootstra
|
|
80
78
|
|
81
79
|
### CSS
|
82
80
|
|
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.
|
81
|
+
**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/browse_everything_bootstrap3";` to your application.scss.
|
84
82
|
|
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.
|
83
|
+
**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/browse_everything_bootstrap4'` to your application.scss.
|
86
84
|
|
87
85
|
### Javascript
|
88
86
|
|
@@ -95,14 +93,18 @@ In `app/assets/javascripts/application.js` include jquery and the BrowseEverythi
|
|
95
93
|
|
96
94
|
(Same for bootstrap3 or bootstrap 4)
|
97
95
|
|
98
|
-
### Migration CSS inclusion from pre-1.0
|
96
|
+
### Migration CSS inclusion from pre-1.0
|
99
97
|
|
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.
|
98
|
+
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/browse_everything_bootstrap3"` instead.
|
101
99
|
|
102
100
|
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
101
|
|
104
102
|
## Testing
|
105
|
-
This is a Rails Engine which is tested using the [engine_cart](https://github.com/cbeer/engine_cart) Gem
|
103
|
+
This is a Rails Engine which is tested using the [engine_cart](https://github.com/cbeer/engine_cart) Gem and rspec.
|
104
|
+
|
105
|
+
One rspec test invokes [karma](https://karma-runner.github.io/latest/index.html) to run Javascript tests. For this test to succeed, you need to install karma on your system, first by making sure `npm` is installed, and then run `npm install -g karma karma-jasmine karma-chrome-launcher`.
|
106
|
+
|
107
|
+
Test suites may be executed with the following invocation:
|
106
108
|
|
107
109
|
```bash
|
108
110
|
bundle exec rake
|
@@ -1,26 +1,20 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
$(function() {
|
8
|
-
let dialog = $('div#browse-everything');
|
9
|
-
|
10
|
-
const initialize = function(obj,options) {
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
$(function () {
|
4
|
+
var dialog = $('div#browse-everything');
|
5
|
+
|
6
|
+
var initialize = function initialize(obj, options) {
|
11
7
|
if ($('div#browse-everything').length === 0) {
|
12
8
|
// bootstrap 4 needs at least the inner class="modal-dialog" div, or it gets really
|
13
9
|
// 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');
|
10
|
+
dialog = $('<div tabindex="-1" id="browse-everything" class="ev-browser modal fade" aria-live="polite" role="dialog" aria-labelledby="beModalLabel">' + '<div class="modal-dialog modal-lg" role="document"></div>' + '</div>').hide().appendTo('body');
|
17
11
|
}
|
18
12
|
|
19
13
|
dialog.modal({
|
20
14
|
backdrop: 'static',
|
21
|
-
show:
|
15
|
+
show: false
|
22
16
|
});
|
23
|
-
|
17
|
+
var ctx = {
|
24
18
|
opts: $.extend(true, {}, options),
|
25
19
|
callbacks: {
|
26
20
|
show: $.Callbacks(),
|
@@ -30,36 +24,42 @@ $(function() {
|
|
30
24
|
}
|
31
25
|
};
|
32
26
|
ctx.callback_proxy = {
|
33
|
-
show
|
34
|
-
|
35
|
-
|
36
|
-
|
27
|
+
show: function show(func) {
|
28
|
+
ctx.callbacks.show.add(func);return this;
|
29
|
+
},
|
30
|
+
done: function done(func) {
|
31
|
+
ctx.callbacks.done.add(func);return this;
|
32
|
+
},
|
33
|
+
cancel: function cancel(func) {
|
34
|
+
ctx.callbacks.cancel.add(func);return this;
|
35
|
+
},
|
36
|
+
fail: function fail(func) {
|
37
|
+
ctx.callbacks.fail.add(func);return this;
|
38
|
+
}
|
37
39
|
};
|
38
|
-
$(obj).data('ev-state',ctx);
|
40
|
+
$(obj).data('ev-state', ctx);
|
39
41
|
return ctx;
|
40
42
|
};
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
-
.split('
|
45
|
-
|
46
|
-
|
47
|
-
return $("<input type='hidden'/>")
|
48
|
-
.attr('name',decodeURIComponent(this[0]))
|
49
|
-
.val(decodeURIComponent(this[1]))[0].outerHTML;
|
44
|
+
var toHiddenFields = function toHiddenFields(data) {
|
45
|
+
var fields = $.param(data).split('&').map(function (t) {
|
46
|
+
return t.replace(/\+/g, ' ').split('=', 2);
|
47
|
+
});
|
48
|
+
var elements = $(fields).map(function () {
|
49
|
+
return $("<input type='hidden'/>").attr('name', decodeURIComponent(this[0])).val(decodeURIComponent(this[1]))[0].outerHTML;
|
50
50
|
});
|
51
51
|
return $(elements.toArray().join("\n"));
|
52
52
|
};
|
53
53
|
|
54
|
-
|
55
|
-
$('input.ev-url').each(function() {
|
56
|
-
return $(
|
57
|
-
})
|
58
|
-
;
|
54
|
+
var indicateSelected = function indicateSelected() {
|
55
|
+
return $('input.ev-url').each(function () {
|
56
|
+
return $('*[data-ev-location=\'' + $(this).val() + '\']').addClass('ev-selected');
|
57
|
+
});
|
58
|
+
};
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
$('input.ev-url').each(function() {
|
60
|
+
var fileIsSelected = function fileIsSelected(row) {
|
61
|
+
var result = false;
|
62
|
+
$('input.ev-url').each(function () {
|
63
63
|
if (this.value === $(row).data('ev-location')) {
|
64
64
|
return result = true;
|
65
65
|
}
|
@@ -67,7 +67,7 @@ $(function() {
|
|
67
67
|
return result;
|
68
68
|
};
|
69
69
|
|
70
|
-
|
70
|
+
var toggleFileSelect = function toggleFileSelect(row) {
|
71
71
|
row.toggleClass('ev-selected');
|
72
72
|
if (row.hasClass('ev-selected')) {
|
73
73
|
selectFile(row);
|
@@ -77,70 +77,74 @@ $(function() {
|
|
77
77
|
return updateFileCount();
|
78
78
|
};
|
79
79
|
|
80
|
-
var selectFile = function(row) {
|
81
|
-
|
82
|
-
|
83
|
-
|
80
|
+
var selectFile = function selectFile(row) {
|
81
|
+
var target_form = $('form.ev-submit-form');
|
82
|
+
var file_location = row.data('ev-location');
|
83
|
+
var hidden_input = $("<input type='hidden' class='ev-url' name='selected_files[]'/>").val(file_location);
|
84
84
|
target_form.append(hidden_input);
|
85
85
|
if (!$(row).find('.ev-select-file').prop('checked')) {
|
86
86
|
return $(row).find('.ev-select-file').prop('checked', true);
|
87
87
|
}
|
88
88
|
};
|
89
89
|
|
90
|
-
var unselectFile = function(row) {
|
91
|
-
|
92
|
-
|
93
|
-
$(
|
90
|
+
var unselectFile = function unselectFile(row) {
|
91
|
+
var target_form = $('form.ev-submit-form');
|
92
|
+
var file_location = row.data('ev-location');
|
93
|
+
$('form.ev-submit-form input[value=\'' + file_location + '\']').remove();
|
94
94
|
if ($(row).find('.ev-select-file').prop('checked')) {
|
95
|
-
|
96
|
-
|
95
|
+
return $(row).find('.ev-select-file').prop('checked', false);
|
96
|
+
}
|
97
97
|
};
|
98
98
|
|
99
|
-
var updateFileCount = function() {
|
100
|
-
|
101
|
-
|
102
|
-
return $('.ev-status').html(
|
99
|
+
var updateFileCount = function updateFileCount() {
|
100
|
+
var count = $('input.ev-url').length;
|
101
|
+
var files = count === 1 ? "file" : "files";
|
102
|
+
return $('.ev-status').html(count + ' ' + files + ' selected');
|
103
103
|
};
|
104
104
|
|
105
|
-
|
105
|
+
var toggleBranchSelect = function toggleBranchSelect(row) {
|
106
106
|
if (row.hasClass('collapsed')) {
|
107
|
-
|
108
|
-
return $('table#file-list').treetable('expandNode',node_id);
|
107
|
+
var node_id = row.find('td.ev-file-name a.ev-link').attr('href');
|
108
|
+
return $('table#file-list').treetable('expandNode', node_id);
|
109
109
|
}
|
110
110
|
};
|
111
111
|
|
112
|
-
|
113
|
-
rows.each(function() {
|
112
|
+
var selectAll = function selectAll(rows) {
|
113
|
+
return rows.each(function () {
|
114
114
|
if ($(this).data('tt-branch')) {
|
115
|
-
|
115
|
+
var box = $(this).find('#select_all')[0];
|
116
116
|
$(box).prop('checked', true);
|
117
117
|
$(box).prop('value', "1");
|
118
118
|
return toggleBranchSelect($(this));
|
119
119
|
} else {
|
120
|
-
if (!fileIsSelected($(this))) {
|
120
|
+
if (!fileIsSelected($(this))) {
|
121
|
+
return toggleFileSelect($(this));
|
122
|
+
}
|
121
123
|
}
|
122
|
-
})
|
123
|
-
;
|
124
|
+
});
|
125
|
+
};
|
124
126
|
|
125
|
-
|
126
|
-
$('table#file-list tr').each(function() {
|
127
|
+
var selectChildRows = function selectChildRows(row, action) {
|
128
|
+
return $('table#file-list tr').each(function () {
|
127
129
|
if ($(this).data('tt-parent-id')) {
|
128
|
-
|
130
|
+
var re = RegExp($(row).data('tt-id'), 'i');
|
129
131
|
if ($(this).data('tt-parent-id').match(re)) {
|
130
132
|
if ($(this).data('tt-branch')) {
|
131
|
-
|
133
|
+
var box = $(this).find('#select_all')[0];
|
132
134
|
$(box).prop('value', action);
|
133
135
|
if (action === "1") {
|
134
136
|
$(box).prop("checked", true);
|
135
|
-
|
136
|
-
return $('table#file-list').treetable('expandNode',node_id);
|
137
|
+
var node_id = $(this).find('td.ev-file-name a.ev-link').attr('href');
|
138
|
+
return $('table#file-list').treetable('expandNode', node_id);
|
137
139
|
} else {
|
138
140
|
return $(box).prop("checked", false);
|
139
141
|
}
|
140
142
|
} else {
|
141
143
|
if (action === "1") {
|
142
144
|
$(this).addClass('ev-selected');
|
143
|
-
if (!fileIsSelected($(this))) {
|
145
|
+
if (!fileIsSelected($(this))) {
|
146
|
+
selectFile($(this));
|
147
|
+
}
|
144
148
|
} else {
|
145
149
|
$(this).removeClass('ev-selected');
|
146
150
|
unselectFile($(this));
|
@@ -149,49 +153,53 @@ $(function() {
|
|
149
153
|
}
|
150
154
|
}
|
151
155
|
}
|
152
|
-
})
|
153
|
-
;
|
156
|
+
});
|
157
|
+
};
|
154
158
|
|
155
|
-
|
159
|
+
var tableSetup = function tableSetup(table) {
|
156
160
|
table.treetable({
|
157
161
|
expandable: true,
|
158
|
-
onNodeCollapse() {
|
159
|
-
|
162
|
+
onNodeCollapse: function onNodeCollapse() {
|
163
|
+
var node = this;
|
160
164
|
return table.treetable("unloadBranch", node);
|
161
165
|
},
|
162
|
-
onNodeExpand() {
|
163
|
-
|
166
|
+
onNodeExpand: function onNodeExpand() {
|
167
|
+
var node = this;
|
164
168
|
startWait();
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
if (size.indexOf("MB")
|
169
|
+
var size = $(node.row).find('td.ev-file-size').text().trim();
|
170
|
+
var start = 1;
|
171
|
+
var increment = 1;
|
172
|
+
if (size.indexOf("MB") > -1) {
|
169
173
|
start = 10;
|
170
174
|
increment = 5;
|
171
175
|
}
|
172
|
-
if (size.indexOf("KB")
|
176
|
+
if (size.indexOf("KB") > -1) {
|
173
177
|
start = 50;
|
174
178
|
increment = 10;
|
175
179
|
}
|
176
180
|
setProgress(start);
|
177
|
-
|
181
|
+
var progressIntervalID = setInterval(function () {
|
178
182
|
start = start + increment;
|
179
183
|
if (start > 99) {
|
180
184
|
start = 99;
|
181
185
|
}
|
182
186
|
return setProgress(start);
|
183
|
-
}
|
184
|
-
return setTimeout(
|
187
|
+
}, 2000);
|
188
|
+
return setTimeout(function () {
|
189
|
+
return loadFiles(node, table, progressIntervalID);
|
190
|
+
}, 10);
|
185
191
|
}
|
186
192
|
});
|
187
193
|
$("#file-list tr:first").focus();
|
188
194
|
return sizeColumns(table);
|
189
195
|
};
|
190
196
|
|
191
|
-
var sizeColumns = function(table) {
|
192
|
-
|
197
|
+
var sizeColumns = function sizeColumns(table) {
|
198
|
+
var full_width = $('.ev-files').width();
|
193
199
|
table.width(full_width);
|
194
|
-
|
200
|
+
var set_size = function set_size(selector, pct) {
|
201
|
+
return $(selector, table).width(full_width * pct).css('width', full_width * pct).css('max-width', full_width * pct);
|
202
|
+
};
|
195
203
|
set_size('.ev-file', 0.4);
|
196
204
|
set_size('.ev-container', 0.4);
|
197
205
|
set_size('.ev-size', 0.1);
|
@@ -199,80 +207,105 @@ $(function() {
|
|
199
207
|
return set_size('.ev-date', 0.2);
|
200
208
|
};
|
201
209
|
|
202
|
-
var loadFiles = (node, table, progressIntervalID)
|
203
|
-
$.ajax({
|
210
|
+
var loadFiles = function loadFiles(node, table, progressIntervalID) {
|
211
|
+
return $.ajax({
|
204
212
|
async: true, // Must be false, otherwise loadBranch happens after showChildren?
|
205
|
-
url: $('a.ev-link',node.row).attr('href'),
|
213
|
+
url: $('a.ev-link', node.row).attr('href'),
|
206
214
|
data: {
|
207
215
|
parent: node.row.data('tt-id'),
|
208
216
|
accept: dialog.data('ev-state').opts.accept,
|
209
217
|
context: dialog.data('ev-state').opts.context
|
210
|
-
}}).done(function(html) {
|
218
|
+
} }).done(function (html) {
|
211
219
|
setProgress('100');
|
212
220
|
clearInterval(progressIntervalID);
|
213
|
-
|
221
|
+
var rows = $('tbody tr', $(html));
|
214
222
|
table.treetable("loadBranch", node, rows);
|
215
223
|
$(node).show();
|
216
224
|
sizeColumns(table);
|
217
225
|
indicateSelected();
|
218
226
|
if ($(node.row).find('#select_all')[0].checked) {
|
219
227
|
return selectAll(rows);
|
220
|
-
}
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
228
|
+
}
|
229
|
+
}).always(function () {
|
230
|
+
clearInterval(progressIntervalID);
|
231
|
+
return stopWait();
|
232
|
+
});
|
233
|
+
};
|
225
234
|
|
226
|
-
var setProgress =
|
235
|
+
var setProgress = function setProgress(done) {
|
236
|
+
return $('.loading-text').text(done + '% complete');
|
237
|
+
};
|
227
238
|
|
228
|
-
|
239
|
+
var refreshFiles = function refreshFiles() {
|
240
|
+
return $('.ev-providers select').change();
|
241
|
+
};
|
229
242
|
|
230
|
-
var startWait = function() {
|
243
|
+
var startWait = function startWait() {
|
231
244
|
$('.loading-progress').removeClass("hidden");
|
232
|
-
$('body').css('cursor','wait');
|
245
|
+
$('body').css('cursor', 'wait');
|
233
246
|
$("html").addClass("wait");
|
234
247
|
$(".ev-browser").addClass("loading");
|
235
248
|
return $('.ev-submit').attr('disabled', true);
|
236
249
|
};
|
237
250
|
|
238
|
-
var stopWait = function() {
|
251
|
+
var stopWait = function stopWait() {
|
239
252
|
$('.loading-progress').addClass("hidden");
|
240
|
-
$('body').css('cursor','default');
|
253
|
+
$('body').css('cursor', 'default');
|
241
254
|
$("html").removeClass("wait");
|
242
255
|
$(".ev-browser").removeClass("loading");
|
243
256
|
return $('.ev-submit').attr('disabled', false);
|
244
257
|
};
|
245
258
|
|
246
|
-
$(window).on('resize', ()
|
259
|
+
$(window).on('resize', function () {
|
260
|
+
return sizeColumns($('table#file-list'));
|
261
|
+
});
|
262
|
+
|
263
|
+
$.fn.browseEverything = function (options) {
|
264
|
+
var ctx = $(this).data('ev-state');
|
265
|
+
|
266
|
+
// Try and load the options from the HTML data attributes
|
267
|
+
if (ctx == null && options == null) {
|
268
|
+
options = $(this).data();
|
269
|
+
}
|
247
270
|
|
248
|
-
$.fn.browseEverything = function(options) {
|
249
|
-
let ctx = $(this).data('ev-state');
|
250
|
-
if ((ctx == null) && (options == null)) { options = $(this).data(); }
|
251
271
|
if (options != null) {
|
252
272
|
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
273
|
}
|
262
274
|
|
275
|
+
$(this).click(function () {
|
276
|
+
dialog.data('ev-state', ctx);
|
277
|
+
return dialog.load(ctx.opts.route, function () {
|
278
|
+
setTimeout(refreshFiles, 50);
|
279
|
+
ctx.callbacks.show.fire();
|
280
|
+
dialog.removeClass('fade')
|
281
|
+
.removeClass('in')
|
282
|
+
.addClass('show');
|
283
|
+
|
284
|
+
return dialog.modal('show');
|
285
|
+
});
|
286
|
+
});
|
287
|
+
|
263
288
|
if (ctx) {
|
264
289
|
return ctx.callback_proxy;
|
265
290
|
} else {
|
266
291
|
return {
|
267
|
-
show() {
|
268
|
-
|
269
|
-
|
270
|
-
|
292
|
+
show: function show() {
|
293
|
+
return this;
|
294
|
+
},
|
295
|
+
done: function done() {
|
296
|
+
return this;
|
297
|
+
},
|
298
|
+
cancel: function cancel() {
|
299
|
+
return this;
|
300
|
+
},
|
301
|
+
fail: function fail() {
|
302
|
+
return this;
|
303
|
+
}
|
271
304
|
};
|
272
305
|
}
|
273
306
|
};
|
274
307
|
|
275
|
-
$.fn.browseEverything.toggleCheckbox = function(box) {
|
308
|
+
$.fn.browseEverything.toggleCheckbox = function (box) {
|
276
309
|
if (box.value === "0") {
|
277
310
|
return $(box).prop('value', "1");
|
278
311
|
} else {
|
@@ -280,48 +313,53 @@ $(function() {
|
|
280
313
|
}
|
281
314
|
};
|
282
315
|
|
283
|
-
$(document).on('ev.refresh',
|
316
|
+
$(document).on('ev.refresh', function (event) {
|
317
|
+
return refreshFiles();
|
318
|
+
});
|
284
319
|
|
285
|
-
$(document).on('click', 'button.ev-cancel', function(event) {
|
320
|
+
$(document).on('click', 'button.ev-cancel', function (event) {
|
286
321
|
event.preventDefault();
|
287
322
|
dialog.data('ev-state').callbacks.cancel.fire();
|
288
323
|
return $('.ev-browser').modal('hide');
|
289
324
|
});
|
290
325
|
|
291
|
-
$(document).on('click', 'button.ev-submit', function(event) {
|
326
|
+
$(document).on('click', 'button.ev-submit', function (event) {
|
292
327
|
event.preventDefault();
|
293
328
|
$(this).button('loading');
|
294
329
|
startWait();
|
295
|
-
|
296
|
-
|
297
|
-
|
330
|
+
var main_form = $(this).closest('form');
|
331
|
+
var resolver_url = main_form.data('resolver');
|
332
|
+
var ctx = dialog.data('ev-state');
|
298
333
|
$(main_form).find('input[name=context]').val(ctx.opts.context);
|
299
334
|
return $.ajax(resolver_url, {
|
300
335
|
type: 'POST',
|
301
336
|
dataType: 'json',
|
302
337
|
data: main_form.serialize()
|
303
|
-
}).done(function(data) {
|
338
|
+
}).done(function (data) {
|
304
339
|
if (ctx.opts.target != null) {
|
305
|
-
|
340
|
+
var fields = toHiddenFields({ selected_files: data });
|
306
341
|
$(ctx.opts.target).append($(fields));
|
307
342
|
}
|
308
|
-
return ctx.callbacks.done.fire(data);
|
309
|
-
|
343
|
+
return ctx.callbacks.done.fire(data);
|
344
|
+
}).fail(function (xhr, status, error) {
|
345
|
+
return ctx.callbacks.fail.fire(status, error, xhr.responseText);
|
346
|
+
}).always(function () {
|
347
|
+
$('body').css('cursor', 'default');
|
310
348
|
$('.ev-browser').modal('hide');
|
311
349
|
return $('#browse-btn').focus();
|
312
350
|
});
|
313
351
|
});
|
314
352
|
|
315
|
-
$(document).on('click', '.ev-files .ev-container a.ev-link', function(event) {
|
353
|
+
$(document).on('click', '.ev-files .ev-container a.ev-link', function (event) {
|
316
354
|
event.stopPropagation();
|
317
355
|
event.preventDefault();
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
return $('table#file-list').treetable(action,node_id);
|
356
|
+
var row = $(this).closest('tr');
|
357
|
+
var action = row.hasClass('expanded') ? 'collapseNode' : 'expandNode';
|
358
|
+
var node_id = $(this).attr('href');
|
359
|
+
return $('table#file-list').treetable(action, node_id);
|
322
360
|
});
|
323
361
|
|
324
|
-
$(document).on('change', '.ev-providers select', function(event) {
|
362
|
+
$(document).on('change', '.ev-providers select', function (event) {
|
325
363
|
event.preventDefault();
|
326
364
|
startWait();
|
327
365
|
return $.ajax({
|
@@ -329,33 +367,37 @@ $(function() {
|
|
329
367
|
data: {
|
330
368
|
accept: dialog.data('ev-state').opts.accept,
|
331
369
|
context: dialog.data('ev-state').opts.context
|
332
|
-
}}).done(function(data) {
|
370
|
+
} }).done(function (data) {
|
333
371
|
$('.ev-files').html(data);
|
334
372
|
indicateSelected();
|
335
373
|
$('#provider_auth').focus();
|
336
|
-
return tableSetup($('table#file-list'));
|
337
|
-
|
374
|
+
return tableSetup($('table#file-list'));
|
375
|
+
}).fail(function (xhr, status, error) {
|
376
|
+
if (xhr.responseText.indexOf("Refresh token has expired") > -1) {
|
338
377
|
return $('.ev-files').html("Your sessison has expired please clear your cookies.");
|
339
378
|
} else {
|
340
379
|
return $('.ev-files').html(xhr.responseText);
|
341
|
-
}
|
380
|
+
}
|
381
|
+
}).always(function () {
|
382
|
+
return stopWait();
|
383
|
+
});
|
342
384
|
});
|
343
385
|
|
344
|
-
$(document).on('click', '.ev-providers a', function(event) {
|
386
|
+
$(document).on('click', '.ev-providers a', function (event) {
|
345
387
|
$('.ev-providers li').removeClass('ev-selected');
|
346
388
|
return $(this).closest('li').addClass('ev-selected');
|
347
389
|
});
|
348
390
|
|
349
|
-
$(document).on('click', '.ev-file a', function(event) {
|
391
|
+
$(document).on('click', '.ev-file a', function (event) {
|
350
392
|
event.preventDefault();
|
351
|
-
|
393
|
+
var target = $(this).closest('*[data-ev-location]');
|
352
394
|
return toggleFileSelect(target);
|
353
395
|
});
|
354
396
|
|
355
|
-
$(document).on('click', '.ev-auth', function(event) {
|
397
|
+
$(document).on('click', '.ev-auth', function (event) {
|
356
398
|
event.preventDefault();
|
357
|
-
|
358
|
-
var check_func = function() {
|
399
|
+
var auth_win = window.open($(this).attr('href'));
|
400
|
+
var check_func = function check_func() {
|
359
401
|
if (auth_win.closed) {
|
360
402
|
return $('.ev-providers .ev-selected a').click();
|
361
403
|
} else {
|
@@ -365,43 +407,44 @@ $(function() {
|
|
365
407
|
return check_func();
|
366
408
|
});
|
367
409
|
|
368
|
-
$(document).on('change', 'input.ev-select-all', function(event) {
|
410
|
+
$(document).on('change', 'input.ev-select-all', function (event) {
|
369
411
|
event.stopPropagation();
|
370
412
|
event.preventDefault();
|
371
413
|
$.fn.browseEverything.toggleCheckbox(this);
|
372
|
-
|
373
|
-
|
374
|
-
|
414
|
+
var action = this.value;
|
415
|
+
var row = $(this).closest('tr');
|
416
|
+
var node_id = row.find('td.ev-file-name a.ev-link').attr('href');
|
375
417
|
if (row.hasClass('collapsed')) {
|
376
|
-
return $('table#file-list').treetable('expandNode',node_id);
|
418
|
+
return $('table#file-list').treetable('expandNode', node_id);
|
377
419
|
} else {
|
378
420
|
return selectChildRows(row, action);
|
379
421
|
}
|
380
422
|
});
|
381
423
|
|
382
|
-
return $(document).on('change', 'input.ev-select-file', function(event) {
|
424
|
+
return $(document).on('change', 'input.ev-select-file', function (event) {
|
383
425
|
event.stopPropagation();
|
384
426
|
event.preventDefault();
|
385
427
|
return toggleFileSelect($(this).closest('tr'));
|
386
428
|
});
|
387
429
|
});
|
388
430
|
|
389
|
-
|
390
|
-
|
391
|
-
const triggers = $('*[data-toggle=browse-everything]');
|
431
|
+
var auto_toggle = function auto_toggle() {
|
432
|
+
var triggers = $('*[data-toggle=browse-everything]');
|
392
433
|
if (typeof Rails !== 'undefined' && Rails !== null) {
|
393
434
|
$.ajaxSetup({
|
394
|
-
|
435
|
+
headers: { 'X-CSRF-TOKEN': (Rails || $.rails).csrfToken() || '' }
|
395
436
|
});
|
396
437
|
}
|
397
438
|
|
398
|
-
return triggers.each(function() {
|
399
|
-
|
400
|
-
if (ctx == null) {
|
439
|
+
return triggers.each(function () {
|
440
|
+
var ctx = $(this).data('ev-state');
|
441
|
+
if (ctx == null) {
|
442
|
+
return $(this).browseEverything($(this).data());
|
443
|
+
}
|
401
444
|
});
|
402
445
|
};
|
403
446
|
|
404
|
-
if (
|
447
|
+
if (typeof Turbolinks !== 'undefined' && Turbolinks !== null && Turbolinks.supported) {
|
405
448
|
// Use turbolinks:load for Turbolinks 5, otherwise use the old way
|
406
449
|
if (Turbolinks.BrowserAdapter) {
|
407
450
|
$(document).on('turbolinks:load', auto_toggle);
|