Skip to content

Instantly share code, notes, and snippets.

@Yopi
Created August 9, 2016 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yopi/efa24cdfb54cc2b2b415a709fb4f79d8 to your computer and use it in GitHub Desktop.
Save Yopi/efa24cdfb54cc2b2b415a709fb4f79d8 to your computer and use it in GitHub Desktop.
class ContentTools.Tools.YogobeVideo extends ContentTools.Tool
# Insert a video.
ContentTools.ToolShelf.stow(@, 'yogobe-readmore')
@label = 'Yogobe Read More'
@icon = 'read-more'
@canApply: (element, selection) ->
# Return true if the tool can be applied to the current
# element/selection.
return not element.isFixed()
@apply: (element, selection, callback) ->
# Apply the tool to the current element
read_more = new ContentEdit.YogobeReadMore(
'yogobe-readmore', {})
# Find insert position
[node, index] = @_insertAt(element)
node.parent().attach(read_more, index)
# Focus the new video
read_more.focus()
callback(true)
ContentTools.DEFAULT_TOOLS[2].push('yogobe-readmore')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment