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,100 @@ | |
| 1 | 
            +
            //= require ./adaptor-default
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            (function() {
         | 
| 4 | 
            +
            	"use strict";
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            	if (!window.jShow) {
         | 
| 7 | 
            +
            		return;
         | 
| 8 | 
            +
            	}
         | 
| 9 | 
            +
            	
         | 
| 10 | 
            +
            	// 映射返回键为 F 键
         | 
| 11 | 
            +
            	jShow.browserSetControlKeycode({
         | 
| 12 | 
            +
            		remoteCode: "VK_BACK_SPACE",
         | 
| 13 | 
            +
            		newKeyCode: "KEY_F",
         | 
| 14 | 
            +
            		ctrlMode: 0,
         | 
| 15 | 
            +
            		shiftMode: 0,
         | 
| 16 | 
            +
            		altMode: 0
         | 
| 17 | 
            +
            	});
         | 
| 18 | 
            +
            	
         | 
| 19 | 
            +
            	var VisionAgent = {
         | 
| 20 | 
            +
            		name: "vision",
         | 
| 21 | 
            +
            		
         | 
| 22 | 
            +
            		keys: {
         | 
| 23 | 
            +
            			UP           : 38,
         | 
| 24 | 
            +
            			DOWN         : 40,
         | 
| 25 | 
            +
            			LEFT         : 37,
         | 
| 26 | 
            +
            			RIGHT        : 39,
         | 
| 27 | 
            +
            			ENTER        : 13,
         | 
| 28 | 
            +
            			RETURN       : 70,
         | 
| 29 | 
            +
            			
         | 
| 30 | 
            +
            			PAGE_UP      : 33,
         | 
| 31 | 
            +
            			PAGE_DOWN    : 34,
         | 
| 32 | 
            +
            			INFO         : 73,
         | 
| 33 | 
            +
            			
         | 
| 34 | 
            +
            			
         | 
| 35 | 
            +
            			
         | 
| 36 | 
            +
            			RED          : 66,
         | 
| 37 | 
            +
            			GREEN        : 71,
         | 
| 38 | 
            +
            			YELLOW       : 89,
         | 
| 39 | 
            +
            			BLUE         : 81,
         | 
| 40 | 
            +
             | 
| 41 | 
            +
             | 
| 42 | 
            +
            			MUTE         : 87,
         | 
| 43 | 
            +
            			VOLUME_INC   : 187,
         | 
| 44 | 
            +
            			VOLUME_DEC   : 189,
         | 
| 45 | 
            +
            			CHANNEL_INC  : 85,
         | 
| 46 | 
            +
            			CHANNEL_DEC  : 68,
         | 
| 47 | 
            +
            			PAUSE        : 71,
         | 
| 48 | 
            +
            			STOP         : 89,
         | 
| 49 | 
            +
            			REW          : 66,
         | 
| 50 | 
            +
            			FFWD         : 81,
         | 
| 51 | 
            +
            			
         | 
| 52 | 
            +
            			NUM_0        : 48,
         | 
| 53 | 
            +
            			NUM_1        : 49,
         | 
| 54 | 
            +
            			NUM_2        : 50,
         | 
| 55 | 
            +
            			NUM_3        : 51,
         | 
| 56 | 
            +
            			NUM_4        : 52,
         | 
| 57 | 
            +
            			NUM_5        : 53,
         | 
| 58 | 
            +
            			NUM_6        : 54,
         | 
| 59 | 
            +
            			NUM_7        : 55,
         | 
| 60 | 
            +
            			NUM_8        : 56,
         | 
| 61 | 
            +
            			NUM_9        : 57
         | 
| 62 | 
            +
            		}
         | 
| 63 | 
            +
            	}
         | 
| 64 | 
            +
            	
         | 
| 65 | 
            +
            	Pox.extend(Pox.Agent, VisionAgent);
         | 
| 66 | 
            +
             | 
| 67 | 
            +
             | 
| 68 | 
            +
            	Pox.extend(Pox.Agent.Broadcast, {
         | 
| 69 | 
            +
            		playChannel: function(upcode) {
         | 
| 70 | 
            +
            			var chIndex = this._queryChIndexByNum(upcode);
         | 
| 71 | 
            +
            			jShow.playByListIndex(0, chIndex);
         | 
| 72 | 
            +
            		},
         | 
| 73 | 
            +
             | 
| 74 | 
            +
            		nowPlaying: function(upcode) {
         | 
| 75 | 
            +
            			return {};
         | 
| 76 | 
            +
            		},
         | 
| 77 | 
            +
             | 
| 78 | 
            +
            		_queryChIndexByNum: function(num) {
         | 
| 79 | 
            +
            			if (num == null) {
         | 
| 80 | 
            +
            				return null;
         | 
| 81 | 
            +
            			}
         | 
| 82 | 
            +
             | 
| 83 | 
            +
            			var sql = "select ch_index from table_ch where ch_l_num = " + num + " and ch_bt = 0";
         | 
| 84 | 
            +
            			var len = jShow.dbSQLQuery(sql).length;
         | 
| 85 | 
            +
            			if (len > 0) {
         | 
| 86 | 
            +
            				return jShow.dbQueryResult(0).ch_index;
         | 
| 87 | 
            +
            			}
         | 
| 88 | 
            +
             | 
| 89 | 
            +
            			return null;
         | 
| 90 | 
            +
            		},
         | 
| 91 | 
            +
             | 
| 92 | 
            +
            		screenDimension: function(left, top, width, height) {
         | 
| 93 | 
            +
            			jShow.avWindow({ x: left, y: top, w: width, h: height });
         | 
| 94 | 
            +
            		}
         | 
| 95 | 
            +
            	});
         | 
| 96 | 
            +
            	
         | 
| 97 | 
            +
            	Pox.leave(function() {
         | 
| 98 | 
            +
            		try { jShow.avStopPlay(); } catch(e) {}
         | 
| 99 | 
            +
            	});
         | 
| 100 | 
            +
            })();
         | 
