From 844a2efb0210de3e944d2315a7d467435645f7be Mon Sep 17 00:00:00 2001 From: John Crepezzi Date: Tue, 10 Jan 2012 23:06:44 -0500 Subject: [PATCH] Added support for raw button --- static/application.css | 6 +++--- static/application.js | 14 ++++++++++++-- static/application.min.js | 2 +- static/index.html | 1 + 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/static/application.css b/static/application.css index 7587eed..55e9469 100644 --- a/static/application.css +++ b/static/application.css @@ -140,9 +140,9 @@ textarea { #box2 .function.enabled.duplicate { background-position: -79px center; } #box2 .function.enabled.duplicate:hover { background-position: -79px bottom; } -#box2 .function.link { background-position: -116px top; } -#box2 .function.enabled.link { background-position: -116px center; } -#box2 .function.enabled.link:hover { background-position: -116px bottom; } +#box2 .function.raw { background-position: -116px top; } +#box2 .function.enabled.raw { background-position: -116px center; } +#box2 .function.enabled.raw:hover { background-position: -116px bottom; } #box2 .function.twitter { background-position: -153px top; } #box2 .function.enabled.twitter { background-position: -153px center; } diff --git a/static/application.js b/static/application.js index cff7443..0f02955 100644 --- a/static/application.js +++ b/static/application.js @@ -88,7 +88,6 @@ haste_document.prototype.save = function(data, callback) { var haste = function(appName, options) { this.appName = appName; - this.baseUrl = window.location.href; // since this is loaded first this.$textarea = $('textarea'); this.$box = $('#box'); this.$code = $('#box code'); @@ -124,7 +123,7 @@ haste.prototype.lightKey = function() { // Show the full key haste.prototype.fullKey = function() { - this.configureKey(['new', 'duplicate', 'twitter', 'link']); + this.configureKey(['new', 'duplicate', 'twitter', 'raw']); }; // Set the key up for certain things to be enabled @@ -293,6 +292,17 @@ haste.prototype.configureButtons = function() { _this.duplicateDocument(); } }, + { + $where: $('#box2 .raw'), + label: 'Just Text', + shortcut: function(evt) { + return evt.ctrlKey && evt.shiftKey && evt.keyCode === 82; + }, + shortcutDescription: 'control + shift + r', + action: function() { + window.open('/raw/' + _this.doc.key); + } + }, { $where: $('#box2 .twitter'), label: 'Twitter', diff --git a/static/application.min.js b/static/application.min.js index 34e7b6a..11573a7 100644 --- a/static/application.min.js +++ b/static/application.min.js @@ -1 +1 @@ -var haste_document=function(){this.locked=!1};haste_document.prototype.htmlEscape=function(a){return a.replace(/&/g,"&").replace(/>/g,">").replace(/'+a+"");$("#messages").prepend(c),setTimeout(function(){c.slideUp("fast",function(){$(this).remove()})},3e3)},haste.prototype.lightKey=function(){this.configureKey(["new","save"])},haste.prototype.fullKey=function(){this.configureKey(["new","duplicate","twitter","link"])},haste.prototype.configureKey=function(a){var b,c=0;$("#box2 .function").each(function(){b=$(this);for(c=0;c";$("#linenos").html(b)},haste.prototype.removeLineNumbers=function(){$("#linenos").html(">")},haste.prototype.loadDocument=function(a){var b=a.split(".",2),c=this;c.doc=new haste_document,c.doc.load(b[0],function(a){a?(c.$code.html(a.value),c.setTitle(a.key),c.fullKey(),c.$textarea.val("").hide(),c.$box.show().focus(),c.addLineNumbers(a.lineCount)):c.newDocument()},this.lookupTypeByExtension(b[1]))},haste.prototype.duplicateDocument=function(){if(this.doc.locked){var a=this.doc.data;this.newDocument(),this.$textarea.val(a)}},haste.prototype.lockDocument=function(){var a=this;this.doc.save(this.$textarea.val(),function(b,c){if(b)a.showMessage(b.message,"error");else if(c){a.$code.html(c.value),a.setTitle(c.key);var d="/"+c.key;c.language&&(d+="."+a.lookupExtensionByType(c.language)),window.history.pushState(null,a.appName+"-"+c.key,d),a.fullKey(),a.$textarea.val("").hide(),a.$box.show().focus(),a.addLineNumbers(c.lineCount)}})},haste.prototype.configureButtons=function(){var a=this;this.buttons=[{$where:$("#box2 .save"),label:"Save",shortcutDescription:"control + s",shortcut:function(a){return a.ctrlKey&&a.keyCode===83},action:function(){a.$textarea.val().replace(/^\s+|\s+$/g,"")!==""&&a.lockDocument()}},{$where:$("#box2 .new"),label:"New",shortcut:function(a){return a.ctrlKey&&a.keyCode===78},shortcutDescription:"control + n",action:function(){a.newDocument(!a.doc.key)}},{$where:$("#box2 .duplicate"),label:"Duplicate & Edit",shortcut:function(b){return a.doc.locked&&b.ctrlKey&&b.keyCode===68},shortcutDescription:"control + d",action:function(){a.duplicateDocument()}},{$where:$("#box2 .twitter"),label:"Twitter",shortcut:function(b){return a.options.twitter&&a.doc.locked&&b.ctrlKey&&b.keyCode==84},shortcutDescription:"control + t",action:function(){window.open("https://twitter.com/share?url="+encodeURI(window.location.href))}}];for(var b=0;b/g,">").replace(/'+a+"");$("#messages").prepend(c),setTimeout(function(){c.slideUp("fast",function(){$(this).remove()})},3e3)},haste.prototype.lightKey=function(){this.configureKey(["new","save"])},haste.prototype.fullKey=function(){this.configureKey(["new","duplicate","twitter","raw"])},haste.prototype.configureKey=function(a){var b,c=0;$("#box2 .function").each(function(){b=$(this);for(c=0;c";$("#linenos").html(b)},haste.prototype.removeLineNumbers=function(){$("#linenos").html(">")},haste.prototype.loadDocument=function(a){var b=a.split(".",2),c=this;c.doc=new haste_document,c.doc.load(b[0],function(a){a?(c.$code.html(a.value),c.setTitle(a.key),c.fullKey(),c.$textarea.val("").hide(),c.$box.show().focus(),c.addLineNumbers(a.lineCount)):c.newDocument()},this.lookupTypeByExtension(b[1]))},haste.prototype.duplicateDocument=function(){if(this.doc.locked){var a=this.doc.data;this.newDocument(),this.$textarea.val(a)}},haste.prototype.lockDocument=function(){var a=this;this.doc.save(this.$textarea.val(),function(b,c){if(b)a.showMessage(b.message,"error");else if(c){a.$code.html(c.value),a.setTitle(c.key);var d="/"+c.key;c.language&&(d+="."+a.lookupExtensionByType(c.language)),window.history.pushState(null,a.appName+"-"+c.key,d),a.fullKey(),a.$textarea.val("").hide(),a.$box.show().focus(),a.addLineNumbers(c.lineCount)}})},haste.prototype.configureButtons=function(){var a=this;this.buttons=[{$where:$("#box2 .save"),label:"Save",shortcutDescription:"control + s",shortcut:function(a){return a.ctrlKey&&a.keyCode===83},action:function(){a.$textarea.val().replace(/^\s+|\s+$/g,"")!==""&&a.lockDocument()}},{$where:$("#box2 .new"),label:"New",shortcut:function(a){return a.ctrlKey&&a.keyCode===78},shortcutDescription:"control + n",action:function(){a.newDocument(!a.doc.key)}},{$where:$("#box2 .duplicate"),label:"Duplicate & Edit",shortcut:function(b){return a.doc.locked&&b.ctrlKey&&b.keyCode===68},shortcutDescription:"control + d",action:function(){a.duplicateDocument()}},{$where:$("#box2 .raw"),label:"Just Text",shortcut:function(a){return a.ctrlKey&&a.shiftKey&&a.keyCode===82},shortcutDescription:"control + shift + r",action:function(){window.open("/raw/"+a.doc.key)}},{$where:$("#box2 .twitter"),label:"Twitter",shortcut:function(b){return a.options.twitter&&a.doc.locked&&b.ctrlKey&&b.keyCode==84},shortcutDescription:"control + t",action:function(){window.open("https://twitter.com/share?url="+encodeURI(window.location.href))}}];for(var b=0;b
+