Created
May 22, 2013 20:48
-
-
Save lamalex/5630772 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fbloading = false; | |
Template.newEventDialog.helpers({ | |
'fbloading': function() { | |
return fbloading; | |
} | |
}); | |
Template.newEventDialog.events({ | |
'blur input[name=facebook-url]': function(e) { | |
e.preventDefault(); | |
function parseUrlForID() { | |
var url = $('input[name=facebook-url]').val(); | |
var re = 'events/[0-9]*'; | |
var args = url.match(re); | |
if (args.length > 0) | |
args = args[0]; | |
var eventId = args.split('/')[1]; | |
return(eventId); | |
} | |
function getEventDetails() { | |
fbloading = true; | |
FB.api(parseUrlForID(), function(response) { | |
fbloading = false; | |
console.log(response); | |
$('input[name=event-title]').val(response.name); | |
$('input[name=event-datetime]').val(response.start_time); | |
$('input[name=event-location]').val(response.location); | |
}); | |
} | |
FB.getLoginStatus(function (response) { | |
if (response.authResponse) { | |
getEventDetails(); | |
} else { | |
FB.login(function(response) { | |
if(response.authResponse) { | |
getEventDetails(); | |
} else { | |
console.log('display an error somewhere'); | |
} | |
}); | |
} | |
}); | |
}, | |
'click #new-event-cancel': function(e) { | |
$('input[name=facebook-url]').val(""); | |
$('input[name=event-title]').val(""); | |
$('input[name=event-datetime]').val(""); | |
$('input[name=event-location]').val(""); | |
}, | |
'click #new-event-submit': function(e) { | |
} | |
}); | |
Template.newEventDialog.rendered = function () { | |
$('#new-event-dialog').on('shown', function() { | |
var picker = $('#datepicker').datetimepicker({ | |
format: 'dd/MM/yyyy hh:mm', | |
pickSeconds: false, | |
pick12HourFormat: true, | |
startDate: new Date().getTime() | |
}); | |
}); | |
$('#new-event-dialog').on('hide', function() { | |
var widget = $('.bootstrap-datetimepicker-widget'); | |
widget.hide(); // this might be problematic. i'm getting this widget popping up at the wrong time but not sure why | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment