Permalink
Browse files

Adding first version of alert code

  • Loading branch information...
0 parents commit 0ef178c20ad6d0b6dd41c759a315109374b01e62 @sairam committed Dec 29, 2012
Showing with 55 additions and 0 deletions.
  1. +20 −0 LICENSE
  2. +7 −0 README.md
  3. +28 −0 bootstrap-prompts-alert.js
20 LICENSE
@@ -0,0 +1,20 @@
+
+Copyright (c) 2012 Sairam Kunala
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
@@ -0,0 +1,7 @@
+Bootstrap-Prompts is an implementation to replace the `alert()`, `prompt()`,`confirm()` notifications on the browser when using [Twitter Bootstrap](http://twitter.github.com/bootstrap/) with Modal information.
+
+## Requires
+* Requires Twitter Bootstrap and JQuery to be initialized before using alert()
+
+## TODO
+Need to implement `prompt()` and `confirm()` actions so that they return
@@ -0,0 +1,28 @@
+window._originalAlert = window.alert;
+window.alert = function(text) {
+ bootStrapAlert = function() {
+ if(! $.fn.modal.Constructor)
+ return false;
+ if($('#windowAlertModal').length == 1)
+ return true;
+ $('body').append(' \
+ <div id="windowAlertModal" class="modal hide fade" tabindex="-1" role="dialog" aria-hidden="true"> \
+ <div class="modal-body"> \
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> \
+ <p> alert text </p> \
+ </div> \
+ <div class="modal-footer"> \
+ <button class="btn btn-danger" data-dismiss="modal" aria-hidden="true">Close</button> \
+ </div> \
+ </div> \
+ ');
+ return true;
+ }
+ if ( bootStrapAlert() ){
+ $('#windowAlertModal .modal-body p').text(text);
+ $('#windowAlertModal').modal();
+ } else {
+ console.log('bootstrap was not found');
+ window._originalAlert(text);
+ }
+}

0 comments on commit 0ef178c

Please sign in to comment.