os0x / ChromeKeyconfig (http://ss-o.net/chrome_extension/)

Keyconfig Extension for Google Chrome

Clone this repository (size: 187.5 KB): HTTPS / SSH
$ hg clone http://bitbucket.org/os0x/chromekeyconfig/
commit 112: 29f846979858
parent 111: 458ba5465e4e
branch: default
hit-a-hint:マッチしたら即focusするように hit-a-hint:MigemoFindInPageからis_viewable関数をポート
os0x
5 weeks ago

Changed (Δ342 bytes):

raw changeset »

chrome_keyconfig.js (29 lines added, 12 lines removed)

Up to file-list chrome_keyconfig.js:

@@ -573,13 +573,9 @@ var ACTION = {
573
573
			return n;
574
574
		};
575
575
		function getAbsolutePosition(elem) {
576
			var style = getComputedStyle(elem, null);
577
			var rect = elem.getClientRects()[0];
578
			if (rect && rect.right - rect.left > 0 && 
579
				style.visibility != 'hidden' && style.opacity != 0 && 
580
				rect.width !== 0 && rect.height !== 0 &&
581
				rect.left >= 0 && rect.right <= window.innerWidth &&
582
				rect.top >= -5 && rect.bottom <= window.innerHeight + 5) {
576
			var rects;
577
			if ((rects=is_viewable(elem))){
578
				var rect = rects[0];
583
579
				return {
584
580
					y: window.pageYOffset - Root.clientTop + rect.top,
585
581
					x: window.pageXOffset - Root.clientLeft + rect.left
@@ -587,6 +583,21 @@ var ACTION = {
587
583
			}
588
584
			return false;
589
585
		};
586
		function is_viewable(elem) {
587
			var rects = elem.getClientRects();
588
			var i = 0, e;
589
			while (r = rects[i++]) {
590
				e = document.elementFromPoint(r.left, r.top);
591
				if (e && e === elem) return rects;
592
				e = document.elementFromPoint(r.left, r.bottom - 1);
593
				if (e && e === elem) return rects;
594
				e = document.elementFromPoint(r.right - 1, r.top);
595
				if (e && e === elem) return rects;
596
				e = document.elementFromPoint(r.right - 1, r.bottom - 1);
597
				if (e && e === elem) return rects;
598
			}
599
			return false;
600
		}
590
601
		var hints = [];
591
602
		function drawHints() {
592
603
			var elems = document.querySelectorAll('a[href],*[onclick],input:not([type="hidden"]),textarea,button,select');
@@ -625,14 +636,20 @@ var ACTION = {
625
636
			document.body.appendChild(div);
626
637
		};
627
638
		var choice = '', choiceHint;
628
		function pushLetter(key){
639
		function pushLetter(key, e){
629
640
			var hint = hints[retrieveNumber(choice+key)];
630
641
			if (hint){
631
642
				choice += key;
632
643
				var lastHint = hints[hints.length - 1].text;
633
				hint.label.style.backgroundColor = '#F0F';
634
				if (choiceHint) choiceHint.label.style.backgroundColor = '#FF0';
644
				hint.label.style.backgroundColor = '#ff00ff';
645
				hint.elem.focus();
646
				e.preventDefault();
647
				if (choiceHint) {
648
					choiceHint.label.style.backgroundColor = '#ffff00';
649
				}
635
650
				choiceHint = hint;
651
			} else {
652
				unloadHaH();
636
653
			}
637
654
		};
638
655
		function focusHint(e){
@@ -650,8 +667,8 @@ var ACTION = {
650
667
		};
651
668
		function handler(e){
652
669
			var key = get_key(e);
653
			if (hintkeys.indexOf(key) >= 0) return pushLetter(key);
654
			if (key == ENTER) return focusHint(e);
670
			if (hintkeys.indexOf(key) >= 0) return pushLetter(key, e);
671
			//if (key == ENTER) return focusHint(e);
655
672
			unloadHaH();
656
673
		};
657
674
		function initHaH(){