sairam / bootstrap-prompts Goto Github PK
View Code? Open in Web Editor NEWBootStrap Alert with modal instead of Browser alert
License: MIT License
BootStrap Alert with modal instead of Browser alert
License: MIT License
To mimic native behaviour, initial focus should be on Close button so that it can be closed with Enter keypress
In ie you get the regular alert
This works for me.
<button class="btn btn-danger" data-dismiss="modal" aria-hidden="true">×</button> \
<button class="btn btn-danger" data-dismiss="modal" aria-hidden="true">Close</button> \
The first button gives a normal plain-jane JavaScript alert().
The second button does nothing (except look pretty, thanks to Bootstrap).
(This is in the latest version of Chrome, on Windows 7.)
This works for me.
Changing to & t i m e s ; (without spaces)
From Close
It work again when fixed by myself.
Fixed source code below:
/*! bootstrap-prompts-alert.js [for Bootstrap v3.0](Fixed by Cow258)*/
bootStrapAlertHeader = 'Alert'; window._originalAlert = window.alert; window.alert = function (text) { var bootStrapAlert = function () { if (!$.fn.modal.Constructor) return false; if ($('#windowAlertModal').length == 1) return true; $('body').append('<div id="windowAlertModal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button><h4 class="modal-title text-danger">' + bootStrapAlertHeader + '</h4></div><div class="modal-body"><p> alert text </p></div><div class="modal-footer" style="text-align: center;"><button class="btn btn-danger" data-dismiss="modal" aria-hidden="true">Close</button></div></div></div></div>'); return true; }; if (bootStrapAlert()) { $('#windowAlertModal .modal-body p').text(text); $('#windowAlertModal').modal(); } else { console.log('bootstrap was not found'); window._originalAlert(text); } }
bootStrapConfirmHeader = 'Confirm'; window._originalConfirm = window.confirm; window.confirm = function (text, cb) { var initTemplate = function () { if ($('#windowConfirmModal').length == 1) return true; $('body').append('<div id="windowConfirmModal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button><h4 class="modal-title text-danger">' + bootStrapConfirmHeader + '</h4></div><div class="modal-body"><p> alert text </p></div><div class="modal-footer" style="text-align: center;"><button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">YES</button><button class="btn btn-danger" data-dismiss="modal" aria-hidden="true">NO</button></div></div></div></div>'); }; var bootStrapConfirm = function () { if (!$.fn.modal.Constructor) return false; $('body').off('click', '#windowConfirmModal .btn-primary'); $('body').off('click', '#windowConfirmModal .btn-danger'); function confirm() { cb(true); } function deny() { cb(false); } $('body').on('click', '#windowConfirmModal .btn-primary', confirm); $('body').on('click', '#windowConfirmModal .btn-danger', deny); return true; }; initTemplate(); if (bootStrapConfirm()) { $('#windowConfirmModal .modal-body p').text(text); $('#windowConfirmModal').modal(); } else { console.log('bootstrap was not found'); cb(window._originalConfirm(text)); } };
Hello!
I take great your script "bootstrap-prompts.js".
But after the upgrade bootsrap 3.0, it stopped working.
This is due to change the layout of modal windows.
I changed myself, and now she is working on version 3.0, but the functions and _originalAlert _originalConfirm not.
https://github.com/ARISTARH/bootstrap-prompts/blob/master/bootstrap-prompts-alert.js
Please help to fix it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.