3 * This software is licensed under the MIT licence (as defined by the OSI at
4 * http://www.opensource.org/licenses/mit-license.php)
6 * ***************************************************************************
7 * Copyright (C) 2011 by Intel Corporation Ltd.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25 * DEALINGS IN THE SOFTWARE.
26 * ***************************************************************************
31 // Given an element, this widget collects all links contained in the descendants of the element and constructs
32 // a popupwindow widget containing numbered buttons for each encountered link.
34 // You can mark any one element in your document with "data-pagelist='true'" and a pagelist will be created that
35 // will allow the user to navigate between the pages linked to within the element.
37 // Currently, only one pagelist can exist in a document and, once created, it cannot be modified.
39 (function($, undefined) {
41 ensureNS("jQuery.mobile.tizen");
43 $.widget("tizen.pagelist", $.tizen.widgetex, {
46 pageList: "#pagelist",
47 button: "#pagelist-button",
48 rowBreak: "#pagelist-rowbreak"
56 this._ui.button.remove();
57 this._ui.rowBreak.remove();
61 .bind("vclick", function(e) {
62 $(this).popupwindow("close");
65 this.element.find("a[href]").each(function(elemIdx, elem) {
66 if (idx > 0 && !(idx % 10))
67 self._ui.pageList.append(self._ui.rowBreak.clone());
71 .attr("href", $(elem).attr("href"))
73 .appendTo(self._ui.pageList)
75 .bind("vclick", function() { self._ui.pageList.popupwindow("close"); })
76 .find(".ui-btn-inner")
80 $(document).bind("keydown", function(e) {
81 popPageList = (e.keyCode === $.mobile.keyCode.CONTROL);
83 $(document).bind("keyup", function(e) {
84 if (e.keyCode === $.mobile.keyCode.CONTROL && popPageList) {
85 var maxDim = {cx: 0, cy: 0};
86 self._ui.pageList.popupwindow("open", undefined, 0);
87 self._ui.pageList.find("a")
91 cx: btn.outerWidth(true),
92 cy: btn.outerHeight(true)
95 // Make sure things will be even later, because padding cannot have decimals - apparently :-S
96 if (dim.cx % 2) btn.css("padding-left", parseInt(btn.css("padding-left")) + 1);
97 if (dim.cy % 2) btn.css("padding-bottom", parseInt(btn.css("padding-bottom")) + 1);
99 maxDim.cx = Math.max(maxDim.cx, dim.cx);
100 maxDim.cy = Math.max(maxDim.cy, dim.cy);
104 h: Math.max(0, (maxDim.cx - $(this).outerWidth(true)) / 2),
105 v: Math.max(0, (maxDim.cy - $(this).outerHeight(true)) / 2)
108 inner = btn.find(".ui-btn-inner");
111 "padding-left" : parseInt(inner.css("padding-left")) + padding.h,
112 "padding-top" : parseInt(inner.css("padding-top")) + padding.v,
113 "padding-right" : parseInt(inner.css("padding-right")) + padding.h,
114 "padding-bottom" : parseInt(inner.css("padding-bottom")) + padding.v
116 btn[((btn.attr("href") === "#" + $.mobile.activePage.attr("id")) ? "addClass" : "removeClass")]("ui-btn-active");
126 // Look for an element marked as a pagelist and assign $.mobile.tizen.pagelist with a newly created pagelist.
127 // If $.mobile.tizen.pagelist is already assigned, ignore any new "data-pagelist='true'" designations.
128 $(document).bind("pagecreate create", function(e) {
129 $(":jqmData(pagelist='true')", e.target)
130 .not(":jqmData(role='none'), :jqmData(role='nojs')")
132 if ($.mobile.tizen.pagelist === undefined) {
133 $.extend($.mobile.tizen, {
134 pagelist: $(this).pagelist()