station 0.0.109 → 0.0.114

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile +9 -7
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +2 -2
  5. data/docs/How-To-Use.md +2 -0
  6. data/lib/nexmo_developer/.nvmrc +1 -1
  7. data/lib/nexmo_developer/.ruby-version +1 -1
  8. data/lib/nexmo_developer/Gemfile +17 -28
  9. data/lib/nexmo_developer/Gemfile.lock +107 -119
  10. data/lib/nexmo_developer/Runbook.md +4 -4
  11. data/lib/nexmo_developer/app/assets/config/manifest.js +1 -4
  12. data/lib/nexmo_developer/app/assets/javascripts/application.js +2 -7
  13. data/lib/nexmo_developer/app/assets/stylesheets/application.css +1 -1
  14. data/lib/nexmo_developer/app/controllers/dashboard_controller.rb +0 -5
  15. data/lib/nexmo_developer/app/controllers/jobs_controller.rb +7 -7
  16. data/lib/nexmo_developer/app/controllers/static_controller.rb +5 -14
  17. data/lib/nexmo_developer/app/models/feedback/feedback.rb +2 -0
  18. data/lib/nexmo_developer/app/presenters/head.rb +5 -1
  19. data/lib/nexmo_developer/app/presenters/improve_page_presenter.rb +10 -7
  20. data/lib/nexmo_developer/app/services/orbit_feedback_notifier.rb +53 -0
  21. data/lib/nexmo_developer/app/services/translator/files_list_coordinator.rb +1 -1
  22. data/lib/nexmo_developer/app/services/translator/smartling/api/download_file.rb +6 -1
  23. data/lib/nexmo_developer/app/services/translator/smartling/api/file_status.rb +7 -1
  24. data/lib/nexmo_developer/app/services/translator/utils.rb +1 -1
  25. data/lib/nexmo_developer/app/views/contribute/guides/landing-pages.md +0 -10
  26. data/lib/nexmo_developer/app/views/contribute/guides/markdown-guide.md +36 -40
  27. data/lib/nexmo_developer/app/views/contribute/guides/platform.md +0 -1
  28. data/lib/nexmo_developer/app/views/dashboard/stats.html.erb +2 -2
  29. data/lib/nexmo_developer/app/views/layouts/partials/_head.html.erb +0 -5
  30. data/lib/nexmo_developer/app/views/static/default_landing/partials/_join_slack.html.erb +1 -1
  31. data/lib/nexmo_developer/app/views/static/{robots.txt.erb → robots.text.erb} +0 -0
  32. data/lib/nexmo_developer/app/webpacker/fonts/Lato-Black.woff +0 -0
  33. data/lib/nexmo_developer/app/webpacker/fonts/Lato-Black.woff2 +0 -0
  34. data/lib/nexmo_developer/app/webpacker/fonts/Lato-Regular.woff +0 -0
  35. data/lib/nexmo_developer/app/webpacker/fonts/Lato-Regular.woff2 +0 -0
  36. data/lib/nexmo_developer/app/webpacker/fonts/Lato-Semibold.woff +0 -0
  37. data/lib/nexmo_developer/app/webpacker/fonts/Lato-Semibold.woff2 +0 -0
  38. data/lib/nexmo_developer/app/webpacker/fonts/icomoon.eot +0 -0
  39. data/lib/nexmo_developer/app/webpacker/fonts/icomoon.json +1257 -0
  40. data/lib/nexmo_developer/app/webpacker/fonts/icomoon.svg +55 -0
  41. data/lib/nexmo_developer/app/webpacker/fonts/icomoon.ttf +0 -0
  42. data/lib/nexmo_developer/app/webpacker/fonts/icomoon.woff +0 -0
  43. data/lib/nexmo_developer/app/{assets → webpacker}/images/.keep +0 -0
  44. data/lib/nexmo_developer/app/{assets → webpacker}/images/logo@3x.png +0 -0
  45. data/lib/nexmo_developer/app/{assets → webpacker}/images/logo_vonage.png +0 -0
  46. data/lib/nexmo_developer/app/{assets → webpacker}/images/nexmo-developer-logo.svg +0 -0
  47. data/lib/nexmo_developer/app/{assets → webpacker}/images/nexmo-logo-collapsed.svg +0 -0
  48. data/lib/nexmo_developer/app/{assets → webpacker}/images/nexmo-vonage-white.svg +0 -0
  49. data/lib/nexmo_developer/app/{assets → webpacker}/images/posters/chatapp.jpg +0 -0
  50. data/lib/nexmo_developer/app/{assets → webpacker}/images/posters/chatapp_small.png +0 -0
  51. data/lib/nexmo_developer/app/{assets → webpacker}/images/posters/nexmo.jpg +0 -0
  52. data/lib/nexmo_developer/app/{assets → webpacker}/images/posters/numberinsight.jpg +0 -0
  53. data/lib/nexmo_developer/app/{assets → webpacker}/images/posters/numberinsight_small.png +0 -0
  54. data/lib/nexmo_developer/app/{assets → webpacker}/images/posters/sms.jpg +0 -0
  55. data/lib/nexmo_developer/app/{assets → webpacker}/images/posters/sms_small.png +0 -0
  56. data/lib/nexmo_developer/app/{assets → webpacker}/images/posters/verify.jpg +0 -0
  57. data/lib/nexmo_developer/app/{assets → webpacker}/images/posters/verify_small.png +0 -0
  58. data/lib/nexmo_developer/app/{assets → webpacker}/images/posters/voice.jpg +0 -0
  59. data/lib/nexmo_developer/app/{assets → webpacker}/images/posters/voice_small.png +0 -0
  60. data/lib/nexmo_developer/app/{assets → webpacker}/images/select-dropdown.png +0 -0
  61. data/lib/nexmo_developer/app/{assets → webpacker}/images/slack.svg +0 -0
  62. data/lib/nexmo_developer/app/{assets → webpacker}/images/themes/ea/topography.png +0 -0
  63. data/lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js +23 -85
  64. data/lib/nexmo_developer/app/webpacker/javascript/volta/volta.js +5 -1
  65. data/lib/nexmo_developer/app/webpacker/packs/active_admin.js +5 -0
  66. data/lib/nexmo_developer/app/webpacker/packs/active_admin/print.scss +2 -0
  67. data/lib/nexmo_developer/app/webpacker/packs/application.js +12 -3
  68. data/lib/nexmo_developer/app/{assets → webpacker}/stylesheets/active_admin.scss +4 -4
  69. data/lib/nexmo_developer/app/webpacker/stylesheets/application.scss +0 -1
  70. data/lib/nexmo_developer/config/environments/development.rb +1 -1
  71. data/lib/nexmo_developer/config/initializers/active_admin.rb +3 -0
  72. data/lib/nexmo_developer/config/routes.rb +0 -2
  73. data/lib/nexmo_developer/config/webpack/environment.js +10 -0
  74. data/lib/nexmo_developer/config/webpack/plugins/jquery.js +7 -0
  75. data/lib/nexmo_developer/lib/tasks/cache.rake +1 -1
  76. data/lib/nexmo_developer/lib/tasks/careers.rake +1 -1
  77. data/lib/nexmo_developer/lib/tasks/ci.rake +7 -7
  78. data/lib/nexmo_developer/lib/tasks/diff.rake +5 -5
  79. data/lib/nexmo_developer/lib/tasks/documentation.rake +1 -1
  80. data/lib/nexmo_developer/lib/tasks/generate_search_terms.rake +2 -2
  81. data/lib/nexmo_developer/lib/tasks/links.rake +6 -6
  82. data/lib/nexmo_developer/lib/tasks/smartling.rake +1 -1
  83. data/lib/nexmo_developer/nexmo_developer.rb +3 -4
  84. data/lib/nexmo_developer/version.rb +1 -1
  85. data/package.json +29 -23
  86. data/station.gemspec +10 -14
  87. data/yarn.lock +2013 -3375
  88. metadata +206 -232
  89. data/lib/nexmo_developer/.dockerignore +0 -1
  90. data/lib/nexmo_developer/Dockerfile +0 -28
  91. data/lib/nexmo_developer/app/assets/javascripts/active_admin.js.coffee +0 -1
  92. data/lib/nexmo_developer/app/assets/javascripts/stats.js +0 -14
  93. data/lib/nexmo_developer/app/assets/regex/matching_chars.rb +0 -1
  94. data/lib/nexmo_developer/app/assets/regex/sequence_diagram_regex.rb +0 -1
  95. data/lib/nexmo_developer/app/assets/regex/stats_regex.rb +0 -1
  96. data/lib/nexmo_developer/app/assets/regex/webfont_regex.rb +0 -1
  97. data/lib/nexmo_developer/app/screenshots/webhook-url-for-delivery-receipt.js +0 -44
  98. data/lib/nexmo_developer/app/screenshots/webhook-url-for-inbound-message.js +0 -44
  99. data/lib/nexmo_developer/app/views/static/default_landing/partials/_submit_your_idea_form.html.erb +0 -58
  100. data/lib/nexmo_developer/app/webpacker/javascript/spotlight/index.js +0 -12
  101. data/lib/nexmo_developer/app/webpacker/stylesheets/objects/_building-block.scss +0 -32
  102. data/lib/nexmo_developer/docker-compose.yml +0 -43
  103. data/lib/nexmo_developer/lib/tasks/screenshots.rake +0 -11
  104. data/lib/nexmo_developer/vendor/assets/javascripts/jquery-scrolltofixed.js +0 -567
  105. data/lib/nexmo_developer/vendor/assets/javascripts/mermaid.js +0 -49
  106. data/lib/nexmo_developer/vendor/assets/javascripts/underscore.js +0 -5
  107. data/lib/nexmo_developer/vendor/assets/javascripts/volta/addons/jquery.tablesorter.js +0 -1031
  108. data/lib/nexmo_developer/vendor/assets/javascripts/volta/addons/prism.js +0 -22
  109. data/lib/nexmo_developer/vendor/assets/javascripts/volta/components/side-navigation/volta.menu.js +0 -377
  110. data/lib/nexmo_developer/vendor/assets/javascripts/volta/components/volta.accordion.js +0 -249
  111. data/lib/nexmo_developer/vendor/assets/javascripts/volta/components/volta.dropdown.js +0 -145
  112. data/lib/nexmo_developer/vendor/assets/javascripts/volta/components/volta.flash.js +0 -175
  113. data/lib/nexmo_developer/vendor/assets/javascripts/volta/components/volta.modal.js +0 -312
  114. data/lib/nexmo_developer/vendor/assets/javascripts/volta/components/volta.tab.js +0 -203
  115. data/lib/nexmo_developer/vendor/assets/javascripts/volta/components/volta.tooltip.js +0 -71
  116. data/lib/nexmo_developer/vendor/assets/javascripts/volta/popper.min.js +0 -5
  117. data/lib/nexmo_developer/vendor/assets/javascripts/volta/svgxuse.min.js +0 -12
  118. data/lib/nexmo_developer/vendor/assets/javascripts/volta/tooltip.min.js +0 -5
  119. data/lib/nexmo_developer/vendor/assets/javascripts/volta/volta.core.js +0 -238
  120. data/lib/nexmo_developer/vendor/assets/javascripts/volta/volta.js +0 -2141
  121. data/lib/nexmo_developer/vendor/assets/javascripts/volta/volta.min.js +0 -1
