Fixed twitter share

This commit is contained in:
fergal.moran
2012-09-24 17:23:18 +01:00
parent 1da11b0462
commit e7db7f79d9
3 changed files with 37 additions and 14 deletions

View File

@@ -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);
};

View File

@@ -42,7 +42,12 @@ window.MixListItemView = Backbone.View.extend({
$('#favourite-' + id, this.el).html('<i class="icon-star"></i> 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..');
});
},

View File

@@ -43,8 +43,8 @@
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a data-mode="<%= item.mode %>" data-id="<%= item.id %>" class="share-button share-button-facebook"> Facebook</a></li>
<!--<li><a data-mode="<%= item.mode %>" data-id="<%= item.id %>" class="share-button share-button-twitter"> Twitter</a></li> -->
<li><a data-mode="facebook" data-id="<%= item.id %>" class="share-button share-button-facebook"> Facebook</a></li>
<li><a data-mode="twitter" data-id="<%= item.id %>" href="" class="share-button share-button-twitter"> Twitter</a></li>
</ul>
</div>
</div>