Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Fix for issue #363: Page loading error method #1158

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ FILES = js/jquery.ui.widget.js \
js/jquery.mobile.dialog.js \
js/jquery.mobile.navbar.js \
js/jquery.mobile.grid.js \
js/jquery.mobile.notification.js \
js/jquery.mobile.init.js

CSSFILES = themes/default/jquery.mobile.theme.css \
Expand Down
1 change: 1 addition & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
jquery.mobile.dialog.js,
jquery.mobile.navbar.js,
jquery.mobile.grid.js,
jquery.mobile.notification.js,
jquery.mobile.init.js
/>

Expand Down
1 change: 1 addition & 0 deletions js/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
'jquery.mobile.dialog.js',
'jquery.mobile.navbar.js',
'jquery.mobile.grid.js',
'jquery.mobile.notification.js',
'jquery.mobile.init.js'
);

Expand Down
70 changes: 70 additions & 0 deletions js/jquery.mobile.notification.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* jQuery Mobile Framework : Growl-like notification widget
* Copyright (c) jQuery Project
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*/
(function( $, undefined ) {

var $messageBox = null;

$.widget( "mobile.notification", $.mobile.widget, {
options: {
fadeDelay : 800,
text : ""
},

_create: function() {
var $el = this.element;

$el.addClass( "ui-loader ui-overlay-shadow ui-body-e ui-corner-all" );
$el.attr( "data-role", "message-box" );

this._text = $( "<h1></h1>" );
$el.append( this._text );

this.option( this.options );
},

_setOption: function( name, value ) {
if ( ( name in this.options ) && ( name in this ) )
this[name]( value );
},

fadeDelay: function( delay ) {
if ( delay === undefined )
return this.options.fadeDelay;
this.options.fadeDelay = delay;
},

text: function( text ) {
if ( text === undefined )
return this.options.text;

this._text.text( text );
this.options.text = text;
},

show: function() {
this.element.clearQueue();

this.element.css( { "display" : "block", "opacity" : 0.96, "top" : $(window).scrollTop() + 100 } )
.appendTo( $.mobile.pageContainer )
.delay( this.options.fadeDelay )
.fadeOut( 400, function(){ $(this).css( "display", "none" ); } );
}
});

$.mobile.messageBox = function( message, delay ) {
if ( $messageBox === null)
$messageBox = $( "<div></div>" );

// 800ms delay before fade out is default.
if ( delay === undefined )
delay = 800;

$messageBox.notification( { "text" : message, "fadeDelay" : delay } );
$messageBox.notification( "show" );
};

})(jQuery);
32 changes: 32 additions & 0 deletions tests/unit/notification/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>jQuery Mobile Page Test Suite</title>

<script type="text/javascript" src="../../../js/jquery.js"></script>
<script type="text/javascript" src="../../../js/"></script>
<script type="text/javascript" src="../../../tests/jquery.testHelper.js"></script>

<link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/>
<script type="text/javascript" src="../../../external/qunit.js"></script>

<script type="text/javascript" src="notification_core.js"></script>
</head>
<body>

<h1 id="qunit-header">jQuery Mobile Notification Test Suite</h1>
<h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests">
</ol>

<div id="qunit-fixture">
<div data-role="page">
<div data-role="content">
<p>Here goes some dummy content</p>
</div>
</div>
</div>
</body>
</html>
19 changes: 19 additions & 0 deletions tests/unit/notification/notification_core.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
(function($){
module("jquery.mobile.notification.js");

test( "messageBox appears and removes itself", function() {
same( $( "div[data-role='message-box']" ).length, 0, "no message box to begin with" );
$.mobile.messageBox( "Baba yetu" );
same( $( "div[data-role='message-box']" ).length, 1, "added one message box");
same( $( "div[data-role='message-box'] h1" ).text(), "Baba yetu", "message is correct" );
$.mobile.messageBox( "yetu uliye" );
same( $( "div[data-role='message-box']" ).length, 1, "no duplicate message boxes" );
same( $( "div[data-role='message-box'] h1" ).text(), "yetu uliye", "message is correct" );
stop();

setTimeout( function(){
same( $( "div[data-role='message-box']" ).css( "display" ), "none", "message box removed after 1.5s" );
start();
}, 1500);
});
})(jQuery);