-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
86 lines (74 loc) · 2.66 KB
/
index.js
File metadata and controls
86 lines (74 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**
* Primary view JavaScript component
*
* This file contains the code for the index/list component of the Order Management module written for Web2Project.
* Module is developed and maintained by Eirik Eggesbø Ottesen.
*
* @package Ordermgmt
* @version 1.0
* @author Eirik Eggesbø Ottesen <Korkonius@gmail.com>
*/
$(document).ready(function(){
$('#load_dialog').position({
of: $('#ordertable tbody'),
at: 'center center',
my: 'center center'
});
$('#load_dialog')
.hide()
$('.paginate').each(function(index, value) {
var total = $('#pagination_total_records').val();
var per_page = $('#pagination_records_per_page').val();
var init_page = $('#pagination_initial_page').val();
$(value).smartpaginator({
totalrecords: total,
recordsperpage: per_page,
initval: init_page,
onchange: function(newpage) {
// Copy and modify global settings
$("#load_dialog").overlay().load();
var request = $.extend(true, {}, ajaxSettings);
request.data.page = newpage;
// Make request!
$.ajax(request);
}
});
});
$('#filter').show();
// Make all order lines clickable and lead to specific project views
/*$('tr.order_clickable').on({
click: function() {
event.preventDefault();
var strId = this.id.substr(8);
window.location = "?m=ordermgmt&order_id=" + strId;
}
});*/
$('#order_filter').change(function() {
window.location = '?m=ordermgmt&filter=' + $('#order_filter option:selected').val();
});
// Text ajax call to see if we can get the expected object to work
var ajaxSettings = {
type: 'POST',
data: {
'dosql': 'do_ajaxrequest',
'filter': $('#pagination_filter').val()
},
url: '?m=ordermgmt&suppressHeaders=true',
success: function(data) {
// Expecting to recieve HTML from server using TBS templates
$('#ordertable tbody').html(data);
$("#load_dialog").overlay().close();
// Register events
$('tr.order_clickable').on({
click: function() {
event.preventDefault();
var strId = this.id.substr(8);
window.location = "?m=ordermgmt&order_id=" + strId;
}
});
},
error: function(data) {
$("#load_dialog").overlay().close();
}
};
});