-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
191 lines (165 loc) · 6.13 KB
/
Copy pathmain.js
File metadata and controls
191 lines (165 loc) · 6.13 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/**
* Created by Lance.Zhao on 2015/4/17.
*/
(function (w,d) {
var animations = {
slideleft: function (inView, outView, callback) {
var self = this;
inView.$el.addClass('animatestart');
inView.show();
inView.$el.css({
'-webkit-transform': 'translate3d(100%, 0px, 0px)',
'-moz-transform': 'translate3d(100%, 0px, 0px)'
});
inView.$el.animate({
'-webkit-transform': 'translate3d(0px, 0px, 0px)',
'-moz-transform': 'translate3d(0px, 0px, 0px)'
}, 300, 'linear', function () {
inView.$el.removeAttr('style');
outView.$el.removeAttr('style');
inView.$el.removeClass('animatestart');
inView.$el.removeAttr('style');
outView.$el.removeAttr('style');
outView.hide();
callback && callback.call(self, inView, outView);
});
},
slideright: function (inView, outView, callback) {
var self = this;
inView.show();
outView.$el.addClass('animatestart');
outView.$el.css({
'-webkit-transform': 'translate3d(0%, 0px, 0px)',
'-moz-transform': 'translate3d(0%, 0px, 0px)'
});
outView.$el.animate({
'-webkit-transform': 'translate3d(100%, 0px, 0px)',
'-moz-transform': 'translate3d(100%, 0px, 0px)'
}, 300, 'linear', function () {
inView.$el.removeAttr('style');
outView.$el.removeAttr('style');
outView.$el.removeClass('animatestart');
outView.hide();
callback && callback.call(self, inView, outView);
});
},
slideleft: function (inView, outView, callback, scope) {
$('body').addClass('hiddenx');
inView.$el.addClass('animatestart');
inView.$el.addClass('sliderightin');
inView.show();
inView.$el.one('webkitAnimationEnd transitionend oTransitionEnd', function (e) {
if(e.target === e.currentTarget){
outView.hide();
$('body').removeClass('hiddenx');
inView.$el.removeClass('animatestart');
inView.$el.removeClass('sliderightin');
callback && callback.call(scope, inView, outView);
}
}, 340);
},
slideright: function (inView, outView, callback, scope) {
$('body').addClass('hiddenx');
outView.$el.addClass('animatestart');
outView.$el.addClass('sliderightout');
inView.show();
outView.$el.one('webkitAnimationEnd transitionend oTransitionEnd', function (e) {
if(e.target === e.currentTarget){
$('body').removeClass('hiddenx');
outView.$el.removeClass('animatestart');
outView.$el.removeClass('sliderightout');
outView.hide();
callback && callback.call(scope, inView, outView);
}
}, 340);
}
};
require(['underscore','extend','fastclick','when','AbstractApp','storage','EnvStore','LanguageStore'],
function (underscore,extend,fastclick,when,App,storage,EnvStore,LanguageStore) {
//实例化App
var app = new App({
//选择pushState还是hashChange
hasPushState: false,
'defaultView': 'index',
'viewRootPath': jsapp.js_path+'views/'
//animations: animations
});
$.bindFastClick && $.bindFastClick();
try {
storage.getInstance().removeOverdueCathch()
} catch(n) {}
//浏览器版本信息,语言环境,请求地址
//判断访问终端
var version = '1.0.0';
var browser={
versions:function(){
var u = navigator.userAgent, app = navigator.appVersion;
return {
trident: u.indexOf('Trident') > -1, //IE内核
presto: u.indexOf('Presto') > -1, //opera内核
webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1,//火狐内核
mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或者uc浏览器
iPhone: u.indexOf('iPhone') > -1 , //是否为iPhone或者QQHD浏览器
iPad: u.indexOf('iPad') > -1, //是否iPad
webApp: u.indexOf('Safari') == -1, //是否web应该程序,没有头部与底部
weixin: u.indexOf('MicroMessenger') > -1, //是否微信 (2015-01-22新增)
qq: u.match(/\sQQ/i) == " qq" //是否QQ
};
}(),
language:(navigator.browserLanguage || navigator.language).toLowerCase()
}
var evnStore = EnvStore.getInstance();
evnStore.setAttr('browser',JSON.stringify(browser.versions));
evnStore.setAttr('language',browser.language);
if(location.origin.indexOf('localhost')>0){
evnStore.setAttr('envUrl','http://192.168.101.126:8082');
}else{
evnStore.setAttr('envUrl',location.origin);
}
//添加多语言
// en_us/zh_cn/zh_tw
var lang = "zh_cn";
if(location.search==""){
lang = evnStore.getAttr('language').replace("-","_");
}else{
lang = location.search.split('?')[1].toLowerCase().replace("-","_");
}
if(lang!="en_us"&&lang!="zh_cn"){
lang = "en_us"
}
var lanStore = LanguageStore.getInstance();
$.ajax({
type: 'GET',
url: './fakedata/'+lang+'.json',
dataType:'json',
success: function (data) {
lanStore.setAttr('language',data.data);
},
error: function (xhr, type) {
console.log('Language Ajax error!');
}
});
});
//highcharts
try{
var highChartsLib = localStorage.getItem('highCharts');
}catch(e){}
if(highChartsLib){
_.execScript(highChartsLib);
}else{
var url = 'js/app/lib/highCharts.min.js';
var xhr = window.ActiveXObject ? new window.ActiveXObject("Microsoft.XMLHTTP") : new window.XMLHttpRequest;
xhr.open("GET", url, !0);
xhr.onreadystatechange = function() {
if (4 === xhr.readyState) {
if (200 !== xhr.status && 0 !== xhr.status) throw new Error("Could not load: " + url + ", status = " + xhr.status);
_.execScript(xhr.responseText);
localStorage.setItem('highCharts',xhr.responseText);
}
};
xhr.send(null);
}
})(window,document);