npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jquery-plainoverlay

v1.0.1

Published

The simple jQuery Plugin for customizable overlay which covers a page, elements or iframe-windows that is specified.

Downloads

1,659

Readme

jQuery-plainOverlay

npm GitHub issues David license

Recommend: PlainOverlay instead of "jQuery-plainOverlay"
No dependency, Modern browsers supported, Lightweight & Single file, and more features


The simple jQuery Plugin for customizable overlay which covers a page, the elements or the iframe-windows that is specified. jQuery-plainOverlay has basic functions only, and it has no image files and no CSS files. Just one small file.

See DEMO

This is used for making the users wait until the your application is ready.
The elements under the overlay don't accept access via mouse or keyboard. And the scrollable elements (e.g. <body>, <div style="overflow:scroll"> or <iframe>) which are specified can't scroll.

The your progress-element (messages or images that means "Please wait...") can be shown to the users on the overlay. You can free style it to perfect match for your web site. Or jQuery-plainOverlay has a simple builtin progress-element.

jQuery-plainOverlay does:

  • Covering a page, the elements or the iframe-windows that is specified with the overlay.
  • Avoiding focusing the elements under the overlay. (by pressing Tab key)
  • Avoiding scrolling a page, the elements or the iframe-windows that is specified.
// Cover an element with overlay.
$('#post-form').plainOverlay('show');
// Hide overlay.
$('#post-form').plainOverlay('hide');

// Cover all of a page.
$('body').plainOverlay('show'); // Or, $(document), $(window)

Getting Started

Load after jQuery.

<script src="jquery-1.11.0.min.js"></script>
<script src="jquery.plainoverlay.min.js"></script>

Methods

show

element = element.plainOverlay('show'[, options])

Cover the specified element with the overlay. This element may be <body>, <iframe> or a box-element like <div>. $(document) and $(window) are same as $('body').
If options (see Options) is specified, the element is initialized with specified options before the overlay is shown. If the element is not initialized yet, it is initialized even if options is not specified (with the default options).
The element can be initialized by new options any number of times.

hide

element = element.plainOverlay('hide'[, ignoreComplete])

Hide the overlay.

By default, behavior restrictions of the element (e.g. scrolling) are removed after the fading effect took options.duration to complete. (i.e. after the overlay was hidden completely.)
If true is specified to ignoreComplete, the restrictions are removed when hide method is called, and plainoverlayhide event is triggered.
For example, this is used to do something about the element (e.g. changing scroll position) while the overlay is shown.

Initialize

element = element.plainOverlay([options])

Initialize the specified element. (preparation the overlay)
The show method too, can initialize. This is used to initialize without showing the overlay at voluntary time.
You can specify options to every show method. But, if options of an element isn't changed, re-initializing it isn't needed. Then, you specify options to only first show method, or use this method for initializing it only once.
If you don't customize any options (using default all), this method isn't needed because options isn't specified to show method, and the element is initialized at only first time.

In this code, it is initialized meaninglessly again, again, and again:

$('#show-button').click(function() {
  // Same initializing per every showing
  $('#list').plainOverlay('show', {duration: 500});
});

In this code, it is initialized at once:

// Initialize without showing
var list = $('#list').plainOverlay({duration: 500});
$('#show-button').click(function() {
  // Show without initializing
  list.plainOverlay('show');
});

In this code, it is initialized at once:

$('#show-button').click(function() {
  // Initialize at only first time
  list.plainOverlay('show');
});

option

currentValue = element.plainOverlay('option', optionName[, newValue])

Return the current option value (see Options) as optionName. If newValue is specified, it is set before returning.

NOTE: The current version of the jQuery-plainOverlay can change option value of duration and opacity options. Use Initialize method to update option value of others.

scrollLeft, scrollTop

element = element.plainOverlay('scrollLeft', scrollLen)
element = element.plainOverlay('scrollTop', scrollLen)

jQuery-plainOverlay avoid scrolling the element. These methods are used instead of element.scrollLeft and element.scrollTop methods to scroll the element while the overlay is shown.

For example:

