voom-presenters 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +54 -0
- data/.ruby-version +1 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +104 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +45 -0
- data/ROADMAP.md +21 -0
- data/Rakefile +6 -0
- data/app/demo/component_status.pom +76 -0
- data/app/demo/components.pom +19 -0
- data/app/demo/components/badges.pom +25 -0
- data/app/demo/components/buttons.pom +51 -0
- data/app/demo/components/cards.pom +79 -0
- data/app/demo/components/chips.pom +91 -0
- data/app/demo/components/dialogs.pom +27 -0
- data/app/demo/components/drawers.pom +34 -0
- data/app/demo/components/expansion_panels.pom +21 -0
- data/app/demo/components/fabs-mini.pom +18 -0
- data/app/demo/components/fabs.pom +16 -0
- data/app/demo/components/footers.pom +36 -0
- data/app/demo/components/forms.pom +30 -0
- data/app/demo/components/headers.pom +37 -0
- data/app/demo/components/hidden_fields.pom +20 -0
- data/app/demo/components/icons.pom +94 -0
- data/app/demo/components/layouts.pom +44 -0
- data/app/demo/components/lists.pom +124 -0
- data/app/demo/components/menus.pom +43 -0
- data/app/demo/components/nav/drawer.pom +5 -0
- data/app/demo/components/nav/menu.pom +15 -0
- data/app/demo/components/selects.pom +30 -0
- data/app/demo/components/snackbar.pom +24 -0
- data/app/demo/components/snackbar_attached.pom +6 -0
- data/app/demo/components/tables.pom +39 -0
- data/app/demo/components/text_areas.pom +19 -0
- data/app/demo/components/text_fields.pom +57 -0
- data/app/demo/components/toggles.pom +29 -0
- data/app/demo/components/tooltips.pom +120 -0
- data/app/demo/event/actions.rb +86 -0
- data/app/demo/event/actions/dialog/show_dialog.pom +9 -0
- data/app/demo/event/actions/dialog/trigger.pom +86 -0
- data/app/demo/event/actions/nav/drawer.pom +5 -0
- data/app/demo/event/actions/nav/menu.pom +19 -0
- data/app/demo/event/autocomplete.pom +27 -0
- data/app/demo/event/field_level.pom +22 -0
- data/app/demo/event/form_level.pom +26 -0
- data/app/demo/event/nav/drawer.pom +5 -0
- data/app/demo/event/nav/menu.pom +14 -0
- data/app/demo/event/new_text.pom +6 -0
- data/app/demo/events.pom +98 -0
- data/app/demo/helpers/indented_grid.rb +14 -0
- data/app/demo/index.pom +19 -0
- data/app/demo/markdown.pom +73 -0
- data/app/demo/nav/top_nav.pom +42 -0
- data/app/demo/shared/code.pom +20 -0
- data/app/demo/shared/context_list.pom +29 -0
- data/app/demo/shared/debug.pom +17 -0
- data/app/demo/styles.pom +26 -0
- data/bin/console +22 -0
- data/bin/setup +8 -0
- data/component-status.yml +219 -0
- data/config.ru +21 -0
- data/lib/voom-presenters.rb +9 -0
- data/lib/voom/container_methods.rb +40 -0
- data/lib/voom/logger_methods.rb +11 -0
- data/lib/voom/parameters.rb +73 -0
- data/lib/voom/presenters-engine.rb +40 -0
- data/lib/voom/presenters.rb +13 -0
- data/lib/voom/presenters/api/app.rb +53 -0
- data/lib/voom/presenters/api/router.rb +94 -0
- data/lib/voom/presenters/app.rb +55 -0
- data/lib/voom/presenters/container_item.rb +16 -0
- data/lib/voom/presenters/demo/echo.rb +29 -0
- data/lib/voom/presenters/demo/search-terms.yml +50 -0
- data/lib/voom/presenters/demo/search.rb +29 -0
- data/lib/voom/presenters/dsl.rb +60 -0
- data/lib/voom/presenters/dsl/components/action.rb +35 -0
- data/lib/voom/presenters/dsl/components/avatar.rb +27 -0
- data/lib/voom/presenters/dsl/components/badge.rb +21 -0
- data/lib/voom/presenters/dsl/components/base.rb +78 -0
- data/lib/voom/presenters/dsl/components/button.rb +49 -0
- data/lib/voom/presenters/dsl/components/card.rb +119 -0
- data/lib/voom/presenters/dsl/components/checkbox.rb +16 -0
- data/lib/voom/presenters/dsl/components/chip.rb +48 -0
- data/lib/voom/presenters/dsl/components/content.rb +33 -0
- data/lib/voom/presenters/dsl/components/date_time.rb +17 -0
- data/lib/voom/presenters/dsl/components/dialog.rb +50 -0
- data/lib/voom/presenters/dsl/components/drawer.rb +40 -0
- data/lib/voom/presenters/dsl/components/event.rb +101 -0
- data/lib/voom/presenters/dsl/components/event_base.rb +20 -0
- data/lib/voom/presenters/dsl/components/expansion_panel.rb +46 -0
- data/lib/voom/presenters/dsl/components/footer.rb +25 -0
- data/lib/voom/presenters/dsl/components/form.rb +42 -0
- data/lib/voom/presenters/dsl/components/grid.rb +64 -0
- data/lib/voom/presenters/dsl/components/header.rb +33 -0
- data/lib/voom/presenters/dsl/components/hidden_field.rb +25 -0
- data/lib/voom/presenters/dsl/components/icon.rb +21 -0
- data/lib/voom/presenters/dsl/components/icon_base.rb +24 -0
- data/lib/voom/presenters/dsl/components/icon_toggle.rb +21 -0
- data/lib/voom/presenters/dsl/components/image.rb +36 -0
- data/lib/voom/presenters/dsl/components/input.rb +19 -0
- data/lib/voom/presenters/dsl/components/list.rb +39 -0
- data/lib/voom/presenters/dsl/components/lists/action.rb +72 -0
- data/lib/voom/presenters/dsl/components/lists/line.rb +83 -0
- data/lib/voom/presenters/dsl/components/lists/separator.rb +16 -0
- data/lib/voom/presenters/dsl/components/menu.rb +66 -0
- data/lib/voom/presenters/dsl/components/mixins/append.rb +20 -0
- data/lib/voom/presenters/dsl/components/mixins/attaches.rb +18 -0
- data/lib/voom/presenters/dsl/components/mixins/avatar.rb +18 -0
- data/lib/voom/presenters/dsl/components/mixins/buttons.rb +15 -0
- data/lib/voom/presenters/dsl/components/mixins/chips.rb +21 -0
- data/lib/voom/presenters/dsl/components/mixins/common.rb +50 -0
- data/lib/voom/presenters/dsl/components/mixins/content.rb +15 -0
- data/lib/voom/presenters/dsl/components/mixins/dialogs.rb +19 -0
- data/lib/voom/presenters/dsl/components/mixins/event.rb +19 -0
- data/lib/voom/presenters/dsl/components/mixins/expansion_panels.rb +15 -0
- data/lib/voom/presenters/dsl/components/mixins/grids.rb +15 -0
- data/lib/voom/presenters/dsl/components/mixins/helpers.rb +20 -0
- data/lib/voom/presenters/dsl/components/mixins/icons.rb +17 -0
- data/lib/voom/presenters/dsl/components/mixins/images.rb +15 -0
- data/lib/voom/presenters/dsl/components/mixins/menus.rb +15 -0
- data/lib/voom/presenters/dsl/components/mixins/selects.rb +17 -0
- data/lib/voom/presenters/dsl/components/mixins/snackbars.rb +18 -0
- data/lib/voom/presenters/dsl/components/mixins/text_fields.rb +35 -0
- data/lib/voom/presenters/dsl/components/mixins/toggles.rb +40 -0
- data/lib/voom/presenters/dsl/components/mixins/tooltips.rb +18 -0
- data/lib/voom/presenters/dsl/components/mixins/typography.rb +37 -0
- data/lib/voom/presenters/dsl/components/page.rb +29 -0
- data/lib/voom/presenters/dsl/components/radio_button.rb +14 -0
- data/lib/voom/presenters/dsl/components/select.rb +64 -0
- data/lib/voom/presenters/dsl/components/snackbar.rb +32 -0
- data/lib/voom/presenters/dsl/components/switch.rb +14 -0
- data/lib/voom/presenters/dsl/components/table.rb +102 -0
- data/lib/voom/presenters/dsl/components/text_area.rb +20 -0
- data/lib/voom/presenters/dsl/components/text_field.rb +74 -0
- data/lib/voom/presenters/dsl/components/toggle_base.rb +26 -0
- data/lib/voom/presenters/dsl/components/tooltip.rb +25 -0
- data/lib/voom/presenters/dsl/components/typography.rb +25 -0
- data/lib/voom/presenters/dsl/definer.rb +13 -0
- data/lib/voom/presenters/dsl/definition.rb +31 -0
- data/lib/voom/presenters/dsl/invalid_presenter.rb +8 -0
- data/lib/voom/presenters/dsl/lockable.rb +15 -0
- data/lib/voom/presenters/dsl/user_interface.rb +135 -0
- data/lib/voom/presenters/errors/parameter_validation.rb +10 -0
- data/lib/voom/presenters/errors/unprocessable.rb +8 -0
- data/lib/voom/presenters/helpers.rb +18 -0
- data/lib/voom/presenters/helpers/currency.rb +14 -0
- data/lib/voom/presenters/helpers/date.rb +22 -0
- data/lib/voom/presenters/helpers/errors.rb +11 -0
- data/lib/voom/presenters/helpers/inflector.rb +16 -0
- data/lib/voom/presenters/helpers/rails.rb +60 -0
- data/lib/voom/presenters/helpers/route.rb +11 -0
- data/lib/voom/presenters/helpers/time.rb +27 -0
- data/lib/voom/presenters/settings.rb +35 -0
- data/lib/voom/presenters/version.rb +5 -0
- data/lib/voom/presenters/web_client/app.rb +128 -0
- data/lib/voom/presenters/web_client/markdown_render.rb +16 -0
- data/lib/voom/presenters/web_client/router.rb +96 -0
- data/lib/voom/serializer.rb +43 -0
- data/lib/voom/symbol/to_str.rb +29 -0
- data/lib/voom/trace.rb +19 -0
- data/presenters.gemspec +37 -0
- data/public/.gitignore +2 -0
- data/public/bundle.css +11413 -0
- data/public/bundle.js +16456 -0
- data/public/dialog-polyfill.js +738 -0
- data/public/favicon.ico +0 -0
- data/public/img/demo/dog.png +0 -0
- data/public/img/demo/image_card.jpg +0 -0
- data/public/img/demo/rx.png +0 -0
- data/public/img/demo/welcome_card.jpg +0 -0
- data/public/img/settings/blue.png +0 -0
- data/public/img/settings/green.png +0 -0
- data/public/img/settings/orange.png +0 -0
- data/public/img/settings/purple.png +0 -0
- data/public/img/settings/red.png +0 -0
- data/public/img/settings/teal.png +0 -0
- data/public/img/settings/white.png +0 -0
- data/public/img/settings/yellow.png +0 -0
- data/public/scripts.js +289 -0
- data/public/style-bundle.js +73 -0
- data/public/styles.css +16 -0
- data/views/mdc/.gitignore +1 -0
- data/views/mdc/assets/js/app.js +10 -0
- data/views/mdc/assets/js/components/base-component.js +5 -0
- data/views/mdc/assets/js/components/button.js +15 -0
- data/views/mdc/assets/js/components/cards.js +3 -0
- data/views/mdc/assets/js/components/checkboxes.js +15 -0
- data/views/mdc/assets/js/components/chips.js +12 -0
- data/views/mdc/assets/js/components/date-time.js +6 -0
- data/views/mdc/assets/js/components/dialogs.js +32 -0
- data/views/mdc/assets/js/components/events.js +151 -0
- data/views/mdc/assets/js/components/events/autocomplete.js +96 -0
- data/views/mdc/assets/js/components/events/base.js +41 -0
- data/views/mdc/assets/js/components/events/dialog.js +25 -0
- data/views/mdc/assets/js/components/events/errors.js +142 -0
- data/views/mdc/assets/js/components/events/loads.js +22 -0
- data/views/mdc/assets/js/components/events/navigates.js +17 -0
- data/views/mdc/assets/js/components/events/posts.js +99 -0
- data/views/mdc/assets/js/components/events/replaces.js +82 -0
- data/views/mdc/assets/js/components/events/selects.js +28 -0
- data/views/mdc/assets/js/components/events/snackbar.js +23 -0
- data/views/mdc/assets/js/components/events/toggle_visiblity.js +19 -0
- data/views/mdc/assets/js/components/forms.js +57 -0
- data/views/mdc/assets/js/components/icon-toggles.js +21 -0
- data/views/mdc/assets/js/components/initialize.js +34 -0
- data/views/mdc/assets/js/components/lists.js +4 -0
- data/views/mdc/assets/js/components/menus.js +31 -0
- data/views/mdc/assets/js/components/mixins/event-handler.js +13 -0
- data/views/mdc/assets/js/components/selects.js +45 -0
- data/views/mdc/assets/js/components/snackbar.js +32 -0
- data/views/mdc/assets/js/components/text-fields.js +77 -0
- data/views/mdc/assets/js/dialog-polyfill.js +738 -0
- data/views/mdc/assets/js/material.js +3996 -0
- data/views/mdc/assets/js/utils/urls.js +54 -0
- data/views/mdc/assets/scss/app.scss +31 -0
- data/views/mdc/assets/scss/components/avatar.scss +41 -0
- data/views/mdc/assets/scss/components/button.scss +47 -0
- data/views/mdc/assets/scss/components/card.scss +54 -0
- data/views/mdc/assets/scss/components/checkbox.scss +5 -0
- data/views/mdc/assets/scss/components/chip.scss +30 -0
- data/views/mdc/assets/scss/components/datetime.scss +0 -0
- data/views/mdc/assets/scss/components/dialog.scss +3 -0
- data/views/mdc/assets/scss/components/expansion-panel.scss +153 -0
- data/views/mdc/assets/scss/components/fab.scss +8 -0
- data/views/mdc/assets/scss/components/grid.scss +10 -0
- data/views/mdc/assets/scss/components/icon-toggles.scss +9 -0
- data/views/mdc/assets/scss/components/icon.scss +34 -0
- data/views/mdc/assets/scss/components/image.scss +24 -0
- data/views/mdc/assets/scss/components/list.scss +9 -0
- data/views/mdc/assets/scss/components/menu.scss +17 -0
- data/views/mdc/assets/scss/components/select.scss +16 -0
- data/views/mdc/assets/scss/components/snackbar.scss +5 -0
- data/views/mdc/assets/scss/components/switch.scss +6 -0
- data/views/mdc/assets/scss/components/table-pagination.scss +65 -0
- data/views/mdc/assets/scss/components/textfield.scss +1 -0
- data/views/mdc/assets/scss/components/typography.scss +25 -0
- data/views/mdc/assets/scss/material.blue_grey-orange.min.css +8 -0
- data/views/mdc/assets/scss/styles.scss +11 -0
- data/views/mdc/assets/scss/theme.scss +5 -0
- data/views/mdc/body/drawer.erb +18 -0
- data/views/mdc/body/drawers/menu.erb +25 -0
- data/views/mdc/body/footer.erb +1 -0
- data/views/mdc/body/footers/large.erb +27 -0
- data/views/mdc/body/footers/menu_item.erb +6 -0
- data/views/mdc/body/footers/small.erb +14 -0
- data/views/mdc/body/header.erb +25 -0
- data/views/mdc/body/snackbar.erb +10 -0
- data/views/mdc/components/avatar.erb +24 -0
- data/views/mdc/components/badge.erb +2 -0
- data/views/mdc/components/body.erb +2 -0
- data/views/mdc/components/button.erb +17 -0
- data/views/mdc/components/buttons/button.erb +20 -0
- data/views/mdc/components/buttons/fab.erb +22 -0
- data/views/mdc/components/buttons/icon.erb +24 -0
- data/views/mdc/components/card.erb +49 -0
- data/views/mdc/components/checkbox.erb +22 -0
- data/views/mdc/components/chip.erb +31 -0
- data/views/mdc/components/content.erb +11 -0
- data/views/mdc/components/date_time.erb +30 -0
- data/views/mdc/components/dialog.erb +27 -0
- data/views/mdc/components/display.erb +2 -0
- data/views/mdc/components/event.erb +18 -0
- data/views/mdc/components/expansion_panel.erb +11 -0
- data/views/mdc/components/form.erb +15 -0
- data/views/mdc/components/grid.erb +24 -0
- data/views/mdc/components/headline.erb +2 -0
- data/views/mdc/components/hidden_field.erb +1 -0
- data/views/mdc/components/icon.erb +30 -0
- data/views/mdc/components/icon_toggle.erb +15 -0
- data/views/mdc/components/image.erb +7 -0
- data/views/mdc/components/link.erb +14 -0
- data/views/mdc/components/list.erb +14 -0
- data/views/mdc/components/list/actions.erb +6 -0
- data/views/mdc/components/list/actions/button.erb +1 -0
- data/views/mdc/components/list/actions/checkbox.erb +1 -0
- data/views/mdc/components/list/actions/icon.erb +1 -0
- data/views/mdc/components/list/actions/icon_toggle.erb +1 -0
- data/views/mdc/components/list/actions/radio_button.erb +1 -0
- data/views/mdc/components/list/actions/switch.erb +1 -0
- data/views/mdc/components/list/avatar.erb +5 -0
- data/views/mdc/components/list/checkbox.erb +5 -0
- data/views/mdc/components/list/icon.erb +5 -0
- data/views/mdc/components/list/info.erb +1 -0
- data/views/mdc/components/list/line.erb +34 -0
- data/views/mdc/components/list/menu.erb +23 -0
- data/views/mdc/components/list/separator.erb +1 -0
- data/views/mdc/components/menu.erb +29 -0
- data/views/mdc/components/modal.erb +15 -0
- data/views/mdc/components/radio_button.erb +11 -0
- data/views/mdc/components/render.erb +4 -0
- data/views/mdc/components/select.erb +22 -0
- data/views/mdc/components/snackbar.erb +17 -0
- data/views/mdc/components/static.erb +7 -0
- data/views/mdc/components/subheading.erb +2 -0
- data/views/mdc/components/switch.erb +13 -0
- data/views/mdc/components/table.erb +13 -0
- data/views/mdc/components/table/header.erb +7 -0
- data/views/mdc/components/table/pagination.erb +24 -0
- data/views/mdc/components/table/row.erb +14 -0
- data/views/mdc/components/text_area.erb +8 -0
- data/views/mdc/components/text_field.erb +27 -0
- data/views/mdc/components/title.erb +4 -0
- data/views/mdc/components/tooltip.erb +5 -0
- data/views/mdc/components/typography.erb +13 -0
- data/views/mdc/init-depends.sh +2 -0
- data/views/mdc/layout.erb +50 -0
- data/views/mdc/package-lock.json +11524 -0
- data/views/mdc/package.json +39 -0
- data/views/mdc/web.erb +1 -0
- data/views/mdc/webpack.config.js +47 -0
- metadata +539 -0
data/public/favicon.ico
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/public/scripts.js
ADDED
@@ -0,0 +1,289 @@
|
|
1
|
+
// Hookup Dialogs
|
2
|
+
document.addEventListener("DOMContentLoaded", function (event) {
|
3
|
+
'use strict';
|
4
|
+
var docDialogButtons = document.querySelectorAll('.vml-js-dialog-button');
|
5
|
+
for (var i = 0; i < docDialogButtons.length; i++) {
|
6
|
+
var button = docDialogButtons[i];
|
7
|
+
var dialog = document.querySelector('#' + button.dataset.dialogId);
|
8
|
+
if (!dialog.showModal) {
|
9
|
+
dialogPolyfill.registerDialog(dialog);
|
10
|
+
}
|
11
|
+
|
12
|
+
button.addEventListener('click', function (event) {
|
13
|
+
var button = event.target;
|
14
|
+
var dialogId = button.dataset.dialogId;
|
15
|
+
var dialog = document.querySelector('#' + dialogId);
|
16
|
+
dialog.showModal();
|
17
|
+
});
|
18
|
+
|
19
|
+
var dialogButtons = dialog.querySelectorAll('button:not([disabled])');
|
20
|
+
for (var i = 0; i != dialogButtons.length; i++) {
|
21
|
+
dialogButtons[i].addEventListener('click', function () {
|
22
|
+
dialog.close();
|
23
|
+
});
|
24
|
+
}
|
25
|
+
}
|
26
|
+
});
|
27
|
+
|
28
|
+
// This class displays a page level message
|
29
|
+
class VSnackbar {
|
30
|
+
constructor(message, action_text, action_fn) {
|
31
|
+
this.message = message;
|
32
|
+
this.action_text = action_text;
|
33
|
+
this.action_fn = action_fn;
|
34
|
+
}
|
35
|
+
|
36
|
+
display() {
|
37
|
+
'use strict';
|
38
|
+
var snackbarContainer = document.querySelector('#snackbar');
|
39
|
+
var data = {
|
40
|
+
message: this.message,
|
41
|
+
timeout: 2000,
|
42
|
+
actionHandler: this.action_fn,
|
43
|
+
actionText: this.action_text
|
44
|
+
};
|
45
|
+
componentHandler.upgradeElement(snackbarContainer);
|
46
|
+
snackbarContainer.MaterialSnackbar.showSnackbar(data);
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
class VEvents {
|
51
|
+
//[[type, url, target, params]]
|
52
|
+
constructor(actions) {
|
53
|
+
this.actions = actions.map((action) => {
|
54
|
+
return this.constructor.action_class(action);
|
55
|
+
})
|
56
|
+
;
|
57
|
+
}
|
58
|
+
|
59
|
+
call() {
|
60
|
+
this.actions.forEach((element) => {
|
61
|
+
element.call();
|
62
|
+
})
|
63
|
+
;
|
64
|
+
}
|
65
|
+
|
66
|
+
static action_class(action) {
|
67
|
+
var action_type = action[0];
|
68
|
+
var url = action[1];
|
69
|
+
var target = action[2];
|
70
|
+
var params = action[3];
|
71
|
+
|
72
|
+
switch (action_type) {
|
73
|
+
case 'loads':
|
74
|
+
return new VLoadsPage(url);
|
75
|
+
case 'replaces':
|
76
|
+
return new VReplaceElement(target, url, params);
|
77
|
+
case 'post':
|
78
|
+
return new VPost(url, params, 'POST');
|
79
|
+
case 'update':
|
80
|
+
return new VPost(url, params, 'PUT');
|
81
|
+
case 'delete':
|
82
|
+
return new VPost(url, params, 'DELETE');
|
83
|
+
default:
|
84
|
+
throw action_type + ' is not supported.';
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
}
|
89
|
+
|
90
|
+
class VLoadsPage {
|
91
|
+
constructor(url) {
|
92
|
+
this.url = url;
|
93
|
+
}
|
94
|
+
|
95
|
+
call() {
|
96
|
+
location.assign(this.url);
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
class Base {
|
101
|
+
|
102
|
+
clearErrors() {
|
103
|
+
var errorMessages = document.querySelectorAll('.mdv-error-message');
|
104
|
+
|
105
|
+
for (var i = 0; i < errorMessages.length; i++) {
|
106
|
+
errorMessages[i].remove();
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
displayError(content_type, response) {
|
111
|
+
var errors = JSON.parse(response);
|
112
|
+
for (var field in errors) {
|
113
|
+
this.prependError(field, errors[field])
|
114
|
+
}
|
115
|
+
|
116
|
+
}
|
117
|
+
|
118
|
+
prependError(div_id, message) {
|
119
|
+
// create a new div element
|
120
|
+
var newDiv = document.createElement("div");
|
121
|
+
newDiv.className = 'mdv-error-message';
|
122
|
+
// and give it some content
|
123
|
+
var newContent = document.createTextNode(message);
|
124
|
+
// add the text node to the newly created div
|
125
|
+
newDiv.appendChild(newContent);
|
126
|
+
|
127
|
+
// add the newly created element and its content into the DOM
|
128
|
+
var currentDiv = document.getElementById(div_id);
|
129
|
+
|
130
|
+
currentDiv.parentElement.insertBefore(newDiv, currentDiv);
|
131
|
+
}
|
132
|
+
}
|
133
|
+
|
134
|
+
// Replaces a given element with the contents of the call to the url.
|
135
|
+
// parameters are appended.
|
136
|
+
class VReplaceElement extends Base {
|
137
|
+
constructor(element_id, url, params) {
|
138
|
+
super();
|
139
|
+
this.element_id = element_id;
|
140
|
+
this.url = url;
|
141
|
+
this.params = params;
|
142
|
+
this.httpRequest = new XMLHttpRequest();
|
143
|
+
}
|
144
|
+
|
145
|
+
call() {
|
146
|
+
if (!this.httpRequest) {
|
147
|
+
new VSnackbar('Cannot talk to server! Please upgrade your browser to one that supports XMLHttpRequest.').display();
|
148
|
+
return false;
|
149
|
+
}
|
150
|
+
this.clearErrors();
|
151
|
+
var _this_ = this;
|
152
|
+
|
153
|
+
this.httpRequest.onreadystatechange = function () {
|
154
|
+
if (_this_.httpRequest.readyState === XMLHttpRequest.DONE) {
|
155
|
+
if (_this_.httpRequest.status === 200) {
|
156
|
+
var node_to_replace = document.getElementById(_this_.element_id);
|
157
|
+
node_to_replace.outerHTML = _this_.httpRequest.responseText;
|
158
|
+
} else {
|
159
|
+
new VSnackbar('There was a problem with the request.').display();
|
160
|
+
}
|
161
|
+
}
|
162
|
+
};
|
163
|
+
var url = this.url + this.seperator() + this.serialize(this.params);
|
164
|
+
console.log('GET:' + url);
|
165
|
+
this.httpRequest.open('GET', url, true);
|
166
|
+
this.httpRequest.setRequestHeader('X-NO-LAYOUT', true);
|
167
|
+
this.httpRequest.send();
|
168
|
+
}
|
169
|
+
|
170
|
+
seperator() {
|
171
|
+
return this.url.includes("?") ? '&' : '?';
|
172
|
+
}
|
173
|
+
|
174
|
+
serialize(obj, prefix) {
|
175
|
+
var str = [],
|
176
|
+
p;
|
177
|
+
for (p in obj) {
|
178
|
+
if (obj.hasOwnProperty(p)) {
|
179
|
+
var k = prefix ? prefix + "[" + p + "]" : p,
|
180
|
+
v = obj[p];
|
181
|
+
str.push((v !== null && typeof v === "object") ?
|
182
|
+
this.serialize(v, k) :
|
183
|
+
encodeURIComponent(k) + "=" + encodeURIComponent(v));
|
184
|
+
}
|
185
|
+
}
|
186
|
+
return str.join("&");
|
187
|
+
}
|
188
|
+
}
|
189
|
+
|
190
|
+
|
191
|
+
// Replaces a given element with the contents of the call to the url.
|
192
|
+
// parameters are appended.
|
193
|
+
class VPost extends Base {
|
194
|
+
constructor(url, params, method, parent) {
|
195
|
+
super();
|
196
|
+
this.url = url;
|
197
|
+
this.params = params;
|
198
|
+
this.method = method;
|
199
|
+
this.httpRequest = new XMLHttpRequest();
|
200
|
+
}
|
201
|
+
|
202
|
+
call() {
|
203
|
+
if (!this.httpRequest) {
|
204
|
+
new VSnackbar('Cannot talk to server! Please upgrade your browser to one that supports XMLHttpRequest.').display();
|
205
|
+
return false;
|
206
|
+
}
|
207
|
+
this.clearErrors();
|
208
|
+
|
209
|
+
var FD = new FormData();
|
210
|
+
var _this_ = this;
|
211
|
+
|
212
|
+
// Push our data into our FormData object
|
213
|
+
for (var name in this.params) {
|
214
|
+
if(name != '__parent_id__') {
|
215
|
+
FD.append(name, this.params[name]);
|
216
|
+
}
|
217
|
+
}
|
218
|
+
// Automatically pull values out of edit controls
|
219
|
+
if(this.params.__parent_id__){
|
220
|
+
var parent_element = document.getElementById(this.params.__parent_id__);
|
221
|
+
if(parent_element) {
|
222
|
+
var value = parent_element.value;
|
223
|
+
if (value) {
|
224
|
+
FD.append(this.params.__parent_id__, value);
|
225
|
+
}
|
226
|
+
}
|
227
|
+
}
|
228
|
+
|
229
|
+
this.httpRequest.onreadystatechange = function (event) {
|
230
|
+
if (_this_.httpRequest.readyState === XMLHttpRequest.DONE) {
|
231
|
+
if (_this_.httpRequest.status >= 200 && _this_.httpRequest.status < 300) {
|
232
|
+
new VSnackbar('Yeah! That worked!').display();
|
233
|
+
console.log(_this_.httpRequest.status + ':' + this.getResponseHeader('content-type') + ':' + event.target.responseText);
|
234
|
+
} else {
|
235
|
+
new VSnackbar('There was a problem with the request.').display();
|
236
|
+
console.log(_this_.httpRequest.status + ':' + this.getResponseHeader('content-type') + ':' + event.target.responseText);
|
237
|
+
_this_.displayError(this.getResponseHeader('content-type'), event.target.responseText);
|
238
|
+
}
|
239
|
+
}
|
240
|
+
};
|
241
|
+
|
242
|
+
// Set up our request
|
243
|
+
this.httpRequest.open(this.method, this.url);
|
244
|
+
|
245
|
+
console.log(this.method + ':' + this.url);
|
246
|
+
// Send our FormData object; HTTP headers are set automatically
|
247
|
+
this.httpRequest.send(FD);
|
248
|
+
}
|
249
|
+
}
|
250
|
+
|
251
|
+
// TODO Create POST that uses the wrapping form
|
252
|
+
// window.addEventListener("load", function () {
|
253
|
+
// function sendData() {
|
254
|
+
// var XHR = new XMLHttpRequest();
|
255
|
+
//
|
256
|
+
// // Bind the FormData object and the form element
|
257
|
+
// var FD = new FormData(form);
|
258
|
+
//
|
259
|
+
// // Define what happens on successful data submission
|
260
|
+
// XHR.addEventListener("load", function(event) {
|
261
|
+
// alert(event.target.responseText);
|
262
|
+
// });
|
263
|
+
//
|
264
|
+
// // Define what happens in case of error
|
265
|
+
// XHR.addEventListener("error", function(event) {
|
266
|
+
// alert('Oups! Something goes wrong.');
|
267
|
+
// });
|
268
|
+
//
|
269
|
+
// // Set up our request
|
270
|
+
// XHR.open("POST", "https://example.com/cors.php");
|
271
|
+
//
|
272
|
+
// // The data sent is what the user provided in the form
|
273
|
+
// XHR.send(FD);
|
274
|
+
// }
|
275
|
+
//
|
276
|
+
// // Access the form element...
|
277
|
+
// var form = document.getElementById("myForm");
|
278
|
+
//
|
279
|
+
// if(form) {
|
280
|
+
// // ...and take over its submit event.
|
281
|
+
// form.addEventListener("submit", function (event) {
|
282
|
+
// event.preventDefault();
|
283
|
+
//
|
284
|
+
// sendData();
|
285
|
+
// });
|
286
|
+
// }
|
287
|
+
// });
|
288
|
+
|
289
|
+
|
@@ -0,0 +1,73 @@
|
|
1
|
+
/******/ (function(modules) { // webpackBootstrap
|
2
|
+
/******/ // The module cache
|
3
|
+
/******/ var installedModules = {};
|
4
|
+
/******/
|
5
|
+
/******/ // The require function
|
6
|
+
/******/ function __webpack_require__(moduleId) {
|
7
|
+
/******/
|
8
|
+
/******/ // Check if module is in cache
|
9
|
+
/******/ if(installedModules[moduleId]) {
|
10
|
+
/******/ return installedModules[moduleId].exports;
|
11
|
+
/******/ }
|
12
|
+
/******/ // Create a new module (and put it into the cache)
|
13
|
+
/******/ var module = installedModules[moduleId] = {
|
14
|
+
/******/ i: moduleId,
|
15
|
+
/******/ l: false,
|
16
|
+
/******/ exports: {}
|
17
|
+
/******/ };
|
18
|
+
/******/
|
19
|
+
/******/ // Execute the module function
|
20
|
+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
21
|
+
/******/
|
22
|
+
/******/ // Flag the module as loaded
|
23
|
+
/******/ module.l = true;
|
24
|
+
/******/
|
25
|
+
/******/ // Return the exports of the module
|
26
|
+
/******/ return module.exports;
|
27
|
+
/******/ }
|
28
|
+
/******/
|
29
|
+
/******/
|
30
|
+
/******/ // expose the modules object (__webpack_modules__)
|
31
|
+
/******/ __webpack_require__.m = modules;
|
32
|
+
/******/
|
33
|
+
/******/ // expose the module cache
|
34
|
+
/******/ __webpack_require__.c = installedModules;
|
35
|
+
/******/
|
36
|
+
/******/ // define getter function for harmony exports
|
37
|
+
/******/ __webpack_require__.d = function(exports, name, getter) {
|
38
|
+
/******/ if(!__webpack_require__.o(exports, name)) {
|
39
|
+
/******/ Object.defineProperty(exports, name, {
|
40
|
+
/******/ configurable: false,
|
41
|
+
/******/ enumerable: true,
|
42
|
+
/******/ get: getter
|
43
|
+
/******/ });
|
44
|
+
/******/ }
|
45
|
+
/******/ };
|
46
|
+
/******/
|
47
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
48
|
+
/******/ __webpack_require__.n = function(module) {
|
49
|
+
/******/ var getter = module && module.__esModule ?
|
50
|
+
/******/ function getDefault() { return module['default']; } :
|
51
|
+
/******/ function getModuleExports() { return module; };
|
52
|
+
/******/ __webpack_require__.d(getter, 'a', getter);
|
53
|
+
/******/ return getter;
|
54
|
+
/******/ };
|
55
|
+
/******/
|
56
|
+
/******/ // Object.prototype.hasOwnProperty.call
|
57
|
+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
58
|
+
/******/
|
59
|
+
/******/ // __webpack_public_path__
|
60
|
+
/******/ __webpack_require__.p = "";
|
61
|
+
/******/
|
62
|
+
/******/ // Load entry module and return exports
|
63
|
+
/******/ return __webpack_require__(__webpack_require__.s = 0);
|
64
|
+
/******/ })
|
65
|
+
/************************************************************************/
|
66
|
+
/******/ ([
|
67
|
+
/* 0 */
|
68
|
+
/***/ (function(module, exports, __webpack_require__) {
|
69
|
+
|
70
|
+
module.exports = __webpack_require__.p + "../../public/bundle.css";
|
71
|
+
|
72
|
+
/***/ })
|
73
|
+
/******/ ]);
|
data/public/styles.css
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
node_modules
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import {MDCRipple} from '@material/ripple';
|
2
|
+
|
3
|
+
export function initButtons() {
|
4
|
+
console.log('\tButtons');
|
5
|
+
|
6
|
+
var rippleButtons = document.querySelectorAll('.v-js-ripple-button');
|
7
|
+
if(rippleButtons) {
|
8
|
+
for (var i = 0; i < rippleButtons.length; i++) {
|
9
|
+
var button = rippleButtons[i];
|
10
|
+
if(!button.mdcComponent) {
|
11
|
+
button.mdcComponent = new MDCRipple(button);
|
12
|
+
}
|
13
|
+
}
|
14
|
+
}
|
15
|
+
}
|