uniform-ui 2.2.2 → 2.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/lib/assets/javascripts/uniform/checkbox.js +2 -2
  3. data/lib/assets/javascripts/uniform/component.js +65 -9
  4. data/lib/assets/javascripts/uniform/dom-helpers.js +32 -10
  5. data/lib/assets/javascripts/uniform/dropdown.js +106 -38
  6. data/lib/assets/javascripts/uniform/floating-label.js +3 -3
  7. data/lib/assets/javascripts/uniform/modal.js +21 -14
  8. data/lib/assets/javascripts/uniform/popover.js +186 -0
  9. data/lib/assets/javascripts/uniform/resizer.js +1 -1
  10. data/lib/assets/javascripts/uniform/select.js +51 -24
  11. data/lib/assets/javascripts/uniform/tooltip.js +18 -71
  12. data/lib/assets/javascripts/uniform.es5.js +1 -1
  13. data/lib/assets/javascripts/uniform.jquery.js +28 -0
  14. data/lib/assets/javascripts/uniform.js +3 -1
  15. data/lib/assets/stylesheets/uniform/components/alert.scss +2 -2
  16. data/lib/assets/stylesheets/uniform/components/buttons.scss +31 -15
  17. data/lib/assets/stylesheets/uniform/components/card.scss +3 -3
  18. data/lib/assets/stylesheets/uniform/components/dropdown.scss +23 -22
  19. data/lib/assets/stylesheets/uniform/components/form/checkbox-collection.scss +4 -4
  20. data/lib/assets/stylesheets/uniform/components/form/checkbox.scss +1 -1
  21. data/lib/assets/stylesheets/uniform/components/form/floating-label.scss +2 -1
  22. data/lib/assets/stylesheets/uniform/components/form/input-group.scss +2 -2
  23. data/lib/assets/stylesheets/uniform/components/form/tristate.scss +88 -0
  24. data/lib/assets/stylesheets/uniform/components/form.scss +12 -6
  25. data/lib/assets/stylesheets/uniform/components/grid.scss +21 -0
  26. data/lib/assets/stylesheets/uniform/components/label.scss +9 -7
  27. data/lib/assets/stylesheets/uniform/components/loaders.scss +39 -39
  28. data/lib/assets/stylesheets/uniform/components/nav.scss +8 -4
  29. data/lib/assets/stylesheets/uniform/components/row.scss +18 -10
  30. data/lib/assets/stylesheets/uniform/components/select.scss +42 -5
  31. data/lib/assets/stylesheets/uniform/components/table.scss +43 -9
  32. data/lib/assets/stylesheets/uniform/components/thumb.scss +1 -1
  33. data/lib/assets/stylesheets/uniform/components/tooltip.scss +8 -30
  34. data/lib/assets/stylesheets/uniform/defaults.scss +1 -6
  35. data/lib/assets/stylesheets/uniform/functions.scss +34 -4
  36. data/lib/assets/stylesheets/uniform/helpers/border.scss +10 -1
  37. data/lib/assets/stylesheets/uniform/helpers/colors.scss +3 -2
  38. data/lib/assets/stylesheets/uniform/helpers/position.scss +6 -0
  39. data/lib/assets/stylesheets/uniform/helpers/text.scss +11 -0
  40. data/lib/assets/stylesheets/uniform/helpers.scss +9 -3
  41. data/lib/assets/stylesheets/uniform/variables.scss +8 -6
  42. data/lib/uniform/version.rb +1 -1
  43. data/lib/uniform.rb +11 -3
  44. metadata +5 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 143d67c2923a932a2dac22c38c5d34b3c34d20ee9342f5b78dd3b16186519586
4
- data.tar.gz: 137630fa26775f6a2daebad301f5b180d739dbf56cec8b36e315cc06521abb61
3
+ metadata.gz: 67b851ccfc8a78fe881b699982278e0ca0822e5548bc9a13b24d0058439a45e5
4
+ data.tar.gz: 3775d8521849dd5e05f2198de179c33dc7cb8daa42904420f8997dedbf0c351e
5
5
  SHA512:
