//
// Typehead
//
$("input[data-provide='typeahead']").typeahead({
    source: function () {
        // console.log(typeahead);
        alert("yo");
        console.log(this);
        console.log($this.closest("form").attr('action'));
        // return [{value: 'Charlie'}, {value: 'Gudbergur'}];
        // return $.post($this.closest("form").attr('action'), { query: query }, function (data) {
        //     return typeahead.process(data);
        // });
    }
});


//
// Optimize remote forms
// Show loading... and disable submit input or button on submit
//
$("form[data-remote='true']").on('submit', function() {
    $this = $(this)
    $btn  = $this.find("input[name='commit'][type='submit'], button[type='submit']")
                 .attr('data-loading-text', 'loading...')
                 .button('loading')

    $this.on('ajax:complete', function() {
        $btn.button('reset')
        $this.off('ajax:complete')
    })
});


//
// Optimize Nav-Tabs
//
$('.nav.nav-tabs.nav-js a').click(function (e)
{
    e.preventDefault()
    window.location.hash = $(this).attr('href')
    $(this).tab('show')
})

if(window.location.hash) {
    $('.nav-js a[href="'+window.location.hash+'"]').tab('show')
}


//
// Optimize data-confirm
//
$.rails.allowAction = function(link)
{
    if (!link.attr('data-confirm')) {
      return true
    }
    $.rails.showConfirmDialog(link)
    return false
}

$.rails.confirmed = function(link)
{
    link.removeAttr('data-confirm')
    return link.trigger('click.rails')
}

$.rails.showConfirmDialog = function(link)
{
    var html, message;
    message = link.attr('data-confirm')

    html = "<div class=\"modal fade\" id=\"modal-confirmation\" role=\"dialog\">\n  <div class=\"modal-header\">\n    <a class=\"close\" data-dismiss=\"modal\">×</a>\n    <h3>" + message + "</h3>\n  </div>\n  <div class=\"modal-body\">\n    <p>Are you sure you want to delete?</p>\n  </div>\n  <div class=\"modal-footer\">\n    <a data-dismiss=\"modal\" class=\"btn\">Cancel</a>\n    <a data-dismiss=\"modal\" class=\"btn btn-primary confirm\">OK</a>\n  </div>\n</div>";
    return $(html).modal('show')
                  .on('hidden', function () {
                       $(this).remove()
                  })
                  .find('.confirm').on('click', function() {
                       return $.rails.confirmed(link)
                  })
}

@@ -1566,23 +1566,56 @@
 r html, 
-message
+%0A        message = %22%22,%0A        body = %22%22
 ;%0A    me
@@ -1647,16 +1647,201 @@
 onfirm')
+%0A    if (link.attr('data-message') && link.attr('data-message').length %3E 0) %7B%0A        body = %22%3Cdiv class=%5C%22modal-body%5C%22%3E%5Cn    %3Cp%3E%22 + link.attr('data-message') + %22%3C/p%3E%5Cn  %3C/div%3E%5Cn%22%0A    %7D
 %0A%0A    ht
@@ -2047,91 +2047,20 @@
 %5Cn  
-%3Cdiv class=%5C%22modal-body%5C%22%3E%5Cn    %3Cp%3EAre you sure you want to delete?%3C/p%3E%5Cn  %3C/div%3E%5Cn
+%22 + body + %22
   %3Cd
@@ -2259,22 +2259,16 @@
 ).modal(
-'show'
 )%0A      
@@ -2329,17 +2329,16 @@
         
- 
 $(this).
@@ -2424,25 +2424,24 @@
 unction() %7B%0A
- 
             

Update bootstrap extends javascript