Code Monkey home page Code Monkey logo

bootstrap-waitingfor's Introduction

bootstrap-waitingfor

"Waiting for..." modal dialog with progress bar for Bootstrap.

See this plugin in action:rocket:: http://bootsnipp.com/snippets/featured/quotwaiting-forquot-modal-dialog

Features

  • AMD-compatible
  • Configurable

Installing

With bower

You can install this module with bower bower install bootstrap-waitingfor and include the files from build directory.

With npm

You can install this module with npm npm install --save bootstrap-waitingfor and include it as shown:

const waitingDialog = require('bootstrap-waitingfor');

Using

In your javascript code write something like this:

waitingDialog.show('I\'m waiting');
setTimeout(function () {
  waitingDialog.hide();
}, 1000);

If you want to change the appearance of the modal, you can pass additional options:

waitingDialog.show('I\'m waiting', {
  dialogSize: 'm',
  progressType: 'success'
});
setTimeout(function () {
  waitingDialog.hide();
}, 1000);

possible options for dialogSize are

  • sm - small
  • m - normal
  • lg - large

possible options for progressType are

  • success
  • danger
  • warning
  • info

Contributing

🔥Before🔥 making a pull request do the following steps:

  1. Run gulp
  2. Make sure gulp doesn't return any errors
  3. Open test/run.html in your favorite browser
  4. Make sure there are no errors in dev console
  5. Make sure all dialogs behave correctly

Setting up the environment:

  1. Install Node.js
  2. Go to your project directory
  3. Run npm install -g bower
  4. Run npm install -g gulp
  5. Run npm install
  6. Run bower install

🌻You should only modify files inside src or test directories!:sunflower: Files in the build directory are generated automatically after running gulp.

Examples

HTML page example:

<html>
<head>
  <meta charset="utf-8">
  <title>boostrap-waitingfor</title>
  <link href="bower_components/bootstrap/dist/css/bootstrap.css" rel="stylesheet" />
  <link href="bower_components/bootstrap/dist/css/bootstrap-theme.css" rel="stylesheet" />
</head>
<body>
  <script src="../bower_components/jquery/dist/jquery.min.js"></script>
  <script src="../bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
  <script src="../build/bootstrap-waitingfor.js"></script>
</body>
</html>

bootstrap-waitingfor's People

Contributors

bryant1410 avatar ehpc avatar falkdav avatar guy-keller avatar lambdacasserole avatar mmolhoek 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bootstrap-waitingfor's Issues

Support yii2?

Nice plugin :)

I like this plugin, because it able to add custom text in the progress bar.
Btww, does this plugin support on Yii2 Framework?

Thanks

Succeeding modal() after waitingDialog.hide() "expands" the page's width

I noticed that if I run $("#someModal").modal right after waitingDialog.hide() "expands" the page, or more like it moves the page to the left and I could see a space on the right side of my navigation bar. My solution is:

/**
 * Closes dialog
 */
hide: function (callback) {
	$dialog.modal('hide');

	if(callback){
		$dialog.on('hidden.bs.modal', function(){
			callback();
		});
	}
}

now, you can show the next modal asynchronously AFTER hiding the waitingDialog.

waitingDialog.hide(function(){
	$("#someModal").modal();
});	

Typo when using importing with bower

Hi, just a small typo In bower.json.

{
"main": "src/boostrap-waitingfor.js",
}

it should be

{
"main": "src/bootstrap-waitingfor.js",
}

In my grunt file, I have task (bowerInstall) that inject Bower components into the HTML file. It looks at where the bower dependencies are and copies all the paths into my index.html as script or style imports. ( That stuff is made by Yeoman, not me )

Anyway, when importing your package, it failed to do so because of the typo above.

Thanks

Not loading properly in Safari 10.0.2

Hello,

I'm having an issue with this plugin in Safari 10.0.2 on macOS

code works well on Firefox and Chrome but while testing in Safari the popup doesn't load on click, only loads after page redirects.

<a class="btn btn-lg btn-block btn-warning" onclick="{literal}waitingDialog.show();setTimeout(function () {waitingDialog.hide();}, 3000);{/literal}" href="{#domainnamesslportal#}

