1
0
Fork 0
mirror of https://github.com/SunRed/haste-server.git synced 2024-11-01 09:40:21 +01:00

Make twitter posting an option

This commit is contained in:
John Crepezzi 2011-11-19 01:00:04 -05:00
parent 6499ad3190
commit 9638baffdb
3 changed files with 7 additions and 5 deletions

1
TODO
View file

@ -3,7 +3,6 @@ tests
test in other browsers and add note to README test in other browsers and add note to README
maximum size of a haste maximum size of a haste
fix any annoying visual quirks fix any annoying visual quirks
make twitter posting an option
add FAVICON add FAVICON
# shared version only # shared version only

View file

@ -53,13 +53,14 @@ haste_document.prototype.save = function(data, callback) {
///// represents the paste application ///// represents the paste application
var haste = function(appName) { var haste = function(appName, options) {
this.appName = appName; this.appName = appName;
this.baseUrl = window.location.href; // since this is loaded first this.baseUrl = window.location.href; // since this is loaded first
this.$textarea = $('textarea'); this.$textarea = $('textarea');
this.$box = $('#box'); this.$box = $('#box');
this.$code = $('#box code'); this.$code = $('#box code');
this.configureShortcuts(); this.configureShortcuts();
this.options = options;
}; };
// Set the page title - include the appName // Set the page title - include the appName
@ -84,7 +85,9 @@ haste.prototype.fullKey = function() {
text += '^s - save<br>'; text += '^s - save<br>';
text += '^n - new<br>'; text += '^n - new<br>';
text += '^d - duplicate<br>'; text += '^d - duplicate<br>';
text += '^t - twitter'; if (this.options.twitter) {
text += '^t - twitter';
}
$('#key').html(text); $('#key').html(text);
}; };
@ -175,7 +178,7 @@ haste.prototype.configureShortcuts = function() {
_this.duplicateDocument(); _this.duplicateDocument();
} }
// ^T for redirecting to twitter // ^T for redirecting to twitter
else if (_this.doc.locked && evt.ctrlKey && evt.keyCode == 84) { else if (_this.options.twitter && _this.doc.locked && evt.ctrlKey && evt.keyCode == 84) {
evt.preventDefault(); evt.preventDefault();
window.open('https://twitter.com/share?url=' + encodeURI(_this.baseUrl + _this.doc.key)); window.open('https://twitter.com/share?url=' + encodeURI(_this.baseUrl + _this.doc.key));
} }

View file

@ -14,7 +14,7 @@
<script type="text/javascript"> <script type="text/javascript">
$(function() { $(function() {
// Set up // Set up
var app = new haste('haste'); var app = new haste('haste', { twitter: true });
// Handle pops // Handle pops
window.onpopstate = function(evt) { window.onpopstate = function(evt) {
var path = evt.target.location.pathname; var path = evt.target.location.pathname;