A jQuery Mobile Android-like Toast Plugin.
Download the production version or the development version.
In your web page:
<script src="jquery.js"></script>
<script src="jquery.mobile.js"></script>
<script src="jquery.mobile.toast.js"></script>
<script>
$.mobile.toast({
message: 'Live long and prosper!'
});
</script>
A toast provides simple feedback about an operation in a small popup. It only fills the amount of space required for the message and the current activity remains visible and interactive. - Android Developer
Run npm install
to install dependencies. Run grunt
to minify, test and generate documentation.
Type: String
Default: ``
The message of the toast.
Example:
$.mobile.toast({ message: 'Live long and prosper' });
// Change default value
$.mobile.toast.prototype.options.message = 'Live long and prosper';
Type: Number or String
Default: 2000
Duration of message show to the user. Possible values: "short", "long" number in milliseconds.
Example:
$.mobile.toast({
message: 'Live long and prosper',
duration: 2000
});
// Change default value
$.mobile.toast.prototype.options.duration = 2000;
Type: Number or String
Default: 80
Position of message. Possible values: "top", "center", "bottom" or number in percent.
Example:
$.mobile.toast({
message: 'Live long and prosper',
position: 80
});
// Change default value
$.mobile.toast.prototype.options.position = 80;
Type: String
Default: ""
Optional class to overwrite styling of toast on open.
Example:
$.mobile.toast({
message: 'Live long and prosper',
classOnOpen: 'pomegranate'
});
// Change default value
$.mobile.toast.prototype.options.classOnOpen = 'pomegranate';
Type: String
Default: ""
Optional class to overwrite styling of toast on close.
Example:
$.mobile.toast({
message: 'Live long and prosper',
classOnClose: 'pomegranate'
});
// Change default value
$.mobile.toast.prototype.options.classOnClose = 'pomegranate';
Default toast.
Javascript:
$.mobile.toast({
message: 'Live long and prosper!'
});
Toast with a 3000ms duration, default is 2000ms.
Javascript:
$.mobile.toast({
message: 'Live long and prosper!',
duration: 'long'
});
Toast with additional class to customize.
CSS:
.pomegranate {
/* OVERWRITES */
background-color: #E74C3C !important;
-webkit-border-radius: 2px !important;
border-radius: 2px !important;
/* CUSTOM */
box-shadow: 0 2px #C0392B;
}
.pomegranate p {
/* OVERWRITES */
/*max-width: 160px !important;*/
/*margin: 0 !important;*/
/*padding: 6px 12px !important;*/
padding-left: 28px !important;
/*font-size: 14px !important;*/
/*color: #FFFFFF !important;*/
/*text-shadow:none !important;*/
/*border: none !important;*/
/* CUSTOM */
background-image: url('heart.png');
background-repeat: no-repeat;
background-position: 6px 8px;
background-size: 16px;
}
Javascript:
$.mobile.toast({
message: 'Live long and prosper!',
classOnOpen: 'pomegranate'
});
Javascript:
$.mobile.toast({
message: 'Live long and prosper!',
afterclose: function( event, ui ){
alert('Toast after closed!');
},
afteropen: function( event, ui ){
alert('Toast after opened!');
},
beforeclose: function( event, ui ){
alert('Toast before closed!');
},
beforeposition: function( event, ui ){
alert('Toast before positioned!');
},
create: function( event, ui ){
alert('Toast created!');
}
});
Javascript:
$.mobile.toast({
message: 'Live long and prosper!',
classOnOpen: 'animated bounceInUp'
});
Javascript:
$.mobile.toast({
message: 'Live long and prosper!',
classOnOpen: 'animated slideInLeft',
classOnClose: 'slideOutRight'
});
- Fixes #6
- option
duration
with text version "short" (2000 ms) or "long" (3500ms)
- base widget ($.mobile.widget) removed, deprecated as of jQuery Mobile 1.4 and will be removed in 1.5
- update demo to jQuery Mobile 1.4
- add new custom theme "KitKat"
- increase font size
- update demo to jQuery Mobile 1.4.0 beta.1
- Tests added