TK.Pager

new Pager(options)

TK.Pager, also known as Notebook in other UI toolkits, provides multiple containers for displaying contents which are switchable via a TK.ButtonArray.

Parameters:
Name Type Description
options Object
Properties:
Name Type Attributes Default Description
options.position integer <optional>
"top"

The position of the ButtonArray

options.pages Array <optional>
[]

An array of mappings (objects) containing the members "label" and "content". "label" is a string for the buttons label or an object containing options for a button and content is either a HTML string or a HTMLElement node.

options.show integer <optional>
-1

The page to show

options.overlap boolean <optional>
false

If false, pages are automatically resized so that the TK.ButtonArray does not overlap the page contents.

Source:
Example
var pager = new TK.Pager({
 pages: [
  {
    label: "Empty Page 1",
    content: document.createElement("span")
  },
  {
    label: { label:"Foobar", class:"foobar" },
    content: "<h1>Foobar</h1><p>Lorem ipsum dolor sit amet</p>"
  }
 ]
});

Extends

Members

_buttonarray_wrapper :HTMLDivElement

An internal container for layout purposes containing the #TK.ButtonArray. Has classes toolkit-buttonarray-wrapper and toolkit-wrapper.

Source:

_clip :HTMLDivElement

The clipping area containing the pages. Has class toolkit-clip.

Source:

_clip :HTMLDivElement

The clipping of the pages. Has class toolkit-clip.

Source:

_container_wrapper :HTMLDivElement

An internal container for layout purposes containing the _clip element. Has classes toolkit-wrapper and toolkit-container-wrapper.

Source:

buttonarray

The TK.ButtonArray instance acting as the menu.

Source:

element

The main DIV element. Has the class toolkit-pager.

Overrides:
Source:

Methods

add_page(button, content, options, position)

Adds a TK.Container to the pager and a TK.Button to the pagers TK.ButtonArray.

Parameters:
Name Type Description
button string | Object

A string with the TK.Button s label or an object cotaining options for the Button

content TK.Widget | Class | string

The content of the page. Either a TK.Container (or derivate) widget, a class (needs option "options" to be set) or a string which get embedded in a new TK.Container

options Object

An object containing options for the TK.Container to add as a page

position integer | undefined

The position to add the new page to. If undefined, the page is added at the end.

Source:
Fires:

add_pages(options)

Adds an array of pages.

Parameters:
Name Type Description
options Array

An Array containing objects with options for the page and its button. Members are a string label for the corresponding button and content, which can be either a DOM node, a HTML string or a TK.Container widget.

Source:
Example
var p = new TK.Pager();
p.add_pages([
  {
    label: "Page 1",
    content: "<h1>Page1</h1>",
  }
]);

current()

Returns the currently displayed page or null.

Source:

first()

Opens the first page of the pager. Returns true if a first page exists, false otherwise.

Source:

last()

Opens the last page of the pager. Returns true if a last page exists, false otherwise.

Source:

next()

Opens the next page of the pager. Returns true if a next page exists, false otherwise.

Source:

prev()

Opens the previous page of the pager. Returns true if a previous page exists, false otherwise.

Source:

remove_page(page)

Removes a page from the TK.Pager.

Parameters:
Name Type Description
page integer | TK.Container

The container to remove. Either a position or the TK.Container widget generated by add_page.

Source:
Fires:

Methods inherited from TK.Container

append_child(child)

Appends child.element to the container element and registers child as a child widget.

append_children(children)

Calls TK.Container#append_child for an array of widgets.

force_hide()

Immediately switches the display state of this container to hide. Unlike TK.Container#hide this method does not perform the hiding transition and immediately modifies the DOM by setting the toolkit-hide class.

force_show()

Immediately switches the display state of this container to show. Unlike TK.Container#hide this method does not perform the hiding transition and immediately modifies the DOM by setting the toolkit-show class.

hide()

Starts the transition of the display_state to hide.

hide_child(child)

Switches the hidden state of a child to hidden. The argument is either the child index or the child itself.

