Update code for Settings change
Clicking the overlay will close the element, and also adds back the `.unscroll` class
This commit is contained in:
parent
d51b6027c2
commit
c01d833ab0
@ -4,7 +4,7 @@ Settings =
|
|||||||
link = $.el 'a',
|
link = $.el 'a',
|
||||||
className: 'settings-link fa fa-wrench'
|
className: 'settings-link fa fa-wrench'
|
||||||
textContent: 'Settings'
|
textContent: 'Settings'
|
||||||
title: '<%= meta.name %> Settings'
|
title: '<%= meta.name %> Settings'
|
||||||
href: 'javascript:;'
|
href: 'javascript:;'
|
||||||
$.on link, 'click', Settings.open
|
$.on link, 'click', Settings.open
|
||||||
|
|
||||||
@ -41,13 +41,9 @@ Settings =
|
|||||||
return if Settings.overlay
|
return if Settings.overlay
|
||||||
$.event 'CloseMenu'
|
$.event 'CloseMenu'
|
||||||
|
|
||||||
Settings.dialog = dialog = $.el 'div',
|
Settings.dialog = overlay = $.el 'div',
|
||||||
id: 'fourchanx-settings'
|
id: 'overlay'
|
||||||
className: 'dialog'
|
innerHTML: <%= readHTML('Settings.html') %>
|
||||||
$.extend dialog, <%= readHTML('Settings.html') %>
|
|
||||||
|
|
||||||
Settings.overlay = overlay = $.el 'div',
|
|
||||||
id: 'overlay'
|
|
||||||
|
|
||||||
$.on $('.export', dialog), 'click', Settings.export
|
$.on $('.export', dialog), 'click', Settings.export
|
||||||
$.on $('.import', dialog), 'click', Settings.import
|
$.on $('.import', dialog), 'click', Settings.import
|
||||||
@ -64,14 +60,16 @@ Settings =
|
|||||||
links.push link, $.tn ' | '
|
links.push link, $.tn ' | '
|
||||||
sectionToOpen = link if section.title is openSection
|
sectionToOpen = link if section.title is openSection
|
||||||
links.pop()
|
links.pop()
|
||||||
$.add $('.sections-list', dialog), links
|
$.add $('.sections-list', overlay), links
|
||||||
(if sectionToOpen then sectionToOpen else links[0]).click() unless openSection is 'none'
|
(if sectionToOpen then sectionToOpen else links[0]).click() unless openSection is 'none'
|
||||||
|
|
||||||
$.on $('.close', dialog), 'click', Settings.close
|
$.on $('.close', overlay), 'click', Settings.close
|
||||||
$.on overlay, 'click', Settings.close
|
$.on overlay, 'click', Settings.close
|
||||||
$.on window, 'beforeunload', Settings.close
|
$.on window, 'beforeunload', Settings.close
|
||||||
|
$.on overlay.firstElementChild, 'click', (e) -> e.stopPropagation()
|
||||||
|
|
||||||
$.add d.body, [overlay, dialog]
|
$.addClass d.body, 'unscroll'
|
||||||
|
$.add d.body, overlay
|
||||||
|
|
||||||
$.event 'OpenSettings', null, dialog
|
$.event 'OpenSettings', null, dialog
|
||||||
|
|
||||||
@ -79,9 +77,8 @@ Settings =
|
|||||||
return unless Settings.dialog
|
return unless Settings.dialog
|
||||||
# Unfocus current field to trigger change event.
|
# Unfocus current field to trigger change event.
|
||||||
d.activeElement?.blur()
|
d.activeElement?.blur()
|
||||||
$.rm Settings.overlay
|
$.rmClass d.body, 'unscroll'
|
||||||
$.rm Settings.dialog
|
$.rm Settings.dialog
|
||||||
delete Settings.overlay
|
|
||||||
delete Settings.dialog
|
delete Settings.dialog
|
||||||
|
|
||||||
sections: []
|
sections: []
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user