From e7db7f79d9ee277178329099a7cbc98dd99bd841 Mon Sep 17 00:00:00 2001 From: "fergal.moran" Date: Mon, 24 Sep 2012 17:23:18 +0100 Subject: [PATCH] Fixed twitter share --- static/js/app/social.js | 34 +++++++++++++++++++++++-------- static/js/app/views/mix.js | 13 ++++++++---- templates/inc/_MixItemInsert.html | 4 ++-- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/static/js/app/social.js b/static/js/app/social.js index 4222d17..aa7b84c 100644 --- a/static/js/app/social.js +++ b/static/js/app/social.js @@ -29,21 +29,39 @@ postFacebookLike = function (mixId) { ); }; -postFacebookFavourite = function(mixId){ +postFacebookFavourite = function (mixId) { }; -sharePageToFacebook = function(model){ +sharePageToTwitter = function (model) { +//We get the URL of the link + var loc = $(this).attr('href'); + +//We get the title of the link + var title = $(this).attr('title'); + +//We trigger a new window with the Twitter dialog, in the middle of the page + window.open( + 'http://twitter.com/share?url=' + 'http://' + window.location.host + "/" + model.get('item_url') + + '&text=' + model.get('title'), + 'twitterwindow', + 'height=450, width=550, top=' + ($(window).height() / 2 - 225) + + ', left=' + $(window).width() / 2 + + ', toolbar=0, location=0, menubar=0, directories=0, scrollbars=0'); +}; +sharePageToFacebook = function (model) { var obj = { - method: 'feed', - link: 'http://' + window.location.host + "/" + model.get('item_url'), - picture: model.get('mix_image'), - name: 'Check out this mix on Deep South Sounds', - caption: model.get('title'), - description: model.get('description') + method:'feed', + link:'http://' + window.location.host + "/" + model.get('item_url'), + picture:model.get('mix_image'), + name:'Check out this mix on Deep South Sounds', + caption:model.get('title'), + description:model.get('description') }; + function callback(response) { com.podnoms.utils.alert("Post ID: " + response['post_id']); } + FB.ui(obj, callback); }; \ No newline at end of file diff --git a/static/js/app/views/mix.js b/static/js/app/views/mix.js index 872d832..c6607c0 100644 --- a/static/js/app/views/mix.js +++ b/static/js/app/views/mix.js @@ -42,7 +42,12 @@ window.MixListItemView = Backbone.View.extend({ $('#favourite-' + id, this.el).html(' Favourite'); }, shareLink:function (e) { - sharePageToFacebook(this.model); + var id = $(e.currentTarget).data("id"); + var mode = $(e.currentTarget).data("mode"); + if (mode == "facebook") + sharePageToFacebook(this.model); + else if (mode == "twitter") + sharePageToTwitter(this.model); }, likeMix:function (e) { var id = $(e.currentTarget).data("id"); @@ -180,10 +185,10 @@ window.MixCreateView = DSSEditableView.extend({ 'buttonText':"Select audio file (mp3 for now please)", 'formData':{ 'upload-hash':this.guid, - 'sessionid': $.cookie('sessionid') + 'sessionid':$.cookie('sessionid') }, - 'onUploadFile': function(file){ - $(window).on('beforeunload', function(){ + 'onUploadFile':function (file) { + $(window).on('beforeunload', function () { alert('Go on outta that..'); }); }, diff --git a/templates/inc/_MixItemInsert.html b/templates/inc/_MixItemInsert.html index bff90ca..8d0d8b8 100644 --- a/templates/inc/_MixItemInsert.html +++ b/templates/inc/_MixItemInsert.html @@ -43,8 +43,8 @@