uniform-ui 1.0 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/assets/config/manifest.js +1 -0
- data/lib/assets/javascripts/uniform/checkbox.js +31 -0
- data/lib/assets/javascripts/uniform/component.js +42 -0
- data/lib/assets/javascripts/uniform/dom-helpers.js +136 -0
- data/lib/assets/javascripts/uniform/dropdown.js +149 -0
- data/lib/assets/javascripts/uniform/floating-label.js +54 -0
- data/lib/assets/javascripts/uniform/icons.js +16 -0
- data/lib/assets/javascripts/uniform/modal.js +103 -0
- data/lib/assets/javascripts/uniform/resizer.js +43 -0
- data/lib/assets/javascripts/uniform/select.js +235 -0
- data/lib/assets/javascripts/uniform/tooltip.js +120 -0
- data/lib/assets/javascripts/uniform-es5.js +1 -0
- data/lib/assets/javascripts/uniform-jquery.js +124 -0
- data/lib/assets/javascripts/uniform.js +17 -0
- data/lib/assets/stylesheets/uniform/base.scss +3 -0
- data/lib/assets/stylesheets/uniform/components/alert.scss +72 -0
- data/lib/assets/stylesheets/uniform/components/buttons.scss +219 -0
- data/{vendor → lib}/assets/stylesheets/uniform/components/card.scss +33 -25
- data/lib/assets/stylesheets/uniform/components/container.scss +19 -0
- data/{vendor → lib}/assets/stylesheets/uniform/components/dropdown.scss +8 -4
- data/lib/assets/stylesheets/uniform/components/form/checkbox-collection.scss +103 -0
- data/lib/assets/stylesheets/uniform/components/form/checkbox.scss +58 -0
- data/lib/assets/stylesheets/uniform/components/form/floating-label.scss +64 -0
- data/lib/assets/stylesheets/uniform/components/form/input-group.scss +56 -0
- data/lib/assets/stylesheets/uniform/components/form.scss +143 -0
- data/lib/assets/stylesheets/uniform/components/grid.scss +158 -0
- data/lib/assets/stylesheets/uniform/components/label.scss +26 -0
- data/lib/assets/stylesheets/uniform/components/loaders.scss +80 -0
- data/{vendor → lib}/assets/stylesheets/uniform/components/modal.scss +26 -4
- data/lib/assets/stylesheets/uniform/components/nav.scss +124 -0
- data/lib/assets/stylesheets/uniform/components/row.scss +69 -0
- data/lib/assets/stylesheets/uniform/components/select.scss +122 -0
- data/lib/assets/stylesheets/uniform/components/table.scss +127 -0
- data/lib/assets/stylesheets/uniform/components/thumb.scss +41 -0
- data/lib/assets/stylesheets/uniform/components/tooltip.scss +63 -0
- data/lib/assets/stylesheets/uniform/components.scss +11 -0
- data/{vendor → lib}/assets/stylesheets/uniform/defaults.scss +7 -4
- data/lib/assets/stylesheets/uniform/functions.scss +31 -0
- data/lib/assets/stylesheets/uniform/helpers/border.scss +19 -0
- data/lib/assets/stylesheets/uniform/helpers/colors.scss +23 -0
- data/lib/assets/stylesheets/uniform/helpers/margin.scss +27 -0
- data/lib/assets/stylesheets/uniform/helpers/padding.scss +9 -0
- data/lib/assets/stylesheets/uniform/helpers/position.scss +13 -0
- data/lib/assets/stylesheets/uniform/helpers/sizes.scss +38 -0
- data/{vendor → lib}/assets/stylesheets/uniform/helpers/text.scss +86 -73
- data/lib/assets/stylesheets/uniform/helpers.scss +127 -0
- data/lib/assets/stylesheets/uniform/mixins.scss +116 -0
- data/lib/assets/stylesheets/uniform/print/grid.scss +50 -0
- data/lib/assets/stylesheets/uniform/variables.scss +72 -0
- data/lib/assets/stylesheets/uniform-print.scss +1 -0
- data/lib/assets/stylesheets/uniform.scss +11 -0
- data/lib/uniform/version.rb +3 -0
- data/lib/uniform.rb +15 -0
- metadata +87 -95
- data/.gitignore +0 -2
- data/CHANGELOG.md +0 -27
- data/CNAME +0 -1
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -40
- data/LICENSE +0 -22
- data/README.md +0 -35
- data/Rakefile +0 -74
- data/index.html +0 -251
- data/lib/uniform/rails/engine.rb +0 -8
- data/lib/uniform/rails.rb +0 -6
- data/lib/uniform/ui.rb +0 -1
- data/preview/alerts.html.erb +0 -1
- data/preview/buttons.html.erb +0 -62
- data/preview/cards.html.erb +0 -23
- data/preview/colors.html.erb +0 -22
- data/preview/dropdown.html.erb +0 -1
- data/preview/form.html.erb +0 -233
- data/preview/grid.html.erb +0 -304
- data/preview/helpers.html.erb +0 -225
- data/preview/index.html.erb +0 -77
- data/preview/labels.html.erb +0 -1
- data/preview/layout.html.erb +0 -63
- data/preview/loaders.html.erb +0 -83
- data/preview/modal.html.erb +0 -1
- data/preview/nav.html.erb +0 -77
- data/preview/preview.scss +0 -76
- data/preview/rows.html.erb +0 -36
- data/preview/select.html.erb +0 -1
- data/preview/tables.html.erb +0 -1
- data/preview/tabs.html.erb +0 -17
- data/preview/tiles.html.erb +0 -1
- data/preview/tooltip.erb +0 -1
- data/preview.css +0 -0
- data/site/alerts.html +0 -157
- data/site/alerts.html copy +0 -133
- data/site/buttons.html +0 -286
- data/site/cards.html +0 -177
- data/site/colors.html +0 -275
- data/site/dropdown.html +0 -157
- data/site/dropdown.html copy +0 -141
- data/site/form.html +0 -369
- data/site/grid.html +0 -716
- data/site/helpers.html +0 -1008
- data/site/index.html +0 -251
- data/site/labels.html +0 -157
- data/site/layout.html +0 -313
- data/site/loaders.html +0 -233
- data/site/logo.png +0 -0
- data/site/modal.html +0 -157
- data/site/nav.html +0 -229
- data/site/preview.css +0 -1
- data/site/preview.js +0 -59
- data/site/rows.html +0 -190
- data/site/select.html +0 -157
- data/site/tables.html +0 -157
- data/site/tabs.html +0 -171
- data/site/tiles.html +0 -157
- data/site/tiles.html copy +0 -109
- data/site/tooltip +0 -157
- data/site/uniform.css +0 -1
- data/uniform.gemspec +0 -22
- data/vendor/assets/stylesheets/uniform/base.scss +0 -2
- data/vendor/assets/stylesheets/uniform/components/alert.scss +0 -27
- data/vendor/assets/stylesheets/uniform/components/buttons.scss +0 -212
- data/vendor/assets/stylesheets/uniform/components/form.scss +0 -290
- data/vendor/assets/stylesheets/uniform/components/grid.scss +0 -225
- data/vendor/assets/stylesheets/uniform/components/label.scss +0 -63
- data/vendor/assets/stylesheets/uniform/components/loaders.scss +0 -82
- data/vendor/assets/stylesheets/uniform/components/nav.scss +0 -197
- data/vendor/assets/stylesheets/uniform/components/row.scss +0 -92
- data/vendor/assets/stylesheets/uniform/components/select.scss +0 -98
- data/vendor/assets/stylesheets/uniform/components/table.scss +0 -83
- data/vendor/assets/stylesheets/uniform/components/tabs.scss +0 -45
- data/vendor/assets/stylesheets/uniform/components/tile.scss +0 -20
- data/vendor/assets/stylesheets/uniform/components/tooltip.scss +0 -46
- data/vendor/assets/stylesheets/uniform/helpers/colors.scss +0 -37
- data/vendor/assets/stylesheets/uniform/helpers/margin.scss +0 -44
- data/vendor/assets/stylesheets/uniform/helpers/padding.scss +0 -74
- data/vendor/assets/stylesheets/uniform/helpers/sizes.scss +0 -31
- data/vendor/assets/stylesheets/uniform/helpers.scss +0 -124
- data/vendor/assets/stylesheets/uniform/mixins.scss +0 -77
- data/vendor/assets/stylesheets/uniform/variables.scss +0 -36
- data/vendor/assets/stylesheets/uniform.scss +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d1dcff8bf35d3dee57b8cbc4de8baf06919ca562110399efff8f61210cfca4b8
|
4
|
+
data.tar.gz: 87aa8ec45d65367955c0bb88768e0d4af321b89f96bbbf41c1b5e5ec6500f3ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56bbcc4f1dfd83f1f90724fa4891490f0375a097a6dda20b717de12001daffbc3695aad86cbb743320da1aa0aa6262196883421db75e5d679a63d43f4cc9c3ca
|
7
|
+
data.tar.gz: f3d2e38f9fda4a0df69145ce8164ff9b18a20da8b8f3e079c11aec50fd29122709d2aef469c924e31cf7654d6bbf9c6f3657d93ee1d241b4eff0217e88c40a96
|
@@ -0,0 +1 @@
|
|
1
|
+
//= link_directory uniform/stylesheets .css
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import Component from './component';
|
2
|
+
import * as Helpers from './dom-helpers';
|
3
|
+
|
4
|
+
export default class Checkbox extends Component {
|
5
|
+
initialize (options) {
|
6
|
+
this.el.addEventListener('change', this.change.bind(this));
|
7
|
+
}
|
8
|
+
|
9
|
+
render () {
|
10
|
+
var type = Helpers.hasClass(this.el, 'uniformRadio') ? 'uniformRadio' : 'uniformCheckbox';
|
11
|
+
this.checkbox = document.createElement('div');
|
12
|
+
Helpers.addClass(this.checkbox, `${type}-indicator`);
|
13
|
+
|
14
|
+
if (this.el.className && this.el.className.replace(type, '') != '')
|
15
|
+
Helpers.addClass(this.checkbox, this.el.className.replace(type, ''));
|
16
|
+
Helpers.toggleClass(this.checkbox, 'checked', this.el.checked);
|
17
|
+
this.el.parentNode.insertBefore(this.checkbox, this.el.nextSibling);
|
18
|
+
this.checkbox.addEventListener('click', this.click.bind(this));
|
19
|
+
return this;
|
20
|
+
}
|
21
|
+
|
22
|
+
click (e) {
|
23
|
+
if (this.el.disabled) return;
|
24
|
+
this.el.checked = !this.el.checked
|
25
|
+
Helpers.trigger(this.el, 'change');
|
26
|
+
e.preventDefault();
|
27
|
+
}
|
28
|
+
change () {
|
29
|
+
Helpers.toggleClass(this.checkbox, 'checked', this.el.checked);
|
30
|
+
}
|
31
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
export default class Component {
|
2
|
+
constructor(options){
|
3
|
+
options = options || {};
|
4
|
+
this.eventListeners = new Array();
|
5
|
+
this.el = options.el || document.createElement('div')
|
6
|
+
|
7
|
+
this.$el = $(this.el);//remove
|
8
|
+
|
9
|
+
this.on = function (type, handler) {
|
10
|
+
this.eventListeners.push({
|
11
|
+
type: type,
|
12
|
+
handler: handler
|
13
|
+
});
|
14
|
+
};
|
15
|
+
|
16
|
+
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);
|
20
|
+
}
|
21
|
+
}
|
22
|
+
};
|
23
|
+
|
24
|
+
this.initialize(options);
|
25
|
+
}
|
26
|
+
|
27
|
+
pick (object, keys) {
|
28
|
+
var newObject = {}
|
29
|
+
keys.forEach(function(key){
|
30
|
+
if(object[key] !== undefined) newObject[key] = object[key];
|
31
|
+
});
|
32
|
+
|
33
|
+
return newObject;
|
34
|
+
}
|
35
|
+
|
36
|
+
extend (object, objectMaster) {
|
37
|
+
|
38
|
+
return
|
39
|
+
}
|
40
|
+
|
41
|
+
initialize(){}
|
42
|
+
}
|
@@ -0,0 +1,136 @@
|
|
1
|
+
export function hasClass (el, className) {
|
2
|
+
var test;
|
3
|
+
if(el.classList)
|
4
|
+
test = el.classList.contains(className)
|
5
|
+
else
|
6
|
+
test = new RegExp('(^| )' + className + '( |$)', 'gi').test(el.className);
|
7
|
+
return test
|
8
|
+
}
|
9
|
+
|
10
|
+
export function addClass(el, className) {
|
11
|
+
if (el.classList){
|
12
|
+
each(className.split(" "), function(className){
|
13
|
+
el.classList.add(className);
|
14
|
+
});
|
15
|
+
} else
|
16
|
+
el.className += ' ' + className;
|
17
|
+
}
|
18
|
+
|
19
|
+
export function removeClass(el, className) {
|
20
|
+
var removeClassFunction = function (el) {
|
21
|
+
if (el.classList)
|
22
|
+
el.classList.remove(className);
|
23
|
+
else
|
24
|
+
el.className = el.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
|
25
|
+
}
|
26
|
+
if (NodeList.prototype.isPrototypeOf(el))
|
27
|
+
each(el, removeClassFunction)
|
28
|
+
else
|
29
|
+
removeClassFunction(el);
|
30
|
+
}
|
31
|
+
|
32
|
+
export function toggleClass(el, className, toggle) {
|
33
|
+
if (el.classList) {
|
34
|
+
el.classList.toggle(className, toggle);
|
35
|
+
} else {
|
36
|
+
var classes = el.className.split(' ');
|
37
|
+
var existingIndex = classes.indexOf(className);
|
38
|
+
|
39
|
+
if (toggle === false || (toggle !== true && existingIndex >= 0))
|
40
|
+
classes.splice(existingIndex, 1);
|
41
|
+
else
|
42
|
+
classes.push(className);
|
43
|
+
|
44
|
+
el.className = classes.join(' ');
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
export function trigger(el, eventName) {
|
49
|
+
var event = document.createEvent('HTMLEvents');
|
50
|
+
event.initEvent(eventName, true, false);
|
51
|
+
el.dispatchEvent(event);
|
52
|
+
}
|
53
|
+
|
54
|
+
export function each (elements, method){
|
55
|
+
for(var i=0; i < elements.length; i++){
|
56
|
+
method(elements[i], i);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
export function map (elements, method){
|
61
|
+
var results = [];
|
62
|
+
for(var i=0; i < elements.length; i++){
|
63
|
+
results.push(method(elements[i], i));
|
64
|
+
}
|
65
|
+
return results;
|
66
|
+
}
|
67
|
+
|
68
|
+
export function is_visible(element){
|
69
|
+
return element.offsetParent !== null;
|
70
|
+
}
|
71
|
+
|
72
|
+
export function is_focus(element){
|
73
|
+
return document.activeElement === element;
|
74
|
+
}
|
75
|
+
|
76
|
+
export function is_empty(element){
|
77
|
+
return element.innerHTML === "";
|
78
|
+
}
|
79
|
+
|
80
|
+
export function css (el, rule) {
|
81
|
+
return getComputedStyle(el)[rule];
|
82
|
+
}
|
83
|
+
|
84
|
+
export function remove (el) {
|
85
|
+
el.parentNode.removeChild(el);
|
86
|
+
}
|
87
|
+
|
88
|
+
export function createElement(html) {
|
89
|
+
var container = document.createElement('div');
|
90
|
+
container.innerHTML = html;
|
91
|
+
return container.children[0];
|
92
|
+
}
|
93
|
+
|
94
|
+
export function closest(el, selector) {
|
95
|
+
if(el.closest) return el.closest(el);
|
96
|
+
while (el) {
|
97
|
+
if (Element.prototype.matches ? el.matches(selector) : el.msMatchesSelector(selector)) {
|
98
|
+
return el;
|
99
|
+
}
|
100
|
+
el = el.parentElement;
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
export function ancestors(el) {
|
105
|
+
var ancestors = [];
|
106
|
+
el = el.parentElement;
|
107
|
+
while (el){
|
108
|
+
ancestors.push(el);
|
109
|
+
el = el.parentElement;
|
110
|
+
}
|
111
|
+
return ancestors;
|
112
|
+
}
|
113
|
+
|
114
|
+
export function filter(nodes, predicate){
|
115
|
+
var filteredNodes = [];
|
116
|
+
each(nodes, function(node){
|
117
|
+
if(predicate(node)) filteredNodes.push(node);
|
118
|
+
});
|
119
|
+
return filteredNodes;
|
120
|
+
}
|
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
|
+
export function offset(el){
|
131
|
+
var rect = el.getBoundingClientRect();
|
132
|
+
return {
|
133
|
+
top: rect.top + window.scrollY,
|
134
|
+
left: rect.left + window.scrollX
|
135
|
+
}
|
136
|
+
}
|
@@ -0,0 +1,149 @@
|
|
1
|
+
import Component from './component';
|
2
|
+
import * as Helpers from './dom-helpers';
|
3
|
+
|
4
|
+
/*. Dropdown.initialize
|
5
|
+
content: string|el - content rendered in dropdown
|
6
|
+
align: 'center'|'left'|'right| - how dropdown aligns to trigger el
|
7
|
+
trigger: 'click'|'focus'|'mouseover' - what triggers showDropdown
|
8
|
+
show_arrow: true\false - show dropdown arrow
|
9
|
+
hide_sm: true|false - don't show dropdown on mobile browsers
|
10
|
+
square: true|false - round corners on dropdown
|
11
|
+
*/
|
12
|
+
export default class Dropdown extends Component {
|
13
|
+
|
14
|
+
initialize(options){
|
15
|
+
options = options || {}
|
16
|
+
this.options = {
|
17
|
+
align: 'center',
|
18
|
+
trigger: 'click',
|
19
|
+
show_arrow: true,
|
20
|
+
hide_sm: false,
|
21
|
+
square: false
|
22
|
+
};
|
23
|
+
|
24
|
+
Object.assign(this.options, this.pick(options, Object.keys(this.options)));
|
25
|
+
this.content = options.content;
|
26
|
+
this.el.dropdown = this;
|
27
|
+
|
28
|
+
this.el.addEventListener(this.options.trigger, this.toggle.bind(this));
|
29
|
+
|
30
|
+
this.el.addEventListener('mousedown', function (){
|
31
|
+
this.mousedown = true;
|
32
|
+
}.bind(this));
|
33
|
+
|
34
|
+
this.el.addEventListener('mouseup', function (){
|
35
|
+
this.mousedown = false;
|
36
|
+
}.bind(this));
|
37
|
+
|
38
|
+
this.el.addEventListener('focus', function (){
|
39
|
+
if(this.mousedown) return;
|
40
|
+
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
|
+
|
47
|
+
window.addEventListener('resize', this.resize.bind(this));
|
48
|
+
}
|
49
|
+
|
50
|
+
render () {
|
51
|
+
this.dropdown = document.createElement('div');
|
52
|
+
Helpers.addClass(this.dropdown, 'uniformDropdown-dropdown');
|
53
|
+
Helpers.addClass(this.dropdown, 'absolute');
|
54
|
+
this.dropdown.style.minWidth = this.$el.outerWidth();
|
55
|
+
this.dropdown.innerHTML = this.content.innerHTML ? this.content.innerHTML : this.content;
|
56
|
+
if (this.options.show_arrow) {
|
57
|
+
Helpers.addClass(this.dropdown, 'has-pointer');
|
58
|
+
var pointer = document.createElement('div');
|
59
|
+
Helpers.addClass(pointer, 'uniformDropdown-pointer')
|
60
|
+
this.dropdown.appendChild(pointer);
|
61
|
+
}
|
62
|
+
Helpers.toggleClass(this.dropdown, 'square', this.options.square);
|
63
|
+
this.dropdown.style.display = 'none';
|
64
|
+
document.body.appendChild(this.dropdown);
|
65
|
+
Helpers.removeClass(this.dropdown.querySelectorAll('.hidden'), 'hidden');
|
66
|
+
return this;
|
67
|
+
}
|
68
|
+
|
69
|
+
resize () {
|
70
|
+
if(!this.dropdown) return;
|
71
|
+
var offset = Helpers.offset(this.el);
|
72
|
+
this.dropdown.style.top = offset.top + this.el.offsetHeight + "px";
|
73
|
+
|
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";
|
80
|
+
}
|
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";
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
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));
|
92
|
+
}
|
93
|
+
|
94
|
+
toggle (e) {
|
95
|
+
if (Helpers.hasClass(this.el, 'active') && e.type == "click") {
|
96
|
+
this.hide();
|
97
|
+
} else {
|
98
|
+
this.show();
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
show () {
|
103
|
+
if(this.options.hide_sm && window.innerWidth < 720) return;
|
104
|
+
if(!this.dropdown) this.render();
|
105
|
+
|
106
|
+
this.dropdown.style.display = 'block';
|
107
|
+
Helpers.addClass(this.el, 'active');
|
108
|
+
|
109
|
+
this.resize();
|
110
|
+
|
111
|
+
this.overlay = document.createElement('div');
|
112
|
+
Helpers.addClass(this.overlay, 'uniformOverlay');
|
113
|
+
document.body.appendChild(this.overlay);
|
114
|
+
|
115
|
+
if (window.innerWidth < 720) {
|
116
|
+
this.lastScrollPosition = window.scrollY;
|
117
|
+
Helpers.addClass(document.body, 'uniformModal-hideBody');
|
118
|
+
}
|
119
|
+
|
120
|
+
this.overlay.addEventListener('click', this.hide.bind(this));
|
121
|
+
this.trigger('shown');
|
122
|
+
}
|
123
|
+
|
124
|
+
hide () {
|
125
|
+
if(!this.dropdown) return;
|
126
|
+
this.dropdown.style.display = 'none';
|
127
|
+
Helpers.removeClass(this.el, 'active');
|
128
|
+
if (this.overlay) this.overlay.parentNode.removeChild(this.overlay)
|
129
|
+
if (window.innerWidth < 720) {
|
130
|
+
Helpers.removeClass(document.body, 'uniformModal-hideBody');
|
131
|
+
window.scrollTo(0, this.lastScrollPosition);
|
132
|
+
}
|
133
|
+
this.trigger('hidden');
|
134
|
+
}
|
135
|
+
|
136
|
+
outsideClick (e) {
|
137
|
+
if (!this.dropdown || this.dropdown.offsetParent === null) return;
|
138
|
+
if (e.target === this.el) return;
|
139
|
+
if (e.target === this.overlay) return;
|
140
|
+
if (this.el.contains(e.target)) return;
|
141
|
+
if (this.dropdown.contains(e.target)) return;
|
142
|
+
this.hide();
|
143
|
+
}
|
144
|
+
|
145
|
+
keyup (e) {
|
146
|
+
if(e.which != 27) return;
|
147
|
+
this.hide();
|
148
|
+
}
|
149
|
+
}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
import Component from './component';
|
2
|
+
import * as Helpers from './dom-helpers';
|
3
|
+
|
4
|
+
export default class FloatingLabel extends Component {
|
5
|
+
|
6
|
+
initialize(){
|
7
|
+
this.label = this.el.querySelector('label');
|
8
|
+
this.input = this.el.querySelector("#" + this.label.getAttribute('for'));
|
9
|
+
this.startingHeight;
|
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));
|
14
|
+
}
|
15
|
+
|
16
|
+
render () {
|
17
|
+
if(!Helpers.is_visible(this.input)) return;
|
18
|
+
if(Helpers.hasClass(this.el, 'enabled')) return;
|
19
|
+
|
20
|
+
var padding = parseInt(Helpers.css(this.input, 'paddingBottom'));
|
21
|
+
this.startingHeight = this.input.offsetHeight;
|
22
|
+
Helpers.addClass(this.el, 'enabled');
|
23
|
+
Helpers.addClass(this.el, 'inactive');
|
24
|
+
|
25
|
+
this.input.style.paddingTop = padding + padding/2 + "px";
|
26
|
+
this.input.style.paddingBottom = padding - padding/2 - 2 + "px";
|
27
|
+
|
28
|
+
this.label.style.position = 'absolute';
|
29
|
+
this.label.style.top = 0;
|
30
|
+
this.label.style.left = this.label.offsetLeft;
|
31
|
+
this.label.style.paddingLeft = Helpers.css(this.input, 'paddingLeft');
|
32
|
+
this.label.style.height = this.startingHeight;
|
33
|
+
this.label.style.lineHeight = this.startingHeight + "px";
|
34
|
+
|
35
|
+
if (Helpers.is_focus(this.input)) this.activate();
|
36
|
+
if (typeof this.input.value !== "undefined" && this.input.value != "") this.activate();
|
37
|
+
}
|
38
|
+
|
39
|
+
activate (e) {
|
40
|
+
if (typeof e !== "undefined") Helpers.addClass(this.el, 'active');
|
41
|
+
if (Helpers.hasClass(this.el, 'float')) return;
|
42
|
+
Helpers.addClass(this.el, 'float');
|
43
|
+
Helpers.removeClass(this.el, 'inactive');
|
44
|
+
this.label.style.lineHeight = this.startingHeight / 2 + "px";
|
45
|
+
}
|
46
|
+
|
47
|
+
deactivate (e) {
|
48
|
+
if (typeof e !== "undefined") Helpers.removeClass(this.el, 'active');
|
49
|
+
if (this.input.value != "") return;
|
50
|
+
Helpers.removeClass(this.el, 'float');
|
51
|
+
Helpers.addClass(this.el, 'inactive');
|
52
|
+
this.label.style.lineHeight = this.startingHeight + "px";
|
53
|
+
}
|
54
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
let check = `
|
2
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1em" height="1em" viewBox="0 0 32 32">
|
3
|
+
<path d="M28.998 8.531l-2.134-2.134c-0.394-0.393-1.030-0.393-1.423 0l-12.795 12.795-6.086-6.13c-0.393-0.393-1.029-0.393-1.423 0l-2.134 2.134c-0.393 0.394-0.393 1.030 0 1.423l8.924 8.984c0.393 0.393 1.030 0.393 1.423 0l15.648-15.649c0.393-0.392 0.393-1.030 0-1.423z"></path>
|
4
|
+
</svg>
|
5
|
+
`.trim()
|
6
|
+
|
7
|
+
let arrow_down = `
|
8
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1em" height="1em" viewBox="0 0 20 20">
|
9
|
+
<path d="M13.418 7.601c0.271-0.268 0.709-0.268 0.979 0s0.271 0.701 0 0.969l-3.907 3.83c-0.271 0.268-0.709 0.268-0.979 0l-3.908-3.83c-0.27-0.268-0.27-0.701 0-0.969s0.708-0.268 0.979 0l3.418 3.14 3.418-3.14z"></path>
|
10
|
+
</svg>
|
11
|
+
`.trim()
|
12
|
+
|
13
|
+
export {
|
14
|
+
check,
|
15
|
+
arrow_down
|
16
|
+
}
|
@@ -0,0 +1,103 @@
|
|
1
|
+
import Component from './component';
|
2
|
+
import * as Helpers from './dom-helpers';
|
3
|
+
|
4
|
+
/* UniformModal.initialize
|
5
|
+
Options
|
6
|
+
content: string|$el|function
|
7
|
+
klass: string - classes to append to modal container
|
8
|
+
*/
|
9
|
+
export default class Modal extends Component {
|
10
|
+
|
11
|
+
initialize (options) {
|
12
|
+
this.options = {};
|
13
|
+
this.options.klass = options.klass || false;
|
14
|
+
this.content = options.content;
|
15
|
+
|
16
|
+
Helpers.addClass(this.el, 'uniformModal');
|
17
|
+
document.addEventListener('keyup', this.keyup.bind(this));
|
18
|
+
this.el.addEventListener('click', this.checkCloseButton.bind(this));
|
19
|
+
}
|
20
|
+
|
21
|
+
keyup (e) {
|
22
|
+
if(e.which != 27) return;
|
23
|
+
this.close();
|
24
|
+
}
|
25
|
+
|
26
|
+
render () {
|
27
|
+
var that = this;
|
28
|
+
var content = typeof this.content == 'function' ? this.content() : this.content;
|
29
|
+
|
30
|
+
this.highest_z_index = 0;
|
31
|
+
this.overlay = document.createElement('div');
|
32
|
+
Helpers.addClass(this.overlay, 'uniformModal-overlay');
|
33
|
+
|
34
|
+
this.blur = document.createElement('div');
|
35
|
+
Helpers.addClass(this.blur, 'uniformModal-blur');
|
36
|
+
|
37
|
+
this.original_scroll = window.scrollY;
|
38
|
+
this.blur.style.top = 0 - this.original_scroll + "px";
|
39
|
+
|
40
|
+
if (document.body.querySelectorAll('.uniformModal').length > 0) {
|
41
|
+
this.highest_z_index = Math.max(Array.prototype.map.call(document.body.querySelectorAll('.uniformModal'), function(el){
|
42
|
+
return parseInt(Helpers.css(el, 'zIndex'));
|
43
|
+
}));
|
44
|
+
this.el.style.zIndex = this.highest_z_index + 2;
|
45
|
+
}
|
46
|
+
|
47
|
+
this.el.appendChild(this.overlay);
|
48
|
+
|
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])
|
53
|
+
}
|
54
|
+
|
55
|
+
Helpers.addClass(document.body, 'uniformModal-active');
|
56
|
+
document.body.appendChild(this.blur);
|
57
|
+
document.body.appendChild(this.el);
|
58
|
+
|
59
|
+
var container = document.createElement('div');
|
60
|
+
Helpers.addClass(container, 'uniformModal-container');
|
61
|
+
container.innerHTML = content.innerHTML ? content.innerHTML : content;
|
62
|
+
|
63
|
+
var closeButton = document.createElement('div');
|
64
|
+
Helpers.addClass(closeButton, 'uniformModal-close');
|
65
|
+
container.appendChild(closeButton);
|
66
|
+
|
67
|
+
this.el.style.top = window.scrollY;
|
68
|
+
this.overlay.addEventListener('click', this.close.bind(this));
|
69
|
+
this.el.appendChild(container);
|
70
|
+
|
71
|
+
if (this.options.klass) Helpers.addClass(container, this.options.klass);
|
72
|
+
if (content.innerHTML) Helpers.trigger(content, 'rendered');
|
73
|
+
this.trigger('rendered');
|
74
|
+
|
75
|
+
return this;
|
76
|
+
}
|
77
|
+
|
78
|
+
checkCloseButton (e) {
|
79
|
+
if(Helpers.hasClass(e.target, 'uniformModal-close'))
|
80
|
+
this.close();
|
81
|
+
}
|
82
|
+
|
83
|
+
close () {
|
84
|
+
Helpers.removeClass(document.querySelectorAll('uniformModal-active'), 'uniformModal-active');
|
85
|
+
var elements = this.blur.children;
|
86
|
+
var elementCount = elements.length
|
87
|
+
for(var i=0; i < elementCount; i++){
|
88
|
+
document.body.appendChild(elements[0]);
|
89
|
+
}
|
90
|
+
this.blur.parentNode.removeChild(this.blur);
|
91
|
+
window.scrollTo(0, this.original_scroll);
|
92
|
+
this.trigger('closed');
|
93
|
+
this.remove();
|
94
|
+
}
|
95
|
+
|
96
|
+
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));
|
102
|
+
}
|
103
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import Component from './component';
|
2
|
+
import * as Helpers from './dom-helpers';
|
3
|
+
|
4
|
+
export default class Resizer extends Component {
|
5
|
+
|
6
|
+
initialize () {
|
7
|
+
window.addEventListener('resize', this.resize.bind(this));
|
8
|
+
Helpers.trigger(window, 'resize');
|
9
|
+
}
|
10
|
+
|
11
|
+
resize () {
|
12
|
+
// breakpoints at 720, 1080, 1440
|
13
|
+
var width = this.el.offsetWidth;
|
14
|
+
|
15
|
+
if(width > 720 && !Helpers.hasClass(this.el, 'md-size')) {
|
16
|
+
Helpers.addClass(this.el, 'md-size');
|
17
|
+
Helpers.trigger(window, 'resized-md');
|
18
|
+
} else if (width < 720 && Helpers.hasClass(this.el, 'md-size')) {
|
19
|
+
Helpers.removeClass(this.el, 'md-size');
|
20
|
+
}
|
21
|
+
|
22
|
+
if(width > 1080 && !this.el.hasClass('lg-size')) {
|
23
|
+
Helpers.addClass(this.el, 'lg-size');
|
24
|
+
Helpers.trigger(window, 'resized-lg');
|
25
|
+
} else if (width < 1080 && Helpers.hasClass(this.el, 'lg-size')) {
|
26
|
+
Helpers.removeClass(this.el, 'lg-size');
|
27
|
+
}
|
28
|
+
|
29
|
+
if(width > 1440 && !Helpers.hasClass(this.el, 'xl-size')) {
|
30
|
+
Helpers.addClass(this.el, 'xl-size');
|
31
|
+
Helpers.trigger(window, 'resized-xl');
|
32
|
+
} else if (width < 1440 && Helpers.hasClass(this.el, 'xl-size')) {
|
33
|
+
Helpers.removeClass(this.el, 'xl-size');
|
34
|
+
}
|
35
|
+
|
36
|
+
if(width < 720 && !Helpers.hasClass(this.el, 'sm-size')) {
|
37
|
+
Helpers.addClass(this.el, 'sm-size');
|
38
|
+
Helpers.trigger(window, 'resized-sm');
|
39
|
+
} else if (width > 720 && Helpers.hasClass(this.el, 'sm-size')) {
|
40
|
+
Helpers.removeClass(this.el, 'sm-size');
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|