GithubHelp home page GithubHelp logo

jadjoubran / android-toast Goto Github PK

View Code? Open in Web Editor NEW
36.0 7.0 10.0 40 KB

An HTML5 replication of the Native Android Toast http://developer.android.com/guide/topics/ui/notifiers/toasts.html

License: Other

CSS 39.29% JavaScript 60.71%

android-toast's Introduction

Android-Toast

An HTML5 replication of the Native Android Toast http://developer.android.com/guide/topics/ui/notifiers/toasts.html

Demo: http://jadjoubran.github.io/Android-Toast/

Compatible with PhoneGap applications.

To use Android toast, simply include src/css/toast.css and src/js/toast.js to your project and call the android_toast javascript function (does not require jQuery or any external DOM manipulation library)

<script>
	var toast1 = new Android_Toast({content: 'Please check your connection and try again.'});
</script>

You can also customize the position and the duration:

<script>
	var toast2 = new Android_Toast({content: 'Connected to Wi-Fi network <em>Router Name</em>', duration: 4000, position: 'top'});
</script>

Installation

Package is available through bower:

bower install android-toast

Or you can simply include the dist/android_toast.min.js and dist/android_toast.min.css files in your document.

JavaScript API

The constructor function accepts 3 options:

content sets the text to be displayed. <em></em> text will be highlighted in blue.

duration accepts an integer. The toast will disappear after the set duration. Defaults to 3000 (milliseconds).

position Either top or bottom. Determines the position of the toast. Defaults to bottom.

License

Check the MIT-LICENSE.txt file

Contributors

http://www.eTobb.com 's first Open Source contribution.

Developed by Jad Joubran @JoubranJad

Other contributors:

Patsy Issa

android-toast's People

Contributors

jadjoubran avatar patsy-issa avatar scullwm avatar ushalnaidoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-toast's Issues

Toast div blocks clicking underneath

The toast_container div blocks clicks.

I have a submit button, on submit it creates a new toast. The placement of the div just happened to be above the submit button when it's invisible.

I found out that the toast div should be removed once the animation finishes, but this does not work in IE.
Add HTML5 event:
toast_container.addEventListener('animationend', function () {
toast_container.parentNode.removeChild(toast_container);
});

Mouse events interference

Hi!
I found your Android toast very nice and started to use it. I experienced that it seemed to interfere with mouse event listeners I am using. After some search and trial, it seems like adding this line to your CSS resolves the probelm:

pointer-events:none;

E.g.

#android_toast_container{
  width:100%;
  position:fixed;
  bottom:12%;
  left:0;
  pointer-events:none;
}

this.show is not a function

Hi, just wanted to add simple toast message to my mobile web app but this happens

screen shot 2016-08-28 at 11 53 39 am

just added css and js files and call :

var toast1 = Android_Toast({content: 'Localizado por GPS.'});

thanks

Use object as parameter

About the Toast code, I would recommend the use of literal object as parameters, easy to implement and much easer to code with.

in the Class you would find something like that :

function Android_Toast(){

this.timeout_id = null;
this.duration = 3000;
this.content = '';
this.position = 'bottom';
for (var n in arguments[0]) {
this[n] = arguments[0][n];
console.log(arguments[0][n]); // please remove me ;)
}

}

the call would look like that :

var toast = new Android_Toast({content: 'Hello Fries', duration: 5000});

This code is ready to use with the current version, but could be easily done with prototyping :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.