User:PerfektesChaos/js/editToolStrIns/Coding

Notes for developers.

noscript
By nature the script does not provide a non-JS approach. For users who have no access to JS or did not enable JS in their browser en:MediaWiki:Edittools supports a fallback solution.

JS variables

 * JS variables on global level abandoned.
 * is used to plug in an application object.

Postponed
For short response time GUI elements (menu) are built only when really visible. If created once, the particular menu is stored and will be reused.

WikEd

 * The first MW 1.18 implementation seems not to recognize currentFocused by .focus binding to wpTextbox1 while WikEd works on
 * wikEd.frameInner = document.getElementById('wikEdFrameInner')
 * By hack with bind and trigger this might be overcome for a while.
 * For co-operation with WikEd  should be considered.

enableForAllFields

 * en:MediaWiki:Edittools.js as of 2009 reads:
 * insertTags from the site-wide /skins-1.5/common/edit.js just inserts in the first textarea in the document. Evidently, that's not good if we have multiple textareas.
 * This has been overcome by MW 1.18 in mediawiki.action.edit.js – mw.toolbar.insertTags provides a currentFocused reference to either #wpSummary or #wpTextbox1.

Multiple textareas
The tool is expecting the class  where gadget and menu are established. It is assumed that this class has one member only.

Images
Glyphs not available in Unicode might be provided as miniatur images.

debug
For developing purposes a  subclass is introduced. It will log messages only when explicitly requested. Such code shall be removed from productive releases.

old
Known other edittools are removed from display.

spaces
Adjacent spaces in selection are changed with the inserted tags now, as WikEd does. This is a challenge for mw.toolbar.insertTags as of MW 1.18, which calls textSelection in jquery.textSelection module. In checkSelectedText the post and pre fields are computed and will be swapped.

style

 * Coding conventions were taken into account.
 * Some personal preferences are preserved.
 * Line length quite short.
 * Native indentaton is 3spc which can easily converted into tabs.
 * Human readability preferred against putting everything into one single line. The author produces several 1000 lines of code per month in many fields and languages and he is not able to read his own code after two weeks otherwise.
 * Any single function and additive property gets a separate timestamp and function documentation. Control structure end clauses are commented.

interface page
mw.messages.get might be used to configure and distribute pieces of code for localization in the future.

subdivision

 * HTML and CSS attributes
 * defines which and whether HTML or CSS
 * defines which and whether HTML or CSS


 * Development support, shall be removed from deployed copies
 * Development support, shall be removed from deployed copies


 * Definitions of menus, tokens and attributes
 * To be interpreted from configuation sources
 * To be interpreted from configuation sources


 * Overall GUI issues, selection device, container
 * Overall GUI issues, selection device, container


 * Localization definitions, mainly by local project
 * fallback
 * fallback


 * Particular menu with tokens and separators
 * Particular menu with tokens and separators


 * User definitions
 * User definitions


 * top
 * Top level functionality
 * API: