Skip to content

Instantly share code, notes, and snippets.

@datapimp
Created September 28, 2012 20:19
Show Gist options
  • Select an option

  • Save datapimp/3801900 to your computer and use it in GitHub Desktop.

Select an option

Save datapimp/3801900 to your computer and use it in GitHub Desktop.
DOM Manipuluation
class SectionMarkup extends Backbone.Model
html: ()->
@raw = @get("html")
# we will receive html, doctype, html tag and all, and get a parsed version of the contents
# which will include some tags ( title tags, stylesheets, etc ) that we should leave out.
# also we need to adjust the src attribute of the images to point to the server paths
previewContent: ()->
markup = @html()
util = $('.markup-editor-util', 'body').eq(0)
util.html( markup )
discardTags = util.find('link,title,meta, script')
discardTags.remove()
content_package_id = Luca.getApplication().contentPackageId()
util.find('img').each (index, element)=>
currentValue = $(element).attr('src')
unless currentValue.match(/^\//)
$(element).attr('src', Publisher.util.applyImagePath(currentValue, content_package_id ))
util.html()
@u-bits
Copy link

u-bits commented Sep 28, 2012

Hi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment