Jump to content

User:MarkS/extraeditbuttons.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by MarkS (talk | contribs) at 20:54, 24 April 2006. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// This is based on the original code on Wikipedia:Tools/Editing tools
//
// The original code was on the project page and needed to be cut and paste to the user's
// monobook.js page. However, this caused problems with the quote marks. So I have moved 
// it to its own page. 
//
// I do not know a lot about Javascript so please do not ask for a complicated change
//
// Changed 24/02/2006 - Window.Onload replaced with addOnloadHook


function InsertButtonsToToolBar()
{
 tooly = document.getElementById('toolbar');

 if (tooly != null) 
{
  StrikeTextButton = "<a href=\"javascript:insertTags('<s>','</s>','Insert text here');\"><img src=\"/media/wikipedia/en/c/c9/Button_strike.png\" alt=\"Strike\" title=\"Strike-through text\"></a>";

LeftTextButton = "<a href=\"javascript:insertTags('<div style=&quot;text-align: left; direction: ltr; margin-left: 1em;&quot;>\\n','\\n</div>','Left-aligned text');\"><img src=\"/media/wikipedia/en/e/ea/Button_align_left.png\" alt=\"Left-align\" title=\"Left-aligned text\"></a>";

  CenterTextButton = "<a href=\"javascript:insertTags('<div style=&quot;text-align: center;&quot;>','</div>','Centered text');\"><img src=\"/media/wikipedia/en/5/5f/Button_center.png\" alt=\"Centered\" title=\"Centered text\"></a>";

  TableButton = "<a href=\"javascript:insertTags('\\n{| border=&quot;1&quot; \\n|- \\n| 1 || 2\\n|- \\n| 3 || 4','\\n|}\\n','');\"><img src=\"/media/wikipedia/en/6/60/Button_insert_table.png\" alt=\"Table\" title=\"Insert table\"></a>";

  EenterButton = "<a href=\"javascript:insertTags('<br />','','');\"><img src=\"/media/wikipedia/en/1/13/Button_enter.png\" alt=\"Break\" title=\"Line break\"></a>";

  UpperTextButton = "<a href=\"javascript:insertTags('<sup>','</sup>','Superscript');\"><img src=\"/media/wikipedia/en/8/80/Button_upper_letter.png\" alt=\"Superscript\" title=\"Superscript text\"></a>";

  LowerTextlButton = "<a href=\"javascript:insertTags('<sub>','</sub>','Subscript');\"><img src=\"/media/wikipedia/en/7/70/Button_lower_letter.png\" alt=\"Subscript\" title=\"Subscript text\"></a>";

  SmallTextButton = "<a href=\"javascript:insertTags('<small>','</small>','Small text');\"><img src=\"/media/wikipedia/en/5/58/Button_small.png\" alt=\"Small\" title=\"Small text\"></a>";

  CommentButton = "<a href=\"javascript:insertTags('<!--','-->','Comment here');\"><img src=\"/media/wikipedia/en/3/34/Button_hide_comment.png\" alt=\"Comment\" title=\"Insert hidden comment\"></a>";

  GalleryButton = "<a href=\"javascript:insertTags('\\n<gallery>\\n','\\n</gallery>','Image:FileName.jpg|Caption1\\Image:FileName2.jpg|Caption2');\"><img src=\"/media/wikipedia/en/1/12/Button_gallery.png\" alt=\"Gallery\" title=\"Insert a picture gallery\"></a>";

  SecondaryHeadlineButton = "<a href=\"javascript:insertTags('\\n===','===','Secondary headline');\"><img src=\"/media/wikipedia/en/e/e9/Button_headline2.png\" alt=\"2nd header\" title=\"Insert secondary headline\"></a>";

ShiftingButton = "<a href=\"javascript:insertTags(':','',':');\"><img src=\"/media/wikipedia/en/8/8e/Button_shifting.png\" alt=\"Tab\" title=\"Insert tab(s)\"></a>";

  BlockQuoteButton = "<a href=\"javascript:insertTags('<blockquote style=&quot;border: 1px solid blue; padding: 2em;&quot;>\\n','\\n</blockquote>','Block quote');\"><img src=\"/media/wikipedia/en/f/fd/Button_blockquote.png\" alt=\"Block quote\" title=\"Insert block of quoted text\"></a>";

  FontColorButton = "<a href=\"javascript:insertTags('<span style=&quot;color: ColorName&quot;>','</span>','Span of text');\"><img src=\"/media/wikipedia/en/1/1e/Button_font_color.png\" alt=\"Color\" title=\"Insert colored text\"></a>";

  CodeButton = "<a href=\"javascript:insertTags('<code>','</code>','Code');\"><img src=\"/media/wikipedia/en/2/23/Button_code.png\" alt=\"Code\" title=\"Insert code\"></a>";

  SubLinkButton = "<a href=\"javascript:insertTags('[[Page#',']]','Sub_page');\"><img src=\"/media/wikipedia/en/9/93/Button_sub_link.png\" alt=\"sub-page link\" title=\"Insert link to sub-page\"></a>";

  DefinitionListCodeButton = "<a href=\"javascript:insertTags('\\n; ',' : ','Insert text');\"><img src=\"/media/wikipedia/en/d/d3/Button_definition_list.png\" alt=\"Definition\" title=\"Insert definition list\"></a>";


 extraHTML = StrikeTextButton + LeftTextButton + CenterTextButton + TableButton + EenterButton + UpperTextButton + LowerTextlButton + SmallTextButton + CommentButton + GalleryButton + SecondaryHeadlineButton + ShiftingButton + BlockQuoteButton + FontColorButton + CodeButton + SubLinkButton + DefinitionListCodeButton;


node2 = document.createElement("span");
tooly.parentNode.insertBefore(node2, tooly.nextSibling);
node2.innerHTML=extraHTML;


}
}
addOnloadHook( InsertButtonsToToolBar );