1/*! 2 * Mobiscroll v2.16.1 3 * http://mobiscroll.com 4 * 5 * Copyright 2010-2015, Acid Media 6 * Licensed under the MIT license. 7 * 8 */ 9(function ($, undefined) { 10 11 function testProps(props) { 12 var i; 13 for (i in props) { 14 if (mod[props[i]] !== undefined) { 15 return true; 16 } 17 } 18 return false; 19 } 20 21 function testPrefix() { 22 var prefixes = ['Webkit', 'Moz', 'O', 'ms'], 23 p; 24 25 for (p in prefixes) { 26 if (testProps([prefixes[p] + 'Transform'])) { 27 return '-' + prefixes[p].toLowerCase() + '-'; 28 } 29 } 30 return ''; 31 } 32 33 function init(that, options, args) { 34 var ret = that; 35 36 // Init 37 if (typeof options === 'object') { 38 return that.each(function () { 39 if (instances[this.id]) { 40 instances[this.id].destroy(); 41 } 42 new $.mobiscroll.classes[options.component || 'Scroller'](this, options); 43 }); 44 } 45 46 // Method call 47 if (typeof options === 'string') { 48 that.each(function () { 49 var r, 50 inst = instances[this.id]; 51 52 if (inst && inst[options]) { 53 r = inst[options].apply(this, Array.prototype.slice.call(args, 1)); 54 if (r !== undefined) { 55 ret = r; 56 return false; 57 } 58 } 59 }); 60 } 61 62 return ret; 63 } 64 65 var ms, 66 id = +new Date(), 67 instances = {}, 68 extend = $.extend, 69 mod = document.createElement('modernizr').style, 70 has3d = testProps(['perspectiveProperty', 'WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective']), 71 hasFlex = testProps(['flex', 'msFlex', 'WebkitBoxDirection']), 72 prefix = testPrefix(), 73 pr = prefix.replace(/^\-/, '').replace(/\-$/, '').replace('moz', 'Moz'); 74 75 $.fn.mobiscroll = function (method) { 76 extend(this, $.mobiscroll.components); 77 return init(this, method, arguments); 78 }; 79 80 ms = $.mobiscroll = $.mobiscroll || { 81 version: '2.16.1', 82 util: { 83 prefix: prefix, 84 jsPrefix: pr, 85 has3d: has3d, 86 hasFlex: hasFlex, 87 testTouch: function (e, elm) { 88 if (e.type == 'touchstart') { 89 $(elm).attr('data-touch', '1'); 90 } else if ($(elm).attr('data-touch')) { 91 $(elm).removeAttr('data-touch'); 92 return false; 93 } 94 return true; 95 }, 96 objectToArray: function (obj) { 97 var arr = [], 98 i; 99 100 for (i in obj) { 101 arr.push(obj[i]); 102 } 103 104 return arr; 105 }, 106 arrayToObject: function (arr) { 107 var obj = {}, 108 i; 109 110 if (arr) { 111 for (i = 0; i < arr.length; i++) { 112 obj[arr[i]] = arr[i]; 113 } 114 } 115 116 return obj; 117 }, 118 isNumeric: function (a) { 119 return a - parseFloat(a) >= 0; 120 }, 121 isString: function (s) { 122 return typeof s === 'string'; 123 }, 124 getCoord: function (e, c, client) { 125 var ev = e.originalEvent || e, 126 prop = (client ? 'client' : 'page') + c; 127 return ev.changedTouches ? ev.changedTouches[0][prop] : e[prop]; 128 }, 129 getPosition: function (t, vertical) { 130 var style = window.getComputedStyle ? getComputedStyle(t[0]) : t[0].style, 131 matrix, 132 px; 133 134 if (has3d) { 135 $.each(['t', 'webkitT', 'MozT', 'OT', 'msT'], function (i, v) { 136 if (style[v + 'ransform'] !== undefined) { 137 matrix = style[v + 'ransform']; 138 return false;
139 } 140 }); 141 matrix = matrix.split(')')[0].split(', '); 142 px = vertical ? (matrix[13] || matrix[5]) : (matrix[12] || matrix[4]); 143 } else { 144 px = vertical ? style.top.replace('px', '') : style.left.replace('px', ''); 145 } 146 147 return px; 148 }, 149 constrain: function (val, min, max) { 150 return Math.max(min, Math.min(val, max)); 151 }, 152 vibrate: function (time) { 153 if ('vibrate' in navigator) { 154 navigator.vibrate(time || 50); 155 } 156 } 157 }, 158 tapped: 0, 159 autoTheme: 'mobiscroll', 160 presets: { 161 scroller: {}, 162 numpad: {}, 163 listview: {}, 164 menustrip: {} 165 }, 166 themes: { 167 form: {}, 168 frame: {}, 169 listview: {}, 170 menustrip: {} 171 }, 172 i18n: {}, 173 instances: instances, 174 classes: {}, 175 components: {}, 176 defaults: { 177 context: 'body', 178 mousewheel: true, 179 vibrate: true 180 }, 181 setDefaults: function (o) { 182 extend(this.defaults, o); 183 }, 184 presetShort: function (name, c, p) { 185 this.components[name] = function (s) { 186 return init(this, extend(s, { 187 component: c, 188 preset: p === false ? undefined : name 189 }), arguments); 190 }; 191 } 192 }; 193 194 $.mobiscroll.classes.Base = function (el, settings) { 195 196 var lang, 197 preset, 198 s, 199 theme, 200 themeName, 201 defaults, 202 ms = $.mobiscroll, 203 that = this; 204 205 that.settings = {}; 206 207 that._presetLoad = function () {}; 208 209 that._init = function (ss) { 210 s = that.settings; 211 212 // Update original user settings 213 extend(settings, ss); 214 215 // Load user defaults 216 if (that._hasDef) { 217 defaults = ms.defaults; 218 } 219 220 // Create settings object 221 extend(s, that._defaults, defaults, settings); 222 223 // Get theme defaults 224 if (that._hasTheme) { 225 226 themeName = s.theme; 227 228 if (themeName == 'auto' || !themeName) { 229 themeName = ms.autoTheme; 230 } 231 232 if (themeName == 'default') { 233 themeName = 'mobiscroll'; 234 } 235 236 settings.theme = themeName; 237 238 theme = ms.themes[that._class][themeName]; 239 } 240 241 // Get language defaults 242 if (that._hasLang) { 243 lang = ms.i18n[s.lang]; 244 } 245 246 if (that._hasTheme) { 247 that.trigger('onThemeLoad', [lang, settings]); 248 } 249 250 // Update settings object 251 extend(s, theme, lang, defaults, settings); 252 253 // Load preset settings 254 if (that._hasPreset) { 255 256 that._presetLoad(s); 257 258 preset = ms.presets[that._class][s.preset]; 259 260 if (preset) { 261 preset = preset.call(el, that); 262 extend(s, preset, settings); 263 } 264 } 265 }; 266 267 that._destroy = function () { 268 that.trigger('onDestroy', []); 269 270 // Delete scroller instance 271 delete instances[el.id]; 272 273 that = null; 274 }; 275 276 /** 277 * Triggers an event 278 */ 279 that.trigger = function (name, args) { 280 var ret; 281 args.push(that); 282 $.each([defaults, theme, preset, settings], function (i, v) { 283 if (v && v[name]) { // Call preset event 284 ret = v[name].apply(el, args); 285 } 286 }); 287 return ret; 288 }; 289 290 /** 291 * Sets one ore more options. 292 */ 293 that.option = function (opt, value) { 294 var obj = {}; 295 if (typeof opt === 'object') { 296 obj = opt; 297 } else { 298 obj[opt] = value; 299 } 300 that.init(obj); 301 }; 302 303 /** 304 * Returns the mobiscroll instance. 305 */ 306 that.getInst = function () { 307 return that; 308 }; 309 310 settings = settings || {}; 311 312 // Autogenerate id 313 if (!el.id) { 314 el.id = 'mobiscroll' + (++id); 315 } 316 317 // Save instance
318 instances[el.id] = that; 319 }; 320 321 // Prevent standard behaviour on body click 322 function preventClick(ev) { 323 if (ms.tapped && !ev.tap) { 324 ev.stopPropagation(); 325 ev.preventDefault(); 326 return false; 327 } 328 } 329 330 if (document.addEventListener) { 331 $.each(['mouseover', 'mousedown', 'mouseup', 'click'], function (i, ev) { 332 document.addEventListener(ev, preventClick, true); 333 }); 334 } 335 336})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.