trestle 0.8.3 → 0.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/.travis.yml +10 -1
- data/Gemfile +4 -0
- data/README.md +1 -0
- data/app/assets/javascripts/trestle/admin.js +24 -0
- data/app/assets/javascripts/trestle/components/_confirmation.js +23 -0
- data/app/assets/javascripts/trestle/components/_datepicker.js +22 -0
- data/app/assets/javascripts/trestle/components/_dialog.js +107 -0
- data/app/assets/javascripts/trestle/components/_errors.js +11 -0
- data/app/assets/javascripts/trestle/components/_form.js +48 -0
- data/app/assets/javascripts/trestle/components/_gallery.js +27 -0
- data/app/assets/javascripts/trestle/components/_select.js +11 -0
- data/app/assets/javascripts/trestle/components/_sidebar.js +75 -0
- data/app/assets/javascripts/trestle/components/_table.js +21 -0
- data/app/assets/javascripts/trestle/components/_tabs.js +24 -0
- data/app/assets/javascripts/trestle/components/_tooltips.js +3 -0
- data/app/assets/javascripts/trestle/core/_contexts.js +13 -0
- data/app/assets/javascripts/trestle/core/_cookies.js +24 -0
- data/app/assets/javascripts/trestle/core/_events.js +39 -0
- data/app/assets/javascripts/trestle/core/_visit.js +10 -0
- data/app/assets/javascripts/trestle/custom.js +4 -0
- data/app/assets/stylesheets/trestle/components/_alerts.scss +28 -0
- data/app/assets/stylesheets/trestle/components/_buttons.scss +9 -0
- data/app/assets/stylesheets/trestle/components/_modal.scss +92 -0
- data/app/assets/stylesheets/trestle/components/_navigation.scss +80 -10
- data/app/assets/stylesheets/trestle/components/_sidebar.scss +1 -0
- data/app/assets/stylesheets/trestle/components/_table.scss +6 -0
- data/app/assets/stylesheets/trestle/core/_defaults.scss +5 -1
- data/app/controllers/trestle/application_controller.rb +5 -1
- data/app/helpers/trestle/dialog_helper.rb +7 -0
- data/app/helpers/trestle/form_helper.rb +8 -1
- data/app/helpers/trestle/format_helper.rb +48 -0
- data/app/helpers/trestle/hook_helper.rb +8 -3
- data/app/helpers/trestle/url_helper.rb +33 -11
- data/app/views/layouts/trestle/admin.html.erb +4 -4
- data/app/views/trestle/admin/index.html.erb +1 -1
- data/app/views/trestle/application/_alert.html.erb +2 -0
- data/app/views/trestle/application/_dialog.html.erb +36 -0
- data/app/views/trestle/application/_flash.html.erb +18 -4
- data/app/views/trestle/application/_tabs.html.erb +7 -1
- data/app/views/trestle/dashboard/index.html.erb +2 -2
- data/app/views/trestle/resource/_form.html.erb +1 -1
- data/app/views/trestle/resource/edit.html.erb +6 -6
- data/app/views/trestle/resource/index.html.erb +5 -2
- data/app/views/trestle/resource/new.html.erb +4 -4
- data/app/views/trestle/resource/show.html.erb +6 -6
- data/app/views/trestle/shared/_sidebar.html.erb +7 -4
- data/bower.json +2 -2
- data/config/locales/en.yml +38 -18
- data/config/locales/fr.rb +18 -0
- data/config/locales/fr.yml +69 -0
- data/config/locales/nl.rb +18 -0
- data/config/locales/nl.yml +67 -0
- data/config/locales/pl.rb +18 -0
- data/config/locales/pl.yml +70 -0
- data/config/locales/pt-BR.rb +18 -0
- data/config/locales/pt-BR.yml +69 -0
- data/gemfiles/rails-4.2.gemfile +14 -0
- data/gemfiles/rails-5.0.gemfile +14 -0
- data/gemfiles/rails-5.1.gemfile +14 -0
- data/gemfiles/rails-edge.gemfile +15 -0
- data/lib/generators/trestle/install/install_generator.rb +3 -3
- data/lib/generators/trestle/install/templates/custom.js +7 -0
- data/lib/generators/trestle/install/templates/trestle.rb.erb +9 -2
- data/lib/generators/trestle/resource/templates/admin.rb.erb +1 -1
- data/lib/trestle/adapters/active_record_adapter.rb +46 -20
- data/lib/trestle/adapters/adapter.rb +176 -0
- data/lib/trestle/adapters/sequel_adapter.rb +85 -0
- data/lib/trestle/adapters.rb +7 -64
- data/lib/trestle/admin/builder.rb +10 -2
- data/lib/trestle/admin.rb +14 -1
- data/lib/trestle/attribute.rb +14 -37
- data/lib/trestle/breadcrumb.rb +19 -0
- data/lib/trestle/configuration.rb +14 -3
- data/lib/trestle/display.rb +1 -1
- data/lib/trestle/form/automatic.rb +29 -21
- data/lib/trestle/form/builder.rb +4 -0
- data/lib/trestle/form/field.rb +2 -2
- data/lib/trestle/form/fields/check_box.rb +1 -1
- data/lib/trestle/form/fields/collection_select.rb +1 -1
- data/lib/trestle/form/fields/date_select.rb +1 -1
- data/lib/trestle/form/fields/datetime_select.rb +1 -1
- data/lib/trestle/form/fields/grouped_collection_select.rb +1 -1
- data/lib/trestle/form/fields/select.rb +2 -2
- data/lib/trestle/form/fields/tag_select.rb +1 -2
- data/lib/trestle/form/fields/time_select.rb +1 -1
- data/lib/trestle/form/fields/time_zone_select.rb +1 -1
- data/lib/trestle/form.rb +7 -3
- data/lib/trestle/model_name.rb +64 -0
- data/lib/trestle/navigation/group.rb +8 -0
- data/lib/trestle/navigation/item.rb +1 -1
- data/lib/trestle/options.rb +7 -5
- data/lib/trestle/reloader.rb +1 -1
- data/lib/trestle/resource/builder.rb +17 -1
- data/lib/trestle/resource/controller.rb +80 -18
- data/lib/trestle/resource.rb +26 -16
- data/lib/trestle/scope.rb +1 -1
- data/lib/trestle/table/actions_column.rb +21 -16
- data/lib/trestle/table/automatic.rb +5 -12
- data/lib/trestle/table/builder.rb +3 -2
- data/lib/trestle/table/column.rb +27 -45
- data/lib/trestle/table/row.rb +8 -2
- data/lib/trestle/table.rb +7 -1
- data/lib/trestle/version.rb +1 -1
- data/lib/trestle.rb +1 -0
- data/trestle.gemspec +5 -5
- data/vendor/assets/bower_components/trestle/flatpickr/dist/flatpickr.css +51 -26
- data/vendor/assets/bower_components/trestle/flatpickr/dist/flatpickr.js +349 -299
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/ar.js +5 -5
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/bg.js +5 -5
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/bn.js +5 -5
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/cat.js +7 -7
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/cs.js +7 -7
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/cy.js +7 -7
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/da.js +6 -6
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/de.js +10 -10
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/eo.js +11 -11
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/es.js +7 -7
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/et.js +11 -11
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/fa.js +6 -6
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/fi.js +7 -7
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/fr.js +11 -11
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/gr.js +13 -13
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/he.js +5 -5
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/hi.js +5 -5
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/hr.js +6 -6
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/hu.js +10 -10
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/id.js +7 -7
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/index.js +97 -0
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/it.js +10 -10
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/ja.js +5 -5
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/ko.js +6 -6
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/lt.js +10 -10
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/lv.js +6 -6
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/mk.js +8 -8
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/ms.js +7 -7
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/my.js +7 -7
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/nl.js +11 -11
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/no.js +11 -11
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/pa.js +5 -5
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/pl.js +6 -6
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/pt.js +6 -8
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/ro.js +7 -9
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/ru.js +6 -8
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/si.js +5 -7
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/sk.js +8 -8
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/sl.js +8 -10
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/sq.js +5 -7
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/sr.js +9 -10
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/sv.js +8 -10
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/th.js +10 -11
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/tr.js +6 -8
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/uk.js +6 -7
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/vn.js +6 -8
- data/vendor/assets/bower_components/trestle/flatpickr/dist/l10n/zh.js +9 -11
- data/vendor/assets/bower_components/trestle/select2/dist/js/select2.full.js +90 -69
- metadata +58 -33
- data/app/assets/javascripts/trestle/_confirmation.js.coffee +0 -18
- data/app/assets/javascripts/trestle/_datepicker.js.coffee +0 -18
- data/app/assets/javascripts/trestle/_errors.js.coffee +0 -8
- data/app/assets/javascripts/trestle/_form.js.coffee +0 -4
- data/app/assets/javascripts/trestle/_gallery.js.coffee +0 -21
- data/app/assets/javascripts/trestle/_select.js.coffee +0 -7
- data/app/assets/javascripts/trestle/_sidebar.js.coffee +0 -45
- data/app/assets/javascripts/trestle/_table.js.coffee +0 -16
- data/app/assets/javascripts/trestle/_tabs.js.coffee +0 -9
- data/app/assets/javascripts/trestle/_tooltips.js.coffee +0 -2
- data/app/assets/javascripts/trestle/admin.js.coffee +0 -22
- data/app/assets/javascripts/trestle/custom.js.coffee +0 -4
- data/lib/generators/trestle/install/templates/custom.js.coffee +0 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1f07f2d3328a13c6ac319c7e04b8926a0dc09660
|
|
4
|
+
data.tar.gz: a8adb65b4c3bd295c5e80397fba9c8968d08febd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9d565ea8bd72cca11c5eb2de1ea72332e8980093e5f4147f598f64958ee82b3f1799de37dc7c2c99b68cbb773821454ee62c5230b4ba55bdc50828e516dc347e
|
|
7
|
+
data.tar.gz: da2e9069173f7fa34f0af87c392af4b00dc9ea5b9b42eb2e6cb3c2df536065bd9648b5482043260c748e919fa735127d3fafb32537e523fe356da52765d7221a
|
data/.gitignore
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/.bundle/
|
|
2
2
|
/.yardoc
|
|
3
3
|
/Gemfile.lock
|
|
4
|
+
/gemfiles/*.lock
|
|
4
5
|
/_yardoc/
|
|
5
6
|
/coverage/
|
|
6
7
|
/doc/
|
|
@@ -11,4 +12,7 @@
|
|
|
11
12
|
/sandbox/*.sqlite3-journal
|
|
12
13
|
/sandbox/log/*.log
|
|
13
14
|
/sandbox/tmp/
|
|
15
|
+
/spec/dummy/db/*.sqlite3
|
|
16
|
+
/spec/dummy/*.sqlite3-journal
|
|
14
17
|
/spec/dummy/log/*.log
|
|
18
|
+
/spec/dummy/tmp/*
|
data/.travis.yml
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
language: ruby
|
|
2
|
+
|
|
3
|
+
before_install:
|
|
4
|
+
- gem install bundler
|
|
5
|
+
|
|
2
6
|
rvm:
|
|
3
7
|
- 2.4.1
|
|
4
|
-
|
|
8
|
+
|
|
9
|
+
gemfile:
|
|
10
|
+
- gemfiles/rails-4.2.gemfile
|
|
11
|
+
- gemfiles/rails-5.0.gemfile
|
|
12
|
+
- gemfiles/rails-5.1.gemfile
|
|
13
|
+
- gemfiles/rails-edge.gemfile
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -92,6 +92,7 @@ The following plugins are currently available:
|
|
|
92
92
|
| *trestle-auth* | User authentication plugin | https://github.com/TrestleAdmin/trestle-auth |
|
|
93
93
|
| *trestle-search* | Search plugin | https://github.com/TrestleAdmin/trestle-search |
|
|
94
94
|
| *trestle-tinymce* | TinyMCE (WYSIWYG editor) integration | https://github.com/TrestleAdmin/trestle-tinymce |
|
|
95
|
+
| *trestle-simplemde* | SimpleMDE (Markdown editor) integration | https://github.com/TrestleAdmin/trestle-simplemde |
|
|
95
96
|
|
|
96
97
|
|
|
97
98
|
## License
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//= require trestle/jquery
|
|
2
|
+
//= require trestle/jquery_ujs
|
|
3
|
+
//= require trestle/bootstrap
|
|
4
|
+
//= require trestle/bootstrap-confirmation
|
|
5
|
+
//= require trestle/magnific-popup
|
|
6
|
+
//= require trestle/flatpickr
|
|
7
|
+
//= require trestle/select2
|
|
8
|
+
//
|
|
9
|
+
//= require_self
|
|
10
|
+
//
|
|
11
|
+
//= require_tree ./core
|
|
12
|
+
//= require_tree ./components
|
|
13
|
+
//
|
|
14
|
+
//= require trestle/custom
|
|
15
|
+
|
|
16
|
+
var Trestle = {
|
|
17
|
+
// Is Turbolinks enabled?
|
|
18
|
+
turbolinks: typeof(Turbolinks) !== 'undefined' && Turbolinks.supported,
|
|
19
|
+
|
|
20
|
+
// Store for i18n translations used within JS
|
|
21
|
+
i18n: {}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
window.Trestle = Trestle;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Trestle.ready(function() {
|
|
2
|
+
// This must be bound to an element beneath document so
|
|
3
|
+
// that it is fired before any jquery_ujs events.
|
|
4
|
+
var root = $('body');
|
|
5
|
+
|
|
6
|
+
// Ensure it is only initialized once
|
|
7
|
+
if (root.data('bs.confirmation')) return;
|
|
8
|
+
|
|
9
|
+
root.confirmation({
|
|
10
|
+
rootSelector: 'body',
|
|
11
|
+
selector: '[data-toggle="confirm-delete"]',
|
|
12
|
+
singleton: true,
|
|
13
|
+
popout: true,
|
|
14
|
+
title: Trestle.i18n['admin.confirmation.title'] || 'Are you sure?',
|
|
15
|
+
btnOkIcon: '',
|
|
16
|
+
btnOkClass: 'btn-danger',
|
|
17
|
+
btnOkLabel: Trestle.i18n['admin.confirmation.delete'] || 'Delete',
|
|
18
|
+
btnCancelIcon: '',
|
|
19
|
+
btnCancelClass: 'btn-default',
|
|
20
|
+
btnCancelLabel: Trestle.i18n['admin.confirmation.cancel'] || 'Cancel',
|
|
21
|
+
copyAttributes: ''
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Trestle.init(function(e, root) {
|
|
2
|
+
$(root).find('input[type="date"][data-picker="true"]').flatpickr({
|
|
3
|
+
allowInput: true,
|
|
4
|
+
altInput: true,
|
|
5
|
+
altFormat: "m/d/Y",
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
$(root).find('input[type="datetime"][data-picker="true"], input[type="datetime-local"][data-picker="true"]').flatpickr({
|
|
9
|
+
enableTime: true,
|
|
10
|
+
allowInput: true,
|
|
11
|
+
altInput: true,
|
|
12
|
+
altFormat: "m/d/Y h:i K",
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
$(root).find('input[type="time"][data-picker="true"]').flatpickr({
|
|
16
|
+
enableTime: true,
|
|
17
|
+
noCalendar: true,
|
|
18
|
+
allowInput: true,
|
|
19
|
+
altInput: true,
|
|
20
|
+
altFormat: "h:i K"
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
Trestle.Dialog = function() {
|
|
2
|
+
this.el = Trestle.Dialog.getElement();
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
Trestle.Dialog.TEMPLATE =
|
|
6
|
+
'<div id="dialog" class="modal fade" tabindex="-1">' +
|
|
7
|
+
'<div class="modal-dialog">' +
|
|
8
|
+
'<div class="modal-content" data-context></div>' +
|
|
9
|
+
'</div>' +
|
|
10
|
+
'</div>';
|
|
11
|
+
|
|
12
|
+
Trestle.Dialog.getElement = function() {
|
|
13
|
+
var el = $('#dialog');
|
|
14
|
+
|
|
15
|
+
if (el.length == 0) {
|
|
16
|
+
el = $(Trestle.Dialog.TEMPLATE).appendTo('body');
|
|
17
|
+
|
|
18
|
+
el.modal({ show: false });
|
|
19
|
+
|
|
20
|
+
// Remove dialog elements once hidden
|
|
21
|
+
el.on('hidden.bs.modal', function() {
|
|
22
|
+
el.remove();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Set X-Trestle-Dialog header on AJAX requests initiated from the dialog
|
|
26
|
+
el.on('ajax:beforeSend', '[data-remote]', function(e, xhr, options) {
|
|
27
|
+
xhr.setRequestHeader("X-Trestle-Dialog", true);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return el;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
Trestle.Dialog.prototype.load = function(url) {
|
|
35
|
+
var dialog = this;
|
|
36
|
+
|
|
37
|
+
dialog.show();
|
|
38
|
+
dialog.setLoading(true);
|
|
39
|
+
|
|
40
|
+
$.ajax({
|
|
41
|
+
url: url,
|
|
42
|
+
dataType: 'html',
|
|
43
|
+
headers: {
|
|
44
|
+
"X-Trestle-Dialog": true
|
|
45
|
+
},
|
|
46
|
+
complete: function() {
|
|
47
|
+
dialog.setLoading(false);
|
|
48
|
+
},
|
|
49
|
+
success: function(content) {
|
|
50
|
+
dialog.setContent(content);
|
|
51
|
+
},
|
|
52
|
+
error: function(xhr, status, error) {
|
|
53
|
+
dialog.showError(error);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
Trestle.Dialog.prototype.setLoading = function(loading) {
|
|
59
|
+
if (loading) {
|
|
60
|
+
this.el.addClass('loading');
|
|
61
|
+
} else {
|
|
62
|
+
this.el.removeClass('loading');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
Trestle.Dialog.prototype.setContent = function(content) {
|
|
67
|
+
this.el.find('.modal-content').html(content);
|
|
68
|
+
$(Trestle).trigger('init', this.el);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
Trestle.Dialog.prototype.showError = function(error) {
|
|
72
|
+
this.el.addClass('error');
|
|
73
|
+
|
|
74
|
+
var container = this.el.find('.modal-content').empty();
|
|
75
|
+
|
|
76
|
+
var errorMessage = Trestle.i18n['trestle.dialog.error'] || 'The request could not be completed.';
|
|
77
|
+
|
|
78
|
+
$('<div class="modal-header">')
|
|
79
|
+
.append('<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>')
|
|
80
|
+
.append('<h4 class="modal-title"></h4>').find('h4').text(error || errorMessage).end()
|
|
81
|
+
.appendTo(container);
|
|
82
|
+
|
|
83
|
+
$('<div class="modal-body">')
|
|
84
|
+
.append('<p>').find('p').text(errorMessage).end()
|
|
85
|
+
.appendTo(container);
|
|
86
|
+
|
|
87
|
+
$('<div class="modal-footer">')
|
|
88
|
+
.append('<button type="button" class="btn btn-default" data-dismiss="modal" aria-label="OK">').find('button').text(Trestle.i18n['admin.buttons.ok'] || 'OK').end()
|
|
89
|
+
.appendTo(container);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
Trestle.Dialog.prototype.show = function() {
|
|
93
|
+
this.el.modal('show');
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
Trestle.Dialog.prototype.hide = function() {
|
|
97
|
+
this.el.modal('hide');
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
$(document).on('click', '[data-behavior="dialog"]', function(e) {
|
|
101
|
+
e.preventDefault();
|
|
102
|
+
|
|
103
|
+
var url = $(this).data('url') || $(this).attr('href');
|
|
104
|
+
|
|
105
|
+
var dialog = new Trestle.Dialog();
|
|
106
|
+
dialog.load(url);
|
|
107
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Add error indicators to tabs
|
|
2
|
+
Trestle.init(function(e, root) {
|
|
3
|
+
$(root).find('.tab-pane').each(function() {
|
|
4
|
+
var errorCount = $(this).find('.has-error').length;
|
|
5
|
+
|
|
6
|
+
if (errorCount > 0) {
|
|
7
|
+
var indicator = $("<span>").addClass('label label-danger label-pill').text(errorCount);
|
|
8
|
+
$(".nav-tabs a[href='#" + $(this).attr('id') + "']").append(indicator);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Prevent enter key from submitting the form
|
|
2
|
+
$(document).on('keypress', 'form[data-behavior="trestle-form"] :input:not(textarea):not([type=submit])', function(e) {
|
|
3
|
+
if (e.keyCode == 13) {
|
|
4
|
+
e.preventDefault();
|
|
5
|
+
}
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
Trestle.init(function(e, root) {
|
|
9
|
+
var form = $(root).find('form[data-behavior="trestle-form"]');
|
|
10
|
+
|
|
11
|
+
form
|
|
12
|
+
.on('ajax:complete', function(e, xhr, status) {
|
|
13
|
+
// Find the parent context and replace content
|
|
14
|
+
var context = $(this).closest('[data-context]');
|
|
15
|
+
context.html(xhr.responseText);
|
|
16
|
+
|
|
17
|
+
// Initialize replaced elements within the context
|
|
18
|
+
$(Trestle).trigger('init', context);
|
|
19
|
+
|
|
20
|
+
// Focus the correct tab
|
|
21
|
+
Trestle.focusActiveTab();
|
|
22
|
+
})
|
|
23
|
+
.on('ajax:success', function(e, data, status, xhr) {
|
|
24
|
+
var context = $(this).closest('[data-context]');
|
|
25
|
+
var location = xhr.getResponseHeader("X-Trestle-Location");
|
|
26
|
+
|
|
27
|
+
if (location) {
|
|
28
|
+
// Update the URL in the browser and context
|
|
29
|
+
history.replaceState({}, "", location);
|
|
30
|
+
context.data('context', location);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Refresh the main context
|
|
34
|
+
if (!context.hasClass('app-main')) {
|
|
35
|
+
Trestle.refreshMainContext();
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Loading indicator
|
|
40
|
+
form.find(':submit').click(function() {
|
|
41
|
+
var button = $(this);
|
|
42
|
+
|
|
43
|
+
// Delay to ensure form is still submitted
|
|
44
|
+
setTimeout(function() {
|
|
45
|
+
button.prop('disabled', true).addClass('loading');
|
|
46
|
+
}, 1);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Trestle.init(function(e, root) {
|
|
2
|
+
$(root).find('[data-behavior~="zoom"]').magnificPopup({
|
|
3
|
+
type: 'image',
|
|
4
|
+
closeOnContentClick: false,
|
|
5
|
+
closeBtnInside: false,
|
|
6
|
+
mainClass: 'mfp-with-zoom mfp-img-mobile',
|
|
7
|
+
zoom: {
|
|
8
|
+
enabled: true,
|
|
9
|
+
duration: 150
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
$(root).find('[data-behavior~="gallery"]').magnificPopup({
|
|
14
|
+
delegate: 'a',
|
|
15
|
+
type: 'image',
|
|
16
|
+
closeOnContentClick: false,
|
|
17
|
+
closeBtnInside: false,
|
|
18
|
+
mainClass: 'mfp-with-zoom mfp-img-mobile',
|
|
19
|
+
gallery: {
|
|
20
|
+
enabled: true
|
|
21
|
+
},
|
|
22
|
+
zoom: {
|
|
23
|
+
enabled: true,
|
|
24
|
+
duration: 150
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Trestle.init(function(e, root) {
|
|
2
|
+
$(root).find('select[data-enable-select2]').each(function() {
|
|
3
|
+
$(this).select2({
|
|
4
|
+
theme: 'bootstrap',
|
|
5
|
+
containerCssClass: ':all:',
|
|
6
|
+
dropdownCssClass: function(el) {
|
|
7
|
+
return el[0].className.replace(/\s*form-control\s*/, '');
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
Trestle.ready(function() {
|
|
2
|
+
var sidebar = $('.app-sidebar');
|
|
3
|
+
|
|
4
|
+
// Toggle mobile navigation using menu button
|
|
5
|
+
|
|
6
|
+
sidebar.find('.navbar-toggle').on('click', function(e) {
|
|
7
|
+
e.preventDefault();
|
|
8
|
+
|
|
9
|
+
$('.app-wrapper').addClass('animate');
|
|
10
|
+
$('body').toggleClass('mobile-nav-expanded');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
$('.app-wrapper').on('transitionend webkitTransitionEnd', function() {
|
|
14
|
+
$(this).removeClass('animate');
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
// Interacting outside of the sidebar closes the navigation
|
|
19
|
+
|
|
20
|
+
$('.app-wrapper').on('click touchstart', function(e) {
|
|
21
|
+
var navExpanded = $('body').hasClass('mobile-nav-expanded');
|
|
22
|
+
|
|
23
|
+
var clickInHeader = $(e.target).closest('.app-header').length;
|
|
24
|
+
var clickInSidebar = $(e.target).closest('.app-sidebar').length;
|
|
25
|
+
|
|
26
|
+
if (navExpanded && !clickInHeader && !clickInSidebar) {
|
|
27
|
+
e.stopPropagation();
|
|
28
|
+
e.preventDefault();
|
|
29
|
+
|
|
30
|
+
$('.app-wrapper').addClass('animate');
|
|
31
|
+
$('body').removeClass('mobile-nav-expanded');
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
// Toggle sidebar expand/collapse
|
|
37
|
+
|
|
38
|
+
sidebar.find('.toggle-sidebar').on('click', function(e) {
|
|
39
|
+
e.preventDefault();
|
|
40
|
+
|
|
41
|
+
if (sidebar.hasClass('expanded') || sidebar.hasClass('collapsed')) {
|
|
42
|
+
sidebar.removeClass('expanded').removeClass('collapsed');
|
|
43
|
+
Trestle.cookie.delete("trestle:sidebar");
|
|
44
|
+
} else if ($(document).width() >= 1200) {
|
|
45
|
+
sidebar.addClass('collapsed');
|
|
46
|
+
Trestle.cookie.set("trestle:sidebar", "collapsed");
|
|
47
|
+
} else if ($(document).width() >= 768) {
|
|
48
|
+
sidebar.addClass('expanded');
|
|
49
|
+
Trestle.cookie.set("trestle:sidebar", "expanded");
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
// Toggle navigation groups
|
|
55
|
+
|
|
56
|
+
sidebar.find('.nav-header a').on('click', function(e) {
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
|
|
59
|
+
$(this).closest('ul').toggleClass('collapsed');
|
|
60
|
+
|
|
61
|
+
var collapsed = sidebar.find('.collapsed .nav-header a').map(function() {
|
|
62
|
+
return $(this).attr('href').replace(/^#/, '');
|
|
63
|
+
}).toArray();
|
|
64
|
+
|
|
65
|
+
Trestle.cookie.set("trestle:navigation:collapsed", collapsed.join(","))
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
// Scroll sidebar to active item
|
|
70
|
+
|
|
71
|
+
var active = sidebar.find('.active');
|
|
72
|
+
if (active.length) {
|
|
73
|
+
sidebar.find('.app-sidebar-inner').scrollTop(active.offset().top - 100);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
$(document).on('click', 'tr[data-url]:not([data-behavior="dialog"])', function(e) {
|
|
2
|
+
var row = $(e.currentTarget);
|
|
3
|
+
|
|
4
|
+
if (row.data('url') == 'auto') {
|
|
5
|
+
var url = row.find('td:not(.actions) a:first').attr('href');
|
|
6
|
+
} else {
|
|
7
|
+
var url = row.data('url');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (url) {
|
|
11
|
+
if (e.metaKey || e.ctrlKey) {
|
|
12
|
+
window.open(url, '_blank');
|
|
13
|
+
} else {
|
|
14
|
+
Trestle.visit(url);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
$(document).on('click', 'tr[data-url] a', function(e) {
|
|
20
|
+
e.stopPropagation();
|
|
21
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Trestle.init(function(e, root) {
|
|
2
|
+
$(root).find("a[data-toggle='tab']").on('shown.bs.tab', function(e) {
|
|
3
|
+
var hash = $(this).attr("href");
|
|
4
|
+
|
|
5
|
+
if (hash.substr(0, 1) == "#") {
|
|
6
|
+
history.replaceState({ turbolinks: {} }, "", "#!" + hash.substr(1));
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
Trestle.focusActiveTab = function() {
|
|
12
|
+
if (location.hash.substr(0, 2) == "#!") {
|
|
13
|
+
// Focus on active tab from URL
|
|
14
|
+
$("a[data-toggle='tab'][href='#" + location.hash.substr(2) + "']").tab("show");
|
|
15
|
+
} else if ($(".tab-pane:has(.has-error)").length) {
|
|
16
|
+
// Focus on first tab with errors
|
|
17
|
+
var pane = $(".tab-pane:has(.has-error)").first();
|
|
18
|
+
$("a[data-toggle='tab'][href='#" + pane.attr("id") + "']").tab("show");
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
Trestle.ready(function() {
|
|
23
|
+
Trestle.focusActiveTab();
|
|
24
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Trestle.refreshContext = function(context) {
|
|
2
|
+
var url = context.data('context');
|
|
3
|
+
|
|
4
|
+
$.get(url, function(data) {
|
|
5
|
+
context.html(data);
|
|
6
|
+
$(Trestle).trigger('init', context);
|
|
7
|
+
});
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
Trestle.refreshMainContext = function() {
|
|
11
|
+
var context = $('.app-main[data-context]');
|
|
12
|
+
Trestle.refreshContext(context);
|
|
13
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Trestle.cookie = {
|
|
2
|
+
get: function(name) {
|
|
3
|
+
name += '=';
|
|
4
|
+
|
|
5
|
+
var cookies = document.cookie.split(/;\s*/)
|
|
6
|
+
|
|
7
|
+
for (i = cookies.length - 1; i >= 0; i--) {
|
|
8
|
+
if (!cookies[i].indexOf(name)) {
|
|
9
|
+
var value = cookies[i].replace(name, '');
|
|
10
|
+
return decodeURIComponent(value);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return "";
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
set: function(name, value) {
|
|
18
|
+
document.cookie = name + "=" + encodeURIComponent(value) + "; path=/";
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
delete: function(name) {
|
|
22
|
+
document.cookie = name + "=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT";
|
|
23
|
+
}
|
|
24
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// The ready function sets up a callback to run on each page load.
|
|
2
|
+
//
|
|
3
|
+
// Trestle.ready(function() {
|
|
4
|
+
// ...
|
|
5
|
+
// });
|
|
6
|
+
//
|
|
7
|
+
Trestle.ready = function(callback) {
|
|
8
|
+
$(Trestle).on('load', callback);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// The init function sets up a callback to run on each page load, as well as when elements are added to the page
|
|
12
|
+
// dynamically (e.g. via a modal). It is used to initialize dynamic elements such as date pickers, although it is
|
|
13
|
+
// preferable if they can be set up using event delegation on the document element.
|
|
14
|
+
//
|
|
15
|
+
// The callback is triggered with the applicable root/container element as the second argument.
|
|
16
|
+
//
|
|
17
|
+
// Trestle.init(function(e, root) {
|
|
18
|
+
// $(root).find('...');
|
|
19
|
+
// });
|
|
20
|
+
//
|
|
21
|
+
Trestle.init = function(callback) {
|
|
22
|
+
$(Trestle).on('init', callback);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// Initialize all elements within the document on page load.
|
|
26
|
+
Trestle.ready(function() {
|
|
27
|
+
$(Trestle).trigger('init', document);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Trigger the page load events.
|
|
31
|
+
if (Trestle.turbolinks) {
|
|
32
|
+
$(document).on('turbolinks:load', function() {
|
|
33
|
+
$(Trestle).trigger("load");
|
|
34
|
+
});
|
|
35
|
+
} else {
|
|
36
|
+
$(document).ready(function() {
|
|
37
|
+
$(Trestle).trigger("load");
|
|
38
|
+
});
|
|
39
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// The visit function is used to direct the user to the given URL. It is provided as an abstraction as the redirection
|
|
2
|
+
// is handled differently depending on whether or not Turbolinks is enabled.
|
|
3
|
+
//
|
|
4
|
+
// Trestle.visit("/admin/pages");
|
|
5
|
+
//
|
|
6
|
+
if (Trestle.turbolinks) {
|
|
7
|
+
Trestle.visit = function(url) { Turbolinks.visit(url); };
|
|
8
|
+
} else {
|
|
9
|
+
Trestle.visit = function(url) { document.location = url; };
|
|
10
|
+
}
|
|
@@ -22,6 +22,10 @@
|
|
|
22
22
|
margin-bottom: 0;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
a {
|
|
26
|
+
color: white;
|
|
27
|
+
}
|
|
28
|
+
|
|
25
29
|
@include mobile {
|
|
26
30
|
padding: 5px 10px;
|
|
27
31
|
|
|
@@ -57,3 +61,27 @@
|
|
|
57
61
|
}
|
|
58
62
|
}
|
|
59
63
|
}
|
|
64
|
+
|
|
65
|
+
.toggle-debug-errors {
|
|
66
|
+
&:hover, &:focus {
|
|
67
|
+
text-decoration: none;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
&:after {
|
|
71
|
+
@extend .ion;
|
|
72
|
+
content: $ionicon-var-chevron-down;
|
|
73
|
+
font-size: 10px;
|
|
74
|
+
margin-left: 5px;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.debug-errors {
|
|
79
|
+
overflow: hidden;
|
|
80
|
+
|
|
81
|
+
ul {
|
|
82
|
+
list-style: none;
|
|
83
|
+
margin: 5px 0 0 0;
|
|
84
|
+
padding: 0 0 0 5px;
|
|
85
|
+
border-left: 4px solid rgba(white, 0.25);
|
|
86
|
+
}
|
|
87
|
+
}
|