git ssb

16+

Dominic / patchbay



Commit a7510b04906d92c7c11644f9a248e69b9f21796f

refactor crtl+scroll a little

mix irving committed on 2/3/2017, 3:12:04 AM
Parent: 1c52cfcf601897aad8909bfa4a03a47a9c6da3f2

Files changed

modules_core/tabs.jschanged
modules_core/tabs.jsView
@@ -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')
56
67 function ancestor (el) {
78 if(!el) return
89 if(el.tagName !== 'A') return ancestor(el.parentElement)
@@ -176,42 +177,41 @@
176177 delete window.onError
177178 }
178179
179180 // 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
182183 if(!tabs.has('errors'))
183184 tabs.add(errors, false)
184- var el = h('div.message',
185 + const el = h('div.message', [
185186 h('strong', err.message),
186- h('pre', err.stack))
187 + h('pre', err.stack)
188 + ])
187189 if (errorsContent.firstChild)
188190 errorsContent.insertBefore(el, errorsContent.firstChild)
189191 else
190192 errorsContent.appendChild(el)
191193 })
192194
193195 if (process.versions.electron) {
194- var {webFrame} = require('electron')
195196
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()
201202 webFrame.setZoomLevel(currentZoom - direction)
202203 }
203204 })
204205
205- window.addEventListener('contextmenu', function (ev) {
206 + window.addEventListener('contextmenu', ev => {
206207 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()
211211 menu.append(new MenuItem({
212212 label: 'Inspect Element',
213- click: function () {
213 + click: () => {
214214 remote.getCurrentWindow().inspectElement(ev.x, ev.y)
215215 }
216216 }))
217217 menu.popup(remote.getCurrentWindow())

Built with git-ssb-web