show()

Starts the transition of the display_state to show.

show_child(child)

Switches the hidden state of a child to shown. The argument is either the child index or the child itself.

toggle_child(child)

Toggles the hidden state of a child. The argument is either the child index or the child itself.

Methods inherited from TK.Widget

add_child(child)

Registers a widget as a child widget. This method is used to build up the widget tree. It does not modify the DOM tree.

add_children(a)

Registers an array of widgets as children.

all_children()

Returns an array of all children.

enable_draw()

Schedules this widget for drawing.

get_style()

Returns the computed style of this widgets DOM element.

hidden()

Returns the current hidden status.

remove_child(child)

Removes a child widget. Note that this method only modifies the widget tree and does not change the DOM.

remove_children(a)

Removes an array of children.

set(key, value)

Sets an option.

set_style()

Sets a CSS style property in this widgets DOM element.

toggle_hidden()

TK.Toggle the hidden status. This is equivalent to calling hide() or show(), depending on the current hidden status of this widget.

visible_children()

Returns an array of all visible children.

widgetize()

Set the DOM elements of this widgets. This method is usually only used internally. Basically it means to add the id from options and set a basic CSS class. If delegate is true, basic events will be delegated from the element to the widget instance if classify is true, CSS functions will be bound to the widget instance.

Methods inherited from TK.Base

add_event(event, func, prevent, stop)

Register an event handler.

add_events(events, func)

Add multiple event handlers at once, either as dedicated event handlers or a list of event descriptors with a single handler function.

delegate_events(element) → {HTMLElement}

Delegates all occuring DOM events of a specific DOM node to the widget. This way the widget fires e.g. a click event if someone clicks on the given DOM node.

destroy()

Destroys all event handlers and the options object.

fire_event(event, …args)

Fires an event.

fire_events(events)

Fires several events.

get(key)

Get the value of an option.

has_event_listeners(event) → {boolean}

Test if the event descriptor has some handler functions in the queue.

remove_event(event, func)

Removes the given function from the event queue. If it is a native DOM event, it removes the DOM event listener as well.

remove_events(events, func)

Remove multiple event handlers at once, either as dedicated event handlers or a list of event descriptors with a single handler function.

set_options(optionsopt)

Merges a new options object into the existing one including deep copies of objects. If an option key begins with the string "on" it is considered as event handler. In this case the value should be the handler function for the event with the corresponding name without the first "on" characters.

Events

added

A page was added to the TK.Pager.

Parameters:
Name Type Description
page TK.Container

The TK.Container which was added as a page.

Source:

changed

The page was switched.

Parameters:
Name Type Description
page TK.Container

The TK.Container instance of the newly selected page.

id number

The ID of the page.

Source:

removed

A page was removed from the Pager

Parameters:
Name Type Description
page TK.Container

The TK.Container which was removed.

Source:

useraction

The useraction event is emitted when a widget gets modified by user interaction. The event is emitted for the option show.

Parameters:
Name Type Description
name string

The name of the option which was changed due to the users action

value mixed

The new value of the option

Source:

Events inherited from TK.Container

hide

Is fired when the container is hidden.

show

Is fired when the container is shown.

Events inherited from TK.Widget

classified

Is fired when a widget is classified.

destroy

Is fired when a widget is destroyed.

initialized

Is fired when a widget is initialized.

redraw

Is fired when a redraw is executed.

resize

The resize event is emitted whenever a widget is being resized. This event can be used to e.g. measure its new size. Note that some widgets do internal adjustments after the resize event. If that is relevant, the TK.Widget#resized event can be used, instead.

resized

The resized event is emitted after each rendering frame, which was triggered by a resize event.

set

The set event is emitted when an option was set using the TK.Widget#set method. The arguments are the option name and its new value.

Note that this happens both for user interaction and programmatical option changes.

stylized

Is fired when a widget is stylized.

widgetize

Is fired when a widget is widgetized.

Events inherited from TK.Base

delegated

Is fired when an element is delegated.

set_[option]

Is fired when an option is set.