-
Notifications
You must be signed in to change notification settings - Fork 81
/
mip.js
executable file
·124 lines (99 loc) · 3.4 KB
/
mip.js
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
define(function (require) {
// 稳定性监控
require('./log/monitor');
require('zepto');
require('naboo');
/* dom */
var dom = require('./dom/dom');
// The global variable of MIP
var Mip = {};
if (window.MIP) {
var exts = window.MIP;
window.MIP = Mip;
MIP.extensions = exts;
} else
{
window.MIP = Mip;
}
// before document ready
MIP.push = function (extensions) {
if (!MIP.extensions) {
MIP.extensions = [];
}
MIP.extensions.push(extensions);
};
dom.waitDocumentReady(function () {
require('fetch-jsonp');
require('fetch');
require('./utils/fn');
require('./utils/gesture/gesture-recognizer');
require('./utils/gesture/data-processor');
require('./utils/gesture');
require('./utils/platform');
require('./utils/event-emitter');
require('./utils/event-action');
require('./dom/css-loader');
require('./dom/rect');
require('./dom/event');
require('./dom/css');
var CustomStorage = require('./utils/customStorage');
var sleepWakeModule = require('./sleepWakeModule');
/* mip frame */
var layout = require('./layout');
require('./fixed-element');
var viewport = require('./viewport');
require('./customElement');
var registerElement = require('./element');
require('./util');
var resources = require('./resources');
var viewer = require('./viewer');
var performance = require('./performance');
var templates = require('./templates');
/* mip hash */
var hash = require('./hash');
/* builtin components */
require('./components/mip-img');
require('./components/mip-pix');
require('./components/mip-carousel');
require('./components/mip-iframe');
var components = require('./components/index');
Mip.css = {};
Mip.viewer = viewer;
Mip.viewport = viewport;
Mip.prerenderElement = resources.prerenderElement;
Mip.registerMipElement = function (name, customClass, css) {
if (templates.isTemplateClass(customClass)) {
templates.register(name, customClass);
} else {
registerElement(name, customClass, css);
}
};
MIP.hash = hash;
// Initialize sleepWakeModule
sleepWakeModule.init();
// Initialize viewer
viewer.init();
// Find the default-hidden elements.
var hiddenElements = Array.prototype.slice.call(document.getElementsByClassName('mip-hidden'));
// Regular for checking mip elements.
var mipTagReg = /mip-/i;
// Apply layout for default-hidden elements.
hiddenElements.forEach(function (element) {
if (element.tagName.search(mipTagReg) > -1) {
layout.applyLayout(element);
}
});
// Register builtin extensions
components.register();
performance.start(window._mipStartTiming);
performance.on('update', function (timing) {
viewer.sendMessage('performance_update', timing);
});
// Show page
viewer.show();
// clear cookie
var storage = new CustomStorage(2);
storage.delExceedCookie();
});
return Mip;
});