DokuWiki

It's better when it's simple

User Tools

Site Tools


devel:toolbar

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
devel:toolbar [2014-11-30 15:08] – [Dynamic Data] turnermmdevel:toolbar [2017-01-07 22:41] – [Tips] turnermm
Line 20: Line 20:
 | ''title'' | title of the button, displayed on mouseover | | ''title'' | title of the button, displayed on mouseover |
 | ''icon'' | icon to use for the button (based in ''DOKUBASE/lib/images/toolbar/'')| | ''icon'' | icon to use for the button (based in ''DOKUBASE/lib/images/toolbar/'')|
-| ''key'' | Hotkey for the button, a value of ''n'' here would result in the button being pressed when the user presses ''ALT + n'' in his browser. (See also the [[:accesskeys|access keys]] used by DokuWiki) |+| ''key''(optional) Hotkey for the button, a value of ''n'' here would result in the button being pressed when the user presses ''ALT + n'' in his browser. (See also the [[:accesskeys|access keys]] used by DokuWiki) 
 +| ''class'' | (optional) classname for styling buttons | 
 +| ''id''    | (optional) id added to button, and with a postfix to icon e.g. ''<id>_ico'' |
 ^ ''format'' type specific parameters  ^^ ^ ''format'' type specific parameters  ^^
 | ''open'' | opening tag of wiki markup to insert, cursor will be placed between opening and closing tag | | ''open'' | opening tag of wiki markup to insert, cursor will be placed between opening and closing tag |
Line 41: Line 43:
 ==== ...using PHP ==== ==== ...using PHP ====
  
-To extend the toolbar from your plugin you need to write a [[devel:Action Plugin]] which registers as handler for the [[events_list#toolbar_define|TOOLBAR_DEFINE]] event with an AFTER advise. Your handler function will receive the toolbar array as described earlier.+To extend the toolbar from your plugin you need to write a [[devel:Action Plugin]] which registers as handler for the [[devel:event:TOOLBAR_DEFINE]] event with an AFTER advise. Your handler function will receive the toolbar array as described earlier.
  
 Create your button structure according to the above information and add it to the received event data.-function in ''inc/toolbar.php''. Create your button structure according to the above information and add it to the received event data.-function in ''inc/toolbar.php''.
Line 57: Line 59:
  * Inserts a toolbar button  * Inserts a toolbar button
  */  */
-function insert_button($event, $param) {+function insert_button(Doku_Event $event, $param) {
     $event->data[] = array (     $event->data[] = array (
         'type' => 'format',         'type' => 'format',
Line 112: Line 114:
 </code> </code>
 Some notes: Some notes:
-  * Be aware of the default locations of the images ''lib/images/toolbar/'' and ''lib/images/''+  * Be aware of the default locations of the images''lib/images/toolbar/'' and ''lib/images/''
   * The available options for access keys depends on the [[:accesskeys|access keys]] used by DokuWiki and the whether they are reserved by a browser or operation system as short cut. There are many differences.   * The available options for access keys depends on the [[:accesskeys|access keys]] used by DokuWiki and the whether they are reserved by a browser or operation system as short cut. There are many differences.
   * More about [[devel:localization#javascript localization]]   * More about [[devel:localization#javascript localization]]
Line 124: Line 126:
 When adding to the ''toolbar'' array you must set a custom value for ''type'' You must use characters that are valid in a function name and should capitalize the first character.  When the toolbar is constructed it looks at the value of ''type'' and appends it to the string ''addBtnAction'' before calling your code.  So if you set ''type'' to ''Click'' the toolbar will call ''addBtnActionClick'' This is an important note because if two plugins use the same ''type'' they will conflict with each other and cause strange behavior (such as both buttons doing the exact same thing). When adding to the ''toolbar'' array you must set a custom value for ''type'' You must use characters that are valid in a function name and should capitalize the first character.  When the toolbar is constructed it looks at the value of ''type'' and appends it to the string ''addBtnAction'' before calling your code.  So if you set ''type'' to ''Click'' the toolbar will call ''addBtnActionClick'' This is an important note because if two plugins use the same ''type'' they will conflict with each other and cause strange behavior (such as both buttons doing the exact same thing).
  
-FIXME  What does the below return string statment mean: "return the id for in aria-control"?   --- [[user>turnermm|Myron Turner]] //2014-06-11 15:52// +The returned string is "the id for in aria-control". This is explained further in [[http://msdn.microsoft.com/en-us/library/windows/apps/hh767301.aspx|Accessible Rich Internet Applications]].
- +
-Answered this for myself: [[http://msdn.microsoft.com/en-us/library/windows/apps/hh767301.aspx|Accessible Rich Internet Applications]]  \\ --- [[user>turnermm|Myron Turner]] //2014-11-30 15:06//+
  
  
Line 181: Line 181:
   * There are some [[devel:javascript#predefined global variables]] available which you can access from your Javascript. For example JSINFO contains the page id and namespace, usage: ''JSINFO.namespace''. This might be handy when doing some more dynamic stuff.   * There are some [[devel:javascript#predefined global variables]] available which you can access from your Javascript. For example JSINFO contains the page id and namespace, usage: ''JSINFO.namespace''. This might be handy when doing some more dynamic stuff.
   * **Important**: If the button does not appear, expire the cache of your DokuWiki by saving your config in the Config Manager or touching the ''conf/local.php'' of your wiki AND delete your browser cache (Ctrl+F5 or Ctrl+R)! Than reload the editor page and your button should appear.   * **Important**: If the button does not appear, expire the cache of your DokuWiki by saving your config in the Config Manager or touching the ''conf/local.php'' of your wiki AND delete your browser cache (Ctrl+F5 or Ctrl+R)! Than reload the editor page and your button should appear.
 +
 +
 +=== Removing Buttons ===
 +
 +If you want to remove some of the toolbar buttons, you can do so by adding the following code into ''/conf/userscript.js''. Note that this is not in any function, simply append this code to the end of the file:
 +
 +<code javascript /conf/userscript.js>
 +if (typeof window.toolbar !== 'undefined') {
 +   var blacklist = ["Bold Text", "Italic Text", "Underlined Text", "Monospaced Text", "Strike-through Text", 
 +   "Same Level Headline", "Lower Headline", "Higher Headline", "Select Headline", "Internal Link", "External Link", 
 +   "Horizontal Rule", "Add Images and other files (opens in a new window)", "Smileys", "Special Chars", "Insert Signature"];
 +    window.toolbar = window.toolbar.filter(function(elem){ return jQuery.inArray(elem.title, blacklist) === -1; });
 +}
 +</code>
 +
 +This is from my personal wiki where I removed almost all the buttons. You can figure out what the title of your button is by running the following snippet in a javascript console:
 +<code javascript>for (i in window.toolbar) { console.log(toolbar[i].title)}</code>
 +
 +Then take the string and append it to the 'blacklist' array in the code.
 +
 +See also the [[plugin:toolbuttondel|]] plugin for removing toolbar items.
 +
devel/toolbar.txt · Last modified: 2023-08-01 20:08 by annda

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki