2 * jQuery Mobile Widget @VERSION
4 * This software is licensed under the MIT licence (as defined by the OSI at
5 * http://www.opensource.org/licenses/mit-license.php)
7 * ***************************************************************************
8 * Copyright (C) 2011 by Intel Corporation Ltd.
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 * DEALINGS IN THE SOFTWARE.
27 * ***************************************************************************
29 * Authors: Elliot Smith <elliot.smith@intel.com>
32 // Horizontal/vertical box layout extension.
34 // This will arrange the child elements of a container in a horizontal
35 // or vertical row. This only makes sense if your container is a div
36 // and contains children which are also divs; the children should
37 // also have a height and width set in CSS, otherwise the layout
38 // manager won't know what to do with them.
40 // Apply it by setting data-layout="hbox" or data-layout="vbox" (vertical
41 // on a container element or calling $(element).layouthbox() or
42 // $(element).layoutvbox().
44 // Usually, you would use a div as the container to get the right effect
45 // (an element with display:block).
47 // Options can be set programmatically:
49 // $(element).layouthbox('option', 'scrollable', false)
50 // $(element).layoutvbox('option', 'scrollable', false)
52 // or via a data-layout-options attribute on the container:
54 // <div data-layout="hbox" data-layout-options='{"hgap":5}'>
59 // <div data-layout="vbox" data-layout-options='{"vgap":5}'>
64 // If you change any options after creating the widget, call
65 // $(element).layout*box('refresh') to have them picked up.
66 // However, note that it's currently not feasible to turn off scrolling
67 // once it's on (as calling scrollview('destroy') doesn't remove the
68 // scrollview custom mouse handlers).
70 // There is one major difference between the horizontal and
71 // vertical box layouts: if scrollable=false, the horizontal layout
72 // will clip children which overflow the edge of the parent container;
73 // by comparison, the vertical container will grow vertically to
74 // accommodate the height of its children. This mirrors the behaviour
75 // of jQuery Mobile, where elements only ever expand horizontally
76 // to fill the width of the window; but will expand vertically forever,
77 // unless the page height is artificially constrained.
81 // {Integer} hgap (default=0)
82 // Horizontal gap (in pixels) between the child elements. Only has
85 // {Integer} vgap (default=0)
86 // Vertical gap (in pixels) between the child elements. Only has
89 // {Boolean} scrollable (default=true; can only be set at create time)
90 // Set to true to enable a scrollview on the
91 // container. If false, children will be clipped if
92 // they fall outside the edges of the container after
95 // {Boolean} showScrollBars (default=true)
96 // Set to false to hide scrollbars on the container's scrollview.
97 // Has no effect is scrollable=false
99 (function ( $, undefined ) {
102 $.widget( "tizen.layouthbox", $.tizen.jlayoutadaptor, {
107 initSelector: ':jqmData(layout="hbox")'
110 _create: function () {
111 if ( !this.options.hgap ) {
112 this.options.hgap = 0;
115 $.tizen.jlayoutadaptor.prototype._create.apply( this, arguments );
119 $( document ).bind( "pagecreate", function ( e ) {
120 $( $.tizen.layouthbox.prototype.fixed.initSelector, e.target )
121 .not( ":jqmData(role='none'), :jqmData(role='nojs')" )
126 $.widget( "tizen.layoutvbox", $.tizen.jlayoutadaptor, {
131 initSelector: ':jqmData(layout="vbox")'
134 _create: function () {
135 if ( !this.options.vgap ) {
136 this.options.vgap = 0;
139 $.tizen.jlayoutadaptor.prototype._create.apply( this, arguments );
143 $( document ).bind( "pagecreate", function ( e ) {
144 $( $.tizen.layoutvbox.prototype.fixed.initSelector, e.target )
145 .not( ":jqmData(role='none'), :jqmData(role='nojs')" )