Add reactive to mileage entry page
This commit is contained in:
+102
-35
@@ -1,4 +1,4 @@
|
||||
$(function () {
|
||||
$(function () {
|
||||
$("tbody > tr:odd").addClass("odd");
|
||||
$("input:submit, .ui-button").button();
|
||||
$("input#Date").datepicker({ maxDate: '+0d' });
|
||||
@@ -61,7 +61,7 @@
|
||||
if ($("input#EmployeeName").length > 0) {
|
||||
|
||||
$("input#EmployeeName")
|
||||
.after('<span id="icon-employee-history" class="add-on"><i class="icon-search" /></span>')
|
||||
.after('<span id="icon-employee-history" class="add-on"><i class="icon-search" /></span>')
|
||||
.add('#icon-employee-history')
|
||||
.wrapAll('<div class="input-append"></div>');
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
events: {
|
||||
show: function(event, api) {
|
||||
$.ajax({
|
||||
url: "CreateLog/RecentLogs",
|
||||
url: "/CreateLog/RecentLogs",
|
||||
data: {
|
||||
employeeName: $("input#EmployeeName").val()
|
||||
},
|
||||
@@ -112,10 +112,39 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$(function() {
|
||||
// Add active class to nav
|
||||
var idNavActiveRegex = { 'log-nav': /\/log/i, 'vehicle-nav': /\/vehicle/i };
|
||||
$.each(idNavActiveRegex, function (id, regex) {
|
||||
if (regex.test(document.URL)) {
|
||||
$("#" + id).addClass('active');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(function () {
|
||||
var textToIcon = {
|
||||
'Edit': 'edit',
|
||||
'Filter': 'filter',
|
||||
'Details' : 'zoom-in',
|
||||
'Delete': 'trash',
|
||||
'Add': 'plus',
|
||||
'Export': 'download',
|
||||
'Employee Mileage': 'user',
|
||||
'Vehicle Mileage': 'car'
|
||||
};
|
||||
$.each(textToIcon, function(text, icon) {
|
||||
$("a:contains('" + text + "')")
|
||||
.prepend('<i class="icon-' + icon + '" /> ');
|
||||
});
|
||||
});
|
||||
|
||||
$(function() {
|
||||
// Convert MVC3 WebGrid paging to Bootstrap
|
||||
var $paging = $('table.table tfoot tr td');
|
||||
|
||||
|
||||
var $currentPage =
|
||||
$paging.contents()
|
||||
.filter(function () { return this.nodeType == 3 && this.length != 1; });
|
||||
@@ -126,42 +155,80 @@
|
||||
$otherPages.wrap('<li>');
|
||||
$('li', $paging).wrapAll('<div class="pagination"><ul>');
|
||||
}
|
||||
|
||||
// Add active class to nav
|
||||
var h = { 'log-nav': /\/log/i, 'vehicle-nav': /\/vehicle/i };
|
||||
$.each(h, function(id, regex) {
|
||||
if (regex.test(document.URL)) {
|
||||
$("#" + id).addClass('active');
|
||||
}
|
||||
});
|
||||
|
||||
// add qtip
|
||||
$("a.qtip-modal").each(function () { bindQtipModal($(this)); });
|
||||
});
|
||||
|
||||
function bindQtipModal(element) {
|
||||
$(function() {
|
||||
// add qtip
|
||||
$("a.qtip-modal").each(function () { bindQtipModal($(this)); });
|
||||
|
||||
function bindQtipModal(element) {
|
||||
|
||||
element.click(function () { return false; });
|
||||
element.click(function() { return false; });
|
||||
|
||||
element.append(' <span class="muted">▴</span>');
|
||||
element.append(' <span class="muted">▴</span>');
|
||||
|
||||
element.qtip({
|
||||
content: {
|
||||
ajax: {
|
||||
url: element.attr('href')
|
||||
element.qtip({
|
||||
content: {
|
||||
ajax: {
|
||||
url: element.attr('href')
|
||||
},
|
||||
text: "<p class=\"loading\">Recent Logs...</p>"
|
||||
},
|
||||
text: "<p class=\"loading\">Recent Logs...</p>"
|
||||
},
|
||||
hide: {
|
||||
fixed: true,
|
||||
delay: 500
|
||||
},
|
||||
style: {
|
||||
classes: 'qtip-light qtip-shadow',
|
||||
width: 300
|
||||
},
|
||||
position: {
|
||||
viewport: $(window)
|
||||
hide: {
|
||||
fixed: true,
|
||||
delay: 500
|
||||
},
|
||||
style: {
|
||||
classes: 'qtip-light qtip-shadow',
|
||||
width: 300
|
||||
},
|
||||
position: {
|
||||
viewport: $(window)
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* Form Validation
|
||||
* This script will set Bootstrap error classes when form.submit is called.
|
||||
* The errors are produced by the MVC unobtrusive validation.
|
||||
*/
|
||||
$(function () {
|
||||
$('form').submit(function () {
|
||||
$(this).find('div.control-group').each(function () {
|
||||
if ($(this).find('span.field-validation-error').length == 0) {
|
||||
$(this).removeClass('error');
|
||||
}
|
||||
});
|
||||
|
||||
if (!$(this).valid()) {
|
||||
$(this).find('div.control-group').each(function () {
|
||||
if ($(this).find('span.field-validation-error').length > 0) {
|
||||
$(this).addClass('error');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
$('form').each(function () {
|
||||
$(this).find('div.control-group').each(function () {
|
||||
if ($(this).find('span.field-validation-error').length > 0) {
|
||||
$(this).addClass('error');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//Update that validator
|
||||
if ($.validator === undefined)
|
||||
return;
|
||||
$.validator.setDefaults({
|
||||
highlight: function (element) {
|
||||
$(element).closest(".control-group").addClass("error");
|
||||
},
|
||||
unhighlight: function (element) {
|
||||
$(element).closest(".control-group").removeClass("error");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/* End Form Validation */
|
||||
Reference in New Issue
Block a user