-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit da5fca5
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
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
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. |
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
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, ' ')); | |||
}); | |||
}); | |||
|
|||
}); |