Skip to content

Commit

Permalink
Implement new custom elements registration to allow updates
Browse files Browse the repository at this point in the history
  • Loading branch information
abe33 committed Nov 1, 2015
1 parent b4fc2d9 commit f5ab5e3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
7 changes: 4 additions & 3 deletions lib/minimap-element.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{debounce} = require 'underscore-plus'
{CompositeDisposable, Disposable} = require 'atom'
{EventsDelegation, AncestorsMethods} = require 'atom-utils'
{registerOrUpdateElement, EventsDelegation, AncestorsMethods} = require 'atom-utils'
DOMStylesReader = require './mixins/dom-styles-reader'
CanvasDrawer = require './mixins/canvas-drawer'

Expand All @@ -18,7 +18,7 @@ MinimapQuickSettingsElement = null
#
# Note that most interactions with the Minimap package is done through the
# {Minimap} model so you should never have to access {MinimapElement} instances.
class MinimapElement extends HTMLElement
class MinimapElement
DOMStylesReader.includeInto(this)
CanvasDrawer.includeInto(this)
EventsDelegation.includeInto(this)
Expand Down Expand Up @@ -698,7 +698,8 @@ class MinimapElement extends HTMLElement
# ## ## ## ## ## ## ## ### ##
# ######## ######## ######## ## ## ######## ## ## ##

module.exports = MinimapElement = document.registerElement 'atom-text-editor-minimap', prototype: MinimapElement.prototype
module.exports =
MinimapElement = registerOrUpdateElement 'atom-text-editor-minimap', MinimapElement.prototype

# Public: The method that registers the {MinimapElement} factory in the
# `atom.views` registry with the passed-in model.
Expand Down
6 changes: 4 additions & 2 deletions lib/minimap-plugin-generator-element.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ fs = require 'fs-plus'
path = require 'path'
{TextEditor, BufferedProcess} = require 'atom'
{CompositeDisposable} = require 'event-kit'
{registerOrUpdateElement} = require 'atom-utils'

# Internal: The {MinimapPluginGeneratorElement} is used whenever the user
# triggers the `minimap:generate-plugin` command.
module.exports =
class MinimapPluginGeneratorElement extends HTMLElement
class MinimapPluginGeneratorElement
previouslyFocusedElement: null
mode: null

Expand Down Expand Up @@ -127,7 +128,8 @@ class MinimapPluginGeneratorElement extends HTMLElement
new BufferedProcess({command, args, exit, options})


module.exports = MinimapPluginGeneratorElement = document.registerElement 'minimap-plugin-generator', prototype: MinimapPluginGeneratorElement.prototype
module.exports =
MinimapPluginGeneratorElement = registerOrUpdateElement 'minimap-plugin-generator', MinimapPluginGeneratorElement.prototype

atom.commands.add 'minimap-plugin-generator', {
'core:confirm': -> @confirm()
Expand Down
8 changes: 4 additions & 4 deletions lib/minimap-quick-settings-element.coffee
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{EventsDelegation, SpacePenDSL} = require 'atom-utils'
{registerOrUpdateElement, EventsDelegation, SpacePenDSL} = require 'atom-utils'
{CompositeDisposable, Emitter} = require 'event-kit'

Main = require './main'

# Internal: The {MinimapQuickSettingsElement} class is used to display
# the Minimap quick settings when clicking on the corresponding button.
module.exports =
class MinimapQuickSettingsElement extends HTMLElement
class MinimapQuickSettingsElement
SpacePenDSL.includeInto(this)
EventsDelegation.includeInto(this)

Expand Down Expand Up @@ -155,4 +154,5 @@ class MinimapQuickSettingsElement extends HTMLElement
deactivateItem: (name, plugin) ->
@plugins[name].classList.remove('active')

module.exports = MinimapQuickSettingsElement = document.registerElement 'minimap-quick-settings', prototype: MinimapQuickSettingsElement.prototype
module.exports =
MinimapQuickSettingsElement = registerOrUpdateElement 'minimap-quick-settings', MinimapQuickSettingsElement.prototype

0 comments on commit f5ab5e3

Please sign in to comment.