diff --git a/fangija-zsyf/js/light7-2.js b/fangija-zsyf/js/light7-2.js
new file mode 100644
index 0000000..891d41f
--- /dev/null
+++ b/fangija-zsyf/js/light7-2.js
@@ -0,0 +1,5474 @@
+/*!
+ * =====================================================
+ * light7 V0.4.3 - http://light7.org/
+ *
+ * =====================================================
+ */
+/* global $:true */
++function ($) {
+ "use strict";
+
+ //全局配置
+ var defaults = {
+ autoInit: false, //自动初始化页面
+ showPageLoadingIndicator: true, //push.js加载页面的时候显示一个加载提示
+ router: true, //默认使用router
+ swipePanel: "left", //滑动打开侧栏
+ swipePanelOnlyClose: false, //只允许滑动关闭,不允许滑动打开侧栏
+ pushAnimationDuration: 400 //不要动这个,这是解决安卓 animationEnd 事件无法触发的bug
+ };
+
+ $.smConfig = $.extend(defaults, $.config);
+
+}($);
+
+/*===========================
+Device/OS Detection
+===========================*/
+/* global $:true */
+;(function ($) {
+ "use strict";
+ var device = {};
+ var ua = navigator.userAgent;
+
+ var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/);
+ var ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
+ var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
+ var iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/);
+
+ device.ios = device.android = device.iphone = device.ipad = device.androidChrome = false;
+
+ // Android
+ if (android) {
+ device.os = 'android';
+ device.osVersion = android[2];
+ device.android = true;
+ device.androidChrome = ua.toLowerCase().indexOf('chrome') >= 0;
+ }
+ if (ipad || iphone || ipod) {
+ device.os = 'ios';
+ device.ios = true;
+ }
+ // iOS
+ if (iphone && !ipod) {
+ device.osVersion = iphone[2].replace(/_/g, '.');
+ device.iphone = true;
+ }
+ if (ipad) {
+ device.osVersion = ipad[2].replace(/_/g, '.');
+ device.ipad = true;
+ }
+ if (ipod) {
+ device.osVersion = ipod[3] ? ipod[3].replace(/_/g, '.') : null;
+ device.iphone = true;
+ }
+ // iOS 8+ changed UA
+ if (device.ios && device.osVersion && ua.indexOf('Version/') >= 0) {
+ if (device.osVersion.split('.')[0] === '10') {
+ device.osVersion = ua.toLowerCase().split('version/')[1].split(' ')[0];
+ }
+ }
+
+ // Webview
+ device.webView = (iphone || ipad || ipod) && ua.match(/.*AppleWebKit(?!.*Safari)/i);
+
+ // Minimal UI
+ if (device.os && device.os === 'ios') {
+ var osVersionArr = device.osVersion.split('.');
+ device.minimalUi = !device.webView &&
+ (ipod || iphone) &&
+ (osVersionArr[0] * 1 === 7 ? osVersionArr[1] * 1 >= 1 : osVersionArr[0] * 1 > 7) &&
+ $('meta[name="viewport"]').length > 0 && $('meta[name="viewport"]').attr('content').indexOf('minimal-ui') >= 0;
+ }
+
+ // Check for status bar and fullscreen app mode
+ var windowWidth = $(window).width();
+ var windowHeight = $(window).height();
+ device.statusBar = false;
+ if (device.webView && (windowWidth * windowHeight === screen.width * screen.height)) {
+ device.statusBar = true;
+ }
+ else {
+ device.statusBar = false;
+ }
+
+ // Classes
+ var classNames = [];
+
+ // Pixel Ratio
+ device.pixelRatio = window.devicePixelRatio || 1;
+ classNames.push('pixel-ratio-' + Math.floor(device.pixelRatio));
+ if (device.pixelRatio >= 2) {
+ classNames.push('retina');
+ }
+
+ // OS classes
+ if (device.os) {
+ classNames.push(device.os, device.os + '-' + device.osVersion.split('.')[0], device.os + '-' + device.osVersion.replace(/\./g, '-'));
+ if (device.os === 'ios') {
+ var major = parseInt(device.osVersion.split('.')[0], 10);
+ for (var i = major - 1; i >= 6; i--) {
+ classNames.push('ios-gt-' + i);
+ }
+ }
+
+ }
+ // Status bar classes
+ if (device.statusBar) {
+ classNames.push('with-statusbar-overlay');
+ }
+ else {
+ $('html').removeClass('with-statusbar-overlay');
+ }
+
+ // Add html classes
+ if (classNames.length > 0) $('html').addClass(classNames.join(' '));
+
+ $.device = device;
+})($);
+
+/* global $:true */
++ function($) {
+ "use strict";
+
+ //比较一个字符串版本号
+ //a > b === 1
+ //a = b === 0
+ //a < b === -1
+ $.compareVersion = function(a, b) {
+ var as = a.split('.');
+ var bs = b.split('.');
+ if (a === b) return 0;
+
+ for (var i = 0; i < as.length; i++) {
+ var x = parseInt(as[i]);
+ if (!bs[i]) return 1;
+ var y = parseInt(bs[i]);
+ if (x < y) return -1;
+ if (x > y) return 1;
+ }
+ return 1;
+ };
+
+ $.getTouchPosition = function(e) {
+ e = e.originalEvent || e; //jquery wrap the originevent
+ if(e.type === 'touchstart' || e.type === 'touchmove' || e.type === 'touchend') {
+ return {
+ x: e.targetTouches[0].pageX,
+ y: e.targetTouches[0].pageY
+ };
+ } else {
+ return {
+ x: e.pageX,
+ y: e.pageY
+ };
+ }
+ };
+
+}($);
+
+// Zepto.js
+// (c) 2010-2015 Thomas Fuchs
+// Zepto.js may be freely distributed under the MIT license.
++ function($) {
+ "use strict";
+ function detect(ua, platform) {
+ var os = this.os = {}, // jshint ignore:line
+ browser = this.browser = {},// jshint ignore:line
+ webkit = ua.match(/Web[kK]it[\/]{0,1}([\d.]+)/),
+ android = ua.match(/(Android);?[\s\/]+([\d.]+)?/),
+ osx = !!ua.match(/\(Macintosh\; Intel /),
+ ipad = ua.match(/(iPad).*OS\s([\d_]+)/),
+ ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/),
+ iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/),
+ webos = ua.match(/(webOS|hpwOS)[\s\/]([\d.]+)/),
+ win = /Win\d{2}|Windows/.test(platform),
+ wp = ua.match(/Windows Phone ([\d.]+)/),
+ touchpad = webos && ua.match(/TouchPad/),
+ kindle = ua.match(/Kindle\/([\d.]+)/),
+ silk = ua.match(/Silk\/([\d._]+)/),
+ blackberry = ua.match(/(BlackBerry).*Version\/([\d.]+)/),
+ bb10 = ua.match(/(BB10).*Version\/([\d.]+)/),
+ rimtabletos = ua.match(/(RIM\sTablet\sOS)\s([\d.]+)/),
+ playbook = ua.match(/PlayBook/),
+ chrome = ua.match(/Chrome\/([\d.]+)/) || ua.match(/CriOS\/([\d.]+)/),
+ firefox = ua.match(/Firefox\/([\d.]+)/),
+ firefoxos = ua.match(/\((?:Mobile|Tablet); rv:([\d.]+)\).*Firefox\/[\d.]+/),
+ ie = ua.match(/MSIE\s([\d.]+)/) || ua.match(/Trident\/[\d](?=[^\?]+).*rv:([0-9.].)/),
+ webview = !chrome && ua.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/),
+ safari = webview || ua.match(/Version\/([\d.]+)([^S](Safari)|[^M]*(Mobile)[^S]*(Safari))/);
+
+ // Todo: clean this up with a better OS/browser seperation:
+ // - discern (more) between multiple browsers on android
+ // - decide if kindle fire in silk mode is android or not
+ // - Firefox on Android doesn't specify the Android version
+ // - possibly devide in os, device and browser hashes
+
+ if (browser.webkit = !!webkit) browser.version = webkit[1]; // jshint ignore:line
+
+ if (android) os.android = true, os.version = android[2];
+ if (iphone && !ipod) os.ios = os.iphone = true, os.version = iphone[2].replace(/_/g, '.');
+ if (ipad) os.ios = os.ipad = true, os.version = ipad[2].replace(/_/g, '.');
+ if (ipod) os.ios = os.ipod = true, os.version = ipod[3] ? ipod[3].replace(/_/g, '.') : null;
+ if (wp) os.wp = true, os.version = wp[1];
+ if (webos) os.webos = true, os.version = webos[2];
+ if (touchpad) os.touchpad = true;
+ if (blackberry) os.blackberry = true, os.version = blackberry[2];
+ if (bb10) os.bb10 = true, os.version = bb10[2];
+ if (rimtabletos) os.rimtabletos = true, os.version = rimtabletos[2];
+ if (playbook) browser.playbook = true;
+ if (kindle) os.kindle = true, os.version = kindle[1];
+ if (silk) browser.silk = true, browser.version = silk[1];
+ if (!silk && os.android && ua.match(/Kindle Fire/)) browser.silk = true;
+ if (chrome) browser.chrome = true, browser.version = chrome[1];
+ if (firefox) browser.firefox = true, browser.version = firefox[1];
+ if (firefoxos) os.firefoxos = true, os.version = firefoxos[1];
+ if (ie) browser.ie = true, browser.version = ie[1];
+ if (safari && (osx || os.ios || win)) {
+ browser.safari = true;
+ if (!os.ios) browser.version = safari[1];
+ }
+ if (webview) browser.webview = true;
+
+ os.tablet = !!(ipad || playbook || (android && !ua.match(/Mobile/)) ||
+ (firefox && ua.match(/Tablet/)) || (ie && !ua.match(/Phone/) && ua.match(/Touch/)));
+ os.phone = !!(!os.tablet && !os.ipod && (android || iphone || webos || blackberry || bb10 ||
+ (chrome && ua.match(/Android/)) || (chrome && ua.match(/CriOS\/([\d.]+)/)) ||
+ (firefox && ua.match(/Mobile/)) || (ie && ua.match(/Touch/))));
+ }
+
+ detect.call($, navigator.userAgent, navigator.platform);
+ // make available to unit tests
+ $.__detect = detect;
+
+}($); // jshint ignore:line
+
+/* global $:true */
+/* global WebKitCSSMatrix:true */
+
+(function($) {
+ "use strict";
+ ['width', 'height'].forEach(function(dimension) {
+ var Dimension = dimension.replace(/./, function(m) {
+ return m[0].toUpperCase();
+ });
+ $.fn['outer' + Dimension] = function(margin) {
+ var elem = this;
+ if (elem) {
+ var size = elem[dimension]();
+ var sides = {
+ 'width': ['left', 'right'],
+ 'height': ['top', 'bottom']
+ };
+ sides[dimension].forEach(function(side) {
+ if (margin) size += parseInt(elem.css('margin-' + side), 10);
+ });
+ return size;
+ } else {
+ return null;
+ }
+ };
+ });
+
+ $.noop = function() {};
+
+ //support
+ $.support = (function() {
+ var support = {
+ touch: !!(('ontouchstart' in window) || window.DocumentTouch && document instanceof window.DocumentTouch)
+ };
+ return support;
+ })();
+
+ $.touchEvents = {
+ start: $.support.touch ? 'touchstart' : 'mousedown',
+ move: $.support.touch ? 'touchmove' : 'mousemove',
+ end: $.support.touch ? 'touchend' : 'mouseup'
+ };
+
+ $.getTranslate = function (el, axis) {
+ var matrix, curTransform, curStyle, transformMatrix;
+
+ // automatic axis detection
+ if (typeof axis === 'undefined') {
+ axis = 'x';
+ }
+
+ curStyle = window.getComputedStyle(el, null);
+ if (window.WebKitCSSMatrix) {
+ // Some old versions of Webkit choke when 'none' is passed; pass
+ // empty string instead in this case
+ transformMatrix = new WebKitCSSMatrix(curStyle.webkitTransform === 'none' ? '' : curStyle.webkitTransform);
+ }
+ else {
+ transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,');
+ matrix = transformMatrix.toString().split(',');
+ }
+
+ if (axis === 'x') {
+ //Latest Chrome and webkits Fix
+ if (window.WebKitCSSMatrix)
+ curTransform = transformMatrix.m41;
+ //Crazy IE10 Matrix
+ else if (matrix.length === 16)
+ curTransform = parseFloat(matrix[12]);
+ //Normal Browsers
+ else
+ curTransform = parseFloat(matrix[4]);
+ }
+ if (axis === 'y') {
+ //Latest Chrome and webkits Fix
+ if (window.WebKitCSSMatrix)
+ curTransform = transformMatrix.m42;
+ //Crazy IE10 Matrix
+ else if (matrix.length === 16)
+ curTransform = parseFloat(matrix[13]);
+ //Normal Browsers
+ else
+ curTransform = parseFloat(matrix[5]);
+ }
+
+ return curTransform || 0;
+ };
+ $.requestAnimationFrame = function (callback) {
+ if (window.requestAnimationFrame) return window.requestAnimationFrame(callback);
+ else if (window.webkitRequestAnimationFrame) return window.webkitRequestAnimationFrame(callback);
+ else if (window.mozRequestAnimationFrame) return window.mozRequestAnimationFrame(callback);
+ else {
+ return window.setTimeout(callback, 1000 / 60);
+ }
+ };
+
+ $.cancelAnimationFrame = function (id) {
+ if (window.cancelAnimationFrame) return window.cancelAnimationFrame(id);
+ else if (window.webkitCancelAnimationFrame) return window.webkitCancelAnimationFrame(id);
+ else if (window.mozCancelAnimationFrame) return window.mozCancelAnimationFrame(id);
+ else {
+ return window.clearTimeout(id);
+ }
+ };
+
+
+ $.fn.transitionEnd = function(callback) {
+ var events = ['webkitTransitionEnd', 'transitionend', 'oTransitionEnd', 'MSTransitionEnd', 'msTransitionEnd'],
+ i, dom = this;
+
+ function fireCallBack(e) {
+ /*jshint validthis:true */
+ if (e.target !== this) return;
+ callback.call(this, e);
+ for (i = 0; i < events.length; i++) {
+ dom.off(events[i], fireCallBack);
+ }
+ }
+ if (callback) {
+ for (i = 0; i < events.length; i++) {
+ dom.on(events[i], fireCallBack);
+ }
+ }
+ return this;
+ };
+ $.fn.dataset = function() {
+ var el = this[0];
+ if (el) {
+ var dataset = {};
+ if (el.dataset) {
+
+ for (var dataKey in el.dataset) { // jshint ignore:line
+ dataset[dataKey] = el.dataset[dataKey];
+ }
+ } else {
+ for (var i = 0; i < el.attributes.length; i++) {
+ var attr = el.attributes[i];
+ if (attr.name.indexOf('data-') >= 0) {
+ dataset[$.toCamelCase(attr.name.split('data-')[1])] = attr.value;
+ }
+ }
+ }
+ for (var key in dataset) {
+ if (dataset[key] === 'false') dataset[key] = false;
+ else if (dataset[key] === 'true') dataset[key] = true;
+ else if (parseFloat(dataset[key]) === dataset[key] * 1) dataset[key] = dataset[key] * 1;
+ }
+ return dataset;
+ } else return undefined;
+ };
+ $.fn.data = function(key, value) {
+ if (typeof value === 'undefined') {
+ // Get value
+ if (this[0] && this[0].getAttribute) {
+ var dataKey = this[0].getAttribute('data-' + key);
+
+ if (dataKey) {
+ return dataKey;
+ } else if (this[0].smElementDataStorage && (key in this[0].smElementDataStorage)) {
+
+
+ return this[0].smElementDataStorage[key];
+
+ } else {
+ return undefined;
+ }
+ } else return undefined;
+
+ } else {
+ // Set value
+ for (var i = 0; i < this.length; i++) {
+ var el = this[i];
+ if (!el.smElementDataStorage) el.smElementDataStorage = {};
+ el.smElementDataStorage[key] = value;
+ }
+ return this;
+ }
+ };
+ $.fn.animationEnd = function(callback) {
+ var events = ['webkitAnimationEnd', 'OAnimationEnd', 'MSAnimationEnd', 'animationend'],
+ i, dom = this;
+
+ function fireCallBack(e) {
+ callback(e);
+ for (i = 0; i < events.length; i++) {
+ dom.off(events[i], fireCallBack);
+ }
+ }
+ if (callback) {
+ for (i = 0; i < events.length; i++) {
+ dom.on(events[i], fireCallBack);
+ }
+ }
+ return this;
+ };
+ $.fn.transition = function(duration) {
+ if (typeof duration !== 'string') {
+ duration = duration + 'ms';
+ }
+ for (var i = 0; i < this.length; i++) {
+ var elStyle = this[i].style;
+ elStyle.webkitTransitionDuration = elStyle.MsTransitionDuration = elStyle.msTransitionDuration = elStyle.MozTransitionDuration = elStyle.OTransitionDuration = elStyle.transitionDuration = duration;
+ }
+ return this;
+ };
+ $.fn.transform = function(transform) {
+ for (var i = 0; i < this.length; i++) {
+ var elStyle = this[i].style;
+ elStyle.webkitTransform = elStyle.MsTransform = elStyle.msTransform = elStyle.MozTransform = elStyle.OTransform = elStyle.transform = transform;
+ }
+ return this;
+ };
+ $.fn.prevAll = function (selector) {
+ var prevEls = [];
+ var el = this[0];
+ if (!el) return $([]);
+ while (el.previousElementSibling) {
+ var prev = el.previousElementSibling;
+ if (selector) {
+ if($(prev).is(selector)) prevEls.push(prev);
+ }
+ else prevEls.push(prev);
+ el = prev;
+ }
+ return $(prevEls);
+ };
+ $.fn.nextAll = function (selector) {
+ var nextEls = [];
+ var el = this[0];
+ if (!el) return $([]);
+ while (el.nextElementSibling) {
+ var next = el.nextElementSibling;
+ if (selector) {
+ if($(next).is(selector)) nextEls.push(next);
+ }
+ else nextEls.push(next);
+ el = next;
+ }
+ return $(nextEls);
+ };
+
+ //重置zepto的show方法,防止有些人引用的版本中 show 方法操作 opacity 属性影响动画执行
+ $.fn.show = function(){
+ var elementDisplay = {};
+ function defaultDisplay(nodeName) {
+ var element, display;
+ if (!elementDisplay[nodeName]) {
+ element = document.createElement(nodeName);
+ document.body.appendChild(element);
+ display = getComputedStyle(element, '').getPropertyValue("display");
+ element.parentNode.removeChild(element);
+ display === "none" && (display = "block");
+ elementDisplay[nodeName] = display;
+ }
+ return elementDisplay[nodeName];
+ }
+
+ return this.each(function(){
+ this.style.display === "none" && (this.style.display = '');
+ if (getComputedStyle(this, '').getPropertyValue("display") === "none");
+ this.style.display = defaultDisplay(this.nodeName);
+ });
+ };
+
+ $.fn.scrollHeight = function() {
+ return this[0].scrollHeight;
+ };
+})($);
+
+/* global $:true */
+;(function ($) {
+ 'use strict';
+
+ /**
+ * @preserve FastClick: polyfill to remove click delays on browsers with touch UIs.
+ *
+ * @codingstandard ftlabs-jsv2
+ * @copyright The Financial Times Limited [All Rights Reserved]
+ * @license MIT License (see LICENSE.txt)
+ */
+
+ /*jslint browser:true, node:true, elision:true*/
+ /*global Event, Node*/
+
+
+ /**
+ * Instantiate fast-clicking listeners on the specified layer.
+ *
+ * @constructor
+ * @param {Element} layer The layer to listen on
+ * @param {Object} [options={}] The options to override the defaults
+ */
+ function FastClick(layer, options) {
+ var oldOnClick;
+
+ options = options || {};
+
+ /**
+ * Whether a click is currently being tracked.
+ *
+ * @type boolean
+ */
+ this.trackingClick = false;
+
+
+ /**
+ * Timestamp for when click tracking started.
+ *
+ * @type number
+ */
+ this.trackingClickStart = 0;
+
+
+ /**
+ * The element being tracked for a click.
+ *
+ * @type EventTarget
+ */
+ this.targetElement = null;
+
+
+ /**
+ * X-coordinate of touch start event.
+ *
+ * @type number
+ */
+ this.touchStartX = 0;
+
+
+ /**
+ * Y-coordinate of touch start event.
+ *
+ * @type number
+ */
+ this.touchStartY = 0;
+
+
+ /**
+ * ID of the last touch, retrieved from Touch.identifier.
+ *
+ * @type number
+ */
+ this.lastTouchIdentifier = 0;
+
+
+ /**
+ * Touchmove boundary, beyond which a click will be cancelled.
+ *
+ * @type number
+ */
+ this.touchBoundary = options.touchBoundary || 10;
+
+
+ /**
+ * The FastClick layer.
+ *
+ * @type Element
+ */
+ this.layer = layer;
+
+ /**
+ * The minimum time between tap(touchstart and touchend) events
+ *
+ * @type number
+ */
+ this.tapDelay = options.tapDelay || 200;
+
+ /**
+ * The maximum time for a tap
+ *
+ * @type number
+ */
+ this.tapTimeout = options.tapTimeout || 700;
+
+ if (FastClick.notNeeded(layer)) {
+ return;
+ }
+
+ // Some old versions of Android don't have Function.prototype.bind
+ function bind(method, context) {
+ return function() { return method.apply(context, arguments); };
+ }
+
+
+ var methods = ['onMouse', 'onClick', 'onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'];
+ var context = this;
+ for (var i = 0, l = methods.length; i < l; i++) {
+ context[methods[i]] = bind(context[methods[i]], context);
+ }
+
+ // Set up event handlers as required
+ if (deviceIsAndroid) {
+ layer.addEventListener('mouseover', this.onMouse, true);
+ layer.addEventListener('mousedown', this.onMouse, true);
+ layer.addEventListener('mouseup', this.onMouse, true);
+ }
+
+ layer.addEventListener('click', this.onClick, true);
+ layer.addEventListener('touchstart', this.onTouchStart, false);
+ layer.addEventListener('touchmove', this.onTouchMove, false);
+ layer.addEventListener('touchend', this.onTouchEnd, false);
+ layer.addEventListener('touchcancel', this.onTouchCancel, false);
+
+ // Hack is required for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2)
+ // which is how FastClick normally stops click events bubbling to callbacks registered on the FastClick
+ // layer when they are cancelled.
+ if (!Event.prototype.stopImmediatePropagation) {
+ layer.removeEventListener = function(type, callback, capture) {
+ var rmv = Node.prototype.removeEventListener;
+ if (type === 'click') {
+ rmv.call(layer, type, callback.hijacked || callback, capture);
+ } else {
+ rmv.call(layer, type, callback, capture);
+ }
+ };
+
+ layer.addEventListener = function(type, callback, capture) {
+ var adv = Node.prototype.addEventListener;
+ if (type === 'click') {
+ adv.call(layer, type, callback.hijacked || (callback.hijacked = function(event) {
+ if (!event.propagationStopped) {
+ callback(event);
+ }
+ }), capture);
+ } else {
+ adv.call(layer, type, callback, capture);
+ }
+ };
+ }
+
+ // If a handler is already declared in the element's onclick attribute, it will be fired before
+ // FastClick's onClick handler. Fix this by pulling out the user-defined handler function and
+ // adding it as listener.
+ if (typeof layer.onclick === 'function') {
+
+ // Android browser on at least 3.2 requires a new reference to the function in layer.onclick
+ // - the old one won't work if passed to addEventListener directly.
+ oldOnClick = layer.onclick;
+ layer.addEventListener('click', function(event) {
+ oldOnClick(event);
+ }, false);
+ layer.onclick = null;
+ }
+ }
+
+ /**
+ * Windows Phone 8.1 fakes user agent string to look like Android and iPhone.
+ *
+ * @type boolean
+ */
+ var deviceIsWindowsPhone = navigator.userAgent.indexOf("Windows Phone") >= 0;
+
+ /**
+ * Android requires exceptions.
+ *
+ * @type boolean
+ */
+ var deviceIsAndroid = navigator.userAgent.indexOf('Android') > 0 && !deviceIsWindowsPhone;
+
+
+ /**
+ * iOS requires exceptions.
+ *
+ * @type boolean
+ */
+ var deviceIsIOS = /iP(ad|hone|od)/.test(navigator.userAgent) && !deviceIsWindowsPhone;
+
+
+ /**
+ * iOS 4 requires an exception for select elements.
+ *
+ * @type boolean
+ */
+ var deviceIsIOS4 = deviceIsIOS && (/OS 4_\d(_\d)?/).test(navigator.userAgent);
+
+
+ /**
+ * iOS 6.0-7.* requires the target element to be manually derived
+ *
+ * @type boolean
+ */
+ var deviceIsIOSWithBadTarget = deviceIsIOS && (/OS [6-7]_\d/).test(navigator.userAgent);
+
+ /**
+ * BlackBerry requires exceptions.
+ *
+ * @type boolean
+ */
+ var deviceIsBlackBerry10 = navigator.userAgent.indexOf('BB10') > 0;
+
+ /**
+ * Determine whether a given element requires a native click.
+ *
+ * @param {EventTarget|Element} target Target DOM element
+ * @returns {boolean} Returns true if the element needs a native click
+ */
+ FastClick.prototype.needsClick = function(target) {
+
+ switch (target.nodeName.toLowerCase()) {
+
+ // Don't send a synthetic click to disabled inputs (issue #62)
+ case 'button':
+ case 'select':
+ case 'textarea':
+ if (target.disabled) {
+ return true;
+ }
+
+ break;
+ case 'input':
+
+ // File inputs need real clicks on iOS 6 due to a browser bug (issue #68)
+ if ((deviceIsIOS && target.type === 'file') || target.disabled) {
+ return true;
+ }
+
+ break;
+ case 'label':
+ case 'iframe': // iOS8 homescreen apps can prevent events bubbling into frames
+ case 'video':
+ return true;
+ default:
+ }
+
+
+
+
+ return (/\bneedsclick\b/).test(target.className);
+ };
+
+
+ /**
+ * Determine whether a given element requires a call to focus to simulate click into element.
+ *
+ * @param {EventTarget|Element} target Target DOM element
+ * @returns {boolean} Returns true if the element requires a call to focus to simulate native click.
+ */
+ FastClick.prototype.needsFocus = function(target) {
+ switch (target.nodeName.toLowerCase()) {
+ case 'textarea':
+ return true;
+ case 'select':
+ return !deviceIsAndroid;
+ case 'input':
+ switch (target.type) {
+ case 'button':
+ case 'checkbox':
+ case 'file':
+ case 'image':
+ case 'radio':
+ case 'submit':
+ return false;
+ }
+
+ // No point in attempting to focus disabled inputs
+ return !target.disabled && !target.readOnly;
+ default:
+ return (/\bneedsfocus\b/).test(target.className);
+ }
+ };
+
+
+ /**
+ * Send a click event to the specified element.
+ *
+ * @param {EventTarget|Element} targetElement
+ * @param {Event} event
+ */
+ FastClick.prototype.sendClick = function(targetElement, event) {
+ var clickEvent, touch;
+
+ // On some Android devices activeElement needs to be blurred otherwise the synthetic click will have no effect (#24)
+ if (document.activeElement && document.activeElement !== targetElement) {
+ document.activeElement.blur();
+ }
+
+ touch = event.changedTouches[0];
+
+ // Synthesise a click event, with an extra attribute so it can be tracked
+ clickEvent = document.createEvent('MouseEvents');
+ clickEvent.initMouseEvent(this.determineEventType(targetElement), true, true, window, 1, touch.screenX, touch.screenY, touch.clientX, touch.clientY, false, false, false, false, 0, null);
+ clickEvent.forwardedTouchEvent = true;
+ targetElement.dispatchEvent(clickEvent);
+ };
+
+ FastClick.prototype.determineEventType = function(targetElement) {
+
+ //Issue #159: Android Chrome Select Box does not open with a synthetic click event
+ if (deviceIsAndroid && targetElement.tagName.toLowerCase() === 'select') {
+ return 'mousedown';
+ }
+
+ return 'click';
+ };
+
+
+ /**
+ * @param {EventTarget|Element} targetElement
+ */
+ FastClick.prototype.focus = function(targetElement) {
+ var length;
+
+ // Issue #160: on iOS 7, some input elements (e.g. date datetime month) throw a vague TypeError on setSelectionRange. These elements don't have an integer value for the selectionStart and selectionEnd properties, but unfortunately that can't be used for detection because accessing the properties also throws a TypeError. Just check the type instead. Filed as Apple bug #15122724.
+ if (deviceIsIOS && targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time' && targetElement.type !== 'month') {
+ length = targetElement.value.length;
+ targetElement.setSelectionRange(length, length);
+ } else {
+ targetElement.focus();
+ }
+ };
+
+
+ /**
+ * Check whether the given target element is a child of a scrollable layer and if so, set a flag on it.
+ *
+ * @param {EventTarget|Element} targetElement
+ */
+ FastClick.prototype.updateScrollParent = function(targetElement) {
+ var scrollParent, parentElement;
+
+ scrollParent = targetElement.fastClickScrollParent;
+
+ // Attempt to discover whether the target element is contained within a scrollable layer. Re-check if the
+ // target element was moved to another parent.
+ if (!scrollParent || !scrollParent.contains(targetElement)) {
+ parentElement = targetElement;
+ do {
+ if (parentElement.scrollHeight > parentElement.offsetHeight) {
+ scrollParent = parentElement;
+ targetElement.fastClickScrollParent = parentElement;
+ break;
+ }
+
+ parentElement = parentElement.parentElement;
+ } while (parentElement);
+ }
+
+ // Always update the scroll top tracker if possible.
+ if (scrollParent) {
+ scrollParent.fastClickLastScrollTop = scrollParent.scrollTop;
+ }
+ };
+
+
+ /**
+ * @param {EventTarget} targetElement
+ * @returns {Element|EventTarget}
+ */
+ FastClick.prototype.getTargetElementFromEventTarget = function(eventTarget) {
+
+ // On some older browsers (notably Safari on iOS 4.1 - see issue #56) the event target may be a text node.
+ if (eventTarget.nodeType === Node.TEXT_NODE) {
+ return eventTarget.parentNode;
+ }
+
+ return eventTarget;
+ };
+
+
+ /**
+ * On touch start, record the position and scroll offset.
+ *
+ * @param {Event} event
+ * @returns {boolean}
+ */
+ FastClick.prototype.onTouchStart = function(event) {
+ var targetElement, touch, selection;
+
+ // Ignore multiple touches, otherwise pinch-to-zoom is prevented if both fingers are on the FastClick element (issue #111).
+ if (event.targetTouches.length > 1) {
+ return true;
+ }
+
+ targetElement = this.getTargetElementFromEventTarget(event.target);
+ touch = event.targetTouches[0];
+
+ if (deviceIsIOS) {
+
+ // Only trusted events will deselect text on iOS (issue #49)
+ selection = window.getSelection();
+ if (selection.rangeCount && !selection.isCollapsed) {
+ return true;
+ }
+
+ if (!deviceIsIOS4) {
+
+ // Weird things happen on iOS when an alert or confirm dialog is opened from a click event callback (issue #23):
+ // when the user next taps anywhere else on the page, new touchstart and touchend events are dispatched
+ // with the same identifier as the touch event that previously triggered the click that triggered the alert.
+ // Sadly, there is an issue on iOS 4 that causes some normal touch events to have the same identifier as an
+ // immediately preceeding touch event (issue #52), so this fix is unavailable on that platform.
+ // Issue 120: touch.identifier is 0 when Chrome dev tools 'Emulate touch events' is set with an iOS device UA string,
+ // which causes all touch events to be ignored. As this block only applies to iOS, and iOS identifiers are always long,
+ // random integers, it's safe to to continue if the identifier is 0 here.
+ if (touch.identifier && touch.identifier === this.lastTouchIdentifier) {
+ event.preventDefault();
+ return false;
+ }
+
+ this.lastTouchIdentifier = touch.identifier;
+
+ // If the target element is a child of a scrollable layer (using -webkit-overflow-scrolling: touch) and:
+ // 1) the user does a fling scroll on the scrollable layer
+ // 2) the user stops the fling scroll with another tap
+ // then the event.target of the last 'touchend' event will be the element that was under the user's finger
+ // when the fling scroll was started, causing FastClick to send a click event to that layer - unless a check
+ // is made to ensure that a parent layer was not scrolled before sending a synthetic click (issue #42).
+ this.updateScrollParent(targetElement);
+ }
+ }
+
+ this.trackingClick = true;
+ this.trackingClickStart = event.timeStamp;
+ this.targetElement = targetElement;
+
+ this.touchStartX = touch.pageX;
+ this.touchStartY = touch.pageY;
+
+ // Prevent phantom clicks on fast double-tap (issue #36)
+ if ((event.timeStamp - this.lastClickTime) < this.tapDelay) {
+ event.preventDefault();
+ }
+
+ return true;
+ };
+
+
+ /**
+ * Based on a touchmove event object, check whether the touch has moved past a boundary since it started.
+ *
+ * @param {Event} event
+ * @returns {boolean}
+ */
+ FastClick.prototype.touchHasMoved = function(event) {
+ var touch = event.changedTouches[0], boundary = this.touchBoundary;
+
+ if (Math.abs(touch.pageX - this.touchStartX) > boundary || Math.abs(touch.pageY - this.touchStartY) > boundary) {
+ return true;
+ }
+
+ return false;
+ };
+
+
+ /**
+ * Update the last position.
+ *
+ * @param {Event} event
+ * @returns {boolean}
+ */
+ FastClick.prototype.onTouchMove = function(event) {
+ if (!this.trackingClick) {
+ return true;
+ }
+
+ // If the touch has moved, cancel the click tracking
+ if (this.targetElement !== this.getTargetElementFromEventTarget(event.target) || this.touchHasMoved(event)) {
+ this.trackingClick = false;
+ this.targetElement = null;
+ }
+
+ return true;
+ };
+
+
+ /**
+ * Attempt to find the labelled control for the given label element.
+ *
+ * @param {EventTarget|HTMLLabelElement} labelElement
+ * @returns {Element|null}
+ */
+ FastClick.prototype.findControl = function(labelElement) {
+
+ // Fast path for newer browsers supporting the HTML5 control attribute
+ if (labelElement.control !== undefined) {
+ return labelElement.control;
+ }
+
+ // All browsers under test that support touch events also support the HTML5 htmlFor attribute
+ if (labelElement.htmlFor) {
+ return document.getElementById(labelElement.htmlFor);
+ }
+
+ // If no for attribute exists, attempt to retrieve the first labellable descendant element
+ // the list of which is defined here: http://www.w3.org/TR/html5/forms.html#category-label
+ return labelElement.querySelector('button, input:not([type=hidden]), keygen, meter, output, progress, select, textarea');
+ };
+
+
+ /**
+ * On touch end, determine whether to send a click event at once.
+ *
+ * @param {Event} event
+ * @returns {boolean}
+ */
+ FastClick.prototype.onTouchEnd = function(event) {
+ var forElement, trackingClickStart, targetTagName, scrollParent, touch, targetElement = this.targetElement;
+
+ if (!this.trackingClick) {
+ return true;
+ }
+
+ // Prevent phantom clicks on fast double-tap (issue #36)
+ if ((event.timeStamp - this.lastClickTime) < this.tapDelay) {
+ this.cancelNextClick = true;
+ return true;
+ }
+
+ if ((event.timeStamp - this.trackingClickStart) > this.tapTimeout) {
+ return true;
+ }
+
+ // Reset to prevent wrong click cancel on input (issue #156).
+ this.cancelNextClick = false;
+
+ this.lastClickTime = event.timeStamp;
+
+ trackingClickStart = this.trackingClickStart;
+ this.trackingClick = false;
+ this.trackingClickStart = 0;
+
+ // On some iOS devices, the targetElement supplied with the event is invalid if the layer
+ // is performing a transition or scroll, and has to be re-detected manually. Note that
+ // for this to function correctly, it must be called *after* the event target is checked!
+ // See issue #57; also filed as rdar://13048589 .
+ if (deviceIsIOSWithBadTarget) {
+ touch = event.changedTouches[0];
+
+ // In certain cases arguments of elementFromPoint can be negative, so prevent setting targetElement to null
+ targetElement = document.elementFromPoint(touch.pageX - window.pageXOffset, touch.pageY - window.pageYOffset) || targetElement;
+ targetElement.fastClickScrollParent = this.targetElement.fastClickScrollParent;
+ }
+
+ targetTagName = targetElement.tagName.toLowerCase();
+ if (targetTagName === 'label') {
+ forElement = this.findControl(targetElement);
+ if (forElement) {
+ this.focus(targetElement);
+ if (deviceIsAndroid) {
+ return false;
+ }
+
+ targetElement = forElement;
+ }
+ } else if (this.needsFocus(targetElement)) {
+
+ // Case 1: If the touch started a while ago (best guess is 100ms based on tests for issue #36) then focus will be triggered anyway. Return early and unset the target element reference so that the subsequent click will be allowed through.
+ // Case 2: Without this exception for input elements tapped when the document is contained in an iframe, then any inputted text won't be visible even though the value attribute is updated as the user types (issue #37).
+ if ((event.timeStamp - trackingClickStart) > 100 || (deviceIsIOS && window.top !== window && targetTagName === 'input')) {
+ this.targetElement = null;
+ return false;
+ }
+
+ this.focus(targetElement);
+ this.sendClick(targetElement, event);
+
+ // Select elements need the event to go through on iOS 4, otherwise the selector menu won't open.
+ // Also this breaks opening selects when VoiceOver is active on iOS6, iOS7 (and possibly others)
+ if (!deviceIsIOS || targetTagName !== 'select') {
+ this.targetElement = null;
+ event.preventDefault();
+ }
+
+ return false;
+ } else {
+ var parent = targetElement;
+ while(parent && (parent.tagName.toUpperCase() !== "BODY")) {
+ if(parent.tagName.toUpperCase() === "LABEL") {
+ $(parent).find("input").click();
+ }
+ parent = parent.parentNode;
+ }
+ }
+
+ if (deviceIsIOS && !deviceIsIOS4) {
+
+ // Don't send a synthetic click event if the target element is contained within a parent layer that was scrolled
+ // and this tap is being used to stop the scrolling (usually initiated by a fling - issue #42).
+ scrollParent = targetElement.fastClickScrollParent;
+ if (scrollParent && scrollParent.fastClickLastScrollTop !== scrollParent.scrollTop) {
+ return true;
+ }
+ }
+
+ // Prevent the actual click from going though - unless the target node is marked as requiring
+ // real clicks or if it is in the whitelist in which case only non-programmatic clicks are permitted.
+ if (!this.needsClick(targetElement)) {
+ event.preventDefault();
+ this.sendClick(targetElement, event);
+ }
+
+ return false;
+ };
+
+
+ /**
+ * On touch cancel, stop tracking the click.
+ *
+ * @returns {void}
+ */
+ FastClick.prototype.onTouchCancel = function() {
+ this.trackingClick = false;
+ this.targetElement = null;
+ };
+
+
+ /**
+ * Determine mouse events which should be permitted.
+ *
+ * @param {Event} event
+ * @returns {boolean}
+ */
+ FastClick.prototype.onMouse = function(event) {
+
+ // If a target element was never set (because a touch event was never fired) allow the event
+ if (!this.targetElement) {
+ return true;
+ }
+
+ if (event.forwardedTouchEvent) {
+ return true;
+ }
+
+ // Programmatically generated events targeting a specific element should be permitted
+ if (!event.cancelable) {
+ return true;
+ }
+
+ // Derive and check the target element to see whether the mouse event needs to be permitted;
+ // unless explicitly enabled, prevent non-touch click events from triggering actions,
+ // to prevent ghost/doubleclicks.
+ if (!this.needsClick(this.targetElement) || this.cancelNextClick) {
+
+ // Prevent any user-added listeners declared on FastClick element from being fired.
+ if (event.stopImmediatePropagation) {
+ event.stopImmediatePropagation();
+ } else {
+
+ // Part of the hack for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2)
+ event.propagationStopped = true;
+ }
+
+ // Cancel the event
+ event.stopPropagation();
+ event.preventDefault();
+
+ return false;
+ }
+
+ // If the mouse event is permitted, return true for the action to go through.
+ return true;
+ };
+
+
+ /**
+ * On actual clicks, determine whether this is a touch-generated click, a click action occurring
+ * naturally after a delay after a touch (which needs to be cancelled to avoid duplication), or
+ * an actual click which should be permitted.
+ *
+ * @param {Event} event
+ * @returns {boolean}
+ */
+ FastClick.prototype.onClick = function(event) {
+ var permitted;
+
+ // It's possible for another FastClick-like library delivered with third-party code to fire a click event before FastClick does (issue #44). In that case, set the click-tracking flag back to false and return early. This will cause onTouchEnd to return early.
+ if (this.trackingClick) {
+ this.targetElement = null;
+ this.trackingClick = false;
+ return true;
+ }
+
+ // Very odd behaviour on iOS (issue #18): if a submit element is present inside a form and the user hits enter in the iOS simulator or clicks the Go button on the pop-up OS keyboard the a kind of 'fake' click event will be triggered with the submit-type input element as the target.
+ if (event.target.type === 'submit' && event.detail === 0) {
+ return true;
+ }
+
+ permitted = this.onMouse(event);
+
+ // Only unset targetElement if the click is not permitted. This will ensure that the check for !targetElement in onMouse fails and the browser's click doesn't go through.
+ if (!permitted) {
+ this.targetElement = null;
+ }
+
+ // If clicks are permitted, return true for the action to go through.
+ return permitted;
+ };
+
+
+ /**
+ * Remove all FastClick's event listeners.
+ *
+ * @returns {void}
+ */
+ FastClick.prototype.destroy = function() {
+ var layer = this.layer;
+
+ if (deviceIsAndroid) {
+ layer.removeEventListener('mouseover', this.onMouse, true);
+ layer.removeEventListener('mousedown', this.onMouse, true);
+ layer.removeEventListener('mouseup', this.onMouse, true);
+ }
+
+ layer.removeEventListener('click', this.onClick, true);
+ layer.removeEventListener('touchstart', this.onTouchStart, false);
+ layer.removeEventListener('touchmove', this.onTouchMove, false);
+ layer.removeEventListener('touchend', this.onTouchEnd, false);
+ layer.removeEventListener('touchcancel', this.onTouchCancel, false);
+ };
+
+
+ /**
+ * Check whether FastClick is needed.
+ *
+ * @param {Element} layer The layer to listen on
+ */
+ FastClick.notNeeded = function(layer) {
+ var metaViewport;
+ var chromeVersion;
+ var blackberryVersion;
+ var firefoxVersion;
+
+ // Devices that don't support touch don't need FastClick
+ if (typeof window.ontouchstart === 'undefined') {
+ return true;
+ }
+
+ // Chrome version - zero for other browsers
+ chromeVersion = +(/Chrome\/([0-9]+)/.exec(navigator.userAgent) || [,0])[1];
+
+ if (chromeVersion) {
+
+ if (deviceIsAndroid) {
+ metaViewport = document.querySelector('meta[name=viewport]');
+
+ if (metaViewport) {
+ // Chrome on Android with user-scalable="no" doesn't need FastClick (issue #89)
+ if (metaViewport.content.indexOf('user-scalable=no') !== -1) {
+ return true;
+ }
+ // Chrome 32 and above with width=device-width or less don't need FastClick
+ if (chromeVersion > 31 && document.documentElement.scrollWidth <= window.outerWidth) {
+ return true;
+ }
+ }
+
+ // Chrome desktop doesn't need FastClick (issue #15)
+ } else {
+ return true;
+ }
+ }
+
+ if (deviceIsBlackBerry10) {
+ blackberryVersion = navigator.userAgent.match(/Version\/([0-9]*)\.([0-9]*)/);
+
+ // BlackBerry 10.3+ does not require Fastclick library.
+ // https://github.com/ftlabs/fastclick/issues/251
+ if (blackberryVersion[1] >= 10 && blackberryVersion[2] >= 3) {
+ metaViewport = document.querySelector('meta[name=viewport]');
+
+ if (metaViewport) {
+ // user-scalable=no eliminates click delay.
+ if (metaViewport.content.indexOf('user-scalable=no') !== -1) {
+ return true;
+ }
+ // width=device-width (or less than device-width) eliminates click delay.
+ if (document.documentElement.scrollWidth <= window.outerWidth) {
+ return true;
+ }
+ }
+ }
+ }
+
+ // IE10 with -ms-touch-action: none or manipulation, which disables double-tap-to-zoom (issue #97)
+ if (layer.style.msTouchAction === 'none' || layer.style.touchAction === 'manipulation') {
+ return true;
+ }
+
+ // Firefox version - zero for other browsers
+ firefoxVersion = +(/Firefox\/([0-9]+)/.exec(navigator.userAgent) || [,0])[1];
+
+ if (firefoxVersion >= 27) {
+ // Firefox 27+ does not have tap delay if the content is not zoomable - https://bugzilla.mozilla.org/show_bug.cgi?id=922896
+
+ metaViewport = document.querySelector('meta[name=viewport]');
+ if (metaViewport && (metaViewport.content.indexOf('user-scalable=no') !== -1 || document.documentElement.scrollWidth <= window.outerWidth)) {
+ return true;
+ }
+ }
+
+ // IE11: prefixed -ms-touch-action is no longer supported and it's recomended to use non-prefixed version
+ // http://msdn.microsoft.com/en-us/library/windows/apps/Hh767313.aspx
+ if (layer.style.touchAction === 'none' || layer.style.touchAction === 'manipulation') {
+ return true;
+ }
+
+ return false;
+ };
+
+
+ /**
+ * Factory method for creating a FastClick object
+ *
+ * @param {Element} layer The layer to listen on
+ * @param {Object} [options={}] The options to override the defaults
+ */
+ FastClick.attach = function(layer, options) {
+ return new FastClick(layer, options);
+ };
+
+ //直接绑定
+ $(function() {
+ FastClick.attach(document.body);
+ });
+}($));
+
+/*===========================
+ Template7 Template engine
+ ===========================*/
+/* global $:true */
+/* jshint unused:false */
+/* jshint forin:false */
++function ($) {
+ "use strict";
+ $.Template7 = $.t7 = (function () {
+ function isArray(arr) {
+ return Object.prototype.toString.apply(arr) === '[object Array]';
+ }
+ function isObject(obj) {
+ return obj instanceof Object;
+ }
+ function isFunction(func) {
+ return typeof func === 'function';
+ }
+ var cache = {};
+ function helperToSlices(string) {
+ var helperParts = string.replace(/[{}#}]/g, '').split(' ');
+ var slices = [];
+ var shiftIndex, i, j;
+ for (i = 0; i < helperParts.length; i++) {
+ var part = helperParts[i];
+ if (i === 0) slices.push(part);
+ else {
+ if (part.indexOf('"') === 0) {
+ // Plain String
+ if (part.match(/"/g).length === 2) {
+ // One word string
+ slices.push(part);
+ }
+ else {
+ // Find closed Index
+ shiftIndex = 0;
+ for (j = i + 1; j < helperParts.length; j++) {
+ part += ' ' + helperParts[j];
+ if (helperParts[j].indexOf('"') >= 0) {
+ shiftIndex = j;
+ slices.push(part);
+ break;
+ }
+ }
+ if (shiftIndex) i = shiftIndex;
+ }
+ }
+ else {
+ if (part.indexOf('=') > 0) {
+ // Hash
+ var hashParts = part.split('=');
+ var hashName = hashParts[0];
+ var hashContent = hashParts[1];
+ if (hashContent.match(/"/g).length !== 2) {
+ shiftIndex = 0;
+ for (j = i + 1; j < helperParts.length; j++) {
+ hashContent += ' ' + helperParts[j];
+ if (helperParts[j].indexOf('"') >= 0) {
+ shiftIndex = j;
+ break;
+ }
+ }
+ if (shiftIndex) i = shiftIndex;
+ }
+ var hash = [hashName, hashContent.replace(/"/g,'')];
+ slices.push(hash);
+ }
+ else {
+ // Plain variable
+ slices.push(part);
+ }
+ }
+ }
+ }
+ return slices;
+ }
+ function stringToBlocks(string) {
+ var blocks = [], i, j, k;
+ if (!string) return [];
+ var _blocks = string.split(/({{[^{^}]*}})/);
+ for (i = 0; i < _blocks.length; i++) {
+ var block = _blocks[i];
+ if (block === '') continue;
+ if (block.indexOf('{{') < 0) {
+ blocks.push({
+ type: 'plain',
+ content: block
+ });
+ }
+ else {
+ if (block.indexOf('{/') >= 0) {
+ continue;
+ }
+ if (block.indexOf('{#') < 0 && block.indexOf(' ') < 0 && block.indexOf('else') < 0) {
+ // Simple variable
+ blocks.push({
+ type: 'variable',
+ contextName: block.replace(/[{}]/g, '')
+ });
+ continue;
+ }
+ // Helpers
+ var helperSlices = helperToSlices(block);
+ var helperName = helperSlices[0];
+ var helperContext = [];
+ var helperHash = {};
+ for (j = 1; j < helperSlices.length; j++) {
+ var slice = helperSlices[j];
+ if (isArray(slice)) {
+ // Hash
+ helperHash[slice[0]] = slice[1] === 'false' ? false : slice[1];
+ }
+ else {
+ helperContext.push(slice);
+ }
+ }
+
+ if (block.indexOf('{#') >= 0) {
+ // Condition/Helper
+ var helperStartIndex = i;
+ var helperContent = '';
+ var elseContent = '';
+ var toSkip = 0;
+ var shiftIndex;
+ var foundClosed = false, foundElse = false, foundClosedElse = false, depth = 0;
+ for (j = i + 1; j < _blocks.length; j++) {
+ if (_blocks[j].indexOf('{{#') >= 0) {
+ depth ++;
+ }
+ if (_blocks[j].indexOf('{{/') >= 0) {
+ depth --;
+ }
+ if (_blocks[j].indexOf('{{#' + helperName) >= 0) {
+ helperContent += _blocks[j];
+ if (foundElse) elseContent += _blocks[j];
+ toSkip ++;
+ }
+ else if (_blocks[j].indexOf('{{/' + helperName) >= 0) {
+ if (toSkip > 0) {
+ toSkip--;
+ helperContent += _blocks[j];
+ if (foundElse) elseContent += _blocks[j];
+ }
+ else {
+ shiftIndex = j;
+ foundClosed = true;
+ break;
+ }
+ }
+ else if (_blocks[j].indexOf('else') >= 0 && depth === 0) {
+ foundElse = true;
+ }
+ else {
+ if (!foundElse) helperContent += _blocks[j];
+ if (foundElse) elseContent += _blocks[j];
+ }
+
+ }
+ if (foundClosed) {
+ if (shiftIndex) i = shiftIndex;
+ blocks.push({
+ type: 'helper',
+ helperName: helperName,
+ contextName: helperContext,
+ content: helperContent,
+ inverseContent: elseContent,
+ hash: helperHash
+ });
+ }
+ }
+ else if (block.indexOf(' ') > 0) {
+ blocks.push({
+ type: 'helper',
+ helperName: helperName,
+ contextName: helperContext,
+ hash: helperHash
+ });
+ }
+ }
+ }
+ return blocks;
+ }
+ var Template7 = function (template) {
+ var t = this;
+ t.template = template;
+
+ function getCompileFn(block, depth) {
+ if (block.content) return compile(block.content, depth);
+ else return function () {return ''; };
+ }
+ function getCompileInverse(block, depth) {
+ if (block.inverseContent) return compile(block.inverseContent, depth);
+ else return function () {return ''; };
+ }
+ function getCompileVar(name, ctx) {
+ var variable, parts, levelsUp = 0, initialCtx = ctx;
+ if (name.indexOf('../') === 0) {
+ levelsUp = name.split('../').length - 1;
+ var newDepth = ctx.split('_')[1] - levelsUp;
+ ctx = 'ctx_' + (newDepth >= 1 ? newDepth : 1);
+ parts = name.split('../')[levelsUp].split('.');
+ }
+ else if (name.indexOf('@global') === 0) {
+ ctx = '$.Template7.global';
+ parts = name.split('@global.')[1].split('.');
+ }
+ else if (name.indexOf('@root') === 0) {
+ ctx = 'ctx_1';
+ parts = name.split('@root.')[1].split('.');
+ }
+ else {
+ parts = name.split('.');
+ }
+ variable = ctx;
+ for (var i = 0; i < parts.length; i++) {
+ var part = parts[i];
+ if (part.indexOf('@') === 0) {
+ if (i > 0) {
+ variable += '[(data && data.' + part.replace('@', '') + ')]';
+ }
+ else {
+ variable = '(data && data.' + name.replace('@', '') + ')';
+ }
+ }
+ else {
+ if (isFinite(part)) {
+ variable += '[' + part + ']';
+ }
+ else {
+ if (part.indexOf('this') === 0) {
+ variable = part.replace('this', ctx);
+ }
+ else {
+ variable += '.' + part;
+ }
+ }
+ }
+ }
+
+ return variable;
+ }
+ function getCompiledArguments(contextArray, ctx) {
+ var arr = [];
+ for (var i = 0; i < contextArray.length; i++) {
+ if (contextArray[i].indexOf('"') === 0) arr.push(contextArray[i]);
+ else {
+ arr.push(getCompileVar(contextArray[i], ctx));
+ }
+ }
+ return arr.join(', ');
+ }
+ function compile(template, depth) {
+ depth = depth || 1;
+ template = template || t.template;
+ if (typeof template !== 'string') {
+ throw new Error('Template7: Template must be a string');
+ }
+ var blocks = stringToBlocks(template);
+ if (blocks.length === 0) {
+ return function () { return ''; };
+ }
+ var ctx = 'ctx_' + depth;
+ var resultString = '(function (' + ctx + ', data) {\n';
+ if (depth === 1) {
+ resultString += 'function isArray(arr){return Object.prototype.toString.apply(arr) === \'[object Array]\';}\n';
+ resultString += 'function isFunction(func){return (typeof func === \'function\');}\n';
+ resultString += 'function c(val, ctx) {if (typeof val !== "undefined") {if (isFunction(val)) {return val.call(ctx);} else return val;} else return "";}\n';
+ }
+ resultString += 'var r = \'\';\n';
+ var i, j, context;
+ for (i = 0; i < blocks.length; i++) {
+ var block = blocks[i];
+ // Plain block
+ if (block.type === 'plain') {
+ resultString += 'r +=\'' + (block.content).replace(/\r/g, '\\r').replace(/\n/g, '\\n').replace(/'/g, '\\' + '\'') + '\';';
+ continue;
+ }
+ var variable, compiledArguments;
+ // Variable block
+ if (block.type === 'variable') {
+ variable = getCompileVar(block.contextName, ctx);
+ resultString += 'r += c(' + variable + ', ' + ctx + ');';
+ }
+ // Helpers block
+ if (block.type === 'helper') {
+ if (block.helperName in t.helpers) {
+ compiledArguments = getCompiledArguments(block.contextName, ctx);
+ resultString += 'r += ($.Template7.helpers.' + block.helperName + ').call(' + ctx + ', ' + (compiledArguments && (compiledArguments + ', ')) +'{hash:' + JSON.stringify(block.hash) + ', data: data || {}, fn: ' + getCompileFn(block, depth+1) + ', inverse: ' + getCompileInverse(block, depth+1) + ', root: ctx_1});';
+ }
+ else {
+ if (block.contextName.length > 0) {
+ throw new Error('Template7: Missing helper: "' + block.helperName + '"');
+ }
+ else {
+ variable = getCompileVar(block.helperName, ctx);
+ resultString += 'if (' + variable + ') {';
+ resultString += 'if (isArray(' + variable + ')) {';
+ resultString += 'r += ($.Template7.helpers.each).call(' + ctx + ', ' + variable + ', {hash:' + JSON.stringify(block.hash) + ', data: data || {}, fn: ' + getCompileFn(block, depth+1) + ', inverse: ' + getCompileInverse(block, depth+1) + ', root: ctx_1});';
+ resultString += '}else {';
+ resultString += 'r += ($.Template7.helpers.with).call(' + ctx + ', ' + variable + ', {hash:' + JSON.stringify(block.hash) + ', data: data || {}, fn: ' + getCompileFn(block, depth+1) + ', inverse: ' + getCompileInverse(block, depth+1) + ', root: ctx_1});';
+ resultString += '}}';
+ }
+ }
+ }
+ }
+ resultString += '\nreturn r;})';
+ return eval.call(window, resultString);
+ }
+ t.compile = function (template) {
+ if (!t.compiled) {
+ t.compiled = compile(template);
+ }
+ return t.compiled;
+ };
+ };
+ Template7.prototype = {
+ options: {},
+ helpers: {
+ 'if': function (context, options) {
+ if (isFunction(context)) { context = context.call(this); }
+ if (context) {
+ return options.fn(this, options.data);
+ }
+ else {
+ return options.inverse(this, options.data);
+ }
+ },
+ 'unless': function (context, options) {
+ if (isFunction(context)) { context = context.call(this); }
+ if (!context) {
+ return options.fn(this, options.data);
+ }
+ else {
+ return options.inverse(this, options.data);
+ }
+ },
+ 'each': function (context, options) {
+ var ret = '', i = 0;
+ if (isFunction(context)) { context = context.call(this); }
+ if (isArray(context)) {
+ if (options.hash.reverse) {
+ context = context.reverse();
+ }
+ for (i = 0; i < context.length; i++) {
+ ret += options.fn(context[i], {first: i === 0, last: i === context.length - 1, index: i});
+ }
+ if (options.hash.reverse) {
+ context = context.reverse();
+ }
+ }
+ else {
+ for (var key in context) {
+ i++;
+ ret += options.fn(context[key], {key: key});
+ }
+ }
+ if (i > 0) return ret;
+ else return options.inverse(this);
+ },
+ 'with': function (context, options) {
+ if (isFunction(context)) { context = context.call(this); }
+ return options.fn(context);
+ },
+ 'join': function (context, options) {
+ if (isFunction(context)) { context = context.call(this); }
+ return context.join(options.hash.delimiter || options.hash.delimeter);
+ },
+ 'js': function (expression, options) {
+ var func;
+ if (expression.indexOf('return')>=0) {
+ func = '(function(){'+expression+'})';
+ }
+ else {
+ func = '(function(){return ('+expression+')})';
+ }
+ return eval.call(this, func).call(this);
+ },
+ 'js_compare': function (expression, options) {
+ var func;
+ if (expression.indexOf('return')>=0) {
+ func = '(function(){'+expression+'})';
+ }
+ else {
+ func = '(function(){return ('+expression+')})';
+ }
+ var condition = eval.call(this, func).call(this);
+ if (condition) {
+ return options.fn(this, options.data);
+ }
+ else {
+ return options.inverse(this, options.data);
+ }
+ }
+ }
+ };
+ var t7 = function (template, data) {
+ if (arguments.length === 2) {
+ var instance = new Template7(template);
+ var rendered = instance.compile()(data);
+ instance = null;
+ return (rendered);
+ }
+ else return new Template7(template);
+ };
+ t7.registerHelper = function (name, fn) {
+ Template7.prototype.helpers[name] = fn;
+ };
+ t7.unregisterHelper = function (name) {
+ Template7.prototype.helpers[name] = undefined;
+ delete Template7.prototype.helpers[name];
+ };
+
+ t7.compile = function (template, options) {
+ var instance = new Template7(template, options);
+ return instance.compile();
+ };
+
+ t7.options = Template7.prototype.options;
+ t7.helpers = Template7.prototype.helpers;
+ return t7;
+ })();
+}($);
+
+/* global $:true */
++ function($) {
+ "use strict";
+
+ $.getCurrentPage = function() {
+ return $(".page")[0] || document.body;
+ };
+}($);
+
+/* ===============================================================================
+************ Tabs ************
+=============================================================================== */
+/* global $:true */
++function ($) {
+ "use strict";
+
+ var showTab = function (tab, tabLink, force) {
+ var newTab = $(tab);
+
+ var activeClass = newTab.hasClass("page") ? "page-current" : "active";
+ if (arguments.length === 2) {
+ if (typeof tabLink === 'boolean') {
+ force = tabLink;
+ }
+ }
+ if (newTab.length === 0) return false;
+ if (newTab.hasClass(activeClass)) {
+ if (force) newTab.trigger('show');
+ return false;
+ }
+ var tabs = newTab.parent('.tabs');
+ if (tabs.length === 0) return false;
+
+ // Animated tabs
+ /*var isAnimatedTabs = tabs.parent().hasClass('tabs-animated-wrap');
+ if (isAnimatedTabs) {
+ tabs.transform('translate3d(' + -newTab.index() * 100 + '%,0,0)');
+ }*/
+
+ // Remove active class from old tabs
+ var oldTab = tabs.children('.tab.'+activeClass).removeClass(activeClass);
+ // Add active class to new tab
+ newTab.addClass(activeClass);
+ // Trigger 'show' event on new tab
+ newTab.trigger('show');
+
+ // Update navbars in new tab
+ /*if (!isAnimatedTabs && newTab.find('.navbar').length > 0) {
+ // Find tab's view
+ var viewContainer;
+ if (newTab.hasClass(app.params.viewClass)) viewContainer = newTab[0];
+ else viewContainer = newTab.parents('.' + app.params.viewClass)[0];
+ app.sizeNavbars(viewContainer);
+ }*/
+
+ // Find related link for new tab
+ if (tabLink) tabLink = $(tabLink);
+ else {
+ // Search by id
+ if (typeof tab === 'string') tabLink = $('.tab-link[href="' + tab + '"]');
+ else tabLink = $('.tab-link[href="#' + newTab.attr('id') + '"]');
+ // Search by data-tab
+ if (!tabLink || tabLink && tabLink.length === 0) {
+ $('[data-tab]').each(function () {
+ if (newTab.is($(this).attr('data-tab'))) tabLink = $(this);
+ });
+ }
+ }
+ if (tabLink.length === 0) return;
+
+ // Find related link for old tab
+ var oldTabLink;
+ if (oldTab && oldTab.length > 0) {
+ // Search by id
+ var oldTabId = oldTab.attr('id');
+ if (oldTabId) oldTabLink = $('.tab-link[href="#' + oldTabId + '"]');
+ // Search by data-tab
+ if (!oldTabLink || oldTabLink && oldTabLink.length === 0) {
+ $('[data-tab]').each(function () {
+ if (oldTab.is($(this).attr('data-tab'))) oldTabLink = $(this);
+ });
+ }
+ }
+
+ // Update links' classes
+ if (tabLink && tabLink.length > 0) tabLink.addClass('active');
+ if (oldTabLink && oldTabLink.length > 0) oldTabLink.removeClass('active');
+
+ return true;
+ };
+
+ var old = $.showTab;
+ $.showTab = showTab;
+
+ $.showTab.noConflict = function () {
+ $.showTab = old;
+ return this;
+ };
+
+
+ $(document).on("click", ".tab-link", function(e) {
+ e.preventDefault();
+ var clicked = $(this);
+ showTab(clicked.data("tab") || clicked.attr('href'), clicked);
+ });
+}($);
+
+/* global $:true */
++function ($) {
+ "use strict";
+ $(document).on("click", ".tab-item", function(e) {
+ var $target = $(e.currentTarget);
+ if(!$target.hasClass("tab-link")) {
+ $target.parent().find(".active").removeClass("active");
+ $target.addClass("active");
+ }
+ });
+
+ var highlight = function(e, pageId) {
+ var $tab = $(".bar-tab .tab-item[href='#"+pageId+"']");
+ $tab.parent().find(".active").removeClass("active");
+ $tab.addClass("active");
+ };
+ $(document).on("pageInit", highlight);
+ $(document).on("pageReinit", highlight);
+
+ $.showToolbar = function(show) {
+ $(document.body)[show ? "removeClass" : "addClass"]("tabbar-hidden");
+ };
+
+}($);
+
+/*======================================================
+************ Modals ************
+======================================================*/
+/*jshint unused: false*/
+/* global $:true */
++function ($) {
+ "use strict";
+ var _modalTemplateTempDiv = document.createElement('div');
+
+ $.modalStack = [];
+ var t7 = $.Template7;
+
+ $.modalStackClearQueue = function () {
+ if ($.modalStack.length) {
+ ($.modalStack.shift())();
+ }
+ };
+ $.modal = function (params) {
+ params = params || {};
+ var modalHTML = '';
+ if (defaults.modalTemplate) {
+ if (!$._compiledTemplates.modal) $._compiledTemplates.modal = t7.compile(defaults.modalTemplate);
+ modalHTML = $._compiledTemplates.modal(params);
+ }
+ else {
+ var buttonsHTML = '';
+ if (params.buttons && params.buttons.length > 0) {
+ for (var i = 0; i < params.buttons.length; i++) {
+ buttonsHTML += '' + params.buttons[i].text + ' ';
+ }
+ }
+ var titleHTML = params.title ? '
' + params.title + '
' : '';
+ var textHTML = params.text ? '' + params.text + '
' : '';
+ var afterTextHTML = params.afterText ? params.afterText : '';
+ var noButtons = !params.buttons || params.buttons.length === 0 ? 'modal-no-buttons' : '';
+ var verticalButtons = params.verticalButtons ? 'modal-buttons-vertical' : '';
+ modalHTML = '';
+ }
+
+ _modalTemplateTempDiv.innerHTML = modalHTML;
+
+ var modal = $(_modalTemplateTempDiv).children();
+
+ $(defaults.modalContainer).append(modal[0]);
+
+ // Add events on buttons
+ modal.find('.modal-button').each(function (index, el) {
+ $(el).on('click', function (e) {
+ if (params.buttons[index].close !== false) $.closeModal(modal);
+ if (params.buttons[index].onClick) params.buttons[index].onClick(modal, e);
+ if (params.onClick) params.onClick(modal, index);
+ });
+ });
+ $.openModal(modal);
+ return modal[0];
+ };
+ $.alert = function (text, title, callbackOk) {
+ if (typeof title === 'function') {
+ callbackOk = arguments[1];
+ title = undefined;
+ }
+ return $.modal({
+ text: text || '',
+ title: typeof title === 'undefined' ? defaults.modalTitle : title,
+ buttons: [ {text: defaults.modalButtonOk, bold: true, onClick: callbackOk} ]
+ });
+ };
+ $.confirm = function (text, title, callbackOk, callbackCancel) {
+ if (typeof title === 'function') {
+ callbackCancel = arguments[2];
+ callbackOk = arguments[1];
+ title = undefined;
+ }
+ return $.modal({
+ text: text || '',
+ title: typeof title === 'undefined' ? defaults.modalTitle : title,
+ buttons: [
+ {text: defaults.modalButtonCancel, onClick: callbackCancel},
+ {text: defaults.modalButtonOk, bold: true, onClick: callbackOk}
+ ]
+ });
+ };
+ $.prompt = function (text, title, callbackOk, callbackCancel) {
+ if (typeof title === 'function') {
+ callbackCancel = arguments[2];
+ callbackOk = arguments[1];
+ title = undefined;
+ }
+ return $.modal({
+ text: text || '',
+ title: typeof title === 'undefined' ? defaults.modalTitle : title,
+ afterText: ' ',
+ buttons: [
+ {
+ text: defaults.modalButtonCancel
+ },
+ {
+ text: defaults.modalButtonOk,
+ bold: true
+ }
+ ],
+ onClick: function (modal, index) {
+ if (index === 0 && callbackCancel) callbackCancel($(modal).find('.modal-text-input').val());
+ if (index === 1 && callbackOk) callbackOk($(modal).find('.modal-text-input').val());
+ }
+ });
+ };
+ $.modalLogin = function (text, title, callbackOk, callbackCancel) {
+ if (typeof title === 'function') {
+ callbackCancel = arguments[2];
+ callbackOk = arguments[1];
+ title = undefined;
+ }
+ return $.modal({
+ text: text || '',
+ title: typeof title === 'undefined' ? defaults.modalTitle : title,
+ afterText: ' ',
+ buttons: [
+ {
+ text: defaults.modalButtonCancel
+ },
+ {
+ text: defaults.modalButtonOk,
+ bold: true
+ }
+ ],
+ onClick: function (modal, index) {
+ var username = $(modal).find('.modal-text-input[name="modal-username"]').val();
+ var password = $(modal).find('.modal-text-input[name="modal-password"]').val();
+ if (index === 0 && callbackCancel) callbackCancel(username, password);
+ if (index === 1 && callbackOk) callbackOk(username, password);
+ }
+ });
+ };
+ $.modalPassword = function (text, title, callbackOk, callbackCancel) {
+ if (typeof title === 'function') {
+ callbackCancel = arguments[2];
+ callbackOk = arguments[1];
+ title = undefined;
+ }
+ return $.modal({
+ text: text || '',
+ title: typeof title === 'undefined' ? defaults.modalTitle : title,
+ afterText: ' ',
+ buttons: [
+ {
+ text: defaults.modalButtonCancel
+ },
+ {
+ text: defaults.modalButtonOk,
+ bold: true
+ }
+ ],
+ onClick: function (modal, index) {
+ var password = $(modal).find('.modal-text-input[name="modal-password"]').val();
+ if (index === 0 && callbackCancel) callbackCancel(password);
+ if (index === 1 && callbackOk) callbackOk(password);
+ }
+ });
+ };
+ $.showPreloader = function (title) {
+ return $.modal({
+ title: title || defaults.modalPreloaderTitle,
+ text: '
'
+ });
+ };
+ $.hidePreloader = function () {
+ $.closeModal('.modal.modal-in');
+ };
+ $.showIndicator = function () {
+ $(defaults.modalContainer).append('
');
+ };
+ $.hideIndicator = function () {
+ $('.preloader-indicator-overlay, .preloader-indicator-modal').remove();
+ };
+ // Action Sheet
+ $.actions = function (target, params) {
+ var toPopover = false, modal, groupSelector, buttonSelector;
+ if (arguments.length === 1) {
+ // Actions
+ params = target;
+ }
+ else {
+ // Popover
+ if ($.device.ios) {
+ if ($.device.ipad) toPopover = true;
+ }
+ else {
+ if ($(window).width() >= 768) toPopover = true;
+ }
+ }
+ params = params || [];
+
+ if (params.length > 0 && !$.isArray(params[0])) {
+ params = [params];
+ }
+ var modalHTML;
+ if (toPopover) {
+ var actionsToPopoverTemplate = defaults.modalActionsToPopoverTemplate ||
+ '' +
+ '
' +
+ '{{#each this}}' +
+ '
' +
+ '
' +
+ '{{#each this}}' +
+ '{{#if label}}' +
+ '{{text}} ' +
+ '{{else}}' +
+ '{{text}} ' +
+ '{{/if}}' +
+ '{{/each}}' +
+ ' ' +
+ '
' +
+ '{{/each}}' +
+ '
' +
+ '
';
+ if (!$._compiledTemplates.actionsToPopover) {
+ $._compiledTemplates.actionsToPopover = t7.compile(actionsToPopoverTemplate);
+ }
+ var popoverHTML = $._compiledTemplates.actionsToPopover(params);
+ modal = $($.popover(popoverHTML, target, true));
+ groupSelector = '.list-block ul';
+ buttonSelector = '.list-button';
+ }
+ else {
+ if (defaults.modalActionsTemplate) {
+ if (!$._compiledTemplates.actions) $._compiledTemplates.actions = t7.compile(defaults.modalActionsTemplate);
+ modalHTML = $._compiledTemplates.actions(params);
+ }
+ else {
+ var buttonsHTML = '';
+ for (var i = 0; i < params.length; i++) {
+ for (var j = 0; j < params[i].length; j++) {
+ if (j === 0) buttonsHTML += '';
+ var button = params[i][j];
+ var buttonClass = button.label ? 'actions-modal-label' : 'actions-modal-button';
+ if (button.bold) buttonClass += ' actions-modal-button-bold';
+ if (button.color) buttonClass += ' color-' + button.color;
+ if (button.bg) buttonClass += ' bg-' + button.bg;
+ if (button.disabled) buttonClass += ' disabled';
+ buttonsHTML += '' + button.text + ' ';
+ if (j === params[i].length - 1) buttonsHTML += '
';
+ }
+ }
+ modalHTML = '' + buttonsHTML + '
';
+ }
+ _modalTemplateTempDiv.innerHTML = modalHTML;
+ modal = $(_modalTemplateTempDiv).children();
+ $(defaults.modalContainer).append(modal[0]);
+ groupSelector = '.actions-modal-group';
+ buttonSelector = '.actions-modal-button';
+ }
+
+ var groups = modal.find(groupSelector);
+ groups.each(function (index, el) {
+ var groupIndex = index;
+ $(el).children().each(function (index, el) {
+ var buttonIndex = index;
+ var buttonParams = params[groupIndex][buttonIndex];
+ var clickTarget;
+ if (!toPopover && $(el).is(buttonSelector)) clickTarget = $(el);
+ if (toPopover && $(el).find(buttonSelector).length > 0) clickTarget = $(el).find(buttonSelector);
+
+ if (clickTarget) {
+ clickTarget.on('click', function (e) {
+ if (buttonParams.close !== false) $.closeModal(modal);
+ if (buttonParams.onClick) buttonParams.onClick(modal, e);
+ });
+ }
+ });
+ });
+ if (!toPopover) $.openModal(modal);
+ return modal[0];
+ };
+ $.popover = function (modal, target, removeOnClose) {
+ if (typeof removeOnClose === 'undefined') removeOnClose = true;
+ if (typeof modal === 'string' && modal.indexOf('<') >= 0) {
+ var _modal = document.createElement('div');
+ _modal.innerHTML = modal.trim();
+ if (_modal.childNodes.length > 0) {
+ modal = _modal.childNodes[0];
+ if (removeOnClose) modal.classList.add('remove-on-close');
+ $(defaults.modalContainer).append(modal);
+ }
+ else return false; //nothing found
+ }
+ modal = $(modal);
+ target = $(target);
+ if (modal.length === 0 || target.length === 0) return false;
+ if (modal.find('.popover-angle').length === 0) {
+ modal.append('
');
+ }
+ modal.show();
+
+ function sizePopover() {
+ modal.css({left: '', top: ''});
+ var modalWidth = modal.width();
+ var modalHeight = modal.height(); // 13 - height of angle
+ var modalAngle = modal.find('.popover-angle');
+ var modalAngleSize = modalAngle.width() / 2;
+ var modalAngleLeft, modalAngleTop;
+ modalAngle.removeClass('on-left on-right on-top on-bottom').css({left: '', top: ''});
+
+ var targetWidth = target.outerWidth();
+ var targetHeight = target.outerHeight();
+ var targetOffset = target.offset();
+ var targetParentPage = target.parents('.page');
+ if (targetParentPage.length > 0) {
+ targetOffset.top = targetOffset.top - targetParentPage[0].scrollTop;
+ }
+
+ var windowHeight = $(window).height();
+ var windowWidth = $(window).width();
+
+ var modalTop = 0;
+ var modalLeft = 0;
+ var diff = 0;
+ // Top Position
+ var modalPosition = 'top';
+
+ if ((modalHeight + modalAngleSize) < targetOffset.top) {
+ // On top
+ modalTop = targetOffset.top - modalHeight - modalAngleSize;
+ }
+ else if ((modalHeight + modalAngleSize) < windowHeight - targetOffset.top - targetHeight) {
+ // On bottom
+ modalPosition = 'bottom';
+ modalTop = targetOffset.top + targetHeight + modalAngleSize;
+ }
+ else {
+ // On middle
+ modalPosition = 'middle';
+ modalTop = targetHeight / 2 + targetOffset.top - modalHeight / 2;
+ diff = modalTop;
+ if (modalTop < 0) {
+ modalTop = 5;
+ }
+ else if (modalTop + modalHeight > windowHeight) {
+ modalTop = windowHeight - modalHeight - 5;
+ }
+ diff = diff - modalTop;
+ }
+ // Horizontal Position
+ if (modalPosition === 'top' || modalPosition === 'bottom') {
+ modalLeft = targetWidth / 2 + targetOffset.left - modalWidth / 2;
+ diff = modalLeft;
+ if (modalLeft < 5) modalLeft = 5;
+ if (modalLeft + modalWidth > windowWidth) modalLeft = windowWidth - modalWidth - 5;
+ if (modalPosition === 'top') modalAngle.addClass('on-bottom');
+ if (modalPosition === 'bottom') modalAngle.addClass('on-top');
+ diff = diff - modalLeft;
+ modalAngleLeft = (modalWidth / 2 - modalAngleSize + diff);
+ modalAngleLeft = Math.max(Math.min(modalAngleLeft, modalWidth - modalAngleSize * 2 - 6), 6);
+ modalAngle.css({left: modalAngleLeft + 'px'});
+ }
+ else if (modalPosition === 'middle') {
+ modalLeft = targetOffset.left - modalWidth - modalAngleSize;
+ modalAngle.addClass('on-right');
+ if (modalLeft < 5) {
+ modalLeft = targetOffset.left + targetWidth + modalAngleSize;
+ modalAngle.removeClass('on-right').addClass('on-left');
+ }
+ if (modalLeft + modalWidth > windowWidth) {
+ modalLeft = windowWidth - modalWidth - 5;
+ modalAngle.removeClass('on-right').addClass('on-left');
+ }
+ modalAngleTop = (modalHeight / 2 - modalAngleSize + diff);
+ modalAngleTop = Math.max(Math.min(modalAngleTop, modalHeight - modalAngleSize * 2 - 6), 6);
+ modalAngle.css({top: modalAngleTop + 'px'});
+ }
+
+ // Apply Styles
+ modal.css({top: modalTop + 'px', left: modalLeft + 'px'});
+ }
+ sizePopover();
+
+ $(window).on('resize', sizePopover);
+ modal.on('close', function () {
+ $(window).off('resize', sizePopover);
+ });
+
+ if (modal.find('.' + defaults.viewClass).length > 0) {
+ $.sizeNavbars(modal.find('.' + defaults.viewClass)[0]);
+ }
+
+ $.openModal(modal);
+ return modal[0];
+ };
+ $.popup = function (modal, removeOnClose) {
+ if (typeof removeOnClose === 'undefined') removeOnClose = true;
+ if (typeof modal === 'string' && modal.indexOf('<') >= 0) {
+ var _modal = document.createElement('div');
+ _modal.innerHTML = modal.trim();
+ if (_modal.childNodes.length > 0) {
+ modal = _modal.childNodes[0];
+ if (removeOnClose) modal.classList.add('remove-on-close');
+ $(defaults.modalContainer).append(modal);
+ }
+ else return false; //nothing found
+ }
+ modal = $(modal);
+ if (modal.length === 0) return false;
+ modal.show();
+ if (modal.find('.' + defaults.viewClass).length > 0) {
+ $.sizeNavbars(modal.find('.' + defaults.viewClass)[0]);
+ }
+ $.openModal(modal);
+
+ return modal[0];
+ };
+ $.pickerModal = function (pickerModal, removeOnClose) {
+ if (typeof removeOnClose === 'undefined') removeOnClose = true;
+ if (typeof pickerModal === 'string' && pickerModal.indexOf('<') >= 0) {
+ pickerModal = $(pickerModal);
+ if (pickerModal.length > 0) {
+ if (removeOnClose) pickerModal.addClass('remove-on-close');
+ $(defaults.modalContainer).append(pickerModal[0]);
+ }
+ else return false; //nothing found
+ }
+ pickerModal = $(pickerModal);
+ if (pickerModal.length === 0) return false;
+ pickerModal.show();
+ $.openModal(pickerModal);
+ return pickerModal[0];
+ };
+ $.loginScreen = function (modal) {
+ if (!modal) modal = '.login-screen';
+ modal = $(modal);
+ if (modal.length === 0) return false;
+ modal.show();
+ if (modal.find('.' + defaults.viewClass).length > 0) {
+ $.sizeNavbars(modal.find('.' + defaults.viewClass)[0]);
+ }
+ $.openModal(modal);
+ return modal[0];
+ };
+ //显示一个消息,会在2秒钟后自动消失
+ $.toast = function(msg, time) {
+ var $toast = $(""+msg+"
").appendTo(document.body);
+ $.openModal($toast);
+ setTimeout(function() {
+ $.closeModal($toast);
+ }, time || 2000);
+ };
+ $.openModal = function (modal) {
+ if(defaults.closePrevious) $.closeModal();
+ modal = $(modal);
+ var isModal = modal.hasClass('modal');
+ if ($('.modal.modal-in:not(.modal-out)').length && defaults.modalStack && isModal) {
+ $.modalStack.push(function () {
+ $.openModal(modal);
+ });
+ return;
+ }
+ var isPopover = modal.hasClass('popover');
+ var isPopup = modal.hasClass('popup');
+ var isLoginScreen = modal.hasClass('login-screen');
+ var isPickerModal = modal.hasClass('picker-modal');
+ var isToast = modal.hasClass('toast');
+ if (isModal) {
+ modal.show();
+ modal.css({
+ marginTop: - Math.round(modal.outerHeight() / 2) + 'px'
+ });
+ }
+ if (isToast) {
+ modal.show();
+ modal.css({
+ marginLeft: - Math.round(parseInt(window.getComputedStyle(modal[0]).width) / 2) + 'px' //
+ });
+ }
+
+ var overlay;
+ if (!isLoginScreen && !isPickerModal && !isToast) {
+ if ($('.modal-overlay').length === 0 && !isPopup) {
+ $(defaults.modalContainer).append('
');
+ }
+ if ($('.popup-overlay').length === 0 && isPopup) {
+ $(defaults.modalContainer).append('');
+ }
+ overlay = isPopup ? $('.popup-overlay') : $('.modal-overlay');
+ }
+
+ //Make sure that styles are applied, trigger relayout;
+ var clientLeft = modal[0].clientLeft;
+
+ // Trugger open event
+ modal.trigger('open');
+
+ // Picker modal body class
+ if (isPickerModal) {
+ $(defaults.modalContainer).addClass('with-picker-modal');
+ }
+
+ // Classes for transition in
+ if (!isLoginScreen && !isPickerModal && !isToast) overlay.addClass('modal-overlay-visible');
+ modal.removeClass('modal-out').addClass('modal-in').transitionEnd(function (e) {
+ if (modal.hasClass('modal-out')) modal.trigger('closed');
+ else modal.trigger('opened');
+ });
+ return true;
+ };
+ $.closeModal = function (modal) {
+ modal = $(modal || '.modal-in');
+ if (typeof modal !== 'undefined' && modal.length === 0) {
+ return;
+ }
+ var isModal = modal.hasClass('modal');
+ var isPopover = modal.hasClass('popover');
+ var isPopup = modal.hasClass('popup');
+ var isLoginScreen = modal.hasClass('login-screen');
+ var isPickerModal = modal.hasClass('picker-modal');
+
+ var removeOnClose = modal.hasClass('remove-on-close');
+
+ var overlay = isPopup ? $('.popup-overlay') : $('.modal-overlay');
+ if (isPopup){
+ if (modal.length === $('.popup.modal-in').length) {
+ overlay.removeClass('modal-overlay-visible');
+ }
+ }
+ else if (!isPickerModal) {
+ overlay.removeClass('modal-overlay-visible');
+ }
+
+ modal.trigger('close');
+
+ // Picker modal body class
+ if (isPickerModal) {
+ $(defaults.modalContainer).removeClass('with-picker-modal');
+ $(defaults.modalContainer).addClass('picker-modal-closing');
+ }
+
+ if (!isPopover) {
+ modal.removeClass('modal-in').addClass('modal-out').transitionEnd(function (e) {
+ if (modal.hasClass('modal-out')) modal.trigger('closed');
+ else modal.trigger('opened');
+
+ if (isPickerModal) {
+ $(defaults.modalContainer).removeClass('picker-modal-closing');
+ }
+ if (isPopup || isLoginScreen || isPickerModal) {
+ modal.removeClass('modal-out').hide();
+ if (removeOnClose && modal.length > 0) {
+ modal.remove();
+ }
+ }
+ else {
+ modal.remove();
+ }
+ });
+ if (isModal && defaults.modalStack ) {
+ $.modalStackClearQueue();
+ }
+ }
+ else {
+ modal.removeClass('modal-in modal-out').trigger('closed').hide();
+ if (removeOnClose) {
+ modal.remove();
+ }
+ }
+ return true;
+ };
+ function handleClicks(e) {
+ /*jshint validthis:true */
+ var clicked = $(this);
+ var url = clicked.attr('href');
+
+ //Collect Clicked data- attributes
+ var clickedData = clicked.dataset();
+
+ // Popover
+ if (clicked.hasClass('open-popover')) {
+ var popover;
+ if (clickedData.popover) {
+ popover = clickedData.popover;
+ }
+ else popover = '.popover';
+ $.popover(popover, clicked);
+ }
+ if (clicked.hasClass('close-popover')) {
+ $.closeModal('.popover.modal-in');
+ }
+ // Popup
+ var popup;
+ if (clicked.hasClass('open-popup')) {
+ if (clickedData.popup) {
+ popup = clickedData.popup;
+ }
+ else popup = '.popup';
+ $.popup(popup);
+ }
+ if (clicked.hasClass('close-popup')) {
+ if (clickedData.popup) {
+ popup = clickedData.popup;
+ }
+ else popup = '.popup.modal-in';
+ $.closeModal(popup);
+ }
+
+ // Close Modal
+ if (clicked.hasClass('modal-overlay')) {
+ if ($('.modal.modal-in').length > 0 && defaults.modalCloseByOutside)
+ $.closeModal('.modal.modal-in');
+ if ($('.actions-modal.modal-in').length > 0 && defaults.actionsCloseByOutside)
+ $.closeModal('.actions-modal.modal-in');
+
+ if ($('.popover.modal-in').length > 0) $.closeModal('.popover.modal-in');
+ }
+ if (clicked.hasClass('popup-overlay')) {
+ if ($('.popup.modal-in').length > 0 && defaults.popupCloseByOutside)
+ $.closeModal('.popup.modal-in');
+ }
+ }
+
+ var defaults = $.modal.prototype.defaults = {
+ modalButtonOk: 'OK',
+ modalButtonCancel: 'Cancel',
+ modalPreloaderTitle: 'Loading...',
+ modalContainer : document.body,
+ modalCloseByOutside: true,
+ actionsCloseByOutside: false,
+ popupCloseByOutside: true,
+ closePrevious: true //close all previous modal before open
+ };
+
+ $(function() {
+ $(document).on('click', ' .modal-overlay, .popup-overlay, .close-popup, .open-popup, .open-popover, .close-popover, .close-picker', handleClicks);
+ defaults.modalContainer = defaults.modalContainer || document.body; //incase some one include js in head
+ });
+}($);
+
+/*======================================================
+************ Calendar ************
+======================================================*/
+/* global $:true */
+/*jshint unused: false*/
++function ($) {
+ "use strict";
+ var rtl = false;
+ var defaults;
+ var Calendar = function (params) {
+ var p = this;
+ params = params || {};
+ for (var def in defaults) {
+ if (typeof params[def] === 'undefined') {
+ params[def] = defaults[def];
+ }
+ }
+ p.params = params;
+ p.initialized = false;
+
+ // Inline flag
+ p.inline = p.params.container ? true : false;
+
+ // Is horizontal
+ p.isH = p.params.direction === 'horizontal';
+
+ // RTL inverter
+ var inverter = p.isH ? (rtl ? -1 : 1) : 1;
+
+ // Animating flag
+ p.animating = false;
+
+ // Should be converted to popover
+ function isPopover() {
+ var toPopover = false;
+ if (!p.params.convertToPopover && !p.params.onlyInPopover) return toPopover;
+ if (!p.inline && p.params.input) {
+ if (p.params.onlyInPopover) toPopover = true;
+ else {
+ if ($.device.ios) {
+ toPopover = $.device.ipad ? true : false;
+ }
+ else {
+ if ($(window).width() >= 768) toPopover = true;
+ }
+ }
+ }
+ return toPopover;
+ }
+ function inPopover() {
+ if (p.opened && p.container && p.container.length > 0 && p.container.parents('.popover').length > 0) return true;
+ else return false;
+ }
+
+ // Format date
+ function formatDate(date) {
+ date = new Date(date);
+ var year = date.getFullYear();
+ var month = date.getMonth();
+ var month1 = month + 1;
+ var day = date.getDate();
+ var weekDay = date.getDay();
+ return p.params.dateFormat
+ .replace(/yyyy/g, year)
+ .replace(/yy/g, (year + '').substring(2))
+ .replace(/mm/g, month1 < 10 ? '0' + month1 : month1)
+ .replace(/m/g, month1)
+ .replace(/MM/g, p.params.monthNames[month])
+ .replace(/M/g, p.params.monthNamesShort[month])
+ .replace(/dd/g, day < 10 ? '0' + day : day)
+ .replace(/d/g, day)
+ .replace(/DD/g, p.params.dayNames[weekDay])
+ .replace(/D/g, p.params.dayNamesShort[weekDay]);
+ }
+
+
+ // Value
+ p.addValue = function (value) {
+ if (p.params.multiple) {
+ if (!p.value) p.value = [];
+ var inValuesIndex;
+ for (var i = 0; i < p.value.length; i++) {
+ if (new Date(value).getTime() === new Date(p.value[i]).getTime()) {
+ inValuesIndex = i;
+ }
+ }
+ if (typeof inValuesIndex === 'undefined') {
+ p.value.push(value);
+ }
+ else {
+ p.value.splice(inValuesIndex, 1);
+ }
+ p.updateValue();
+ }
+ else {
+ p.value = [value];
+ p.updateValue();
+ }
+ };
+ p.setValue = function (arrValues) {
+ p.value = arrValues;
+ p.updateValue();
+ };
+ p.updateValue = function () {
+ p.wrapper.find('.picker-calendar-day-selected').removeClass('picker-calendar-day-selected');
+ var i, inputValue;
+ for (i = 0; i < p.value.length; i++) {
+ var valueDate = new Date(p.value[i]);
+ p.wrapper.find('.picker-calendar-day[data-date="' + valueDate.getFullYear() + '-' + valueDate.getMonth() + '-' + valueDate.getDate() + '"]').addClass('picker-calendar-day-selected');
+ }
+ if (p.params.onChange) {
+ p.params.onChange(p, p.value, p.value.map(formatDate));
+ }
+ if (p.input && p.input.length > 0) {
+ if (p.params.formatValue) inputValue = p.params.formatValue(p, p.value);
+ else {
+ inputValue = [];
+ for (i = 0; i < p.value.length; i++) {
+ inputValue.push(formatDate(p.value[i]));
+ }
+ inputValue = inputValue.join(', ');
+ }
+ $(p.input).val(inputValue);
+ $(p.input).trigger('change');
+ }
+ };
+
+ // Columns Handlers
+ p.initCalendarEvents = function () {
+ var col;
+ var allowItemClick = true;
+ var isTouched, isMoved, touchStartX, touchStartY, touchCurrentX, touchCurrentY, touchStartTime, touchEndTime, startTranslate, currentTranslate, wrapperWidth, wrapperHeight, percentage, touchesDiff, isScrolling;
+ function handleTouchStart (e) {
+ if (isMoved || isTouched) return;
+ // e.preventDefault();
+ isTouched = true;
+ var position = $.getTouchPosition(e);
+ touchStartX = touchCurrentY = position.x;
+ touchStartY = touchCurrentY = position.y;
+ touchStartTime = (new Date()).getTime();
+ percentage = 0;
+ allowItemClick = true;
+ isScrolling = undefined;
+ startTranslate = currentTranslate = p.monthsTranslate;
+ }
+ function handleTouchMove (e) {
+ if (!isTouched) return;
+ var position = $.getTouchPosition(e);
+ touchCurrentX = position.x;
+ touchCurrentY = position.y;
+ if (typeof isScrolling === 'undefined') {
+ isScrolling = !!(isScrolling || Math.abs(touchCurrentY - touchStartY) > Math.abs(touchCurrentX - touchStartX));
+ }
+ if (p.isH && isScrolling) {
+ isTouched = false;
+ return;
+ }
+ e.preventDefault();
+ if (p.animating) {
+ isTouched = false;
+ return;
+ }
+ allowItemClick = false;
+ if (!isMoved) {
+ // First move
+ isMoved = true;
+ wrapperWidth = p.wrapper[0].offsetWidth;
+ wrapperHeight = p.wrapper[0].offsetHeight;
+ p.wrapper.transition(0);
+ }
+ e.preventDefault();
+
+ touchesDiff = p.isH ? touchCurrentX - touchStartX : touchCurrentY - touchStartY;
+ percentage = touchesDiff/(p.isH ? wrapperWidth : wrapperHeight);
+ currentTranslate = (p.monthsTranslate * inverter + percentage) * 100;
+
+ // Transform wrapper
+ p.wrapper.transform('translate3d(' + (p.isH ? currentTranslate : 0) + '%, ' + (p.isH ? 0 : currentTranslate) + '%, 0)');
+
+ }
+ function handleTouchEnd (e) {
+ if (!isTouched || !isMoved) {
+ isTouched = isMoved = false;
+ return;
+ }
+ isTouched = isMoved = false;
+
+ touchEndTime = new Date().getTime();
+ if (touchEndTime - touchStartTime < 300) {
+ if (Math.abs(touchesDiff) < 10) {
+ p.resetMonth();
+ }
+ else if (touchesDiff >= 10) {
+ if (rtl) p.nextMonth();
+ else p.prevMonth();
+ }
+ else {
+ if (rtl) p.prevMonth();
+ else p.nextMonth();
+ }
+ }
+ else {
+ if (percentage <= -0.5) {
+ if (rtl) p.prevMonth();
+ else p.nextMonth();
+ }
+ else if (percentage >= 0.5) {
+ if (rtl) p.nextMonth();
+ else p.prevMonth();
+ }
+ else {
+ p.resetMonth();
+ }
+ }
+
+ // Allow click
+ setTimeout(function () {
+ allowItemClick = true;
+ }, 100);
+ }
+
+ function handleDayClick(e) {
+ if (!allowItemClick) return;
+ var day = $(e.target).parents('.picker-calendar-day');
+ if (day.length === 0 && $(e.target).hasClass('picker-calendar-day')) {
+ day = $(e.target);
+ }
+ if (day.length === 0) return;
+ if (day.hasClass('picker-calendar-day-selected') && !p.params.multiple) return;
+ if (day.hasClass('picker-calendar-day-disabled')) return;
+ if (day.hasClass('picker-calendar-day-next')) p.nextMonth();
+ if (day.hasClass('picker-calendar-day-prev')) p.prevMonth();
+ var dateYear = day.attr('data-year');
+ var dateMonth = day.attr('data-month');
+ var dateDay = day.attr('data-day');
+ if (p.params.onDayClick) {
+ p.params.onDayClick(p, day[0], dateYear, dateMonth, dateDay);
+ }
+ p.addValue(new Date(dateYear, dateMonth, dateDay).getTime());
+ if (p.params.closeOnSelect) p.close();
+ }
+
+ p.container.find('.picker-calendar-prev-month').on('click', p.prevMonth);
+ p.container.find('.picker-calendar-next-month').on('click', p.nextMonth);
+ p.container.find('.picker-calendar-prev-year').on('click', p.prevYear);
+ p.container.find('.picker-calendar-next-year').on('click', p.nextYear);
+ p.wrapper.on('click', handleDayClick);
+ if (p.params.touchMove) {
+ p.wrapper.on($.touchEvents.start, handleTouchStart);
+ p.wrapper.on($.touchEvents.move, handleTouchMove);
+ p.wrapper.on($.touchEvents.end, handleTouchEnd);
+ }
+
+ p.container[0].f7DestroyCalendarEvents = function () {
+ p.container.find('.picker-calendar-prev-month').off('click', p.prevMonth);
+ p.container.find('.picker-calendar-next-month').off('click', p.nextMonth);
+ p.container.find('.picker-calendar-prev-year').off('click', p.prevYear);
+ p.container.find('.picker-calendar-next-year').off('click', p.nextYear);
+ p.wrapper.off('click', handleDayClick);
+ if (p.params.touchMove) {
+ p.wrapper.off($.touchEvents.start, handleTouchStart);
+ p.wrapper.off($.touchEvents.move, handleTouchMove);
+ p.wrapper.off($.touchEvents.end, handleTouchEnd);
+ }
+ };
+
+
+ };
+ p.destroyCalendarEvents = function (colContainer) {
+ if ('f7DestroyCalendarEvents' in p.container[0]) p.container[0].f7DestroyCalendarEvents();
+ };
+
+ // Calendar Methods
+ p.daysInMonth = function (date) {
+ var d = new Date(date);
+ return new Date(d.getFullYear(), d.getMonth() + 1, 0).getDate();
+ };
+ p.monthHTML = function (date, offset) {
+ date = new Date(date);
+ var year = date.getFullYear(),
+ month = date.getMonth(),
+ day = date.getDate();
+ if (offset === 'next') {
+ if (month === 11) date = new Date(year + 1, 0);
+ else date = new Date(year, month + 1, 1);
+ }
+ if (offset === 'prev') {
+ if (month === 0) date = new Date(year - 1, 11);
+ else date = new Date(year, month - 1, 1);
+ }
+ if (offset === 'next' || offset === 'prev') {
+ month = date.getMonth();
+ year = date.getFullYear();
+ }
+ var daysInPrevMonth = p.daysInMonth(new Date(date.getFullYear(), date.getMonth()).getTime() - 10 * 24 * 60 * 60 * 1000),
+ daysInMonth = p.daysInMonth(date),
+ firstDayOfMonthIndex = new Date(date.getFullYear(), date.getMonth()).getDay();
+ if (firstDayOfMonthIndex === 0) firstDayOfMonthIndex = 7;
+
+ var dayDate, currentValues = [], i, j,
+ rows = 6, cols = 7,
+ monthHTML = '',
+ dayIndex = 0 + (p.params.firstDay - 1),
+ today = new Date().setHours(0,0,0,0),
+ minDate = p.params.minDate ? new Date(p.params.minDate).getTime() : null,
+ maxDate = p.params.maxDate ? new Date(p.params.maxDate).getTime() : null;
+
+ if (p.value && p.value.length) {
+ for (i = 0; i < p.value.length; i++) {
+ currentValues.push(new Date(p.value[i]).setHours(0,0,0,0));
+ }
+ }
+
+ for (i = 1; i <= rows; i++) {
+ var rowHTML = '';
+ var row = i;
+ for (j = 1; j <= cols; j++) {
+ var col = j;
+ dayIndex ++;
+ var dayNumber = dayIndex - firstDayOfMonthIndex;
+ var addClass = '';
+ if (dayNumber < 0) {
+ dayNumber = daysInPrevMonth + dayNumber + 1;
+ addClass += ' picker-calendar-day-prev';
+ dayDate = new Date(month - 1 < 0 ? year - 1 : year, month - 1 < 0 ? 11 : month - 1, dayNumber).getTime();
+ }
+ else {
+ dayNumber = dayNumber + 1;
+ if (dayNumber > daysInMonth) {
+ dayNumber = dayNumber - daysInMonth;
+ addClass += ' picker-calendar-day-next';
+ dayDate = new Date(month + 1 > 11 ? year + 1 : year, month + 1 > 11 ? 0 : month + 1, dayNumber).getTime();
+ }
+ else {
+ dayDate = new Date(year, month, dayNumber).getTime();
+ }
+ }
+ // Today
+ if (dayDate === today) addClass += ' picker-calendar-day-today';
+ // Selected
+ if (currentValues.indexOf(dayDate) >= 0) addClass += ' picker-calendar-day-selected';
+ // Weekend
+ if (p.params.weekendDays.indexOf(col - 1) >= 0) {
+ addClass += ' picker-calendar-day-weekend';
+ }
+ // Disabled
+ if ((minDate && dayDate < minDate) || (maxDate && dayDate > maxDate)) {
+ addClass += ' picker-calendar-day-disabled';
+ }
+
+ dayDate = new Date(dayDate);
+ var dayYear = dayDate.getFullYear();
+ var dayMonth = dayDate.getMonth();
+ rowHTML += ''+dayNumber+'
';
+ }
+ monthHTML += '' + rowHTML + '
';
+ }
+ monthHTML = '' + monthHTML + '
';
+ return monthHTML;
+ };
+ p.animating = false;
+ p.updateCurrentMonthYear = function (dir) {
+ if (typeof dir === 'undefined') {
+ p.currentMonth = parseInt(p.months.eq(1).attr('data-month'), 10);
+ p.currentYear = parseInt(p.months.eq(1).attr('data-year'), 10);
+ }
+ else {
+ p.currentMonth = parseInt(p.months.eq(dir === 'next' ? (p.months.length - 1) : 0).attr('data-month'), 10);
+ p.currentYear = parseInt(p.months.eq(dir === 'next' ? (p.months.length - 1) : 0).attr('data-year'), 10);
+ }
+ p.container.find('.current-month-value').text(p.params.monthNames[p.currentMonth]);
+ p.container.find('.current-year-value').text(p.currentYear);
+
+ };
+ p.onMonthChangeStart = function (dir) {
+ p.updateCurrentMonthYear(dir);
+ p.months.removeClass('picker-calendar-month-current picker-calendar-month-prev picker-calendar-month-next');
+ var currentIndex = dir === 'next' ? p.months.length - 1 : 0;
+
+ p.months.eq(currentIndex).addClass('picker-calendar-month-current');
+ p.months.eq(dir === 'next' ? currentIndex - 1 : currentIndex + 1).addClass(dir === 'next' ? 'picker-calendar-month-prev' : 'picker-calendar-month-next');
+
+ if (p.params.onMonthYearChangeStart) {
+ p.params.onMonthYearChangeStart(p, p.currentYear, p.currentMonth);
+ }
+ };
+ p.onMonthChangeEnd = function (dir, rebuildBoth) {
+ p.animating = false;
+ var nextMonthHTML, prevMonthHTML, newMonthHTML;
+ p.wrapper.find('.picker-calendar-month:not(.picker-calendar-month-prev):not(.picker-calendar-month-current):not(.picker-calendar-month-next)').remove();
+
+ if (typeof dir === 'undefined') {
+ dir = 'next';
+ rebuildBoth = true;
+ }
+ if (!rebuildBoth) {
+ newMonthHTML = p.monthHTML(new Date(p.currentYear, p.currentMonth), dir);
+ }
+ else {
+ p.wrapper.find('.picker-calendar-month-next, .picker-calendar-month-prev').remove();
+ prevMonthHTML = p.monthHTML(new Date(p.currentYear, p.currentMonth), 'prev');
+ nextMonthHTML = p.monthHTML(new Date(p.currentYear, p.currentMonth), 'next');
+ }
+ if (dir === 'next' || rebuildBoth) {
+ p.wrapper.append(newMonthHTML || nextMonthHTML);
+ }
+ if (dir === 'prev' || rebuildBoth) {
+ p.wrapper.prepend(newMonthHTML || prevMonthHTML);
+ }
+ p.months = p.wrapper.find('.picker-calendar-month');
+ p.setMonthsTranslate(p.monthsTranslate);
+ if (p.params.onMonthAdd) {
+ p.params.onMonthAdd(p, dir === 'next' ? p.months.eq(p.months.length - 1)[0] : p.months.eq(0)[0]);
+ }
+ if (p.params.onMonthYearChangeEnd) {
+ p.params.onMonthYearChangeEnd(p, p.currentYear, p.currentMonth);
+ }
+ };
+ p.setMonthsTranslate = function (translate) {
+ translate = translate || p.monthsTranslate || 0;
+ if (typeof p.monthsTranslate === 'undefined') p.monthsTranslate = translate;
+ p.months.removeClass('picker-calendar-month-current picker-calendar-month-prev picker-calendar-month-next');
+ var prevMonthTranslate = -(translate + 1) * 100 * inverter;
+ var currentMonthTranslate = -translate * 100 * inverter;
+ var nextMonthTranslate = -(translate - 1) * 100 * inverter;
+ p.months.eq(0).transform('translate3d(' + (p.isH ? prevMonthTranslate : 0) + '%, ' + (p.isH ? 0 : prevMonthTranslate) + '%, 0)').addClass('picker-calendar-month-prev');
+ p.months.eq(1).transform('translate3d(' + (p.isH ? currentMonthTranslate : 0) + '%, ' + (p.isH ? 0 : currentMonthTranslate) + '%, 0)').addClass('picker-calendar-month-current');
+ p.months.eq(2).transform('translate3d(' + (p.isH ? nextMonthTranslate : 0) + '%, ' + (p.isH ? 0 : nextMonthTranslate) + '%, 0)').addClass('picker-calendar-month-next');
+ };
+ p.nextMonth = function (transition) {
+ if (typeof transition === 'undefined' || typeof transition === 'object') {
+ transition = '';
+ if (!p.params.animate) transition = 0;
+ }
+ var nextMonth = parseInt(p.months.eq(p.months.length - 1).attr('data-month'), 10);
+ var nextYear = parseInt(p.months.eq(p.months.length - 1).attr('data-year'), 10);
+ var nextDate = new Date(nextYear, nextMonth);
+ var nextDateTime = nextDate.getTime();
+ var transitionEndCallback = p.animating ? false : true;
+ if (p.params.maxDate) {
+ if (nextDateTime > new Date(p.params.maxDate).getTime()) {
+ return p.resetMonth();
+ }
+ }
+ p.monthsTranslate --;
+ if (nextMonth === p.currentMonth) {
+ var nextMonthTranslate = -(p.monthsTranslate) * 100 * inverter;
+ var nextMonthHTML = $(p.monthHTML(nextDateTime, 'next')).transform('translate3d(' + (p.isH ? nextMonthTranslate : 0) + '%, ' + (p.isH ? 0 : nextMonthTranslate) + '%, 0)').addClass('picker-calendar-month-next');
+ p.wrapper.append(nextMonthHTML[0]);
+ p.months = p.wrapper.find('.picker-calendar-month');
+ if (p.params.onMonthAdd) {
+ p.params.onMonthAdd(p, p.months.eq(p.months.length - 1)[0]);
+ }
+ }
+ p.animating = true;
+ p.onMonthChangeStart('next');
+ var translate = (p.monthsTranslate * 100) * inverter;
+
+ p.wrapper.transition(transition).transform('translate3d(' + (p.isH ? translate : 0) + '%, ' + (p.isH ? 0 : translate) + '%, 0)');
+ if (transitionEndCallback) {
+ p.wrapper.transitionEnd(function () {
+ p.onMonthChangeEnd('next');
+ });
+ }
+ if (!p.params.animate) {
+ p.onMonthChangeEnd('next');
+ }
+ };
+ p.prevMonth = function (transition) {
+ if (typeof transition === 'undefined' || typeof transition === 'object') {
+ transition = '';
+ if (!p.params.animate) transition = 0;
+ }
+ var prevMonth = parseInt(p.months.eq(0).attr('data-month'), 10);
+ var prevYear = parseInt(p.months.eq(0).attr('data-year'), 10);
+ var prevDate = new Date(prevYear, prevMonth + 1, -1);
+ var prevDateTime = prevDate.getTime();
+ var transitionEndCallback = p.animating ? false : true;
+ if (p.params.minDate) {
+ if (prevDateTime < new Date(p.params.minDate).getTime()) {
+ return p.resetMonth();
+ }
+ }
+ p.monthsTranslate ++;
+ if (prevMonth === p.currentMonth) {
+ var prevMonthTranslate = -(p.monthsTranslate) * 100 * inverter;
+ var prevMonthHTML = $(p.monthHTML(prevDateTime, 'prev')).transform('translate3d(' + (p.isH ? prevMonthTranslate : 0) + '%, ' + (p.isH ? 0 : prevMonthTranslate) + '%, 0)').addClass('picker-calendar-month-prev');
+ p.wrapper.prepend(prevMonthHTML[0]);
+ p.months = p.wrapper.find('.picker-calendar-month');
+ if (p.params.onMonthAdd) {
+ p.params.onMonthAdd(p, p.months.eq(0)[0]);
+ }
+ }
+ p.animating = true;
+ p.onMonthChangeStart('prev');
+ var translate = (p.monthsTranslate * 100) * inverter;
+ p.wrapper.transition(transition).transform('translate3d(' + (p.isH ? translate : 0) + '%, ' + (p.isH ? 0 : translate) + '%, 0)');
+ if (transitionEndCallback) {
+ p.wrapper.transitionEnd(function () {
+ p.onMonthChangeEnd('prev');
+ });
+ }
+ if (!p.params.animate) {
+ p.onMonthChangeEnd('prev');
+ }
+ };
+ p.resetMonth = function (transition) {
+ if (typeof transition === 'undefined') transition = '';
+ var translate = (p.monthsTranslate * 100) * inverter;
+ p.wrapper.transition(transition).transform('translate3d(' + (p.isH ? translate : 0) + '%, ' + (p.isH ? 0 : translate) + '%, 0)');
+ };
+ p.setYearMonth = function (year, month, transition) {
+ if (typeof year === 'undefined') year = p.currentYear;
+ if (typeof month === 'undefined') month = p.currentMonth;
+ if (typeof transition === 'undefined' || typeof transition === 'object') {
+ transition = '';
+ if (!p.params.animate) transition = 0;
+ }
+ var targetDate;
+ if (year < p.currentYear) {
+ targetDate = new Date(year, month + 1, -1).getTime();
+ }
+ else {
+ targetDate = new Date(year, month).getTime();
+ }
+ if (p.params.maxDate && targetDate > new Date(p.params.maxDate).getTime()) {
+ return false;
+ }
+ if (p.params.minDate && targetDate < new Date(p.params.minDate).getTime()) {
+ return false;
+ }
+ var currentDate = new Date(p.currentYear, p.currentMonth).getTime();
+ var dir = targetDate > currentDate ? 'next' : 'prev';
+ var newMonthHTML = p.monthHTML(new Date(year, month));
+ p.monthsTranslate = p.monthsTranslate || 0;
+ var prevTranslate = p.monthsTranslate;
+ var monthTranslate, wrapperTranslate;
+ var transitionEndCallback = p.animating ? false : true;
+ if (targetDate > currentDate) {
+ // To next
+ p.monthsTranslate --;
+ if (!p.animating) p.months.eq(p.months.length - 1).remove();
+ p.wrapper.append(newMonthHTML);
+ p.months = p.wrapper.find('.picker-calendar-month');
+ monthTranslate = -(prevTranslate - 1) * 100 * inverter;
+ p.months.eq(p.months.length - 1).transform('translate3d(' + (p.isH ? monthTranslate : 0) + '%, ' + (p.isH ? 0 : monthTranslate) + '%, 0)').addClass('picker-calendar-month-next');
+ }
+ else {
+ // To prev
+ p.monthsTranslate ++;
+ if (!p.animating) p.months.eq(0).remove();
+ p.wrapper.prepend(newMonthHTML);
+ p.months = p.wrapper.find('.picker-calendar-month');
+ monthTranslate = -(prevTranslate + 1) * 100 * inverter;
+ p.months.eq(0).transform('translate3d(' + (p.isH ? monthTranslate : 0) + '%, ' + (p.isH ? 0 : monthTranslate) + '%, 0)').addClass('picker-calendar-month-prev');
+ }
+ if (p.params.onMonthAdd) {
+ p.params.onMonthAdd(p, dir === 'next' ? p.months.eq(p.months.length - 1)[0] : p.months.eq(0)[0]);
+ }
+ p.animating = true;
+ p.onMonthChangeStart(dir);
+ wrapperTranslate = (p.monthsTranslate * 100) * inverter;
+ p.wrapper.transition(transition).transform('translate3d(' + (p.isH ? wrapperTranslate : 0) + '%, ' + (p.isH ? 0 : wrapperTranslate) + '%, 0)');
+ if (transitionEndCallback) {
+ p.wrapper.transitionEnd(function () {
+ p.onMonthChangeEnd(dir, true);
+ });
+ }
+ if (!p.params.animate) {
+ p.onMonthChangeEnd(dir);
+ }
+ };
+ p.nextYear = function () {
+ p.setYearMonth(p.currentYear + 1);
+ };
+ p.prevYear = function () {
+ p.setYearMonth(p.currentYear - 1);
+ };
+
+
+ // HTML Layout
+ p.layout = function () {
+ var pickerHTML = '';
+ var pickerClass = '';
+ var i;
+
+ var layoutDate = p.value && p.value.length ? p.value[0] : new Date().setHours(0,0,0,0);
+ var prevMonthHTML = p.monthHTML(layoutDate, 'prev');
+ var currentMonthHTML = p.monthHTML(layoutDate);
+ var nextMonthHTML = p.monthHTML(layoutDate, 'next');
+ var monthsHTML = '' + (prevMonthHTML + currentMonthHTML + nextMonthHTML) + '
';
+ // Week days header
+ var weekHeaderHTML = '';
+ if (p.params.weekHeader) {
+ for (i = 0; i < 7; i++) {
+ var weekDayIndex = (i + p.params.firstDay > 6) ? (i - 7 + p.params.firstDay) : (i + p.params.firstDay);
+ var dayName = p.params.dayNamesShort[weekDayIndex];
+ weekHeaderHTML += ' ' + dayName + '
';
+
+ }
+ weekHeaderHTML = '' + weekHeaderHTML + '
';
+ }
+ pickerClass = 'picker-modal picker-calendar ' + (p.params.cssClass || '');
+ var toolbarHTML = p.params.toolbar ? p.params.toolbarTemplate.replace(/{{closeText}}/g, p.params.toolbarCloseText) : '';
+ if (p.params.toolbar) {
+ toolbarHTML = p.params.toolbarTemplate
+ .replace(/{{closeText}}/g, p.params.toolbarCloseText)
+ .replace(/{{monthPicker}}/g, (p.params.monthPicker ? p.params.monthPickerTemplate : ''))
+ .replace(/{{yearPicker}}/g, (p.params.yearPicker ? p.params.yearPickerTemplate : ''));
+ }
+
+ pickerHTML =
+ '' +
+ toolbarHTML +
+ '
' +
+ weekHeaderHTML +
+ monthsHTML +
+ '
' +
+ '
';
+
+
+ p.pickerHTML = pickerHTML;
+ };
+
+ // Input Events
+ function openOnInput(e) {
+ e.preventDefault();
+ if (p.opened) return;
+ p.open();
+ if (p.params.scrollToInput && !isPopover()) {
+ var pageContent = p.input.parents('.page-content');
+ if (pageContent.length === 0) return;
+
+ var paddingTop = parseInt(pageContent.css('padding-top'), 10),
+ paddingBottom = parseInt(pageContent.css('padding-bottom'), 10),
+ pageHeight = pageContent[0].offsetHeight - paddingTop - p.container.height(),
+ pageScrollHeight = pageContent[0].scrollHeight - paddingTop - p.container.height(),
+ newPaddingBottom;
+
+ var inputTop = p.input.offset().top - paddingTop + p.input[0].offsetHeight;
+ if (inputTop > pageHeight) {
+ var scrollTop = pageContent.scrollTop() + inputTop - pageHeight;
+ if (scrollTop + pageHeight > pageScrollHeight) {
+ newPaddingBottom = scrollTop + pageHeight - pageScrollHeight + paddingBottom;
+ if (pageHeight === pageScrollHeight) {
+ newPaddingBottom = p.container.height();
+ }
+ pageContent.css({'padding-bottom': (newPaddingBottom) + 'px'});
+ }
+ pageContent.scrollTop(scrollTop, 300);
+ }
+ }
+ }
+ function closeOnHTMLClick(e) {
+ if (inPopover()) return;
+ if (p.input && p.input.length > 0) {
+ if (e.target !== p.input[0] && $(e.target).parents('.picker-modal').length === 0) p.close();
+ }
+ else {
+ if ($(e.target).parents('.picker-modal').length === 0) p.close();
+ }
+ }
+
+ if (p.params.input) {
+ p.input = $(p.params.input);
+ if (p.input.length > 0) {
+ if (p.params.inputReadOnly) p.input.prop('readOnly', true);
+ if (!p.inline) {
+ p.input.on("click", function(e) {
+ openOnInput(e);
+ //修复部分安卓系统下,即使设置了readonly依然会弹出系统键盘的bug
+ if (p.params.inputReadOnly) {
+ this.focus();
+ this.blur();
+ }
+ });
+ }
+ if (p.params.inputReadOnly) {
+ p.input.on('focus mousedown', function (e) {
+ e.preventDefault();
+ });
+ }
+ }
+ }
+
+ if (!p.inline) $('html').on('click', closeOnHTMLClick);
+
+ // Open
+ function onPickerClose() {
+ p.opened = false;
+ if (p.input && p.input.length > 0) p.input.parents('.page-content').css({'padding-bottom': ''});
+ if (p.params.onClose) p.params.onClose(p);
+
+ // Destroy events
+ p.destroyCalendarEvents();
+ }
+
+ p.opened = false;
+ p.open = function () {
+ var toPopover = isPopover();
+ var updateValue = false;
+ if (!p.opened) {
+ // Set date value
+ if (!p.value) {
+ if (p.params.value) {
+ p.value = p.params.value;
+ updateValue = true;
+ }
+ }
+
+ // Layout
+ p.layout();
+
+ // Append
+ if (toPopover) {
+ p.pickerHTML = '';
+ p.popover = $.popover(p.pickerHTML, p.params.input, true);
+ p.container = $(p.popover).find('.picker-modal');
+ $(p.popover).on('close', function () {
+ onPickerClose();
+ });
+ }
+ else if (p.inline) {
+ p.container = $(p.pickerHTML);
+ p.container.addClass('picker-modal-inline');
+ $(p.params.container).append(p.container);
+ }
+ else {
+ p.container = $($.pickerModal(p.pickerHTML));
+ $(p.container)
+ .on('close', function () {
+ onPickerClose();
+ });
+ }
+
+ // Store calendar instance
+ p.container[0].f7Calendar = p;
+ p.wrapper = p.container.find('.picker-calendar-months-wrapper');
+
+ // Months
+ p.months = p.wrapper.find('.picker-calendar-month');
+
+ // Update current month and year
+ p.updateCurrentMonthYear();
+
+ // Set initial translate
+ p.monthsTranslate = 0;
+ p.setMonthsTranslate();
+
+ // Init events
+ p.initCalendarEvents();
+
+ // Update input value
+ if (updateValue) p.updateValue();
+
+ }
+
+ // Set flag
+ p.opened = true;
+ p.initialized = true;
+ if (p.params.onMonthAdd) {
+ p.months.each(function () {
+ p.params.onMonthAdd(p, this);
+ });
+ }
+ if (p.params.onOpen) p.params.onOpen(p);
+ };
+
+ // Close
+ p.close = function () {
+ if (!p.opened || p.inline) return;
+ if (inPopover()) {
+ $.closeModal(p.popover);
+ return;
+ }
+ else {
+ $.closeModal(p.container);
+ return;
+ }
+ };
+
+ // Destroy
+ p.destroy = function () {
+ p.close();
+ if (p.params.input && p.input.length > 0) {
+ p.input.off('click focus', openOnInput);
+ }
+ $('html').off('click', closeOnHTMLClick);
+ };
+
+ if (p.inline) {
+ p.open();
+ }
+
+ return p;
+ };
+ $.fn.calendar = function (params) {
+ return this.each(function() {
+ var $this = $(this);
+ if(!$this[0]) return;
+ var calendar = $this.data("calendar");
+ if(!calendar) {
+ var p = {};
+ if($this[0].tagName.toUpperCase() === "INPUT") {
+ p.input = $this;
+ } else {
+ p.container = $this;
+ }
+ $this.data("calendar", new Calendar($.extend(p, params)));
+ }
+ });
+ };
+
+ defaults = $.fn.calendar.prototype.defaults = {
+ monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August' , 'September' , 'October', 'November', 'December'],
+ monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
+ dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
+ dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
+ firstDay: 1, // First day of the week, Monday
+ weekendDays: [0, 6], // Sunday and Saturday
+ multiple: false,
+ dateFormat: 'yyyy-mm-dd',
+ direction: 'horizontal', // or 'vertical'
+ minDate: null,
+ maxDate: null,
+ touchMove: true,
+ animate: true,
+ closeOnSelect: true,
+ monthPicker: true,
+ monthPickerTemplate:
+ '' +
+ '
' +
+ '
' +
+ '
' +
+ '
',
+ yearPicker: true,
+ yearPickerTemplate:
+ '' +
+ '
' +
+ '
' +
+ '
' +
+ '
',
+ weekHeader: true,
+ // Common settings
+ scrollToInput: true,
+ inputReadOnly: true,
+ convertToPopover: true,
+ onlyInPopover: false,
+ toolbar: true,
+ toolbarCloseText: 'Done',
+ toolbarTemplate:
+ '',
+ /* Callbacks
+ onMonthAdd
+ onChange
+ onOpen
+ onClose
+ onDayClick
+ onMonthYearChangeStart
+ onMonthYearChangeEnd
+ */
+ };
+
+ $.initCalendar = function(content) {
+ var $content = content ? $(content) : $(document.body);
+ $content.find("[data-toggle='date']").each(function() {
+ $(this).calendar();
+ });
+ };
+}($);
+
+/*======================================================
+************ Picker ************
+======================================================*/
+/* global $:true */
+/* jshint unused:false */
+/* jshint multistr:true */
++ function($) {
+ "use strict";
+ var Picker = function (params) {
+ var p = this;
+ var defaults = {
+ updateValuesOnMomentum: false,
+ updateValuesOnTouchmove: true,
+ rotateEffect: false,
+ momentumRatio: 7,
+ freeMode: false,
+ // Common settings
+ scrollToInput: true,
+ inputReadOnly: true,
+ convertToPopover: true,
+ onlyInPopover: false,
+ toolbar: true,
+ toolbarCloseText: 'OK',
+ toolbarTemplate: '',
+ };
+ params = params || {};
+ for (var def in defaults) {
+ if (typeof params[def] === 'undefined') {
+ params[def] = defaults[def];
+ }
+ }
+ p.params = params;
+ p.cols = [];
+ p.initialized = false;
+
+ // Inline flag
+ p.inline = p.params.container ? true : false;
+
+ // 3D Transforms origin bug, only on safari
+ var originBug = $.device.ios || (navigator.userAgent.toLowerCase().indexOf('safari') >= 0 && navigator.userAgent.toLowerCase().indexOf('chrome') < 0) && !$.device.android;
+
+ // Should be converted to popover
+ function isPopover() {
+ var toPopover = false;
+ if (!p.params.convertToPopover && !p.params.onlyInPopover) return toPopover;
+ if (!p.inline && p.params.input) {
+ if (p.params.onlyInPopover) toPopover = true;
+ else {
+ if ($.device.ios) {
+ toPopover = $.device.ipad ? true : false;
+ }
+ else {
+ if ($(window).width() >= 768) toPopover = true;
+ }
+ }
+ }
+ return toPopover;
+ }
+ function inPopover() {
+ if (p.opened && p.container && p.container.length > 0 && p.container.parents('.popover').length > 0) return true;
+ else return false;
+ }
+
+ // Value
+ p.setValue = function (arrValues, transition) {
+ var valueIndex = 0;
+ for (var i = 0; i < p.cols.length; i++) {
+ if (p.cols[i] && !p.cols[i].divider) {
+ p.cols[i].setValue(arrValues[valueIndex], transition);
+ valueIndex++;
+ }
+ }
+ };
+ p.updateValue = function () {
+ var newValue = [];
+ var newDisplayValue = [];
+ for (var i = 0; i < p.cols.length; i++) {
+ if (!p.cols[i].divider) {
+ newValue.push(p.cols[i].value);
+ newDisplayValue.push(p.cols[i].displayValue);
+ }
+ }
+ if (newValue.indexOf(undefined) >= 0) {
+ return;
+ }
+ p.value = newValue;
+ p.displayValue = newDisplayValue;
+ if (p.params.onChange) {
+ p.params.onChange(p, p.value, p.displayValue);
+ }
+ if (p.input && p.input.length > 0) {
+ $(p.input).val(p.params.formatValue ? p.params.formatValue(p, p.value, p.displayValue) : p.value.join(' '));
+ $(p.input).trigger('change');
+ }
+ };
+
+ // Columns Handlers
+ p.initPickerCol = function (colElement, updateItems) {
+ var colContainer = $(colElement);
+ var colIndex = colContainer.index();
+ var col = p.cols[colIndex];
+ if (col.divider) return;
+ col.container = colContainer;
+ col.wrapper = col.container.find('.picker-items-col-wrapper');
+ col.items = col.wrapper.find('.picker-item');
+
+ var i, j;
+ var wrapperHeight, itemHeight, itemsHeight, minTranslate, maxTranslate;
+ col.replaceValues = function (values, displayValues) {
+ col.destroyEvents();
+ col.values = values;
+ col.displayValues = displayValues;
+ var newItemsHTML = p.columnHTML(col, true);
+ col.wrapper.html(newItemsHTML);
+ col.items = col.wrapper.find('.picker-item');
+ col.calcSize();
+ col.setValue(col.values[0], 0, true);
+ col.initEvents();
+ };
+ col.calcSize = function () {
+ if (p.params.rotateEffect) {
+ col.container.removeClass('picker-items-col-absolute');
+ if (!col.width) col.container.css({width:''});
+ }
+ var colWidth, colHeight;
+ colWidth = 0;
+ colHeight = col.container[0].offsetHeight;
+ wrapperHeight = col.wrapper[0].offsetHeight;
+ itemHeight = col.items[0].offsetHeight;
+ itemsHeight = itemHeight * col.items.length;
+ minTranslate = colHeight / 2 - itemsHeight + itemHeight / 2;
+ maxTranslate = colHeight / 2 - itemHeight / 2;
+ if (col.width) {
+ colWidth = col.width;
+ if (parseInt(colWidth, 10) === colWidth) colWidth = colWidth + 'px';
+ col.container.css({width: colWidth});
+ }
+ if (p.params.rotateEffect) {
+ if (!col.width) {
+ col.items.each(function () {
+ var item = $(this);
+ item.css({width:'auto'});
+ colWidth = Math.max(colWidth, item[0].offsetWidth);
+ item.css({width:''});
+ });
+ col.container.css({width: (colWidth + 2) + 'px'});
+ }
+ col.container.addClass('picker-items-col-absolute');
+ }
+ };
+ col.calcSize();
+
+ col.wrapper.transform('translate3d(0,' + maxTranslate + 'px,0)').transition(0);
+
+
+ var activeIndex = 0;
+ var animationFrameId;
+
+ // Set Value Function
+ col.setValue = function (newValue, transition, valueCallbacks) {
+ if (typeof transition === 'undefined') transition = '';
+ var newActiveIndex = col.wrapper.find('.picker-item[data-picker-value="' + newValue + '"]').index();
+ if(typeof newActiveIndex === 'undefined' || newActiveIndex === -1) {
+ return;
+ }
+ var newTranslate = -newActiveIndex * itemHeight + maxTranslate;
+ // Update wrapper
+ col.wrapper.transition(transition);
+ col.wrapper.transform('translate3d(0,' + (newTranslate) + 'px,0)');
+
+ // Watch items
+ if (p.params.updateValuesOnMomentum && col.activeIndex && col.activeIndex !== newActiveIndex ) {
+ $.cancelAnimationFrame(animationFrameId);
+ col.wrapper.transitionEnd(function(){
+ $.cancelAnimationFrame(animationFrameId);
+ });
+ updateDuringScroll();
+ }
+
+ // Update items
+ col.updateItems(newActiveIndex, newTranslate, transition, valueCallbacks);
+ };
+
+ col.updateItems = function (activeIndex, translate, transition, valueCallbacks) {
+ if (typeof translate === 'undefined') {
+ translate = $.getTranslate(col.wrapper[0], 'y');
+ }
+ if(typeof activeIndex === 'undefined') activeIndex = -Math.round((translate - maxTranslate)/itemHeight);
+ if (activeIndex < 0) activeIndex = 0;
+ if (activeIndex >= col.items.length) activeIndex = col.items.length - 1;
+ var previousActiveIndex = col.activeIndex;
+ col.activeIndex = activeIndex;
+ /*
+ col.wrapper.find('.picker-selected, .picker-after-selected, .picker-before-selected').removeClass('picker-selected picker-after-selected picker-before-selected');
+
+ col.items.transition(transition);
+ var selectedItem = col.items.eq(activeIndex).addClass('picker-selected').transform('');
+ var prevItems = selectedItem.prevAll().addClass('picker-before-selected');
+ var nextItems = selectedItem.nextAll().addClass('picker-after-selected');
+ */
+ //去掉 .picker-after-selected, .picker-before-selected 以提高性能
+ col.wrapper.find('.picker-selected').removeClass('picker-selected');
+ if (p.params.rotateEffect) {
+ col.items.transition(transition);
+ }
+ var selectedItem = col.items.eq(activeIndex).addClass('picker-selected').transform('');
+
+ if (valueCallbacks || typeof valueCallbacks === 'undefined') {
+ // Update values
+ col.value = selectedItem.attr('data-picker-value');
+ col.displayValue = col.displayValues ? col.displayValues[activeIndex] : col.value;
+ // On change callback
+ if (previousActiveIndex !== activeIndex) {
+ if (col.onChange) {
+ col.onChange(p, col.value, col.displayValue);
+ }
+ p.updateValue();
+ }
+ }
+
+ // Set 3D rotate effect
+ if (!p.params.rotateEffect) {
+ return;
+ }
+ var percentage = (translate - (Math.floor((translate - maxTranslate)/itemHeight) * itemHeight + maxTranslate)) / itemHeight;
+
+ col.items.each(function () {
+ var item = $(this);
+ var itemOffsetTop = item.index() * itemHeight;
+ var translateOffset = maxTranslate - translate;
+ var itemOffset = itemOffsetTop - translateOffset;
+ var percentage = itemOffset / itemHeight;
+
+ var itemsFit = Math.ceil(col.height / itemHeight / 2) + 1;
+
+ var angle = (-18*percentage);
+ if (angle > 180) angle = 180;
+ if (angle < -180) angle = -180;
+ // Far class
+ if (Math.abs(percentage) > itemsFit) item.addClass('picker-item-far');
+ else item.removeClass('picker-item-far');
+ // Set transform
+ item.transform('translate3d(0, ' + (-translate + maxTranslate) + 'px, ' + (originBug ? -110 : 0) + 'px) rotateX(' + angle + 'deg)');
+ });
+ };
+
+ function updateDuringScroll() {
+ animationFrameId = $.requestAnimationFrame(function () {
+ col.updateItems(undefined, undefined, 0);
+ updateDuringScroll();
+ });
+ }
+
+ // Update items on init
+ if (updateItems) col.updateItems(0, maxTranslate, 0);
+
+ var allowItemClick = true;
+ var isTouched, isMoved, touchStartY, touchCurrentY, touchStartTime, touchEndTime, startTranslate, returnTo, currentTranslate, prevTranslate, velocityTranslate, velocityTime;
+ function handleTouchStart (e) {
+ if (isMoved || isTouched) return;
+ e.preventDefault();
+ isTouched = true;
+ var position = $.getTouchPosition(e);
+ touchStartY = touchCurrentY = position.y;
+ touchStartTime = (new Date()).getTime();
+
+ allowItemClick = true;
+ startTranslate = currentTranslate = $.getTranslate(col.wrapper[0], 'y');
+ }
+ function handleTouchMove (e) {
+ if (!isTouched) return;
+ e.preventDefault();
+ allowItemClick = false;
+ var position = $.getTouchPosition(e);
+ touchCurrentY = position.y;
+ if (!isMoved) {
+ // First move
+ $.cancelAnimationFrame(animationFrameId);
+ isMoved = true;
+ startTranslate = currentTranslate = $.getTranslate(col.wrapper[0], 'y');
+ col.wrapper.transition(0);
+ }
+ e.preventDefault();
+
+ var diff = touchCurrentY - touchStartY;
+ currentTranslate = startTranslate + diff;
+ returnTo = undefined;
+
+ // Normalize translate
+ if (currentTranslate < minTranslate) {
+ currentTranslate = minTranslate - Math.pow(minTranslate - currentTranslate, 0.8);
+ returnTo = 'min';
+ }
+ if (currentTranslate > maxTranslate) {
+ currentTranslate = maxTranslate + Math.pow(currentTranslate - maxTranslate, 0.8);
+ returnTo = 'max';
+ }
+ // Transform wrapper
+ col.wrapper.transform('translate3d(0,' + currentTranslate + 'px,0)');
+
+ // Update items
+ col.updateItems(undefined, currentTranslate, 0, p.params.updateValuesOnTouchmove);
+
+ // Calc velocity
+ velocityTranslate = currentTranslate - prevTranslate || currentTranslate;
+ velocityTime = (new Date()).getTime();
+ prevTranslate = currentTranslate;
+ }
+ function handleTouchEnd (e) {
+ if (!isTouched || !isMoved) {
+ isTouched = isMoved = false;
+ return;
+ }
+ isTouched = isMoved = false;
+ col.wrapper.transition('');
+ if (returnTo) {
+ if (returnTo === 'min') {
+ col.wrapper.transform('translate3d(0,' + minTranslate + 'px,0)');
+ }
+ else col.wrapper.transform('translate3d(0,' + maxTranslate + 'px,0)');
+ }
+ touchEndTime = new Date().getTime();
+ var velocity, newTranslate;
+ if (touchEndTime - touchStartTime > 300) {
+ newTranslate = currentTranslate;
+ }
+ else {
+ velocity = Math.abs(velocityTranslate / (touchEndTime - velocityTime));
+ newTranslate = currentTranslate + velocityTranslate * p.params.momentumRatio;
+ }
+
+ newTranslate = Math.max(Math.min(newTranslate, maxTranslate), minTranslate);
+
+ // Active Index
+ var activeIndex = -Math.floor((newTranslate - maxTranslate)/itemHeight);
+
+ // Normalize translate
+ if (!p.params.freeMode) newTranslate = -activeIndex * itemHeight + maxTranslate;
+
+ // Transform wrapper
+ col.wrapper.transform('translate3d(0,' + (parseInt(newTranslate,10)) + 'px,0)');
+
+ // Update items
+ col.updateItems(activeIndex, newTranslate, '', true);
+
+ // Watch items
+ if (p.params.updateValuesOnMomentum) {
+ updateDuringScroll();
+ col.wrapper.transitionEnd(function(){
+ $.cancelAnimationFrame(animationFrameId);
+ });
+ }
+
+ // Allow click
+ setTimeout(function () {
+ allowItemClick = true;
+ }, 100);
+ }
+
+ function handleClick(e) {
+ if (!allowItemClick) return;
+ $.cancelAnimationFrame(animationFrameId);
+ /*jshint validthis:true */
+ var value = $(this).attr('data-picker-value');
+ col.setValue(value);
+ }
+
+ col.initEvents = function (detach) {
+ var method = detach ? 'off' : 'on';
+ col.container[method]($.touchEvents.start, handleTouchStart);
+ col.container[method]($.touchEvents.move, handleTouchMove);
+ col.container[method]($.touchEvents.end, handleTouchEnd);
+ col.items[method]('click', handleClick);
+ };
+ col.destroyEvents = function () {
+ col.initEvents(true);
+ };
+
+ col.container[0].f7DestroyPickerCol = function () {
+ col.destroyEvents();
+ };
+
+ col.initEvents();
+
+ };
+ p.destroyPickerCol = function (colContainer) {
+ colContainer = $(colContainer);
+ if ('f7DestroyPickerCol' in colContainer[0]) colContainer[0].f7DestroyPickerCol();
+ };
+ // Resize cols
+ function resizeCols() {
+ if (!p.opened) return;
+ for (var i = 0; i < p.cols.length; i++) {
+ if (!p.cols[i].divider) {
+ p.cols[i].calcSize();
+ p.cols[i].setValue(p.cols[i].value, 0, false);
+ }
+ }
+ }
+ $(window).on('resize', resizeCols);
+
+ // HTML Layout
+ p.columnHTML = function (col, onlyItems) {
+ var columnItemsHTML = '';
+ var columnHTML = '';
+ if (col.divider) {
+ columnHTML += '' + col.content + '
';
+ }
+ else {
+ for (var j = 0; j < col.values.length; j++) {
+ columnItemsHTML += '' + (col.displayValues ? col.displayValues[j] : col.values[j]) + '
';
+ }
+ columnHTML += '';
+ }
+ return onlyItems ? columnItemsHTML : columnHTML;
+ };
+ p.layout = function () {
+ var pickerHTML = '';
+ var pickerClass = '';
+ var i;
+ p.cols = [];
+ var colsHTML = '';
+ for (i = 0; i < p.params.cols.length; i++) {
+ var col = p.params.cols[i];
+ colsHTML += p.columnHTML(p.params.cols[i]);
+ p.cols.push(col);
+ }
+ pickerClass = 'picker-modal picker-columns ' + (p.params.cssClass || '') + (p.params.rotateEffect ? ' picker-3d' : '');
+ pickerHTML =
+ '' +
+ (p.params.toolbar ? p.params.toolbarTemplate.replace(/{{closeText}}/g, p.params.toolbarCloseText) : '') +
+ '
' +
+ colsHTML +
+ '
' +
+ '
' +
+ '
';
+
+ p.pickerHTML = pickerHTML;
+ };
+
+ // Input Events
+ function openOnInput(e) {
+ e.preventDefault();
+ if (p.opened) return;
+ p.open();
+ if (p.params.scrollToInput && !isPopover()) {
+ var pageContent = p.input.parents('.content');
+ if (pageContent.length === 0) return;
+
+ var paddingTop = parseInt(pageContent.css('padding-top'), 10),
+ paddingBottom = parseInt(pageContent.css('padding-bottom'), 10),
+ pageHeight = pageContent[0].offsetHeight - paddingTop - p.container.height(),
+ pageScrollHeight = pageContent[0].scrollHeight - paddingTop - p.container.height(),
+ newPaddingBottom;
+ var inputTop = p.input.offset().top - paddingTop + p.input[0].offsetHeight;
+ if (inputTop > pageHeight) {
+ var scrollTop = pageContent.scrollTop() + inputTop - pageHeight;
+ if (scrollTop + pageHeight > pageScrollHeight) {
+ newPaddingBottom = scrollTop + pageHeight - pageScrollHeight + paddingBottom;
+ if (pageHeight === pageScrollHeight) {
+ newPaddingBottom = p.container.height();
+ }
+ pageContent.css({'padding-bottom': (newPaddingBottom) + 'px'});
+ }
+ pageContent.scrollTop(scrollTop, 300);
+ }
+ }
+ }
+ function closeOnHTMLClick(e) {
+ if (inPopover()) return;
+ if (p.input && p.input.length > 0) {
+ if (e.target !== p.input[0] && $(e.target).parents('.picker-modal').length === 0) p.close();
+ }
+ else {
+ if ($(e.target).parents('.picker-modal').length === 0) p.close();
+ }
+ }
+
+ if (p.params.input) {
+ p.input = $(p.params.input);
+ if (p.input.length > 0) {
+ if (p.params.inputReadOnly) p.input.prop('readOnly', true);
+ if (!p.inline) {
+ p.input.on("click", function(e) {
+ openOnInput(e);
+ //修复部分安卓系统下,即使设置了readonly依然会弹出系统键盘的bug
+ if (p.params.inputReadOnly) {
+ this.focus();
+ this.blur();
+ }
+ });
+ }
+ if (p.params.inputReadOnly) {
+ p.input.on('focus mousedown', function (e) {
+ e.preventDefault();
+ });
+ }
+ }
+
+ }
+
+ if (!p.inline) $('html').on('click', closeOnHTMLClick);
+
+ // Open
+ function onPickerClose() {
+ p.opened = false;
+ if (p.input && p.input.length > 0) p.input.parents('.page-content').css({'padding-bottom': ''});
+ if (p.params.onClose) p.params.onClose(p);
+
+ // Destroy events
+ p.container.find('.picker-items-col').each(function () {
+ p.destroyPickerCol(this);
+ });
+ }
+
+ p.opened = false;
+ p.open = function () {
+ var toPopover = isPopover();
+
+ if (!p.opened) {
+
+ // Layout
+ p.layout();
+
+ // Append
+ if (toPopover) {
+ p.pickerHTML = '';
+ p.popover = $.popover(p.pickerHTML, p.params.input, true);
+ p.container = $(p.popover).find('.picker-modal');
+ $(p.popover).on('close', function () {
+ onPickerClose();
+ });
+ }
+ else if (p.inline) {
+ p.container = $(p.pickerHTML);
+ p.container.addClass('picker-modal-inline');
+ $(p.params.container).append(p.container);
+ }
+ else {
+ p.container = $($.pickerModal(p.pickerHTML));
+ $(p.container)
+ .on('close', function () {
+ onPickerClose();
+ });
+ }
+
+ // Store picker instance
+ p.container[0].f7Picker = p;
+
+ // Init Events
+ p.container.find('.picker-items-col').each(function () {
+ var updateItems = true;
+ if ((!p.initialized && p.params.value) || (p.initialized && p.value)) updateItems = false;
+ p.initPickerCol(this, updateItems);
+ });
+
+ // Set value
+ if (!p.initialized) {
+ if (p.params.value) {
+ p.setValue(p.params.value, 0);
+ }
+ }
+ else {
+ if (p.value) p.setValue(p.value, 0);
+ }
+ }
+
+ // Set flag
+ p.opened = true;
+ p.initialized = true;
+
+ if (p.params.onOpen) p.params.onOpen(p);
+ };
+
+ // Close
+ p.close = function () {
+ if (!p.opened || p.inline) return;
+ if (inPopover()) {
+ $.closeModal(p.popover);
+ return;
+ }
+ else {
+ $.closeModal(p.container);
+ return;
+ }
+ };
+
+ // Destroy
+ p.destroy = function () {
+ p.close();
+ if (p.params.input && p.input.length > 0) {
+ p.input.off('click focus', openOnInput);
+ }
+ $('html').off('click', closeOnHTMLClick);
+ $(window).off('resize', resizeCols);
+ };
+
+ if (p.inline) {
+ p.open();
+ }
+
+ return p;
+ };
+
+ $(document).on("click", ".close-picker", function() {
+ var pickerToClose = $('.picker-modal.modal-in');
+ if (pickerToClose.length > 0) {
+ $.closeModal(pickerToClose);
+ }
+ else {
+ pickerToClose = $('.popover.modal-in .picker-modal');
+ if (pickerToClose.length > 0) {
+ $.closeModal(pickerToClose.parents('.popover'));
+ }
+ }
+ });
+
+ //修复picker会滚动页面的bug
+ $(document).on($.touchEvents.move, ".picker-modal-inner", function(e) {
+ e.preventDefault();
+ });
+
+ $.fn.picker = function(params) {
+ var args = arguments;
+ return this.each(function() {
+ if(!this) return;
+ var $this = $(this);
+
+ var picker = $this.data("picker");
+ if(!picker) {
+ params = params || {};
+ var inputValue = $this.val();
+ if(params.value === undefined && inputValue !== "") {
+ params.value = params.cols.length > 1 ? inputValue.split(" ") : [inputValue];
+ }
+ var p = $.extend({input: this}, params);
+ picker = new Picker(p);
+ $this.data("picker", picker);
+ }
+ if(typeof params === typeof "a") {
+ picker[params].apply(picker, Array.prototype.slice.call(args, 1));
+ }
+ });
+ };
+}($);
+
+/* global $:true */
+/* jshint unused:false*/
+
++ function($) {
+ "use strict";
+
+
+ $.fn.datetimePicker = function(params) {
+ return this.each(function() {
+
+ if(!this) return;
+
+ var today = new Date();
+
+ var getDays = function(max) {
+ var days = [];
+ for(var i=1; i<= (max||31);i++) {
+ days.push(i < 10 ? "0"+i : i);
+ }
+ return days;
+ };
+
+ var getDaysByMonthAndYear = function(month, year) {
+ var int_d = new Date(year, parseInt(month)+1-1, 1);
+ var d = new Date(int_d - 1);
+ return getDays(d.getDate());
+ };
+
+ var formatNumber = function (n) {
+ return n < 10 ? "0" + n : n;
+ };
+
+ var initMonthes = ('01 02 03 04 05 06 07 08 09 10 11 12').split(' ');
+
+ var initYears = (function () {
+ var arr = [];
+ for (var i = 1950; i <= 2030; i++) { arr.push(i); }
+ return arr;
+ })();
+
+
+ var defaults = {
+
+ rotateEffect: false, //为了性能
+
+ value: [today.getFullYear(), formatNumber(today.getMonth()+1), today.getDate(), formatNumber(today.getHours()), formatNumber(today.getMinutes())],
+
+ onChange: function (picker, values, displayValues) {
+ var days = getDaysByMonthAndYear(picker.cols[1].value, picker.cols[0].value);
+ var currentValue = picker.cols[2].value;
+ if(currentValue > days.length) currentValue = days.length;
+ picker.cols[2].setValue(currentValue);
+ },
+
+ formatValue: function (p, values, displayValues) {
+ return displayValues[0] + '-' + values[1] + '-' + values[2] + ' ';
+ },
+
+ cols: [
+ // Years
+ {
+ values: initYears
+ },
+ // Months
+ {
+ values: initMonthes
+ },
+ // Days
+ {
+ values: getDays()
+ },
+
+// // Space divider
+// {
+// divider: true,
+// content: ' '
+// },
+// // Hours
+// {
+// values: (function () {
+// var arr = [];
+// for (var i = 0; i <= 23; i++) { arr.push(formatNumber(i)); }
+// return arr;
+// })(),
+// },
+// // Divider
+// {
+// divider: true,
+// content: ':'
+// },
+// // Minutes
+// {
+// values: (function () {
+// var arr = [];
+// for (var i = 0; i <= 59; i++) { arr.push(formatNumber(i)); }
+// return arr;
+// })(),
+// }
+ ]
+ };
+
+ params = params || {};
+ var inputValue = $(this).val();
+ if(params.value === undefined && inputValue !== "") {
+ params.value = [].concat(inputValue.split(" ")[0].split("-"), inputValue.split(" ")[1].split(":"));
+ }
+
+ var p = $.extend(defaults, params);
+ $(this).picker(p);
+ });
+ };
+
+}($);
+
++ function($) {
+ 'use strict';
+
+ $.initPullToRefresh = function(pageContainer) {
+ var eventsTarget = $(pageContainer);
+ if (!eventsTarget.hasClass('pull-to-refresh-content')) {
+ eventsTarget = eventsTarget.find('.pull-to-refresh-content');
+ }
+ if (!eventsTarget || eventsTarget.length === 0) return;
+
+ var isTouched, isMoved, touchesStart = {},
+ isScrolling, touchesDiff, touchStartTime, container, refresh = false,
+ useTranslate = false,
+ startTranslate = 0,
+ translate, scrollTop, wasScrolled, triggerDistance, dynamicTriggerDistance;
+
+ container = eventsTarget;
+
+ // Define trigger distance
+ if (container.attr('data-ptr-distance')) {
+ dynamicTriggerDistance = true;
+ } else {
+ triggerDistance = 44;
+ }
+
+ function handleTouchStart(e) {
+ if (isTouched) {
+ if ($.os.android) {
+ if ('targetTouches' in e && e.targetTouches.length > 1) return;
+ } else return;
+ }
+ isMoved = false;
+ isTouched = true;
+ isScrolling = undefined;
+ wasScrolled = undefined;
+ var position = $.getTouchPosition(e);
+ touchesStart.x = position.x;
+ touchesStart.y = position.y;
+ touchStartTime = (new Date()).getTime();
+ /*jshint validthis:true */
+ container = $(this);
+ }
+
+ function handleTouchMove(e) {
+ if (!isTouched) return;
+ var position = $.getTouchPosition(e);
+ var pageX = position.x;
+ var pageY = position.y;
+ if (typeof isScrolling === 'undefined') {
+ isScrolling = !!(isScrolling || Math.abs(pageY - touchesStart.y) > Math.abs(pageX - touchesStart.x));
+ }
+ if (!isScrolling) {
+ isTouched = false;
+ return;
+ }
+
+ scrollTop = container[0].scrollTop;
+ if (typeof wasScrolled === 'undefined' && scrollTop !== 0) wasScrolled = true;
+
+ if (!isMoved) {
+ /*jshint validthis:true */
+ container.removeClass('transitioning');
+ if (scrollTop > container[0].offsetHeight) {
+ isTouched = false;
+ return;
+ }
+ if (dynamicTriggerDistance) {
+ triggerDistance = container.attr('data-ptr-distance');
+ if (triggerDistance.indexOf('%') >= 0) triggerDistance = container[0].offsetHeight * parseInt(triggerDistance, 10) / 100;
+ }
+ startTranslate = container.hasClass('refreshing') ? triggerDistance : 0;
+ if (container[0].scrollHeight === container[0].offsetHeight || !$.os.ios) {
+ useTranslate = true;
+ } else {
+ useTranslate = false;
+ }
+ useTranslate = true;
+ }
+ isMoved = true;
+ touchesDiff = pageY - touchesStart.y;
+
+ if (touchesDiff > 0 && scrollTop <= 0 || scrollTop < 0) {
+ // iOS 8 fix
+ if ($.os.ios && parseInt($.os.version.split('.')[0], 10) > 7 && scrollTop === 0 && !wasScrolled) useTranslate = true;
+
+ if (useTranslate) {
+ e.preventDefault();
+ translate = (Math.pow(touchesDiff, 0.85) + startTranslate);
+ container.transform('translate3d(0,' + translate + 'px,0)');
+ } else {}
+ if ((useTranslate && Math.pow(touchesDiff, 0.85) > triggerDistance) || (!useTranslate && touchesDiff >= triggerDistance * 2)) {
+ refresh = true;
+ container.addClass('pull-up').removeClass('pull-down');
+ } else {
+ refresh = false;
+ container.removeClass('pull-up').addClass('pull-down');
+ }
+ } else {
+
+ container.removeClass('pull-up pull-down');
+ refresh = false;
+ return;
+ }
+ }
+
+ function handleTouchEnd() {
+ if (!isTouched || !isMoved) {
+ isTouched = false;
+ isMoved = false;
+ return;
+ }
+ if (translate) {
+ container.addClass('transitioning');
+ translate = 0;
+ }
+ container.transform('');
+ if (refresh) {
+ container.addClass('refreshing');
+ container.trigger('refresh', {
+ done: function() {
+ $.pullToRefreshDone(container);
+ }
+ });
+ } else {
+ container.removeClass('pull-down');
+ }
+ isTouched = false;
+ isMoved = false;
+ }
+
+ // Attach Events
+ eventsTarget.on($.touchEvents.start, handleTouchStart);
+ eventsTarget.on($.touchEvents.move, handleTouchMove);
+ eventsTarget.on($.touchEvents.end, handleTouchEnd);
+
+
+ function destroyPullToRefresh() {
+ eventsTarget.off($.touchEvents.start, handleTouchStart);
+ eventsTarget.off($.touchEvents.move, handleTouchMove);
+ eventsTarget.off($.touchEvents.end, handleTouchEnd);
+ }
+ eventsTarget[0].destroyPullToRefresh = destroyPullToRefresh;
+
+ };
+ $.pullToRefreshDone = function(container) {
+ container = $(container);
+ if (container.length === 0) container = $('.pull-to-refresh-content.refreshing');
+ container.removeClass('refreshing').addClass('transitioning');
+ container.transitionEnd(function() {
+ container.removeClass('transitioning pull-up pull-down');
+ });
+ };
+ $.pullToRefreshTrigger = function(container) {
+ container = $(container);
+ if (container.length === 0) container = $('.pull-to-refresh-content');
+ if (container.hasClass('refreshing')) return;
+ container.addClass('transitioning refreshing');
+ container.trigger('refresh', {
+ done: function() {
+ $.pullToRefreshDone(container);
+ }
+ });
+ };
+
+ $.destroyPullToRefresh = function(pageContainer) {
+ pageContainer = $(pageContainer);
+ var pullToRefreshContent = pageContainer.hasClass('pull-to-refresh-content') ? pageContainer : pageContainer.find('.pull-to-refresh-content');
+ if (pullToRefreshContent.length === 0) return;
+ if (pullToRefreshContent[0].destroyPullToRefresh) pullToRefreshContent[0].destroyPullToRefresh();
+ };
+
+}($); //jshint ignore:line
+
+/* global $:true */
++ function($) {
+ 'use strict';
+
+ function handleInfiniteScroll() {
+ /*jshint validthis:true */
+ var inf = $(this);
+ var scrollTop = inf.scrollTop();
+ var scrollHeight = inf.scrollHeight();
+ var height = inf[0].offsetHeight;
+ var distance = inf[0].getAttribute('data-distance');
+ var virtualListContainer = inf.find('.virtual-list');
+ var virtualList;
+ var onTop = inf.hasClass('infinite-scroll-top');
+ if (!distance) distance = 50;
+ if (typeof distance === 'string' && distance.indexOf('%') >= 0) {
+ distance = parseInt(distance, 10) / 100 * height;
+ }
+ if (distance > height) distance = height;
+ if (onTop) {
+ if (scrollTop < distance) {
+ inf.trigger('infinite');
+ }
+ } else {
+ if (scrollTop + height >= scrollHeight - distance) {
+ if (virtualListContainer.length > 0) {
+ virtualList = virtualListContainer[0].f7VirtualList;
+ if (virtualList && !virtualList.reachEnd) return;
+ }
+ inf.trigger('infinite');
+ }
+ }
+
+ }
+ $.attachInfiniteScroll = function(infiniteContent) {
+ $(infiniteContent).on('scroll', handleInfiniteScroll);
+ };
+ $.detachInfiniteScroll = function(infiniteContent) {
+ $(infiniteContent).off('scroll', handleInfiniteScroll);
+ };
+
+ $.initInfiniteScroll = function(pageContainer) {
+ pageContainer = $(pageContainer);
+ var infiniteContent = pageContainer.hasClass('infinite-scroll')?pageContainer:pageContainer.find('.infinite-scroll');
+ if (infiniteContent.length === 0) return;
+ $.attachInfiniteScroll(infiniteContent);
+
+ function detachEvents() {
+ $.detachInfiniteScroll(infiniteContent);
+ pageContainer.off('pageBeforeRemove', detachEvents);
+ }
+ pageContainer.on('pageBeforeRemove', detachEvents);
+ };
+}($);
+
+/* ===============================================================================
+************ Notification ************
+=============================================================================== */
+/* global $:true */
++function ($) {
+ "use strict";
+
+ var noti, defaults, timeout, start, diffX, diffY;
+
+ var touchStart = function(e) {
+ var p = $.getTouchPosition(e);
+ start = p;
+ diffX = diffY = 0;
+ noti.addClass("touching");
+ };
+ var touchMove = function(e) {
+ if(!start) return false;
+ e.preventDefault();
+ e.stopPropagation();
+ var p = $.getTouchPosition(e);
+ diffX = p.x - start.x;
+ diffY = p.y - start.y;
+ if(diffY > 0) {
+ diffY = Math.sqrt(diffY);
+ }
+
+ noti.css("transform", "translate3d(0, "+diffY+"px, 0)");
+ };
+ var touchEnd = function() {
+ noti.removeClass("touching");
+ noti.attr("style", "");
+ if(diffY < 0 && (Math.abs(diffY) > noti.height()*0.38)) {
+ $.closeNotification();
+ }
+
+ if(Math.abs(diffX) <= 1 && Math.abs(diffY) <= 1) {
+ noti.trigger("noti-click");
+ }
+
+ start = false;
+ };
+
+ var attachEvents = function(el) {
+ el.on($.touchEvents.start, touchStart);
+ el.on($.touchEvents.move, touchMove);
+ el.on($.touchEvents.end, touchEnd);
+ };
+
+ $.notification = $.noti = function(params) {
+ params = $.extend({}, defaults, params);
+ noti = $(".notification");
+ if(!noti[0]) { // create a new notification
+ noti = $('
').appendTo(document.body);
+ attachEvents(noti);
+ }
+
+ noti.off("noti-click"); //the click event is not correct sometime: it will trigger when user is draging.
+ if(params.onClick) noti.on("noti-click", function() {
+ params.onClick(params.data);
+ });
+
+ noti.html($.t7.compile(params.tpl)(params));
+
+ noti.show();
+
+ noti.addClass("notification-in");
+ noti.data("params", params);
+
+ var startTimeout = function() {
+ if(timeout) {
+ clearTimeout(timeout);
+ timeout = null;
+ }
+
+ timeout = setTimeout(function() {
+ if(noti.hasClass("touching")) {
+ startTimeout();
+ } else {
+ $.closeNotification();
+ }
+ }, params.time);
+ };
+
+ startTimeout();
+
+ };
+
+ $.closeNotification = function() {
+ timeout && clearTimeout(timeout);
+ timeout = null;
+ var noti = $(".notification").removeClass("notification-in").transitionEnd(function() {
+ $(this).remove();
+ });
+
+ if(noti[0]) {
+ var params = $(".notification").data("params");
+ if(params && params.onClose) {
+ params.onClose(params.data);
+ }
+ }
+ };
+
+ defaults = $.noti.prototype.defaults = {
+ title: undefined,
+ text: undefined,
+ media: undefined,
+ time: 4000,
+ onClick: undefined,
+ onClose: undefined,
+ data: undefined,
+ tpl: '' +
+ '{{#if media}}
{{media}}
{{/if}}' +
+ '
' +
+ '{{#if title}}
{{title}}
{{/if}}' +
+ '{{#if text}}
{{text}}
{{/if}}' +
+ '
' +
+ '
' +
+ '
'
+ };
+
+}($);
+
+/* global $:true */
++function ($) {
+ "use strict";
+
+ var Index = function(params) {
+ this.params = params;
+ this.tpl = $.t7(this.params.indexListTemplate).compile();
+ };
+
+ Index.prototype.render = function(list) {
+ this.list = $(list || ".list");
+ this.draw();
+ };
+
+ Index.prototype.draw = function() {
+ if(this.indexList) this.indexList.remove();
+ this.titles = this.list.find(this.params.titleSelector);
+ var titleTexts = this.titles.map(function(i, t) {
+ return $(t).data("index") || $(t).text();
+ }).toArray();
+
+ this.indexList = $("").appendTo(this.list.parents(".page"));
+ this.indexList.html(this.tpl({indexes: titleTexts}));
+ this.indexList.on($.touchEvents.start, $.proxy(this.touchStart, this));
+ this.indexList.on($.touchEvents.start + " " + $.touchEvents.move, $.proxy(this.touchMove, this));
+ this.indexList.on($.touchEvents.end, $.proxy(this.touchEnd, this));
+
+ this.content = this.list.parents(".content");
+ };
+
+ Index.prototype.touchStart = function() {
+ this.pageOffsetTop = this.content.offset().top;
+ this.touching = true;
+ };
+
+ Index.prototype.touchMove = function(e) {
+ if(!this.touching) return;
+ e.preventDefault();
+ var li = this.getElementOnTouch($.getTouchPosition(e));
+ if(!li) return;
+ var title = this.titles.eq(li.data("index"));
+ var titleTop = title.parent().offset().top; // if a element has class list-group-title, it will be sticky in safari, so it's offset is not correct
+ var top = titleTop - this.pageOffsetTop + this.content.scrollTop();
+ this.content.scrollTop(top);
+ };
+
+ Index.prototype.touchEnd = function() {
+ this.touching = false;
+ };
+
+ Index.prototype.getElementOnTouch = function(position) {
+ var result = null;
+ this.indexList.find("li").each(function() {
+ if(result) return;
+ var $this = $(this);
+ var offset = $this.offset();
+ if(offset.top < position.y && offset.top + $this.outerHeight() > position.y) {
+ result = $this;
+ }
+ });
+ return result;
+ };
+
+ $.fn.indexList = function(params) {
+ return this.each(function() {
+ if(!this) return;
+
+ var list = $(this);
+
+ var index = list.data("index");
+
+ if(!index) {
+ params = $.extend({}, $.fn.indexList.prototype.defaults, params);
+ index = new Index(params).render(list);
+ list.data("index", index);
+ }
+
+ return index;
+
+ });
+ };
+
+
+ $.fn.indexList.prototype.defaults = {
+ titleSelector: ".list-group-title",
+ indexListTemplate: "{{#indexes}}{{this}} {{/indexes}}"
+ };
+
+ $.initIndexList = function(selector) {
+ var container = $(selector);
+ if(container.hasClass(".contacts-block")) {
+ container.indexList();
+ } else {
+ container.find(".contacts-block").indexList();
+ }
+ };
+
+}($);
+
+/* global $:true */
++function ($) {
+ "use strict";
+ $(function() {
+ $(document).on("focus", ".searchbar input", function(e) {
+ var $input = $(e.target);
+ $input.parents(".searchbar").addClass("searchbar-active");
+ });
+ $(document).on("click", ".searchbar-cancel", function(e) {
+ var $btn = $(e.target);
+ $btn.parents(".searchbar").removeClass("searchbar-active");
+ });
+ $(document).on("blur", ".searchbar input", function(e) {
+ var $input = $(e.target);
+ $input.parents(".searchbar").removeClass("searchbar-active");
+ });
+ });
+}($);
+
+/*======================================================
+************ Panels ************
+======================================================*/
+/* global $:true */
+/*jshint unused: false*/
++function ($) {
+ "use strict";
+ $.allowPanelOpen = true;
+ $.openPanel = function (panel) {
+ if (!$.allowPanelOpen) return false;
+ if(panel === 'left' || panel === 'right') panel = ".panel-" + panel; //可以传入一个方向
+ panel = panel ? $(panel) : $(".panel").eq(0);
+ var direction = panel.hasClass("panel-right") ? "right" : "left";
+ if (panel.length === 0 || panel.hasClass('active')) return false;
+ $.closePanel(); // Close if some panel is opened
+ $.allowPanelOpen = false;
+ var effect = panel.hasClass('panel-reveal') ? 'reveal' : 'cover';
+ panel.css({display: 'block'}).addClass('active');
+ panel.trigger('open');
+
+ // Trigger reLayout
+ var clientLeft = panel[0].clientLeft;
+
+ // Transition End;
+ var transitionEndTarget = effect === 'reveal' ? $($.getCurrentPage()) : panel;
+ var openedTriggered = false;
+
+ function panelTransitionEnd() {
+ transitionEndTarget.transitionEnd(function (e) {
+ if (e.target === transitionEndTarget[0]) {
+ if (panel.hasClass('active')) {
+ panel.trigger('opened');
+ }
+ else {
+ panel.trigger('closed');
+ }
+ $.allowPanelOpen = true;
+ }
+ else panelTransitionEnd();
+ });
+ }
+ panelTransitionEnd();
+
+ $(document.body).addClass('with-panel-' + direction + '-' + effect);
+ return true;
+ };
+ $.closePanel = function () {
+ var activePanel = $('.panel.active');
+ if (activePanel.length === 0) return false;
+ var effect = activePanel.hasClass('panel-reveal') ? 'reveal' : 'cover';
+ var panelPosition = activePanel.hasClass('panel-left') ? 'left' : 'right';
+ activePanel.removeClass('active');
+ var transitionEndTarget = effect === 'reveal' ? $('.page') : activePanel;
+ activePanel.trigger('close');
+ $.allowPanelOpen = false;
+
+ transitionEndTarget.transitionEnd(function () {
+ if (activePanel.hasClass('active')) return;
+ activePanel.css({display: ''});
+ activePanel.trigger('closed');
+ $('body').removeClass('panel-closing');
+ $.allowPanelOpen = true;
+ });
+
+ $('body').addClass('panel-closing').removeClass('with-panel-' + panelPosition + '-' + effect);
+ };
+
+ $(document).on("click", ".open-panel", function(e) {
+ var panel = $(e.target).data(panel);
+ $.openPanel(panel);
+ });
+ $(document).on("click", ".close-panel, .panel-overlay", function(e) {
+ $.closePanel();
+ });
+ /*======================================================
+ ************ Swipe panels ************
+ ======================================================*/
+ $.initSwipePanels = function () {
+ var panel, side;
+ var swipePanel = $.smConfig.swipePanel;
+ var swipePanelOnlyClose = $.smConfig.swipePanelOnlyClose;
+ var swipePanelCloseOpposite = true;
+ var swipePanelActiveArea = false;
+ var swipePanelThreshold = 2;
+ var swipePanelNoFollow = false;
+
+ if(!(swipePanel || swipePanelOnlyClose)) return;
+
+ var panelOverlay = $('.panel-overlay');
+ var isTouched, isMoved, isScrolling, touchesStart = {}, touchStartTime, touchesDiff, translate, opened, panelWidth, effect, direction;
+ var currentPage = $($.getCurrentPage());
+
+ function handleTouchStart(e) {
+ currentPage = $($.getCurrentPage()); //page may changed
+ if (!$.allowPanelOpen || (!swipePanel && !swipePanelOnlyClose) || isTouched) return;
+ if ($('.modal-in, .photo-browser-in').length > 0) return;
+ if (!(swipePanelCloseOpposite || swipePanelOnlyClose)) {
+ if ($('.panel.active').length > 0 && !panel.hasClass('active')) return;
+ }
+ var position = $.getTouchPosition(e);
+ touchesStart.x = position.x;
+ touchesStart.y = position.y;
+ if (swipePanelCloseOpposite || swipePanelOnlyClose) {
+ if ($('.panel.active').length > 0) {
+ side = $('.panel.active').hasClass('panel-left') ? 'left' : 'right';
+ }
+ else {
+ if (swipePanelOnlyClose) return;
+ side = swipePanel;
+ }
+ if (!side) return;
+ }
+ panel = $('.panel.panel-' + side);
+ if(!panel[0]) return;
+ opened = panel.hasClass('active');
+ if (swipePanelActiveArea && !opened) {
+ if (side === 'left') {
+ if (touchesStart.x > swipePanelActiveArea) return;
+ }
+ if (side === 'right') {
+ if (touchesStart.x < window.innerWidth - swipePanelActiveArea) return;
+ }
+ }
+ isMoved = false;
+ isTouched = true;
+ isScrolling = undefined;
+
+ touchStartTime = (new Date()).getTime();
+ direction = undefined;
+ }
+ function handleTouchMove(e) {
+ if (!isTouched) return;
+ if(!panel[0]) return;
+ if (e.f7PreventPanelSwipe) return;
+ var position = $.getTouchPosition(e);
+ var pageX = position.x;
+ var pageY = position.y;
+ if (typeof isScrolling === 'undefined') {
+ isScrolling = !!(isScrolling || Math.abs(pageY - touchesStart.y) > Math.abs(pageX - touchesStart.x));
+ }
+ if (isScrolling) {
+ isTouched = false;
+ return;
+ }
+ if (!direction) {
+ if (pageX > touchesStart.x) {
+ direction = 'to-right';
+ }
+ else {
+ direction = 'to-left';
+ }
+
+ if (
+ side === 'left' &&
+ (
+ direction === 'to-left' && !panel.hasClass('active')
+ ) ||
+ side === 'right' &&
+ (
+ direction === 'to-right' && !panel.hasClass('active')
+ )
+ )
+ {
+ isTouched = false;
+ return;
+ }
+ }
+
+ if (swipePanelNoFollow) {
+ var timeDiff = (new Date()).getTime() - touchStartTime;
+ if (timeDiff < 300) {
+ if (direction === 'to-left') {
+ if (side === 'right') $.openPanel(side);
+ if (side === 'left' && panel.hasClass('active')) $.closePanel();
+ }
+ if (direction === 'to-right') {
+ if (side === 'left') $.openPanel(side);
+ if (side === 'right' && panel.hasClass('active')) $.closePanel();
+ }
+ }
+ isTouched = false;
+ isMoved = false;
+ return;
+ }
+
+ if (!isMoved) {
+ effect = panel.hasClass('panel-cover') ? 'cover' : 'reveal';
+ if (!opened) {
+ panel.show();
+ panelOverlay.show();
+ }
+ panelWidth = panel[0].offsetWidth;
+ panel.transition(0);
+ /*
+ if (panel.find('.' + app.params.viewClass).length > 0) {
+ if (app.sizeNavbars) app.sizeNavbars(panel.find('.' + app.params.viewClass)[0]);
+ }
+ */
+ }
+
+ isMoved = true;
+
+ e.preventDefault();
+ var threshold = opened ? 0 : -swipePanelThreshold;
+ if (side === 'right') threshold = -threshold;
+
+ touchesDiff = pageX - touchesStart.x + threshold;
+
+ if (side === 'right') {
+ translate = touchesDiff - (opened ? panelWidth : 0);
+ if (translate > 0) translate = 0;
+ if (translate < -panelWidth) {
+ translate = -panelWidth;
+ }
+ }
+ else {
+ translate = touchesDiff + (opened ? panelWidth : 0);
+ if (translate < 0) translate = 0;
+ if (translate > panelWidth) {
+ translate = panelWidth;
+ }
+ }
+ if (effect === 'reveal') {
+ currentPage.transform('translate3d(' + translate + 'px,0,0)').transition(0);
+ panelOverlay.transform('translate3d(' + translate + 'px,0,0)');
+ //app.pluginHook('swipePanelSetTransform', currentPage[0], panel[0], Math.abs(translate / panelWidth));
+ }
+ else {
+ panel.transform('translate3d(' + translate + 'px,0,0)').transition(0);
+ //app.pluginHook('swipePanelSetTransform', currentPage[0], panel[0], Math.abs(translate / panelWidth));
+ }
+ }
+ function handleTouchEnd(e) {
+ if (!isTouched || !isMoved) {
+ isTouched = false;
+ isMoved = false;
+ return;
+ }
+ isTouched = false;
+ isMoved = false;
+ var timeDiff = (new Date()).getTime() - touchStartTime;
+ var action;
+ var edge = (translate === 0 || Math.abs(translate) === panelWidth);
+
+ if (!opened) {
+ if (translate === 0) {
+ action = 'reset';
+ }
+ else if (
+ timeDiff < 300 && Math.abs(translate) > 0 ||
+ timeDiff >= 300 && (Math.abs(translate) >= panelWidth / 2)
+ ) {
+ action = 'swap';
+ }
+ else {
+ action = 'reset';
+ }
+ }
+ else {
+ if (translate === -panelWidth) {
+ action = 'reset';
+ }
+ else if (
+ timeDiff < 300 && Math.abs(translate) >= 0 ||
+ timeDiff >= 300 && (Math.abs(translate) <= panelWidth / 2)
+ ) {
+ if (side === 'left' && translate === panelWidth) action = 'reset';
+ else action = 'swap';
+ }
+ else {
+ action = 'reset';
+ }
+ }
+ if (action === 'swap') {
+ $.allowPanelOpen = true;
+ if (opened) {
+ $.closePanel();
+ if (edge) {
+ panel.css({display: ''});
+ $('body').removeClass('panel-closing');
+ }
+ }
+ else {
+ $.openPanel(side);
+ }
+ if (edge) $.allowPanelOpen = true;
+ }
+ if (action === 'reset') {
+ if (opened) {
+ $.allowPanelOpen = true;
+ $.openPanel(side);
+ }
+ else {
+ $.closePanel();
+ if (edge) {
+ $.allowPanelOpen = true;
+ panel.css({display: ''});
+ }
+ else {
+ var target = effect === 'reveal' ? currentPage : panel;
+ $('body').addClass('panel-closing');
+ target.transitionEnd(function () {
+ $.allowPanelOpen = true;
+ panel.css({display: ''});
+ $('body').removeClass('panel-closing');
+ });
+ }
+ }
+ }
+ if (effect === 'reveal') {
+ currentPage.transition('');
+ currentPage.transform('');
+ }
+ panel.transition('').transform('');
+ panelOverlay.css({display: ''}).transform('');
+ }
+ $(document).on($.touchEvents.start, handleTouchStart);
+ $(document).on($.touchEvents.move, handleTouchMove);
+ $(document).on($.touchEvents.end, handleTouchEnd);
+ };
+
+ $.initSwipePanels();
+}($);
+
+// jshint ignore: start
+/*
+ * 路由器
+ */
++function ($) {
+ "use strict";
+
+ if (!window.CustomEvent) {
+ window.CustomEvent = function (type, config) {
+ var e = document.createEvent('CustomEvent');
+ e.initCustomEvent(type, config.bubbles, config.cancelable, config.detail, config.id);
+ return e;
+ };
+ }
+
+ var Router = function() {
+ this.state = sessionStorage;
+ this.state.setItem("stateid", parseInt(this.state.getItem("stateid") || 1)+1);
+ this.state.setItem("currentStateID", this.state.getItem("stateid"));
+ this.stack = sessionStorage;
+ this.stack.setItem("back", "[]"); //返回栈, {url, pageid, stateid}
+ this.stack.setItem("forward", "[]"); //前进栈, {url, pageid, stateid}
+ this.extras = {}; //page extra: popup, panel...
+ this.init();
+ this.xhr = null;
+ }
+
+ Router.prototype.defaults = {
+ transition: true
+ };
+
+ Router.prototype.init = function() {
+ var currentPage = this.getCurrentPage();
+ if(!currentPage[0]) currentPage = $(".page").eq(0).addClass("page-current");
+ var hash = location.hash;
+ if(currentPage[0] && !currentPage[0].id) currentPage[0].id = (hash ? hash.slice(1) : this.genRandomID());
+
+ if(!currentPage[0]) throw new Error("can't find .page element");
+ var newCurrentPage = $(hash);
+
+
+ if(newCurrentPage[0] && (!currentPage[0] || hash.slice(1) !== currentPage[0].id)) {
+ currentPage.removeClass("page-current");
+ newCurrentPage.addClass("page-current");
+ currentPage = newCurrentPage;
+ }
+
+ //第一次加载的时候,初识话当前页面的state
+ var state = history.state;
+ if(!state) {
+ var id = this.genStateID();
+ this.replaceState(location.href, id);
+ this.setCurrentStateID(id);
+ }
+
+
+ var self = this;
+ window.addEventListener('load', function() {
+ //解决safari的一个bug,safari会在首次加载页面的时候触发 popstate 事件,通过setTimeout 做延迟来忽略这个错误的事件。
+ //参考 https://github.com/visionmedia/page.js/pull/239/files
+ setTimeout(function() {
+ window.addEventListener('popstate', $.proxy(self.onpopstate, self));
+ }, 0);
+ }, false);
+ }
+
+ //load new page, and push to history
+ Router.prototype.loadPage = function(url, noAnimation, replace, reload) {
+
+ var param = url;
+
+ if(noAnimation === undefined) {
+ noAnimation = !this.defaults.transition;
+ }
+
+ if(typeof url === typeof "a") {
+ param = {
+ url: url,
+ noAnimation: noAnimation,
+ replace: replace
+ }
+ }
+
+ var url = param.url, noAnimation = param.noAnimation, replace = param.replace;
+
+ this.getPage(url, function(page, extra) {
+
+ var currentPage = this.getCurrentPage();
+
+ var pageid = currentPage[0].id;
+
+ var action = "pushBack";
+ if(replace) action = "replaceBack";
+ if(reload) action = "reloadBack";
+ this[action]({
+ url: location.href,
+ pageid: "#"+ pageid,
+ id: this.getCurrentStateID(),
+ animation: !noAnimation
+ });
+
+ //remove all forward page
+ var forward = JSON.parse(this.state.getItem("forward") || "[]");
+ var self = this;
+ for(var i=0;i this.getCurrentStateID();
+ if(forward) this._forward();
+ else this._back();
+ }
+
+
+ //根据url获取页面的DOM,如果是一个内联页面,则直接返回,否则用ajax加载
+ Router.prototype.getPage = function(url, callback) {
+ if(url[0] === "#") return callback.apply(this, [$(url)]);
+
+ this.dispatch("pageLoadStart");
+
+ if(this.xhr && this.xhr.readyState < 4) {
+ this.xhr.onreadystatechange = $.noop;
+ this.xhr.abort();
+ this.dispatch("pageLoadCancel");
+ }
+
+ var self = this;
+
+ this.xhr = $.ajax({
+ url: url,
+ success: $.proxy(function(data, s, xhr) {
+ var html = this.parseXHR(xhr);
+ var $page = html[0];
+ var $extra = html[1];
+ if(!$page[0].id) $page[0].id = this.genRandomID();
+ $page.data("page-remote", 1);
+ callback.apply(this, [$page, $extra]);
+ }, this),
+ error: function() {
+ self.dispatch("pageLoadError");
+ },
+ complete: function() {
+ self.dispatch("pageLoadComplete");
+ }
+ });
+ }
+ Router.prototype.parseXHR = function(xhr) {
+ var response = xhr.responseText;
+ var body = response.match(/]*>([\s\S.]*)<\/body>/i);
+ var html = body ? body[1] : response;
+ html = ""+html+"
";
+ var tmp = $(html);
+
+ var $extra = tmp.find(".popup, .popover, .panel, .panel-overlay");
+
+ var $page = tmp.find(".page");
+ if(!$page[0]) $page = tmp.addClass("page");
+ return [$page, $extra];
+ }
+
+ Router.prototype.genStateID = function() {
+ var id = parseInt(this.state.getItem("stateid")) + 1;
+ this.state.setItem("stateid", id);
+ return id;
+ }
+ Router.prototype.getCurrentStateID = function() {
+ return parseInt(this.state.getItem("currentStateID"));
+ }
+ Router.prototype.setCurrentStateID = function(id) {
+ this.state.setItem("currentStateID", id);
+ }
+ Router.prototype.genRandomID = function() {
+ return "page-"+(+new Date());
+ }
+
+ Router.prototype.popBack = function() {
+ var stack = JSON.parse(this.stack.getItem("back"));
+ if(!stack.length) return null;
+ var h = stack.splice(stack.length-1, 1)[0];
+ this.stack.setItem("back", JSON.stringify(stack));
+ return h;
+ }
+ Router.prototype.pushBack = function(h) {
+ var stack = JSON.parse(this.stack.getItem("back"));
+ stack.push(h);
+ this.stack.setItem("back", JSON.stringify(stack));
+ }
+ Router.prototype.replaceBack = function(h) {
+ var stack = JSON.parse(this.stack.getItem("back"));
+ stack.pop();
+ stack.push(h);
+ this.stack.setItem("back", JSON.stringify(stack));
+ }
+ Router.prototype.reloadBack = function(h) {
+ //do nothing;
+ return;
+ }
+ Router.prototype.popForward = function() {
+ var stack = JSON.parse(this.stack.getItem("forward"));
+ if(!stack.length) return null;
+ var h = stack.splice(stack.length-1, 1)[0];
+ this.stack.setItem("forward", JSON.stringify(stack));
+ return h;
+ }
+ Router.prototype.pushForward = function(h) {
+ var stack = JSON.parse(this.stack.getItem("forward"));
+ stack.push(h);
+ this.stack.setItem("forward", JSON.stringify(stack));
+ }
+
+ Router.prototype.dispatch = function (event) {
+ var e = new CustomEvent(event, {
+ bubbles: true,
+ cancelable: true
+ });
+
+ window.dispatchEvent(e);
+ };
+
+
+ $(function() {
+ if(!$.smConfig.router) return;
+
+ var router = $.router = new Router();
+ router.defaults = Router.prototype.defaults;
+
+ $(document).on("click", "a", function(e) {
+ var $target = $(e.currentTarget);
+ if($target.hasClass("external") ||
+ $target[0].hasAttribute("external") ||
+ $target.hasClass("tab-link") ||
+ $target.hasClass("open-popup") ||
+ $target.hasClass("open-panel")
+ ) return;
+ e.preventDefault();
+ var url = $target.attr("href");
+ if($target.hasClass("back")) {
+ router.back(url);
+ return;
+ }
+
+ if(!url || url === "#" || /javascript:.*;/.test(url)) return;
+ router.loadPage(url, $target.hasClass("no-transition") ? true : undefined, $target.hasClass("replace") ? true : undefined); //undefined is different to false
+ })
+ });
+}($);
+// jshint ignore: end
+
+/* global $:true */
+/*jshint unused: false*/
++function ($) {
+ "use strict";
+
+ var getPage = function() {
+ var $page = $(".page-current");
+ if(!$page[0]) $page = $(".page").addClass("page-current");
+ return $page;
+ };
+
+ //初始化页面中的JS组件
+ $.initPage = function(page) {
+ var $page = page ? $(page) : getPage();
+ if(!$page[0]) $page = $(document.body);
+ var $content = $page.hasClass("content") ? $page : $page.find(".content");
+
+ $.initPullToRefresh($content);
+ $.initInfiniteScroll($content);
+ $.initCalendar($content);
+ $.initIndexList($content);
+
+ //extend
+ if($.initSwiper) $.initSwiper($content);
+ if($.initSwipeout) $.initSwipeout(); // don't pass $content because the swipeout element is not $content
+ };
+
+
+ /* if($.smConfig.showPageLoadingIndicator) {
+ //这里的 以 push 开头的是私有事件,不要用
+ $(window).on("pageLoadStart", function() {
+ $.showIndicator();
+ });
+ $(document).on("pageAnimationStart", function() {
+ $.hideIndicator();
+ });
+ $(window).on("pageLoadCancel", function() {
+ $.hideIndicator();
+ });
+ $(window).on("pageLoadError", function() {
+ $.hideIndicator();
+ $.toast("");
+ });
+ }*/
+
+
+
+ $.init = function() {
+ var $page = getPage();
+ var id = $page[0].id;
+ if($page.hasClass("page-inited")) {
+ $page.trigger("pageReinit", [id, $page]);
+ } else {
+ $.initPage();
+ $page.addClass("page-inited");
+ $page.trigger("pageInit", [id, $page]);
+ }
+ };
+
+ $(function() {
+ if($.smConfig.autoInit) {
+ $.init();
+ }
+
+ $(document).on("pageInitInternal", function(e, id, $page) {
+ $.init();
+ });
+ });
+
+
+}($);
diff --git a/fangija-zsyf/manifest.json b/fangija-zsyf/manifest.json
index 6d1b0ce..bd4bf24 100644
--- a/fangija-zsyf/manifest.json
+++ b/fangija-zsyf/manifest.json
@@ -1,4 +1,4 @@
-{
+{
"@platforms": [
"android",
"iPhone",
diff --git a/fangija-zsyf/yfindex.html b/fangija-zsyf/yfindex.html
index 9858d70..23d1fbe 100644
--- a/fangija-zsyf/yfindex.html
+++ b/fangija-zsyf/yfindex.html
@@ -42,17 +42,23 @@
-
+
-
42906元/㎡
+
{{momAvgPrice}}元/㎡
-
虹桥临空经济园区
-
-
+
+
+
-
2018-02-28
+
2018-02-28
-
+
-
-
+
+
@@ -139,7 +123,68 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 同意
+
+ 198票 62%
+
+
+
+ 反对
+
+ 121票 38%
+
+
V.S
+
@@ -1404,7 +1449,7 @@
-->
-
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-/* 选择-选择区域 */
-$("#region").picker({
- toolbarTemplate: '
',
- cols: [
- {
- textAlign: "center",
- values: ["黄浦", "长宁", "徐汇", "普陀", "静安"]
- }
- ]
-});
-
-/* 获取#region字数,截取#region前4字,并添加... */
-$(document).ready(function () {
- regionChange();
-});
-$("#region").change(function () {
- regionChange();
-});
-function regionChange(){
- var text = $("#region").val();
- var length = $("#region").val().length;
- var textStr = "";
- if(length > 4){
- textStr = text.substr(0,4);
- $("#region").val(textStr + "...");
- $("#region").css("width","3.8rem");
- }
- if(length == 4){
- $("#region").css("width","3.2rem");
- }
- if(length == 3){
- $("#region").css("width","2.4rem");
- }
- if(length == 2){
- $("#region").css("width","1.8rem");
- }
-};
-
+