im_reader 1.0.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.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/Gemfile +9 -0
  4. data/Gemfile.lock +44 -0
  5. data/LICENSE.txt +21 -0
  6. data/README.md +110 -0
  7. data/Rakefile +8 -0
  8. data/app/assets/fonts/im_reader/icons.ttf +0 -0
  9. data/app/assets/fonts/im_reader/icons.woff +0 -0
  10. data/app/assets/fonts/im_reader/icons.woff2 +0 -0
  11. data/app/assets/images/im_reader/logo_colore.svg +26 -0
  12. data/app/assets/javascripts/im_reader/epub.min.js +1 -0
  13. data/app/assets/javascripts/im_reader/jszip.min.js +13 -0
  14. data/app/assets/javascripts/im_reader/reader.js +144 -0
  15. data/app/assets/javascripts/im_reader/semantic/progress.js +793 -0
  16. data/app/assets/javascripts/im_reader/semantic/sidebar.js +1022 -0
  17. data/app/assets/javascripts/im_reader/semantic-ui.js +2 -0
  18. data/app/assets/stylesheets/im_reader/reader.scss +127 -0
  19. data/app/assets/stylesheets/im_reader/semantic/button.scss +3172 -0
  20. data/app/assets/stylesheets/im_reader/semantic/colors.scss +15 -0
  21. data/app/assets/stylesheets/im_reader/semantic/container.scss +154 -0
  22. data/app/assets/stylesheets/im_reader/semantic/grid.scss +2029 -0
  23. data/app/assets/stylesheets/im_reader/semantic/header.scss +719 -0
  24. data/app/assets/stylesheets/im_reader/semantic/icon.scss +2587 -0
  25. data/app/assets/stylesheets/im_reader/semantic/item.scss +482 -0
  26. data/app/assets/stylesheets/im_reader/semantic/menu.scss +2054 -0
  27. data/app/assets/stylesheets/im_reader/semantic/progress.scss +517 -0
  28. data/app/controllers/im_reader/application_controller.rb +8 -0
  29. data/app/controllers/im_reader/epub_reader_controller.rb +62 -0
  30. data/app/views/im_reader/epub_reader/show.html.erb +38 -0
  31. data/app/views/layouts/im_reader/epub_reader.html.erb +23 -0
  32. data/config/locales/de.yml +10 -0
  33. data/config/locales/en.yml +10 -0
  34. data/config/locales/es.yml +10 -0
  35. data/config/locales/fr.yml +10 -0
  36. data/config/locales/pt.yml +10 -0
  37. data/config/routes.rb +4 -0
  38. data/im_reader.gemspec +33 -0
  39. data/lib/im_reader/engine.rb +32 -0
  40. data/lib/im_reader/version.rb +5 -0
  41. data/lib/im_reader.rb +8 -0
  42. data/sig/im_reader.rbs +4 -0
  43. data/spec/im_reader_spec.rb +11 -0
  44. data/spec/spec_helper.rb +15 -0
  45. metadata +115 -0
