Skip to main content

ViewUtils

Import :

const ViewUtils = brackets.getModule("utils/ViewUtils")

addScrollerShadow(displayElement, scrollElement, showBottom)

Installs event handlers for updatng shadow background elements to indicate vertical scrolling.

Kind: global function

ParamTypeDescription
displayElementDOMElementthe DOMElement that displays the shadow. Must fire "contentChanged" events when the element is resized or repositioned.
scrollElementObjectthe object that is scrolled. Must fire "scroll" events when the element is scrolled. If null, the displayElement is used.
showBottombooleanoptionally show the bottom shadow

removeScrollerShadow(displayElement, scrollElement)

Remove scroller-shadow effect.

Kind: global function

ParamTypeDescription
displayElementDOMElementthe DOMElement that displays the shadow
scrollElementObjectthe object that is scrolled

toggleClass($domElement, className, addClass)

Utility function to replace jQuery.toggleClass when used with the second argument, which needs to be a true boolean for jQuery

Kind: global function

ParamTypeDescription
$domElementjQueryObjectThe jQueryObject to toggle the Class on
classNamestringClass name or names (separated by spaces) to toggle
addClassbooleanA truthy value to add the class and a falsy value to remove the class

sidebarList(scrollElement, selectedClassName)

Within a scrolling DOMElement, creates and positions a styled selection div to align a single selected list item from a ul list element.

Assumptions:

  • scrollerElement is a child of the #sidebar div
  • ul list element fires a "selectionChanged" event after the selectedClassName is assigned to a new list item

Kind: global function

ParamTypeDescription
scrollElementDOMElementA DOMElement containing a ul list element
selectedClassNamestringA CSS class name on at most one list item in the contained list

getElementClipSize($view, elementRect) ⇒ Object

Determine how much of an element rect is clipped in view.

Kind: global function
Returns: Object - amount element rect is clipped in each direction

ParamTypeDescription
$viewDOMElementA jQuery scrolling container
elementRectObjectrectangle of element's default position/size

scrollElementIntoView($view, $element, scrollHorizontal)

Within a scrolling DOMElement, if necessary, scroll element into viewport.

To Perform the minimum amount of scrolling necessary, cases should be handled as follows:

  • element already completely in view : no scrolling
  • element above viewport : scroll view so element is at top
  • element left of viewport : scroll view so element is at left
  • element below viewport : scroll view so element is at bottom
  • element right of viewport : scroll view so element is at right

Assumptions:

  • $view is a scrolling container

Kind: global function

ParamTypeDescription
$viewDOMElementA jQuery scrolling container
$elementDOMElementA jQuery element
scrollHorizontalbooleanwhether to also scroll horizontally

getFileEntryDisplay(entry) ⇒ string

HTML formats a file entry name for display in the sidebar.

Kind: global function
Returns: string - HTML formatted string

ParamTypeDescription
entryFileFile entry to display

getDirNamesForDuplicateFiles(files) ⇒ Array.<string>

Determine the minimum directory path to distinguish duplicate file names for each file in list.

Kind: global function
Returns: Array.<string> - directory paths to match list of files

ParamTypeDescription
filesArray.<File>list of Files with the same filename

hideMainToolBar()

Hides the main toolbar

Kind: global function

showMainToolBar()

Shows the main toolbar

Kind: global function