User:Andreas Plank/common.js

From TDWG Terms Wiki
< User:Andreas Plank
Revision as of 16:41, 9 January 2014 by Andreas Plank (Talk | contribs) ("div.definition-inline")

Jump to: navigation, search

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Clear the cache in Tools → Preferences
/* <pre> */
var customizeToolbar = function() {
    $('#wpTextbox1').wikiEditor('addToToolbar', {
      'sections': {
        'programming': {
          type: 'booklet',
          label: 'Programming'
        }
      }
    });
    $('#wpTextbox1').wikiEditor('addToToolbar', {
      section: 'programming',
      pages: {
        tags: {
          layout: 'characters',
          label: 'Wiki/HTML Tags',
          'characters': [{
              label: "nbsp;",
              action: {
                type: 'encapsulate',
                options: {pre: "&nbsp;", post: ""}
              }
            }, {
              label: "()",
              action: {
                type: 'encapsulate',
                options: {pre: "(", post: ")"}
              }
            }, {
              label: "[]",
              action: {
                type: 'encapsulate',
                options: {pre: "[", post: "]"}
              }
            }, {
              label: "[[]]",
              action: {
                type: 'encapsulate',
                options: {pre: "[[", post: "]]"}
              }
            }, {
              label: "{{}}",
              action: {
                type: 'encapsulate',
                options: {pre: "{{", post: "}}"}
              }
            }, {
              label: "[[Category:]]",
              action: {
                type: 'encapsulate',
                options: {pre: "[[Category: ", post: "]]"}
              }
            }, {
              label: "[[property:]]",
              action: {
                type: 'encapsulate',
                options: {
                  /* no selection */
                  pre: "[[property: ",
                  post: "]]",
                  /* a selection */
                  regex:/\s*(.+)\s*/,
                  regexReplace:"[[property: \$1 |\$1]]"
                }
              }
            }, {
              label: "#REDIRECT [[]]",
              action: {
                type: 'encapsulate',
                options: {pre: "#REDIRECT [[", post: "]]"}
              }
            }, {
              label: "noinclude",
              action: {
                type: 'encapsulate',
                options: {pre: "<noinclude>", post: "</noinclude>"}
              }
            }, {
              label: "includeonly",
              action: {
                type: 'encapsulate',
                options: {pre: "<includeonly>", post: "</includeonly>"}
              }
            }, {
              label: "onlyinclude",
              action: {
                type: 'encapsulate',
                options: {pre: "<onlyinclude>", post: "</onlyinclude>"}
              }
            }, {
              label: "code",
              action: {
                type: 'encapsulate',
                options: {pre: "<code>", post: "</code>"}
              }
            }, {
              label: "nowiki",
              action: {
                type: 'encapsulate',
                options: {pre: "<nowiki>", post: "</nowiki>"}
              }
            }, {
              label: "code nowiki code",
              action: {
                type: 'encapsulate',
                options: {pre: "<code><nowiki>", post: "</nowiki></code>"}
              }
            }, {
              label: "comment",
              action: {
                type: 'encapsulate',
                options: {pre: "<!-- ", post: " -->"}
              }
            }, {
              label: "span",
              action: {
                type: 'encapsulate',
                options: {pre: '<span style="">', post: '</span>'}
              }
            }, {
              label: "div",
              action: {
                type: 'encapsulate',
                options: {pre: '<div style="">', post: '</div>'}
              }
            }, {
              label: "div.floating-form-parts",
              action: {
                type: 'encapsulate',
                options: {pre: '<div class="floating-form-parts">', post: '</div>'}
              }
            }, {
              label: "div.no-pre-border",
              action: {
                type: 'encapsulate',
                options: {pre: '<div class="no-pre-border no-pre-margin no-pre-padding">', post: '</div>'}
              }
            }, {
              label: "table",
              action: {
                type: 'encapsulate',
                options: {pre: '<table>',peri: '<!--\n--><tr><!--\n  --><td></td><!--\n--></tr><!--\n-->', post: '</table>'}
              }
            }, {
              label: "tr",
              action: {
                type: 'encapsulate',
                options: {pre: '<tr>',peri: '<!--\n  --><td></td><!--\n-->', post: '</tr>'}
              }
            }, {
              label: "th",
              action: {
                type: 'encapsulate',
                options: {pre: '<th>', post: '</th>'}
              }
            }, {
              label: "td",
              action: {
                type: 'encapsulate',
                options: {pre: '<td>', post: '</td>'}
              }
            },
            '┌',
            '┬',
            '┐',
            '└',
            '┴',
            '┘',
            '│',
            '─',
            '├',
            '┼',
            '┤',
            '↖', '↗', '↘', '↙', '↔', '↕', '⇄', '⇅'
          /*  <s></s>   <sup></sup>   <sub></sub>  <ref></ref>   {{Reflist}}   <references/>  <span class="plainlinks"></span> */
          ]
        },
        vars: {
          layout: 'characters',
          label: 'Functions/Variables',
          'characters': [{
              label: "nbsp;",
              action: {
                type: 'encapsulate',
                options: {pre: "&nbsp;", post: ""}
              }
            }, {
              label: "()",
              action: {
                type: 'encapsulate',
                options: {pre: "(", post: ")"}
              }
            }, {
              label: "[]",
              action: {
                type: 'encapsulate',
                options: {pre: "[", post: "]"}
              }
            }, {
              label: "[[]]",
              action: {
                type: 'encapsulate',
                options: {pre: "[[", post: "]]"}
              }
            }, {
              label: "{{}}",
              action: {
                type: 'encapsulate',
                options: {pre: "{{", post: "}}"}
              }
            }, {
              label: "{{{}}}",
              action: {
                type: 'encapsulate',
                options: {pre: "{{{", post: "}}}"}
              }
            }, {
              label: "{{{|}}}",
              action: {
                type: 'encapsulate',
                options: {pre: "{{{", post: "|}}}"}
              }
            }, {
              label: "noinclude",
              action: {
                type: 'encapsulate',
                options: {pre: "<noinclude>", post: "</noinclude>"}
              }
            }, {
              label: "includeonly",
              action: {
                type: 'encapsulate',
                options: {pre: "<includeonly>", post: "</includeonly>"}
              }
            }, {
              label: "onlyinclude",
              action: {
                type: 'encapsulate',
                options: {pre: "<onlyinclude>", post: "</onlyinclude>"}
              }
            }, {
              label: "nowiki",
              action: {
                type: 'encapsulate',
                options: {pre: "<nowiki>", post: "</nowiki>"}
              }
            }, {
              label: "comment",
              action: {
                type: 'encapsulate',
                options: {pre: "<!-- ", post: " -->"}
              }
            },{
              'label': "div.definition-inline",
              'action': {
                'type': 'encapsulate','options': {'pre': '<div class="definition-inline">\n; ','post': ' : description \n</div>'}
              }
            }, {
              label: "{{#arraymap:}} long",
              action: {
                type: 'encapsulate',
                options: {pre: "{{#arraymap: ", peri : '{{{field|}}}', post: "<!--\n-->|;<!-- sep\n-->|§<!-- assign temporary var\n-->|[[My property::§]] <!--output\n-->|&#32;•&#32;<!--output sep\n-->}}<!-- end arraymap \n-->"}
              }
            }, {
              label: "{{#arraymap:}}",
              action: {
                type: 'encapsulate',
                options: {pre: "{{#arraymap: ", peri : '{{{field|}}}', post: "|;|§|[[My property::§]] |&#32;•&#32;}}"}
              }
            }, {
              label: "{{#ask:table}}",
              action: {
                type: 'encapsulate',
                options: {pre: "{{#ask: ", peri : '[[PAGE]] [[property::+]]', post: " | ?displayprop |? | mainlabel=- | link=none | format = table | limit = 500}}"}
              }
            }, {
              label: "{{#ask:list}}",
              action: {
                type: 'encapsulate',
                options: {pre: "{{#ask: ", peri : '[[PAGE]] [[property::+]]', post: " | ?displayprop | mainlabel=- | link=none | format = list | sep=&#32;•&#32; | limit = 500}}"}
              }
            }, {
              label: "{{#vardefine:}}",
              action: {
                type: 'encapsulate',
                options: {pre: "{{#vardefine: ", peri : 'myVar', post: "| }}"}
              }
            }, {
              label: "{{#varexist:}}",
              action: {
                type: 'encapsulate',
                options: {pre: "{{#varexist: ", peri : 'myVar', post: "}}"}
              }
            }, {
              label: "{{#var:}}",
              action: {
                type: 'encapsulate',
                options: {pre: "{{#var: ", peri : 'myVar', post: "}}"}
              }
            }, {
              label: "if",
              action: {
                type: 'encapsulate',
                options: {pre: "{{#if: ", post: "| | }}"}
              }
            }, {
              label: "if long",
              action: {
                type: 'encapsulate',
                options: {pre: "<!--\n-->{{#if: ", post: "<!--\nthen-->|<!--\nelse-->|<!--\n-->}}<!-- end if\n-->"}
              }
            }, {
              label: "ifexist",
              action: {
                type: 'encapsulate',
                options: {pre: "{{#ifexist: ", post: "| | }}"}
              }
            }, {
              label: "ifexist long",
              action: {
                type: 'encapsulate',
                options: {pre: "<!--\n-->{{#ifexist: ", post: "<!--\nthen-->|<!--\nelse-->|<!--\n-->}}<!-- end ifexist\n-->"}
              }
            }, {
              label: "{{#expr:}}",
              action: {
                type: 'encapsulate',
                options: {pre: "{{#expr: ", peri : '1 + 6', post: "}}"}
              }
            }, {
              label: "switch",
              action: {
                type: 'encapsulate',
                options: {pre: "{{#switch: ", post: "<!--\n-->| one | two = <!--\n-->| #default = <!--\n-->}}<!-- end switch\n-->"}
              }
            }, {
              label: "{{DEFAULTSORT:}}",
              action: {
                type: 'encapsulate',
                options: {pre: "{{DEFAULTSORT:", post: "}}"}
              }
            }, {
              label: "{{DISPLAYTITLE:}}",
              action: {
                type: 'encapsulate',
                options: {pre: "{{DISPLAYTITLE:", post: "}}"}
              }
            },
            '{{PAGENAME}}',
            '{{PAGENAMEE}}',
            '{{FULLPAGENAME}}',
            '{{FULLPAGENAMEE}}'
          ]
        }
      }
    });
  }
  /* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar . . . */
  if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) {
        mw.loader.using( 'user.options', function () {
                if ( mw.user.options.get('usebetatoolbar') ) {
                        mw.loader.using( 'ext.wikiEditor.toolbar', function () {
                                $(document).ready( customizeToolbar );
                        } );
                }
        } );
  }
/* </pre> */