rails-active-ui 0.1.0
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 +7 -0
- data/Rakefile +6 -0
- data/app/assets/stylesheets.css +73555 -0
- data/app/components/accordion_component.rb +34 -0
- data/app/components/ad_component.rb +28 -0
- data/app/components/api_component.rb +24 -0
- data/app/components/breadcrumb_component.rb +26 -0
- data/app/components/button_component.rb +49 -0
- data/app/components/calendar_component.rb +34 -0
- data/app/components/card_component.rb +56 -0
- data/app/components/checkbox_component.rb +41 -0
- data/app/components/column_component.rb +62 -0
- data/app/components/comment_component.rb +45 -0
- data/app/components/concerns/alignable.rb +21 -0
- data/app/components/concerns/attachable.rb +16 -0
- data/app/components/concerns/orientable.rb +21 -0
- data/app/components/concerns/positionable.rb +21 -0
- data/app/components/concerns/sizeable.rb +18 -0
- data/app/components/container_component.rb +23 -0
- data/app/components/dimmer_component.rb +30 -0
- data/app/components/divider_component.rb +30 -0
- data/app/components/dropdown_component.rb +63 -0
- data/app/components/embed_component.rb +32 -0
- data/app/components/emoji_component.rb +15 -0
- data/app/components/feed_component.rb +22 -0
- data/app/components/flag_component.rb +15 -0
- data/app/components/flyout_component.rb +41 -0
- data/app/components/form_component.rb +39 -0
- data/app/components/grid_component.rb +85 -0
- data/app/components/h_stack_component.rb +67 -0
- data/app/components/header_component.rb +60 -0
- data/app/components/icon_component.rb +41 -0
- data/app/components/image_component.rb +46 -0
- data/app/components/input_component.rb +52 -0
- data/app/components/item_component.rb +39 -0
- data/app/components/item_group_component.rb +30 -0
- data/app/components/label_component.rb +49 -0
- data/app/components/link_component.rb +23 -0
- data/app/components/list_component.rb +39 -0
- data/app/components/loader_component.rb +33 -0
- data/app/components/menu_component.rb +64 -0
- data/app/components/menu_item_component.rb +52 -0
- data/app/components/message_component.rb +54 -0
- data/app/components/modal_component.rb +50 -0
- data/app/components/nag_component.rb +25 -0
- data/app/components/overlay_component.rb +16 -0
- data/app/components/placeholder_component.rb +39 -0
- data/app/components/popup_component.rb +31 -0
- data/app/components/progress_component.rb +48 -0
- data/app/components/pusher_component.rb +18 -0
- data/app/components/rail_component.rb +31 -0
- data/app/components/rating_component.rb +41 -0
- data/app/components/reset_component.rb +12 -0
- data/app/components/reveal_component.rb +39 -0
- data/app/components/row_component.rb +39 -0
- data/app/components/search_component.rb +44 -0
- data/app/components/segment_component.rb +57 -0
- data/app/components/segment_group_component.rb +36 -0
- data/app/components/shape_component.rb +25 -0
- data/app/components/sidebar_component.rb +33 -0
- data/app/components/site_component.rb +12 -0
- data/app/components/slider_component.rb +46 -0
- data/app/components/state_component.rb +25 -0
- data/app/components/statistic_component.rb +43 -0
- data/app/components/step_component.rb +56 -0
- data/app/components/step_group_component.rb +38 -0
- data/app/components/sticky_component.rb +22 -0
- data/app/components/sub_header_component.rb +15 -0
- data/app/components/sub_menu_component.rb +24 -0
- data/app/components/tab_component.rb +24 -0
- data/app/components/table_cell_component.rb +60 -0
- data/app/components/table_component.rb +160 -0
- data/app/components/table_row_component.rb +43 -0
- data/app/components/text_component.rb +73 -0
- data/app/components/toast_component.rb +36 -0
- data/app/components/transition_component.rb +32 -0
- data/app/components/v_stack_component.rb +31 -0
- data/app/components/visibility_component.rb +22 -0
- data/app/helpers/component_helper.rb +109 -0
- data/app/helpers/fui_helper.rb +53 -0
- data/app/javascript/accordion.js +547 -0
- data/app/javascript/accordion.min.js +11 -0
- data/app/javascript/api.js +1112 -0
- data/app/javascript/api.min.js +11 -0
- data/app/javascript/calendar.js +1960 -0
- data/app/javascript/calendar.min.js +11 -0
- data/app/javascript/checkbox.js +819 -0
- data/app/javascript/checkbox.min.js +11 -0
- data/app/javascript/dimmer.js +686 -0
- data/app/javascript/dimmer.min.js +11 -0
- data/app/javascript/dropdown.js +4019 -0
- data/app/javascript/dropdown.min.js +11 -0
- data/app/javascript/embed.js +646 -0
- data/app/javascript/embed.min.js +11 -0
- data/app/javascript/flyout.js +1405 -0
- data/app/javascript/flyout.min.js +11 -0
- data/app/javascript/form.js +2070 -0
- data/app/javascript/form.min.js +11 -0
- data/app/javascript/jquery.js +10716 -0
- data/app/javascript/jquery.min.js +2 -0
- data/app/javascript/modal.js +1507 -0
- data/app/javascript/modal.min.js +11 -0
- data/app/javascript/nag.js +522 -0
- data/app/javascript/nag.min.js +11 -0
- data/app/javascript/popup.js +1457 -0
- data/app/javascript/popup.min.js +11 -0
- data/app/javascript/progress.js +922 -0
- data/app/javascript/progress.min.js +11 -0
- data/app/javascript/rating.js +496 -0
- data/app/javascript/rating.min.js +11 -0
- data/app/javascript/search.js +1519 -0
- data/app/javascript/search.min.js +11 -0
- data/app/javascript/shape.js +721 -0
- data/app/javascript/shape.min.js +11 -0
- data/app/javascript/sidebar.js +952 -0
- data/app/javascript/sidebar.min.js +11 -0
- data/app/javascript/site.js +415 -0
- data/app/javascript/site.min.js +11 -0
- data/app/javascript/slider.js +1449 -0
- data/app/javascript/slider.min.js +11 -0
- data/app/javascript/state.js +653 -0
- data/app/javascript/state.min.js +11 -0
- data/app/javascript/sticky.js +852 -0
- data/app/javascript/sticky.min.js +11 -0
- data/app/javascript/tab.js +867 -0
- data/app/javascript/tab.min.js +11 -0
- data/app/javascript/toast.js +916 -0
- data/app/javascript/toast.min.js +11 -0
- data/app/javascript/transition.js +955 -0
- data/app/javascript/transition.min.js +11 -0
- data/app/javascript/ui/controllers/fui_accordion_controller.js +45 -0
- data/app/javascript/ui/controllers/fui_api_controller.js +80 -0
- data/app/javascript/ui/controllers/fui_calendar_controller.js +66 -0
- data/app/javascript/ui/controllers/fui_checkbox_controller.js +48 -0
- data/app/javascript/ui/controllers/fui_dimmer_controller.js +45 -0
- data/app/javascript/ui/controllers/fui_dropdown_controller.js +68 -0
- data/app/javascript/ui/controllers/fui_embed_controller.js +49 -0
- data/app/javascript/ui/controllers/fui_flyout_controller.js +49 -0
- data/app/javascript/ui/controllers/fui_form_controller.js +62 -0
- data/app/javascript/ui/controllers/fui_modal_controller.js +61 -0
- data/app/javascript/ui/controllers/fui_nag_controller.js +52 -0
- data/app/javascript/ui/controllers/fui_popup_controller.js +58 -0
- data/app/javascript/ui/controllers/fui_progress_controller.js +60 -0
- data/app/javascript/ui/controllers/fui_rating_controller.js +49 -0
- data/app/javascript/ui/controllers/fui_search_controller.js +76 -0
- data/app/javascript/ui/controllers/fui_shape_controller.js +45 -0
- data/app/javascript/ui/controllers/fui_sidebar_controller.js +48 -0
- data/app/javascript/ui/controllers/fui_site_controller.js +29 -0
- data/app/javascript/ui/controllers/fui_slider_controller.js +53 -0
- data/app/javascript/ui/controllers/fui_state_controller.js +63 -0
- data/app/javascript/ui/controllers/fui_sticky_controller.js +50 -0
- data/app/javascript/ui/controllers/fui_tab_controller.js +57 -0
- data/app/javascript/ui/controllers/fui_toast_controller.js +60 -0
- data/app/javascript/ui/controllers/fui_transition_controller.js +60 -0
- data/app/javascript/ui/controllers/fui_visibility_controller.js +55 -0
- data/app/javascript/ui/index.js +114 -0
- data/app/javascript/visibility.js +1196 -0
- data/app/javascript/visibility.min.js +11 -0
- data/app/lib/component.rb +63 -0
- data/config/importmap.rb +27 -0
- data/config/initializers/ruby_template_handler.rb +31 -0
- data/config/routes.rb +2 -0
- data/lib/tasks/ui_tasks.rake +4 -0
- data/lib/ui/engine.rb +27 -0
- data/lib/ui/version.rb +3 -0
- data/lib/ui.rb +6 -0
- metadata +220 -0
|
@@ -0,0 +1,721 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* # Fomantic-UI 2.9.4 - Shape
|
|
3
|
+
* https://github.com/fomantic/Fomantic-UI/
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* Released under the MIT license
|
|
7
|
+
* https://opensource.org/licenses/MIT
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
(function ($, window, document) {
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
function isFunction(obj) {
|
|
15
|
+
return typeof obj === 'function' && typeof obj.nodeType !== 'number';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
window = window !== undefined && window.Math === Math
|
|
19
|
+
? window
|
|
20
|
+
: globalThis;
|
|
21
|
+
|
|
22
|
+
$.fn.shape = function (...args) {
|
|
23
|
+
const $allModules = $(this);
|
|
24
|
+
|
|
25
|
+
let time = Date.now();
|
|
26
|
+
let performance = [];
|
|
27
|
+
|
|
28
|
+
const parameters = args[0];
|
|
29
|
+
const methodInvoked = typeof parameters === 'string';
|
|
30
|
+
const queryArguments = args.slice(1);
|
|
31
|
+
|
|
32
|
+
let returnedValue;
|
|
33
|
+
|
|
34
|
+
$allModules.each(function () {
|
|
35
|
+
const settings = $.isPlainObject(parameters)
|
|
36
|
+
? $.extend(true, {}, $.fn.shape.settings, parameters)
|
|
37
|
+
: $.extend({}, $.fn.shape.settings);
|
|
38
|
+
|
|
39
|
+
// internal aliases
|
|
40
|
+
const namespace = settings.namespace;
|
|
41
|
+
const selector = settings.selector;
|
|
42
|
+
const error = settings.error;
|
|
43
|
+
const className = settings.className;
|
|
44
|
+
|
|
45
|
+
// define namespaces for modules
|
|
46
|
+
const eventNamespace = '.' + namespace;
|
|
47
|
+
const moduleNamespace = 'module-' + namespace;
|
|
48
|
+
|
|
49
|
+
// selector cache
|
|
50
|
+
let $module = $(this);
|
|
51
|
+
let $sides = $module.find('>' + selector.sides);
|
|
52
|
+
let $side = $sides.find('>' + selector.side);
|
|
53
|
+
|
|
54
|
+
// private variables
|
|
55
|
+
let nextIndex = false;
|
|
56
|
+
let $activeSide;
|
|
57
|
+
let $nextSide;
|
|
58
|
+
|
|
59
|
+
// standard module
|
|
60
|
+
const element = this;
|
|
61
|
+
let instance = $module.data(moduleNamespace);
|
|
62
|
+
|
|
63
|
+
const module = {
|
|
64
|
+
|
|
65
|
+
initialize: function () {
|
|
66
|
+
module.verbose('Initializing module for', element);
|
|
67
|
+
module.set.defaultSide();
|
|
68
|
+
module.instantiate();
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
instantiate: function () {
|
|
72
|
+
module.verbose('Storing instance of module', module);
|
|
73
|
+
instance = module;
|
|
74
|
+
$module
|
|
75
|
+
.data(moduleNamespace, instance);
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
destroy: function () {
|
|
79
|
+
module.verbose('Destroying previous module for', element);
|
|
80
|
+
$module
|
|
81
|
+
.removeData(moduleNamespace)
|
|
82
|
+
.off(eventNamespace);
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
refresh: function () {
|
|
86
|
+
module.verbose('Refreshing selector cache for', element);
|
|
87
|
+
$module = $(element);
|
|
88
|
+
$sides = $(this).find(selector.sides);
|
|
89
|
+
$side = $(this).find(selector.side);
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
repaint: function () {
|
|
93
|
+
module.verbose('Forcing repaint event');
|
|
94
|
+
const shape = $sides[0] || document.createElement('div');
|
|
95
|
+
const fakeAssignment = shape.offsetWidth;
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
animate: function (propertyObject, callback) {
|
|
99
|
+
module.verbose('Animating box with properties', propertyObject);
|
|
100
|
+
callback = callback || function (event) {
|
|
101
|
+
module.verbose('Executing animation callback');
|
|
102
|
+
if (event !== undefined) {
|
|
103
|
+
event.stopPropagation();
|
|
104
|
+
}
|
|
105
|
+
module.reset();
|
|
106
|
+
module.set.active();
|
|
107
|
+
};
|
|
108
|
+
settings.onBeforeChange.call($nextSide[0]);
|
|
109
|
+
module.verbose('Starting CSS animation');
|
|
110
|
+
$module
|
|
111
|
+
.addClass(className.animating);
|
|
112
|
+
$sides
|
|
113
|
+
.css(propertyObject)
|
|
114
|
+
.one('transitionend', callback);
|
|
115
|
+
module.set.duration(settings.duration);
|
|
116
|
+
requestAnimationFrame(function () {
|
|
117
|
+
$module
|
|
118
|
+
.addClass(className.animating);
|
|
119
|
+
$activeSide
|
|
120
|
+
.addClass(className.hidden);
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
queue: function (method) {
|
|
125
|
+
module.debug('Queueing animation of', method);
|
|
126
|
+
$sides
|
|
127
|
+
.one('transitionend', function () {
|
|
128
|
+
module.debug('Executing queued animation');
|
|
129
|
+
setTimeout(function () {
|
|
130
|
+
$module.shape(method);
|
|
131
|
+
}, 0);
|
|
132
|
+
});
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
reset: function () {
|
|
136
|
+
module.verbose('Animating states reset');
|
|
137
|
+
$module
|
|
138
|
+
.removeClass(className.animating)
|
|
139
|
+
.attr('style', '')
|
|
140
|
+
.removeAttr('style');
|
|
141
|
+
// removeAttr style does not consistently work in safari
|
|
142
|
+
$sides
|
|
143
|
+
.attr('style', '')
|
|
144
|
+
.removeAttr('style');
|
|
145
|
+
$side
|
|
146
|
+
.attr('style', '')
|
|
147
|
+
.removeAttr('style')
|
|
148
|
+
.removeClass(className.hidden);
|
|
149
|
+
$nextSide
|
|
150
|
+
.removeClass(className.animating)
|
|
151
|
+
.attr('style', '')
|
|
152
|
+
.removeAttr('style');
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
is: {
|
|
156
|
+
complete: function () {
|
|
157
|
+
return $side.filter('.' + className.active)[0] === $nextSide[0];
|
|
158
|
+
},
|
|
159
|
+
animating: function () {
|
|
160
|
+
return $module.hasClass(className.animating);
|
|
161
|
+
},
|
|
162
|
+
hidden: function () {
|
|
163
|
+
return $module.closest(':hidden').length > 0;
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
|
|
167
|
+
set: {
|
|
168
|
+
|
|
169
|
+
defaultSide: function () {
|
|
170
|
+
$activeSide = $side.filter('.' + className.active);
|
|
171
|
+
$nextSide = $activeSide.next(selector.side).length > 0
|
|
172
|
+
? $activeSide.next(selector.side)
|
|
173
|
+
: $side.first();
|
|
174
|
+
nextIndex = false;
|
|
175
|
+
module.verbose('Active side set to', $activeSide);
|
|
176
|
+
module.verbose('Next side set to', $nextSide);
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
duration: function (duration = settings.duration) {
|
|
180
|
+
duration = typeof duration === 'number'
|
|
181
|
+
? duration + 'ms'
|
|
182
|
+
: duration;
|
|
183
|
+
module.verbose('Setting animation duration', duration);
|
|
184
|
+
if (settings.duration || settings.duration === 0) {
|
|
185
|
+
$sides.add($side)
|
|
186
|
+
.css({
|
|
187
|
+
'transition-duration': duration,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
|
|
192
|
+
currentStageSize: function () {
|
|
193
|
+
const $activeSide = $side.filter('.' + className.active);
|
|
194
|
+
const width = $activeSide.outerWidth(true);
|
|
195
|
+
const height = $activeSide.outerHeight(true);
|
|
196
|
+
$module
|
|
197
|
+
.css({
|
|
198
|
+
width: width,
|
|
199
|
+
height: height,
|
|
200
|
+
});
|
|
201
|
+
},
|
|
202
|
+
|
|
203
|
+
stageSize: function () {
|
|
204
|
+
const $clone = $module.clone().addClass(className.loading);
|
|
205
|
+
const $side = $clone.find('>' + selector.sides + '>' + selector.side);
|
|
206
|
+
const $activeSide = $side.filter('.' + className.active);
|
|
207
|
+
const $nextSide = nextIndex
|
|
208
|
+
? $side.eq(nextIndex)
|
|
209
|
+
: ($activeSide.next(selector.side).length > 0
|
|
210
|
+
? $activeSide.next(selector.side)
|
|
211
|
+
: $side.first());
|
|
212
|
+
const newWidth = settings.width === 'next'
|
|
213
|
+
? $nextSide.outerWidth(true)
|
|
214
|
+
: (settings.width === 'initial'
|
|
215
|
+
? $module.width()
|
|
216
|
+
: settings.width);
|
|
217
|
+
const newHeight = settings.height === 'next'
|
|
218
|
+
? $nextSide.outerHeight(true)
|
|
219
|
+
: (settings.height === 'initial'
|
|
220
|
+
? $module.height()
|
|
221
|
+
: settings.height);
|
|
222
|
+
$activeSide.removeClass(className.active);
|
|
223
|
+
$nextSide.addClass(className.active);
|
|
224
|
+
$clone.insertAfter($module);
|
|
225
|
+
$clone.remove();
|
|
226
|
+
if (settings.width !== 'auto') {
|
|
227
|
+
$module.css('width', newWidth + settings.jitter);
|
|
228
|
+
module.verbose('Specifying width during animation', newWidth);
|
|
229
|
+
}
|
|
230
|
+
if (settings.height !== 'auto') {
|
|
231
|
+
$module.css('height', newHeight + settings.jitter);
|
|
232
|
+
module.verbose('Specifying height during animation', newHeight);
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
|
|
236
|
+
nextSide: function (selector) {
|
|
237
|
+
nextIndex = selector;
|
|
238
|
+
$nextSide = $side.filter(selector);
|
|
239
|
+
nextIndex = $side.index($nextSide);
|
|
240
|
+
if ($nextSide.length === 0) {
|
|
241
|
+
module.set.defaultSide();
|
|
242
|
+
module.error(error.side);
|
|
243
|
+
}
|
|
244
|
+
module.verbose('Next side manually set to', $nextSide);
|
|
245
|
+
},
|
|
246
|
+
|
|
247
|
+
active: function () {
|
|
248
|
+
module.verbose('Setting new side to active', $nextSide);
|
|
249
|
+
$side
|
|
250
|
+
.removeClass(className.active);
|
|
251
|
+
$nextSide
|
|
252
|
+
.addClass(className.active);
|
|
253
|
+
settings.onChange.call($nextSide[0]);
|
|
254
|
+
module.set.defaultSide();
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
|
|
258
|
+
flip: {
|
|
259
|
+
to: function (type, stage) {
|
|
260
|
+
if (module.is.hidden()) {
|
|
261
|
+
module.debug('Module not visible', $nextSide);
|
|
262
|
+
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if (module.is.complete() && !module.is.animating() && !settings.allowRepeats) {
|
|
266
|
+
module.debug('Side already visible', $nextSide);
|
|
267
|
+
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
const transform = module.get.transform[type]();
|
|
271
|
+
if (!module.is.animating()) {
|
|
272
|
+
module.debug('Flipping ' + type, $nextSide);
|
|
273
|
+
module.set.stageSize();
|
|
274
|
+
module.stage[stage]();
|
|
275
|
+
module.animate(transform);
|
|
276
|
+
} else {
|
|
277
|
+
module.queue('flip ' + type);
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
|
|
281
|
+
up: function () {
|
|
282
|
+
module.flip.to('up', 'above');
|
|
283
|
+
},
|
|
284
|
+
|
|
285
|
+
down: function () {
|
|
286
|
+
module.flip.to('down', 'below');
|
|
287
|
+
},
|
|
288
|
+
|
|
289
|
+
left: function () {
|
|
290
|
+
module.flip.to('left', 'left');
|
|
291
|
+
},
|
|
292
|
+
|
|
293
|
+
right: function () {
|
|
294
|
+
module.flip.to('right', 'right');
|
|
295
|
+
},
|
|
296
|
+
|
|
297
|
+
over: function () {
|
|
298
|
+
module.flip.to('over', 'behind');
|
|
299
|
+
},
|
|
300
|
+
|
|
301
|
+
back: function () {
|
|
302
|
+
module.flip.to('back', 'behind');
|
|
303
|
+
},
|
|
304
|
+
|
|
305
|
+
},
|
|
306
|
+
|
|
307
|
+
get: {
|
|
308
|
+
|
|
309
|
+
transform: {
|
|
310
|
+
up: function () {
|
|
311
|
+
const translateZ = $activeSide.outerHeight(true) / 2;
|
|
312
|
+
const translateY = $nextSide.outerHeight(true) - translateZ;
|
|
313
|
+
|
|
314
|
+
return {
|
|
315
|
+
transform: 'translateY(' + translateY + 'px) translateZ(-' + translateZ + 'px) rotateX(-90deg)',
|
|
316
|
+
};
|
|
317
|
+
},
|
|
318
|
+
|
|
319
|
+
down: function () {
|
|
320
|
+
const translate = {
|
|
321
|
+
z: $activeSide.outerHeight(true) / 2,
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
return {
|
|
325
|
+
transform: 'translateY(-' + translate.z + 'px) translateZ(-' + translate.z + 'px) rotateX(90deg)',
|
|
326
|
+
};
|
|
327
|
+
},
|
|
328
|
+
|
|
329
|
+
left: function () {
|
|
330
|
+
const translateZ = $activeSide.outerWidth(true) / 2;
|
|
331
|
+
const translateX = $nextSide.outerWidth(true) - translateZ;
|
|
332
|
+
|
|
333
|
+
return {
|
|
334
|
+
transform: 'translateX(' + translateX + 'px) translateZ(-' + translateZ + 'px) rotateY(90deg)',
|
|
335
|
+
};
|
|
336
|
+
},
|
|
337
|
+
|
|
338
|
+
right: function () {
|
|
339
|
+
const translate = {
|
|
340
|
+
z: $activeSide.outerWidth(true) / 2,
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
return {
|
|
344
|
+
transform: 'translateX(-' + translate.z + 'px) translateZ(-' + translate.z + 'px) rotateY(-90deg)',
|
|
345
|
+
};
|
|
346
|
+
},
|
|
347
|
+
|
|
348
|
+
over: function () {
|
|
349
|
+
const translate = {
|
|
350
|
+
x: -(($activeSide.outerWidth(true) - $nextSide.outerWidth(true)) / 2),
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
return {
|
|
354
|
+
transform: 'translateX(' + translate.x + 'px) rotateY(180deg)',
|
|
355
|
+
};
|
|
356
|
+
},
|
|
357
|
+
|
|
358
|
+
back: function () {
|
|
359
|
+
const translate = {
|
|
360
|
+
x: -(($activeSide.outerWidth(true) - $nextSide.outerWidth(true)) / 2),
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
return {
|
|
364
|
+
transform: 'translateX(' + translate.x + 'px) rotateY(-180deg)',
|
|
365
|
+
};
|
|
366
|
+
},
|
|
367
|
+
},
|
|
368
|
+
|
|
369
|
+
nextSide: function () {
|
|
370
|
+
return $activeSide.next(selector.side).length > 0
|
|
371
|
+
? $activeSide.next(selector.side)
|
|
372
|
+
: $side.first();
|
|
373
|
+
},
|
|
374
|
+
|
|
375
|
+
},
|
|
376
|
+
|
|
377
|
+
stage: {
|
|
378
|
+
|
|
379
|
+
above: function () {
|
|
380
|
+
const box = {
|
|
381
|
+
origin: ($activeSide.outerHeight(true) - $nextSide.outerHeight(true)) / 2,
|
|
382
|
+
depth: {
|
|
383
|
+
active: $nextSide.outerHeight(true) / 2,
|
|
384
|
+
next: $activeSide.outerHeight(true) / 2,
|
|
385
|
+
},
|
|
386
|
+
};
|
|
387
|
+
module.verbose('Setting the initial animation position as above', $nextSide, box);
|
|
388
|
+
$activeSide
|
|
389
|
+
.css({
|
|
390
|
+
transform: 'rotateX(0deg)',
|
|
391
|
+
});
|
|
392
|
+
$nextSide
|
|
393
|
+
.addClass(className.animating)
|
|
394
|
+
.css({
|
|
395
|
+
top: box.origin + 'px',
|
|
396
|
+
transform: 'rotateX(90deg) translateZ(' + box.depth.next + 'px) translateY(-' + box.depth.active + 'px)',
|
|
397
|
+
});
|
|
398
|
+
},
|
|
399
|
+
|
|
400
|
+
below: function () {
|
|
401
|
+
const box = {
|
|
402
|
+
origin: ($activeSide.outerHeight(true) - $nextSide.outerHeight(true)) / 2,
|
|
403
|
+
depth: {
|
|
404
|
+
active: $nextSide.outerHeight(true) / 2,
|
|
405
|
+
next: $activeSide.outerHeight(true) / 2,
|
|
406
|
+
},
|
|
407
|
+
};
|
|
408
|
+
module.verbose('Setting the initial animation position as below', $nextSide, box);
|
|
409
|
+
$activeSide
|
|
410
|
+
.css({
|
|
411
|
+
transform: 'rotateX(0deg)',
|
|
412
|
+
});
|
|
413
|
+
$nextSide
|
|
414
|
+
.addClass(className.animating)
|
|
415
|
+
.css({
|
|
416
|
+
top: box.origin + 'px',
|
|
417
|
+
transform: 'rotateX(-90deg) translateZ(' + box.depth.next + 'px) translateY(' + box.depth.active + 'px)',
|
|
418
|
+
});
|
|
419
|
+
},
|
|
420
|
+
|
|
421
|
+
left: function () {
|
|
422
|
+
const height = {
|
|
423
|
+
active: $activeSide.outerWidth(true),
|
|
424
|
+
next: $nextSide.outerWidth(true),
|
|
425
|
+
};
|
|
426
|
+
const box = {
|
|
427
|
+
origin: (height.active - height.next) / 2,
|
|
428
|
+
depth: {
|
|
429
|
+
active: height.next / 2,
|
|
430
|
+
next: height.active / 2,
|
|
431
|
+
},
|
|
432
|
+
};
|
|
433
|
+
module.verbose('Setting the initial animation position as left', $nextSide, box);
|
|
434
|
+
$activeSide
|
|
435
|
+
.css({
|
|
436
|
+
transform: 'rotateY(0deg)',
|
|
437
|
+
});
|
|
438
|
+
$nextSide
|
|
439
|
+
.addClass(className.animating)
|
|
440
|
+
.css({
|
|
441
|
+
left: box.origin + 'px',
|
|
442
|
+
transform: 'rotateY(-90deg) translateZ(' + box.depth.next + 'px) translateX(-' + box.depth.active + 'px)',
|
|
443
|
+
});
|
|
444
|
+
},
|
|
445
|
+
|
|
446
|
+
right: function () {
|
|
447
|
+
const height = {
|
|
448
|
+
active: $activeSide.outerWidth(true),
|
|
449
|
+
next: $nextSide.outerWidth(true),
|
|
450
|
+
};
|
|
451
|
+
const box = {
|
|
452
|
+
origin: (height.active - height.next) / 2,
|
|
453
|
+
depth: {
|
|
454
|
+
active: height.next / 2,
|
|
455
|
+
next: height.active / 2,
|
|
456
|
+
},
|
|
457
|
+
};
|
|
458
|
+
module.verbose('Setting the initial animation position as right', $nextSide, box);
|
|
459
|
+
$activeSide
|
|
460
|
+
.css({
|
|
461
|
+
transform: 'rotateY(0deg)',
|
|
462
|
+
});
|
|
463
|
+
$nextSide
|
|
464
|
+
.addClass(className.animating)
|
|
465
|
+
.css({
|
|
466
|
+
left: box.origin + 'px',
|
|
467
|
+
transform: 'rotateY(90deg) translateZ(' + box.depth.next + 'px) translateX(' + box.depth.active + 'px)',
|
|
468
|
+
});
|
|
469
|
+
},
|
|
470
|
+
|
|
471
|
+
behind: function () {
|
|
472
|
+
const height = {
|
|
473
|
+
active: $activeSide.outerWidth(true),
|
|
474
|
+
next: $nextSide.outerWidth(true),
|
|
475
|
+
};
|
|
476
|
+
const box = {
|
|
477
|
+
origin: (height.active - height.next) / 2,
|
|
478
|
+
depth: {
|
|
479
|
+
active: height.next / 2,
|
|
480
|
+
next: height.active / 2,
|
|
481
|
+
},
|
|
482
|
+
};
|
|
483
|
+
module.verbose('Setting the initial animation position as behind', $nextSide, box);
|
|
484
|
+
$activeSide
|
|
485
|
+
.css({
|
|
486
|
+
transform: 'rotateY(0deg)',
|
|
487
|
+
});
|
|
488
|
+
$nextSide
|
|
489
|
+
.addClass(className.animating)
|
|
490
|
+
.css({
|
|
491
|
+
left: box.origin + 'px',
|
|
492
|
+
transform: 'rotateY(-180deg)',
|
|
493
|
+
});
|
|
494
|
+
},
|
|
495
|
+
},
|
|
496
|
+
setting: function (name, value) {
|
|
497
|
+
module.debug('Changing setting', name, value);
|
|
498
|
+
if ($.isPlainObject(name)) {
|
|
499
|
+
$.extend(true, settings, name);
|
|
500
|
+
} else if (value !== undefined) {
|
|
501
|
+
if ($.isPlainObject(settings[name])) {
|
|
502
|
+
$.extend(true, settings[name], value);
|
|
503
|
+
} else {
|
|
504
|
+
settings[name] = value;
|
|
505
|
+
}
|
|
506
|
+
} else {
|
|
507
|
+
return settings[name];
|
|
508
|
+
}
|
|
509
|
+
},
|
|
510
|
+
internal: function (name, value) {
|
|
511
|
+
if ($.isPlainObject(name)) {
|
|
512
|
+
$.extend(true, module, name);
|
|
513
|
+
} else if (value !== undefined) {
|
|
514
|
+
module[name] = value;
|
|
515
|
+
} else {
|
|
516
|
+
return module[name];
|
|
517
|
+
}
|
|
518
|
+
},
|
|
519
|
+
debug: function (...args) {
|
|
520
|
+
if (!settings.silent && settings.debug) {
|
|
521
|
+
if (settings.performance) {
|
|
522
|
+
module.performance.log(args);
|
|
523
|
+
} else {
|
|
524
|
+
module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
|
|
525
|
+
module.debug.apply(console, args);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
},
|
|
529
|
+
verbose: function (...args) {
|
|
530
|
+
if (!settings.silent && settings.verbose && settings.debug) {
|
|
531
|
+
if (settings.performance) {
|
|
532
|
+
module.performance.log(args);
|
|
533
|
+
} else {
|
|
534
|
+
module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
|
|
535
|
+
module.verbose.apply(console, args);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
},
|
|
539
|
+
error: function (...args) {
|
|
540
|
+
if (!settings.silent) {
|
|
541
|
+
module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
|
|
542
|
+
module.error.apply(console, args);
|
|
543
|
+
}
|
|
544
|
+
},
|
|
545
|
+
performance: {
|
|
546
|
+
log: function (message) {
|
|
547
|
+
let currentTime;
|
|
548
|
+
let executionTime;
|
|
549
|
+
let previousTime;
|
|
550
|
+
if (settings.performance) {
|
|
551
|
+
currentTime = Date.now();
|
|
552
|
+
previousTime = time || currentTime;
|
|
553
|
+
executionTime = currentTime - previousTime;
|
|
554
|
+
time = currentTime;
|
|
555
|
+
performance.push({
|
|
556
|
+
Name: message[0],
|
|
557
|
+
Arguments: message.slice(1),
|
|
558
|
+
Element: element,
|
|
559
|
+
'Execution Time': executionTime,
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
clearTimeout(module.performance.timer);
|
|
563
|
+
module.performance.timer = setTimeout(function () {
|
|
564
|
+
module.performance.display();
|
|
565
|
+
}, 500);
|
|
566
|
+
},
|
|
567
|
+
display: function () {
|
|
568
|
+
let title = settings.name + ':';
|
|
569
|
+
let totalTime = 0;
|
|
570
|
+
time = false;
|
|
571
|
+
clearTimeout(module.performance.timer);
|
|
572
|
+
$.each(performance, function (index, data) {
|
|
573
|
+
totalTime += data['Execution Time'];
|
|
574
|
+
});
|
|
575
|
+
title += ' ' + totalTime + 'ms';
|
|
576
|
+
if ($allModules.length > 1) {
|
|
577
|
+
title += ' (' + $allModules.length + ')';
|
|
578
|
+
}
|
|
579
|
+
if (performance.length > 0) {
|
|
580
|
+
console.groupCollapsed(title);
|
|
581
|
+
console.table(performance);
|
|
582
|
+
console.groupEnd();
|
|
583
|
+
}
|
|
584
|
+
performance = [];
|
|
585
|
+
},
|
|
586
|
+
},
|
|
587
|
+
invoke: function (query, passedArguments = queryArguments, context = element) {
|
|
588
|
+
let object = instance;
|
|
589
|
+
let maxDepth;
|
|
590
|
+
let found;
|
|
591
|
+
let response;
|
|
592
|
+
if (typeof query === 'string' && object !== undefined) {
|
|
593
|
+
query = query.split(/[ .]/);
|
|
594
|
+
maxDepth = query.length - 1;
|
|
595
|
+
$.each(query, function (depth, value) {
|
|
596
|
+
const camelCaseValue = depth !== maxDepth
|
|
597
|
+
? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
|
|
598
|
+
: query;
|
|
599
|
+
if ($.isPlainObject(object[camelCaseValue]) && (depth !== maxDepth)) {
|
|
600
|
+
object = object[camelCaseValue];
|
|
601
|
+
} else if (object[camelCaseValue] !== undefined) {
|
|
602
|
+
found = object[camelCaseValue];
|
|
603
|
+
|
|
604
|
+
return false;
|
|
605
|
+
} else if ($.isPlainObject(object[value]) && (depth !== maxDepth)) {
|
|
606
|
+
object = object[value];
|
|
607
|
+
} else if (object[value] !== undefined) {
|
|
608
|
+
found = object[value];
|
|
609
|
+
|
|
610
|
+
return false;
|
|
611
|
+
} else {
|
|
612
|
+
module.error(error.method, query);
|
|
613
|
+
|
|
614
|
+
return false;
|
|
615
|
+
}
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
if (isFunction(found)) {
|
|
619
|
+
response = found.apply(context, passedArguments);
|
|
620
|
+
} else if (found !== undefined) {
|
|
621
|
+
response = found;
|
|
622
|
+
}
|
|
623
|
+
if (Array.isArray(returnedValue)) {
|
|
624
|
+
returnedValue.push(response);
|
|
625
|
+
} else if (returnedValue !== undefined) {
|
|
626
|
+
returnedValue = [returnedValue, response];
|
|
627
|
+
} else if (response !== undefined) {
|
|
628
|
+
returnedValue = response;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
return found;
|
|
632
|
+
},
|
|
633
|
+
};
|
|
634
|
+
|
|
635
|
+
if (methodInvoked) {
|
|
636
|
+
if (instance === undefined) {
|
|
637
|
+
module.initialize();
|
|
638
|
+
}
|
|
639
|
+
const $inputs = $module.find('input');
|
|
640
|
+
if ($inputs.length > 0) {
|
|
641
|
+
$inputs.trigger('blur');
|
|
642
|
+
setTimeout(function () {
|
|
643
|
+
module.invoke(parameters);
|
|
644
|
+
}, 150);
|
|
645
|
+
} else {
|
|
646
|
+
module.invoke(parameters);
|
|
647
|
+
}
|
|
648
|
+
} else {
|
|
649
|
+
if (instance !== undefined) {
|
|
650
|
+
instance.invoke('destroy');
|
|
651
|
+
}
|
|
652
|
+
module.initialize();
|
|
653
|
+
}
|
|
654
|
+
});
|
|
655
|
+
|
|
656
|
+
return returnedValue !== undefined
|
|
657
|
+
? returnedValue
|
|
658
|
+
: this;
|
|
659
|
+
};
|
|
660
|
+
|
|
661
|
+
$.fn.shape.settings = {
|
|
662
|
+
|
|
663
|
+
// module info
|
|
664
|
+
name: 'Shape',
|
|
665
|
+
|
|
666
|
+
// hide all debug content
|
|
667
|
+
silent: false,
|
|
668
|
+
|
|
669
|
+
// debug content outputted to console
|
|
670
|
+
debug: false,
|
|
671
|
+
|
|
672
|
+
// verbose debug output
|
|
673
|
+
verbose: false,
|
|
674
|
+
|
|
675
|
+
// fudge factor in pixels when swapping from 2d to 3d (can be useful to correct rounding errors)
|
|
676
|
+
jitter: 0,
|
|
677
|
+
|
|
678
|
+
// performance data output
|
|
679
|
+
performance: true,
|
|
680
|
+
|
|
681
|
+
// event namespace
|
|
682
|
+
namespace: 'shape',
|
|
683
|
+
|
|
684
|
+
// width during animation, can be set to 'auto', initial', 'next' or pixel amount
|
|
685
|
+
width: 'initial',
|
|
686
|
+
|
|
687
|
+
// height during animation, can be set to 'auto', 'initial', 'next' or pixel amount
|
|
688
|
+
height: 'initial',
|
|
689
|
+
|
|
690
|
+
// callback occurs on side change
|
|
691
|
+
onBeforeChange: function () {},
|
|
692
|
+
onChange: function () {},
|
|
693
|
+
|
|
694
|
+
// allow animation to the same side
|
|
695
|
+
allowRepeats: false,
|
|
696
|
+
|
|
697
|
+
// animation duration
|
|
698
|
+
duration: false,
|
|
699
|
+
|
|
700
|
+
// possible errors
|
|
701
|
+
error: {
|
|
702
|
+
side: 'You tried to switch to a side that does not exist.',
|
|
703
|
+
method: 'The method you called is not defined',
|
|
704
|
+
},
|
|
705
|
+
|
|
706
|
+
// classnames used
|
|
707
|
+
className: {
|
|
708
|
+
animating: 'animating',
|
|
709
|
+
hidden: 'hidden',
|
|
710
|
+
loading: 'loading',
|
|
711
|
+
active: 'active',
|
|
712
|
+
},
|
|
713
|
+
|
|
714
|
+
// selectors used
|
|
715
|
+
selector: {
|
|
716
|
+
sides: '.sides',
|
|
717
|
+
side: '.side',
|
|
718
|
+
},
|
|
719
|
+
|
|
720
|
+
};
|
|
721
|
+
})(jQuery, window, document);
|