Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
markelliot committed Jun 29, 2011
0 parents commit da5fca5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,4 @@
StackOverflow Edit Context Tab Remover
--------------------------------------

Adds a simple button (\t) to stip tabs from the post material for easier editing. The button applies only to the edit context.
31 changes: 31 additions & 0 deletions SOTabRemover.user.js
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,31 @@
// ==UserScript==
// @name StackOverflow Edit Context Tab Remover
// @author Mark Elliot
// @description Adds a button in the SO edit context to replace tab literals (\t) with 4 spaces
// @include http://stackoverflow.com/posts/*/edit*
// @match http://stackoverflow.com/posts/*/edit*
// ==/UserScript==

// This work is licensed under the Creative Commons Attribution 3.0 Unported License.
// To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/.

function with_jquery(f) {
var script = document.createElement("script");
script.type = "text/javascript";
script.textContent = "(" + f.toString() + ")(jQuery)";
document.body.appendChild(script);
};

with_jquery(function($){

$(function(){
$('ul#wmd-button-row li:last')
.before('<li class="wmd-button" id="fix-tabs" style="left: 400px; font-family: monospace; padding-top: 3px; font-size: 11px; hover:">\\t</li>')
.before('<li class="wmd-spacer" style="left: 375px;"></li>');

$('li#fix-tabs').click(function(){
$('textarea#wmd-input.processed').val($('textarea#wmd-input.processed').text().replace(/\t/g, ' '));
});
});

});

0 comments on commit da5fca5

Please sign in to comment.