(data)
| 26391 | } |
| 26392 | |
| 26393 | function clickToOpen(data){ |
| 26394 | var preventDefault = matchedRule.clickToOpen.preventDefault; |
| 26395 | var button = matchedRule.clickToOpen.button || 0; |
| 26396 | var alt = !!matchedRule.clickToOpen.alt; |
| 26397 | var ctrl = !!matchedRule.clickToOpen.ctrl; |
| 26398 | var shift = !!matchedRule.clickToOpen.shift; |
| 26399 | var meta = !!matchedRule.clickToOpen.meta; |
| 26400 | |
| 26401 | function mouseout(){ |
| 26402 | document.removeEventListener('mouseout', mouseout, true); |
| 26403 | document.removeEventListener(button == 2 ? 'contextmenu' : 'mousedown', click, true); |
| 26404 | if(data.imgPA && preventDefault){ |
| 26405 | data.imgPA.removeEventListener('click', clickA, true); |
| 26406 | }; |
| 26407 | }; |
| 26408 | |
| 26409 | function checkLimit(e){ |
| 26410 | if(e.button!=button || |
| 26411 | e.altKey!=alt || |
| 26412 | e.ctrlKey!=ctrl || |
| 26413 | e.shiftKey!=shift || |
| 26414 | e.metaKey!=meta){ |
| 26415 | return false; |
| 26416 | } |
| 26417 | return true; |
| 26418 | } |
| 26419 | |
| 26420 | function click(e){ |
| 26421 | if(!checkLimit(e))return; |
| 26422 | FloatBarC.prototype.open.call({ |
| 26423 | data:data, |
| 26424 | },e,matchedRule.clickToOpen.type); |
| 26425 | if(preventDefault){ |
| 26426 | e.preventDefault(); |
| 26427 | e.stopPropagation(); |
| 26428 | return false; |
| 26429 | } |
| 26430 | }; |
| 26431 | |
| 26432 | function clickA(e){//阻止a的默认行为 |
| 26433 | if(!checkLimit(e))return; |
| 26434 | e.preventDefault(); |
| 26435 | }; |
| 26436 | |
| 26437 | document.addEventListener(button == 2 ? 'contextmenu' : 'mousedown', click, true); |
| 26438 | |
| 26439 | if(data.imgPA && preventDefault){ |
| 26440 | data.imgPA.addEventListener('click', clickA, true); |
| 26441 | }; |
| 26442 | |
| 26443 | setTimeout(function(){//稍微延时。错开由于css hover样式发生的out; |
| 26444 | document.addEventListener('mouseout', mouseout, true); |
| 26445 | },100); |
| 26446 | |
| 26447 | return function(){ |
| 26448 | mouseout(); |
| 26449 | }; |
| 26450 | } |
no test coverage detected