*using smarty v3 hence the literal / # code

If i click on the link and stop the page from loading then the popup launches.

Using JQuery 3.1.1

Add callback

Hello,

Thanks for this script.

How we can add callback function to this?
when I run waitingDialog.hide();, I want to alert('1'); after it's gone hidden.

Right now if you do:
waitingDialog.hide();
alert('1');

You will get the alert while the modal is still there, I want to have the alert after the modal is completely hidden.

Thanks

Bootstrap 4 hide not working if invoke immediately after show

Hi,
I've try bootstrap-waitingfor with boostrap 4 but I found if I try to invoke hide() method, dialog not closing.
Problem I is fade can not permit to close it immediately.

I able to correct this issue by modify hide() method with this code at line 143:

hide: function () {
            if (typeof $dialog !== 'undefined') {
                $dialog.on('shown.bs.modal', function(e) {
                    $dialog.modal('hide');
                });
            }
        }

Safari

It does not work in Safari.

Versioning

Hey there,

For CDN control purposes, could we define versions numbers, and add a Changelog.md to the project. Can I help with that somehow?

Feature Request: Help method for showing the default options.

First of all, thanks for this great tool. It's very easy to use and adds so much to websites.

Feature 1
I am about to add something to this library that will make it easy to have access to some basic documentation.

It's a help method that people can just call at the console using waitingDialog.help(). This will write in the console a least the structure of the options object that can be passed to the code.

Feature 2

An init function that can be called once after loading the library for setting default options. That way, there will be no need to pass the options every time we are calling the show() method unless we need to temporarily override the default.

What do you guys think? Is it something you could accept as a pull request?

Thanks

Generated element contains inline styles, breaking CSPs

PR #21 probably fixes this (haven't checked though). Opening an issue to provide more detail as to what the issue is and how we could address it.

First of all, fantastic library. Really makes things much simpler when I want to show the user that a task is in progress, and the fact that I don't have to add any extra markup to the page makes it all that much easier to use.

There is an issue, however, when a web application uses a content security policy that doesn't specify unsafe-inline, which is considered bad practice and sacrifices a substantial amount of security. The generated element (below) contains 4 inline style attributes, which the client will refuse to apply:

<div class="modal fade" data-backdrop="static" data-keyboard="false" tabindex="-1" role="dialog" aria-hidden="true" style="padding-top:15%; overflow-y:visible;"> 
	<div class="modal-dialog modal-m"> 
		<div class="modal-content"> 
			<div class="modal-header" style="display: none;"></div> 
			<div class="modal-body"> 
				<div class="progress progress-striped active" style="margin-bottom:0;"> 
					<div class="progress-bar" style="width: 100%"></div> 
				</div> 
			</div> 
		</div> 
	</div> 
</div>

The result is a modal that works, but contains no visible progress bar (because its width is 0) and has layout issues to the padding-top and overflow-y CSS attributes not being applied.

There are a few approaches we can take to fix this issue:

  • Move things to an external style sheet and make sure that style-src includes self - from PR #21 I am guessing this isn't a particularly appealing option.
  • Place the burden on the CSP implementer to add specific exceptions for the SHA256 hashes of the inline styles included - Not particularly user-friendly and even the slightest change to the inline styles in this library will completely break it everywhere until users update their CSPs.
  • Extend the script to allow a 'nonce' to be specified - Probably the best option. As long as your users securely (i.e. unpredictably) generate a unique nonce for each page request. This won't break anything if no nonce is specified and no CSP is in place.

I'll submit a PR with the proposed change shortly.

Adding support for Bootstrap 4

Hello, first off, nice plugin!

I want to know if would be possible to add support for Bootstrap 4 to this cool plugin.

Thanks!

show.bs.modal doesn't trigger

Hi,

As this plugin uses the modal component of Bootstrap, one would expect the default events to be usable (such as 'show.bs.modal'). However, when calling waitingDialog.show();, that event doesn't seem to be triggered as expected.

Am I missing something, or is this a bug?

Example: https://bootsnipp.com/snippets/PElzm (check the HTML. The second console.log() is never executed).

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.