$(function () { $('.enable-javascript').show(); $("input#Date, input#InactiveDate").datepicker({ maxDate: '+0d' }); $("input#CityName").autocomplete({ source: "/City/Autocomplete", minLength: 2 }); $("input#EmployeeName, input#Assigned, input#UserFullName, input#UserName").autocomplete({ source: "/User/Autocomplete", minLength: 2 }); $("form select#Year").change(function () { var year = $(this).val(); var months = availableLogYearMonths[year]; var options = ''; for (var i = 0; i < months.length; i++) { options += ''; } $("form select#Month").html(options); }); $("input#ModelYear,input#Price,input#VehicleId,input#EndOdometer,input#GasPurchased").numeric(); $(".report-miles").append(' ').each(function () { var content = $(this).next('.report-calculation'); $(this).qtip({ content: content, hide: { fixed: true, delay: 1000 }, style: { width: 520, classes: "qtip-light" }, position: { my: "top right", at: "bottom left" }, }); }); // add popup for span titles $('span[title]').append(' ').qtip({ content: { text: false // Use each elements title attribute }, style: { classes: "qtip-light" } // Give it some style }); $(".miles-unknown").addClass('label label-warning').append(' ') .each(function () { $(this).qtip({ content: "No previous log for this vehicle", style: { classes: "qtip-red" } }); }); }); // add recent logs to a div if it exists $(function () { var $recentLogs = $("#RecentLogs"); if ($recentLogs.length > 0) { $.ajax({ url: "/CreateLog/RecentLogs", success: function (data) { $recentLogs.append(data); } }); } }); $(function() { // move checkbox elements into their labels $('label[for]').each(function() { var $label = $(this); var $for = $label.attr('for'); if ($for.length > 0) { var $input = $('input#' + $for + ',input[name="' + $for + '"]'); if ($input.filter(':checkbox').length > 0) { $input.prependTo($label); $label.addClass('checkbox'); } } }); }); // Add active class to nav $(function() { var idNavActiveRegex = { 'fuellog-nav': /\/fuellog/i, 'log-nav': /\/log|\/City|\/Purpose/i, 'vehicle-nav': /\/vehicle/i, 'user-nav': /\/user/i }; var set = false; $.each(idNavActiveRegex, function (id, regex) { if (regex.test(document.URL)) { $("#" + id).addClass('active'); set = true; } }); if (!set) { $("#" + 'create-nav').addClass('active'); } }); function addButtonIcons () { var textToIcon = { 'Edit': 'edit', 'Filter': 'filter', 'Details' : 'zoom-in', 'Delete': 'trash', 'Add': 'plus', 'Export': 'download', 'Import': 'upload', 'Driver Mileage': 'user', 'Vehicle Mileage': 'car', 'Show Active': 'ok-circle', 'Show Inactive': 'ban-circle', 'Set Inactive' : 'ban-circle', 'Reactivate' : 'ok-circle' }; $.each(textToIcon, function(text, icon) { $("a:contains('" + text + "'):not(:has(i))") .prepend(' '); }); $(".navbar-inverse a[title='Manage']:not(:has(i))") .prepend(' '); } $(function () { addButtonIcons(); }); // Convert MVC3 WebGrid paging to Bootstrap $(function() { var $paging = $('table.table tfoot tr td'); var $currentPage = $paging.contents() .filter(function () { return this.nodeType == 3 && this.length != 1; }); var $otherPages = $('a', $paging); if ($paging.length == 1 && $otherPages.length > 0) { $currentPage.wrap('
  • '); $otherPages.wrap('
  • '); $('li', $paging).wrapAll('