Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #1426 -- Made several admin JavaScript improvements. Thanks, an…

…onymous

git-svn-id: http://code.djangoproject.com/svn/django/trunk@2448 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 3daf7bde2e150c623b80a3a0518196121bd4ea36 1 parent 4a608b4
Adrian Holovaty authored March 01, 2006
8  django/contrib/admin/media/js/admin/RelatedObjectLookups.js
@@ -3,11 +3,11 @@
3 3
 
4 4
 function showRelatedObjectLookupPopup(triggeringLink) {
5 5
     var name = triggeringLink.id.replace(/^lookup_/, '');
6  
-    var href
  6
+    var href;
7 7
     if (triggeringLink.href.search(/\?/) >= 0) {
8 8
         href = triggeringLink.href + '&pop=1';
9 9
     } else {
10  
-        href = triggeringLink.href + '?pop=1'
  10
+        href = triggeringLink.href + '?pop=1';
11 11
     }
12 12
     var win = window.open(href, name, 'height=500,width=740,resizable=yes,scrollbars=yes');
13 13
     win.focus();
@@ -33,12 +33,12 @@ function showAddAnotherPopup(triggeringLink) {
33 33
 }
34 34
 
35 35
 function dismissAddAnotherPopup(win, newId, newRepr) {
36  
-    var name = win.name.replace(/___/g, '.')
  36
+    var name = win.name.replace(/___/g, '.');
37 37
     var elem = document.getElementById(name);
38 38
     if (elem) {
39 39
         if (elem.nodeName == 'SELECT') {
40 40
             var o = new Option(newRepr, newId);
41  
-            elem.options[elem.options.length] = o
  41
+            elem.options[elem.options.length] = o;
42 42
             elem.selectedIndex = elem.length - 1;
43 43
         } else if (elem.nodeName == 'INPUT') {
44 44
             elem.value = newId;
24  django/contrib/admin/media/js/calendar.js
@@ -102,15 +102,17 @@ function Calendar(div_id, callback) {
102 102
     this.today = new Date();
103 103
     this.currentMonth = this.today.getMonth() + 1;
104 104
     this.currentYear = this.today.getFullYear();
105  
-    this.drawCurrent = function() {
  105
+}
  106
+Calendar.prototype = {
  107
+    drawCurrent: function() {
106 108
         CalendarNamespace.draw(this.currentMonth, this.currentYear, this.div_id, this.callback);
107  
-    }
108  
-    this.drawDate = function(month, year) {
  109
+    },
  110
+    drawDate: function(month, year) {
109 111
         this.currentMonth = month;
110 112
         this.currentYear = year;
111 113
         this.drawCurrent();
112  
-    }
113  
-    this.drawPreviousMonth = function() {
  114
+    },
  115
+    drawPreviousMonth: function() {
114 116
         if (this.currentMonth == 1) {
115 117
             this.currentMonth = 12;
116 118
             this.currentYear--;
@@ -119,8 +121,8 @@ function Calendar(div_id, callback) {
119 121
             this.currentMonth--;
120 122
         }
121 123
         this.drawCurrent();
122  
-    }
123  
-    this.drawNextMonth = function() {
  124
+    },
  125
+    drawNextMonth: function() {
124 126
         if (this.currentMonth == 12) {
125 127
             this.currentMonth = 1;
126 128
             this.currentYear++;
@@ -129,12 +131,12 @@ function Calendar(div_id, callback) {
129 131
             this.currentMonth++;
130 132
         }
131 133
         this.drawCurrent();
132  
-    }
133  
-    this.drawPreviousYear = function() {
  134
+    },
  135
+    drawPreviousYear: function() {
134 136
         this.currentYear--;
135 137
         this.drawCurrent();
136  
-    }
137  
-    this.drawNextYear = function() {
  138
+    },
  139
+    drawNextYear: function() {
138 140
         this.currentYear++;
139 141
         this.drawCurrent();
140 142
     }
6  django/contrib/admin/media/js/core.js
@@ -70,7 +70,7 @@ function findPosX(obj) {
70 70
     var curleft = 0;
71 71
     if (obj.offsetParent) {
72 72
         while (obj.offsetParent) {
73  
-            curleft += obj.offsetLeft
  73
+            curleft += obj.offsetLeft;
74 74
             obj = obj.offsetParent;
75 75
         }
76 76
     } else if (obj.x) {
@@ -83,7 +83,7 @@ function findPosY(obj) {
83 83
     var curtop = 0;
84 84
     if (obj.offsetParent) {
85 85
         while (obj.offsetParent) {
86  
-            curtop += obj.offsetTop
  86
+            curtop += obj.offsetTop;
87 87
             obj = obj.offsetParent;
88 88
         }
89 89
     } else if (obj.y) {
@@ -130,7 +130,7 @@ Date.prototype.getHourMinute = function() {
130 130
 // String object extensions
131 131
 // ----------------------------------------------------------------------------
132 132
 String.prototype.pad_left = function(pad_length, pad_string) {
133  
-    new_string = this;
  133
+    var new_string = this;
134 134
     for (var i = 0; new_string.length < pad_length; i++) {
135 135
         new_string = pad_string + new_string;
136 136
     }
36  django/contrib/admin/media/js/dateparse.js
@@ -4,24 +4,30 @@
4 4
 */
5 5
 
6 6
 /* Finds the index of the first occurence of item in the array, or -1 if not found */
7  
-Array.prototype.indexOf = function(item) {
8  
-    for (var i = 0; i < this.length; i++) {
9  
-        if (this[i] == item) {
10  
-            return i;
  7
+if (typeof Array.prototype.indexOf == 'undefined') {
  8
+    Array.prototype.indexOf = function(item) {
  9
+        var len = this.length;
  10
+        for (var i = 0; i < len; i++) {
  11
+            if (this[i] == item) {
  12
+                return i;
  13
+            }
11 14
         }
12  
-    }
13  
-    return -1;
14  
-};
  15
+        return -1;
  16
+    };
  17
+}
15 18
 /* Returns an array of items judged 'true' by the passed in test function */
16  
-Array.prototype.filter = function(test) {
17  
-    var matches = [];
18  
-    for (var i = 0; i < this.length; i++) {
19  
-        if (test(this[i])) {
20  
-            matches[matches.length] = this[i];
  19
+if (typeof Array.prototype.filter == 'undefined') {
  20
+    Array.prototype.filter = function(test) {
  21
+        var matches = [];
  22
+        var len = this.length;
  23
+        for (var i = 0; i < len; i++) {
  24
+            if (test(this[i])) {
  25
+                matches[matches.length] = this[i];
  26
+            }
21 27
         }
22  
-    }
23  
-    return matches;
24  
-};
  28
+        return matches;
  29
+    };
  30
+}
25 31
 
26 32
 var monthNames = gettext("January February March April May June July August September October November December").split(" ");
27 33
 var weekdayNames = gettext("Sunday Monday Tuesday Wednesday Thursday Friday Saturday").split(" ");

0 notes on commit 3daf7bd

Please sign in to comment.
Something went wrong with that request. Please try again.