mirror of https://github.com/django/django.git
Fixed #1426 -- Made several admin JavaScript improvements. Thanks, anonymous
git-svn-id: http://code.djangoproject.com/svn/django/trunk@2448 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
4a608b48c5
commit
3daf7bde2e
|
@ -3,11 +3,11 @@
|
||||||
|
|
||||||
function showRelatedObjectLookupPopup(triggeringLink) {
|
function showRelatedObjectLookupPopup(triggeringLink) {
|
||||||
var name = triggeringLink.id.replace(/^lookup_/, '');
|
var name = triggeringLink.id.replace(/^lookup_/, '');
|
||||||
var href
|
var href;
|
||||||
if (triggeringLink.href.search(/\?/) >= 0) {
|
if (triggeringLink.href.search(/\?/) >= 0) {
|
||||||
href = triggeringLink.href + '&pop=1';
|
href = triggeringLink.href + '&pop=1';
|
||||||
} else {
|
} else {
|
||||||
href = triggeringLink.href + '?pop=1'
|
href = triggeringLink.href + '?pop=1';
|
||||||
}
|
}
|
||||||
var win = window.open(href, name, 'height=500,width=740,resizable=yes,scrollbars=yes');
|
var win = window.open(href, name, 'height=500,width=740,resizable=yes,scrollbars=yes');
|
||||||
win.focus();
|
win.focus();
|
||||||
|
@ -33,12 +33,12 @@ function showAddAnotherPopup(triggeringLink) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function dismissAddAnotherPopup(win, newId, newRepr) {
|
function dismissAddAnotherPopup(win, newId, newRepr) {
|
||||||
var name = win.name.replace(/___/g, '.')
|
var name = win.name.replace(/___/g, '.');
|
||||||
var elem = document.getElementById(name);
|
var elem = document.getElementById(name);
|
||||||
if (elem) {
|
if (elem) {
|
||||||
if (elem.nodeName == 'SELECT') {
|
if (elem.nodeName == 'SELECT') {
|
||||||
var o = new Option(newRepr, newId);
|
var o = new Option(newRepr, newId);
|
||||||
elem.options[elem.options.length] = o
|
elem.options[elem.options.length] = o;
|
||||||
elem.selectedIndex = elem.length - 1;
|
elem.selectedIndex = elem.length - 1;
|
||||||
} else if (elem.nodeName == 'INPUT') {
|
} else if (elem.nodeName == 'INPUT') {
|
||||||
elem.value = newId;
|
elem.value = newId;
|
||||||
|
|
|
@ -102,15 +102,17 @@ function Calendar(div_id, callback) {
|
||||||
this.today = new Date();
|
this.today = new Date();
|
||||||
this.currentMonth = this.today.getMonth() + 1;
|
this.currentMonth = this.today.getMonth() + 1;
|
||||||
this.currentYear = this.today.getFullYear();
|
this.currentYear = this.today.getFullYear();
|
||||||
this.drawCurrent = function() {
|
}
|
||||||
|
Calendar.prototype = {
|
||||||
|
drawCurrent: function() {
|
||||||
CalendarNamespace.draw(this.currentMonth, this.currentYear, this.div_id, this.callback);
|
CalendarNamespace.draw(this.currentMonth, this.currentYear, this.div_id, this.callback);
|
||||||
}
|
},
|
||||||
this.drawDate = function(month, year) {
|
drawDate: function(month, year) {
|
||||||
this.currentMonth = month;
|
this.currentMonth = month;
|
||||||
this.currentYear = year;
|
this.currentYear = year;
|
||||||
this.drawCurrent();
|
this.drawCurrent();
|
||||||
}
|
},
|
||||||
this.drawPreviousMonth = function() {
|
drawPreviousMonth: function() {
|
||||||
if (this.currentMonth == 1) {
|
if (this.currentMonth == 1) {
|
||||||
this.currentMonth = 12;
|
this.currentMonth = 12;
|
||||||
this.currentYear--;
|
this.currentYear--;
|
||||||
|
@ -119,8 +121,8 @@ function Calendar(div_id, callback) {
|
||||||
this.currentMonth--;
|
this.currentMonth--;
|
||||||
}
|
}
|
||||||
this.drawCurrent();
|
this.drawCurrent();
|
||||||
}
|
},
|
||||||
this.drawNextMonth = function() {
|
drawNextMonth: function() {
|
||||||
if (this.currentMonth == 12) {
|
if (this.currentMonth == 12) {
|
||||||
this.currentMonth = 1;
|
this.currentMonth = 1;
|
||||||
this.currentYear++;
|
this.currentYear++;
|
||||||
|
@ -129,12 +131,12 @@ function Calendar(div_id, callback) {
|
||||||
this.currentMonth++;
|
this.currentMonth++;
|
||||||
}
|
}
|
||||||
this.drawCurrent();
|
this.drawCurrent();
|
||||||
}
|
},
|
||||||
this.drawPreviousYear = function() {
|
drawPreviousYear: function() {
|
||||||
this.currentYear--;
|
this.currentYear--;
|
||||||
this.drawCurrent();
|
this.drawCurrent();
|
||||||
}
|
},
|
||||||
this.drawNextYear = function() {
|
drawNextYear: function() {
|
||||||
this.currentYear++;
|
this.currentYear++;
|
||||||
this.drawCurrent();
|
this.drawCurrent();
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ function findPosX(obj) {
|
||||||
var curleft = 0;
|
var curleft = 0;
|
||||||
if (obj.offsetParent) {
|
if (obj.offsetParent) {
|
||||||
while (obj.offsetParent) {
|
while (obj.offsetParent) {
|
||||||
curleft += obj.offsetLeft
|
curleft += obj.offsetLeft;
|
||||||
obj = obj.offsetParent;
|
obj = obj.offsetParent;
|
||||||
}
|
}
|
||||||
} else if (obj.x) {
|
} else if (obj.x) {
|
||||||
|
@ -83,7 +83,7 @@ function findPosY(obj) {
|
||||||
var curtop = 0;
|
var curtop = 0;
|
||||||
if (obj.offsetParent) {
|
if (obj.offsetParent) {
|
||||||
while (obj.offsetParent) {
|
while (obj.offsetParent) {
|
||||||
curtop += obj.offsetTop
|
curtop += obj.offsetTop;
|
||||||
obj = obj.offsetParent;
|
obj = obj.offsetParent;
|
||||||
}
|
}
|
||||||
} else if (obj.y) {
|
} else if (obj.y) {
|
||||||
|
@ -130,7 +130,7 @@ Date.prototype.getHourMinute = function() {
|
||||||
// String object extensions
|
// String object extensions
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
String.prototype.pad_left = function(pad_length, pad_string) {
|
String.prototype.pad_left = function(pad_length, pad_string) {
|
||||||
new_string = this;
|
var new_string = this;
|
||||||
for (var i = 0; new_string.length < pad_length; i++) {
|
for (var i = 0; new_string.length < pad_length; i++) {
|
||||||
new_string = pad_string + new_string;
|
new_string = pad_string + new_string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,24 +4,30 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Finds the index of the first occurence of item in the array, or -1 if not found */
|
/* Finds the index of the first occurence of item in the array, or -1 if not found */
|
||||||
Array.prototype.indexOf = function(item) {
|
if (typeof Array.prototype.indexOf == 'undefined') {
|
||||||
for (var i = 0; i < this.length; i++) {
|
Array.prototype.indexOf = function(item) {
|
||||||
if (this[i] == item) {
|
var len = this.length;
|
||||||
return i;
|
for (var i = 0; i < len; i++) {
|
||||||
|
if (this[i] == item) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
return -1;
|
||||||
return -1;
|
};
|
||||||
};
|
}
|
||||||
/* Returns an array of items judged 'true' by the passed in test function */
|
/* Returns an array of items judged 'true' by the passed in test function */
|
||||||
Array.prototype.filter = function(test) {
|
if (typeof Array.prototype.filter == 'undefined') {
|
||||||
var matches = [];
|
Array.prototype.filter = function(test) {
|
||||||
for (var i = 0; i < this.length; i++) {
|
var matches = [];
|
||||||
if (test(this[i])) {
|
var len = this.length;
|
||||||
matches[matches.length] = this[i];
|
for (var i = 0; i < len; i++) {
|
||||||
|
if (test(this[i])) {
|
||||||
|
matches[matches.length] = this[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
return matches;
|
||||||
return matches;
|
};
|
||||||
};
|
}
|
||||||
|
|
||||||
var monthNames = gettext("January February March April May June July August September October November December").split(" ");
|
var monthNames = gettext("January February March April May June July August September October November December").split(" ");
|
||||||
var weekdayNames = gettext("Sunday Monday Tuesday Wednesday Thursday Friday Saturday").split(" ");
|
var weekdayNames = gettext("Sunday Monday Tuesday Wednesday Thursday Friday Saturday").split(" ");
|
||||||
|
|
Loading…
Reference in New Issue