Changeset 34875
- Timestamp:
- 08/15/09 11:03:06 (4 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/javascript/vimperator-plugins/trunk/auto-focus-frame.js
r34522 r34875 39 39 <description>Automatically focus to largest frame.</description> 40 40 <description lang="ja">最も大きなフレームに自動的にフォーカスする。</description> 41 <version>1.0. 6</version>41 <version>1.0.7</version> 42 42 <author mail="anekos@snca.net" homepage="http://d.hatena.ne.jp/nokturnalmortum/">anekos</author> 43 43 <license>new BSD License (Please read the source code comments of this plugin)</license> … … 53 53 == Usage == 54 54 インストールするだけ 55 一番面積の大きいフレームをフォーカスします 55 56 ]]></detail> 56 57 </VimperatorPlugin>; … … 59 60 (function () { 60 61 61 autocommands.add( 62 'DOMLoad', 63 '.*', 64 function () { 65 function doFocus () { 66 let [maxSize, maxFrame] = [-1, null]; 67 for (let frame in util.Array.itervalues(content.frames)) { 68 try { 69 if (!(frame.frameElement instanceof HTMLFrameElement)) 70 continue; 71 if (frame.scrollMaxX <= 0 && frame.scrollMaxY <= 0) 72 continue; 73 let size = frame.innerWidth * frame.innerHeight; 74 if (maxSize < size) { 75 maxSize = size; 76 maxFrame = frame; 77 } 78 } catch (e) { 79 liberator.log(e) 62 function onLoad () { 63 function doFocus () { 64 let [maxSize, maxFrame] = [-1, null]; 65 for (let frame in util.Array.itervalues(content.frames)) { 66 try { 67 if (!(frame.frameElement instanceof HTMLFrameElement)) 80 68 continue; 69 if (frame.scrollMaxX <= 0 && frame.scrollMaxY <= 0) 70 continue; 71 let size = frame.innerWidth * frame.innerHeight; 72 if (maxSize < size) { 73 maxSize = size; 74 maxFrame = frame; 81 75 } 76 } catch (e) { 77 liberator.log(e) 78 continue; 82 79 } 83 if (maxFrame)84 maxFrame.focus();85 80 } 81 if (maxFrame) 82 maxFrame.focus(); 83 } 86 84 87 88 if (!(window.content.document instanceof HTMLDocument)) 89 return; 90 if (content.frames.length <= 1) 85 if (!(window.content.document instanceof HTMLDocument)) 91 86 return; 92 87 93 let nframes = content.frames.length; 94 for (let frame in util.Array.itervalues(content.frames)) { 95 if (frame.frameElement instanceof HTMLFrameElement) { 88 if (content.frames.length <= 1) 89 return; 90 91 let nframes = content.frames.length; 92 93 function callDoFocus () { 94 if (!--nframes) 95 doFocus(); 96 } 97 98 for (let frame in util.Array.itervalues(content.frames)) { 99 if (frame.frameElement instanceof HTMLFrameElement) { 100 if (frame.body) { 101 callDoFocus(); 102 } else { 96 103 frame.addEventListener( 97 104 'DOMContentLoaded', 98 105 function () { 99 106 frame.removeEventListener('DOMContentLoaded', arguments.callee, true); 100 if (!--nframes) 101 doFocus(); 107 callDoFocus(); 102 108 }, 103 109 true … … 105 111 } 106 112 } 113 } 114 } 107 115 108 } 109 ); 116 autocommands.add('DOMLoad', '.*', onLoad); 110 117 111 118 })();
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)