1 /* ***************************************************************************
2 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
21 * ***************************************************************************
23 * Author: Minkyu Kang <mk7.kang@samsung.com>
31 * data-role: set to 'nocontents'.
32 * data-text1: top message.
33 * data-text2: bottom message.
34 * data-type: type of nocontents. You can set text, picture, multimedia and unnamed.
47 * <div data-role="nocontents" id="nocontents" data-text1="Text1" data-text2="Text2" data-type="text"></div>
50 * <div data-role="nocontents" id="nocontents" data-text1="Text1" data-text2="Text2" data-type="picture"></div>
53 * <div data-role="nocontents" id="nocontents" data-text1="Text1" data-text2="Text2" data-type="multimedia"></div>
56 * <div data-role="nocontents" id="nocontents" data-text1="Text1" data-text2="Text2"></div>
58 * <div data-role="nocontents" id="nocontents" data-text1="Text1" data-text2="Text2" data-type="unnamed"></div>
62 (function ( $, window, undefined ) {
63 $.widget( "tizen.nocontents", $.mobile.widget, {
71 _get_height: function () {
72 var $page = $('.ui-page'),
73 $content = $page.children('.ui-content'),
74 $header = $page.children('.ui-header'),
75 $footer = $page.children('.ui-footer'),
76 header_h = $header.outerHeight() || 0,
77 footer_h = $footer.outerHeight() || 0,
78 padding_t = parseFloat( $content.css('padding-top') ) || 0,
79 padding_b = parseFloat( $content.css('padding-bottom') ) || 0,
80 content_h = $(window).height() - header_h - footer_h -
81 (padding_t + padding_b) * 2,
82 container_h = this.container.height();
84 return ( content_h < container_h ? container_h : content_h );
88 var content_height = this._get_height(),
89 icon_height = this.icon_img.height(),
90 icon_width = this.icon_img.width(),
92 text0_height = this.text0_bg.height() || 0,
93 text1_height = this.text1_bg.height() || 0,
95 icon_top = (content_height -
96 (icon_height + content_gap +
97 text0_height + text1_height)) / 2;
99 if ( icon_top < content_gap ) {
100 icon_top = content_gap;
103 this.container.height( content_height );
105 this.icon_img.css( 'left',
106 ($(window).width() - icon_width) / 2 );
107 this.icon_img.css( 'top', icon_top );
109 text_top = icon_top + icon_height + content_gap;
111 this.text0_bg.css( 'top', text_top );
112 this.text1_bg.css( 'top', text_top + text0_height );
115 _create: function () {
116 var icon_type = $( this.element ).jqmData('type'),
119 if ( icon_type === undefined ||
120 (icon_type !== "picture" &&
121 icon_type !== "multimedia" &&
122 icon_type !== "text") ) {
123 icon_type = "unnamed";
126 text[0] = $( this.element ).jqmData('text1');
127 text[1] = $( this.element ).jqmData('text2');
129 if ( text[0] === undefined ) {
133 if ( text[1] === undefined ) {
137 this.container = $('<div class="ui-nocontents"/>');
138 this.icon_img = $('<div class="ui-nocontents-icon-' +
141 this.text0_bg = $('<div class="ui-nocontents-text">' +
143 this.text1_bg = $('<div class="ui-nocontents-text">' +
146 this.container.append( this.icon_img );
147 this.container.append( this.text0_bg );
148 this.container.append( this.text1_bg );
150 $( this.element ).append( this.container );
156 $( document ).bind( "pagecreate create", function ( e ) {
157 $( e.target ).find(":jqmData(role='nocontents')").nocontents();