merb-admin 0.8.1 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +29 -27
- data/Gemfile +24 -22
- data/Gemfile.lock +86 -0
- data/LICENSE +20 -20
- data/README.rdoc +54 -58
- data/Rakefile +11 -44
- data/app/controllers/application.rb +6 -6
- data/app/controllers/main.rb +191 -191
- data/app/helpers/application_helper.rb +64 -64
- data/app/helpers/main_helper.rb +167 -167
- data/app/models/.gitkeep +0 -0
- data/app/views/layout/_message.html.erb +10 -10
- data/app/views/layout/dashboard.html.erb +34 -34
- data/app/views/layout/form.html.erb +48 -48
- data/app/views/layout/list.html.erb +42 -42
- data/app/views/main/_belongs_to.html.erb +29 -29
- data/app/views/main/_big_decimal.html.erb +12 -12
- data/app/views/main/_boolean.html.erb +7 -7
- data/app/views/main/_date.html.erb +12 -12
- data/app/views/main/_datetime.html.erb +12 -12
- data/app/views/main/_float.html.erb +12 -12
- data/app/views/main/_has_many.html.erb +16 -16
- data/app/views/main/_has_one.html.erb +30 -30
- data/app/views/main/_integer.html.erb +12 -12
- data/app/views/main/_properties.html.erb +18 -18
- data/app/views/main/_string.html.erb +15 -15
- data/app/views/main/_text.html.erb +11 -11
- data/app/views/main/_time.html.erb +12 -12
- data/app/views/main/_timestamp.html.erb +12 -12
- data/app/views/main/delete.html.erb +28 -28
- data/app/views/main/edit.html.erb +19 -19
- data/app/views/main/index.html.erb +22 -22
- data/app/views/main/list.html.erb +93 -93
- data/app/views/main/new.html.erb +16 -16
- data/config/init.rb +30 -0
- data/config/router.rb +4 -0
- data/lib/abstract_model.rb +84 -86
- data/lib/active_record_support.rb +147 -147
- data/lib/datamapper_support.rb +139 -140
- data/lib/generic_support.rb +13 -13
- data/lib/merb-admin.rb +99 -99
- data/lib/merb-admin/merbtasks.rb +103 -103
- data/lib/merb-admin/slicetasks.rb +174 -174
- data/lib/merb-admin/spectasks.rb +55 -55
- data/lib/merb-admin/version.rb +3 -0
- data/lib/sequel_support.rb +275 -275
- data/merb-admin.gemspec +42 -232
- data/public/javascripts/CollapsedFieldsets.js +85 -85
- data/public/javascripts/DateTimeShortcuts.js +255 -255
- data/public/javascripts/RelatedObjectLookups.js +96 -96
- data/public/javascripts/SelectBox.js +111 -111
- data/public/javascripts/SelectFilter2.js +113 -113
- data/public/javascripts/actions.js +39 -39
- data/public/javascripts/calendar.js +143 -143
- data/public/javascripts/core.js +176 -176
- data/public/javascripts/dateparse.js +233 -233
- data/public/javascripts/getElementsBySelector.js +167 -167
- data/public/javascripts/i18n.js +33 -33
- data/public/javascripts/ordering.js +137 -137
- data/public/javascripts/timeparse.js +94 -94
- data/public/javascripts/urlify.js +140 -140
- data/public/stylesheets/base.css +746 -746
- data/public/stylesheets/changelists.css +269 -269
- data/public/stylesheets/dashboard.css +24 -24
- data/public/stylesheets/forms.css +327 -327
- data/public/stylesheets/global.css +142 -142
- data/public/stylesheets/ie.css +50 -50
- data/public/stylesheets/layout.css +29 -29
- data/public/stylesheets/login.css +54 -54
- data/public/stylesheets/master.css +1 -1
- data/public/stylesheets/patch-iewin.css +7 -7
- data/public/stylesheets/rtl.css +206 -206
- data/public/stylesheets/widgets.css +506 -506
- data/screenshots/create.png +0 -0
- data/screenshots/delete.png +0 -0
- data/screenshots/edit.png +0 -0
- data/screenshots/index.png +0 -0
- data/screenshots/list.png +0 -0
- data/screenshots/new.png +0 -0
- data/spec/controllers/main_spec.rb +25 -25
- data/spec/migrations/activerecord/001_create_divisions_migration.rb +13 -13
- data/spec/migrations/activerecord/002_create_drafts_migration.rb +19 -19
- data/spec/migrations/activerecord/003_create_leagues_migration.rb +12 -12
- data/spec/migrations/activerecord/004_create_players_migration.rb +19 -20
- data/spec/migrations/activerecord/005_create_teams_migration.rb +22 -22
- data/spec/migrations/sequel/001_create_divisions_migration.rb +15 -15
- data/spec/migrations/sequel/002_create_drafts_migration.rb +21 -21
- data/spec/migrations/sequel/003_create_leagues_migration.rb +14 -14
- data/spec/migrations/sequel/004_create_players_migration.rb +21 -22
- data/spec/migrations/sequel/005_create_teams_migration.rb +24 -24
- data/spec/models/activerecord/division.rb +7 -7
- data/spec/models/activerecord/draft.rb +11 -11
- data/spec/models/activerecord/league.rb +6 -6
- data/spec/models/activerecord/player.rb +8 -8
- data/spec/models/activerecord/team.rb +13 -13
- data/spec/models/datamapper/division.rb +12 -12
- data/spec/models/datamapper/draft.rb +18 -18
- data/spec/models/datamapper/league.rb +11 -11
- data/spec/models/datamapper/player.rb +20 -21
- data/spec/models/datamapper/team.rb +22 -22
- data/spec/models/sequel/division.rb +15 -15
- data/spec/models/sequel/draft.rb +19 -19
- data/spec/models/sequel/league.rb +14 -14
- data/spec/models/sequel/player.rb +18 -18
- data/spec/models/sequel/team.rb +21 -21
- data/spec/requests/main_spec.rb +763 -763
- data/spec/spec_helper.rb +113 -112
- metadata +247 -41
- data/VERSION +0 -1
@@ -1,39 +1,39 @@
|
|
1
|
-
var Actions = {
|
2
|
-
init: function() {
|
3
|
-
var selectAll = document.getElementById('action-toggle');
|
4
|
-
if (selectAll) {
|
5
|
-
selectAll.style.display = 'inline';
|
6
|
-
addEvent(selectAll, 'click', function() {
|
7
|
-
Actions.checker(selectAll.checked);
|
8
|
-
});
|
9
|
-
}
|
10
|
-
var changelistTable = document.getElementsBySelector('#changelist table')[0];
|
11
|
-
if (changelistTable) {
|
12
|
-
addEvent(changelistTable, 'click', function(e) {
|
13
|
-
if (!e) { var e = window.event; }
|
14
|
-
var target = e.target ? e.target : e.srcElement;
|
15
|
-
if (target.nodeType == 3) { target = target.parentNode; }
|
16
|
-
if (target.className == 'action-select') {
|
17
|
-
var tr = target.parentNode.parentNode;
|
18
|
-
Actions.toggleRow(tr, target.checked);
|
19
|
-
}
|
20
|
-
});
|
21
|
-
}
|
22
|
-
},
|
23
|
-
toggleRow: function(tr, checked) {
|
24
|
-
if (checked && tr.className.indexOf('selected') == -1) {
|
25
|
-
tr.className += ' selected';
|
26
|
-
} else if (!checked) {
|
27
|
-
tr.className = tr.className.replace(' selected', '');
|
28
|
-
}
|
29
|
-
},
|
30
|
-
checker: function(checked) {
|
31
|
-
var actionCheckboxes = document.getElementsBySelector('tr input.action-select');
|
32
|
-
for(var i = 0; i < actionCheckboxes.length; i++) {
|
33
|
-
actionCheckboxes[i].checked = checked;
|
34
|
-
Actions.toggleRow(actionCheckboxes[i].parentNode.parentNode, checked);
|
35
|
-
}
|
36
|
-
}
|
37
|
-
};
|
38
|
-
|
39
|
-
addEvent(window, 'load', Actions.init);
|
1
|
+
var Actions = {
|
2
|
+
init: function() {
|
3
|
+
var selectAll = document.getElementById('action-toggle');
|
4
|
+
if (selectAll) {
|
5
|
+
selectAll.style.display = 'inline';
|
6
|
+
addEvent(selectAll, 'click', function() {
|
7
|
+
Actions.checker(selectAll.checked);
|
8
|
+
});
|
9
|
+
}
|
10
|
+
var changelistTable = document.getElementsBySelector('#changelist table')[0];
|
11
|
+
if (changelistTable) {
|
12
|
+
addEvent(changelistTable, 'click', function(e) {
|
13
|
+
if (!e) { var e = window.event; }
|
14
|
+
var target = e.target ? e.target : e.srcElement;
|
15
|
+
if (target.nodeType == 3) { target = target.parentNode; }
|
16
|
+
if (target.className == 'action-select') {
|
17
|
+
var tr = target.parentNode.parentNode;
|
18
|
+
Actions.toggleRow(tr, target.checked);
|
19
|
+
}
|
20
|
+
});
|
21
|
+
}
|
22
|
+
},
|
23
|
+
toggleRow: function(tr, checked) {
|
24
|
+
if (checked && tr.className.indexOf('selected') == -1) {
|
25
|
+
tr.className += ' selected';
|
26
|
+
} else if (!checked) {
|
27
|
+
tr.className = tr.className.replace(' selected', '');
|
28
|
+
}
|
29
|
+
},
|
30
|
+
checker: function(checked) {
|
31
|
+
var actionCheckboxes = document.getElementsBySelector('tr input.action-select');
|
32
|
+
for(var i = 0; i < actionCheckboxes.length; i++) {
|
33
|
+
actionCheckboxes[i].checked = checked;
|
34
|
+
Actions.toggleRow(actionCheckboxes[i].parentNode.parentNode, checked);
|
35
|
+
}
|
36
|
+
}
|
37
|
+
};
|
38
|
+
|
39
|
+
addEvent(window, 'load', Actions.init);
|
@@ -1,143 +1,143 @@
|
|
1
|
-
/*
|
2
|
-
calendar.js - Calendar functions by Adrian Holovaty
|
3
|
-
*/
|
4
|
-
|
5
|
-
function removeChildren(a) { // "a" is reference to an object
|
6
|
-
while (a.hasChildNodes()) a.removeChild(a.lastChild);
|
7
|
-
}
|
8
|
-
|
9
|
-
// quickElement(tagType, parentReference, textInChildNode, [, attribute, attributeValue ...]);
|
10
|
-
function quickElement() {
|
11
|
-
var obj = document.createElement(arguments[0]);
|
12
|
-
if (arguments[2] != '' && arguments[2] != null) {
|
13
|
-
var textNode = document.createTextNode(arguments[2]);
|
14
|
-
obj.appendChild(textNode);
|
15
|
-
}
|
16
|
-
var len = arguments.length;
|
17
|
-
for (var i = 3; i < len; i += 2) {
|
18
|
-
obj.setAttribute(arguments[i], arguments[i+1]);
|
19
|
-
}
|
20
|
-
arguments[1].appendChild(obj);
|
21
|
-
return obj;
|
22
|
-
}
|
23
|
-
|
24
|
-
// CalendarNamespace -- Provides a collection of HTML calendar-related helper functions
|
25
|
-
var CalendarNamespace = {
|
26
|
-
monthsOfYear: gettext('January February March April May June July August September October November December').split(' '),
|
27
|
-
daysOfWeek: gettext('S M T W T F S').split(' '),
|
28
|
-
isLeapYear: function(year) {
|
29
|
-
return (((year % 4)==0) && ((year % 100)!=0) || ((year % 400)==0));
|
30
|
-
},
|
31
|
-
getDaysInMonth: function(month,year) {
|
32
|
-
var days;
|
33
|
-
if (month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12) {
|
34
|
-
days = 31;
|
35
|
-
}
|
36
|
-
else if (month==4 || month==6 || month==9 || month==11) {
|
37
|
-
days = 30;
|
38
|
-
}
|
39
|
-
else if (month==2 && CalendarNamespace.isLeapYear(year)) {
|
40
|
-
days = 29;
|
41
|
-
}
|
42
|
-
else {
|
43
|
-
days = 28;
|
44
|
-
}
|
45
|
-
return days;
|
46
|
-
},
|
47
|
-
draw: function(month, year, div_id, callback) { // month = 1-12, year = 1-9999
|
48
|
-
month = parseInt(month);
|
49
|
-
year = parseInt(year);
|
50
|
-
var calDiv = document.getElementById(div_id);
|
51
|
-
removeChildren(calDiv);
|
52
|
-
var calTable = document.createElement('table');
|
53
|
-
quickElement('caption', calTable, CalendarNamespace.monthsOfYear[month-1] + ' ' + year);
|
54
|
-
var tableBody = quickElement('tbody', calTable);
|
55
|
-
|
56
|
-
// Draw days-of-week header
|
57
|
-
var tableRow = quickElement('tr', tableBody);
|
58
|
-
for (var i = 0; i < 7; i++) {
|
59
|
-
quickElement('th', tableRow, CalendarNamespace.daysOfWeek[i]);
|
60
|
-
}
|
61
|
-
|
62
|
-
var startingPos = new Date(year, month-1, 1).getDay();
|
63
|
-
var days = CalendarNamespace.getDaysInMonth(month, year);
|
64
|
-
|
65
|
-
// Draw blanks before first of month
|
66
|
-
tableRow = quickElement('tr', tableBody);
|
67
|
-
for (var i = 0; i < startingPos; i++) {
|
68
|
-
var _cell = quickElement('td', tableRow, ' ');
|
69
|
-
_cell.style.backgroundColor = '#f3f3f3';
|
70
|
-
}
|
71
|
-
|
72
|
-
// Draw days of month
|
73
|
-
var currentDay = 1;
|
74
|
-
for (var i = startingPos; currentDay <= days; i++) {
|
75
|
-
if (i%7 == 0 && currentDay != 1) {
|
76
|
-
tableRow = quickElement('tr', tableBody);
|
77
|
-
}
|
78
|
-
var cell = quickElement('td', tableRow, '');
|
79
|
-
quickElement('a', cell, currentDay, 'href', 'javascript:void(' + callback + '('+year+','+month+','+currentDay+'));');
|
80
|
-
currentDay++;
|
81
|
-
}
|
82
|
-
|
83
|
-
// Draw blanks after end of month (optional, but makes for valid code)
|
84
|
-
while (tableRow.childNodes.length < 7) {
|
85
|
-
var _cell = quickElement('td', tableRow, ' ');
|
86
|
-
_cell.style.backgroundColor = '#f3f3f3';
|
87
|
-
}
|
88
|
-
|
89
|
-
calDiv.appendChild(calTable);
|
90
|
-
}
|
91
|
-
}
|
92
|
-
|
93
|
-
// Calendar -- A calendar instance
|
94
|
-
function Calendar(div_id, callback) {
|
95
|
-
// div_id (string) is the ID of the element in which the calendar will
|
96
|
-
// be displayed
|
97
|
-
// callback (string) is the name of a JavaScript function that will be
|
98
|
-
// called with the parameters (year, month, day) when a day in the
|
99
|
-
// calendar is clicked
|
100
|
-
this.div_id = div_id;
|
101
|
-
this.callback = callback;
|
102
|
-
this.today = new Date();
|
103
|
-
this.currentMonth = this.today.getMonth() + 1;
|
104
|
-
this.currentYear = this.today.getFullYear();
|
105
|
-
}
|
106
|
-
Calendar.prototype = {
|
107
|
-
drawCurrent: function() {
|
108
|
-
CalendarNamespace.draw(this.currentMonth, this.currentYear, this.div_id, this.callback);
|
109
|
-
},
|
110
|
-
drawDate: function(month, year) {
|
111
|
-
this.currentMonth = month;
|
112
|
-
this.currentYear = year;
|
113
|
-
this.drawCurrent();
|
114
|
-
},
|
115
|
-
drawPreviousMonth: function() {
|
116
|
-
if (this.currentMonth == 1) {
|
117
|
-
this.currentMonth = 12;
|
118
|
-
this.currentYear--;
|
119
|
-
}
|
120
|
-
else {
|
121
|
-
this.currentMonth--;
|
122
|
-
}
|
123
|
-
this.drawCurrent();
|
124
|
-
},
|
125
|
-
drawNextMonth: function() {
|
126
|
-
if (this.currentMonth == 12) {
|
127
|
-
this.currentMonth = 1;
|
128
|
-
this.currentYear++;
|
129
|
-
}
|
130
|
-
else {
|
131
|
-
this.currentMonth++;
|
132
|
-
}
|
133
|
-
this.drawCurrent();
|
134
|
-
},
|
135
|
-
drawPreviousYear: function() {
|
136
|
-
this.currentYear--;
|
137
|
-
this.drawCurrent();
|
138
|
-
},
|
139
|
-
drawNextYear: function() {
|
140
|
-
this.currentYear++;
|
141
|
-
this.drawCurrent();
|
142
|
-
}
|
143
|
-
}
|
1
|
+
/*
|
2
|
+
calendar.js - Calendar functions by Adrian Holovaty
|
3
|
+
*/
|
4
|
+
|
5
|
+
function removeChildren(a) { // "a" is reference to an object
|
6
|
+
while (a.hasChildNodes()) a.removeChild(a.lastChild);
|
7
|
+
}
|
8
|
+
|
9
|
+
// quickElement(tagType, parentReference, textInChildNode, [, attribute, attributeValue ...]);
|
10
|
+
function quickElement() {
|
11
|
+
var obj = document.createElement(arguments[0]);
|
12
|
+
if (arguments[2] != '' && arguments[2] != null) {
|
13
|
+
var textNode = document.createTextNode(arguments[2]);
|
14
|
+
obj.appendChild(textNode);
|
15
|
+
}
|
16
|
+
var len = arguments.length;
|
17
|
+
for (var i = 3; i < len; i += 2) {
|
18
|
+
obj.setAttribute(arguments[i], arguments[i+1]);
|
19
|
+
}
|
20
|
+
arguments[1].appendChild(obj);
|
21
|
+
return obj;
|
22
|
+
}
|
23
|
+
|
24
|
+
// CalendarNamespace -- Provides a collection of HTML calendar-related helper functions
|
25
|
+
var CalendarNamespace = {
|
26
|
+
monthsOfYear: gettext('January February March April May June July August September October November December').split(' '),
|
27
|
+
daysOfWeek: gettext('S M T W T F S').split(' '),
|
28
|
+
isLeapYear: function(year) {
|
29
|
+
return (((year % 4)==0) && ((year % 100)!=0) || ((year % 400)==0));
|
30
|
+
},
|
31
|
+
getDaysInMonth: function(month,year) {
|
32
|
+
var days;
|
33
|
+
if (month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12) {
|
34
|
+
days = 31;
|
35
|
+
}
|
36
|
+
else if (month==4 || month==6 || month==9 || month==11) {
|
37
|
+
days = 30;
|
38
|
+
}
|
39
|
+
else if (month==2 && CalendarNamespace.isLeapYear(year)) {
|
40
|
+
days = 29;
|
41
|
+
}
|
42
|
+
else {
|
43
|
+
days = 28;
|
44
|
+
}
|
45
|
+
return days;
|
46
|
+
},
|
47
|
+
draw: function(month, year, div_id, callback) { // month = 1-12, year = 1-9999
|
48
|
+
month = parseInt(month);
|
49
|
+
year = parseInt(year);
|
50
|
+
var calDiv = document.getElementById(div_id);
|
51
|
+
removeChildren(calDiv);
|
52
|
+
var calTable = document.createElement('table');
|
53
|
+
quickElement('caption', calTable, CalendarNamespace.monthsOfYear[month-1] + ' ' + year);
|
54
|
+
var tableBody = quickElement('tbody', calTable);
|
55
|
+
|
56
|
+
// Draw days-of-week header
|
57
|
+
var tableRow = quickElement('tr', tableBody);
|
58
|
+
for (var i = 0; i < 7; i++) {
|
59
|
+
quickElement('th', tableRow, CalendarNamespace.daysOfWeek[i]);
|
60
|
+
}
|
61
|
+
|
62
|
+
var startingPos = new Date(year, month-1, 1).getDay();
|
63
|
+
var days = CalendarNamespace.getDaysInMonth(month, year);
|
64
|
+
|
65
|
+
// Draw blanks before first of month
|
66
|
+
tableRow = quickElement('tr', tableBody);
|
67
|
+
for (var i = 0; i < startingPos; i++) {
|
68
|
+
var _cell = quickElement('td', tableRow, ' ');
|
69
|
+
_cell.style.backgroundColor = '#f3f3f3';
|
70
|
+
}
|
71
|
+
|
72
|
+
// Draw days of month
|
73
|
+
var currentDay = 1;
|
74
|
+
for (var i = startingPos; currentDay <= days; i++) {
|
75
|
+
if (i%7 == 0 && currentDay != 1) {
|
76
|
+
tableRow = quickElement('tr', tableBody);
|
77
|
+
}
|
78
|
+
var cell = quickElement('td', tableRow, '');
|
79
|
+
quickElement('a', cell, currentDay, 'href', 'javascript:void(' + callback + '('+year+','+month+','+currentDay+'));');
|
80
|
+
currentDay++;
|
81
|
+
}
|
82
|
+
|
83
|
+
// Draw blanks after end of month (optional, but makes for valid code)
|
84
|
+
while (tableRow.childNodes.length < 7) {
|
85
|
+
var _cell = quickElement('td', tableRow, ' ');
|
86
|
+
_cell.style.backgroundColor = '#f3f3f3';
|
87
|
+
}
|
88
|
+
|
89
|
+
calDiv.appendChild(calTable);
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
// Calendar -- A calendar instance
|
94
|
+
function Calendar(div_id, callback) {
|
95
|
+
// div_id (string) is the ID of the element in which the calendar will
|
96
|
+
// be displayed
|
97
|
+
// callback (string) is the name of a JavaScript function that will be
|
98
|
+
// called with the parameters (year, month, day) when a day in the
|
99
|
+
// calendar is clicked
|
100
|
+
this.div_id = div_id;
|
101
|
+
this.callback = callback;
|
102
|
+
this.today = new Date();
|
103
|
+
this.currentMonth = this.today.getMonth() + 1;
|
104
|
+
this.currentYear = this.today.getFullYear();
|
105
|
+
}
|
106
|
+
Calendar.prototype = {
|
107
|
+
drawCurrent: function() {
|
108
|
+
CalendarNamespace.draw(this.currentMonth, this.currentYear, this.div_id, this.callback);
|
109
|
+
},
|
110
|
+
drawDate: function(month, year) {
|
111
|
+
this.currentMonth = month;
|
112
|
+
this.currentYear = year;
|
113
|
+
this.drawCurrent();
|
114
|
+
},
|
115
|
+
drawPreviousMonth: function() {
|
116
|
+
if (this.currentMonth == 1) {
|
117
|
+
this.currentMonth = 12;
|
118
|
+
this.currentYear--;
|
119
|
+
}
|
120
|
+
else {
|
121
|
+
this.currentMonth--;
|
122
|
+
}
|
123
|
+
this.drawCurrent();
|
124
|
+
},
|
125
|
+
drawNextMonth: function() {
|
126
|
+
if (this.currentMonth == 12) {
|
127
|
+
this.currentMonth = 1;
|
128
|
+
this.currentYear++;
|
129
|
+
}
|
130
|
+
else {
|
131
|
+
this.currentMonth++;
|
132
|
+
}
|
133
|
+
this.drawCurrent();
|
134
|
+
},
|
135
|
+
drawPreviousYear: function() {
|
136
|
+
this.currentYear--;
|
137
|
+
this.drawCurrent();
|
138
|
+
},
|
139
|
+
drawNextYear: function() {
|
140
|
+
this.currentYear++;
|
141
|
+
this.drawCurrent();
|
142
|
+
}
|
143
|
+
}
|
data/public/javascripts/core.js
CHANGED
@@ -1,176 +1,176 @@
|
|
1
|
-
// Core javascript helper functions
|
2
|
-
|
3
|
-
// basic browser identification & version
|
4
|
-
var isOpera = (navigator.userAgent.indexOf("Opera")>=0) && parseFloat(navigator.appVersion);
|
5
|
-
var isIE = ((document.all) && (!isOpera)) && parseFloat(navigator.appVersion.split("MSIE ")[1].split(";")[0]);
|
6
|
-
|
7
|
-
// Cross-browser event handlers.
|
8
|
-
function addEvent(obj, evType, fn) {
|
9
|
-
if (obj.addEventListener) {
|
10
|
-
obj.addEventListener(evType, fn, false);
|
11
|
-
return true;
|
12
|
-
} else if (obj.attachEvent) {
|
13
|
-
var r = obj.attachEvent("on" + evType, fn);
|
14
|
-
return r;
|
15
|
-
} else {
|
16
|
-
return false;
|
17
|
-
}
|
18
|
-
}
|
19
|
-
|
20
|
-
function removeEvent(obj, evType, fn) {
|
21
|
-
if (obj.removeEventListener) {
|
22
|
-
obj.removeEventListener(evType, fn, false);
|
23
|
-
return true;
|
24
|
-
} else if (obj.detachEvent) {
|
25
|
-
obj.detachEvent("on" + evType, fn);
|
26
|
-
return true;
|
27
|
-
} else {
|
28
|
-
return false;
|
29
|
-
}
|
30
|
-
}
|
31
|
-
|
32
|
-
// quickElement(tagType, parentReference, textInChildNode, [, attribute, attributeValue ...]);
|
33
|
-
function quickElement() {
|
34
|
-
var obj = document.createElement(arguments[0]);
|
35
|
-
if (arguments[2] != '' && arguments[2] != null) {
|
36
|
-
var textNode = document.createTextNode(arguments[2]);
|
37
|
-
obj.appendChild(textNode);
|
38
|
-
}
|
39
|
-
var len = arguments.length;
|
40
|
-
for (var i = 3; i < len; i += 2) {
|
41
|
-
obj.setAttribute(arguments[i], arguments[i+1]);
|
42
|
-
}
|
43
|
-
arguments[1].appendChild(obj);
|
44
|
-
return obj;
|
45
|
-
}
|
46
|
-
|
47
|
-
// ----------------------------------------------------------------------------
|
48
|
-
// Cross-browser xmlhttp object
|
49
|
-
// from http://jibbering.com/2002/4/httprequest.html
|
50
|
-
// ----------------------------------------------------------------------------
|
51
|
-
var xmlhttp;
|
52
|
-
/*@cc_on @*/
|
53
|
-
/*@if (@_jscript_version >= 5)
|
54
|
-
try {
|
55
|
-
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
|
56
|
-
} catch (e) {
|
57
|
-
try {
|
58
|
-
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
|
59
|
-
} catch (E) {
|
60
|
-
xmlhttp = false;
|
61
|
-
}
|
62
|
-
}
|
63
|
-
@else
|
64
|
-
xmlhttp = false;
|
65
|
-
@end @*/
|
66
|
-
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
|
67
|
-
xmlhttp = new XMLHttpRequest();
|
68
|
-
}
|
69
|
-
|
70
|
-
// ----------------------------------------------------------------------------
|
71
|
-
// Find-position functions by PPK
|
72
|
-
// See http://www.quirksmode.org/js/findpos.html
|
73
|
-
// ----------------------------------------------------------------------------
|
74
|
-
function findPosX(obj) {
|
75
|
-
var curleft = 0;
|
76
|
-
if (obj.offsetParent) {
|
77
|
-
while (obj.offsetParent) {
|
78
|
-
curleft += obj.offsetLeft - ((isOpera) ? 0 : obj.scrollLeft);
|
79
|
-
obj = obj.offsetParent;
|
80
|
-
}
|
81
|
-
// IE offsetParent does not include the top-level
|
82
|
-
if (isIE && obj.parentElement){
|
83
|
-
curleft += obj.offsetLeft - obj.scrollLeft;
|
84
|
-
}
|
85
|
-
} else if (obj.x) {
|
86
|
-
curleft += obj.x;
|
87
|
-
}
|
88
|
-
return curleft;
|
89
|
-
}
|
90
|
-
|
91
|
-
function findPosY(obj) {
|
92
|
-
var curtop = 0;
|
93
|
-
if (obj.offsetParent) {
|
94
|
-
while (obj.offsetParent) {
|
95
|
-
curtop += obj.offsetTop - ((isOpera) ? 0 : obj.scrollTop);
|
96
|
-
obj = obj.offsetParent;
|
97
|
-
}
|
98
|
-
// IE offsetParent does not include the top-level
|
99
|
-
if (isIE && obj.parentElement){
|
100
|
-
curtop += obj.offsetTop - obj.scrollTop;
|
101
|
-
}
|
102
|
-
} else if (obj.y) {
|
103
|
-
curtop += obj.y;
|
104
|
-
}
|
105
|
-
return curtop;
|
106
|
-
}
|
107
|
-
|
108
|
-
//-----------------------------------------------------------------------------
|
109
|
-
// Date object extensions
|
110
|
-
// ----------------------------------------------------------------------------
|
111
|
-
Date.prototype.getCorrectYear = function() {
|
112
|
-
// Date.getYear() is unreliable --
|
113
|
-
// see http://www.quirksmode.org/js/introdate.html#year
|
114
|
-
var y = this.getYear() % 100;
|
115
|
-
return (y < 38) ? y + 2000 : y + 1900;
|
116
|
-
}
|
117
|
-
|
118
|
-
Date.prototype.getTwoDigitMonth = function() {
|
119
|
-
return (this.getMonth() < 9) ? '0' + (this.getMonth()+1) : (this.getMonth()+1);
|
120
|
-
}
|
121
|
-
|
122
|
-
Date.prototype.getTwoDigitDate = function() {
|
123
|
-
return (this.getDate() < 10) ? '0' + this.getDate() : this.getDate();
|
124
|
-
}
|
125
|
-
|
126
|
-
Date.prototype.getTwoDigitHour = function() {
|
127
|
-
return (this.getHours() < 10) ? '0' + this.getHours() : this.getHours();
|
128
|
-
}
|
129
|
-
|
130
|
-
Date.prototype.getTwoDigitMinute = function() {
|
131
|
-
return (this.getMinutes() < 10) ? '0' + this.getMinutes() : this.getMinutes();
|
132
|
-
}
|
133
|
-
|
134
|
-
Date.prototype.getTwoDigitSecond = function() {
|
135
|
-
return (this.getSeconds() < 10) ? '0' + this.getSeconds() : this.getSeconds();
|
136
|
-
}
|
137
|
-
|
138
|
-
Date.prototype.getISODate = function() {
|
139
|
-
return this.getCorrectYear() + '-' + this.getTwoDigitMonth() + '-' + this.getTwoDigitDate();
|
140
|
-
}
|
141
|
-
|
142
|
-
Date.prototype.getHourMinute = function() {
|
143
|
-
return this.getTwoDigitHour() + ':' + this.getTwoDigitMinute();
|
144
|
-
}
|
145
|
-
|
146
|
-
Date.prototype.getHourMinuteSecond = function() {
|
147
|
-
return this.getTwoDigitHour() + ':' + this.getTwoDigitMinute() + ':' + this.getTwoDigitSecond();
|
148
|
-
}
|
149
|
-
|
150
|
-
// ----------------------------------------------------------------------------
|
151
|
-
// String object extensions
|
152
|
-
// ----------------------------------------------------------------------------
|
153
|
-
String.prototype.pad_left = function(pad_length, pad_string) {
|
154
|
-
var new_string = this;
|
155
|
-
for (var i = 0; new_string.length < pad_length; i++) {
|
156
|
-
new_string = pad_string + new_string;
|
157
|
-
}
|
158
|
-
return new_string;
|
159
|
-
}
|
160
|
-
|
161
|
-
// ----------------------------------------------------------------------------
|
162
|
-
// Get the computed style for and element
|
163
|
-
// ----------------------------------------------------------------------------
|
164
|
-
function getStyle(oElm, strCssRule){
|
165
|
-
var strValue = "";
|
166
|
-
if(document.defaultView && document.defaultView.getComputedStyle){
|
167
|
-
strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
|
168
|
-
}
|
169
|
-
else if(oElm.currentStyle){
|
170
|
-
strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
|
171
|
-
return p1.toUpperCase();
|
172
|
-
});
|
173
|
-
strValue = oElm.currentStyle[strCssRule];
|
174
|
-
}
|
175
|
-
return strValue;
|
176
|
-
}
|
1
|
+
// Core javascript helper functions
|
2
|
+
|
3
|
+
// basic browser identification & version
|
4
|
+
var isOpera = (navigator.userAgent.indexOf("Opera")>=0) && parseFloat(navigator.appVersion);
|
5
|
+
var isIE = ((document.all) && (!isOpera)) && parseFloat(navigator.appVersion.split("MSIE ")[1].split(";")[0]);
|
6
|
+
|
7
|
+
// Cross-browser event handlers.
|
8
|
+
function addEvent(obj, evType, fn) {
|
9
|
+
if (obj.addEventListener) {
|
10
|
+
obj.addEventListener(evType, fn, false);
|
11
|
+
return true;
|
12
|
+
} else if (obj.attachEvent) {
|
13
|
+
var r = obj.attachEvent("on" + evType, fn);
|
14
|
+
return r;
|
15
|
+
} else {
|
16
|
+
return false;
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
function removeEvent(obj, evType, fn) {
|
21
|
+
if (obj.removeEventListener) {
|
22
|
+
obj.removeEventListener(evType, fn, false);
|
23
|
+
return true;
|
24
|
+
} else if (obj.detachEvent) {
|
25
|
+
obj.detachEvent("on" + evType, fn);
|
26
|
+
return true;
|
27
|
+
} else {
|
28
|
+
return false;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
// quickElement(tagType, parentReference, textInChildNode, [, attribute, attributeValue ...]);
|
33
|
+
function quickElement() {
|
34
|
+
var obj = document.createElement(arguments[0]);
|
35
|
+
if (arguments[2] != '' && arguments[2] != null) {
|
36
|
+
var textNode = document.createTextNode(arguments[2]);
|
37
|
+
obj.appendChild(textNode);
|
38
|
+
}
|
39
|
+
var len = arguments.length;
|
40
|
+
for (var i = 3; i < len; i += 2) {
|
41
|
+
obj.setAttribute(arguments[i], arguments[i+1]);
|
42
|
+
}
|
43
|
+
arguments[1].appendChild(obj);
|
44
|
+
return obj;
|
45
|
+
}
|
46
|
+
|
47
|
+
// ----------------------------------------------------------------------------
|
48
|
+
// Cross-browser xmlhttp object
|
49
|
+
// from http://jibbering.com/2002/4/httprequest.html
|
50
|
+
// ----------------------------------------------------------------------------
|
51
|
+
var xmlhttp;
|
52
|
+
/*@cc_on @*/
|
53
|
+
/*@if (@_jscript_version >= 5)
|
54
|
+
try {
|
55
|
+
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
|
56
|
+
} catch (e) {
|
57
|
+
try {
|
58
|
+
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
|
59
|
+
} catch (E) {
|
60
|
+
xmlhttp = false;
|
61
|
+
}
|
62
|
+
}
|
63
|
+
@else
|
64
|
+
xmlhttp = false;
|
65
|
+
@end @*/
|
66
|
+
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
|
67
|
+
xmlhttp = new XMLHttpRequest();
|
68
|
+
}
|
69
|
+
|
70
|
+
// ----------------------------------------------------------------------------
|
71
|
+
// Find-position functions by PPK
|
72
|
+
// See http://www.quirksmode.org/js/findpos.html
|
73
|
+
// ----------------------------------------------------------------------------
|
74
|
+
function findPosX(obj) {
|
75
|
+
var curleft = 0;
|
76
|
+
if (obj.offsetParent) {
|
77
|
+
while (obj.offsetParent) {
|
78
|
+
curleft += obj.offsetLeft - ((isOpera) ? 0 : obj.scrollLeft);
|
79
|
+
obj = obj.offsetParent;
|
80
|
+
}
|
81
|
+
// IE offsetParent does not include the top-level
|
82
|
+
if (isIE && obj.parentElement){
|
83
|
+
curleft += obj.offsetLeft - obj.scrollLeft;
|
84
|
+
}
|
85
|
+
} else if (obj.x) {
|
86
|
+
curleft += obj.x;
|
87
|
+
}
|
88
|
+
return curleft;
|
89
|
+
}
|
90
|
+
|
91
|
+
function findPosY(obj) {
|
92
|
+
var curtop = 0;
|
93
|
+
if (obj.offsetParent) {
|
94
|
+
while (obj.offsetParent) {
|
95
|
+
curtop += obj.offsetTop - ((isOpera) ? 0 : obj.scrollTop);
|
96
|
+
obj = obj.offsetParent;
|
97
|
+
}
|
98
|
+
// IE offsetParent does not include the top-level
|
99
|
+
if (isIE && obj.parentElement){
|
100
|
+
curtop += obj.offsetTop - obj.scrollTop;
|
101
|
+
}
|
102
|
+
} else if (obj.y) {
|
103
|
+
curtop += obj.y;
|
104
|
+
}
|
105
|
+
return curtop;
|
106
|
+
}
|
107
|
+
|
108
|
+
//-----------------------------------------------------------------------------
|
109
|
+
// Date object extensions
|
110
|
+
// ----------------------------------------------------------------------------
|
111
|
+
Date.prototype.getCorrectYear = function() {
|
112
|
+
// Date.getYear() is unreliable --
|
113
|
+
// see http://www.quirksmode.org/js/introdate.html#year
|
114
|
+
var y = this.getYear() % 100;
|
115
|
+
return (y < 38) ? y + 2000 : y + 1900;
|
116
|
+
}
|
117
|
+
|
118
|
+
Date.prototype.getTwoDigitMonth = function() {
|
119
|
+
return (this.getMonth() < 9) ? '0' + (this.getMonth()+1) : (this.getMonth()+1);
|
120
|
+
}
|
121
|
+
|
122
|
+
Date.prototype.getTwoDigitDate = function() {
|
123
|
+
return (this.getDate() < 10) ? '0' + this.getDate() : this.getDate();
|
124
|
+
}
|
125
|
+
|
126
|
+
Date.prototype.getTwoDigitHour = function() {
|
127
|
+
return (this.getHours() < 10) ? '0' + this.getHours() : this.getHours();
|
128
|
+
}
|
129
|
+
|
130
|
+
Date.prototype.getTwoDigitMinute = function() {
|
131
|
+
return (this.getMinutes() < 10) ? '0' + this.getMinutes() : this.getMinutes();
|
132
|
+
}
|
133
|
+
|
134
|
+
Date.prototype.getTwoDigitSecond = function() {
|
135
|
+
return (this.getSeconds() < 10) ? '0' + this.getSeconds() : this.getSeconds();
|
136
|
+
}
|
137
|
+
|
138
|
+
Date.prototype.getISODate = function() {
|
139
|
+
return this.getCorrectYear() + '-' + this.getTwoDigitMonth() + '-' + this.getTwoDigitDate();
|
140
|
+
}
|
141
|
+
|
142
|
+
Date.prototype.getHourMinute = function() {
|
143
|
+
return this.getTwoDigitHour() + ':' + this.getTwoDigitMinute();
|
144
|
+
}
|
145
|
+
|
146
|
+
Date.prototype.getHourMinuteSecond = function() {
|
147
|
+
return this.getTwoDigitHour() + ':' + this.getTwoDigitMinute() + ':' + this.getTwoDigitSecond();
|
148
|
+
}
|
149
|
+
|
150
|
+
// ----------------------------------------------------------------------------
|
151
|
+
// String object extensions
|
152
|
+
// ----------------------------------------------------------------------------
|
153
|
+
String.prototype.pad_left = function(pad_length, pad_string) {
|
154
|
+
var new_string = this;
|
155
|
+
for (var i = 0; new_string.length < pad_length; i++) {
|
156
|
+
new_string = pad_string + new_string;
|
157
|
+
}
|
158
|
+
return new_string;
|
159
|
+
}
|
160
|
+
|
161
|
+
// ----------------------------------------------------------------------------
|
162
|
+
// Get the computed style for and element
|
163
|
+
// ----------------------------------------------------------------------------
|
164
|
+
function getStyle(oElm, strCssRule){
|
165
|
+
var strValue = "";
|
166
|
+
if(document.defaultView && document.defaultView.getComputedStyle){
|
167
|
+
strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
|
168
|
+
}
|
169
|
+
else if(oElm.currentStyle){
|
170
|
+
strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
|
171
|
+
return p1.toUpperCase();
|
172
|
+
});
|
173
|
+
strValue = oElm.currentStyle[strCssRule];
|
174
|
+
}
|
175
|
+
return strValue;
|
176
|
+
}
|