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-type: type of nocontents. You can set text, picture, multimedia and unnamed.
34 * Deprecated in Tizen 2.0 beta : data-text1, data-text2
47 * <div data-role="nocontents" id="nocontents">
48 * <p> Unnamed Type </p>
54 * <div data-role="nocontents" id="nocontents" data-type="text"></div>
57 * <div data-role="nocontents" id="nocontents" data-type="picture"></div>
60 * <div data-role="nocontents" id="nocontents" data-type="multimedia"></div>
63 * <div data-role="nocontents" id="nocontents"></div>
65 * <div data-role="nocontents" id="nocontents" data-type="unnamed"></div>
69 (function ( $, window, undefined ) {
70 $.widget( "tizen.nocontents", $.mobile.widget, {
75 _get_height: function () {
76 var $page = $('.ui-page'),
77 $content = $page.children('.ui-content'),
78 $header = $page.children('.ui-header'),
79 $footer = $page.children('.ui-footer'),
80 $view = $content.children('.ui-scrollview-view'),
81 header_h = $header.outerHeight() || 0,
82 footer_h = $footer.outerHeight() || 0,
83 padding_t = (parseFloat( $content.css('padding-top') ) || 0) +
84 (parseFloat( $view.css('padding-top') ) || 0),
85 padding_b = (parseFloat( $content.css('padding-bottom') ) || 0) +
86 (parseFloat( $view.css('padding-bottom') ) || 0),
87 content_h = $( window ).height() - header_h - footer_h -
88 (padding_t + padding_b);
94 var content_height = this._get_height(),
95 icon_height = this.icon_img.height(),
96 icon_width = this.icon_img.width(),
103 if ( this.text_bg.length ) {
104 text_height = $( this.text_bg[0] ).height() * this.text_bg.length;
105 content_gap = $( this.text_bg[0] ).height();
108 icon_top = ( content_height - ( icon_height + content_gap + text_height ) ) / 2;
110 if ( icon_top < content_gap ) {
111 icon_top = content_gap;
114 this.icon_img.css( 'left',
115 ( $( window ).width() - icon_width ) / 2 );
116 this.icon_img.css( 'top', icon_top );
118 text_top = icon_top + icon_height + content_gap;
120 for ( i = 0; i < this.text_bg.length; i++ ) {
121 $( this.text_bg[i] ).css( 'top', text_top );
122 text_top += $( this.text_bg[i] ).height();
126 _create: function () {
127 var elem = this.element,
128 icon_type = $( this.element ).jqmData('type');
130 switch ( icon_type ) {
136 icon_type = "unnamed";
140 $( elem ).addClass( "ui-nocontents" );
141 this.icon_img = $('<div class="ui-nocontents-icon-' +
144 this.text_bg = $( elem ).find("p").addClass("ui-nocontents-text");
146 $( elem ).prepend( this.icon_img );
150 $( window ).bind( 'resize', function () {
151 $( elem ).nocontents( 'refresh' );
155 refresh: function () {
160 $( document ).bind( "pagecreate create", function ( e ) {
161 $( e.target ).find(":jqmData(role='nocontents')").nocontents();