| @@ -0,0 +1,161 @@ | |
| 1 | 
            +
            //= require ./pox/all
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            (function() {
         | 
| 4 | 
            +
            	"use strict";
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            	window.KeyBindResult = Pox.clazz(
         | 
| 7 | 
            +
            	/** @lends KeyBindResult.prototype */
         | 
| 8 | 
            +
            	{
         | 
| 9 | 
            +
            		/**
         | 
| 10 | 
            +
            		 * @constructs
         | 
| 11 | 
            +
            		 * @param {Event} event
         | 
| 12 | 
            +
            		 */
         | 
| 13 | 
            +
            		init: function(event) {
         | 
| 14 | 
            +
            			this.which = event.which;
         | 
| 15 | 
            +
            		},
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            		defaultPrevented: false,
         | 
| 18 | 
            +
            		/**
         | 
| 19 | 
            +
            		 * 是否允许浏览器默认执行
         | 
| 20 | 
            +
            		 * @returns {boolean}
         | 
| 21 | 
            +
            		 */
         | 
| 22 | 
            +
            		isDefaultPrevented: function() {
         | 
| 23 | 
            +
            			return this.defaultPrevented;
         | 
| 24 | 
            +
            		},
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            		/** 阻止浏览器默认执行 */
         | 
| 27 | 
            +
            		preventDefault: function() {
         | 
| 28 | 
            +
            			this.defaultPrevented = true;
         | 
| 29 | 
            +
            		},
         | 
| 30 | 
            +
             | 
| 31 | 
            +
             | 
| 32 | 
            +
            		propagationStopped: false,
         | 
| 33 | 
            +
            		/** 
         | 
| 34 | 
            +
            		 * 是否允许阻止事件冒泡
         | 
| 35 | 
            +
            		 * @returns {boolean}
         | 
| 36 | 
            +
            		 */
         | 
| 37 | 
            +
            		isPropagationStopped: function() {
         | 
| 38 | 
            +
            			return this.propagationStopped;
         | 
| 39 | 
            +
            		},
         | 
| 40 | 
            +
            		/** 阻止事件冒泡 */
         | 
| 41 | 
            +
            		stopPropagation: function() {
         | 
| 42 | 
            +
            			this.propagationStopped = true;
         | 
| 43 | 
            +
            		},
         | 
| 44 | 
            +
             | 
| 45 | 
            +
            		/** 阻止冒泡和默认执行 */
         | 
| 46 | 
            +
            		abort: function() {
         | 
| 47 | 
            +
            			this.preventDefault();
         | 
| 48 | 
            +
            			this.stopPropagation();
         | 
| 49 | 
            +
            		}
         | 
| 50 | 
            +
            	});
         | 
| 51 | 
            +
             | 
| 52 | 
            +
             | 
| 53 | 
            +
            	window.EventChain = Pox.clazz(
         | 
| 54 | 
            +
            	/** @lends EventChain.prototype */
         | 
| 55 | 
            +
            	{
         | 
| 56 | 
            +
            		/**
         | 
| 57 | 
            +
            		 * 回调执行位置顺序
         | 
| 58 | 
            +
            		 */
         | 
| 59 | 
            +
            		chain: [],
         | 
| 60 | 
            +
            		callbacks: {},
         | 
| 61 | 
            +
             | 
| 62 | 
            +
            		/**
         | 
| 63 | 
            +
            		 * @constructs
         | 
| 64 | 
            +
            		 * @param {Object} exts
         | 
| 65 | 
            +
            		 * @param {string[]} exts.chain 回调执行位置顺序
         | 
| 66 | 
            +
            		 */
         | 
| 67 | 
            +
            		init: function(exts) {
         | 
| 68 | 
            +
            			Pox.extend(this, exts);
         | 
| 69 | 
            +
            			if (this.afterInit) { this.afterInit() }
         | 
| 70 | 
            +
            		},
         | 
| 71 | 
            +
             | 
| 72 | 
            +
            		/**
         | 
| 73 | 
            +
            		 * 覆盖指定位置回调
         | 
| 74 | 
            +
            		 * @param {string} position
         | 
| 75 | 
            +
            		 * @param {function} callback
         | 
| 76 | 
            +
            		 */
         | 
| 77 | 
            +
            		set: function(position, callback) {
         | 
| 78 | 
            +
            			this.callbacks[position] = [ callback ];
         | 
| 79 | 
            +
            		},
         | 
| 80 | 
            +
             | 
| 81 | 
            +
            		/**
         | 
| 82 | 
            +
            		 * 追加指定位置回调
         | 
| 83 | 
            +
            		 * @param {string} position
         | 
| 84 | 
            +
            		 * @param {function} callback
         | 
| 85 | 
            +
            		 */
         | 
| 86 | 
            +
            		bind: function(position, callback) {
         | 
| 87 | 
            +
            			this.callbacks[position] = this.callbacks[position] || [];
         | 
| 88 | 
            +
            			this.callbacks[position].push(callback);
         | 
| 89 | 
            +
            		},
         | 
| 90 | 
            +
             | 
| 91 | 
            +
            		/**
         | 
| 92 | 
            +
            		 * 触发回调
         | 
| 93 | 
            +
            		 * @param {KeyBindResult} result
         | 
| 94 | 
            +
            		 */
         | 
| 95 | 
            +
            		fire: function(result) {
         | 
| 96 | 
            +
            			for (var i = 0; i < this.chain.length; i++) {
         | 
| 97 | 
            +
            				var position = this.chain[i];
         | 
| 98 | 
            +
            				var cbs = this.callbacks[position] || [];
         | 
| 99 | 
            +
            				for (var j = 0; j < cbs.length; j++) {
         | 
| 100 | 
            +
            					var callback = cbs[j];
         | 
| 101 | 
            +
            					if (callback) {
         | 
| 102 | 
            +
            						callback(result);
         | 
| 103 | 
            +
            					}
         | 
| 104 | 
            +
            				}
         | 
| 105 | 
            +
             | 
| 106 | 
            +
            				if (result.isPropagationStopped()) {
         | 
| 107 | 
            +
            					break;
         | 
| 108 | 
            +
            				}
         | 
| 109 | 
            +
            			}
         | 
| 110 | 
            +
             | 
| 111 | 
            +
            			return !result.isDefaultPrevented();
         | 
| 112 | 
            +
            		}
         | 
| 113 | 
            +
            	});
         | 
| 114 | 
            +
             | 
| 115 | 
            +
             | 
| 116 | 
            +
            	/**
         | 
| 117 | 
            +
            	 * 浏览器全局按键绑定对象 (唯一)
         | 
| 118 | 
            +
            	 * @memberof window
         | 
| 119 | 
            +
            	 * @type KeyBind
         | 
| 120 | 
            +
            	 */
         | 
| 121 | 
            +
            	window.KeyBind = new EventChain(
         | 
| 122 | 
            +
            	/**
         | 
| 123 | 
            +
            	 * @namespace KeyBind
         | 
| 124 | 
            +
            	 * @mixes EventChain
         | 
| 125 | 
            +
            	 * @virtual
         | 
| 126 | 
            +
            	 */
         | 
| 127 | 
            +
            	/** @lends KeyBind.prototype */
         | 
| 128 | 
            +
            	{
         | 
| 129 | 
            +
            		chain: [ "widget", "panel", "global", "_system_" ],
         | 
| 130 | 
            +
             | 
| 131 | 
            +
            		afterInit: function() {
         | 
| 132 | 
            +
            			// 垃圾茁壮机顶盒必须这样写, 不能做任何修改!!!
         | 
| 133 | 
            +
            			var self = this;
         | 
| 134 | 
            +
            			document.onkeydown = function(event) {
         | 
| 135 | 
            +
            				return self.onkeydown(event);
         | 
| 136 | 
            +
            			};
         | 
| 137 | 
            +
            		},
         | 
| 138 | 
            +
             | 
| 139 | 
            +
            		onkeydown: function(event) {
         | 
| 140 | 
            +
            			var result = new KeyBindResult(event);
         | 
| 141 | 
            +
            			return this.fire(result);
         | 
| 142 | 
            +
            		},
         | 
| 143 | 
            +
            		
         | 
| 144 | 
            +
            		/**
         | 
| 145 | 
            +
            		 * 阻止浏览器响应方向键
         | 
| 146 | 
            +
            		 */
         | 
| 147 | 
            +
            		stopNavigationPropagation: function() {
         | 
| 148 | 
            +
            			this.bind("_system_", function(event) {
         | 
| 149 | 
            +
            				switch(event.which) {
         | 
| 150 | 
            +
            				case $a.keys.LEFT:
         | 
| 151 | 
            +
            				case $a.keys.UP:
         | 
| 152 | 
            +
            				case $a.keys.DOWN:
         | 
| 153 | 
            +
            				case $a.keys.RIGHT:
         | 
| 154 | 
            +
            					event.abort();
         | 
| 155 | 
            +
            					break;
         | 
| 156 | 
            +
            				}
         | 
| 157 | 
            +
            			});
         | 
| 158 | 
            +
            		}
         | 
| 159 | 
            +
            	});
         | 
| 160 | 
            +
             | 
| 161 | 
            +
            })()
         | 
