binda 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +83 -25
- data/app/assets/javascripts/binda/application.js +3 -3
- data/app/assets/javascripts/binda/components/bootstrap.js +3 -4
- data/app/assets/javascripts/binda/components/field_group_editor.js +10 -10
- data/app/assets/javascripts/binda/components/field_setting_choices.js +61 -49
- data/app/assets/javascripts/binda/components/fileupload.js +135 -118
- data/app/assets/javascripts/binda/components/form_item.js +65 -65
- data/app/assets/javascripts/binda/components/form_item_editor.js +19 -19
- data/app/assets/javascripts/binda/components/form_item_image.js +11 -13
- data/app/assets/javascripts/binda/components/form_item_repeater.js +77 -71
- data/app/assets/javascripts/binda/components/login-shader.js +171 -164
- data/app/assets/javascripts/binda/components/login_form.js +65 -73
- data/app/assets/javascripts/binda/components/radio-toggle.js +8 -12
- data/app/assets/javascripts/binda/components/select2.js +19 -14
- data/app/assets/javascripts/binda/components/sortable.js +76 -71
- data/app/assets/javascripts/binda/dist/binda.bundle.js +735 -727
- data/app/assets/javascripts/binda/index.js +49 -35
- data/app/assets/stylesheets/binda/components/assets_manager.scss +13 -22
- data/app/assets/stylesheets/binda/components/b-alert.scss +18 -14
- data/app/assets/stylesheets/binda/components/b-btn.scss +24 -43
- data/app/assets/stylesheets/binda/components/field_setting_choices.scss +16 -31
- data/app/assets/stylesheets/binda/components/fileupload.scss +25 -42
- data/app/assets/stylesheets/binda/components/form_item.scss +51 -93
- data/app/assets/stylesheets/binda/components/form_item_choices.scss +7 -10
- data/app/assets/stylesheets/binda/components/login.scss +2 -2
- data/app/assets/stylesheets/binda/components/main_header.scss +5 -10
- data/app/assets/stylesheets/binda/components/main_sidebar.scss +42 -46
- data/app/assets/stylesheets/binda/components/main_sortable_table.scss +12 -21
- data/app/assets/stylesheets/binda/components/main_table.scss +18 -35
- data/app/assets/stylesheets/binda/components/popup_warning.scss +14 -27
- data/app/assets/stylesheets/binda/components/select2.scss +46 -48
- data/app/assets/stylesheets/binda/components/sortable.scss +25 -45
- data/app/assets/stylesheets/binda/components/standard-form.scss +43 -73
- data/app/assets/stylesheets/binda/controllers/users_sessions_new.scss +52 -89
- data/app/assets/stylesheets/binda/index.scss +0 -1
- data/app/assets/stylesheets/binda/settings/buttons.scss +9 -10
- data/app/assets/stylesheets/binda/settings/common.scss +17 -22
- data/app/assets/stylesheets/binda/settings/fonts.scss +112 -67
- data/app/assets/stylesheets/binda/settings/tiny_mce_overrides.scss +20 -36
- data/app/assets/stylesheets/binda/settings/variables.scss +38 -43
- data/app/controllers/binda/choices_controller.rb +14 -11
- data/app/controllers/binda/components_controller.rb +6 -4
- data/app/controllers/binda/structures_controller.rb +7 -3
- data/app/helpers/binda/components_helper.rb +69 -3
- data/app/helpers/binda/field_groups_helper.rb +16 -6
- data/app/helpers/binda/structures_helper.rb +1 -4
- data/app/models/binda/application_record.rb +4 -1
- data/app/models/binda/asset.rb +3 -1
- data/app/models/binda/b.rb +1 -0
- data/app/models/binda/category.rb +1 -0
- data/app/models/binda/checkbox.rb +2 -0
- data/app/models/binda/choice.rb +74 -41
- data/app/models/binda/component.rb +1 -1
- data/app/models/binda/date.rb +4 -0
- data/app/models/binda/deprecation.rb +7 -0
- data/app/models/binda/field_group.rb +16 -3
- data/app/models/binda/field_setting.rb +168 -41
- data/app/models/binda/image.rb +1 -0
- data/app/models/binda/radio.rb +2 -0
- data/app/models/binda/relation.rb +3 -0
- data/app/models/binda/repeater.rb +3 -0
- data/app/models/binda/selection.rb +237 -0
- data/app/models/binda/string.rb +4 -0
- data/app/models/binda/structure.rb +25 -14
- data/app/models/binda/text.rb +9 -0
- data/app/models/binda/video.rb +1 -0
- data/app/models/concerns/binda/default_helpers.rb +40 -31
- data/app/models/concerns/binda/deprecations.rb +6 -0
- data/app/models/concerns/binda/fieldable_association_helpers.rb +366 -0
- data/app/models/concerns/binda/fieldable_associations.rb +32 -369
- data/app/views/binda/boards/edit.html.erb +15 -2
- data/app/views/binda/categories/_form.html.erb +24 -51
- data/app/views/binda/categories/edit.html.erb +23 -3
- data/app/views/binda/categories/index.html.erb +49 -25
- data/app/views/binda/categories/new.html.erb +21 -2
- data/app/views/binda/components/edit.html.erb +27 -4
- data/app/views/binda/components/index.html.erb +47 -50
- data/app/views/binda/components/new.html.erb +12 -2
- data/app/views/binda/components/sort_index.html.erb +28 -13
- data/app/views/binda/field_groups/_form_body.html.erb +43 -82
- data/app/views/binda/field_groups/_form_item.html.erb +3 -120
- data/app/views/binda/field_groups/_form_section.html.erb +11 -16
- data/app/views/binda/field_groups/_form_section_repeater.html.erb +7 -15
- data/app/views/binda/field_groups/edit.html.erb +14 -2
- data/app/views/binda/field_groups/form_item/_form_item_choice_editor.html.erb +11 -0
- data/app/views/binda/field_groups/form_item/_form_item_editor.html.erb +14 -0
- data/app/views/binda/field_groups/form_item/_form_item_header.html.erb +25 -0
- data/app/views/binda/field_groups/form_item/_form_item_new_editor.html.erb +8 -0
- data/app/views/binda/field_groups/form_item/_form_item_persisted_editor.html.erb +27 -0
- data/app/views/binda/field_groups/form_item/form_item_choice/_form_item_allow_null_choice.html.erb +11 -0
- data/app/views/binda/field_groups/form_item/form_item_choice/_form_item_choice_header.html.erb +11 -0
- data/app/views/binda/field_groups/form_item/form_item_choice/_form_item_default_choice.html.erb +11 -0
- data/app/views/binda/field_groups/form_item/form_item_choice/_form_item_new_choice.html.erb +16 -0
- data/app/views/binda/field_groups/form_item/form_item_choice/_form_item_persisted_choices.html.erb +16 -0
- data/app/views/binda/field_groups/new.html.erb +14 -2
- data/app/views/binda/field_settings/_form_body.html.erb +1 -3
- data/app/views/binda/field_settings/edit.html.erb +1 -1
- data/app/views/binda/field_settings/new.html.erb +1 -1
- data/app/views/binda/fieldable/_form_body.html.erb +24 -72
- data/app/views/binda/fieldable/_form_item_date.html.erb +1 -4
- data/app/views/binda/fieldable/_form_item_image.html.erb +3 -7
- data/app/views/binda/fieldable/_form_item_new_repeater.html.erb +0 -13
- data/app/views/binda/fieldable/_form_item_selections.html.erb +20 -112
- data/app/views/binda/fieldable/form_item_selections/_form_item_checkbox.html.erb +34 -0
- data/app/views/binda/fieldable/form_item_selections/_form_item_radio.html.erb +28 -0
- data/app/views/binda/fieldable/form_item_selections/_form_item_selection.html.erb +30 -0
- data/app/views/binda/manage/users/_form_body.html.erb +1 -31
- data/app/views/binda/manage/users/edit.html.erb +12 -2
- data/app/views/binda/manage/users/index.html.erb +36 -19
- data/app/views/binda/manage/users/new.html.erb +14 -3
- data/app/views/binda/structures/_form_body.html.erb +2 -25
- data/app/views/binda/structures/_form_section.html.erb +43 -65
- data/app/views/binda/structures/_form_sidebar.html.erb +19 -12
- data/app/views/binda/structures/edit.html.erb +20 -3
- data/app/views/binda/structures/index.html.erb +46 -26
- data/app/views/binda/structures/new.html.erb +13 -2
- data/app/views/binda/structures/sort_index.html.erb +37 -17
- data/app/views/binda/users/sessions/new.html.erb +25 -20
- data/app/views/layouts/binda/_form_errors.html.erb +10 -0
- data/app/views/layouts/binda/_sidebar.html.erb +6 -6
- data/app/views/layouts/binda/application.html.erb +1 -1
- data/config/initializers/carrierwave.rb +3 -2
- data/config/locales/en.yml +56 -12
- data/config/tinymce.yml +2 -2
- data/db/migrate/1_create_binda_tables.rb +1 -1
- data/lib/binda/version.rb +1 -1
- data/lib/generators/binda/setup/setup_generator.rb +2 -2
- data/lib/tasks/add_default_choice_to_all_selections_with_no_choices_task.rake +6 -0
- metadata +58 -8
- data/app/assets/stylesheets/binda/components/form_item_image.scss +0 -0
- data/app/views/binda/field_groups/_form_item_choice.erb +0 -104
|
@@ -1,144 +1,148 @@
|
|
|
1
1
|
class Shader {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
resources = PIXI.loader.resources,
|
|
17
|
-
Sprite = PIXI.Sprite
|
|
18
|
-
|
|
19
|
-
// Create a container object called the `stage`
|
|
20
|
-
this.stage = new Container()
|
|
21
|
-
|
|
22
|
-
// Create 'renderer'
|
|
23
|
-
this.renderer = PIXI.autoDetectRenderer( window.innerWidth, window.innerHeight )
|
|
24
|
-
|
|
25
|
-
// //Add the canvas to the HTML document
|
|
26
|
-
|
|
27
|
-
document.getElementById('background-shader').appendChild(this.renderer.view)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
this.renderer.backgroundColor = 0xFF00FF
|
|
31
|
-
|
|
32
|
-
// canvas full window
|
|
33
|
-
this.renderer.view.style.position = "fixed"
|
|
34
|
-
this.renderer.view.style.display = "block"
|
|
35
|
-
|
|
36
|
-
let fragmentShader = document.getElementById("fragmentShader").innerHTML
|
|
37
|
-
|
|
38
|
-
let currentTime = Math.sin( Date.now() ) + 0.5
|
|
39
|
-
|
|
40
|
-
this.uniforms = {
|
|
41
|
-
uTime : { type: '1f', value: 0.0 },
|
|
42
|
-
uCurrentTime : { type: '1f', value: currentTime },
|
|
43
|
-
uMouse : { type: '2f', value: [ window.innerWidth, window.innerHeight ] },
|
|
44
|
-
uWindowSize : { type: '2f', value: [ window.innerWidth, window.innerHeight ] }
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
this.customShader = new PIXI.AbstractFilter(null, fragmentShader, this.uniforms)
|
|
48
|
-
this.drawRectagle()
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
// DRAW RECTANGLE
|
|
53
|
-
drawRectagle() {
|
|
54
|
-
|
|
55
|
-
this.rectangle = new PIXI.Graphics()
|
|
56
|
-
|
|
57
|
-
// Set the default background color wo if browser doesn't support the filter we still see the primary color
|
|
58
|
-
let colorWithHash = '#FF00FF'
|
|
59
|
-
const colorWith0x = '0x' + colorWithHash.slice( 1, 7 )
|
|
60
|
-
this.rectangle.beginFill( colorWith0x )
|
|
61
|
-
|
|
62
|
-
// Create the background rectanlge
|
|
63
|
-
this.rectangle.drawRect( 0, 0, window.innerWidth, window.innerHeight )
|
|
64
|
-
this.rectangle.endFill()
|
|
65
|
-
|
|
66
|
-
// Setup the filter (shader)
|
|
67
|
-
this.rectangle.filters = [ this.customShader ]
|
|
68
|
-
|
|
69
|
-
// Add background to stage
|
|
70
|
-
this.stage.addChild( this.rectangle )
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// START ANIMATION
|
|
75
|
-
start() { animate() }
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
// MOUSE UPDATE
|
|
79
|
-
mouseUpdate( event ) {
|
|
80
|
-
|
|
81
|
-
// If uniforms haven't been set yet don't do anything and exit
|
|
82
|
-
if ( typeof this.uniforms === 'undefined' ) return
|
|
83
|
-
|
|
84
|
-
// udpate mouse coordinates for the shader
|
|
85
|
-
this.customShader.uniforms.uMouse = [ event.pageX, event.pageY ]
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
// RESIZE
|
|
90
|
-
resize() {
|
|
91
|
-
|
|
92
|
-
// let scale = scaleToWindow( this.renderer.view )
|
|
93
|
-
let prevWidth = this.renderer.view.style.width
|
|
94
|
-
let prevHeight = this.renderer.view.style.height
|
|
95
|
-
this.renderer.view.style.width = window.innerWidth + "px"
|
|
96
|
-
this.renderer.view.style.height = window.innerHeight + "px"
|
|
97
|
-
this.customShader.uniforms.uWindowSize = [ window.innerWidth, window.innerHeight ]
|
|
2
|
+
constructor() {
|
|
3
|
+
this.uniforms = {
|
|
4
|
+
uTime: { type: "1f", value: 0.0 },
|
|
5
|
+
uCurrentTime: { type: "1f", value: Math.sin(Date.now()) + 0.5 },
|
|
6
|
+
uMouse: {
|
|
7
|
+
type: "2f",
|
|
8
|
+
value: [window.innerWidth, window.innerHeight]
|
|
9
|
+
},
|
|
10
|
+
uWindowSize: {
|
|
11
|
+
type: "2f",
|
|
12
|
+
value: [window.innerWidth, window.innerHeight]
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
98
16
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
17
|
+
isSet() {
|
|
18
|
+
if ($("#background-shader").length > 0) {
|
|
19
|
+
return true;
|
|
20
|
+
} else {
|
|
21
|
+
return false;
|
|
102
22
|
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// SETUP SHADER
|
|
26
|
+
setup() {
|
|
27
|
+
// Create a container object called the `stage`
|
|
28
|
+
this.stage = new PIXI.Container();
|
|
29
|
+
|
|
30
|
+
// Create 'renderer'
|
|
31
|
+
this.renderer = PIXI.autoDetectRenderer(
|
|
32
|
+
window.innerWidth,
|
|
33
|
+
window.innerHeight
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
// //Add the canvas to the HTML document
|
|
37
|
+
|
|
38
|
+
document
|
|
39
|
+
.getElementById("background-shader")
|
|
40
|
+
.appendChild(this.renderer.view);
|
|
41
|
+
|
|
42
|
+
this.renderer.backgroundColor = 0xff00ff;
|
|
43
|
+
|
|
44
|
+
// canvas full window
|
|
45
|
+
this.renderer.view.style.position = "fixed";
|
|
46
|
+
this.renderer.view.style.display = "block";
|
|
47
|
+
|
|
48
|
+
let fragmentShader = document.getElementById("fragmentShader").innerHTML;
|
|
49
|
+
|
|
50
|
+
this.customShader = new PIXI.AbstractFilter(
|
|
51
|
+
null,
|
|
52
|
+
fragmentShader,
|
|
53
|
+
this.uniforms
|
|
54
|
+
);
|
|
55
|
+
this.drawRectagle();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// DRAW RECTANGLE
|
|
59
|
+
drawRectagle() {
|
|
60
|
+
this.rectangle = new PIXI.Graphics();
|
|
61
|
+
|
|
62
|
+
// Set the default background color wo if browser doesn't support the filter we still see the primary color
|
|
63
|
+
let colorWithHash = "#FF00FF";
|
|
64
|
+
const colorWith0x = "0x" + colorWithHash.slice(1, 7);
|
|
65
|
+
this.rectangle.beginFill(colorWith0x);
|
|
66
|
+
|
|
67
|
+
// Create the background rectanlge
|
|
68
|
+
this.rectangle.drawRect(0, 0, window.innerWidth, window.innerHeight);
|
|
69
|
+
this.rectangle.endFill();
|
|
70
|
+
|
|
71
|
+
// Setup the filter (shader)
|
|
72
|
+
this.rectangle.filters = [this.customShader];
|
|
73
|
+
|
|
74
|
+
// Add background to stage
|
|
75
|
+
this.stage.addChild(this.rectangle);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// START ANIMATION
|
|
79
|
+
start() {
|
|
80
|
+
animate();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// MOUSE UPDATE
|
|
84
|
+
mouseUpdate(event) {
|
|
85
|
+
// If uniforms haven't been set yet don't do anything and exit
|
|
86
|
+
if (typeof this.uniforms === "undefined") return;
|
|
87
|
+
|
|
88
|
+
// udpate mouse coordinates for the shader
|
|
89
|
+
this.customShader.uniforms.uMouse = [event.pageX, event.pageY];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// RESIZE
|
|
93
|
+
resize() {
|
|
94
|
+
// let scale = scaleToWindow( this.renderer.view )
|
|
95
|
+
let prevWidth = this.renderer.view.style.width;
|
|
96
|
+
let prevHeight = this.renderer.view.style.height;
|
|
97
|
+
this.renderer.view.style.width = window.innerWidth + "px";
|
|
98
|
+
this.renderer.view.style.height = window.innerHeight + "px";
|
|
99
|
+
this.customShader.uniforms.uWindowSize = [
|
|
100
|
+
window.innerWidth,
|
|
101
|
+
window.innerHeight
|
|
102
|
+
];
|
|
103
|
+
|
|
104
|
+
// Plese check this out ↴↴↴
|
|
105
|
+
// this.rectangle.scale.x = window.innerWidth / prevWidth
|
|
106
|
+
// this.rectangle.scale.y = window.innerHeight / prevHeight
|
|
107
|
+
}
|
|
103
108
|
}
|
|
104
109
|
|
|
105
|
-
|
|
106
|
-
export let _Shader = new Shader()
|
|
107
|
-
|
|
110
|
+
export let _Shader = new Shader();
|
|
108
111
|
|
|
109
112
|
// ANIMATE
|
|
110
113
|
// -------
|
|
111
114
|
function animate() {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
_Shader.renderer.render( _Shader.stage )
|
|
115
|
+
// start the timer for the next animation loop
|
|
116
|
+
requestAnimationFrame(animate);
|
|
117
|
+
_Shader.customShader.uniforms.uTime += 0.01;
|
|
118
|
+
// this is the main render call that makes pixi draw your container and its children.
|
|
119
|
+
_Shader.renderer.render(_Shader.stage);
|
|
118
120
|
}
|
|
119
121
|
|
|
120
122
|
// CONVERT HEX TO RGB COLORS
|
|
121
123
|
// -------------------------
|
|
122
|
-
function hexToShaderRgb(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
124
|
+
function hexToShaderRgb(hex) {
|
|
125
|
+
// Precision of the float number
|
|
126
|
+
var precision = 100;
|
|
127
|
+
// Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
|
|
128
|
+
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
|
|
129
|
+
hex = hex.replace(shorthandRegex, function(m, r, g, b) {
|
|
130
|
+
return r + r + g + g + b + b;
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
134
|
+
if (result) {
|
|
135
|
+
return {
|
|
136
|
+
// Get a number between 0.00 and 1.00
|
|
137
|
+
r: Math.round(parseInt(result[1], 16) * precision / 255) / precision,
|
|
138
|
+
g: Math.round(parseInt(result[2], 16) * precision / 255) / precision,
|
|
139
|
+
b: Math.round(parseInt(result[3], 16) * precision / 255) / precision
|
|
140
|
+
};
|
|
141
|
+
} else {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
139
144
|
}
|
|
140
145
|
|
|
141
|
-
|
|
142
146
|
// REQUEST ANIMATION POLYFILL
|
|
143
147
|
// --------------------------
|
|
144
148
|
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
|
|
@@ -146,48 +150,51 @@ function hexToShaderRgb( hex ) {
|
|
|
146
150
|
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
|
|
147
151
|
// MIT license
|
|
148
152
|
(function() {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
clearTimeout(id);
|
|
169
|
-
};
|
|
170
|
-
}());
|
|
153
|
+
var lastTime = 0;
|
|
154
|
+
var vendors = ["ms", "moz", "webkit", "o"];
|
|
155
|
+
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
|
156
|
+
window.requestAnimationFrame = window[vendors[x] + "RequestAnimationFrame"];
|
|
157
|
+
window.cancelAnimationFrame =
|
|
158
|
+
window[vendors[x] + "CancelAnimationFrame"] ||
|
|
159
|
+
window[vendors[x] + "CancelRequestAnimationFrame"];
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (!window.requestAnimationFrame)
|
|
163
|
+
window.requestAnimationFrame = function(callback, element) {
|
|
164
|
+
var currTime = new Date().getTime();
|
|
165
|
+
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
|
166
|
+
var id = window.setTimeout(function() {
|
|
167
|
+
callback(currTime + timeToCall);
|
|
168
|
+
}, timeToCall);
|
|
169
|
+
lastTime = currTime + timeToCall;
|
|
170
|
+
return id;
|
|
171
|
+
};
|
|
171
172
|
|
|
173
|
+
if (!window.cancelAnimationFrame)
|
|
174
|
+
window.cancelAnimationFrame = function(id) {
|
|
175
|
+
clearTimeout(id);
|
|
176
|
+
};
|
|
177
|
+
})();
|
|
172
178
|
|
|
173
179
|
// Mozilla MDN optimized resize
|
|
174
180
|
// https://developer.mozilla.org/en-US/docs/Web/Events/resize
|
|
175
181
|
(function() {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
182
|
+
var throttle = function(type, name, obj) {
|
|
183
|
+
obj = obj || window;
|
|
184
|
+
var running = false;
|
|
185
|
+
var func = function() {
|
|
186
|
+
if (running) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
running = true;
|
|
190
|
+
requestAnimationFrame(function() {
|
|
191
|
+
obj.dispatchEvent(new CustomEvent(name));
|
|
192
|
+
running = false;
|
|
193
|
+
});
|
|
188
194
|
};
|
|
195
|
+
obj.addEventListener(type, func);
|
|
196
|
+
};
|
|
189
197
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
})();
|
|
193
|
-
|
|
198
|
+
/* init - you can init any event */
|
|
199
|
+
throttle("resize", "optimizedResize");
|
|
200
|
+
})();
|
|
@@ -1,116 +1,108 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* LOGIN FORM
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* https://tympanus.net/Development/MinimalForm/
|
|
5
5
|
* https://github.com/codrops/MinimalForm/blob/master/js/stepsForm.js
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
class LoginForm {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.current = 0;
|
|
11
|
+
this.isFilled = false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
isSet() {
|
|
15
|
+
if ($(".login--form").length > 0) {
|
|
16
|
+
return true;
|
|
17
|
+
} else {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
9
21
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
isSet()
|
|
17
|
-
{
|
|
18
|
-
if ( $('.login--form').length > 0 ) { return true }
|
|
19
|
-
else { return false }
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
init()
|
|
23
|
-
{
|
|
24
|
-
this.$form = $('.login--form')
|
|
25
|
-
this.$questions = $('ol.login--questions > li')
|
|
26
|
-
this.questionsCount = this.$questions.length
|
|
27
|
-
this.$nextButton = $('button.login--next')
|
|
22
|
+
init() {
|
|
23
|
+
this.$form = $(".login--form");
|
|
24
|
+
this.$questions = $("ol.login--questions > li");
|
|
25
|
+
this.questionsCount = this.$questions.length;
|
|
26
|
+
this.$nextButton = $("button.login--next");
|
|
28
27
|
|
|
29
28
|
// Mark the first question as the current one
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
this.$questions.first().addClass("login--current");
|
|
30
|
+
|
|
32
31
|
//disable form autocomplete
|
|
33
|
-
this.$form.attr(
|
|
34
|
-
this.setEvents()
|
|
32
|
+
this.$form.attr("autocomplete", "off");
|
|
33
|
+
this.setEvents();
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
let self = this
|
|
36
|
+
setEvents() {
|
|
37
|
+
let self = this;
|
|
40
38
|
|
|
41
39
|
// first input
|
|
42
|
-
let firstInput = this.$questions
|
|
40
|
+
let firstInput = this.$questions
|
|
41
|
+
.get(this.current)
|
|
42
|
+
.querySelector("input, textarea, select");
|
|
43
43
|
|
|
44
44
|
// focus
|
|
45
|
-
let onFocusStart = function()
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
45
|
+
let onFocusStart = function() {
|
|
46
|
+
firstInput.removeEventListener("focus", onFocusStart);
|
|
47
|
+
self.$nextButton.addClass("login--show");
|
|
48
|
+
};
|
|
50
49
|
// show the next question control first time the input gets focused
|
|
51
|
-
firstInput.addEventListener(
|
|
50
|
+
firstInput.addEventListener("focus", onFocusStart);
|
|
52
51
|
|
|
53
52
|
// show next question
|
|
54
|
-
this.$nextButton.on(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
} )
|
|
53
|
+
this.$nextButton.on("click", event => {
|
|
54
|
+
event.preventDefault();
|
|
55
|
+
this._nextQuestion();
|
|
56
|
+
});
|
|
59
57
|
|
|
60
58
|
// pressing enter will jump to next question
|
|
61
|
-
this.$form.on(
|
|
62
|
-
|
|
63
|
-
let keyCode = event.keyCode || event.which
|
|
59
|
+
this.$form.on("keydown", event => {
|
|
60
|
+
let keyCode = event.keyCode || event.which;
|
|
64
61
|
// enter
|
|
65
|
-
if(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
this._nextQuestion()
|
|
62
|
+
if (keyCode === 13) {
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
this._nextQuestion();
|
|
69
65
|
}
|
|
70
|
-
})
|
|
71
|
-
|
|
66
|
+
});
|
|
67
|
+
}
|
|
72
68
|
|
|
73
|
-
|
|
74
|
-
{
|
|
69
|
+
_nextQuestion() {
|
|
75
70
|
// check if form is filled
|
|
76
|
-
if(
|
|
71
|
+
if (this.current === this.questionsCount - 1) {
|
|
72
|
+
this.isFilled = true;
|
|
73
|
+
}
|
|
77
74
|
|
|
78
|
-
|
|
79
|
-
let currentQuestion = this.$questions.get(this.current)
|
|
75
|
+
// current question
|
|
76
|
+
let currentQuestion = this.$questions.get(this.current);
|
|
80
77
|
|
|
81
78
|
// increment current question iterator
|
|
82
|
-
++this.current
|
|
79
|
+
++this.current;
|
|
83
80
|
|
|
84
|
-
if(
|
|
85
|
-
{
|
|
81
|
+
if (!this.isFilled) {
|
|
86
82
|
// add class "show-next" to form element (start animations)
|
|
87
|
-
this.$form.addClass(
|
|
83
|
+
this.$form.addClass("login--show-next");
|
|
88
84
|
|
|
89
85
|
// remove class "current" from current question and add it to the next one
|
|
90
86
|
// current question
|
|
91
|
-
var nextQuestion = this.$questions.get(this.current)
|
|
92
|
-
$(currentQuestion).removeClass(
|
|
93
|
-
$(nextQuestion).addClass(
|
|
87
|
+
var nextQuestion = this.$questions.get(this.current);
|
|
88
|
+
$(currentQuestion).removeClass("login--current");
|
|
89
|
+
$(nextQuestion).addClass("login--current");
|
|
94
90
|
}
|
|
95
91
|
|
|
96
92
|
// after animation ends, remove class "show-next" from form element and change current question placeholder
|
|
97
|
-
let self = this
|
|
98
|
-
let onEndTransition = function()
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
{
|
|
102
|
-
self.$form.
|
|
103
|
-
}
|
|
104
|
-
else
|
|
105
|
-
{
|
|
106
|
-
self.$form.removeClass('login--show-next')
|
|
93
|
+
let self = this;
|
|
94
|
+
let onEndTransition = function() {
|
|
95
|
+
if (self.isFilled) {
|
|
96
|
+
self.$form.submit();
|
|
97
|
+
} else {
|
|
98
|
+
self.$form.removeClass("login--show-next");
|
|
107
99
|
// force the focus on the next input
|
|
108
|
-
nextQuestion.querySelector(
|
|
100
|
+
nextQuestion.querySelector("input, textarea, select").focus();
|
|
109
101
|
}
|
|
110
|
-
}
|
|
102
|
+
};
|
|
111
103
|
|
|
112
|
-
setTimeout(
|
|
104
|
+
setTimeout(onEndTransition, 400); // Wait for CSS transition to complete
|
|
113
105
|
}
|
|
114
106
|
}
|
|
115
107
|
|
|
116
|
-
export let _LoginForm = new LoginForm()
|
|
108
|
+
export let _LoginForm = new LoginForm();
|