Giter VIP home page Giter VIP logo

jquery-titlealert's Introduction

jquery-titlealert

Flashes the page title with a custom message.

Example usage

$.titleAlert("Hello World!", {
    requireBlur:true,
    stopOnFocus:true,
    duration:10000,
    interval:500
});

Flash title bar with text "Hello World!", if the window doesn't have focus, for 10 seconds or until window gets focused, with an interval of 500ms

Parameters and Options

jQuery.titleAlert(message, options)
message A string the message that should be flashed in the browser title.
options JavaScript object containing options
name default description
interval 500 The flashing interval in milliseconds.
originalTitleInterval null Time in milliseconds that the original title is diplayed for. If null the time is the same as interval.
duration 0 The total lenght of the flashing before it is automatically stopped. Zero means infinite.
stopOnFocus true If true, the flashing will stop when the window gets focus.
stopOnMouseMove false If true, the flashing will stop when the document recieves a mousemove event (i.e. when the user moves the mouse over the document area, regardless of what window is active).
requireBlur false Experimental. If true, the call will be ignored unless the window is out of focus. Known issues: Firefox doesn't recognize tab switching as blur, and there are some minor IE problems as well.

License

MIT License

jquery-titlealert's People

Contributors

cgbystrom avatar fayozjon avatar heyman 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  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  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

jquery-titlealert's Issues

Rewrite without jQuery

Hi! You wrote a great tool that I use in many projects. Now many companies are abandoning the use of heavy jQuery in favor of modern solutions. Maybe it's time to get rid of jQuery dependency and rewrite the plugin on pure Javascript?

BUG: Original title can be lost if stopOnMouseMove is active

Hi,

When stopOnMouseMove setting is active, the binded event is:
$(this).unbind(event);
$.titleAlert.stop();
Since it does not check whether a titleAlert is active, if a titleAlert is already stopped through another event (such as focus) before a mouseMove, the mouseMove event cause a successive call of the stop function. Which runs:
document.title = $.titleAlert._initialText;
Since a stop function is already called before the mouseMove, $.titleAlert._initialText is null. Hence, after the mouseMove the document.title is set to null.

In order to reproduce this, just start a titleAlert (with stopOnMouseMove setting) when the window is blurred. Then focus to the window, this will stop the titleAlert. Wait a little. Then move the mouse, this will set the document.title to null.

A possible solution might be to add a check to the beginning of the stop function:
$.titleAlert.stop = function() {
if(!$.titleAlert._running)
return;

This seems solved the problem but i am not sure if it breaks something. I believe the check should be done in the stop function (not in the mouseMove event), since stop function should not do anything if there are no titleAlert instances running.

Thanks.

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.