Skip to content
Browse files

Added new method on player: getCurrentlyPlayingUrl() and implemented …

…it in the share page for mailto share link.
  • Loading branch information...
1 parent f89b93b commit 589bb7227b079399e3d853171b24cdf31bacc55f Johan Bichel Lindegaard committed
Showing with 28 additions and 2 deletions.
  1. +1 −1 html/pages/share.html
  2. +8 −0 src/controllers/control.coffee
  3. +19 −1 src/controllers/player.coffee
View
2 html/pages/share.html
@@ -18,7 +18,7 @@
</div>
</div>
<div data-role="fieldcontain" id="mail-button-wrapper">
- <a id="mail" href="mailto:?subject=Link til bog fra E17 Mobil" data-role="button">Del bog</a>
+ <a id="email-bookmark" href="" rel="external" data-role="button">Del bog</a>
</div>
</div>
View
8 src/controllers/control.coffee
@@ -354,5 +354,13 @@ LYT.control =
share:(type, match, ui, page, event) ->
if type is 'pageshow'
+
+ if LYT.player.getCurrentlyPlaying()?
+ subject = "Link til bog på E17"
+ body = "Hør #{LYT.player.book.title} her #{LYT.player.getCurrentlyPlayingUrl()}"
+ $("#email-bookmark").attr('href', "mailto:?subject=#{subject}&body=#{body}")
+ else
+ history.back()
+ # todo: better error handling here
View
20 src/controllers/player.coffee
@@ -454,4 +454,22 @@ LYT.player =
return null unless @book? and @section?
book: @book.id
section: @section.id
-
+
+ getCurrentlyPlayingUrl: (absolute=true, resolution='book') ->
+ # Returns the url of the currently playing book
+ # Accepts a resolution a string that is either 'book', 'section' or 'offset'
+ # Defaults to 'book'
+ # If absolute is true it returns the full url with domain
+
+ return null unless @book? and @section?
+
+ url = "#book-play?book=#{@book.id}"
+ if resolution in ['section', 'offset']
+ url = url + "&section=#{@section.id}"
+ if resolution is 'offset' and @time?
+ url = url + "&offset=#{@time}"
+
+ if absolute
+ return document.baseURI + url
+
+ return url

0 comments on commit 589bb72

Please sign in to comment.
Something went wrong with that request. Please try again.