Skip to content

Instantly share code, notes, and snippets.

@mxub
Forked from drewjoh/custom.js
Created August 2, 2012 10:24

Revisions

  1. Drew Johnston revised this gist Jun 13, 2012. No changes.
  2. Drew Johnston revised this gist Jun 13, 2012. 1 changed file with 0 additions and 6 deletions.
    6 changes: 0 additions & 6 deletions custom.js
    Original file line number Diff line number Diff line change
    @@ -13,11 +13,5 @@ $('[data-toggle="modal"]').click(function(e) {
    }).success(function() { $('input:text:visible:first').focus(); });
    }
    });

    // Delete the modal window on close
    $('[data-dismiss="modal"]').click(function(e) {
    e.preventDefault();
    $('.modal').remove();
    });

    });
  3. Drew Johnston revised this gist Jun 13, 2012. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions custom.js
    Original file line number Diff line number Diff line change
    @@ -13,5 +13,11 @@ $('[data-toggle="modal"]').click(function(e) {
    }).success(function() { $('input:text:visible:first').focus(); });
    }
    });

    // Delete the modal window on close
    $('[data-dismiss="modal"]').click(function(e) {
    e.preventDefault();
    $('.modal').remove();
    });

    });
  4. Drew Johnston revised this gist May 31, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion index.htm
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    <a herf="/url/to/load/modal_window.htm" data-toggle="modal">link</a>
    <a href="/url/to/load/modal_window.htm" data-toggle="modal">link</a>
  5. Drew Johnston revised this gist Feb 1, 2012. 3 changed files with 6 additions and 6 deletions.
    4 changes: 2 additions & 2 deletions custom.js
    Original file line number Diff line number Diff line change
    @@ -2,9 +2,9 @@ $(document).ready(function() {

    // Support for AJAX loaded modal window.
    // Focuses on first input textbox after it loads the window.
    $('.to-modal').click(function(e) {
    $('[data-toggle="modal"]').click(function(e) {
    e.preventDefault();
    var href = $(e.target).attr('href');
    var href = $(this).attr('href');
    if (href.indexOf('#') == 0) {
    $(href).modal('open');
    } else {
    2 changes: 1 addition & 1 deletion index.htm
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    <a herf="/url/to/load/modal_window.htm" class="to-modal">link</a>
    <a herf="/url/to/load/modal_window.htm" data-toggle="modal">link</a>
    6 changes: 3 additions & 3 deletions modal_window.htm
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,11 @@
    <div class="modal-header">
    <a href="#" class="close modal-close">×</a>
    <a class="close" data-dismiss="modal">×</a>
    <h3>Modal header 2</h3>
    </div>
    <div class="modal-body">
    <p>One body...</p>
    </div>
    <div class="modal-footer">
    <input class="btn btn-primary" type="submit" value="Save Changes" />
    <a class="btn modal-close">Close</a>
    <a class="btn btn-primary">Save Changes</a>
    <a class="btn" data-dismiss="modal">Close</a>
    </div>
  6. Drew Johnston revised this gist Feb 1, 2012. 3 changed files with 17 additions and 16 deletions.
    25 changes: 13 additions & 12 deletions custom.js
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,17 @@
    $(document).ready(function() {

    // Support for AJAX loaded modal window
    $('.to_modal').click(function(e) {
    e.preventDefault();
    var href = $(e.target).attr('href');
    if (href.indexOf('#') == 0) {
    $(href).modal('open');
    } else {
    $.get(href, function(data) {
    $('<div class="modal fade" >' + data + '</div>').modal();
    });
    }
    });
    // Support for AJAX loaded modal window.
    // Focuses on first input textbox after it loads the window.
    $('.to-modal').click(function(e) {
    e.preventDefault();
    var href = $(e.target).attr('href');
    if (href.indexOf('#') == 0) {
    $(href).modal('open');
    } else {
    $.get(href, function(data) {
    $('<div class="modal" >' + data + '</div>').modal();
    }).success(function() { $('input:text:visible:first').focus(); });
    }
    });

    });
    2 changes: 1 addition & 1 deletion index.htm
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    <a herf="/url/to/load/modal_window.htm" class="to_modal">link</a>
    <a herf="/url/to/load/modal_window.htm" class="to-modal">link</a>
    6 changes: 3 additions & 3 deletions modal_window.htm
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,11 @@
    <div class="modal-header">
    <a href="#" class="close js-dismiss">×</a>
    <a href="#" class="close modal-close">×</a>
    <h3>Modal header 2</h3>
    </div>
    <div class="modal-body">
    <p>One body...</p>
    </div>
    <div class="modal-footer">
    <input class="btn primary" type="submit" value="Save Changes" />
    <a href="#" class="btn js-dismiss">Close</a>
    <input class="btn btn-primary" type="submit" value="Save Changes" />
    <a class="btn modal-close">Close</a>
    </div>
  7. Drew Johnston revised this gist Feb 1, 2012. 2 changed files with 13 additions and 24 deletions.
    19 changes: 12 additions & 7 deletions custom.js
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,16 @@
    $(document).ready(function() {

    // Support for AJAX loaded modal window
    $('.btn-modal').click(function() {
    $.get($(this).attr('data-target'), function(data) {
    $('#modal_window').html(data);
    $('#modal_window').modal('show');
    }, 'html');
    });
    // Support for AJAX loaded modal window
    $('.to_modal').click(function(e) {
    e.preventDefault();
    var href = $(e.target).attr('href');
    if (href.indexOf('#') == 0) {
    $(href).modal('open');
    } else {
    $.get(href, function(data) {
    $('<div class="modal fade" >' + data + '</div>').modal();
    });
    }
    });

    });
    18 changes: 1 addition & 17 deletions index.htm
    Original file line number Diff line number Diff line change
    @@ -1,17 +1 @@
    <html>
    <head>
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/custom.js"></script>

    <link href="css/bootstrap.css" rel="stylesheet">

    <!-- Modal window to load dynamic content -->
    <div class="modal hide" id="modal_window"></div>
    </head>

    <body>
    <!-- Uses btn-model class to indicate an AJAX loaded modal, and data-target as the source -->
    <a class="btn btn-modal" data-target="modal_window.htm">Launch Modal</a>
    </body>
    </html>
    <a herf="/url/to/load/modal_window.htm" class="to_modal">link</a>
  8. Drew Johnston revised this gist Jan 27, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion index.htm
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,6 @@

    <body>
    <!-- Uses btn-model class to indicate an AJAX loaded modal, and data-target as the source -->
    <a class="btn btn-modal" data-target="modal_window.html">Launch Modal</a>
    <a class="btn btn-modal" data-target="modal_window.htm">Launch Modal</a>
    </body>
    </html>
  9. Drew Johnston created this gist Jan 27, 2012.
    11 changes: 11 additions & 0 deletions custom.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    $(document).ready(function() {

    // Support for AJAX loaded modal window
    $('.btn-modal').click(function() {
    $.get($(this).attr('data-target'), function(data) {
    $('#modal_window').html(data);
    $('#modal_window').modal('show');
    }, 'html');
    });

    });
    17 changes: 17 additions & 0 deletions index.htm
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    <html>
    <head>
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/custom.js"></script>

    <link href="css/bootstrap.css" rel="stylesheet">

    <!-- Modal window to load dynamic content -->
    <div class="modal hide" id="modal_window"></div>
    </head>

    <body>
    <!-- Uses btn-model class to indicate an AJAX loaded modal, and data-target as the source -->
    <a class="btn btn-modal" data-target="modal_window.html">Launch Modal</a>
    </body>
    </html>
    11 changes: 11 additions & 0 deletions modal_window.htm
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    <div class="modal-header">
    <a href="#" class="close js-dismiss">×</a>
    <h3>Modal header 2</h3>
    </div>
    <div class="modal-body">
    <p>One body...</p>
    </div>
    <div class="modal-footer">
    <input class="btn primary" type="submit" value="Save Changes" />
    <a href="#" class="btn js-dismiss">Close</a>
    </div>