Commit a7510b04906d92c7c11644f9a248e69b9f21796f
refactor crtl+scroll a little
mix irving committed on 2/3/2017, 3:12:04 AMParent: 1c52cfcf601897aad8909bfa4a03a47a9c6da3f2
Files changed
modules_core/tabs.js | changed |
modules_core/tabs.js | ||
---|---|---|
@@ -1,8 +1,9 @@ | ||
1 | -var Tabs = require('hypertabs') | |
2 | -var h = require('hyperscript') | |
3 | -var keyscroll = require('../keyscroll') | |
4 | -var open = require('open-external') | |
1 … | +const Tabs = require('hypertabs') | |
2 … | +const h = require('hyperscript') | |
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) |
@@ -176,42 +177,41 @@ | ||
176 | 177 … | delete window.onError |
177 | 178 … | } |
178 | 179 … | |
179 | 180 … | // put errors in a tab |
180 | - window.addEventListener('error', function (ev) { | |
181 | - var err = ev.error || ev | |
181 … | + window.addEventListener('error', ev => { | |
182 … | + const err = ev.error || ev | |
182 | 183 … | if(!tabs.has('errors')) |
183 | 184 … | tabs.add(errors, false) |
184 | - var el = h('div.message', | |
185 … | + const el = h('div.message', [ | |
185 | 186 … | h('strong', err.message), |
186 | - h('pre', err.stack)) | |
187 … | + h('pre', err.stack) | |
188 … | + ]) | |
187 | 189 … | if (errorsContent.firstChild) |
188 | 190 … | errorsContent.insertBefore(el, errorsContent.firstChild) |
189 | 191 … | else |
190 | 192 … | errorsContent.appendChild(el) |
191 | 193 … | }) |
192 | 194 … | |
193 | 195 … | if (process.versions.electron) { |
194 | - var {webFrame} = require('electron') | |
195 | 196 … | |
196 | - window.addEventListener('mousewheel', function (ev) { | |
197 | - var {ctrlKey, deltaY} = ev | |
198 | - if(ctrlKey){ | |
199 | - var direction = (deltaY / Math.abs(deltaY)) | |
200 | - var currentZoom = webFrame.getZoomLevel() | |
197 … | + window.addEventListener('mousewheel', ev => { | |
198 … | + const { ctrlKey, deltaY } = ev | |
199 … | + if (ctrlKey) { | |
200 … | + const direction = (deltaY / Math.abs(deltaY)) | |
201 … | + const currentZoom = webFrame.getZoomLevel() | |
201 | 202 … | webFrame.setZoomLevel(currentZoom - direction) |
202 | 203 … | } |
203 | 204 … | }) |
204 | 205 … | |
205 | - window.addEventListener('contextmenu', function (ev) { | |
206 … | + window.addEventListener('contextmenu', ev => { | |
206 | 207 … | ev.preventDefault() |
207 | - var remote = require('electron').remote | |
208 | - var Menu = remote.Menu | |
209 | - var MenuItem = remote.MenuItem | |
210 | - var menu = new Menu() | |
208 … | + const Menu = remote.Menu | |
209 … | + const MenuItem = remote.MenuItem | |
210 … | + const menu = new Menu() | |
211 | 211 … | menu.append(new MenuItem({ |
212 | 212 … | label: 'Inspect Element', |
213 | - click: function () { | |
213 … | + click: () => { | |
214 | 214 … | remote.getCurrentWindow().inspectElement(ev.x, ev.y) |
215 | 215 … | } |
216 | 216 … | })) |
217 | 217 … | menu.popup(remote.getCurrentWindow()) |
Built with git-ssb-web