foundation-rails 5.5.3.2 → 6.1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +2 -8
- data/Rakefile +23 -0
- data/app/views/foundation/rails/styleguide/show.html.erb +2 -5
- data/bower.json +2 -2
- data/lib/foundation/rails/version.rb +1 -1
- data/lib/generators/foundation/install_generator.rb +6 -3
- data/lib/generators/foundation/templates/_settings.scss +546 -0
- data/lib/generators/foundation/templates/application.html.erb +0 -1
- data/lib/generators/foundation/templates/application.html.haml +0 -2
- data/lib/generators/foundation/templates/application.html.slim +0 -2
- data/lib/generators/foundation/templates/foundation_and_overrides.scss +51 -0
- data/vendor/assets/js/foundation.abide.js +418 -0
- data/vendor/assets/js/foundation.accordion.js +229 -0
- data/vendor/assets/js/foundation.accordionMenu.js +262 -0
- data/vendor/assets/js/foundation.core.js +378 -0
- data/vendor/assets/js/foundation.drilldown.js +321 -0
- data/vendor/assets/js/foundation.dropdown.js +390 -0
- data/vendor/assets/js/foundation.dropdownMenu.js +391 -0
- data/vendor/assets/js/foundation.equalizer.js +274 -0
- data/vendor/assets/js/foundation.interchange.js +184 -0
- data/vendor/assets/js/foundation.js +28 -0
- data/vendor/assets/js/foundation.magellan.js +212 -0
- data/vendor/assets/js/foundation.offcanvas.js +371 -0
- data/vendor/assets/js/foundation.orbit.js +419 -0
- data/vendor/assets/js/foundation.responsiveMenu.js +145 -0
- data/vendor/assets/js/foundation.responsiveToggle.js +106 -0
- data/vendor/assets/js/foundation.reveal.js +478 -0
- data/vendor/assets/js/foundation.slider.js +484 -0
- data/vendor/assets/js/foundation.sticky.js +436 -0
- data/vendor/assets/js/foundation.tabs.js +306 -0
- data/vendor/assets/js/foundation.toggler.js +147 -0
- data/vendor/assets/js/foundation.tooltip.js +429 -0
- data/vendor/assets/js/foundation.util.box.js +169 -0
- data/vendor/assets/js/foundation.util.keyboard.js +115 -0
- data/vendor/assets/js/foundation.util.mediaQuery.js +210 -0
- data/vendor/assets/js/foundation.util.motion.js +89 -0
- data/vendor/assets/js/foundation.util.nest.js +64 -0
- data/vendor/assets/js/foundation.util.timerAndImageLoader.js +78 -0
- data/vendor/assets/js/foundation.util.touch.js +339 -0
- data/vendor/assets/js/foundation.util.triggers.js +222 -0
- data/vendor/assets/scss/_global.scss +626 -0
- data/vendor/assets/scss/components/_accordion-menu.scss +32 -0
- data/vendor/assets/scss/components/_accordion.scss +113 -0
- data/vendor/assets/scss/components/_badge.scss +55 -0
- data/vendor/assets/scss/components/_breadcrumbs.scss +94 -0
- data/vendor/assets/scss/components/_button-group.scss +130 -0
- data/vendor/assets/scss/components/_button.scss +265 -0
- data/vendor/assets/scss/components/_callout.scss +105 -0
- data/vendor/assets/scss/components/_close-button.scss +61 -0
- data/vendor/assets/scss/components/_drilldown.scss +75 -0
- data/vendor/assets/scss/components/_dropdown-menu.scss +148 -0
- data/vendor/assets/scss/components/_dropdown.scss +64 -0
- data/vendor/assets/scss/components/_flex-video.scss +63 -0
- data/vendor/assets/scss/components/_float.scss +27 -0
- data/vendor/assets/scss/components/_label.scss +56 -0
- data/vendor/assets/scss/components/_media-object.scss +74 -0
- data/vendor/assets/scss/components/_menu.scss +209 -0
- data/vendor/assets/scss/components/_off-canvas.scss +180 -0
- data/vendor/assets/scss/components/_orbit.scss +193 -0
- data/vendor/assets/scss/components/_pagination.scss +158 -0
- data/vendor/assets/scss/components/_progress-bar.scss +83 -0
- data/vendor/assets/scss/components/_reveal.scss +156 -0
- data/vendor/assets/scss/components/_slider.scss +158 -0
- data/vendor/assets/scss/components/_sticky.scss +38 -0
- data/vendor/assets/scss/components/_switch.scss +232 -0
- data/vendor/assets/scss/components/_table.scss +213 -0
- data/vendor/assets/scss/components/_tabs.scss +170 -0
- data/vendor/assets/scss/components/_thumbnail.scss +54 -0
- data/vendor/assets/scss/components/_title-bar.scss +68 -0
- data/vendor/assets/scss/components/_tooltip.scss +100 -0
- data/vendor/assets/scss/components/_top-bar.scss +89 -0
- data/vendor/assets/scss/components/_visibility.scss +131 -0
- data/vendor/assets/scss/forms/_checkbox.scss +36 -0
- data/vendor/assets/scss/forms/_error.scss +82 -0
- data/vendor/assets/scss/forms/_fieldset.scss +53 -0
- data/vendor/assets/scss/forms/_forms.scss +32 -0
- data/vendor/assets/scss/forms/_help-text.scss +30 -0
- data/vendor/assets/scss/forms/_input-group.scss +91 -0
- data/vendor/assets/scss/forms/_label.scss +48 -0
- data/vendor/assets/scss/forms/_select.scss +63 -0
- data/vendor/assets/scss/forms/_text.scss +154 -0
- data/vendor/assets/scss/foundation.scss +91 -0
- data/vendor/assets/scss/grid/_classes.scss +153 -0
- data/vendor/assets/scss/grid/_column.scss +124 -0
- data/vendor/assets/scss/grid/_flex-grid.scss +281 -0
- data/vendor/assets/scss/grid/_grid.scss +48 -0
- data/vendor/assets/scss/grid/_gutter.scss +34 -0
- data/vendor/assets/scss/grid/_layout.scss +33 -0
- data/vendor/assets/scss/grid/_position.scss +72 -0
- data/vendor/assets/scss/grid/_row.scss +97 -0
- data/vendor/assets/scss/grid/_size.scss +24 -0
- data/vendor/assets/scss/settings/_settings.scss +547 -0
- data/vendor/assets/scss/typography/_alignment.scss +22 -0
- data/vendor/assets/scss/typography/_base.scss +439 -0
- data/vendor/assets/scss/typography/_helpers.scss +77 -0
- data/vendor/assets/scss/typography/_print.scss +73 -0
- data/vendor/assets/scss/typography/_typography.scss +28 -0
- data/vendor/assets/scss/util/_breakpoint.scss +266 -0
- data/vendor/assets/scss/util/_color.scss +41 -0
- data/vendor/assets/scss/util/_mixins.scss +223 -0
- data/vendor/assets/scss/util/_selector.scss +40 -0
- data/vendor/assets/scss/util/_unit.scss +90 -0
- data/vendor/assets/scss/util/_util.scss +15 -0
- data/vendor/assets/scss/util/_value.scss +126 -0
- metadata +97 -64
- data/update-gem.sh +0 -20
- data/vendor/assets/javascripts/foundation.js +0 -17
- data/vendor/assets/javascripts/foundation/foundation.abide.js +0 -426
- data/vendor/assets/javascripts/foundation/foundation.accordion.js +0 -125
- data/vendor/assets/javascripts/foundation/foundation.alert.js +0 -43
- data/vendor/assets/javascripts/foundation/foundation.clearing.js +0 -586
- data/vendor/assets/javascripts/foundation/foundation.dropdown.js +0 -468
- data/vendor/assets/javascripts/foundation/foundation.equalizer.js +0 -104
- data/vendor/assets/javascripts/foundation/foundation.interchange.js +0 -360
- data/vendor/assets/javascripts/foundation/foundation.joyride.js +0 -935
- data/vendor/assets/javascripts/foundation/foundation.js +0 -732
- data/vendor/assets/javascripts/foundation/foundation.magellan.js +0 -214
- data/vendor/assets/javascripts/foundation/foundation.offcanvas.js +0 -225
- data/vendor/assets/javascripts/foundation/foundation.orbit.js +0 -476
- data/vendor/assets/javascripts/foundation/foundation.reveal.js +0 -522
- data/vendor/assets/javascripts/foundation/foundation.slider.js +0 -296
- data/vendor/assets/javascripts/foundation/foundation.tab.js +0 -247
- data/vendor/assets/javascripts/foundation/foundation.tooltip.js +0 -348
- data/vendor/assets/javascripts/foundation/foundation.topbar.js +0 -458
- data/vendor/assets/javascripts/vendor/modernizr.js +0 -1406
- data/vendor/assets/stylesheets/foundation.scss +0 -42
- data/vendor/assets/stylesheets/foundation/_functions.scss +0 -156
- data/vendor/assets/stylesheets/foundation/_settings.scss +0 -1489
- data/vendor/assets/stylesheets/foundation/components/_accordion.scss +0 -161
- data/vendor/assets/stylesheets/foundation/components/_alert-boxes.scss +0 -128
- data/vendor/assets/stylesheets/foundation/components/_block-grid.scss +0 -133
- data/vendor/assets/stylesheets/foundation/components/_breadcrumbs.scss +0 -132
- data/vendor/assets/stylesheets/foundation/components/_button-groups.scss +0 -208
- data/vendor/assets/stylesheets/foundation/components/_buttons.scss +0 -261
- data/vendor/assets/stylesheets/foundation/components/_clearing.scss +0 -260
- data/vendor/assets/stylesheets/foundation/components/_dropdown-buttons.scss +0 -130
- data/vendor/assets/stylesheets/foundation/components/_dropdown.scss +0 -269
- data/vendor/assets/stylesheets/foundation/components/_flex-video.scss +0 -51
- data/vendor/assets/stylesheets/foundation/components/_forms.scss +0 -607
- data/vendor/assets/stylesheets/foundation/components/_global.scss +0 -566
- data/vendor/assets/stylesheets/foundation/components/_grid.scss +0 -292
- data/vendor/assets/stylesheets/foundation/components/_icon-bar.scss +0 -460
- data/vendor/assets/stylesheets/foundation/components/_inline-lists.scss +0 -58
- data/vendor/assets/stylesheets/foundation/components/_joyride.scss +0 -220
- data/vendor/assets/stylesheets/foundation/components/_keystrokes.scss +0 -60
- data/vendor/assets/stylesheets/foundation/components/_labels.scss +0 -106
- data/vendor/assets/stylesheets/foundation/components/_magellan.scss +0 -34
- data/vendor/assets/stylesheets/foundation/components/_offcanvas.scss +0 -606
- data/vendor/assets/stylesheets/foundation/components/_orbit.scss +0 -388
- data/vendor/assets/stylesheets/foundation/components/_pagination.scss +0 -163
- data/vendor/assets/stylesheets/foundation/components/_panels.scss +0 -107
- data/vendor/assets/stylesheets/foundation/components/_pricing-tables.scss +0 -150
- data/vendor/assets/stylesheets/foundation/components/_progress-bars.scss +0 -85
- data/vendor/assets/stylesheets/foundation/components/_range-slider.scss +0 -177
- data/vendor/assets/stylesheets/foundation/components/_reveal.scss +0 -212
- data/vendor/assets/stylesheets/foundation/components/_side-nav.scss +0 -120
- data/vendor/assets/stylesheets/foundation/components/_split-buttons.scss +0 -203
- data/vendor/assets/stylesheets/foundation/components/_sub-nav.scss +0 -125
- data/vendor/assets/stylesheets/foundation/components/_switches.scss +0 -241
- data/vendor/assets/stylesheets/foundation/components/_tables.scss +0 -135
- data/vendor/assets/stylesheets/foundation/components/_tabs.scss +0 -142
- data/vendor/assets/stylesheets/foundation/components/_thumbs.scss +0 -66
- data/vendor/assets/stylesheets/foundation/components/_tooltips.scss +0 -142
- data/vendor/assets/stylesheets/foundation/components/_top-bar.scss +0 -745
- data/vendor/assets/stylesheets/foundation/components/_type.scss +0 -525
- data/vendor/assets/stylesheets/foundation/components/_visibility.scss +0 -425
- data/vendor/assets/stylesheets/normalize.scss +0 -424
@@ -0,0 +1,89 @@
|
|
1
|
+
/**
|
2
|
+
* Motion module.
|
3
|
+
* @module foundation.motion
|
4
|
+
*/
|
5
|
+
!function($, Foundation) {
|
6
|
+
|
7
|
+
var initClasses = ['mui-enter', 'mui-leave'];
|
8
|
+
var activeClasses = ['mui-enter-active', 'mui-leave-active'];
|
9
|
+
|
10
|
+
function animate(isIn, element, animation, cb) {
|
11
|
+
element = $(element).eq(0);
|
12
|
+
|
13
|
+
if (!element.length) return;
|
14
|
+
|
15
|
+
var initClass = isIn ? initClasses[0] : initClasses[1];
|
16
|
+
var activeClass = isIn ? activeClasses[0] : activeClasses[1];
|
17
|
+
|
18
|
+
// Set up the animation
|
19
|
+
reset();
|
20
|
+
element.addClass(animation)
|
21
|
+
.css('transition', 'none');
|
22
|
+
// .addClass(initClass);
|
23
|
+
// if(isIn) element.show();
|
24
|
+
requestAnimationFrame(function() {
|
25
|
+
element.addClass(initClass);
|
26
|
+
if (isIn) element.show();
|
27
|
+
});
|
28
|
+
// Start the animation
|
29
|
+
requestAnimationFrame(function() {
|
30
|
+
element[0].offsetWidth;
|
31
|
+
element.css('transition', '');
|
32
|
+
element.addClass(activeClass);
|
33
|
+
});
|
34
|
+
// Move(500, element, function(){
|
35
|
+
// // element[0].offsetWidth;
|
36
|
+
// element.css('transition', '');
|
37
|
+
// element.addClass(activeClass);
|
38
|
+
// });
|
39
|
+
|
40
|
+
// Clean up the animation when it finishes
|
41
|
+
element.one(Foundation.transitionend(element), finish);//.one('finished.zf.animate', finish);
|
42
|
+
|
43
|
+
// Hides the element (for out animations), resets the element, and runs a callback
|
44
|
+
function finish() {
|
45
|
+
if (!isIn) element.hide();
|
46
|
+
reset();
|
47
|
+
if (cb) cb.apply(element);
|
48
|
+
}
|
49
|
+
|
50
|
+
// Resets transitions and removes motion-specific classes
|
51
|
+
function reset() {
|
52
|
+
element[0].style.transitionDuration = 0;
|
53
|
+
element.removeClass(initClass + ' ' + activeClass + ' ' + animation);
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
var Motion = {
|
58
|
+
animateIn: function(element, animation, /*duration,*/ cb) {
|
59
|
+
animate(true, element, animation, cb);
|
60
|
+
},
|
61
|
+
|
62
|
+
animateOut: function(element, animation, /*duration,*/ cb) {
|
63
|
+
animate(false, element, animation, cb);
|
64
|
+
}
|
65
|
+
};
|
66
|
+
|
67
|
+
var Move = function(duration, elem, fn){
|
68
|
+
var anim, prog, start = null;
|
69
|
+
// console.log('called');
|
70
|
+
|
71
|
+
function move(ts){
|
72
|
+
if(!start) start = window.performance.now();
|
73
|
+
// console.log(start, ts);
|
74
|
+
prog = ts - start;
|
75
|
+
fn.apply(elem);
|
76
|
+
|
77
|
+
if(prog < duration){ anim = window.requestAnimationFrame(move, elem); }
|
78
|
+
else{
|
79
|
+
window.cancelAnimationFrame(anim);
|
80
|
+
elem.trigger('finished.zf.animate', [elem]).triggerHandler('finished.zf.animate', [elem]);
|
81
|
+
}
|
82
|
+
}
|
83
|
+
anim = window.requestAnimationFrame(move);
|
84
|
+
};
|
85
|
+
|
86
|
+
Foundation.Move = Move;
|
87
|
+
Foundation.Motion = Motion;
|
88
|
+
|
89
|
+
}(jQuery, Foundation);
|
@@ -0,0 +1,64 @@
|
|
1
|
+
!function($, Foundation){
|
2
|
+
'use strict';
|
3
|
+
Foundation.Nest = {
|
4
|
+
Feather: function(menu, type){
|
5
|
+
menu.attr('role', 'menubar');
|
6
|
+
type = type || 'zf';
|
7
|
+
var items = menu.find('li').attr({'role': 'menuitem'}),
|
8
|
+
subMenuClass = 'is-' + type + '-submenu',
|
9
|
+
subItemClass = subMenuClass + '-item',
|
10
|
+
hasSubClass = 'is-' + type + '-submenu-parent';
|
11
|
+
menu.find('a:first').attr('tabindex', 0);
|
12
|
+
items.each(function(){
|
13
|
+
var $item = $(this),
|
14
|
+
$sub = $item.children('ul');
|
15
|
+
if($sub.length){
|
16
|
+
$item.addClass('has-submenu ' + hasSubClass)
|
17
|
+
.attr({
|
18
|
+
'aria-haspopup': true,
|
19
|
+
'aria-selected': false,
|
20
|
+
'aria-expanded': false,
|
21
|
+
'aria-label': $item.children('a:first').text()
|
22
|
+
});
|
23
|
+
$sub.addClass('submenu ' + subMenuClass)
|
24
|
+
.attr({
|
25
|
+
'data-submenu': '',
|
26
|
+
'aria-hidden': true,
|
27
|
+
'role': 'menu'
|
28
|
+
});
|
29
|
+
}
|
30
|
+
if($item.parent('[data-submenu]').length){
|
31
|
+
$item.addClass('is-submenu-item ' + subItemClass);
|
32
|
+
}
|
33
|
+
});
|
34
|
+
return;
|
35
|
+
},
|
36
|
+
Burn: function(menu, type){
|
37
|
+
var items = menu.find('li').removeAttr('tabindex'),
|
38
|
+
subMenuClass = 'is-' + type + '-submenu',
|
39
|
+
subItemClass = subMenuClass + '-item',
|
40
|
+
hasSubClass = 'is-' + type + '-submenu-parent';
|
41
|
+
|
42
|
+
// menu.find('.is-active').removeClass('is-active');
|
43
|
+
menu.find('*')
|
44
|
+
// menu.find('.' + subMenuClass + ', .' + subItemClass + ', .is-active, .has-submenu, .is-submenu-item, .submenu, [data-submenu]')
|
45
|
+
.removeClass(subMenuClass + ' ' + subItemClass + ' ' + hasSubClass + ' has-submenu is-submenu-item submenu is-active')
|
46
|
+
.removeAttr('data-submenu').css('display', '');
|
47
|
+
|
48
|
+
// console.log( menu.find('.' + subMenuClass + ', .' + subItemClass + ', .has-submenu, .is-submenu-item, .submenu, [data-submenu]')
|
49
|
+
// .removeClass(subMenuClass + ' ' + subItemClass + ' has-submenu is-submenu-item submenu')
|
50
|
+
// .removeAttr('data-submenu'));
|
51
|
+
// items.each(function(){
|
52
|
+
// var $item = $(this),
|
53
|
+
// $sub = $item.children('ul');
|
54
|
+
// if($item.parent('[data-submenu]').length){
|
55
|
+
// $item.removeClass('is-submenu-item ' + subItemClass);
|
56
|
+
// }
|
57
|
+
// if($sub.length){
|
58
|
+
// $item.removeClass('has-submenu');
|
59
|
+
// $sub.removeClass('submenu ' + subMenuClass).removeAttr('data-submenu');
|
60
|
+
// }
|
61
|
+
// });
|
62
|
+
}
|
63
|
+
};
|
64
|
+
}(jQuery, window.Foundation);
|
@@ -0,0 +1,78 @@
|
|
1
|
+
!function($, Foundation){
|
2
|
+
'use strict';
|
3
|
+
var Timer = function(elem, options, cb){
|
4
|
+
var _this = this,
|
5
|
+
duration = options.duration,//options is an object for easily adding features later.
|
6
|
+
nameSpace = Object.keys(elem.data())[0] || 'timer',
|
7
|
+
remain = -1,
|
8
|
+
start,
|
9
|
+
timer;
|
10
|
+
|
11
|
+
this.restart = function(){
|
12
|
+
remain = -1;
|
13
|
+
clearTimeout(timer);
|
14
|
+
this.start();
|
15
|
+
};
|
16
|
+
|
17
|
+
this.start = function(){
|
18
|
+
// if(!elem.data('paused')){ return false; }//maybe implement this sanity check if used for other things.
|
19
|
+
clearTimeout(timer);
|
20
|
+
remain = remain <= 0 ? duration : remain;
|
21
|
+
elem.data('paused', false);
|
22
|
+
start = Date.now();
|
23
|
+
timer = setTimeout(function(){
|
24
|
+
if(options.infinite){
|
25
|
+
_this.restart();//rerun the timer.
|
26
|
+
}
|
27
|
+
cb();
|
28
|
+
}, remain);
|
29
|
+
elem.trigger('timerstart.zf.' + nameSpace);
|
30
|
+
};
|
31
|
+
|
32
|
+
this.pause = function(){
|
33
|
+
//if(elem.data('paused')){ return false; }//maybe implement this sanity check if used for other things.
|
34
|
+
clearTimeout(timer);
|
35
|
+
elem.data('paused', true);
|
36
|
+
var end = Date.now();
|
37
|
+
remain = remain - (end - start);
|
38
|
+
elem.trigger('timerpaused.zf.' + nameSpace);
|
39
|
+
};
|
40
|
+
};
|
41
|
+
/**
|
42
|
+
* Runs a callback function when images are fully loaded.
|
43
|
+
* @param {Object} images - Image(s) to check if loaded.
|
44
|
+
* @param {Func} callback - Function to execute when image is fully loaded.
|
45
|
+
*/
|
46
|
+
var onImagesLoaded = function(images, callback){
|
47
|
+
var self = this,
|
48
|
+
unloaded = images.length;
|
49
|
+
|
50
|
+
if (unloaded === 0) {
|
51
|
+
callback();
|
52
|
+
}
|
53
|
+
|
54
|
+
var singleImageLoaded = function() {
|
55
|
+
unloaded--;
|
56
|
+
if (unloaded === 0) {
|
57
|
+
callback();
|
58
|
+
}
|
59
|
+
};
|
60
|
+
|
61
|
+
images.each(function() {
|
62
|
+
if (this.complete) {
|
63
|
+
singleImageLoaded();
|
64
|
+
}
|
65
|
+
else if (typeof this.naturalWidth !== 'undefined' && this.naturalWidth > 0) {
|
66
|
+
singleImageLoaded();
|
67
|
+
}
|
68
|
+
else {
|
69
|
+
$(this).one('load', function() {
|
70
|
+
singleImageLoaded();
|
71
|
+
});
|
72
|
+
}
|
73
|
+
});
|
74
|
+
};
|
75
|
+
|
76
|
+
Foundation.Timer = Timer;
|
77
|
+
Foundation.onImagesLoaded = onImagesLoaded;
|
78
|
+
}(jQuery, window.Foundation);
|
@@ -0,0 +1,339 @@
|
|
1
|
+
//**************************************************
|
2
|
+
//**Work inspired by multiple jquery swipe plugins**
|
3
|
+
//**Done by Yohai Ararat ***************************
|
4
|
+
//**************************************************
|
5
|
+
(function($) {
|
6
|
+
|
7
|
+
$.spotSwipe = {
|
8
|
+
version: '1.0.0',
|
9
|
+
enabled: 'ontouchstart' in document.documentElement,
|
10
|
+
preventDefault: false,
|
11
|
+
moveThreshold: 75,
|
12
|
+
timeThreshold: 200
|
13
|
+
};
|
14
|
+
|
15
|
+
var startPosX,
|
16
|
+
startPosY,
|
17
|
+
startTime,
|
18
|
+
elapsedTime,
|
19
|
+
isMoving = false;
|
20
|
+
|
21
|
+
function onTouchEnd() {
|
22
|
+
// alert(this);
|
23
|
+
this.removeEventListener('touchmove', onTouchMove);
|
24
|
+
this.removeEventListener('touchend', onTouchEnd);
|
25
|
+
isMoving = false;
|
26
|
+
}
|
27
|
+
|
28
|
+
function onTouchMove(e) {
|
29
|
+
if ($.spotSwipe.preventDefault) { e.preventDefault(); }
|
30
|
+
if(isMoving) {
|
31
|
+
var x = e.touches[0].pageX;
|
32
|
+
var y = e.touches[0].pageY;
|
33
|
+
var dx = startPosX - x;
|
34
|
+
var dy = startPosY - y;
|
35
|
+
var dir;
|
36
|
+
elapsedTime = new Date().getTime() - startTime;
|
37
|
+
if(Math.abs(dx) >= $.spotSwipe.moveThreshold && elapsedTime <= $.spotSwipe.timeThreshold) {
|
38
|
+
dir = dx > 0 ? 'left' : 'right';
|
39
|
+
}
|
40
|
+
// else if(Math.abs(dy) >= $.spotSwipe.moveThreshold && elapsedTime <= $.spotSwipe.timeThreshold) {
|
41
|
+
// dir = dy > 0 ? 'down' : 'up';
|
42
|
+
// }
|
43
|
+
if(dir) {
|
44
|
+
e.preventDefault();
|
45
|
+
onTouchEnd.call(this);
|
46
|
+
$(this).trigger('swipe', dir).trigger('swipe' + dir);
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
function onTouchStart(e) {
|
52
|
+
if (e.touches.length == 1) {
|
53
|
+
startPosX = e.touches[0].pageX;
|
54
|
+
startPosY = e.touches[0].pageY;
|
55
|
+
isMoving = true;
|
56
|
+
startTime = new Date().getTime();
|
57
|
+
this.addEventListener('touchmove', onTouchMove, false);
|
58
|
+
this.addEventListener('touchend', onTouchEnd, false);
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
function init() {
|
63
|
+
this.addEventListener && this.addEventListener('touchstart', onTouchStart, false);
|
64
|
+
}
|
65
|
+
|
66
|
+
function teardown() {
|
67
|
+
this.removeEventListener('touchstart', onTouchStart);
|
68
|
+
}
|
69
|
+
|
70
|
+
$.event.special.swipe = { setup: init };
|
71
|
+
|
72
|
+
$.each(['left', 'up', 'down', 'right'], function () {
|
73
|
+
$.event.special['swipe' + this] = { setup: function(){
|
74
|
+
$(this).on('swipe', $.noop);
|
75
|
+
} };
|
76
|
+
});
|
77
|
+
})(jQuery);
|
78
|
+
/****************************************************
|
79
|
+
* Method for adding psuedo drag events to elements *
|
80
|
+
***************************************************/
|
81
|
+
!function($){
|
82
|
+
$.fn.addTouch = function(){
|
83
|
+
this.each(function(i,el){
|
84
|
+
$(el).bind('touchstart touchmove touchend touchcancel',function(){
|
85
|
+
//we pass the original event object because the jQuery event
|
86
|
+
//object is normalized to w3c specs and does not provide the TouchList
|
87
|
+
handleTouch(event);
|
88
|
+
});
|
89
|
+
});
|
90
|
+
|
91
|
+
var handleTouch = function(event){
|
92
|
+
var touches = event.changedTouches,
|
93
|
+
first = touches[0],
|
94
|
+
eventTypes = {
|
95
|
+
touchstart: 'mousedown',
|
96
|
+
touchmove: 'mousemove',
|
97
|
+
touchend: 'mouseup'
|
98
|
+
},
|
99
|
+
type = eventTypes[event.type];
|
100
|
+
|
101
|
+
var simulatedEvent = document.createEvent('MouseEvent');
|
102
|
+
simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY, false, false, false, false, 0/*left*/, null);
|
103
|
+
first.target.dispatchEvent(simulatedEvent);
|
104
|
+
};
|
105
|
+
};
|
106
|
+
}(jQuery);
|
107
|
+
|
108
|
+
|
109
|
+
//**********************************
|
110
|
+
//**From the jQuery Mobile Library**
|
111
|
+
//**need to recreate functionality**
|
112
|
+
//**and try to improve if possible**
|
113
|
+
//**********************************
|
114
|
+
|
115
|
+
/* Removing the jQuery function ****
|
116
|
+
************************************
|
117
|
+
|
118
|
+
(function( $, window, undefined ) {
|
119
|
+
|
120
|
+
var $document = $( document ),
|
121
|
+
// supportTouch = $.mobile.support.touch,
|
122
|
+
touchStartEvent = 'touchstart'//supportTouch ? "touchstart" : "mousedown",
|
123
|
+
touchStopEvent = 'touchend'//supportTouch ? "touchend" : "mouseup",
|
124
|
+
touchMoveEvent = 'touchmove'//supportTouch ? "touchmove" : "mousemove";
|
125
|
+
|
126
|
+
// setup new event shortcuts
|
127
|
+
$.each( ( "touchstart touchmove touchend " +
|
128
|
+
"swipe swipeleft swiperight" ).split( " " ), function( i, name ) {
|
129
|
+
|
130
|
+
$.fn[ name ] = function( fn ) {
|
131
|
+
return fn ? this.bind( name, fn ) : this.trigger( name );
|
132
|
+
};
|
133
|
+
|
134
|
+
// jQuery < 1.8
|
135
|
+
if ( $.attrFn ) {
|
136
|
+
$.attrFn[ name ] = true;
|
137
|
+
}
|
138
|
+
});
|
139
|
+
|
140
|
+
function triggerCustomEvent( obj, eventType, event, bubble ) {
|
141
|
+
var originalType = event.type;
|
142
|
+
event.type = eventType;
|
143
|
+
if ( bubble ) {
|
144
|
+
$.event.trigger( event, undefined, obj );
|
145
|
+
} else {
|
146
|
+
$.event.dispatch.call( obj, event );
|
147
|
+
}
|
148
|
+
event.type = originalType;
|
149
|
+
}
|
150
|
+
|
151
|
+
// also handles taphold
|
152
|
+
|
153
|
+
// Also handles swipeleft, swiperight
|
154
|
+
$.event.special.swipe = {
|
155
|
+
|
156
|
+
// More than this horizontal displacement, and we will suppress scrolling.
|
157
|
+
scrollSupressionThreshold: 30,
|
158
|
+
|
159
|
+
// More time than this, and it isn't a swipe.
|
160
|
+
durationThreshold: 1000,
|
161
|
+
|
162
|
+
// Swipe horizontal displacement must be more than this.
|
163
|
+
horizontalDistanceThreshold: window.devicePixelRatio >= 2 ? 15 : 30,
|
164
|
+
|
165
|
+
// Swipe vertical displacement must be less than this.
|
166
|
+
verticalDistanceThreshold: window.devicePixelRatio >= 2 ? 15 : 30,
|
167
|
+
|
168
|
+
getLocation: function ( event ) {
|
169
|
+
var winPageX = window.pageXOffset,
|
170
|
+
winPageY = window.pageYOffset,
|
171
|
+
x = event.clientX,
|
172
|
+
y = event.clientY;
|
173
|
+
|
174
|
+
if ( event.pageY === 0 && Math.floor( y ) > Math.floor( event.pageY ) ||
|
175
|
+
event.pageX === 0 && Math.floor( x ) > Math.floor( event.pageX ) ) {
|
176
|
+
|
177
|
+
// iOS4 clientX/clientY have the value that should have been
|
178
|
+
// in pageX/pageY. While pageX/page/ have the value 0
|
179
|
+
x = x - winPageX;
|
180
|
+
y = y - winPageY;
|
181
|
+
} else if ( y < ( event.pageY - winPageY) || x < ( event.pageX - winPageX ) ) {
|
182
|
+
|
183
|
+
// Some Android browsers have totally bogus values for clientX/Y
|
184
|
+
// when scrolling/zooming a page. Detectable since clientX/clientY
|
185
|
+
// should never be smaller than pageX/pageY minus page scroll
|
186
|
+
x = event.pageX - winPageX;
|
187
|
+
y = event.pageY - winPageY;
|
188
|
+
}
|
189
|
+
|
190
|
+
return {
|
191
|
+
x: x,
|
192
|
+
y: y
|
193
|
+
};
|
194
|
+
},
|
195
|
+
|
196
|
+
start: function( event ) {
|
197
|
+
var data = event.originalEvent.touches ?
|
198
|
+
event.originalEvent.touches[ 0 ] : event,
|
199
|
+
location = $.event.special.swipe.getLocation( data );
|
200
|
+
return {
|
201
|
+
time: ( new Date() ).getTime(),
|
202
|
+
coords: [ location.x, location.y ],
|
203
|
+
origin: $( event.target )
|
204
|
+
};
|
205
|
+
},
|
206
|
+
|
207
|
+
stop: function( event ) {
|
208
|
+
var data = event.originalEvent.touches ?
|
209
|
+
event.originalEvent.touches[ 0 ] : event,
|
210
|
+
location = $.event.special.swipe.getLocation( data );
|
211
|
+
return {
|
212
|
+
time: ( new Date() ).getTime(),
|
213
|
+
coords: [ location.x, location.y ]
|
214
|
+
};
|
215
|
+
},
|
216
|
+
|
217
|
+
handleSwipe: function( start, stop, thisObject, origTarget ) {
|
218
|
+
if ( stop.time - start.time < $.event.special.swipe.durationThreshold &&
|
219
|
+
Math.abs( start.coords[ 0 ] - stop.coords[ 0 ] ) > $.event.special.swipe.horizontalDistanceThreshold &&
|
220
|
+
Math.abs( start.coords[ 1 ] - stop.coords[ 1 ] ) < $.event.special.swipe.verticalDistanceThreshold ) {
|
221
|
+
var direction = start.coords[0] > stop.coords[ 0 ] ? "swipeleft" : "swiperight";
|
222
|
+
|
223
|
+
triggerCustomEvent( thisObject, "swipe", $.Event( "swipe", { target: origTarget, swipestart: start, swipestop: stop }), true );
|
224
|
+
triggerCustomEvent( thisObject, direction,$.Event( direction, { target: origTarget, swipestart: start, swipestop: stop } ), true );
|
225
|
+
return true;
|
226
|
+
}
|
227
|
+
return false;
|
228
|
+
|
229
|
+
},
|
230
|
+
|
231
|
+
// This serves as a flag to ensure that at most one swipe event event is
|
232
|
+
// in work at any given time
|
233
|
+
eventInProgress: false,
|
234
|
+
|
235
|
+
setup: function() {
|
236
|
+
var events,
|
237
|
+
thisObject = this,
|
238
|
+
$this = $( thisObject ),
|
239
|
+
context = {};
|
240
|
+
|
241
|
+
// Retrieve the events data for this element and add the swipe context
|
242
|
+
events = $.data( this, "mobile-events" );
|
243
|
+
if ( !events ) {
|
244
|
+
events = { length: 0 };
|
245
|
+
$.data( this, "mobile-events", events );
|
246
|
+
}
|
247
|
+
events.length++;
|
248
|
+
events.swipe = context;
|
249
|
+
|
250
|
+
context.start = function( event ) {
|
251
|
+
|
252
|
+
// Bail if we're already working on a swipe event
|
253
|
+
if ( $.event.special.swipe.eventInProgress ) {
|
254
|
+
return;
|
255
|
+
}
|
256
|
+
$.event.special.swipe.eventInProgress = true;
|
257
|
+
|
258
|
+
var stop,
|
259
|
+
start = $.event.special.swipe.start( event ),
|
260
|
+
origTarget = event.target,
|
261
|
+
emitted = false;
|
262
|
+
|
263
|
+
context.move = function( event ) {
|
264
|
+
if ( !start || event.isDefaultPrevented() ) {
|
265
|
+
return;
|
266
|
+
}
|
267
|
+
|
268
|
+
stop = $.event.special.swipe.stop( event );
|
269
|
+
if ( !emitted ) {
|
270
|
+
emitted = $.event.special.swipe.handleSwipe( start, stop, thisObject, origTarget );
|
271
|
+
if ( emitted ) {
|
272
|
+
|
273
|
+
// Reset the context to make way for the next swipe event
|
274
|
+
$.event.special.swipe.eventInProgress = false;
|
275
|
+
}
|
276
|
+
}
|
277
|
+
// prevent scrolling
|
278
|
+
if ( Math.abs( start.coords[ 0 ] - stop.coords[ 0 ] ) > $.event.special.swipe.scrollSupressionThreshold ) {
|
279
|
+
event.preventDefault();
|
280
|
+
}
|
281
|
+
};
|
282
|
+
|
283
|
+
context.stop = function() {
|
284
|
+
emitted = true;
|
285
|
+
|
286
|
+
// Reset the context to make way for the next swipe event
|
287
|
+
$.event.special.swipe.eventInProgress = false;
|
288
|
+
$document.off( touchMoveEvent, context.move );
|
289
|
+
context.move = null;
|
290
|
+
};
|
291
|
+
|
292
|
+
$document.on( touchMoveEvent, context.move )
|
293
|
+
.one( touchStopEvent, context.stop );
|
294
|
+
};
|
295
|
+
$this.on( touchStartEvent, context.start );
|
296
|
+
},
|
297
|
+
|
298
|
+
teardown: function() {
|
299
|
+
var events, context;
|
300
|
+
|
301
|
+
events = $.data( this, "mobile-events" );
|
302
|
+
if ( events ) {
|
303
|
+
context = events.swipe;
|
304
|
+
delete events.swipe;
|
305
|
+
events.length--;
|
306
|
+
if ( events.length === 0 ) {
|
307
|
+
$.removeData( this, "mobile-events" );
|
308
|
+
}
|
309
|
+
}
|
310
|
+
|
311
|
+
if ( context ) {
|
312
|
+
if ( context.start ) {
|
313
|
+
$( this ).off( touchStartEvent, context.start );
|
314
|
+
}
|
315
|
+
if ( context.move ) {
|
316
|
+
$document.off( touchMoveEvent, context.move );
|
317
|
+
}
|
318
|
+
if ( context.stop ) {
|
319
|
+
$document.off( touchStopEvent, context.stop );
|
320
|
+
}
|
321
|
+
}
|
322
|
+
}
|
323
|
+
};
|
324
|
+
$.each({
|
325
|
+
swipeleft: "swipe.left",
|
326
|
+
swiperight: "swipe.right"
|
327
|
+
}, function( event, sourceEvent ) {
|
328
|
+
|
329
|
+
$.event.special[ event ] = {
|
330
|
+
setup: function() {
|
331
|
+
$( this ).bind( sourceEvent, $.noop );
|
332
|
+
},
|
333
|
+
teardown: function() {
|
334
|
+
$( this ).unbind( sourceEvent );
|
335
|
+
}
|
336
|
+
};
|
337
|
+
});
|
338
|
+
})( jQuery, this );
|
339
|
+
*/
|