pox 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +10 -0
- data/lib/pox.rb +2 -0
- data/lib/pox/engine.rb +8 -0
- data/lib/pox/version.rb +3 -0
- data/pox.gemspec +20 -0
- data/vendor/assets/javascripts/agent/adaptor-cos.js +94 -0
- data/vendor/assets/javascripts/agent/adaptor-default.js +175 -0
- data/vendor/assets/javascripts/agent/adaptor-ipanel.js +127 -0
- data/vendor/assets/javascripts/agent/adaptor-vision.js +100 -0
- data/vendor/assets/javascripts/agent/core.js +12 -0
- data/vendor/assets/javascripts/build-in.js +161 -0
- data/vendor/assets/javascripts/pox.js +24 -0
- data/vendor/assets/javascripts/pox/ajax.js +68 -0
- data/vendor/assets/javascripts/pox/all.js +1 -0
- data/vendor/assets/javascripts/pox/animate.js +211 -0
- data/vendor/assets/javascripts/pox/browser.js +33 -0
- data/vendor/assets/javascripts/pox/core.js +289 -0
- data/vendor/assets/javascripts/pox/debugger.js +54 -0
- data/vendor/assets/javascripts/pox/dom.js +261 -0
- data/vendor/assets/javascripts/pox/transition.js +316 -0
- metadata +85 -0
@@ -0,0 +1,316 @@
|
|
1
|
+
//= require ./browser
|
2
|
+
//= require ./animate
|
3
|
+
|
4
|
+
(function(){
|
5
|
+
"use strict";
|
6
|
+
|
7
|
+
var ConvertTransformToStyle = {
|
8
|
+
convertTransformToCss: function(animateProperties, failbackProperties) {
|
9
|
+
var properties = this.cssProperties["transform"];
|
10
|
+
|
11
|
+
for (var name in properties) {
|
12
|
+
var value = properties[name];
|
13
|
+
var failback = function() {
|
14
|
+
failbackProperties["transform-" + name] = value;
|
15
|
+
};
|
16
|
+
|
17
|
+
if (name == "translate") {
|
18
|
+
var offsetArray = value.split(/[, ]+/);
|
19
|
+
|
20
|
+
this.buildTranslateProperty({
|
21
|
+
left: offsetArray[0],
|
22
|
+
top: offsetArray[1]
|
23
|
+
}, animateProperties, failbackProperties, failback);
|
24
|
+
} else if (name == "translateX") {
|
25
|
+
this.buildTranslateProperty({
|
26
|
+
left: properties[name]
|
27
|
+
}, animateProperties, failbackProperties, failback);
|
28
|
+
} else if (name == "translateY") {
|
29
|
+
this.buildTranslateProperty({
|
30
|
+
top: properties[name]
|
31
|
+
}, animateProperties, failbackProperties, failback);
|
32
|
+
} else {
|
33
|
+
failback();
|
34
|
+
}
|
35
|
+
}
|
36
|
+
},
|
37
|
+
|
38
|
+
buildTranslateProperty: function(offset, animateProperties, failbackProperties, failback) {
|
39
|
+
var position = Pox.getStyle(this.element, "position");
|
40
|
+
var animateStyles = {};
|
41
|
+
|
42
|
+
if (position != "absolute") {
|
43
|
+
return failback();
|
44
|
+
}
|
45
|
+
|
46
|
+
this.element.originStyles = this.element.originStyles || {};
|
47
|
+
|
48
|
+
for (var property in offset) {
|
49
|
+
if (this.cssProperties[property]) {
|
50
|
+
return failback();
|
51
|
+
}
|
52
|
+
|
53
|
+
var offsetValue = offset[property];
|
54
|
+
|
55
|
+
if (offsetValue == null || offsetValue === "" || parseFloat(offsetValue) == 0) {
|
56
|
+
offsetValue = "0px";
|
57
|
+
}
|
58
|
+
|
59
|
+
if (!/\px$/.test(offsetValue)) {
|
60
|
+
return failback();
|
61
|
+
}
|
62
|
+
|
63
|
+
var originValue = this.element.originStyles[property] || Pox.getComputedStyle(this.element, property);
|
64
|
+
|
65
|
+
if (originValue == null) {
|
66
|
+
return failback();
|
67
|
+
}
|
68
|
+
|
69
|
+
this.element.originStyles[property] = originValue;
|
70
|
+
animateStyles[property] = parseFloat(originValue) + parseFloat(offsetValue) + "px";
|
71
|
+
}
|
72
|
+
|
73
|
+
Pox.extend(animateProperties, animateStyles);
|
74
|
+
}
|
75
|
+
};
|
76
|
+
|
77
|
+
/** @lends Pox */
|
78
|
+
var WebkitTransition = Pox.clazz({
|
79
|
+
element: null,
|
80
|
+
duration: 400,
|
81
|
+
delay: 0,
|
82
|
+
cssProperties: {},
|
83
|
+
complete: function() { },
|
84
|
+
failback: function(failbackProperties, transition) {
|
85
|
+
var failbackString = "these properties is not supported: ";
|
86
|
+
for (var key in failbackProperties) {
|
87
|
+
failbackString += key + ": " + failbackProperties[key] + ", ";
|
88
|
+
}
|
89
|
+
alert(failbackString);
|
90
|
+
},
|
91
|
+
|
92
|
+
exec: function() {
|
93
|
+
var failbackProperties = {};
|
94
|
+
var prevTransition = this.element.dataWebkitTransition;
|
95
|
+
if (prevTransition) {
|
96
|
+
prevTransition.unbindEvents();
|
97
|
+
}
|
98
|
+
|
99
|
+
this.element.dataWebkitTransition = this;
|
100
|
+
|
101
|
+
if (this.duration === 0) {
|
102
|
+
this.complete();
|
103
|
+
} else {
|
104
|
+
this.bindEvents();
|
105
|
+
}
|
106
|
+
this.applyStyles(failbackProperties);
|
107
|
+
|
108
|
+
if (!Pox.isEmpty(failbackProperties, this)) {
|
109
|
+
this.failback(failbackProperties);
|
110
|
+
}
|
111
|
+
|
112
|
+
|
113
|
+
},
|
114
|
+
|
115
|
+
unbindEvents: function() {
|
116
|
+
if (this._completeBindWrapper) {
|
117
|
+
this.element.removeEventListener("webkitTransitionEnd", this._completeBindWrapper);
|
118
|
+
this._completeBindWrapper = null;
|
119
|
+
}
|
120
|
+
},
|
121
|
+
|
122
|
+
bindEvents: function() {
|
123
|
+
var self = this;
|
124
|
+
this._completeBindWrapper = function(event) {
|
125
|
+
self.unbindEvents();
|
126
|
+
return self.complete();
|
127
|
+
}
|
128
|
+
|
129
|
+
this.element.addEventListener("webkitTransitionEnd", this._completeBindWrapper, false);
|
130
|
+
},
|
131
|
+
|
132
|
+
applyStyles: function(failbackProperties) {
|
133
|
+
this.element.style.webkitTransitionDelay = this.delay + "ms";
|
134
|
+
this.element.style.webkitTransitionDuration = this.duration + "ms";
|
135
|
+
|
136
|
+
var propertyNames = []
|
137
|
+
for (var name in this.cssProperties) {
|
138
|
+
var value = this.cssProperties[name];
|
139
|
+
|
140
|
+
if (name == "transform") {
|
141
|
+
this.buildTransformStyle(failbackProperties);
|
142
|
+
} else {
|
143
|
+
this.element.style[name] = value;
|
144
|
+
}
|
145
|
+
|
146
|
+
propertyNames.push(name);
|
147
|
+
}
|
148
|
+
this.element.style.webkitTransitionProperty = propertyNames.join(", ");
|
149
|
+
},
|
150
|
+
|
151
|
+
buildTransformStyle: function(failbackProperties) {
|
152
|
+
var properties = this.cssProperties["transform"];
|
153
|
+
|
154
|
+
if (Pox.Browser.supportWebkitTransform) {
|
155
|
+
var styles = [];
|
156
|
+
|
157
|
+
for (var name in properties) {
|
158
|
+
if ( name == "origin" ) {
|
159
|
+
this.element.style["-webkit-transform-origin"] = properties[name];
|
160
|
+
} else {
|
161
|
+
styles.push(name + "(" + properties[name] + ")");
|
162
|
+
}
|
163
|
+
|
164
|
+
}
|
165
|
+
|
166
|
+
this.element.style["-webkit-transform"] = styles.join(" ");
|
167
|
+
|
168
|
+
} else {
|
169
|
+
this.convertTransformToCss(this.cssProperties, failbackProperties);
|
170
|
+
}
|
171
|
+
}
|
172
|
+
}, ConvertTransformToStyle);
|
173
|
+
|
174
|
+
/**
|
175
|
+
* 元素滑动(css3滑动)
|
176
|
+
* @param {HTMLElement} element
|
177
|
+
* @param {object} options
|
178
|
+
* @param {number} [options.duration=400] 滑动时长
|
179
|
+
* @param {object} options.cssProperties 样式
|
180
|
+
* @param {function} [options.complete] 滑动成功后的回调函数
|
181
|
+
* @param {function} [options.failback] 滑动失败后的回调函数
|
182
|
+
* @example <caption>Example usage of webkitTransition.</caption>
|
183
|
+
* $p.webkitTransition(element, {
|
184
|
+
* duration: 200,
|
185
|
+
* cssProperties: {
|
186
|
+
* transform: {
|
187
|
+
* translate: "300px, 200px",
|
188
|
+
* rotate: "-80deg",
|
189
|
+
* origin: "80% 80%"
|
190
|
+
* },
|
191
|
+
* height: "300px",
|
192
|
+
* width: "400px"
|
193
|
+
* },
|
194
|
+
* complete: function() {},
|
195
|
+
* failback: function() {},
|
196
|
+
* });
|
197
|
+
*/
|
198
|
+
Pox.webkitTransition = function(element, customOptions) {
|
199
|
+
var webkitTransition = Pox.instance(WebkitTransition, customOptions);
|
200
|
+
webkitTransition.element = element;
|
201
|
+
webkitTransition.exec();
|
202
|
+
};
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
var AnimateTransition = Pox.clazz({
|
207
|
+
element: null,
|
208
|
+
duration: 400,
|
209
|
+
delay: 0,
|
210
|
+
complete: function() { },
|
211
|
+
cssProperties: {},
|
212
|
+
failback: function(failbackProperties, transition) {
|
213
|
+
var failbackString = "these properties is not supported: ";
|
214
|
+
for (var key in failbackProperties) {
|
215
|
+
failbackString += key + ": " + failbackProperties[key] + ", ";
|
216
|
+
}
|
217
|
+
alert(failbackString);
|
218
|
+
},
|
219
|
+
|
220
|
+
exec: function() {
|
221
|
+
var animateProperties = {},
|
222
|
+
failbackProperties = {};
|
223
|
+
|
224
|
+
this.buildAnimateStyles(animateProperties, failbackProperties);
|
225
|
+
|
226
|
+
Pox.animate(this.element, {
|
227
|
+
duration: this.duration,
|
228
|
+
complete: this.complete,
|
229
|
+
styles: animateProperties
|
230
|
+
});
|
231
|
+
|
232
|
+
if (!Pox.isEmpty(failbackProperties, this)) {
|
233
|
+
this.failback(failbackProperties);
|
234
|
+
}
|
235
|
+
},
|
236
|
+
|
237
|
+
buildAnimateStyles: function(animateProperties, failbackProperties) {
|
238
|
+
var SUPPORT_ANIMATE_NAMES = ["left", "top", "right", "bottom", "width", "height", "opacity"];
|
239
|
+
|
240
|
+
for (var name in this.cssProperties) {
|
241
|
+
var value = this.cssProperties[name];
|
242
|
+
|
243
|
+
if (Pox.contains(SUPPORT_ANIMATE_NAMES, name)) {
|
244
|
+
animateProperties[name] = value;
|
245
|
+
} else if (name == "transform") {
|
246
|
+
this.convertTransformToCss(animateProperties, failbackProperties);
|
247
|
+
} else {
|
248
|
+
failbackProperties[name] = value;
|
249
|
+
}
|
250
|
+
}
|
251
|
+
}
|
252
|
+
}, ConvertTransformToStyle);
|
253
|
+
|
254
|
+
/**
|
255
|
+
* 元素滑动(支持js滑动)
|
256
|
+
* @param {HTMLElement} element
|
257
|
+
* @param {object} options
|
258
|
+
* @param {number} [options.duration=400] 滑动时长
|
259
|
+
* @param {object} options.cssProperties 样式
|
260
|
+
* @param {function} [options.complete] 滑动成功后的回调函数
|
261
|
+
* @param {function} [options.failback] 滑动失败后的回调函数
|
262
|
+
* @example <caption>Example usage of webkitTransition.</caption>
|
263
|
+
* $p.transition(element, {
|
264
|
+
* duration: 200,
|
265
|
+
* cssProperties: {
|
266
|
+
* transform: {
|
267
|
+
* translate: "300px, 200px",
|
268
|
+
* rotate: "-80deg",
|
269
|
+
* origin: "80% 80%"
|
270
|
+
* },
|
271
|
+
* height: "300px",
|
272
|
+
* width: "400px"
|
273
|
+
* },
|
274
|
+
* complete: function() {},
|
275
|
+
* failback: function() {}
|
276
|
+
* });
|
277
|
+
*/
|
278
|
+
Pox.animateTransition = function(element, customOptions) {
|
279
|
+
var animateTransition = Pox.instance(AnimateTransition, customOptions);
|
280
|
+
animateTransition.element = element;
|
281
|
+
animateTransition.exec();
|
282
|
+
};
|
283
|
+
|
284
|
+
/**
|
285
|
+
* 元素滑动(支持js滑动和css3滑动)
|
286
|
+
* @param {HTMLElement} element
|
287
|
+
* @param {object} options
|
288
|
+
* @param {number} [options.duration=400] 滑动时长
|
289
|
+
* @param {object} options.cssProperties 样式
|
290
|
+
* @param {function} [options.complete] 滑动成功后的回调函数
|
291
|
+
* @param {function} [options.failback] 滑动失败后的回调函数
|
292
|
+
* @example <caption>Example usage of webkitTransition.</caption>
|
293
|
+
* $p.transition(element, {
|
294
|
+
* duration: 200,
|
295
|
+
* cssProperties: {
|
296
|
+
* transform: {
|
297
|
+
* translate: "300px, 200px",
|
298
|
+
* rotate: "-80deg",
|
299
|
+
* origin: "80% 80%"
|
300
|
+
* },
|
301
|
+
* height: "300px",
|
302
|
+
* width: "400px"
|
303
|
+
* },
|
304
|
+
* complete: function() {},
|
305
|
+
* failback: function() {}
|
306
|
+
* });
|
307
|
+
*/
|
308
|
+
Pox.transition = function(element, options) {
|
309
|
+
if (Pox.Browser.supportWebkitTransition) {
|
310
|
+
Pox.webkitTransition(element, options);
|
311
|
+
} else {
|
312
|
+
Pox.animateTransition(element, options);
|
313
|
+
}
|
314
|
+
};
|
315
|
+
|
316
|
+
})()
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pox
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- nmzhu
|
8
|
+
- gxw
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-06-30 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
description: assets for ipanel
|
29
|
+
email:
|
30
|
+
- nmzhu@b-star.cn
|
31
|
+
- xwgou@b-star.cn
|
32
|
+
executables: []
|
33
|
+
extensions: []
|
34
|
+
extra_rdoc_files: []
|
35
|
+
files:
|
36
|
+
- ".gitignore"
|
37
|
+
- CHANGELOG.md
|
38
|
+
- Gemfile
|
39
|
+
- LICENSE
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- lib/pox.rb
|
43
|
+
- lib/pox/engine.rb
|
44
|
+
- lib/pox/version.rb
|
45
|
+
- pox.gemspec
|
46
|
+
- vendor/assets/javascripts/agent/adaptor-cos.js
|
47
|
+
- vendor/assets/javascripts/agent/adaptor-default.js
|
48
|
+
- vendor/assets/javascripts/agent/adaptor-ipanel.js
|
49
|
+
- vendor/assets/javascripts/agent/adaptor-vision.js
|
50
|
+
- vendor/assets/javascripts/agent/core.js
|
51
|
+
- vendor/assets/javascripts/build-in.js
|
52
|
+
- vendor/assets/javascripts/pox.js
|
53
|
+
- vendor/assets/javascripts/pox/ajax.js
|
54
|
+
- vendor/assets/javascripts/pox/all.js
|
55
|
+
- vendor/assets/javascripts/pox/animate.js
|
56
|
+
- vendor/assets/javascripts/pox/browser.js
|
57
|
+
- vendor/assets/javascripts/pox/core.js
|
58
|
+
- vendor/assets/javascripts/pox/debugger.js
|
59
|
+
- vendor/assets/javascripts/pox/dom.js
|
60
|
+
- vendor/assets/javascripts/pox/transition.js
|
61
|
+
homepage:
|
62
|
+
licenses: []
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.2.2
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: assets for ipanel
|
84
|
+
test_files: []
|
85
|
+
has_rdoc:
|