| @@ -0,0 +1,24 @@ | |
| 1 | 
            +
            //= require ./pox/all
         | 
| 2 | 
            +
            //= require_tree ./agent/
         | 
| 3 | 
            +
            //= require ./build-in
         | 
| 4 | 
            +
            //= require_self
         | 
| 5 | 
            +
             | 
| 6 | 
            +
             | 
| 7 | 
            +
            /** @namespace window */
         | 
| 8 | 
            +
            window;
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            /**
         | 
| 11 | 
            +
             * Pox 的简写形式
         | 
| 12 | 
            +
             * @memberof window
         | 
| 13 | 
            +
             * @type Pox
         | 
| 14 | 
            +
             */
         | 
| 15 | 
            +
            window.$p = window.Pox;
         | 
| 16 | 
            +
             | 
| 17 | 
            +
             | 
| 18 | 
            +
            /**
         | 
| 19 | 
            +
             * Pox.Agent 的简写形式
         | 
| 20 | 
            +
             * @memberof window
         | 
| 21 | 
            +
             * @type Pox.Agent
         | 
| 22 | 
            +
             */
         | 
| 23 | 
            +
            window.$a = window.Pox.Agent;
         | 
| 24 | 
            +
             | 
| @@ -0,0 +1,68 @@ | |
| 1 | 
            +
            //= require ./core
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            (function(){
         | 
| 4 | 
            +
            	"use strict";
         | 
| 5 | 
            +
            	
         | 
| 6 | 
            +
            	/** @lends Pox */
         | 
| 7 | 
            +
            	var AjaxModule = {
         | 
| 8 | 
            +
            		/**
         | 
| 9 | 
            +
            		 * ajax请求
         | 
| 10 | 
            +
            		 * @param {object} options
         | 
| 11 | 
            +
            		 * @param {string} options.url 请求地址
         | 
| 12 | 
            +
            		 * @param {string} [options.method=GET] http方法
         | 
| 13 | 
            +
            		 * @param {boolean} [options.async=false] 是否为异步
         | 
| 14 | 
            +
            		 * @param {string} [options.dataType] 数据类型
         | 
| 15 | 
            +
            		 * @param {function} [options.success] 请求成功后的回调函数
         | 
| 16 | 
            +
            		 * @example <caption>Example usage of ajax.</caption>
         | 
| 17 | 
            +
            		 *$p.ajax({
         | 
| 18 | 
            +
            		 *	url: "https://wido.me/index.json",
         | 
| 19 | 
            +
            		 *	method: "POST",
         | 
| 20 | 
            +
            		 *	async: true,
         | 
| 21 | 
            +
            		 *	dataType: "json",
         | 
| 22 | 
            +
            		 *	success: function(data) { // do some thing  }
         | 
| 23 | 
            +
            		 *})
         | 
| 24 | 
            +
            		 */
         | 
| 25 | 
            +
            		ajax :function(options) {
         | 
| 26 | 
            +
            			var self = this;
         | 
| 27 | 
            +
            			var xhr = new XMLHttpRequest();
         | 
| 28 | 
            +
            			xhr.onreadystatechange = function() {
         | 
| 29 | 
            +
            				self._ajaxStateChange(xhr, options);
         | 
| 30 | 
            +
            			}
         | 
| 31 | 
            +
            			
         | 
| 32 | 
            +
            			var method = options["method"] || "GET";
         | 
| 33 | 
            +
            			var url = options["url"];
         | 
| 34 | 
            +
            			
         | 
| 35 | 
            +
            			var async = false;
         | 
| 36 | 
            +
            			if (options["async"] != null) {
         | 
| 37 | 
            +
            				async = options["async"];
         | 
| 38 | 
            +
            			}
         | 
| 39 | 
            +
             | 
| 40 | 
            +
            			xhr.open(method, url, async);
         | 
| 41 | 
            +
             | 
| 42 | 
            +
            			var data = options["data"] || null;
         | 
| 43 | 
            +
            			if (method != "GET" && data) {
         | 
| 44 | 
            +
            				xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
         | 
| 45 | 
            +
            			}
         | 
| 46 | 
            +
            			if (options["beforeSend"]) {
         | 
| 47 | 
            +
            				options["beforeSend"](xhr);
         | 
| 48 | 
            +
            			}
         | 
| 49 | 
            +
             | 
| 50 | 
            +
            			xhr.send(data);
         | 
| 51 | 
            +
            		},
         | 
| 52 | 
            +
             | 
| 53 | 
            +
            		_ajaxStateChange :function(xhr, options) {
         | 
| 54 | 
            +
            			if (xhr.readyState == 4 && xhr.status == 200) { // 4 = "loaded"
         | 
| 55 | 
            +
            				var data = xhr.responseText;
         | 
| 56 | 
            +
            				if (options["dataType"] == "json") {
         | 
| 57 | 
            +
            					data = eval("(" + data + ");");
         | 
| 58 | 
            +
            				}
         | 
| 59 | 
            +
            				
         | 
| 60 | 
            +
            				options["success"](data);
         | 
| 61 | 
            +
            			}
         | 
| 62 | 
            +
            		} 
         | 
| 63 | 
            +
            	}
         | 
| 64 | 
            +
             | 
| 65 | 
            +
            	Pox.extend(Pox, AjaxModule);
         | 
| 66 | 
            +
            })()
         | 
