View - dennisvintherjensen/OpenClassrooms-FED-Enhance-an-existing-project GitHub Wiki
Description
Presents the data and enables users to modify it - filtering, adding, deleting, etc.
Properties
template
: Instance of the template classENTER_KEY
: Number that references the Enter keyESCAPE_KEY
: Number that references the Escape key$todoList
: Element object$todoItemCounter
: Element object$clearCompleted
: Element object$main
: Element object$footer
: Element object$toggleAll
: Element object$newTodo
: Element object
Constructor
View(template)
: Creates a new View and defines required properties
Parameters
{object} template
: Instance of the template class
Methods
_removeItem(id)
: Removes a task from the list
Parameters
{number} id
: Id of the item that should be removed
_clearCompletedButton(completedCount, visible)
: Displays the "Clear completed" link in the footer if any tasks has been marked as completed.
Parameters
{number} completedCount
: Amount of completed tasks{boolean} visible
: Whether or not to display the button
_setFilter(currentPage)
: Updates the filters in the footer, highlighting the one currently selected.
Parameters
{string} currentPage
: The current location hash
_elementComplete(id, completed)
: Displays a task as completed
Parameters
{number} id
: Id of the task{boolean} completed
: Whether or not the task is completed
_editItem(id, title)
: Display the task title in an input field, allowing for it to be changed
Parameters
{number} id
: The id of the task{string} title
: The title of the task
_editItemDone(id, title)
: Remove the input field from a task being edited and displays the title
Parameters
{number} id
: The id of the task{string} title
: The title of the task
render(viewCmd, parameters)
: Renders a view by handling access to private functions
Parameters
{string} viewCmd
: Name of the command to run{object|string|number
Parameters for the command to run
_itemId(element)
: Returns the id of the given element
Parameters
{Element} element
: The element from which the id is requested
Returns
number
: The id of the element provided
_bindItemEditDone(handler)
: Bind a handler that will be run when a task has been edited.
Parameters
{function} handler
: The function to run when the task has been edited
_bindItemEditCancel(handler)
: Bind a handler that will be run when a task editing is cancelled
Parameters
{function} handler
: The function to run when the task editing has been cancelled
bind(event, handler)
: Bind a handler to a view event
Parameters
{string} event
: Name of the event{function} handler
: The function to run when the event occurs