Commit 32a28daa63eadf650dd8fdd3dd5140aa9d8e6538
Merge branch 'master' into refactor_hypertabs
mix irving committed on 2/3/2017, 5:25:25 AMParent: 32aba29b1bd68e4ba002781ccc56db127018f545
Parent: 0132c055406a2cc025989cea9154fea161b776c9
Files changed
modules_core/tabs.js | changed |
package.json | changed |
modules_core/tabs.js | ||
---|---|---|
@@ -1,8 +1,9 @@ | ||
1 | -var Tabs = require('hypertabs') | |
2 | -var h = require('../h') | |
3 | -var keyscroll = require('../keyscroll') | |
4 | -var open = require('open-external') | |
1 … | +const Tabs = require('hypertabs') | |
2 … | +const h = require('../h') | |
3 … | +const keyscroll = require('../keyscroll') | |
4 … | +const open = require('open-external') | |
5 … | +const { webFrame, remote } = require('electron') | |
5 | 6 … | |
6 | 7 … | function ancestor (el) { |
7 | 8 … | if(!el) return |
8 | 9 … | if(el.tagName !== 'A') return ancestor(el.parentElement) |
@@ -183,31 +184,41 @@ | ||
183 | 184 … | delete window.onError |
184 | 185 … | } |
185 | 186 … | |
186 | 187 … | // put errors in a tab |
187 | - window.addEventListener('error', function (ev) { | |
188 | - var err = ev.error || ev | |
188 … | + window.addEventListener('error', ev => { | |
189 … | + const err = ev.error || ev | |
189 | 190 … | if(!tabs.has('errors')) |
190 | 191 … | tabs.add(errors, false) |
191 | - var el = h('div.message', | |
192 … | + const el = h('div.message', [ | |
192 | 193 … | h('strong', err.message), |
193 | - h('pre', err.stack)) | |
194 … | + h('pre', err.stack) | |
195 … | + ]) | |
194 | 196 … | if (errorsContent.firstChild) |
195 | 197 … | errorsContent.insertBefore(el, errorsContent.firstChild) |
196 | 198 … | else |
197 | 199 … | errorsContent.appendChild(el) |
198 | 200 … | }) |
199 | 201 … | |
200 | 202 … | if (process.versions.electron) { |
201 | - window.addEventListener('contextmenu', function (ev) { | |
203 … | + | |
204 … | + window.addEventListener('mousewheel', ev => { | |
205 … | + const { ctrlKey, deltaY } = ev | |
206 … | + if (ctrlKey) { | |
207 … | + const direction = (deltaY / Math.abs(deltaY)) | |
208 … | + const currentZoom = webFrame.getZoomLevel() | |
209 … | + webFrame.setZoomLevel(currentZoom - direction) | |
210 … | + } | |
211 … | + }) | |
212 … | + | |
213 … | + window.addEventListener('contextmenu', ev => { | |
202 | 214 … | ev.preventDefault() |
203 | - var remote = require('electron').remote | |
204 | - var Menu = remote.Menu | |
205 | - var MenuItem = remote.MenuItem | |
206 | - var menu = new Menu() | |
215 … | + const Menu = remote.Menu | |
216 … | + const MenuItem = remote.MenuItem | |
217 … | + const menu = new Menu() | |
207 | 218 … | menu.append(new MenuItem({ |
208 | 219 … | label: 'Inspect Element', |
209 | - click: function () { | |
220 … | + click: () => { | |
210 | 221 … | remote.getCurrentWindow().inspectElement(ev.x, ev.y) |
211 | 222 … | } |
212 | 223 … | })) |
213 | 224 … | menu.popup(remote.getCurrentWindow()) |
Built with git-ssb-web