$('body').plainOverlay('show', {
  show: function(event) {
    // Now, the overlay is shown. The user can't scroll the page.
    // Do something...
    // Scroll the page to show something.
    $('body').plainOverlay('scrollLeft', 100).plainOverlay('scrollTop', 400)
      // And hide the overlay.
      .plainOverlay('hide');
  }
});

Options

An options Object can be specified to show or Initialize method. It can have following properties.

duration

Type: Number
Default: 200

A number determining how long (milliseconds) the effect animation for showing and hiding the overlay will run.

fillColor

Type: String
Default: '#888'

A fill-color of the overlay.

$('#list').plainOverlay({fillColor: 'red'});

color is an alias for fillColor.

opacity

Type: Number
Default: 0.6

A number in the range 0.0 (invisible) to 1.0 (solid).

$('#list').plainOverlay({opacity: 0.3});

If you want to style the overlay more, add style to plainoverlay class.

.plainoverlay {
  background-image: url('bg.png');
}

progress

Type: Function or Boolean
Default: Builtin Element

The jQuery-Element that is returned by specified Function is shown to the users as the progress-element on the overlay. This is usually the messages or images that means "Please wait...".
If false is specified, nothing is shown on the overlay.
The builtin element (default) is shown via CSS Animations in modern browsers (e.g. Firefox, Chrome, etc.), and it is shown via simple effect in legacy browsers (IE9, IE8, etc.). This choice is automatic.

$('#list').plainOverlay({
  progress: function() { return $('<div>I am busy...</div>'); }
});

Of course your image files, some CSS codes which are distributed free in the internet, or any elements can be used. (e.g. SVG Animations jxnblk/loading)

If you want to change the color of shapes in the builtin progress-element, use CSS below.

/* Change to red */
.jQuery-plainOverlay-progress {
  border-color: red !important;
}
.jQuery-plainOverlay-progress-legacy div {
  background-color: red !important;
}

zIndex

Type: Number
Default: 9000

A z-index CSS property of the overlay.

show, hide

Type: Function
Default: undefined

The plainoverlayshow and plainoverlayhide event handlers. This is convenient way to do on(type, handler) method. (see Events)

$('#form1').plainOverlay({show: function(event) { console.log(event); } });

NOTE: If this option is specified in the show method, declared Function or the variable the Function is assigned should be specified (Don't specify the function expression). Because the show method may be called again, and the function expression generates the new Function every time.
The "function statement" and the "function operator" are different.
See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions#Defining_functions
For example, this code is OK:

function handler(event) { console.log(event); }
$('#show-button').click(function() {
  $('#form1').plainOverlay('show', {show: handler});
});

This code registers event handler repeatedly when the show method is called:

$('#show-button').click(function() {
  $('#form1').plainOverlay('show', {show: function(event) { console.log(event); } });
});

Events

plainoverlayshow

Triggered when the overlay is shown. (after the fading effect took options.duration to complete.)
An event handler can be attached when initializing via options.show as well.

$('#form1').on('plainoverlayshow', function(event) {
  $('#loading', event.target).text(size + ' Bytes Downloading');
});

plainoverlayhide

Triggered when the overlay is hidden.
By default, it is triggered after the fading effect took options.duration to complete. If hide method is called with ignoreComplete argument, it is triggered when hide method is called.
An event handler can be attached when initializing via options.hide as well.

$('#form1').on('plainoverlayhide', function(event) {
  $('#complete-message').show();
});

Note

  • If target is <iframe> element, jQuery 1.10.3+ or 2.0.4+ must be used. (see #14180: focusin/out special events don't work cross-window)
  • As everyone knows, IE8- has many problems. CSS position:fixed in HTML without <!DOCTYPE> is ignored.
    If your web site supports IE8- and it use position:fixed, HTML must include <!DOCTYPE> even if jQuery-plainOverlay is not used. And jQuery-plainOverlay uses position:fixed.
  • plainoverlayshow and plainoverlayhide events bubble up the DOM hierarchy.

See Also

  • PlainOverlay : The simple library for customizable overlay which covers all or part of a web page.
  • PlainModal : The simple library for fully customizable modal window in a web page.