| 67 | 
            +
             | 
| 68 | 
            +
             | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            //= require_tree ./
         | 
| @@ -0,0 +1,211 @@ | |
| 1 | 
            +
            //= require ./dom
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            (function(){
         | 
| 4 | 
            +
            	"use strict";
         | 
| 5 | 
            +
            	
         | 
| 6 | 
            +
            	var EASINGS = {
         | 
| 7 | 
            +
            		'linear': function(percent) {
         | 
| 8 | 
            +
            			return percent;
         | 
| 9 | 
            +
            		}
         | 
| 10 | 
            +
            	}
         | 
| 11 | 
            +
            	
         | 
| 12 | 
            +
            	/** @lends Pox */
         | 
| 13 | 
            +
            	var Animate = Pox.clazz({
         | 
| 14 | 
            +
            		element: null,
         | 
| 15 | 
            +
            		duration: 200,
         | 
| 16 | 
            +
            		interval: 60,
         | 
| 17 | 
            +
            		easing: 'linear',
         | 
| 18 | 
            +
            		complete: function() {},
         | 
| 19 | 
            +
            		styles: {},
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            		prepare: function(exts) {
         | 
| 22 | 
            +
            			this.buildSourceProperties();
         | 
| 23 | 
            +
            			this.buildTicks();
         | 
| 24 | 
            +
            		},
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            		buildSourceProperties: function() {
         | 
| 27 | 
            +
            			var CSS_EXPRESS = /(-?[\d.]+)([^\d.]*)/;
         | 
| 28 | 
            +
            			this.properties = {};
         | 
| 29 | 
            +
            			for (var name in this.styles) {
         | 
| 30 | 
            +
            				var target = this.styles[name];
         | 
| 31 | 
            +
            				var source = this.getStyle(this.element, name);
         | 
| 32 | 
            +
            				
         | 
| 33 | 
            +
            				var targetMatch = target.match(CSS_EXPRESS);
         | 
| 34 | 
            +
            				var targetValueStr = targetMatch[1];
         | 
| 35 | 
            +
            				var unit = targetMatch[2];
         | 
| 36 | 
            +
             | 
| 37 | 
            +
            				var sourceMatch = ("" + source).match(CSS_EXPRESS);
         | 
| 38 | 
            +
            				var sourceValueStr = sourceMatch[1];
         | 
| 39 | 
            +
             | 
| 40 | 
            +
            				var targetValue = parseFloat(targetValueStr);
         | 
| 41 | 
            +
            				var sourceValue = parseFloat(sourceValueStr);
         | 
| 42 | 
            +
             | 
| 43 | 
            +
            				this.properties[name] = {
         | 
| 44 | 
            +
            					source: sourceValue,
         | 
| 45 | 
            +
            					target: targetValue,
         | 
| 46 | 
            +
            					difference: targetValue - sourceValue,
         | 
| 47 | 
            +
            					unit: unit
         | 
| 48 | 
            +
            				}
         | 
| 49 | 
            +
            			}
         | 
| 50 | 
            +
            		},
         | 
| 51 | 
            +
             | 
| 52 | 
            +
            		buildTicks: function() {
         | 
| 53 | 
            +
            			this.ticks = []
         | 
| 54 | 
            +
            			var past = this.interval;
         | 
| 55 | 
            +
            			while (past < this.duration) {
         | 
| 56 | 
            +
            				this.ticks.push({
         | 
| 57 | 
            +
            					past: past,
         | 
| 58 | 
            +
            					percent: past / this.duration
         | 
| 59 | 
            +
            				})
         | 
| 60 | 
            +
            				past += this.interval;
         | 
| 61 | 
            +
            			}
         | 
| 62 | 
            +
            			this.ticks.push({
         | 
| 63 | 
            +
            				past: this.duration,
         | 
| 64 | 
            +
            				percent: 1.0
         | 
| 65 | 
            +
            			});
         | 
| 66 | 
            +
            		},
         | 
| 67 | 
            +
             | 
| 68 | 
            +
            		start: function() {
         | 
| 69 | 
            +
            			this.prepare();
         | 
| 70 | 
            +
             | 
| 71 | 
            +
            			var tick = this.ticks[0];
         | 
| 72 | 
            +
            			if (tick) {
         | 
| 73 | 
            +
            				if (tick.past == 0) {
         | 
| 74 | 
            +
            					this.track();
         | 
| 75 | 
            +
            				} else {
         | 
| 76 | 
            +
            					tick.timeoutId = setTimeout(Pox.proxy(this, this.track), tick.past);
         | 
| 77 | 
            +
            				}
         | 
| 78 | 
            +
            			}
         | 
| 79 | 
            +
            		},
         | 
| 80 | 
            +
             | 
| 81 | 
            +
            		track: function() {
         | 
| 82 | 
            +
            			var currentTick = this.ticks.shift();
         | 
| 83 | 
            +
            			this.transition(currentTick.percent);
         | 
| 84 | 
            +
             | 
| 85 | 
            +
            			var nextTick = this.ticks[0];
         | 
| 86 | 
            +
            			if (nextTick) {
         | 
| 87 | 
            +
            				var time = nextTick.past - currentTick.past;
         | 
| 88 | 
            +
            				nextTick.timeoutId = setTimeout(Pox.proxy(this, this.track), time);
         | 
| 89 | 
            +
            			} else {
         | 
| 90 | 
            +
            				this.completed = true;
         | 
| 91 | 
            +
            				this.complete();
         | 
| 92 | 
            +
            			}
         | 
| 93 | 
            +
            		},
         | 
| 94 | 
            +
             | 
| 95 | 
            +
            		abort: function() {
         | 
| 96 | 
            +
            			if (this.completed) {
         | 
| 97 | 
            +
            				return;
         | 
| 98 | 
            +
            			}
         | 
| 99 | 
            +
             | 
| 100 | 
            +
            			if (this.aborted) {
         | 
| 101 | 
            +
            				return;
         | 
| 102 | 
            +
            			}
         | 
| 103 | 
            +
             | 
| 104 | 
            +
            			this.aborted = true;
         | 
| 105 | 
            +
            			var current = this.ticks[0];
         | 
| 106 | 
            +
            			if (current.timeoutId) {
         | 
| 107 | 
            +
            				clearTimeout(current.timeoutId);
         | 
| 108 | 
            +
            				current.timeoutId = null;
         | 
| 109 | 
            +
            			}
         | 
| 110 | 
            +
             | 
| 111 | 
            +
            			this.complete();
         | 
| 112 | 
            +
            		},
         | 
| 113 | 
            +
             | 
| 114 | 
            +
            		transition: function(progress) {
         | 
| 115 | 
            +
            			var percent = EASINGS[this.easing](progress);
         | 
| 116 | 
            +
            			for (var name in this.properties) {
         | 
| 117 | 
            +
            				var property = this.properties[name];
         | 
| 118 | 
            +
            				this.changeStyle(name, property, percent);
         | 
| 119 | 
            +
            			}
         | 
| 120 | 
            +
            		},
         | 
| 121 | 
            +
             | 
| 122 | 
            +
            		changeStyle: function(name, property, percent) {
         | 
| 123 | 
            +
            			if (percent == 1.0) {
         | 
| 124 | 
            +
            				var value = property.target;
         | 
| 125 | 
            +
            			} else {
         | 
| 126 | 
            +
            				var value = property.source + property.difference * percent
         | 
| 127 | 
            +
            			}
         | 
| 128 | 
            +
             | 
| 129 | 
            +
            			var cssValue = null;
         | 
| 130 | 
            +
            			if (property.unit == 'px') {
         | 
| 131 | 
            +
            				cssValue = parseInt(value) + property.unit;
         | 
| 132 | 
            +
            			} else {
         | 
| 133 | 
            +
            				cssValue = value.toFixed(2) + property.unit;
         | 
| 134 | 
            +
            			}
         | 
| 135 | 
            +
             | 
| 136 | 
            +
            			this.setStyle(this.element, name, cssValue);
         | 
| 137 | 
            +
            		},
         | 
| 138 | 
            +
             | 
| 139 | 
            +
            		getStyle: function(element, cssProperty) {
         | 
| 140 | 
            +
            			return Pox.getComputedStyle(element, cssProperty);
         | 
| 141 | 
            +
            		},
         | 
| 142 | 
            +
             | 
| 143 | 
            +
            		setStyle: function(element, cssProperty, cssValue) {
         | 
| 144 | 
            +
            			Pox.setStyle(element, cssProperty, cssValue);
         | 
| 145 | 
            +
            		}
         | 
| 146 | 
            +
            	})
         | 
| 147 | 
            +
             | 
| 148 | 
            +
            	var AnimateQueue = Pox.clazz({
         | 
| 149 | 
            +
            		animates: [],
         | 
| 150 | 
            +
             | 
| 151 | 
            +
            		append: function(animate) {
         | 
| 152 | 
            +
            			var self = this;
         | 
| 153 | 
            +
             | 
| 154 | 
            +
            			animate.originComplete = animate.complete;
         | 
| 155 | 
            +
            			animate.complete = function() {
         | 
| 156 | 
            +
            				self.animates.shift();
         | 
| 157 | 
            +
            				if (self.animates.length >= 1) {
         | 
| 158 | 
            +
            					self.animates[0].start();
         | 
| 159 | 
            +
            				}
         | 
| 160 | 
            +
             | 
| 161 | 
            +
            				this.originComplete();
         | 
| 162 | 
            +
            			}
         | 
| 163 | 
            +
             | 
| 164 | 
            +
            			this.animates.push(animate);
         | 
| 165 | 
            +
            			if (this.animates.length == 1) {
         | 
| 166 | 
            +
            				this.animates[0].start();
         | 
| 167 | 
            +
            			}
         | 
| 168 | 
            +
            		},
         | 
| 169 | 
            +
             | 
| 170 | 
            +
            		clear: function() {
         | 
| 171 | 
            +
            			for (var i = 0; i < this.animates.length; i++) {
         | 
| 172 | 
            +
            				this.animates[i].abort();
         | 
| 173 | 
            +
            			}
         | 
| 174 | 
            +
            			this.animates = [];
         | 
| 175 | 
            +
            		}
         | 
| 176 | 
            +
            	})
         | 
| 177 | 
            +
             | 
| 178 | 
            +
            	Pox.EASINGS = EASINGS;
         | 
| 179 | 
            +
            	
         | 
| 180 | 
            +
            	/**
         | 
| 181 | 
            +
            	 * 元素滑动(js滑动)
         | 
| 182 | 
            +
            	 * @param {HTMLElement} element
         | 
| 183 | 
            +
            	 * @param {object} options
         | 
| 184 | 
            +
            	 * @param {number} [options.duration=200] 滑动时长
         | 
| 185 | 
            +
            	 * @param {number} [options.interval=60]  频率
         | 
| 186 | 
            +
            	 * @param {string} [options.easing=linear] 滑动类型
         | 
| 187 | 
            +
            	 * @param {object} options.styles 样式
         | 
| 188 | 
            +
            	 * @param {function} [options.complete] 滑动成功后的回调函数
         | 
| 189 | 
            +
            	 * @example <caption>Example usage of animate.</caption>
         | 
| 190 | 
            +
            	 * $p.animate(element, {
         | 
| 191 | 
            +
            	 *	  styles: {
         | 
| 192 | 
            +
            	 *	  	left: this.elementResetPosition.left + leftOffset + 'px',
         | 
| 193 | 
            +
            	 *	  	top: this.elementResetPosition.top + topOffset + 'px'
         | 
| 194 | 
            +
            	 *	  },
         | 
| 195 | 
            +
            	 *	  duration: 200,
         | 
| 196 | 
            +
            	 *	  interval: 40,
         | 
| 197 | 
            +
            	 *	  easing: 'linear',
         | 
| 198 | 
            +
            	 *	  complete: function() {}
         | 
| 199 | 
            +
            	 *  });
         | 
| 200 | 
            +
            	 */
         | 
| 201 | 
            +
            	Pox.animate = function(element, options) {
         | 
| 202 | 
            +
            		var animate = Pox.instance(Animate, options);
         | 
| 203 | 
            +
            		animate.element = element;
         | 
| 204 | 
            +
             | 
| 205 | 
            +
            		var queue = element.animateQueue = element.animateQueue || Pox.instance(AnimateQueue);
         | 
| 206 | 
            +
            		if (!options.queue) {
         | 
| 207 | 
            +
            			queue.clear();
         | 
| 208 | 
            +
            		}
         | 
| 209 | 
            +
            		queue.append(animate);
         | 
| 210 | 
            +
            	}
         | 
| 211 | 
            +
            })()
         |