6
- metadata.gz: 95ada558865451809abc9d757fc5fde4d2aeec45bf47d7403d57ac7e077a8d49abfcdf27fca692efc86341a3429b79440ee01a369effcb593a04d998f171856a
7
- data.tar.gz: 4ed537a653c15ebdd10d3365d5c79e5f8db3ada7ba71f89e685dd538eb2b3aec6c1fc3a94dd63db0ceadacb375eee09478d86c37e3f836704e5cfbb15861ddde
6
+ metadata.gz: 8915a6b1cc20b2d31a99c0d6b2a0f6896d2a412484a00cd8007968e761d09acfda4ed86ef5b8f906e2e5fb1d9c0a7eda416bac2358557956db437520a0033f83
7
+ data.tar.gz: 6caf4d24608b7bca30c93d2838f8a32a12ad91afe039748155fc0e110e960c92c066c01a2bfe026b329d675a4120b2f49a05b8ced017b86cdfc9a0ab044777f0
@@ -3,7 +3,7 @@ import * as Helpers from './dom-helpers';
3
3
 
4
4
  export default class Checkbox extends Component {
5
5
  initialize (options) {
6
- this.el.addEventListener('change', this.change.bind(this));
6
+ this.listenTo(this.el, 'change', this.change);
7
7
  }
8
8
 
9
9
  render () {
@@ -15,7 +15,7 @@ export default class Checkbox extends Component {
15
15
  Helpers.addClass(this.checkbox, this.el.className.replace(type, ''));
16
16
  Helpers.toggleClass(this.checkbox, 'checked', this.el.checked);
17
17
  this.el.parentNode.insertBefore(this.checkbox, this.el.nextSibling);
18
- this.checkbox.addEventListener('click', this.click.bind(this));
18
+ this.listenTo(this.checkbox, 'click', this.click);
19
19
  return this;
20
20
  }
21
21
 
@@ -1,10 +1,12 @@
1
+ import {uniqueId, hasClass} from './dom-helpers';
2
+
1
3
  export default class Component {
2
4
  constructor(options){
3
5
  options = options || {};
6
+ this.eventListens = new Array();
4
7
  this.eventListeners = new Array();
5
- this.el = options.el || document.createElement('div')
6
-
7
- this.$el = $(this.el);//remove
8
+ this.el = options.el || document.createElement('div');
9
+ this.cid = uniqueId('c');
8
10
 
9
11
  this.on = function (type, handler) {
10
12
  this.eventListeners.push({
@@ -12,13 +14,21 @@ export default class Component {
12
14
  handler: handler
13
15
  });
14
16
  };
17
+
18
+ this.off = function (type, handler) {
19
+ if(!this.eventListeners) return;
20
+ this.eventListeners = this.eventListeners.filter(function(listener){
21
+ return !(listener.type == type && listener.handler)
22
+ });
23
+ }.bind(this);
15
24
 
16
25
  this.trigger = function (event_key) {
17
- for (var i = 0; i < this.eventListeners.length; i++) {
18
- if(this.eventListeners[i].type == "*" || this.eventListeners[i].type == "all" || event_key == this.eventListeners[i].type){
19
- this.eventListeners[i].handler(event_key, this);
26
+ if(!this.eventListeners) return;
27
+ this.eventListeners.forEach(function(listener){
28
+ if(listener.type == "*" || listener.type == "all" || event_key == listener.type){
29
+ listener.handler(event_key, this);
20
30
  }
21
- }
31
+ })
22
32
  };
23
33
 
24
34
  this.initialize(options);
@@ -33,9 +43,55 @@ export default class Component {
33
43
  return newObject;
34
44
  }
35
45
 
36
- extend (object, objectMaster) {
46
+ /*
47
+ listenTo(el, 'click', '.inner_class', f(), this)
48
+ listenTo(el, 'click', f(), this)
49
+ */
50
+ listenTo(node, event, scope, callback, context){
51
+ // scope is optional param
52
+ if(typeof scope != "string") {
53
+ context = callback
54
+ callback = scope
55
+ scope = false;
56
+ }
57
+ context || (context = this);
58
+ var listen = [
59
+ node,
60
+ event,
61
+ function(e){
62
+ if(scope && !hasClass(e.target, scope.replace('.', ''))) return;
63
+ return callback.bind(context)(...arguments);
64
+ }.bind(context)
65
+ ]
66
+ this.eventListens.push(listen);
67
+ node.addEventListener(event, listen[2]);
68
+ }
69
+
70
+ listenToOnce(node, event, callback, context){
71
+ context || (context = this);
72
+ var onceCallback = function(e){
73
+ node.removeEventListener(event, onceCallback);
74
+ return callback.apply(context, arguments);
75
+ }
76
+ var listen = [
77
+ node,
78
+ event,
79
+ onceCallback
80
+ ]
81
+ this.eventListens.push(listen);
82
+ node.addEventListener(event, onceCallback);
83
+ }
84
+
85
+ remove () {
86
+ this.trigger('removed');
37
87
 
38
- return
88
+ if(this.eventListens) this.eventListens.forEach(function(listen){
89
+ listen[0].removeEventListener(listen[1], listen[2]);
90
+ });
91
+ delete this.eventListens;
92
+ delete this.eventListeners;
93
+ if(this.el && this.el.parentNode) this.el.parentNode.removeChild(this.el);
94
+ delete this.el;
39
95
  }
40
96
 
41
97
  initialize(){}
@@ -19,7 +19,7 @@ export function addClass(el, className) {
19
19
  export function removeClass(el, className) {
20
20
  var removeClassFunction = function (el) {
21
21
  if (el.classList)
22
- el.classList.remove(className);
22
+ className.split(" ").forEach((x) => el.classList.remove(x));
23
23
  else
24
24
  el.className = el.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
25
25
  }
@@ -92,7 +92,7 @@ export function createElement(html) {
92
92
  }
93
93
 
94
94
  export function closest(el, selector) {
95
- if(el.closest) return el.closest(el);
95
+ if(el.closest) return el.closest(selector);
96
96
  while (el) {
97
97
  if (Element.prototype.matches ? el.matches(selector) : el.msMatchesSelector(selector)) {
98
98
  return el;
@@ -119,18 +119,40 @@ export function filter(nodes, predicate){
119
119
  return filteredNodes;
120
120
  }
121
121
 
122
- export function once(el, type, callback) {
123
- el.addEventListener(type, function fn (e){
124
- console.log('fn', type, fn);
125
- e.target.removeEventListener(e.type, fn);
126
- return callback(e);
127
- });
128
- }
129
-
130
122
  export function offset(el){
131
123
  var rect = el.getBoundingClientRect();
132
124
  return {
133
125
  top: rect.top + window.scrollY,
134
126
  left: rect.left + window.scrollX
135
127
  }
128
+ }
129
+
130
+ export function offsetToViewport(el){
131
+ var rect = el.getBoundingClientRect();
132
+ return {
133
+ top: rect.top,
134
+ left: rect.left
135
+ }
136
+ }
137
+
138
+ export function outerHeight(el){
139
+ var height = el.offsetHeight;
140
+ var style = getComputedStyle(el);
141
+
142
+ height += parseInt(style.marginTop) + parseInt(style.marginBottom);
143
+ return height;
144
+ }
145
+
146
+ export function outerWidth(el){
147
+ var width = el.offsetWidth;
148
+ var style = getComputedStyle(el);
149
+
150
+ width += parseInt(style.marginLeft) + parseInt(style.marginRight);
151
+ return width;
152
+ }
153
+
154
+ export function uniqueId(prefix){
155
+ window.idCounter || (window.idCounter = 0);
156
+ var id = ++window.idCounter + '';
157
+ return prefix ? prefix + id : id;
136
158
  }
@@ -8,50 +8,53 @@ import * as Helpers from './dom-helpers';
8
8
  show_arrow: true\false - show dropdown arrow
9
9
  hide_sm: true|false - don't show dropdown on mobile browsers
10
10
  square: true|false - round corners on dropdown
11
+ container: node - append dropdown to
11
12
  */
12
13
  export default class Dropdown extends Component {
13
14
 
14
15
  initialize(options){
15
16
  options = options || {}
16
17
  this.options = {
17
- align: 'center',
18
+ align: 'center bottom',
18
19
  trigger: 'click',
19
20
  show_arrow: true,
20
21
  hide_sm: false,
21
- square: false
22
+ square: false,
23
+ container: document.body,
24
+ offset: {}
22
25
  };
26
+ this.options.container = this.options.container || document.body;
23
27
 
24
28
  Object.assign(this.options, this.pick(options, Object.keys(this.options)));
25
29
  this.content = options.content;
30
+ this.dropdown = document.createElement('div');
26
31
  this.el.dropdown = this;
27
32
 
28
- this.el.addEventListener(this.options.trigger, this.toggle.bind(this));
33
+ this.listenTo(this.el, this.options.trigger, this.toggle);
29
34
 
30
- this.el.addEventListener('mousedown', function (){
35
+ this.listenTo(this.el, 'mousedown', function (){
31
36
  this.mousedown = true;
32
- }.bind(this));
37
+ });
33
38
 
34
- this.el.addEventListener('mouseup', function (){
39
+ this.listenTo(this.el, 'mouseup', function (){
35
40
  this.mousedown = false;
36
- }.bind(this));
41
+ });
37
42
 
38
- this.el.addEventListener('focus', function (){
43
+ this.listenTo(this.el, 'focus', function (){
39
44
  if(this.mousedown) return;
40
45
  this.show();
41
- }.bind(this));
42
-
43
- document.addEventListener('focus', this.outsideClick.bind(this));
44
- document.addEventListener(this.options.trigger, this.outsideClick.bind(this));
45
- document.addEventListener('keyup', this.keyup.bind(this));
46
+ });
46
47
 
47
- window.addEventListener('resize', this.resize.bind(this));
48
+ this.listenTo(document, 'focus', this.outsideClick);
49
+ this.listenTo(document, this.options.trigger, this.outsideClick);
50
+ this.listenTo(document, 'keyup', this.keyup);
51
+ this.listenTo(window, 'resize', this.resize);
48
52
  }
49
53
 
50
54
  render () {
51
- this.dropdown = document.createElement('div');
52
55
  Helpers.addClass(this.dropdown, 'uniformDropdown-dropdown');
53
56
  Helpers.addClass(this.dropdown, 'absolute');
54
- this.dropdown.style.minWidth = this.$el.outerWidth();
57
+ this.dropdown.style.minWidth = Helpers.outerWidth(this.el);
55
58
  this.dropdown.innerHTML = this.content.innerHTML ? this.content.innerHTML : this.content;
56
59
  if (this.options.show_arrow) {
57
60
  Helpers.addClass(this.dropdown, 'has-pointer');
@@ -61,34 +64,96 @@ export default class Dropdown extends Component {
61
64
  }
62
65
  Helpers.toggleClass(this.dropdown, 'square', this.options.square);
63
66
  this.dropdown.style.display = 'none';
64
- document.body.appendChild(this.dropdown);
67
+ this.options.container.appendChild(this.dropdown);
65
68
  Helpers.removeClass(this.dropdown.querySelectorAll('.hidden'), 'hidden');
66
69
  return this;
67
70
  }
68
71
 
69
72
  resize () {
70
- if(!this.dropdown) return;
73
+ this.setPosition();
74
+
75
+ var align = this.options.align.split(" ");
76
+ var reposition = false;
77
+ if (Helpers.offset(this.dropdown).top + Helpers.outerHeight(this.dropdown) > Math.max(document.body.offsetHeight, window.innerHeight)) {
78
+ align[1] = "top";
79
+ reposition = true;
80
+ }
81
+ if (Helpers.offset(this.dropdown).top < 0) {
82
+ align[1] = "bottom";
83
+ reposition = true;
84
+ }
85
+ if (Helpers.offset(this.dropdown).left < 0) {
86
+ align[0] = "right";
87
+ reposition = true;
88
+ }
89
+ if (Helpers.offset(this.dropdown).left + Helpers.outerWidth(this.dropdown) > document.body.offsetWidth) {
90
+ align[0] = "left";
91
+ reposition = true;
92
+ }
93
+ if(reposition) this.setPosition(align.join(" "))
94
+ }
95
+
96
+
97
+ setPosition(align){
98
+ align = align || this.options.align;
99
+ var [leftAlign, topAlign] = align.split(" ");
100
+ leftAlign = leftAlign || "bottom";
101
+ topAlign = topAlign || "bottom";
102
+
71
103
  var offset = Helpers.offset(this.el);
72
- this.dropdown.style.top = offset.top + this.el.offsetHeight + "px";
104
+ var container = this.options.container;
105
+ if(getComputedStyle(container)['position'] == "static") container = container.offsetParent;
106
+ if(!container) container = document.body;
107
+
108
+ var containerOffset = Helpers.offset(container);
109
+ offset = {
110
+ top: offset.top - containerOffset.top,
111
+ left: offset.left - containerOffset.left
112
+ }
73
113
 
74
- if (this.options.align == "center") {
75
- this.dropdown.style.left = offset.left + this.el.offsetWidth / 2 - this.dropdown.offsetWidth / 2 + "px";
76
- } else if(this.options.align == "right") {
77
- this.dropdown.style.right = window.innerWidth - (offset.left + this.el.offsetWidth) + "px";
78
- } else {
79
- this.dropdown.style.left = offset.left + "px";
114
+ var position = {};
115
+ if(leftAlign == 'left'){
116
+ position.right = Helpers.outerWidth(container) - offset.left;
117
+ } else if(leftAlign == 'center'){
118
+ position.left = offset.left + Helpers.outerWidth(this.el) / 2 - Helpers.outerWidth(this.dropdown) / 2;
119
+ } else if (leftAlign == 'right'){
120
+ position.left = offset.left + Helpers.outerWidth(this.el);
121
+ } else if (leftAlign.includes("%")){
122
+ position.left = offset.left + Helpers.outerWidth(this.el) * parseInt(leftAlign) / 100;
123
+ } else if (leftAlign.includes("px")){
124
+ position.left = offset.left + Helpers.outerWidth(this.el) + parseInt(leftAlign);
80
125
  }
81
- if (this.dropdown.style.left && this.dropdown.style.left + this.dropdown.offsetWidth > window.innerWidth) {
82
- this.dropdown.style.left = window.innerWidth - this.dropdown.offsetWidth + "px";
126
+
127
+ if(topAlign == 'top'){
128
+ position.top = offset.top - Helpers.outerHeight(this.dropdown);
129
+ } else if(topAlign == 'center'){
130
+ position.top = offset.top + Helpers.outerHeight(this.el) / 2 - Helpers.outerHeight(this.dropdown) / 2;
131
+ } else if (topAlign == 'bottom'){
132
+ position.top = offset.top + Helpers.outerHeight(this.el);
133
+ } else if (topAlign.includes("%")){
134
+ position.top = offset.top + Helpers.outerHeight(this.el) * parseInt(topAlign) / 100;
135
+ } else if (topAlign.includes("px")){
136
+ position.top = offset.top + Helpers.outerHeight(this.el) + parseInt(topAlign);
83
137
  }
138
+
139
+ if(this.options.offset.left) position.left += parseInt(this.options.offset.left);
140
+ if(this.options.offset.top) position.top += parseInt(this.options.offset.top);
141
+ if(this.options.offset.left) position.right -= parseInt(this.options.offset.left);
142
+
143
+ this.dropdown.style.left = 'auto';
144
+ this.dropdown.style.right = 'auto';
145
+ Helpers.removeClass(this.dropdown, 'popover-left popover-right popover-center popover-top popover-bottom');
146
+ Helpers.addClass(this.dropdown, 'popover-' + topAlign);
147
+ Helpers.addClass(this.dropdown, 'popover-' + leftAlign);
148
+ Object.keys(position).forEach(function(key){
149
+ this.dropdown.style[key] = position[key] + "px";
150
+ }, this);
84
151
  }
85
152
 
86
153
  remove () {
87
- this.el.parentNode.removeChild(this.el);
88
- this.el.removeEventListener(this.options.trigger);
89
- window.removeEventListener('resize', this.resize.bind(this));
90
- document.removeEventListener(this.options.trigger, this.outsideClick.bind(this));
91
- document.removeEventListener('keyup', this.keyup.bind(this));
154
+ Component.prototype.remove.apply(this, arguments);
155
+ if(this.dropdown.parentNode) this.dropdown.parentNode.removeChild(this.dropdown);
156
+ delete this.dropdown;
92
157
  }
93
158
 
94
159
  toggle (e) {
@@ -99,7 +164,8 @@ export default class Dropdown extends Component {
99
164
  }
100
165
  }
101
166
 
102
- show () {
167
+ show (options) {
168
+ options || (options = {});
103
169
  if(this.options.hide_sm && window.innerWidth < 720) return;
104
170
  if(!this.dropdown) this.render();
105
171
 
@@ -117,20 +183,22 @@ export default class Dropdown extends Component {
117
183
  Helpers.addClass(document.body, 'uniformModal-hideBody');
118
184
  }
119
185
 
120
- this.overlay.addEventListener('click', this.hide.bind(this));
121
- this.trigger('shown');
186
+ this.listenTo(this.overlay, 'click', this.hide);
187
+ if(!options.silent) this.trigger('shown');
122
188
  }
123
189
 
124
- hide () {
190
+ hide (options) {
191
+ options || (options = {});
125
192
  if(!this.dropdown) return;
193
+ if(!Helpers.hasClass(this.el, 'active')) return;
126
194
  this.dropdown.style.display = 'none';
127
195
  Helpers.removeClass(this.el, 'active');
128
- if (this.overlay) this.overlay.parentNode.removeChild(this.overlay)
196
+ if (this.overlay && this.overlay.parentNode) this.overlay.parentNode.removeChild(this.overlay)
129
197
  if (window.innerWidth < 720) {
130
198
  Helpers.removeClass(document.body, 'uniformModal-hideBody');
131
199
  window.scrollTo(0, this.lastScrollPosition);
132
200
  }
133
- this.trigger('hidden');
201
+ if(!options.silent) this.trigger('hidden');
134
202
  }
135
203
 
136
204
  outsideClick (e) {
@@ -8,9 +8,9 @@ export default class FloatingLabel extends Component {
8
8
  this.input = this.el.querySelector("#" + this.label.getAttribute('for'));
9
9
  this.startingHeight;
10
10
 
11
- this.input.addEventListener('focus', this.activate.bind(this));
12
- this.input.addEventListener('blur', this.deactivate.bind(this));
13
- this.input.addEventListener('revealed', this.render.bind(this));
11
+ this.listenTo(this.input, 'focus', this.activate);
12
+ this.listenTo(this.input, 'blur', this.deactivate);
13
+ this.listenTo(this.input, 'revealed', this.render);
14
14
  }
15
15
 
16
16
  render () {
@@ -5,6 +5,8 @@ import * as Helpers from './dom-helpers';
5
5
  Options
6
6
  content: string|$el|function
7
7
  klass: string - classes to append to modal container
8
+
9
+ * use blurrable to keep some elements from being blurred ie. <div blurrable="false">...</div>
8
10
  */
9
11
  export default class Modal extends Component {
10
12
 
@@ -14,8 +16,8 @@ export default class Modal extends Component {
14
16
  this.content = options.content;
15
17
 
16
18
  Helpers.addClass(this.el, 'uniformModal');
17
- document.addEventListener('keyup', this.keyup.bind(this));
18
- this.el.addEventListener('click', this.checkCloseButton.bind(this));
19
+ this.listenTo(document, 'keyup', this.keyup);
20
+ this.listenTo(this.el, 'click', this.checkCloseButton);
19
21
  }
20
22
 
21
23
  keyup (e) {
@@ -46,10 +48,13 @@ export default class Modal extends Component {
46
48
 
47
49
  this.el.appendChild(this.overlay);
48
50
 
49
- var elements = document.body.children;
50
- var elementCount = elements.length
51
- for(var i=0; i < elementCount; i++){
52
- this.blur.appendChild(elements[0])
51
+ let next_element = document.body.children[0]
52
+ while(next_element){
53
+ const element = next_element;
54
+ next_element = element.nextElementSibling;
55
+ if(!element.matches('[blurrable="false"]')) {
56
+ this.blur.appendChild(element)
57
+ }
53
58
  }
54
59
 
55
60
  Helpers.addClass(document.body, 'uniformModal-active');
@@ -58,14 +63,18 @@ export default class Modal extends Component {
58
63
 
59
64
  var container = document.createElement('div');
60
65
  Helpers.addClass(container, 'uniformModal-container');
61
- container.innerHTML = content.innerHTML ? content.innerHTML : content;
66
+ if (content instanceof Node) {
67
+ container.appendChild(content);
68
+ } else {
69
+ container.innerHTML = content;
70
+ }
62
71
 
63
72
  var closeButton = document.createElement('div');
64
73
  Helpers.addClass(closeButton, 'uniformModal-close');
65
74
  container.appendChild(closeButton);
66
75
 
67
76
  this.el.style.top = window.scrollY;
68
- this.overlay.addEventListener('click', this.close.bind(this));
77
+ this.listenTo(this.overlay, 'click', this.close);
69
78
  this.el.appendChild(container);
70
79
 
71
80
  if (this.options.klass) Helpers.addClass(container, this.options.klass);
@@ -87,17 +96,15 @@ export default class Modal extends Component {
87
96
  for(var i=0; i < elementCount; i++){
88
97
  document.body.appendChild(elements[0]);
89
98
  }
90
- this.blur.parentNode.removeChild(this.blur);
99
+ if(this.blur.parentNode) this.blur.parentNode.removeChild(this.blur);
91
100
  window.scrollTo(0, this.original_scroll);
92
101
  this.trigger('closed');
93
102
  this.remove();
94
103
  }
95
104
 
96
105
  remove () {
97
- this.overlay.parentNode.removeChild(this.overlay);
98
- this.el.parentNode.removeChild(this.el);
99
- this.el.removeEventListener('click', this.checkCloseButton.bind(this));
100
- this.overlay.removeEventListener('click', this.close.bind(this));
101
- document.removeEventListener('keyup', this.keyup.bind(this));
106
+ Component.prototype.remove.apply(this, arguments);
107
+ if(this.overlay && this.overlay.parentNode) this.overlay.parentNode.removeChild(this.overlay);
108
+ delete this.overlay;
102
109
  }
103
110
  }