Repository navigation
Expand file tree
/
Copy pathinit.js
More file actions
65 lines (52 loc) · 1.62 KB
/
Copy pathinit.js
File metadata and controls
65 lines (52 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* global Zepto: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 = getPage();
if(!$page[0]) $page = $(document.body);
var $content = $page.hasClass("content") ? $page : $page.find(".content");
$content.scroller(); //注意滚动条一定要最先初始化
$.initPullToRefresh($content);
$.initInfiniteScroll($content);
$.initCalendar($content);
//extend
if($.initSwiper) $.initSwiper($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;
$.initPage();
$page.trigger("pageInit", [id, $page]);
};
$(function() {
if($.smConfig.autoInit) {
$.init();
}
$(document).on("pageInitInternal", function(e, id, page) {
$.init();
});
});
}(Zepto);