@@ -0,0 +1,1022 @@
1
+ /*!
2
+ * # Semantic UI 2.1.4 - Sidebar
3
+ * http://github.com/semantic-org/semantic-ui/
4
+ *
5
+ *
6
+ * Copyright 2015 Contributors
7
+ * Released under the MIT license
8
+ * http://opensource.org/licenses/MIT
9
+ *
10
+ */
11
+
12
+ ;(function ( $, window, document, undefined ) {
13
+
14
+ "use strict";
15
+
16
+ $.fn.sidebar = function(parameters) {
17
+ var
18
+ $allModules = $(this),
19
+ $window = $(window),
20
+ $document = $(document),
21
+ $html = $('html'),
22
+ $head = $('head'),
23
+
24
+ moduleSelector = $allModules.selector || '',
25
+
26
+ time = new Date().getTime(),
27
+ performance = [],
28
+
29
+ query = arguments[0],
30
+ methodInvoked = (typeof query == 'string'),
31
+ queryArguments = [].slice.call(arguments, 1),
32
+
33
+ requestAnimationFrame = window.requestAnimationFrame
34
+ || window.mozRequestAnimationFrame
35
+ || window.webkitRequestAnimationFrame
36
+ || window.msRequestAnimationFrame
37
+ || function(callback) { setTimeout(callback, 0); },
38
+
39
+ returnedValue
40
+ ;
41
+
42
+ $allModules
43
+ .each(function() {
44
+ var
45
+ settings = ( $.isPlainObject(parameters) )
46
+ ? $.extend(true, {}, $.fn.sidebar.settings, parameters)
47
+ : $.extend({}, $.fn.sidebar.settings),
48
+
49
+ selector = settings.selector,
50
+ className = settings.className,
51
+ namespace = settings.namespace,
52
+ regExp = settings.regExp,
53
+ error = settings.error,
54
+
55
+ eventNamespace = '.' + namespace,
56
+ moduleNamespace = 'module-' + namespace,
57
+
58
+ $module = $(this),
59
+ $context = $(settings.context),
60
+
61
+ $sidebars = $module.children(selector.sidebar),
62
+ $fixed = $context.children(selector.fixed),
63
+ $pusher = $context.children(selector.pusher),
64
+ $style,
65
+
66
+ element = this,
67
+ instance = $module.data(moduleNamespace),
68
+
69
+ elementNamespace,
70
+ id,
71
+ currentScroll,
72
+ transitionEvent,
73
+
74
+ module
75
+ ;
76
+
77
+ module = {
78
+
79
+ initialize: function() {
80
+ module.debug('Initializing sidebar', parameters);
81
+
82
+ module.create.id();
83
+
84
+ transitionEvent = module.get.transitionEvent();
85
+
86
+ if(module.is.ios()) {
87
+ module.set.ios();
88
+ }
89
+
90
+ // avoids locking rendering if initialized in onReady
91
+ if(settings.delaySetup) {
92
+ requestAnimationFrame(module.setup.layout);
93
+ }
94
+ else {
95
+ module.setup.layout();
96
+ }
97
+
98
+ requestAnimationFrame(function() {
99
+ module.setup.cache();
100
+ });
101
+
102
+ module.instantiate();
103
+ },
104
+
105
+ instantiate: function() {
106
+ module.verbose('Storing instance of module', module);
107
+ instance = module;
108
+ $module
109
+ .data(moduleNamespace, module)
110
+ ;
111
+ },
112
+
113
+ create: {
114
+ id: function() {
115
+ id = (Math.random().toString(16) + '000000000').substr(2,8);
116
+ elementNamespace = '.' + id;
117
+ module.verbose('Creating unique id for element', id);
118
+ }
119
+ },
120
+
121
+ destroy: function() {
122
+ module.verbose('Destroying previous module for', $module);
123
+ $module
124
+ .off(eventNamespace)
125
+ .removeData(moduleNamespace)
126
+ ;
127
+ if(module.is.ios()) {
128
+ module.remove.ios();
129
+ }
130
+ // bound by uuid
131
+ $context.off(elementNamespace);
132
+ $window.off(elementNamespace);
133
+ $document.off(elementNamespace);
134
+ },
135
+
136
+ event: {
137
+ clickaway: function(event) {
138
+ var
139
+ clickedInPusher = ($pusher.find(event.target).length > 0 || $pusher.is(event.target)),
140
+ clickedContext = ($context.is(event.target))
141
+ ;
142
+ if(clickedInPusher) {
143
+ module.verbose('User clicked on dimmed page');
144
+ module.hide();
145
+ }
146
+ if(clickedContext) {
147
+ module.verbose('User clicked on dimmable context (scaled out page)');
148
+ module.hide();
149
+ }
150
+ },
151
+ touch: function(event) {
152
+ //event.stopPropagation();
153
+ },
154
+ containScroll: function(event) {
155
+ if(element.scrollTop <= 0) {
156
+ element.scrollTop = 1;
157
+ }
158
+ if((element.scrollTop + element.offsetHeight) >= element.scrollHeight) {
159
+ element.scrollTop = element.scrollHeight - element.offsetHeight - 1;
160
+ }
161
+ },
162
+ scroll: function(event) {
163
+ if( $(event.target).closest(selector.sidebar).length === 0 ) {
164
+ event.preventDefault();
165
+ }
166
+ }
167
+ },
168
+
169
+ bind: {
170
+ clickaway: function() {
171
+ module.verbose('Adding clickaway events to context', $context);
172
+ if(settings.closable) {
173
+ $context
174
+ .on('click' + elementNamespace, module.event.clickaway)
175
+ .on('touchend' + elementNamespace, module.event.clickaway)
176
+ ;
177
+ }
178
+ },
179
+ scrollLock: function() {
180
+ if(settings.scrollLock) {
181
+ module.debug('Disabling page scroll');
182
+ $window
183
+ .on('DOMMouseScroll' + elementNamespace, module.event.scroll)
184
+ ;
185
+ }
186
+ module.verbose('Adding events to contain sidebar scroll');
187
+ $document
188
+ .on('touchmove' + elementNamespace, module.event.touch)
189
+ ;
190
+ $module
191
+ .on('scroll' + eventNamespace, module.event.containScroll)
192
+ ;
193
+ }
194
+ },
195
+ unbind: {
196
+ clickaway: function() {
197
+ module.verbose('Removing clickaway events from context', $context);
198
+ $context.off(elementNamespace);
199
+ },
200
+ scrollLock: function() {
201
+ module.verbose('Removing scroll lock from page');
202
+ $document.off(elementNamespace);
203
+ $window.off(elementNamespace);
204
+ $module.off('scroll' + eventNamespace);
205
+ }
206
+ },
207
+
208
+ add: {
209
+ inlineCSS: function() {
210
+ var
211
+ width = module.cache.width || $module.outerWidth(),
212
+ height = module.cache.height || $module.outerHeight(),
213
+ isRTL = module.is.rtl(),
214
+ direction = module.get.direction(),
215
+ distance = {
216
+ left : width,
217
+ right : -width,
218
+ top : height,
219
+ bottom : -height
220
+ },
221
+ style
222
+ ;
223
+
224
+ if(isRTL){
225
+ module.verbose('RTL detected, flipping widths');
226
+ distance.left = -width;
227
+ distance.right = width;
228
+ }
229
+
230
+ style = '<style>';
231
+
232
+ if(direction === 'left' || direction === 'right') {
233
+ module.debug('Adding CSS rules for animation distance', width);
234
+ style += ''
235
+ + ' .ui.visible.' + direction + '.sidebar ~ .fixed,'
236
+ + ' .ui.visible.' + direction + '.sidebar ~ .pusher {'
237
+ + ' -webkit-transform: translate3d('+ distance[direction] + 'px, 0, 0);'
238
+ + ' transform: translate3d('+ distance[direction] + 'px, 0, 0);'
239
+ + ' }'
240
+ ;
241
+ }
242
+ else if(direction === 'top' || direction == 'bottom') {
243
+ style += ''
244
+ + ' .ui.visible.' + direction + '.sidebar ~ .fixed,'
245
+ + ' .ui.visible.' + direction + '.sidebar ~ .pusher {'
246
+ + ' -webkit-transform: translate3d(0, ' + distance[direction] + 'px, 0);'
247
+ + ' transform: translate3d(0, ' + distance[direction] + 'px, 0);'
248
+ + ' }'
249
+ ;
250
+ }
251
+
252
+ /* IE is only browser not to create context with transforms */
253
+ /* https://www.w3.org/Bugs/Public/show_bug.cgi?id=16328 */
254
+ if( module.is.ie() ) {
255
+ if(direction === 'left' || direction === 'right') {
256
+ module.debug('Adding CSS rules for animation distance', width);
257
+ style += ''
258
+ + ' body.pushable > .ui.visible.' + direction + '.sidebar ~ .pusher:after {'
259
+ + ' -webkit-transform: translate3d('+ distance[direction] + 'px, 0, 0);'
260
+ + ' transform: translate3d('+ distance[direction] + 'px, 0, 0);'
261
+ + ' }'
262
+ ;
263
+ }
264
+ else if(direction === 'top' || direction == 'bottom') {
265
+ style += ''
266
+ + ' body.pushable > .ui.visible.' + direction + '.sidebar ~ .pusher:after {'
267
+ + ' -webkit-transform: translate3d(0, ' + distance[direction] + 'px, 0);'
268
+ + ' transform: translate3d(0, ' + distance[direction] + 'px, 0);'
269
+ + ' }'
270
+ ;
271
+ }
272
+ /* opposite sides visible forces content overlay */
273
+ style += ''
274
+ + ' body.pushable > .ui.visible.left.sidebar ~ .ui.visible.right.sidebar ~ .pusher:after,'
275
+ + ' body.pushable > .ui.visible.right.sidebar ~ .ui.visible.left.sidebar ~ .pusher:after {'
276
+ + ' -webkit-transform: translate3d(0px, 0, 0);'
277
+ + ' transform: translate3d(0px, 0, 0);'
278
+ + ' }'
279
+ ;
280
+ }
281
+ style += '</style>';
282
+ $style = $(style)
283
+ .appendTo($head)
284
+ ;
285
+ module.debug('Adding sizing css to head', $style);
286
+ }
287
+ },
288
+
289
+ refresh: function() {
290
+ module.verbose('Refreshing selector cache');
291
+ $context = $(settings.context);
292
+ $sidebars = $context.children(selector.sidebar);
293
+ $pusher = $context.children(selector.pusher);
294
+ $fixed = $context.children(selector.fixed);
295
+ module.clear.cache();
296
+ },
297
+
298
+ refreshSidebars: function() {
299
+ module.verbose('Refreshing other sidebars');
300
+ $sidebars = $context.children(selector.sidebar);
301
+ },
302
+
303
+ repaint: function() {
304
+ module.verbose('Forcing repaint event');
305
+ element.style.display = 'none';
306
+ var ignored = element.offsetHeight;
307
+ element.scrollTop = element.scrollTop;
308
+ element.style.display = '';
309
+ },
310
+
311
+ setup: {
312
+ cache: function() {
313
+ module.cache = {
314
+ width : $module.outerWidth(),
315
+ height : $module.outerHeight(),
316
+ rtl : ($module.css('direction') == 'rtl')
317
+ };
318
+ },
319
+ layout: function() {
320
+ if( $context.children(selector.pusher).length === 0 ) {
321
+ module.debug('Adding wrapper element for sidebar');
322
+ module.error(error.pusher);
323
+ $pusher = $('<div class="pusher" />');
324
+ $context
325
+ .children()
326
+ .not(selector.omitted)
327
+ .not($sidebars)
328
+ .wrapAll($pusher)
329
+ ;
330
+ module.refresh();
331
+ }
332
+ if($module.nextAll(selector.pusher).length === 0 || $module.nextAll(selector.pusher)[0] !== $pusher[0]) {
333
+ module.debug('Moved sidebar to correct parent element');
334
+ module.error(error.movedSidebar, element);
335
+ $module.detach().prependTo($context);
336
+ module.refresh();
337
+ }
338
+ module.clear.cache();
339
+ module.set.pushable();
340
+ module.set.direction();
341
+ }
342
+ },
343
+
344
+ attachEvents: function(selector, event) {
345
+ var
346
+ $toggle = $(selector)
347
+ ;
348
+ event = $.isFunction(module[event])
349
+ ? module[event]
350
+ : module.toggle
351
+ ;
352
+ if($toggle.length > 0) {
353
+ module.debug('Attaching sidebar events to element', selector, event);
354
+ $toggle
355
+ .on('click' + eventNamespace, event)
356
+ ;
357
+ }
358
+ else {
359
+ module.error(error.notFound, selector);
360
+ }
361
+ },
362
+
363
+ show: function(callback) {
364
+ callback = $.isFunction(callback)
365
+ ? callback
366
+ : function(){}
367
+ ;
368
+ if(module.is.hidden()) {
369
+ module.refreshSidebars();
370
+ if(settings.overlay) {
371
+ module.error(error.overlay);
372
+ settings.transition = 'overlay';
373
+ }
374
+ module.refresh();
375
+ if(module.othersActive()) {
376
+ module.debug('Other sidebars currently visible');
377
+ if(settings.exclusive) {
378
+ // if not overlay queue animation after hide
379
+ if(settings.transition != 'overlay') {
380
+ module.hideOthers(module.show);
381
+ return;
382
+ }
383
+ else {
384
+ module.hideOthers();
385
+ }
386
+ }
387
+ else {
388
+ settings.transition = 'overlay';
389
+ }
390
+ }
391
+ module.pushPage(function() {
392
+ callback.call(element);
393
+ settings.onShow.call(element);
394
+ });
395
+ settings.onChange.call(element);
396
+ settings.onVisible.call(element);
397
+ }
398
+ else {
399
+ module.debug('Sidebar is already visible');
400
+ }
401
+ },
402
+
403
+ hide: function(callback) {
404
+ callback = $.isFunction(callback)
405
+ ? callback
406
+ : function(){}
407
+ ;
408
+ if(module.is.visible() || module.is.animating()) {
409
+ module.debug('Hiding sidebar', callback);
410
+ module.refreshSidebars();
411
+ module.pullPage(function() {
412
+ callback.call(element);
413
+ settings.onHidden.call(element);
414
+ });
415
+ settings.onChange.call(element);
416
+ settings.onHide.call(element);
417
+ }
418
+ },
419
+
420
+ othersAnimating: function() {
421
+ return ($sidebars.not($module).filter('.' + className.animating).length > 0);
422
+ },
423
+ othersVisible: function() {
424
+ return ($sidebars.not($module).filter('.' + className.visible).length > 0);
425
+ },
426
+ othersActive: function() {
427
+ return(module.othersVisible() || module.othersAnimating());
428
+ },
429
+
430
+ hideOthers: function(callback) {
431
+ var
432
+ $otherSidebars = $sidebars.not($module).filter('.' + className.visible),
433
+ sidebarCount = $otherSidebars.length,
434
+ callbackCount = 0
435
+ ;
436
+ callback = callback || function(){};
437
+ $otherSidebars
438
+ .sidebar('hide', function() {
439
+ callbackCount++;
440
+ if(callbackCount == sidebarCount) {
441
+ callback();
442
+ }
443
+ })
444
+ ;
445
+ },
446
+
447
+ toggle: function() {
448
+ module.verbose('Determining toggled direction');
449
+ if(module.is.hidden()) {
450
+ module.show();
451
+ }
452
+ else {
453
+ module.hide();
454
+ }
455
+ },
456
+
457
+ pushPage: function(callback) {
458
+ var
459
+ transition = module.get.transition(),
460
+ $transition = (transition === 'overlay' || module.othersActive())
461
+ ? $module
462
+ : $pusher,
463
+ animate,
464
+ dim,
465
+ transitionEnd
466
+ ;
467
+ callback = $.isFunction(callback)
468
+ ? callback
469
+ : function(){}
470
+ ;
471
+ if(settings.transition == 'scale down') {
472
+ module.scrollToTop();
473
+ }
474
+ module.set.transition(transition);
475
+ module.repaint();
476
+ animate = function() {
477
+ module.bind.clickaway();
478
+ module.add.inlineCSS();
479
+ module.set.animating();
480
+ module.set.visible();
481
+ };
482
+ dim = function() {
483
+ module.set.dimmed();
484
+ };
485
+ transitionEnd = function(event) {
486
+ if( event.target == $transition[0] ) {
487
+ $transition.off(transitionEvent + elementNamespace, transitionEnd);
488
+ module.remove.animating();
489
+ module.bind.scrollLock();
490
+ callback.call(element);
491
+ }
492
+ };
493
+ $transition.off(transitionEvent + elementNamespace);
494
+ $transition.on(transitionEvent + elementNamespace, transitionEnd);
495
+ requestAnimationFrame(animate);
496
+ if(settings.dimPage && !module.othersVisible()) {
497
+ requestAnimationFrame(dim);
498
+ }
499
+ },
500
+
501
+ pullPage: function(callback) {
502
+ var
503
+ transition = module.get.transition(),
504
+ $transition = (transition == 'overlay' || module.othersActive())
505
+ ? $module
506
+ : $pusher,
507
+ animate,
508
+ transitionEnd
509
+ ;
510
+ callback = $.isFunction(callback)
511
+ ? callback
512
+ : function(){}
513
+ ;
514
+ module.verbose('Removing context push state', module.get.direction());
515
+
516
+ module.unbind.clickaway();
517
+ module.unbind.scrollLock();
518
+
519
+ animate = function() {
520
+ module.set.transition(transition);
521
+ module.set.animating();
522
+ module.remove.visible();
523
+ if(settings.dimPage && !module.othersVisible()) {
524
+ $pusher.removeClass(className.dimmed);
525
+ }
526
+ };
527
+ transitionEnd = function(event) {
528
+ if( event.target == $transition[0] ) {
529
+ $transition.off(transitionEvent + elementNamespace, transitionEnd);
530
+ module.remove.animating();
531
+ module.remove.transition();
532
+ module.remove.inlineCSS();
533
+ if(transition == 'scale down' || (settings.returnScroll && module.is.mobile()) ) {
534
+ module.scrollBack();
535
+ }
536
+ callback.call(element);
537
+ }
538
+ };
539
+ $transition.off(transitionEvent + elementNamespace);
540
+ $transition.on(transitionEvent + elementNamespace, transitionEnd);
541
+ requestAnimationFrame(animate);
542
+ },
543
+
544
+ scrollToTop: function() {
545
+ module.verbose('Scrolling to top of page to avoid animation issues');
546
+ currentScroll = $(window).scrollTop();
547
+ $module.scrollTop(0);
548
+ window.scrollTo(0, 0);
549
+ },
550
+
551
+ scrollBack: function() {
552
+ module.verbose('Scrolling back to original page position');
553
+ window.scrollTo(0, currentScroll);
554
+ },
555
+
556
+ clear: {
557
+ cache: function() {
558
+ module.verbose('Clearing cached dimensions');
559
+ module.cache = {};
560
+ }
561
+ },
562
+
563
+ set: {
564
+
565
+ // ios only (scroll on html not document). This prevent auto-resize canvas/scroll in ios
566
+ ios: function() {
567
+ $html.addClass(className.ios);
568
+ },
569
+
570
+ // container
571
+ pushed: function() {
572
+ $context.addClass(className.pushed);
573
+ },
574
+ pushable: function() {
575
+ $context.addClass(className.pushable);
576
+ },
577
+
578
+ // pusher
579
+ dimmed: function() {
580
+ $pusher.addClass(className.dimmed);
581
+ },
582
+
583
+ // sidebar
584
+ active: function() {
585
+ $module.addClass(className.active);
586
+ },
587
+ animating: function() {
588
+ $module.addClass(className.animating);
589
+ },
590
+ transition: function(transition) {
591
+ transition = transition || module.get.transition();
592
+ $module.addClass(transition);
593
+ },
594
+ direction: function(direction) {
595
+ direction = direction || module.get.direction();
596
+ $module.addClass(className[direction]);
597
+ },
598
+ visible: function() {
599
+ $module.addClass(className.visible);
600
+ },
601
+ overlay: function() {
602
+ $module.addClass(className.overlay);
603
+ }
604
+ },
605
+ remove: {
606
+
607
+ inlineCSS: function() {
608
+ module.debug('Removing inline css styles', $style);
609
+ if($style && $style.length > 0) {
610
+ $style.remove();
611
+ }
612
+ },
613
+
614
+ // ios scroll on html not document
615
+ ios: function() {
616
+ $html.removeClass(className.ios);
617
+ },
618
+
619
+ // context
620
+ pushed: function() {
621
+ $context.removeClass(className.pushed);
622
+ },
623
+ pushable: function() {
624
+ $context.removeClass(className.pushable);
625
+ },
626
+
627
+ // sidebar
628
+ active: function() {
629
+ $module.removeClass(className.active);
630
+ },
631
+ animating: function() {
632
+ $module.removeClass(className.animating);
633
+ },
634
+ transition: function(transition) {
635
+ transition = transition || module.get.transition();
636
+ $module.removeClass(transition);
637
+ },
638
+ direction: function(direction) {
639
+ direction = direction || module.get.direction();
640
+ $module.removeClass(className[direction]);
641
+ },
642
+ visible: function() {
643
+ $module.removeClass(className.visible);
644
+ },
645
+ overlay: function() {
646
+ $module.removeClass(className.overlay);
647
+ }
648
+ },
649
+
650
+ get: {
651
+ direction: function() {
652
+ if($module.hasClass(className.top)) {
653
+ return className.top;
654
+ }
655
+ else if($module.hasClass(className.right)) {
656
+ return className.right;
657
+ }
658
+ else if($module.hasClass(className.bottom)) {
659
+ return className.bottom;
660
+ }
661
+ return className.left;
662
+ },
663
+ transition: function() {
664
+ var
665
+ direction = module.get.direction(),
666
+ transition
667
+ ;
668
+ transition = ( module.is.mobile() )
669
+ ? (settings.mobileTransition == 'auto')
670
+ ? settings.defaultTransition.mobile[direction]
671
+ : settings.mobileTransition
672
+ : (settings.transition == 'auto')
673
+ ? settings.defaultTransition.computer[direction]
674
+ : settings.transition
675
+ ;
676
+ module.verbose('Determined transition', transition);
677
+ return transition;
678
+ },
679
+ transitionEvent: function() {
680
+ var
681
+ element = document.createElement('element'),
682
+ transitions = {
683
+ 'transition' :'transitionend',
684
+ 'OTransition' :'oTransitionEnd',
685
+ 'MozTransition' :'transitionend',
686
+ 'WebkitTransition' :'webkitTransitionEnd'
687
+ },
688
+ transition
689
+ ;
690
+ for(transition in transitions){
691
+ if( element.style[transition] !== undefined ){
692
+ return transitions[transition];
693
+ }
694
+ }
695
+ }
696
+ },
697
+
698
+ is: {
699
+
700
+ ie: function() {
701
+ var
702
+ isIE11 = (!(window.ActiveXObject) && 'ActiveXObject' in window),
703
+ isIE = ('ActiveXObject' in window)
704
+ ;
705
+ return (isIE11 || isIE);
706
+ },
707
+
708
+ ios: function() {
709
+ var
710
+ userAgent = navigator.userAgent,
711
+ isIOS = userAgent.match(regExp.ios),
712
+ isMobileChrome = userAgent.match(regExp.mobileChrome)
713
+ ;
714
+ if(isIOS && !isMobileChrome) {
715
+ module.verbose('Browser was found to be iOS', userAgent);
716
+ return true;
717
+ }
718
+ else {
719
+ return false;
720
+ }
721
+ },
722
+ mobile: function() {
723
+ var
724
+ userAgent = navigator.userAgent,
725
+ isMobile = userAgent.match(regExp.mobile)
726
+ ;
727
+ if(isMobile) {
728
+ module.verbose('Browser was found to be mobile', userAgent);
729
+ return true;
730
+ }
731
+ else {
732
+ module.verbose('Browser is not mobile, using regular transition', userAgent);
733
+ return false;
734
+ }
735
+ },
736
+ hidden: function() {
737
+ return !module.is.visible();
738
+ },
739
+ visible: function() {
740
+ return $module.hasClass(className.visible);
741
+ },
742
+ // alias
743
+ open: function() {
744
+ return module.is.visible();
745
+ },
746
+ closed: function() {
747
+ return module.is.hidden();
748
+ },
749
+ vertical: function() {
750
+ return $module.hasClass(className.top);
751
+ },
752
+ animating: function() {
753
+ return $context.hasClass(className.animating);
754
+ },
755
+ rtl: function () {
756
+ if(module.cache.rtl === undefined) {
757
+ module.cache.rtl = ($module.css('direction') == 'rtl');
758
+ }
759
+ return module.cache.rtl;
760
+ }
761
+ },
762
+
763
+ setting: function(name, value) {
764
+ module.debug('Changing setting', name, value);
765
+ if( $.isPlainObject(name) ) {
766
+ $.extend(true, settings, name);
767
+ }
768
+ else if(value !== undefined) {
769
+ settings[name] = value;
770
+ }
771
+ else {
772
+ return settings[name];
773
+ }
774
+ },
775
+ internal: function(name, value) {
776
+ if( $.isPlainObject(name) ) {
777
+ $.extend(true, module, name);
778
+ }
779
+ else if(value !== undefined) {
780
+ module[name] = value;
781
+ }
782
+ else {
783
+ return module[name];
784
+ }
785
+ },
786
+ debug: function() {
787
+ if(settings.debug) {
788
+ if(settings.performance) {
789
+ module.performance.log(arguments);
790
+ }
791
+ else {
792
+ module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
793
+ module.debug.apply(console, arguments);
794
+ }
795
+ }
796
+ },
797
+ verbose: function() {
798
+ if(settings.verbose && settings.debug) {
799
+ if(settings.performance) {
800
+ module.performance.log(arguments);
801
+ }
802
+ else {
803
+ module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
804
+ module.verbose.apply(console, arguments);
805
+ }
806
+ }
807
+ },
808
+ error: function() {
809
+ module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
810
+ module.error.apply(console, arguments);
811
+ },
812
+ performance: {
813
+ log: function(message) {
814
+ var
815
+ currentTime,
816
+ executionTime,
817
+ previousTime
818
+ ;
819
+ if(settings.performance) {
820
+ currentTime = new Date().getTime();
821
+ previousTime = time || currentTime;
822
+ executionTime = currentTime - previousTime;
823
+ time = currentTime;
824
+ performance.push({
825
+ 'Name' : message[0],
826
+ 'Arguments' : [].slice.call(message, 1) || '',
827
+ 'Element' : element,
828
+ 'Execution Time' : executionTime
829
+ });
830
+ }
831
+ clearTimeout(module.performance.timer);
832
+ module.performance.timer = setTimeout(module.performance.display, 500);
833
+ },
834
+ display: function() {
835
+ var
836
+ title = settings.name + ':',
837
+ totalTime = 0
838
+ ;
839
+ time = false;
840
+ clearTimeout(module.performance.timer);
841
+ $.each(performance, function(index, data) {
842
+ totalTime += data['Execution Time'];
843
+ });
844
+ title += ' ' + totalTime + 'ms';
845
+ if(moduleSelector) {
846
+ title += ' \'' + moduleSelector + '\'';
847
+ }
848
+ if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
849
+ console.groupCollapsed(title);
850
+ if(console.table) {
851
+ console.table(performance);
852
+ }
853
+ else {
854
+ $.each(performance, function(index, data) {
855
+ console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
856
+ });
857
+ }
858
+ console.groupEnd();
859
+ }
860
+ performance = [];
861
+ }
862
+ },
863
+ invoke: function(query, passedArguments, context) {
864
+ var
865
+ object = instance,
866
+ maxDepth,
867
+ found,
868
+ response
869
+ ;
870
+ passedArguments = passedArguments || queryArguments;
871
+ context = element || context;
872
+ if(typeof query == 'string' && object !== undefined) {
873
+ query = query.split(/[\. ]/);
874
+ maxDepth = query.length - 1;
875
+ $.each(query, function(depth, value) {
876
+ var camelCaseValue = (depth != maxDepth)
877
+ ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
878
+ : query
879
+ ;
880
+ if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
881
+ object = object[camelCaseValue];
882
+ }
883
+ else if( object[camelCaseValue] !== undefined ) {
884
+ found = object[camelCaseValue];
885
+ return false;
886
+ }
887
+ else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
888
+ object = object[value];
889
+ }
890
+ else if( object[value] !== undefined ) {
891
+ found = object[value];
892
+ return false;
893
+ }
894
+ else {
895
+ module.error(error.method, query);
896
+ return false;
897
+ }
898
+ });
899
+ }
900
+ if ( $.isFunction( found ) ) {
901
+ response = found.apply(context, passedArguments);
902
+ }
903
+ else if(found !== undefined) {
904
+ response = found;
905
+ }
906
+ if($.isArray(returnedValue)) {
907
+ returnedValue.push(response);
908
+ }
909
+ else if(returnedValue !== undefined) {
910
+ returnedValue = [returnedValue, response];
911
+ }
912
+ else if(response !== undefined) {
913
+ returnedValue = response;
914
+ }
915
+ return found;
916
+ }
917
+ }
918
+ ;
919
+
920
+ if(methodInvoked) {
921
+ if(instance === undefined) {
922
+ module.initialize();
923
+ }
924
+ module.invoke(query);
925
+ }
926
+ else {
927
+ if(instance !== undefined) {
928
+ module.invoke('destroy');
929
+ }
930
+ module.initialize();
931
+ }
932
+ });
933
+
934
+ return (returnedValue !== undefined)
935
+ ? returnedValue
936
+ : this
937
+ ;
938
+ };
939
+
940
+ $.fn.sidebar.settings = {
941
+
942
+ name : 'Sidebar',
943
+ namespace : 'sidebar',
944
+
945
+ debug : false,
946
+ verbose : false,
947
+ performance : true,
948
+
949
+ transition : 'auto',
950
+ mobileTransition : 'auto',
951
+
952
+ defaultTransition : {
953
+ computer: {
954
+ left : 'uncover',
955
+ right : 'uncover',
956
+ top : 'overlay',
957
+ bottom : 'overlay'
958
+ },
959
+ mobile: {
960
+ left : 'uncover',
961
+ right : 'uncover',
962
+ top : 'overlay',
963
+ bottom : 'overlay'
964
+ }
965
+ },
966
+
967
+ context : 'body',
968
+ exclusive : false,
969
+ closable : true,
970
+ dimPage : true,
971
+ scrollLock : false,
972
+ returnScroll : false,
973
+ delaySetup : false,
974
+
975
+ duration : 500,
976
+
977
+ onChange : function(){},
978
+ onShow : function(){},
979
+ onHide : function(){},
980
+
981
+ onHidden : function(){},
982
+ onVisible : function(){},
983
+
984
+ className : {
985
+ active : 'active',
986
+ animating : 'animating',
987
+ dimmed : 'dimmed',
988
+ ios : 'ios',
989
+ pushable : 'pushable',
990
+ pushed : 'pushed',
991
+ right : 'right',
992
+ top : 'top',
993
+ left : 'left',
994
+ bottom : 'bottom',
995
+ visible : 'visible'
996
+ },
997
+
998
+ selector: {
999
+ fixed : '.fixed',
1000
+ omitted : 'script, link, style, .ui.modal, .ui.dimmer, .ui.nag, .ui.fixed',
1001
+ pusher : '.pusher',
1002
+ sidebar : '.ui.sidebar'
1003
+ },
1004
+
1005
+ regExp: {
1006
+ ios : /(iPad|iPhone|iPod)/g,
1007
+ mobileChrome : /(CriOS)/g,
1008
+ mobile : /Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/g
1009
+ },
1010
+
1011
+ error : {
1012
+ method : 'The method you called is not defined.',
1013
+ pusher : 'Had to add pusher element. For optimal performance make sure body content is inside a pusher element',
1014
+ movedSidebar : 'Had to move sidebar. For optimal performance make sure sidebar and pusher are direct children of your body tag',
1015
+ overlay : 'The overlay setting is no longer supported, use animation: overlay',
1016
+ notFound : 'There were no elements that matched the specified selector'
1017
+ }
1018
+
1019
+ };
1020
+
1021
+
1022
+ })( jQuery, window , document );