@@ -1,145 +0,0 @@
1
- /**
2
- * Copyright (c) 2018-present, Vonage. All rights reserved.
3
- *
4
- * Dropdowns (requires core)
5
- */
6
-
7
- 'use strict';
8
-
9
- Volta.dropdown = function () {
10
- var _class = {
11
- wrapper: 'Vlt-dropdown',
12
- block: 'Vlt-dropdown__block',
13
- btn: 'Vlt-dropdown__trigger',
14
- btnLegacy: 'Vlt-dropdown__btn',
15
- dismissed: 'Vlt-callout--dismissed',
16
- expanded: 'Vlt-dropdown--expanded',
17
- label: 'Vlt-dropdown__label',
18
- link: 'Vlt-dropdown__link',
19
- noCloseLink: 'Vlt-dropdown__link--noclose',
20
- noCloseBlock: 'Vlt-dropdown__block--noclose',
21
- panel: 'Vlt-dropdown__panel',
22
- panelContent: 'Vlt-dropdown__panel__content',
23
- selection: 'Vlt-dropdown__selection',
24
- switch: 'Vlt-switch',
25
- switchSlider: 'Vlt-switch__slider'
26
- }
27
-
28
- function Dropdown() {}
29
-
30
- Dropdown.prototype = {
31
- init: function(element, supressClickHandler) {
32
- this.dropdown = element;
33
- this.selection = this.dropdown.querySelector('.' + _class.selection);
34
- this.isSelectionVisible = !!this.selection;
35
- this.btn = this.dropdown.querySelector('.' + _class.btn) || this.dropdown.querySelector('.' + _class.btnLegacy);
36
- this._suppress = supressClickHandler;
37
-
38
- if(!this._suppress) {
39
- this._addEventListener();
40
- }
41
- },
42
- _addEventListener: function(){
43
- var openHandler = this.open.bind(this);
44
- this.dropdown.addEventListener('click', openHandler, { once: true })
45
- },
46
- close: function(text) {
47
- if(text) {
48
- this._setDropdownSelectionText(text);
49
- }
50
- this.dropdown.classList.remove(_class.expanded);
51
-
52
- if(!this._suppress){
53
- this._addEventListener();
54
- }
55
-
56
- },
57
- _closeEventHandler: undefined,
58
- _closeEvent: function(e) {
59
- var targetIsPanel = Volta._hasClass(e.target, _class.panel);
60
- var parentIsPanel = Volta._closest(e.target, '.' + _class.panelContent, _class.panel) !== null;
61
- var parentLink = Volta._closest(e.target, '.' + _class.link, _class.wrapper);
62
- var parentIsLink = parentLink && parentLink.length === 1;
63
- var isSwitchSlider = Volta._hasClass(e.target, _class.switchSlider);
64
- var isParentSwitch = Volta._closest(e.target,'.' + _class.switch, _class.link);
65
- var isNoClose = Volta._hasClass(e.target, _class.noCloseLink) || Volta._hasClass(e.target, _class.noCloseBlock);
66
- var isNoCloseParent = Volta._closest(e.target,'.' + _class.noCloseLink, _class.link) || Volta._closest(e.target,'.' + _class.noCloseBlock, _class.noCloseBlock);
67
- var isInput = e.target instanceof HTMLInputElement;
68
-
69
- if(!targetIsPanel && !parentIsPanel && !parentIsLink && !isNoClose && !isInput && !isNoCloseParent) {
70
- e.preventDefault();
71
- e.stopPropagation();
72
- }
73
-
74
- if(isSwitchSlider || isParentSwitch || isNoClose || isInput || isNoCloseParent) {
75
- return null;
76
- }
77
-
78
- var text;
79
- if(parentIsPanel && Volta._hasClass(e.target, _class.label)) {
80
- text = e.target.innerHTML;
81
- } else if (parentIsPanel) {
82
- var label = e.target.querySelector('.' + _class.label);
83
- if(label) {
84
- text = label.innerHTML;
85
- }
86
- }
87
-
88
- this.close(text);
89
-
90
- document.querySelector('body').removeEventListener('click', this._closeEventHandler );
91
- },
92
- open: function(event) {
93
- if(event) {
94
- event.preventDefault();
95
- event.stopPropagation();
96
- }
97
-
98
- this.dropdown.classList.add(_class.expanded);
99
-
100
- if(!this._suppress){
101
- this._closeEventHandler = this._closeEvent.bind(this);
102
- document.querySelector('body').addEventListener('click', this._closeEventHandler );
103
- }
104
- },
105
- _setDropdownSelectionText: function(text) {
106
- if(this.isSelectionVisible) {
107
- this.selection.innerText = text;
108
- } else {
109
- this.btn.innerText = text;
110
- this.btn.value = text;
111
- }
112
- },
113
- _suppress: false
114
- }
115
-
116
- return {
117
- create: create,
118
- init: attachDropdownHandlers
119
- }
120
-
121
- /**
122
- * @public
123
- *
124
- * @description Attach a listeners to dropdowns
125
- */
126
- function attachDropdownHandlers() {
127
- document.querySelectorAll('.' + _class.wrapper).forEach(attachHandler);
128
-
129
- function attachHandler(dropdown) {
130
- create(dropdown);
131
- }
132
- }
133
-
134
- /**
135
- * @private
136
- *
137
- * @description Create a dropdown element
138
- * @param {HTMLElement} element
139
- */
140
- function create(element){
141
- var dropdown = Object.create(Dropdown.prototype, {})
142
- dropdown.init(element);
143
- return dropdown;
144
- }
145
- }();
@@ -1,175 +0,0 @@
1
- /**
2
- * Copyright (c) 2018-present, Vonage. All rights reserved.
3
- *
4
- * Tabs (requires core)
5
- */
6
-
7
- 'use strict';
8
-
9
- Volta.flash = function () {
10
- var _class = {
11
- flash: 'Vlt-flash',
12
- trigger: 'Vlt-flash-trigger',
13
- visible: 'Vlt-flash_visible'
14
- }
15
-
16
- var gap = 20,
17
- openBottomFlashes = [],
18
- openTopFlashes = [],
19
- timeouts =[];
20
-
21
- return {
22
- closeAll: closeAll,
23
- init: attachFlashHandlers,
24
- show: show
25
- }
26
-
27
- /**
28
- * @public
29
- *
30
- * @description Attach a click listener to each flash's trigger on the screen
31
- * @param {HTMLElement} element
32
- */
33
- function attachFlashHandlers() {
34
- var triggers = document.querySelectorAll('.' + _class.trigger);
35
-
36
- if(triggers.length === 0) {
37
- return;
38
- }
39
-
40
- triggers.forEach(attachHandler);
41
-
42
- function attachHandler(trigger) {
43
- trigger.addEventListener('click', function() {
44
- if(trigger.dataset.flash) {
45
- var flash = document.querySelector('#' + trigger.dataset.flash);
46
- show(flash);
47
- } else {
48
- console.warn("Volta: flash trigger is missing data-flash attribute");
49
- }
50
- });
51
- }
52
- }
53
-
54
- /**
55
- * @public
56
- *
57
- * @description Close all open flashes
58
- */
59
- function closeAll() {
60
- if(timeouts.length > 0) {
61
- timeouts.forEach(function(timeout){
62
- clearTimeout(timeout);
63
- });
64
- }
65
- if(openBottomFlashes.length > 0) {
66
- clearQueue(openBottomFlashes);
67
- }
68
- if(openTopFlashes.length > 0) {
69
- clearQueue(openTopFlashes);
70
- }
71
-
72
- timeouts = [];
73
- openBottomFlashes = [];
74
- openTopFlashes = [];
75
-
76
- function clearQueue(elementArr) {
77
- elementArr.forEach(function(element){
78
- _hide(element);
79
- });
80
- elementArr = [];
81
- }
82
- }
83
-
84
- /**
85
- * @public
86
- *
87
- * @description Show the flash
88
- * @param {HTMLElement} element
89
- */
90
- function show(elementOrId, time) {
91
- if(!elementOrId || elementOrId.length == 0) {
92
- return;
93
- }
94
-
95
- time = time || 5000;
96
-
97
- var element = !elementOrId.classList ? document.querySelector('#' + elementOrId) : elementOrId;
98
- var position = Volta._hasClass(element, 'Vlt-flash--bottom') ? 'bottom' : 'top';
99
- var arr = position === 'bottom' ? openBottomFlashes : openTopFlashes;
100
-
101
- if(arr.indexOf(element) !== -1) {
102
- return;
103
- }
104
-
105
- _setFlashPosition(arr, element, position);
106
-
107
- arr.push(element);
108
-
109
- element.classList.add(_class.visible);
110
-
111
- var hideTimeout = setTimeout(function(){
112
- _hide(element, true);
113
- Volta._removeFromArr(timeouts, hideTimeout);
114
- }, time);
115
-
116
- timeouts.push(hideTimeout);
117
- }
118
-
119
- /**
120
- * @private
121
- * @description Hide the flash
122
- * @param {HTMLElement} element
123
- */
124
- function _hide(element, shouldRemove) {
125
- var position = Volta._hasClass(element, 'Vlt-flash--bottom') ? 'bottom' : 'top';
126
- var arr = position === 'bottom' ? openBottomFlashes : openTopFlashes;
127
-
128
- if(shouldRemove) {
129
- Volta._removeFromArr(arr, element);
130
- }
131
-
132
- _updateFlashPositions(arr, element, position);
133
-
134
- element.style[position] = '';
135
- element.classList.remove(_class.visible);
136
- }
137
-
138
- /**
139
- * @private
140
- * @description Set the position of the flash
141
- * @param {HTMLElement} element
142
- */
143
- function _setFlashPosition(arr, element, position) {
144
- var positionPx = arr.reduce(function(px, flash) {
145
- return px + flash.clientHeight;
146
- }, 0);
147
- if(positionPx > 0) {
148
- element.style[position] = (gap * arr.length) + gap + positionPx + 'px';
149
- }
150
- }
151
-
152
- /**
153
- * @private
154
- * @description Update the position of all the visible flashes
155
- * @param {Array} arr
156
- * @param {HTMLElement} element
157
- * @param {string} position
158
- */
159
- function _updateFlashPositions(arr, element, position){
160
- if(arr.length > 0) {
161
- var elementHeight = element.clientHeight;
162
-
163
- arr.forEach(function(flash) {
164
- var newPosition;
165
-
166
- if(position === 'bottom') {
167
- newPosition = Number(flash.style.bottom.substring(0, flash.style.bottom.length - 2));
168
- } else {
169
- newPosition = flash.getBoundingClientRect()[position];
170
- }
171
- flash.style[position] = newPosition -elementHeight - gap + "px";
172
- });
173
- }
174
- }
175
- }();
@@ -1,312 +0,0 @@
1
- /**
2
- * Copyright (c) 2018-present, Vonage. All rights reserved.
3
- *
4
- * Modals (requires core)
5
- */
6
-
7
- 'use strict';
8
-
9
- Volta.modal = function () {
10
- var _class = {
11
- auto: 'Vlt-modal--auto',
12
- bodyModalOpen: 'Vlt-body--modal-open',
13
- cancel: 'Vlt-modal__cancel',
14
- confirm: 'Vlt-modal__confirm',
15
- content: 'Vlt-modal__content',
16
- modal: 'Vlt-modal',
17
- out: 'Vlt-modal--out',
18
- panel: 'Vlt-modal__panel',
19
- trigger: 'Vlt-modal-trigger',
20
- visible: 'Vlt-modal_visible',
21
- dismiss: 'Vlt-modal__dismiss',
22
- }
23
-
24
- var body,
25
- dismissModalHandler,
26
- cancelModalHandler,
27
- confirmModalHandler,
28
- escHandler,
29
- clickHandler,
30
- escAttached;
31
-
32
- function Modal() {}
33
-
34
- Modal.prototype = {
35
- attachButtons: function() {
36
- var _this = this;
37
- _this.dismissBtn = _this.modal.querySelector('.' + _class.dismiss);
38
-
39
- if(_this.dismissBtn) {
40
- dismissModalHandler = dismissModal.bind(_this);
41
- _this.dismissBtn.addEventListener('click', dismissModalHandler);
42
- }
43
-
44
- _this.cancelBtn = _this.modal.querySelector('.' + _class.cancel);
45
-
46
- if(_this.cancelBtn) {
47
- cancelModalHandler = cancelModal.bind(_this);
48
- _this.cancelBtn.addEventListener('click', cancelModalHandler);
49
- }
50
-
51
- _this.confirmBtn = _this.modal.querySelector('.' + _class.confirm);
52
-
53
- if(_this.confirmBtn) {
54
- confirmModalHandler = confirmModal.bind(_this);
55
- _this.confirmBtn.addEventListener('click', confirmModalHandler);
56
- }
57
- },
58
- html: function(newHtml) {
59
- this.modal.innerHTML = newHtml;
60
- return this;
61
- },
62
- init: function(elementOrId) {
63
- if(elementOrId.length) {
64
- this.modal = document.querySelector('#' + elementOrId);
65
- } else {
66
- this.modal = elementOrId;
67
- }
68
-
69
- this._callback = Volta._getFunction(this.modal.dataset.callback);
70
- },
71
- open: function(e) {
72
- if(e && e.preventDefault) {
73
- e.preventDefault();
74
- e.stopPropagation();
75
- }
76
-
77
- this.modal.classList.remove(_class.out);
78
- this.modal.classList.add(_class.visible);
79
- this.attachButtons();
80
-
81
- disableScroll();
82
-
83
- if(!escAttached && !this.modal.dataset.disableEsc || this.modal.dataset.disableEsc === "false") {
84
- escHandler = closeModalOnEscape.bind(this);
85
- body.addEventListener('keyup', escHandler, { once: true });
86
- escAttached = true;
87
- }
88
-
89
- if(!this.modal.dataset.disableClick || this.modal.dataset.disableClick === "false") {
90
- clickHandler = closeModalOnClick.bind(this);
91
- this.modal.addEventListener('click', clickHandler, { once: true });
92
- }
93
- },
94
- dismiss: function(e, confirmed) {
95
- var _this = this;
96
-
97
- if(e && e.preventDefault) {
98
- e.preventDefault();
99
- e.stopPropagation();
100
- }
101
-
102
- enableScroll();
103
-
104
- if(_this.modal){
105
- _this.modal.classList.remove(_class.visible);
106
- _this.modal.classList.add(_class.out);
107
- }
108
-
109
- if(_this._callback) {
110
- _this._callback(confirmed);
111
- }
112
-
113
- removeModal(_this);
114
- }
115
- }
116
-
117
- return {
118
- create: create,
119
- init: attachModalHandlers
120
- }
121
-
122
- /**
123
- * @public
124
- *
125
- * @description Attach a click listener to each modals trigger on the screen, which will open the modal
126
- */
127
- function attachModalHandlers() {
128
- if(!body) {
129
- body = document.querySelector('body');
130
- }
131
-
132
- var triggers = document.querySelectorAll('.' + _class.trigger);
133
-
134
- if(triggers.length > 0) {
135
- triggers.forEach(attachTriggerHandler);
136
- }
137
-
138
- //Not the recommended way to use modals
139
- var modals = document.querySelectorAll('.' + _class.modal);
140
-
141
- if(modals.length > 0) {
142
- modals.forEach(attachModalHandler);
143
- }
144
-
145
- function attachModalHandler(modal) {
146
- if(Volta._hasClass(modal, _class.auto)) {
147
- var trigger = document.querySelector('#' + modal.dataset.trigger);
148
- trigger.addEventListener('click', function() {
149
- create(modal).open();
150
- });
151
- }
152
- }
153
-
154
- function attachTriggerHandler(trigger) {
155
- if(trigger.dataset.modal) {
156
- var modal = document.querySelector('#' + trigger.dataset.modal);
157
-
158
- if(!modal) {
159
- console.warn('Volta: modal ' + trigger.dataset.modal + ' cannot be found');
160
- }
161
-
162
- trigger.addEventListener('click', function() {
163
- create(modal).open();
164
- });
165
- }
166
- }
167
- }
168
-
169
- /**
170
- * @private
171
- *
172
- * @description Close the modal, triggered by cancel button, passes false to callback function
173
- * @param {event} e
174
- */
175
- function cancelModal(e) {
176
- return this.dismiss(e, false);
177
- }
178
-
179
- /**
180
- * @private
181
- *
182
- * @description Close the modal, triggered by confirm button, passes true to callback function
183
- * @param {event} e
184
- */
185
- function confirmModal(e) {
186
- return this.dismiss(e, true);
187
- }
188
-
189
- /**
190
- * @private
191
- *
192
- * @description Close the modal, triggered by 'x' button, passes false to callback function
193
- * @param {event} e
194
- */
195
- function dismissModal(e) {
196
- return this.dismiss(e, false);
197
- }
198
-
199
- /** @private
200
- *
201
- * @description Close the modal, triggered by 'esc' key, passes false to callback function
202
- * @param {event} e
203
- */
204
- function closeModalOnEscape(e){
205
- if(e && e.keyCode === 27) {
206
- this.dismiss(e, false);
207
- } else {
208
- body.addEventListener('click', escHandler, { once: true });
209
- }
210
- }
211
-
212
-
213
- /** @private
214
- *
215
- * @description Close the modal, triggered by 'body click, passes false to callback function
216
- * @param {event} e
217
- */
218
- function closeModalOnClick(e){
219
- if(!Volta._hasClass(e.target, _class.trigger)
220
- && !Volta._closest(e.target, '.' + _class.trigger, '.' + _class.trigger)
221
- && !Volta._closest(e.target, '.' + _class.panel, '.' + _class.panel)) {
222
- this.dismiss(e, false);
223
- } else if(this.modal) {
224
- this.modal.addEventListener('click', clickHandler, { once: true });
225
- }
226
- }
227
-
228
- /**
229
- * @public
230
- *
231
- * @description Create the modal object
232
- * @param {HTMLElement|string} elementOrId Reference to the modal element or the id
233
- *. @return {Object} A modal object
234
- */
235
- function create(elementOrId) {
236
- if(!body) {
237
- body = document.querySelector('body');
238
- }
239
- var modal = Object.create(Modal.prototype, {})
240
- modal.init(elementOrId);
241
- return modal;
242
- }
243
-
244
- /**
245
- * Private functions to disable body scroll when modal is open
246
- */
247
- function disableScroll() {
248
- body.classList.add(_class.bodyModalOpen);
249
- body.addEventListener('touchmove', preventScroll);
250
-
251
- if (body.querySelector('.Vlt-main')) {
252
- body.querySelector('.Vlt-main').addEventListener('touchmove', preventScroll);
253
- } else {
254
- body.addEventListener('touchmove', preventScroll);
255
- }
256
-
257
- body.querySelector('.' + _class.content).addEventListener('touchmove', allowScroll);
258
- }
259
-
260
- function enableScroll() {
261
- body.classList.remove(_class.bodyModalOpen);
262
- body.removeEventListener('touchmove', preventScroll);
263
-
264
- if (body.querySelector('.Vlt-main')) {
265
- body.querySelector('.Vlt-main').removeEventListener('touchmove', preventScroll);
266
- } else {
267
- body.removeEventListener('touchmove', preventScroll);
268
- }
269
-
270
- var modalContent = body.querySelector('.' + _class.content);
271
- if(modalContent) modalContent.removeEventListener('touchmove', allowScroll);
272
- }
273
-
274
- function allowScroll(e) {
275
- e.stopPropagation();
276
- }
277
-
278
- function preventScroll(e) {
279
- e.preventDefault();
280
- }
281
-
282
- /**
283
- * @private
284
- *
285
- * @description Remove the modal after dismiss, makes sure to delete the modal properties so it can be garbage collected, and removes event listeners
286
- * @param {HTMLElement|string} elementOrId Reference to the modal element or the id
287
- */
288
- function removeModal(modal) {
289
- delete modal.modal;
290
-
291
- if(modal.dismissBtn) {
292
- modal.dismissBtn.removeEventListener('click', dismissModalHandler);
293
- }
294
-
295
- if(modal.cancelBtn) {
296
- modal.cancelBtn.removeEventListener('click', cancelModalHandler);
297
- }
298
-
299
- if(modal.confirmBtn) {
300
- modal.confirmBtn.removeEventListener('click', confirmModalHandler);
301
- }
302
-
303
- if(clickHandler) {
304
- body.removeEventListener('click', clickHandler);
305
- }
306
-
307
- if(escHandler) {
308
- body.removeEventListener('keyup', escHandler);
309
- escAttached = false;
310
- }
311
- }
312
- }();