1/** 2 * 带æç¶æçæé®ï¼æ¨å¨è¿éå¯ä»¥è¿è¡ç¶æåæ¢æä½ 3 */ 4class StatusButton { 5 6 static status_className = { 7 "active": "status_button_active", 8 "close": "status_button_close", 9 "warning": "status_button_warning", 10 "pause": "status_button_pause" 11 } 12 13 _status_color = { 14 "active": {color: "rgb(0, 255, 174)"}, 15 "close": {color: "rgb(255, 0, 0)"}, 16 "warning": {color: "rgb(255, 255, 0)"}, 17 "pause": {color: "#777777"} 18 } 19 20 status_fun = [ 21 () => this.setStatusNoFun("pause"), () => this.setStatusNoFun("active"), () => this.setStatusNoFun("close"), () => this.setStatusNoFun("warning") 22 ] 23 24 /** 25 * å°ä¸ä¸ªæé®å ç´ åå§åä¸ºç¶ææé® 26 * @param element å ç´ å¯¹è±¡ 27 */ 28 constructor(element) { 29 this.e = element; 30 for (let string of ['status_button']) { 31 this.e.classList.add(string); 32 } 33 } 34 35 /** 36 * 设置å½åæé®çä¸åç¶æ 37 * @param status {"active"|"close"|"warning"|"pause"} ç¶æ 38 */ 39 setStatusNoFun(status) { 40 const statusColorElement = this._status_color[status]; 41 for (let statusColorKey in statusColorElement) { 42 this.e.style[statusColorKey] = statusColorElement[statusColorKey]; 43 } 44 } 45 46 /** 47 * 设置å½åæé®çä¸åç¶æä¸çCSSæ ·å¼ 48 * @param status {"active"|"close"|"warning"|"pause"} ç¶æ 49 * @param color {string:string} æ ·å¼å±æ§ 50 */ 51 setStatusColor(status, color) { 52 this._status_color[status] = color; 53 } 54 55 /** 56 * 57 * @param {function(HTMLElement, function(), function(), function(), function())} fun è¿éæ¯ä¸ä¸ªåè°å½æ°ï¼æ¨å¯ä»¥å¨æ¤å½æ°ä¸å®ç°ç¶æåæ¢ï¼å½æ°ä¸çå个形å代表çå°±æ¯å个ä¸åçç¶æ 58 * å嫿¯æåãæ¿æ´»ãå ³éãè¦å 59 */ 60 setStatus(fun) { 61 // å 设置为æå 62 this.setStatusNoFun("pause"); 63 // ç¶åè®©ç¨æ·è®¾ç½®ç¶æ æåç¨æ·éè¦å¨å½æ°ä¸è°ç¨æ´æ°å½æ° 64 fun(this.e, this.status_fun[0], this.status_fun[1], this.status_fun[2], this.status_fun[3]); 65 } 66 67 /** 68 * 对å½åçæé®æ·»å ä¸ä¸ªäºä»¶å¤ç 69 * @param fun äºä»¶å¤ç彿° è¾å ¥çæ¯äºä»¶å¯¹è±¡ ä»¥å æé®å¯¹è±¡ 70 * @param eventName 触åäºä»¶çåç§° 71 * @return {function} è¿åç彿°æ¯ç§»é¤äºä»¶å½æ°ï¼æ¨å¦æéè¦ç§»é¤çè¯ï¼å¯ä»¥ç´æ¥ä½¿ç¨æ¤å½æ°æ¥è¿è¡ç§»é¤ï¼ 72 */ 73 addEvent(fun, eventName = "click") { 74 const newVar = (e) => fun(e, this.e); 75 this.e.addEventListener(eventName, newVar); 76 return newVar; 77 } 78 79 /** 80 * ç§»é¤äºä»¶ 81 * @param fun éè¦ç§»é¤çäºä»¶å½æ° 82 * @param eventName 对åºçäºä»¶åç§° 83 */ 84 removeEvent(fun, eventName = "click") { 85 this.e.removeEventListener(eventName, fun); 86 } 87}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.