new Controller(model, view)
Parameters:
Name | Type | Description |
---|---|---|
model |
object | The Model instance |
view |
object | The View instance |
- Source:
Members
_activeRoute
Store a reference to the active route, allowing us to re-filter todo
items as they are marked complete or incomplete.
- Source:
Methods
_filter(force)
Re-filters the todo items, based on the active route.
Parameters:
Name | Type | Description |
---|---|---|
force |
boolean | undefined | Force item re-filtering |
- Source:
_updateCount()
Updates the pieces of the page which change depending on the remaining number of todos.
- Source:
_updateFilterState(currentPage)
Simply updates routes in url
Parameters:
Name | Type | Description |
---|---|---|
currentPage |
string | '' || active || completed. |
- Source:
addItem(title)
An event to fire whenever you want to add an item. Simply pass in the event
object and it'll handle the DOM insertion and saving of the new item.
Parameters:
Name | Type | Description |
---|---|---|
title |
string | The title of the item to add |
- Source:
editItem(id)
Triggers the item editing mode.
Parameters:
Name | Type | Description |
---|---|---|
id |
number | ID of the new model to edit. |
- Source:
editItemCancel(id)
Cancels the item editing mode of the element.
Parameters:
Name | Type | Description |
---|---|---|
id |
number | ID of the model being edited. |
- Source:
editItemSave(id, title)
Finishes the item editing mode successfully.
Parameters:
Name | Type | Description |
---|---|---|
id |
number | ID of the edited model to save |
title |
string | The content of the todo. |
- Source:
removeCompletedItems()
Will remove all completed items from the DOM and storage.
- Source:
removeItem(id)
Removes an item from the list : By giving it an ID it'll find the DOM element matching that ID,
remove it from the DOM and also remove it from storage.
Parameters:
Name | Type | Description |
---|---|---|
id |
number | The ID of the item to remove from the DOM and storage |
- Source:
setView(locationHash)
Loads and initialises the View
Parameters:
Name | Type | Description |
---|---|---|
locationHash |
string | The hash of the actual page can have these values : '' | 'active' | 'completed' |
- Source:
showActive()
Renders all active tasks with the parameter completed: false.
- Source:
showAll()
An event to fire on load. Will get all items and display them in the
todo-list
- Source:
showCompleted()
Renders all completed tasks with the parameter completed: true.
- Source:
toggleAll(checkbox)
Will toggle ALL checkboxes' on/off state and completeness of models (Just pass in the event object).
Parameters:
Name | Type | Description |
---|---|---|
checkbox |
object | The checkbox to validate the status of the element. |
- Source:
toggleComplete(id, checkbox, silent)
Updates the display of items based on their status wich depend from the checkbox state
Parameters:
Name | Type | Description |
---|---|---|
id |
number | The ID of the element to complete or uncomplete |
checkbox |
object | The checkbox to check the state of complete or not. |
silent |
boolean | undefined | Prevent re-filtering the todo items |
- Source: