ns-styleguide 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/style-guide/_style-guide.scss +4 -0
- data/style-guide/global/_base.scss +33 -0
- data/style-guide/global/_colors.scss +24 -0
- data/style-guide/global/_extendables.scss +16 -0
- data/style-guide/global/_functions.scss +5 -0
- data/style-guide/global/_mixins.scss +5 -0
- data/style-guide/global/_variables.scss +15 -0
- data/templates/project/assets/6.jpg +0 -0
- data/templates/project/assets/_nsfont/_comment.svg +8 -0
- data/templates/project/assets/_nsfont/_default-user.svg +12 -0
- data/templates/project/assets/_nsfont/_home.svg +12 -0
- data/templates/project/assets/_nsfont/_notify.svg +13 -0
- data/templates/project/assets/_nsfont/_pillbox.svg +27 -0
- data/templates/project/assets/_nsfont/_search.svg +12 -0
- data/templates/project/assets/_nsfont/bs-circulatory.svg +26 -0
- data/templates/project/assets/_nsfont/bs-digestive.svg +28 -0
- data/templates/project/assets/_nsfont/bs-endocrine.svg +33 -0
- data/templates/project/assets/_nsfont/bs-immune.svg +31 -0
- data/templates/project/assets/_nsfont/bs-muscular-skeletal.svg +119 -0
- data/templates/project/assets/_nsfont/bs-nervous.svg +31 -0
- data/templates/project/assets/_nsfont/bs-reprodutive.svg +29 -0
- data/templates/project/assets/_nsfont/bs-respiratory.svg +17 -0
- data/templates/project/assets/_nsfont/ls-athletic.svg +17 -0
- data/templates/project/assets/_nsfont/ls-diet.svg +21 -0
- data/templates/project/assets/_nsfont/ls-energyvitality.svg +14 -0
- data/templates/project/assets/_nsfont/ls-mentalacuity.svg +34 -0
- data/templates/project/assets/_nsfont/ls-sexual.svg +42 -0
- data/templates/project/assets/_nsfont/ls-weightcontrol.svg +17 -0
- data/templates/project/assets/_nsfont/nsa-check.svg +7 -0
- data/templates/project/assets/_nsfont/nsa-questionmark.svg +15 -0
- data/templates/project/assets/_nsfont/nsa-xmark.svg +10 -0
- data/templates/project/assets/_nsfont/st-botanical.svg +18 -0
- data/templates/project/assets/_nsfont/st-food.svg +24 -0
- data/templates/project/assets/_nsfont/st-mineral.svg +15 -0
- data/templates/project/assets/_nsfont/st-other.svg +9 -0
- data/templates/project/assets/_nsfont/st-vitamin.svg +25 -0
- data/templates/project/assets/_nsfont/vote-down.svg +10 -0
- data/templates/project/assets/_nsfont/vote-up.svg +10 -0
- data/templates/project/assets/_nsfont/yp-age.svg +22 -0
- data/templates/project/assets/_nsfont/yp-gender.svg +16 -0
- data/templates/project/assets/_nsfont/yp-preventiontherapy.svg +109 -0
- data/templates/project/assets/aloe-vera.jpg +0 -0
- data/templates/project/assets/alzheimers-brainpuzzle-512.jpg +0 -0
- data/templates/project/assets/blurred1.jpg +0 -0
- data/templates/project/assets/blurred5.jpg +0 -0
- data/templates/project/assets/blurred6.jpg +0 -0
- data/templates/project/assets/botanical.svg +18 -0
- data/templates/project/assets/capsule.jpg +0 -0
- data/templates/project/assets/clouds.jpg +0 -0
- data/templates/project/assets/clouds.png +0 -0
- data/templates/project/assets/factorfiction-s3d0b80354a.png +0 -0
- data/templates/project/assets/factorfiction/factorfiction.png +0 -0
- data/templates/project/assets/factorfiction/factorfiction.svg +420 -0
- data/templates/project/assets/fff.png +0 -0
- data/templates/project/assets/food.svg +24 -0
- data/templates/project/assets/foundation/orbit/bullets.jpg +0 -0
- data/templates/project/assets/foundation/orbit/left-arrow-small.png +0 -0
- data/templates/project/assets/foundation/orbit/left-arrow.png +0 -0
- data/templates/project/assets/foundation/orbit/loading.gif +0 -0
- data/templates/project/assets/foundation/orbit/mask-black.png +0 -0
- data/templates/project/assets/foundation/orbit/pause-black.png +0 -0
- data/templates/project/assets/foundation/orbit/right-arrow-small.png +0 -0
- data/templates/project/assets/foundation/orbit/right-arrow.png +0 -0
- data/templates/project/assets/foundation/orbit/rotator-black.png +0 -0
- data/templates/project/assets/foundation/orbit/timer-black.png +0 -0
- data/templates/project/assets/glyphicons-halflings-white.png +0 -0
- data/templates/project/assets/glyphicons-halflings.png +0 -0
- data/templates/project/assets/hero.jpg +0 -0
- data/templates/project/assets/hero2.jpg +0 -0
- data/templates/project/assets/hero3.jpg +0 -0
- data/templates/project/assets/ice.jpg +0 -0
- data/templates/project/assets/iceberg.jpg +0 -0
- data/templates/project/assets/landing.jpg +0 -0
- data/templates/project/assets/mineral.svg +15 -0
- data/templates/project/assets/moon.jpg +0 -0
- data/templates/project/assets/ns-logo.svg +177 -0
- data/templates/project/assets/nslogo-s56b550b473.png +0 -0
- data/templates/project/assets/nslogo/nslogo.png +0 -0
- data/templates/project/assets/nslogo/nslogo.svg +177 -0
- data/templates/project/assets/other.svg +9 -0
- data/templates/project/assets/pillbox-hover.svg +33 -0
- data/templates/project/assets/pillbox-image.png +0 -0
- data/templates/project/assets/pillbox-image.svg +7880 -0
- data/templates/project/assets/pillbox.svg +27 -0
- data/templates/project/assets/rocket.jpg +0 -0
- data/templates/project/assets/shuttle.jpeg +0 -0
- data/templates/project/assets/svg/community-clear.svg +82 -0
- data/templates/project/assets/svg/community.svg +64 -0
- data/templates/project/assets/svg/conditions.svg +18 -0
- data/templates/project/assets/svg/experts.svg +32 -0
- data/templates/project/assets/svg/fact-or-fiction.svg +420 -0
- data/templates/project/assets/svg/lifestyle.svg +22 -0
- data/templates/project/assets/svg/perspective.svg +22 -0
- data/templates/project/assets/svg/supplements.svg +19 -0
- data/templates/project/assets/svgicons-s95620826ea.png +0 -0
- data/templates/project/assets/svgicons/community.png +0 -0
- data/templates/project/assets/svgicons/community.svg +55 -0
- data/templates/project/assets/svgicons/conditions.png +0 -0
- data/templates/project/assets/svgicons/conditions.svg +16 -0
- data/templates/project/assets/svgicons/experts.png +0 -0
- data/templates/project/assets/svgicons/experts.svg +30 -0
- data/templates/project/assets/svgicons/lifestyle.png +0 -0
- data/templates/project/assets/svgicons/lifestyle.svg +20 -0
- data/templates/project/assets/svgicons/supplements.png +0 -0
- data/templates/project/assets/svgicons/supplements.svg +17 -0
- data/templates/project/assets/svgicons/your-perspective.png +0 -0
- data/templates/project/assets/svgicons/your-perspective.svg +20 -0
- data/templates/project/assets/users/kp.jpg +0 -0
- data/templates/project/assets/video_placeholder.jpg +0 -0
- data/templates/project/assets/vitamin.svg +25 -0
- data/templates/project/component.json +9 -0
- data/templates/project/libs/bootstrap-modal.js +374 -0
- data/templates/project/libs/bootstrap/README.md +106 -0
- data/templates/project/libs/bootstrap/application.js +156 -0
- data/templates/project/libs/bootstrap/bootstrap-affix.js +117 -0
- data/templates/project/libs/bootstrap/bootstrap-alert.js +99 -0
- data/templates/project/libs/bootstrap/bootstrap-button.js +105 -0
- data/templates/project/libs/bootstrap/bootstrap-carousel.js +207 -0
- data/templates/project/libs/bootstrap/bootstrap-collapse.js +167 -0
- data/templates/project/libs/bootstrap/bootstrap-dropdown.js +165 -0
- data/templates/project/libs/bootstrap/bootstrap-modal.js +251 -0
- data/templates/project/libs/bootstrap/bootstrap-popover.js +114 -0
- data/templates/project/libs/bootstrap/bootstrap-scrollspy.js +162 -0
- data/templates/project/libs/bootstrap/bootstrap-tab.js +144 -0
- data/templates/project/libs/bootstrap/bootstrap-tooltip.js +361 -0
- data/templates/project/libs/bootstrap/bootstrap-transition.js +60 -0
- data/templates/project/libs/bootstrap/bootstrap-typeahead.js +335 -0
- data/templates/project/libs/bootstrap/bootstrap.js +2280 -0
- data/templates/project/libs/bootstrap/bootstrap.min.js +6 -0
- data/templates/project/libs/bootstrap/holder/holder.js +401 -0
- data/templates/project/libs/bootstrap/html5shiv.js +8 -0
- data/templates/project/libs/bootstrap/jquery.js +5 -0
- data/templates/project/libs/bootstrap/respond/respond.min.js +6 -0
- data/templates/project/libs/equalheights.js +46 -0
- data/templates/project/libs/foundation/foundation.alerts.js +50 -0
- data/templates/project/libs/foundation/foundation.clearing.js +516 -0
- data/templates/project/libs/foundation/foundation.cookie.js +74 -0
- data/templates/project/libs/foundation/foundation.dropdown.js +175 -0
- data/templates/project/libs/foundation/foundation.forms.js +513 -0
- data/templates/project/libs/foundation/foundation.joyride.js +831 -0
- data/templates/project/libs/foundation/foundation.js +401 -0
- data/templates/project/libs/foundation/foundation.magellan.js +130 -0
- data/templates/project/libs/foundation/foundation.orbit.js +373 -0
- data/templates/project/libs/foundation/foundation.placeholder.js +159 -0
- data/templates/project/libs/foundation/foundation.reveal.js +277 -0
- data/templates/project/libs/foundation/foundation.section.js +407 -0
- data/templates/project/libs/foundation/foundation.tooltips.js +200 -0
- data/templates/project/libs/foundation/foundation.topbar.js +245 -0
- data/templates/project/libs/hello.coffee +1 -0
- data/templates/project/libs/helper.js +385 -0
- data/templates/project/libs/jquery.magnific-popup.js +1783 -0
- data/templates/project/libs/jquery.magnific-popup.min.js +4 -0
- data/templates/project/libs/jquery.mixitup.min.js +43 -0
- data/templates/project/libs/main.js +1 -0
- data/templates/project/libs/ns.js +128 -0
- data/templates/project/libs/select2-3.4.0/README.md +83 -0
- data/templates/project/libs/select2-3.4.0/component.json +8 -0
- data/templates/project/libs/select2-3.4.0/release.sh +69 -0
- data/templates/project/libs/select2-3.4.0/select2-spinner.gif +0 -0
- data/templates/project/libs/select2-3.4.0/select2.css +652 -0
- data/templates/project/libs/select2-3.4.0/select2.jquery.json +36 -0
- data/templates/project/libs/select2-3.4.0/select2.js +3054 -0
- data/templates/project/libs/select2-3.4.0/select2.min.js +22 -0
- data/templates/project/libs/select2-3.4.0/select2.png +0 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_ca.js +17 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_cs.js +49 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_da.js +17 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_de.js +15 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_en.js.template +17 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_es.js +15 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_et.js +17 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_eu.js +43 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_fr.js +15 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_gl.js +43 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_he.js +17 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_hr.js +42 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_hu.js +15 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_is.js +16 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_it.js +15 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_ja.js +15 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_lt.js +29 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_lv.js +16 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_mk.js +17 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_nl.js +15 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_no.js +18 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_pl.js +37 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_pt-BR.js +15 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_pt-PT.js +15 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_ro.js +15 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_ru.js +15 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_sk.js +48 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_sv.js +17 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_tr.js +17 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_ua.js +17 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_vi.js +18 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_zh-CN.js +14 -0
- data/templates/project/libs/select2-3.4.0/select2_locale_zh-TW.js +14 -0
- data/templates/project/libs/select2-3.4.0/select2x2.png +0 -0
- data/templates/project/libs/vendor/modernizr-2.6.2.min.js +4 -0
- data/templates/project/libs/vendor/zepto.js +1884 -0
- data/templates/project/libs/vendor/zepto.min.js +2 -0
- data/templates/project/manifest.rb +9 -0
- data/templates/project/style.scss.erb +2 -0
- metadata +288 -0
@@ -0,0 +1,200 @@
|
|
1
|
+
/*jslint unparam: true, browser: true, indent: 2 */
|
2
|
+
|
3
|
+
;(function ($, window, document, undefined) {
|
4
|
+
'use strict';
|
5
|
+
|
6
|
+
Foundation.libs.tooltips = {
|
7
|
+
name: 'tooltips',
|
8
|
+
|
9
|
+
version : '4.1.3',
|
10
|
+
|
11
|
+
settings : {
|
12
|
+
selector : '.has-tip',
|
13
|
+
additionalInheritableClasses : [],
|
14
|
+
tooltipClass : '.tooltip',
|
15
|
+
appendTo: 'body',
|
16
|
+
tipTemplate : function (selector, content) {
|
17
|
+
return '<span data-selector="' + selector + '" class="'
|
18
|
+
+ Foundation.libs.tooltips.settings.tooltipClass.substring(1)
|
19
|
+
+ '">' + content + '<span class="nub"></span></span>';
|
20
|
+
}
|
21
|
+
},
|
22
|
+
|
23
|
+
cache : {},
|
24
|
+
|
25
|
+
init : function (scope, method, options) {
|
26
|
+
var self = this;
|
27
|
+
this.scope = scope || this.scope;
|
28
|
+
|
29
|
+
if (typeof method === 'object') {
|
30
|
+
$.extend(true, this.settings, method);
|
31
|
+
}
|
32
|
+
|
33
|
+
if (typeof method != 'string') {
|
34
|
+
if (Modernizr.touch) {
|
35
|
+
$(this.scope)
|
36
|
+
.on('click.fndtn.tooltip touchstart.fndtn.tooltip touchend.fndtn.tooltip',
|
37
|
+
'[data-tooltip]', function (e) {
|
38
|
+
e.preventDefault();
|
39
|
+
$(self.settings.tooltipClass).hide();
|
40
|
+
self.showOrCreateTip($(this));
|
41
|
+
})
|
42
|
+
.on('click.fndtn.tooltip touchstart.fndtn.tooltip touchend.fndtn.tooltip',
|
43
|
+
this.settings.tooltipClass, function (e) {
|
44
|
+
e.preventDefault();
|
45
|
+
$(this).fadeOut(150);
|
46
|
+
});
|
47
|
+
} else {
|
48
|
+
$(this.scope)
|
49
|
+
.on('mouseenter.fndtn.tooltip mouseleave.fndtn.tooltip',
|
50
|
+
'[data-tooltip]', function (e) {
|
51
|
+
var $this = $(this);
|
52
|
+
|
53
|
+
if (e.type === 'mouseover' || e.type === 'mouseenter') {
|
54
|
+
self.showOrCreateTip($this);
|
55
|
+
} else if (e.type === 'mouseout' || e.type === 'mouseleave') {
|
56
|
+
self.hide($this);
|
57
|
+
}
|
58
|
+
});
|
59
|
+
}
|
60
|
+
|
61
|
+
// $(this.scope).data('fndtn-tooltips', true);
|
62
|
+
} else {
|
63
|
+
return this[method].call(this, options);
|
64
|
+
}
|
65
|
+
|
66
|
+
},
|
67
|
+
|
68
|
+
showOrCreateTip : function ($target) {
|
69
|
+
var $tip = this.getTip($target);
|
70
|
+
|
71
|
+
if ($tip && $tip.length > 0) {
|
72
|
+
return this.show($target);
|
73
|
+
}
|
74
|
+
|
75
|
+
return this.create($target);
|
76
|
+
},
|
77
|
+
|
78
|
+
getTip : function ($target) {
|
79
|
+
var selector = this.selector($target),
|
80
|
+
tip = null;
|
81
|
+
|
82
|
+
if (selector) {
|
83
|
+
tip = $('span[data-selector=' + selector + ']' + this.settings.tooltipClass);
|
84
|
+
}
|
85
|
+
|
86
|
+
return (typeof tip === 'object') ? tip : false;
|
87
|
+
},
|
88
|
+
|
89
|
+
selector : function ($target) {
|
90
|
+
var id = $target.attr('id'),
|
91
|
+
dataSelector = $target.attr('data-tooltip') || $target.attr('data-selector');
|
92
|
+
|
93
|
+
if ((id && id.length < 1 || !id) && typeof dataSelector != 'string') {
|
94
|
+
dataSelector = 'tooltip' + Math.random().toString(36).substring(7);
|
95
|
+
$target.attr('data-selector', dataSelector);
|
96
|
+
}
|
97
|
+
|
98
|
+
return (id && id.length > 0) ? id : dataSelector;
|
99
|
+
},
|
100
|
+
|
101
|
+
create : function ($target) {
|
102
|
+
var $tip = $(this.settings.tipTemplate(this.selector($target), $('<div></div>').html($target.attr('title')).html())),
|
103
|
+
classes = this.inheritable_classes($target);
|
104
|
+
|
105
|
+
$tip.addClass(classes).appendTo(this.settings.appendTo);
|
106
|
+
if (Modernizr.touch) {
|
107
|
+
$tip.append('<span class="tap-to-close">tap to close </span>');
|
108
|
+
}
|
109
|
+
$target.removeAttr('title').attr('title','');
|
110
|
+
this.show($target);
|
111
|
+
},
|
112
|
+
|
113
|
+
reposition : function (target, tip, classes) {
|
114
|
+
var width, nub, nubHeight, nubWidth, column, objPos;
|
115
|
+
|
116
|
+
tip.css('visibility', 'hidden').show();
|
117
|
+
|
118
|
+
width = target.data('width');
|
119
|
+
nub = tip.children('.nub');
|
120
|
+
nubHeight = this.outerHeight(nub);
|
121
|
+
nubWidth = this.outerHeight(nub);
|
122
|
+
|
123
|
+
objPos = function (obj, top, right, bottom, left, width) {
|
124
|
+
return obj.css({
|
125
|
+
'top' : (top) ? top : 'auto',
|
126
|
+
'bottom' : (bottom) ? bottom : 'auto',
|
127
|
+
'left' : (left) ? left : 'auto',
|
128
|
+
'right' : (right) ? right : 'auto',
|
129
|
+
'width' : (width) ? width : 'auto'
|
130
|
+
}).end();
|
131
|
+
};
|
132
|
+
|
133
|
+
objPos(tip, (target.offset().top + this.outerHeight(target) + 10), 'auto', 'auto', target.offset().left, width);
|
134
|
+
|
135
|
+
if ($(window).width() < 767) {
|
136
|
+
objPos(tip, (target.offset().top + this.outerHeight(target) + 10), 'auto', 'auto', 12.5, $(this.scope).width());
|
137
|
+
tip.addClass('tip-override');
|
138
|
+
objPos(nub, -nubHeight, 'auto', 'auto', target.offset().left);
|
139
|
+
} else {
|
140
|
+
var left = target.offset().left;
|
141
|
+
if (Foundation.rtl) {
|
142
|
+
left = target.offset().left + target.offset().width - this.outerWidth(tip);
|
143
|
+
}
|
144
|
+
objPos(tip, (target.offset().top + this.outerHeight(target) + 10), 'auto', 'auto', left, width);
|
145
|
+
tip.removeClass('tip-override');
|
146
|
+
if (classes && classes.indexOf('tip-top') > -1) {
|
147
|
+
objPos(tip, (target.offset().top - this.outerHeight(tip)), 'auto', 'auto', left, width)
|
148
|
+
.removeClass('tip-override');
|
149
|
+
} else if (classes && classes.indexOf('tip-left') > -1) {
|
150
|
+
objPos(tip, (target.offset().top + (this.outerHeight(target) / 2) - nubHeight*2.5), 'auto', 'auto', (target.offset().left - this.outerWidth(tip) - nubHeight), width)
|
151
|
+
.removeClass('tip-override');
|
152
|
+
} else if (classes && classes.indexOf('tip-right') > -1) {
|
153
|
+
objPos(tip, (target.offset().top + (this.outerHeight(target) / 2) - nubHeight*2.5), 'auto', 'auto', (target.offset().left + this.outerWidth(target) + nubHeight), width)
|
154
|
+
.removeClass('tip-override');
|
155
|
+
}
|
156
|
+
}
|
157
|
+
|
158
|
+
tip.css('visibility', 'visible').hide();
|
159
|
+
},
|
160
|
+
|
161
|
+
inheritable_classes : function (target) {
|
162
|
+
var inheritables = ['tip-top', 'tip-left', 'tip-bottom', 'tip-right', 'noradius'].concat(this.settings.additionalInheritableClasses),
|
163
|
+
classes = target.attr('class'),
|
164
|
+
filtered = classes ? $.map(classes.split(' '), function (el, i) {
|
165
|
+
if ($.inArray(el, inheritables) !== -1) {
|
166
|
+
return el;
|
167
|
+
}
|
168
|
+
}).join(' ') : '';
|
169
|
+
|
170
|
+
return $.trim(filtered);
|
171
|
+
},
|
172
|
+
|
173
|
+
show : function ($target) {
|
174
|
+
var $tip = this.getTip($target);
|
175
|
+
|
176
|
+
this.reposition($target, $tip, $target.attr('class'));
|
177
|
+
$tip.fadeIn(150);
|
178
|
+
},
|
179
|
+
|
180
|
+
hide : function ($target) {
|
181
|
+
var $tip = this.getTip($target);
|
182
|
+
|
183
|
+
$tip.fadeOut(150);
|
184
|
+
},
|
185
|
+
|
186
|
+
// deprecate reload
|
187
|
+
reload : function () {
|
188
|
+
var $self = $(this);
|
189
|
+
|
190
|
+
return ($self.data('fndtn-tooltips')) ? $self.foundationTooltips('destroy').foundationTooltips('init') : $self.foundationTooltips('init');
|
191
|
+
},
|
192
|
+
|
193
|
+
off : function () {
|
194
|
+
$(this.scope).off('.fndtn.tooltip');
|
195
|
+
$(this.settings.tooltipClass).each(function (i) {
|
196
|
+
$('[data-tooltip]').get(i).attr('title', $(this).text());
|
197
|
+
}).remove();
|
198
|
+
}
|
199
|
+
};
|
200
|
+
}(Foundation.zj, this, this.document));
|
@@ -0,0 +1,245 @@
|
|
1
|
+
/*jslint unparam: true, browser: true, indent: 2 */
|
2
|
+
|
3
|
+
;(function ($, window, document, undefined) {
|
4
|
+
'use strict';
|
5
|
+
|
6
|
+
Foundation.libs.topbar = {
|
7
|
+
name : 'topbar',
|
8
|
+
|
9
|
+
version : '4.1.2',
|
10
|
+
|
11
|
+
settings : {
|
12
|
+
index : 0,
|
13
|
+
stickyClass : 'sticky',
|
14
|
+
custom_back_text: true,
|
15
|
+
back_text: 'Back',
|
16
|
+
init : false
|
17
|
+
},
|
18
|
+
|
19
|
+
init : function (section, method, options) {
|
20
|
+
var self = this;
|
21
|
+
|
22
|
+
if (typeof method === 'object') {
|
23
|
+
$.extend(true, this.settings, method);
|
24
|
+
}
|
25
|
+
|
26
|
+
if (typeof method != 'string') {
|
27
|
+
|
28
|
+
$('.top-bar').each(function () {
|
29
|
+
self.settings.$w = $(window);
|
30
|
+
self.settings.$topbar = $(this);
|
31
|
+
self.settings.$section = self.settings.$topbar.find('section');
|
32
|
+
self.settings.$titlebar = self.settings.$topbar.children('ul').first();
|
33
|
+
|
34
|
+
|
35
|
+
self.settings.$topbar.data('index', 0);
|
36
|
+
|
37
|
+
var breakpoint = $("<div class='top-bar-js-breakpoint'/>").insertAfter(self.settings.$topbar);
|
38
|
+
self.settings.breakPoint = breakpoint.width();
|
39
|
+
breakpoint.remove();
|
40
|
+
|
41
|
+
self.assemble();
|
42
|
+
|
43
|
+
if (self.settings.$topbar.parent().hasClass('fixed')) {
|
44
|
+
$('body').css('padding-top', self.outerHeight(self.settings.$topbar));
|
45
|
+
}
|
46
|
+
});
|
47
|
+
|
48
|
+
if (!self.settings.init) {
|
49
|
+
this.events();
|
50
|
+
}
|
51
|
+
|
52
|
+
return this.settings.init;
|
53
|
+
} else {
|
54
|
+
// fire method
|
55
|
+
return this[method].call(this, options);
|
56
|
+
}
|
57
|
+
},
|
58
|
+
|
59
|
+
events : function () {
|
60
|
+
var self = this;
|
61
|
+
var offst = this.outerHeight($('.top-bar'));
|
62
|
+
$(this.scope)
|
63
|
+
.on('click.fndtn.topbar', '.top-bar .toggle-topbar', function (e) {
|
64
|
+
var topbar = $(this).closest('.top-bar'),
|
65
|
+
section = topbar.find('section, .section'),
|
66
|
+
titlebar = topbar.children('ul').first();
|
67
|
+
|
68
|
+
if (!topbar.data('height')) self.largestUL();
|
69
|
+
|
70
|
+
e.preventDefault();
|
71
|
+
|
72
|
+
if (self.breakpoint()) {
|
73
|
+
topbar
|
74
|
+
.toggleClass('expanded')
|
75
|
+
.css('min-height', '');
|
76
|
+
}
|
77
|
+
|
78
|
+
if (!topbar.hasClass('expanded')) {
|
79
|
+
if (!self.rtl) {
|
80
|
+
section.css({left: '0%'});
|
81
|
+
section.find('>.name').css({left: '100%'});
|
82
|
+
} else {
|
83
|
+
section.css({right: '0%'});
|
84
|
+
section.find('>.name').css({right: '100%'});
|
85
|
+
}
|
86
|
+
section.find('li.moved').removeClass('moved');
|
87
|
+
topbar.data('index', 0);
|
88
|
+
|
89
|
+
if (topbar.hasClass('fixed')) {
|
90
|
+
topbar.parent().addClass('fixed');
|
91
|
+
topbar.removeClass('fixed');
|
92
|
+
$('body').css('padding-top',offst);
|
93
|
+
}
|
94
|
+
} else if (topbar.parent().hasClass('fixed')) {
|
95
|
+
topbar.parent().removeClass('fixed');
|
96
|
+
topbar.addClass('fixed');
|
97
|
+
$('body').css('padding-top','0');
|
98
|
+
window.scrollTo(0,0);
|
99
|
+
}
|
100
|
+
})
|
101
|
+
|
102
|
+
.on('click.fndtn.topbar', '.top-bar .has-dropdown>a', function (e) {
|
103
|
+
var topbar = $(this).closest('.top-bar'),
|
104
|
+
section = topbar.find('section, .section'),
|
105
|
+
titlebar = topbar.children('ul').first(),
|
106
|
+
dropdownHeight = $(this).next('.dropdown').outerHeight();
|
107
|
+
|
108
|
+
if (Modernizr.touch || self.breakpoint()) {
|
109
|
+
e.preventDefault();
|
110
|
+
}
|
111
|
+
|
112
|
+
if (self.breakpoint()) {
|
113
|
+
var $this = $(this),
|
114
|
+
$selectedLi = $this.closest('li');
|
115
|
+
|
116
|
+
topbar.data('index', topbar.data('index') + 1);
|
117
|
+
$selectedLi.addClass('moved');
|
118
|
+
if (!self.rtl) {
|
119
|
+
section.css({left: -(100 * topbar.data('index')) + '%'});
|
120
|
+
section.find('>.name').css({left: 100 * topbar.data('index') + '%'});
|
121
|
+
} else {
|
122
|
+
section.css({right: -(100 * topbar.data('index')) + '%'});
|
123
|
+
section.find('>.name').css({right: 100 * topbar.data('index') + '%'});
|
124
|
+
}
|
125
|
+
|
126
|
+
$('.top-bar').css('min-height', dropdownHeight);
|
127
|
+
|
128
|
+
$this.siblings('ul')
|
129
|
+
.height(topbar.data('height') + self.outerHeight(titlebar, true));
|
130
|
+
topbar
|
131
|
+
.css('min-height', topbar.data('height') + self.outerHeight(titlebar, true) * 2)
|
132
|
+
}
|
133
|
+
});
|
134
|
+
|
135
|
+
$(window).on('resize.fndtn.topbar', function () {
|
136
|
+
if (!self.breakpoint()) {
|
137
|
+
$('.top-bar')
|
138
|
+
.css('min-height', '')
|
139
|
+
.removeClass('expanded');
|
140
|
+
}
|
141
|
+
}.bind(this));
|
142
|
+
|
143
|
+
// Go up a level on Click
|
144
|
+
$(this.scope).on('click.fndtn', '.top-bar .has-dropdown .back', function (e) {
|
145
|
+
e.preventDefault();
|
146
|
+
|
147
|
+
var $this = $(this),
|
148
|
+
topbar = $this.closest('.top-bar'),
|
149
|
+
section = topbar.find('section, .section'),
|
150
|
+
$movedLi = $this.closest('li.moved'),
|
151
|
+
$previousLevelUl = $movedLi.parent();
|
152
|
+
|
153
|
+
topbar.data('index', topbar.data('index') - 1);
|
154
|
+
if (!self.rtl) {
|
155
|
+
section.css({left: -(100 * topbar.data('index')) + '%'});
|
156
|
+
section.find('>.name').css({left: 100 * topbar.data('index') + '%'});
|
157
|
+
} else {
|
158
|
+
section.css({right: -(100 * topbar.data('index')) + '%'});
|
159
|
+
section.find('>.name').css({right: 100 * topbar.data('index') + '%'});
|
160
|
+
}
|
161
|
+
|
162
|
+
if (topbar.data('index') === 0) {
|
163
|
+
topbar.css('min-height', 0);
|
164
|
+
}
|
165
|
+
|
166
|
+
setTimeout(function () {
|
167
|
+
$movedLi.removeClass('moved');
|
168
|
+
}, 300);
|
169
|
+
});
|
170
|
+
},
|
171
|
+
|
172
|
+
breakpoint : function () {
|
173
|
+
return $(window).width() <= this.settings.breakPoint || $('html').hasClass('lt-ie9');
|
174
|
+
},
|
175
|
+
|
176
|
+
assemble : function () {
|
177
|
+
var self = this;
|
178
|
+
// Pull element out of the DOM for manipulation
|
179
|
+
this.settings.$section.detach();
|
180
|
+
|
181
|
+
this.settings.$section.find('.has-dropdown>a').each(function () {
|
182
|
+
var $link = $(this),
|
183
|
+
$dropdown = $link.siblings('.dropdown'),
|
184
|
+
$titleLi = $('<li class="title back js-generated"><h5><a href="#"></a></h5></li>');
|
185
|
+
|
186
|
+
// Copy link to subnav
|
187
|
+
if (self.settings.custom_back_text == true) {
|
188
|
+
$titleLi.find('h5>a').html('« ' + self.settings.back_text);
|
189
|
+
} else {
|
190
|
+
$titleLi.find('h5>a').html('« ' + $link.html());
|
191
|
+
}
|
192
|
+
$dropdown.prepend($titleLi);
|
193
|
+
});
|
194
|
+
|
195
|
+
// Put element back in the DOM
|
196
|
+
this.settings.$section.appendTo(this.settings.$topbar);
|
197
|
+
|
198
|
+
// check for sticky
|
199
|
+
this.sticky();
|
200
|
+
},
|
201
|
+
|
202
|
+
largestUL : function () {
|
203
|
+
var uls = this.settings.$topbar.find('section ul ul'),
|
204
|
+
largest = uls.first(),
|
205
|
+
total = 0,
|
206
|
+
self = this;
|
207
|
+
|
208
|
+
uls.each(function () {
|
209
|
+
if ($(this).children('li').length > largest.children('li').length) {
|
210
|
+
largest = $(this);
|
211
|
+
}
|
212
|
+
});
|
213
|
+
|
214
|
+
largest.children('li').each(function () { total += self.outerHeight($(this), true); });
|
215
|
+
|
216
|
+
this.settings.$topbar.data('height', total);
|
217
|
+
},
|
218
|
+
|
219
|
+
sticky : function () {
|
220
|
+
var klass = '.' + this.settings.stickyClass;
|
221
|
+
if ($(klass).length > 0) {
|
222
|
+
var distance = $(klass).length ? $(klass).offset().top: 0,
|
223
|
+
$window = $(window);
|
224
|
+
var offst = this.outerHeight($('.top-bar'));
|
225
|
+
|
226
|
+
$window.scroll(function() {
|
227
|
+
if ($window.scrollTop() >= (distance)) {
|
228
|
+
$(klass).addClass("fixed");
|
229
|
+
$('body').css('padding-top',offst);
|
230
|
+
}
|
231
|
+
|
232
|
+
else if ($window.scrollTop() < distance) {
|
233
|
+
$(klass).removeClass("fixed");
|
234
|
+
$('body').css('padding-top','0');
|
235
|
+
}
|
236
|
+
});
|
237
|
+
}
|
238
|
+
},
|
239
|
+
|
240
|
+
off : function () {
|
241
|
+
$(this.scope).off('.fndtn.topbar');
|
242
|
+
$(window).off('.fndtn.topbar');
|
243
|
+
}
|
244
|
+
};
|
245
|
+
}(Foundation.zj, this, this.document));
|
@@ -0,0 +1 @@
|
|
1
|
+
console.log "'Allo from CoffeeScript!"
|
@@ -0,0 +1,385 @@
|
|
1
|
+
/**
|
2
|
+
* MBP - Mobile boilerplate helper functions
|
3
|
+
*/
|
4
|
+
|
5
|
+
(function(document) {
|
6
|
+
|
7
|
+
window.MBP = window.MBP || {};
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Fix for iPhone viewport scale bug
|
11
|
+
* http://www.blog.highub.com/mobile-2/a-fix-for-iphone-viewport-scale-bug/
|
12
|
+
*/
|
13
|
+
|
14
|
+
MBP.viewportmeta = document.querySelector && document.querySelector('meta[name="viewport"]');
|
15
|
+
MBP.ua = navigator.userAgent;
|
16
|
+
|
17
|
+
MBP.scaleFix = function() {
|
18
|
+
if (MBP.viewportmeta && /iPhone|iPad|iPod/.test(MBP.ua) && !/Opera Mini/.test(MBP.ua)) {
|
19
|
+
MBP.viewportmeta.content = 'width=device-width, minimum-scale=1.0, maximum-scale=1.0';
|
20
|
+
document.addEventListener('gesturestart', MBP.gestureStart, false);
|
21
|
+
}
|
22
|
+
};
|
23
|
+
|
24
|
+
MBP.gestureStart = function() {
|
25
|
+
MBP.viewportmeta.content = 'width=device-width, minimum-scale=0.25, maximum-scale=1.6';
|
26
|
+
};
|
27
|
+
|
28
|
+
/**
|
29
|
+
* Normalized hide address bar for iOS & Android
|
30
|
+
* (c) Scott Jehl, scottjehl.com
|
31
|
+
* MIT License
|
32
|
+
*/
|
33
|
+
|
34
|
+
// If we split this up into two functions we can reuse
|
35
|
+
// this function if we aren't doing full page reloads.
|
36
|
+
|
37
|
+
// If we cache this we don't need to re-calibrate everytime we call
|
38
|
+
// the hide url bar
|
39
|
+
MBP.BODY_SCROLL_TOP = false;
|
40
|
+
|
41
|
+
// So we don't redefine this function everytime we
|
42
|
+
// we call hideUrlBar
|
43
|
+
MBP.getScrollTop = function() {
|
44
|
+
var win = window;
|
45
|
+
var doc = document;
|
46
|
+
|
47
|
+
return win.pageYOffset || doc.compatMode === 'CSS1Compat' && doc.documentElement.scrollTop || doc.body.scrollTop || 0;
|
48
|
+
};
|
49
|
+
|
50
|
+
// It should be up to the mobile
|
51
|
+
MBP.hideUrlBar = function() {
|
52
|
+
var win = window;
|
53
|
+
|
54
|
+
// if there is a hash, or MBP.BODY_SCROLL_TOP hasn't been set yet, wait till that happens
|
55
|
+
if (!location.hash && MBP.BODY_SCROLL_TOP !== false) {
|
56
|
+
win.scrollTo( 0, MBP.BODY_SCROLL_TOP === 1 ? 0 : 1 );
|
57
|
+
}
|
58
|
+
};
|
59
|
+
|
60
|
+
MBP.hideUrlBarOnLoad = function() {
|
61
|
+
var win = window;
|
62
|
+
var doc = win.document;
|
63
|
+
var bodycheck;
|
64
|
+
|
65
|
+
// If there's a hash, or addEventListener is undefined, stop here
|
66
|
+
if ( !location.hash && win.addEventListener ) {
|
67
|
+
|
68
|
+
// scroll to 1
|
69
|
+
window.scrollTo( 0, 1 );
|
70
|
+
MBP.BODY_SCROLL_TOP = 1;
|
71
|
+
|
72
|
+
// reset to 0 on bodyready, if needed
|
73
|
+
bodycheck = setInterval(function() {
|
74
|
+
if ( doc.body ) {
|
75
|
+
clearInterval( bodycheck );
|
76
|
+
MBP.BODY_SCROLL_TOP = MBP.getScrollTop();
|
77
|
+
MBP.hideUrlBar();
|
78
|
+
}
|
79
|
+
}, 15 );
|
80
|
+
|
81
|
+
win.addEventListener('load', function() {
|
82
|
+
setTimeout(function() {
|
83
|
+
// at load, if user hasn't scrolled more than 20 or so...
|
84
|
+
if (MBP.getScrollTop() < 20) {
|
85
|
+
// reset to hide addr bar at onload
|
86
|
+
MBP.hideUrlBar();
|
87
|
+
}
|
88
|
+
}, 0);
|
89
|
+
});
|
90
|
+
}
|
91
|
+
};
|
92
|
+
|
93
|
+
/**
|
94
|
+
* Fast Buttons - read wiki below before using
|
95
|
+
* https://github.com/h5bp/mobile-boilerplate/wiki/JavaScript-Helper
|
96
|
+
*/
|
97
|
+
|
98
|
+
MBP.fastButton = function(element, handler, pressedClass) {
|
99
|
+
this.handler = handler;
|
100
|
+
// styling of .pressed is defined in the project's CSS files
|
101
|
+
this.pressedClass = typeof pressedClass === 'undefined' ? 'pressed' : pressedClass;
|
102
|
+
|
103
|
+
if (element.length && element.length > 1) {
|
104
|
+
for (var singleElIdx in element) {
|
105
|
+
this.addClickEvent(element[singleElIdx]);
|
106
|
+
}
|
107
|
+
} else {
|
108
|
+
this.addClickEvent(element);
|
109
|
+
}
|
110
|
+
};
|
111
|
+
|
112
|
+
MBP.fastButton.prototype.handleEvent = function(event) {
|
113
|
+
event = event || window.event;
|
114
|
+
|
115
|
+
switch (event.type) {
|
116
|
+
case 'touchstart': this.onTouchStart(event); break;
|
117
|
+
case 'touchmove': this.onTouchMove(event); break;
|
118
|
+
case 'touchend': this.onClick(event); break;
|
119
|
+
case 'click': this.onClick(event); break;
|
120
|
+
}
|
121
|
+
};
|
122
|
+
|
123
|
+
MBP.fastButton.prototype.onTouchStart = function(event) {
|
124
|
+
var element = event.target || event.srcElement;
|
125
|
+
event.stopPropagation();
|
126
|
+
element.addEventListener('touchend', this, false);
|
127
|
+
document.body.addEventListener('touchmove', this, false);
|
128
|
+
this.startX = event.touches[0].clientX;
|
129
|
+
this.startY = event.touches[0].clientY;
|
130
|
+
|
131
|
+
element.className+= ' ' + this.pressedClass;
|
132
|
+
};
|
133
|
+
|
134
|
+
MBP.fastButton.prototype.onTouchMove = function(event) {
|
135
|
+
if (Math.abs(event.touches[0].clientX - this.startX) > 10 ||
|
136
|
+
Math.abs(event.touches[0].clientY - this.startY) > 10) {
|
137
|
+
this.reset(event);
|
138
|
+
}
|
139
|
+
};
|
140
|
+
|
141
|
+
MBP.fastButton.prototype.onClick = function(event) {
|
142
|
+
event = event || window.event;
|
143
|
+
var element = event.target || event.srcElement;
|
144
|
+
if (event.stopPropagation) {
|
145
|
+
event.stopPropagation();
|
146
|
+
}
|
147
|
+
this.reset(event);
|
148
|
+
this.handler.apply(event.currentTarget, [event]);
|
149
|
+
if (event.type == 'touchend') {
|
150
|
+
MBP.preventGhostClick(this.startX, this.startY);
|
151
|
+
}
|
152
|
+
var pattern = new RegExp(' ?' + this.pressedClass, 'gi');
|
153
|
+
element.className = element.className.replace(pattern, '');
|
154
|
+
};
|
155
|
+
|
156
|
+
MBP.fastButton.prototype.reset = function(event) {
|
157
|
+
var element = event.target || event.srcElement;
|
158
|
+
rmEvt(element, 'touchend', this, false);
|
159
|
+
rmEvt(document.body, 'touchmove', this, false);
|
160
|
+
|
161
|
+
var pattern = new RegExp(' ?' + this.pressedClass, 'gi');
|
162
|
+
element.className = element.className.replace(pattern, '');
|
163
|
+
};
|
164
|
+
|
165
|
+
MBP.fastButton.prototype.addClickEvent = function(element) {
|
166
|
+
addEvt(element, 'touchstart', this, false);
|
167
|
+
addEvt(element, 'click', this, false);
|
168
|
+
};
|
169
|
+
|
170
|
+
MBP.preventGhostClick = function(x, y) {
|
171
|
+
MBP.coords.push(x, y);
|
172
|
+
window.setTimeout(function() {
|
173
|
+
MBP.coords.splice(0, 2);
|
174
|
+
}, 2500);
|
175
|
+
};
|
176
|
+
|
177
|
+
MBP.ghostClickHandler = function(event) {
|
178
|
+
if (!MBP.hadTouchEvent && MBP.dodgyAndroid) {
|
179
|
+
// This is a bit of fun for Android 2.3...
|
180
|
+
// If you change window.location via fastButton, a click event will fire
|
181
|
+
// on the new page, as if the events are continuing from the previous page.
|
182
|
+
// We pick that event up here, but MBP.coords is empty, because it's a new page,
|
183
|
+
// so we don't prevent it. Here's we're assuming that click events on touch devices
|
184
|
+
// that occur without a preceding touchStart are to be ignored.
|
185
|
+
event.stopPropagation();
|
186
|
+
event.preventDefault();
|
187
|
+
return;
|
188
|
+
}
|
189
|
+
for (var i = 0, len = MBP.coords.length; i < len; i += 2) {
|
190
|
+
var x = MBP.coords[i];
|
191
|
+
var y = MBP.coords[i + 1];
|
192
|
+
if (Math.abs(event.clientX - x) < 25 && Math.abs(event.clientY - y) < 25) {
|
193
|
+
event.stopPropagation();
|
194
|
+
event.preventDefault();
|
195
|
+
}
|
196
|
+
}
|
197
|
+
};
|
198
|
+
|
199
|
+
// This bug only affects touch Android 2.3 devices, but a simple ontouchstart test creates a false positive on
|
200
|
+
// some Blackberry devices. https://github.com/Modernizr/Modernizr/issues/372
|
201
|
+
// The browser sniffing is to avoid the Blackberry case. Bah
|
202
|
+
MBP.dodgyAndroid = ('ontouchstart' in window) && (navigator.userAgent.indexOf('Android 2.3') != -1);
|
203
|
+
|
204
|
+
if (document.addEventListener) {
|
205
|
+
document.addEventListener('click', MBP.ghostClickHandler, true);
|
206
|
+
}
|
207
|
+
|
208
|
+
addEvt(document.documentElement, 'touchstart', function() {
|
209
|
+
MBP.hadTouchEvent = true;
|
210
|
+
}, false);
|
211
|
+
|
212
|
+
MBP.coords = [];
|
213
|
+
|
214
|
+
// fn arg can be an object or a function, thanks to handleEvent
|
215
|
+
// read more about the explanation at: http://www.thecssninja.com/javascript/handleevent
|
216
|
+
function addEvt(el, evt, fn, bubble) {
|
217
|
+
if ('addEventListener' in el) {
|
218
|
+
// BBOS6 doesn't support handleEvent, catch and polyfill
|
219
|
+
try {
|
220
|
+
el.addEventListener(evt, fn, bubble);
|
221
|
+
} catch(e) {
|
222
|
+
if (typeof fn == 'object' && fn.handleEvent) {
|
223
|
+
el.addEventListener(evt, function(e){
|
224
|
+
// Bind fn as this and set first arg as event object
|
225
|
+
fn.handleEvent.call(fn,e);
|
226
|
+
}, bubble);
|
227
|
+
} else {
|
228
|
+
throw e;
|
229
|
+
}
|
230
|
+
}
|
231
|
+
} else if ('attachEvent' in el) {
|
232
|
+
// check if the callback is an object and contains handleEvent
|
233
|
+
if (typeof fn == 'object' && fn.handleEvent) {
|
234
|
+
el.attachEvent('on' + evt, function(){
|
235
|
+
// Bind fn as this
|
236
|
+
fn.handleEvent.call(fn);
|
237
|
+
});
|
238
|
+
} else {
|
239
|
+
el.attachEvent('on' + evt, fn);
|
240
|
+
}
|
241
|
+
}
|
242
|
+
}
|
243
|
+
|
244
|
+
function rmEvt(el, evt, fn, bubble) {
|
245
|
+
if ('removeEventListener' in el) {
|
246
|
+
// BBOS6 doesn't support handleEvent, catch and polyfill
|
247
|
+
try {
|
248
|
+
el.removeEventListener(evt, fn, bubble);
|
249
|
+
} catch(e) {
|
250
|
+
if (typeof fn == 'object' && fn.handleEvent) {
|
251
|
+
el.removeEventListener(evt, function(e){
|
252
|
+
// Bind fn as this and set first arg as event object
|
253
|
+
fn.handleEvent.call(fn,e);
|
254
|
+
}, bubble);
|
255
|
+
} else {
|
256
|
+
throw e;
|
257
|
+
}
|
258
|
+
}
|
259
|
+
} else if ('detachEvent' in el) {
|
260
|
+
// check if the callback is an object and contains handleEvent
|
261
|
+
if (typeof fn == 'object' && fn.handleEvent) {
|
262
|
+
el.detachEvent("on" + evt, function() {
|
263
|
+
// Bind fn as this
|
264
|
+
fn.handleEvent.call(fn);
|
265
|
+
});
|
266
|
+
} else {
|
267
|
+
el.detachEvent('on' + evt, fn);
|
268
|
+
}
|
269
|
+
}
|
270
|
+
}
|
271
|
+
|
272
|
+
/**
|
273
|
+
* Autogrow
|
274
|
+
* http://googlecode.blogspot.com/2009/07/gmail-for-mobile-html5-series.html
|
275
|
+
*/
|
276
|
+
|
277
|
+
MBP.autogrow = function(element, lh) {
|
278
|
+
function handler(e) {
|
279
|
+
var newHeight = this.scrollHeight;
|
280
|
+
var currentHeight = this.clientHeight;
|
281
|
+
if (newHeight > currentHeight) {
|
282
|
+
this.style.height = newHeight + 3 * textLineHeight + 'px';
|
283
|
+
}
|
284
|
+
}
|
285
|
+
|
286
|
+
var setLineHeight = (lh) ? lh : 12;
|
287
|
+
var textLineHeight = element.currentStyle ? element.currentStyle.lineHeight : getComputedStyle(element, null).lineHeight;
|
288
|
+
|
289
|
+
textLineHeight = (textLineHeight.indexOf('px') == -1) ? setLineHeight : parseInt(textLineHeight, 10);
|
290
|
+
|
291
|
+
element.style.overflow = 'hidden';
|
292
|
+
element.addEventListener ? element.addEventListener('input', handler, false) : element.attachEvent('onpropertychange', handler);
|
293
|
+
};
|
294
|
+
|
295
|
+
/**
|
296
|
+
* Enable CSS active pseudo styles in Mobile Safari
|
297
|
+
* http://alxgbsn.co.uk/2011/10/17/enable-css-active-pseudo-styles-in-mobile-safari/
|
298
|
+
*/
|
299
|
+
|
300
|
+
MBP.enableActive = function() {
|
301
|
+
document.addEventListener('touchstart', function() {}, false);
|
302
|
+
};
|
303
|
+
|
304
|
+
/**
|
305
|
+
* Prevent default scrolling on document window
|
306
|
+
*/
|
307
|
+
|
308
|
+
MBP.preventScrolling = function() {
|
309
|
+
document.addEventListener('touchmove', function(e) {
|
310
|
+
if (e.target.type === 'range') { return; }
|
311
|
+
e.preventDefault();
|
312
|
+
}, false);
|
313
|
+
};
|
314
|
+
|
315
|
+
/**
|
316
|
+
* Prevent iOS from zooming onfocus
|
317
|
+
* https://github.com/h5bp/mobile-boilerplate/pull/108
|
318
|
+
* Adapted from original jQuery code here: http://nerd.vasilis.nl/prevent-ios-from-zooming-onfocus/
|
319
|
+
*/
|
320
|
+
|
321
|
+
MBP.preventZoom = function() {
|
322
|
+
var formFields = document.querySelectorAll('input, select, textarea');
|
323
|
+
var contentString = 'width=device-width,initial-scale=1,maximum-scale=';
|
324
|
+
var i = 0;
|
325
|
+
|
326
|
+
for (i = 0; i < formFields.length; i++) {
|
327
|
+
formFields[i].onfocus = function() {
|
328
|
+
MBP.viewportmeta.content = contentString + '1';
|
329
|
+
};
|
330
|
+
formFields[i].onblur = function() {
|
331
|
+
MBP.viewportmeta.content = contentString + '10';
|
332
|
+
};
|
333
|
+
}
|
334
|
+
};
|
335
|
+
|
336
|
+
/**
|
337
|
+
* iOS Startup Image helper
|
338
|
+
*/
|
339
|
+
|
340
|
+
MBP.startupImage = function() {
|
341
|
+
var portrait;
|
342
|
+
var landscape;
|
343
|
+
var pixelRatio;
|
344
|
+
var head;
|
345
|
+
var link1;
|
346
|
+
var link2;
|
347
|
+
|
348
|
+
pixelRatio = window.devicePixelRatio;
|
349
|
+
head = document.getElementsByTagName('head')[0];
|
350
|
+
|
351
|
+
if (navigator.platform === 'iPad') {
|
352
|
+
portrait = pixelRatio === 2 ? 'img/startup/startup-tablet-portrait-retina.png' : 'img/startup/startup-tablet-portrait.png';
|
353
|
+
landscape = pixelRatio === 2 ? 'img/startup/startup-tablet-landscape-retina.png' : 'img/startup/startup-tablet-landscape.png';
|
354
|
+
|
355
|
+
link1 = document.createElement('link');
|
356
|
+
link1.setAttribute('rel', 'apple-touch-startup-image');
|
357
|
+
link1.setAttribute('media', 'screen and (orientation: portrait)');
|
358
|
+
link1.setAttribute('href', portrait);
|
359
|
+
head.appendChild(link1);
|
360
|
+
|
361
|
+
link2 = document.createElement('link');
|
362
|
+
link2.setAttribute('rel', 'apple-touch-startup-image');
|
363
|
+
link2.setAttribute('media', 'screen and (orientation: landscape)');
|
364
|
+
link2.setAttribute('href', landscape);
|
365
|
+
head.appendChild(link2);
|
366
|
+
} else {
|
367
|
+
portrait = pixelRatio === 2 ? "img/startup/startup-retina.png" : "img/startup/startup.png";
|
368
|
+
portrait = screen.height === 568 ? "img/startup/startup-retina-4in.png" : portrait;
|
369
|
+
link1 = document.createElement('link');
|
370
|
+
link1.setAttribute('rel', 'apple-touch-startup-image');
|
371
|
+
link1.setAttribute('href', portrait);
|
372
|
+
head.appendChild(link1);
|
373
|
+
}
|
374
|
+
|
375
|
+
//hack to fix letterboxed full screen web apps on 4" iPhone / iPod
|
376
|
+
if ((navigator.platform === 'iPhone' || 'iPod') && (screen.height === 568)) {
|
377
|
+
if (MBP.viewportmeta) {
|
378
|
+
MBP.viewportmeta.content = MBP.viewportmeta.content
|
379
|
+
.replace(/\bwidth\s*=\s*320\b/, 'width=320.1')
|
380
|
+
.replace(/\bwidth\s*=\s*device-width\b/, '');
|
381
|
+
}
|
382
|
+
}
|
383
|
+
};
|
384
|
+
|
385
|
+
})(document);
|