It's better when it's simple

User Tools

Site Tools


JavaScript Refactoring and Cleanup

The current JavaScript needs some refactoring to make optimal use of jQuery and remove/deprecate old cruft.

Coding Guidelines for Refactoring

  • Don't use anonymous wrappers the map jQuery() to $()
  • Always use jQuery(), $() is still our old protoype.js-stolen version
  • Try to wrap functionality into named objects for
    • namespacing
    • easy access for modifications by plugins
  • prefix objects with dw_
  • mark deprecated stuff with the DEPRECATED() function
  • move compatibility wrappers to compatibility.js
  • prefix variables holding a jQuery instance with $

Old Functions and Classes

Below is an overview of scripts and functions that still need to have a look at.

  • cookie.js
    • object DokuCookie
    • It makes use of a JQuery plugin, do we really need that jquery plugin? Or maybe we can only use that plugin?
  • delay.js
    • object timer
    • object Delay
    • probably not really needed because window.timeout can call callbacks
  • edit.js
    • function createToolButton(icon,label,key,id,classname)
    • function createPicker(id,props,edid)
    • function pickerInsert(text,edid)
    • function addBtnActionSignature(btn, props, edid)
    • function keyHandler(e)
    • function currentHeadlineLevel(textboxId)
    • function deleteDraft()
    • function summaryCheck()
  • hotkeys.js
    • object hotkeys
  • script.js
    • there is some global stuff left that should be moved
  • textselection.js
    • object select_class
    • function selection_class()
    • function getSelection(textArea)
    • function setSelection(selection)
    • function pasteText(selection,text,opts)
    • function insertTags(textAreaID, tagOpen, tagClose, sampleText)
    • function insertAtCarret(textAreaID, text)
  • toolbar.js
    • function initToolbar(tbid,edid,tb, allowblock)
    • function tb_format(btn, props, edid)
    • function tb_formatln(btn, props, edid)
    • function tb_insert(btn, props, edid)
    • function tb_mediapopup(btn, props, edid)
    • function tb_autohead(btn, props, edid)
    • function addBtnActionPicker(btn, props, edid)
    • function addBtnActionLinkwiz(btn, props, edid)
    • function pickerToggle(pickerid,btn)
    • function pickerClose()
    • function fixtxt(str)
devel/jsrefactor.txt · Last modified: 2011-08-19 16:16 by andi

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