basic lightbox support

This commit is contained in:
Sam Saffron
2013-02-19 17:57:14 +11:00
parent 14c0b96d55
commit d9531d94d5
15 changed files with 191 additions and 44 deletions
@@ -134,6 +134,7 @@ window.Discourse = Ember.Application.createWithMixins
return if href is '#'
return if $currentTarget.attr('target')
return if $currentTarget.data('auto-route')
return if $currentTarget.hasClass('lightbox')
return if href.indexOf("mailto:") is 0
if href.match(/^http[s]?:\/\//i) && !href.match new RegExp("^http:\\/\\/" + window.location.hostname,"i")
@@ -6,6 +6,8 @@ window.Discourse.ClickTrack =
$a = $(e.currentTarget)
return if $a.hasClass('lightbox')
e.preventDefault()
# We don't track clicks on quote back buttons
@@ -0,0 +1,8 @@
# Helper object for light boxes. Uses highlight.js which is loaded
# on demand.
window.Discourse.Lightbox =
apply: ($elem) ->
$('a.lightbox', $elem).each (i, e) =>
$LAB.script("/javascripts/jquery.colorbox-min.js").wait ->
$(e).colorbox()
@@ -212,6 +212,7 @@ window.Discourse.PostView = Ember.View.extend
# Add syntax highlighting
Discourse.SyntaxHighlighting.apply($post)
Discourse.Lightbox.apply($post)
# If we're scrolling upwards, adjust the scroll position accordingly
if scrollTo = @get('post.scrollTo')