Code

Ticket #16212: 16212.better-admin-multiple-sort.diff

File 16212.better-admin-multiple-sort.diff, 8.5 KB (added by julien, 3 years ago)
Line 
1diff --git a/django/contrib/admin/media/css/base.css b/django/contrib/admin/media/css/base.css
2index 6d1b673..a3c68be 100644
3--- a/django/contrib/admin/media/css/base.css
4+++ b/django/contrib/admin/media/css/base.css
5@@ -305,38 +305,49 @@ tr.alt {
6 
7 /* SORTABLE TABLES */
8 
9+thead th {
10+    padding: 0;
11+    line-height: normal;
12+}
13+
14 thead th a:link, thead th a:visited {
15     color: #666;
16-    display: block;
17+}
18+
19+thead th a.sortremove {
20+    display: none; /* Hide by default */
21 }
22 
23 thead th.sorted {
24     background: #c5c5c5 url(../img/admin/nav-bg-selected.gif) top left repeat-x;
25 }
26 
27-table thead th.sorted a {
28-    padding-right: 13px;
29+table thead th .text a {
30+   display: block;
31+   padding: 2px 5px;
32+   cursor: pointer; /* IE needs this */
33 }
34 
35-table thead th.ascending a {
36-    background: url(../img/admin/arrow-up.gif) right .4em no-repeat;
37+table thead th .text a:hover {
38+   background-color: #ffffcc;
39 }
40 
41-table thead th.descending a {
42-    background: url(../img/admin/arrow-down.gif) right .4em no-repeat;
43+table thead th.sorted .sortoptions {
44+   display: block;
45+   padding: 2px 5px;
46+   float: right;
47+   text-align: right;
48 }
49 
50-table thead th.sorted a span.text {
51-   display: block;
52-   float: left;
53-   cursor: pointer; /* IE needs this */
54+table thead th.sorted img#primary-sort-icon {
55+    cursor: pointer;
56 }
57 
58-table thead th.sorted a span.sortpos {
59-   display: block;
60-   float: right;
61-   font-size: .6em;
62-   text-align: right;
63+table thead th.sorted .sortposition {
64+   font-size: .8em;
65+   min-width: 12px;
66+   text-align: center;
67+   display:inline-block;
68    cursor: pointer; /* IE needs this */
69 }
70 
71@@ -344,7 +355,7 @@ table thead th.sorted a img {
72    vertical-align: top;
73 }
74 
75-table thead th.sorted a span.clear {
76+table thead th.sorted a .clear {
77    display: block;
78    clear: both;
79 }
80diff --git a/django/contrib/admin/media/css/rtl.css b/django/contrib/admin/media/css/rtl.css
81index ec2bb2a..f433a4f 100644
82--- a/django/contrib/admin/media/css/rtl.css
83+++ b/django/contrib/admin/media/css/rtl.css
84@@ -80,22 +80,7 @@ div.breadcrumbs {
85 
86 /* SORTABLE TABLES */
87 
88-
89-table thead th.sorted a {
90-    padding-left: 13px;
91-    padding-right: 0px;
92-}
93-
94-table thead th.ascending a,
95-table thead th.descending a {
96-    background-position: left;
97-}
98-
99-table thead th.sorted a span.text {
100-   float: right;
101-}
102-
103-table thead th.sorted a span.sortpos {
104+table thead th.sorted .sortoptions {
105    float: left;
106 }
107 
108@@ -260,4 +245,4 @@ div.colM {
109 
110 .submit-row input {
111     float: left;
112-}
113\ No newline at end of file
114+}
115diff --git a/django/contrib/admin/media/img/admin/arrow-down-hover.gif b/django/contrib/admin/media/img/admin/arrow-down-hover.gif
116new file mode 100644
117index 0000000000000000000000000000000000000000..30d63d61788f7cc03d18f1516738b11f89cdf36f
118GIT binary patch
119literal 69
120zcmZ?wbh9u|<Y(Yvn8?5o*tzh<ix&)Fp!k!8k%57UK?lSG$ulsCP3d2Gx|Tti$IB~9
121RH|~1pOUY=DX?~0h)&ML^5a$2@
122
123literal 0
124HcmV?d00001
125
126diff --git a/django/contrib/admin/media/img/admin/arrow-down.gif b/django/contrib/admin/media/img/admin/arrow-down.gif
127index a967b9fd5563a0fc2f5fde8ec0f7de3fc8fbc5a9..1161248023ee7d02f6bdc9eb0f4185cf6c1280ac 100644
128GIT binary patch
129literal 88
130zcmZ?wbhEHb<Y(YvSj50EbLPyA8#kUfapJ{`7Ys;1@h1x>0|N_#4oD27mVsH;W7nO3
131g26_(KvV1HDEe}L0u*EN#xFFKY>(oAjISdTe06$F_qW}N^
132
133literal 80
134zcmZ?wbhEHb<YZuDSj5I~;>3wfn>L+1d2-{%jW1rjm^pLi|Ns9P7#I|PvM@3LmFNK3
135i3?Q`(%%TyyyiA!oB04G)Te5yh$2@OMO7G-kum%ACMICAY
136
137diff --git a/django/contrib/admin/media/img/admin/arrow-up-hover.gif b/django/contrib/admin/media/img/admin/arrow-up-hover.gif
138new file mode 100644
139index 0000000000000000000000000000000000000000..29a3dc500b6ae6f442e46da95ec10b63dabf0a58
140GIT binary patch
141literal 70
142zcmZ?wbh9u|<Y(Yvn8?5o*tzh<ix&(G40Db#D*j|)WME)o&;fE8K=KSs;#2xpp5FVA
143YkKw}E$m@G0-`<s!7oVCI$-rO@0ITy9_y7O^
144
145literal 0
146HcmV?d00001
147
148diff --git a/django/contrib/admin/media/img/admin/arrow-up.gif b/django/contrib/admin/media/img/admin/arrow-up.gif
149index 3fe4851399a37337891ccf5452ee5d59bbedeec7..d0842b3545151ab949a84aeefa39bcfdd83c828b 100644
150GIT binary patch
151literal 87
152zcmZ?wbhEHb<Y(YvSj50EbLPyA8#kUfapJ{`7Ys;1@h1x>0|N_#4oD27mVsHuW7nO3
153f2KyAn8A6x@3+_0+uuRZMJF|3E#?yU)ObpflIM^AU
154
155literal 838
156zcmZ?wbhEHb<YZuD_|Cv^;>3wfn>L+1d2-{%jW1rjm^pJM!zdUHfe{k|ia%Kx8Gu<q
157z2jpW=o?zfmX5i&8aY$HjkcpK`j>SOX;Q=NFCLWFl0*@NH#f6pb?3n1_z+epkX4f1j
158
159diff --git a/django/contrib/admin/media/img/admin/icon-remove-small.gif b/django/contrib/admin/media/img/admin/icon-remove-small.gif
160new file mode 100644
161index 0000000000000000000000000000000000000000..288c2ad7cc7b807ab02d035c098c80b2c11458b6
162GIT binary patch
163literal 189
164zcmZ?wbh9u|<YC}pIKsfNO;diiuJQ>RQwTcgWCKJO94ybcJ6`ei0HUkGen50BGysSm
165z$45O*h<cTs{-vh;{Dkfc6M8Psn|W=)90mpkW@aD(1R7A<2TCjcWMO1r5NFT<NrLQT
166zV6}Rn+Lw|!OH4H=EK}DvRMFKssP~FWzrob0ZciFl%+T7?dcb3mf&#}u#ShYvT&KMl
167R5;m{WoBS@*hmVoL8UXbGKC1u#
168
169literal 0
170HcmV?d00001
171
172diff --git a/django/contrib/admin/media/img/admin/icon_cog-hover.gif b/django/contrib/admin/media/img/admin/icon_cog-hover.gif
173new file mode 100644
174index 0000000000000000000000000000000000000000..45611686ee942ed9ee4277564f7c00a83684417b
175GIT binary patch
176literal 131
177zcmZ?wbh9u|<Y(Yv*v!BX*tzf&7+eQ~mtgSq>sJOGK=CIFBLf2mgAPa@WCjC^fq-Wu
178z*DB*+1}^zqPYUBLCTUnK)R{i_pzEsa$}HX4yq4nG%g-ySFn?gMf26QY#!rdC8UTGS
179BDRlq<
180
181literal 0
182HcmV?d00001
183
184diff --git a/django/contrib/admin/templates/admin/change_list_results.html b/django/contrib/admin/templates/admin/change_list_results.html
185index 738ff28..cc09533 100644
186--- a/django/contrib/admin/templates/admin/change_list_results.html
187+++ b/django/contrib/admin/templates/admin/change_list_results.html
188@@ -12,15 +12,18 @@
189 <tr>
190 {% for header in result_headers %}
191 <th scope="col" {{ header.class_attrib }}>
192-  {% if header.sortable %}<a href="{{ header.url_primary }}">{% endif %}
193-  <span class="text">{{ header.text|capfirst }}</span>
194   {% if header.sortable %}
195-    {% if header.sort_pos > 0 %}<span class="sortpos">
196-      {% if header.sort_pos == 1 %}<img id="primary-sort-icon" src="{% admin_media_prefix %}img/admin/icon_cog.gif" alt="" />&nbsp;{% endif %}
197-      {{ header.sort_pos }}</span>
198+    {% if header.sort_pos > 0 %}
199+      <div class="sortoptions">
200+      {% if header.sort_pos == 1 %}<img id="primary-sort-icon" src="{% admin_media_prefix %}img/admin/icon_cog.gif" alt="{% trans "options" %}" title="{% trans "Sorting options" %}"/>&nbsp;{% endif %}
201+      <span class="sortposition">{{ header.sort_pos }}</span>
202+      <a class="sortremove" href="{{ header.url_remove }}" title="{% trans "Remove from sorting" %}"><img src="{% admin_media_prefix %}img/admin/icon-remove-small.gif"></a>
203+      <a href="{{ header.url_toggle }}" class="toggle {% if header.ascending %}ascending{% else %}descending{% endif %}"><img src="{% admin_media_prefix %}img/admin/arrow-{% if header.ascending %}up{% else %}down{% endif %}.gif" alt="{% trans "toggle" %}" title="{% trans "Toggle sorting" %}" /></a>
204+      </div>
205     {% endif %}
206-    <span class="clear"></span></a>
207   {% endif %}
208+  <div class="text">{% if header.sortable %}<a href="{{ header.url_primary }}" title="{% trans "Make primary sorting column and toggle sorting" %}">{{ header.text|capfirst }}</a>{% else %}{{ header.text|capfirst }}{% endif %}</div>
209+  <div class="clear"></div>
210 </th>{% endfor %}
211 </tr>
212 </thead>
213@@ -115,6 +118,33 @@
214             hidePopup();
215             ev.preventDefault()
216         });
217+
218+        $('a.toggle.ascending img').mouseenter(function(){
219+            $(this).attr('src', '{% admin_media_prefix %}img/admin/arrow-up-hover.gif');
220+        });
221+        $('a.toggle.ascending img').mouseout(function(){
222+            $(this).attr('src', '{% admin_media_prefix %}img/admin/arrow-up.gif');
223+        });
224+        $('a.toggle.descending img').mouseenter(function(){
225+            $(this).attr('src', '{% admin_media_prefix %}img/admin/arrow-down-hover.gif');
226+        });
227+        $('a.toggle.descending img').mouseout(function(){
228+            $(this).attr('src', '{% admin_media_prefix %}img/admin/arrow-down.gif');
229+        });
230+        $('img#primary-sort-icon').mouseenter(function(){
231+            $(this).attr('src', '{% admin_media_prefix %}img/admin/icon_cog-hover.gif');
232+        });
233+        $('img#primary-sort-icon').mouseout(function(){
234+            $(this).attr('src', '{% admin_media_prefix %}img/admin/icon_cog.gif');
235+        });
236+        $('span.sortposition').mouseover(function(){
237+            $(this).hide();
238+            $(this).siblings('a.sortremove').show();
239+        });
240+        $('a.sortremove').mouseleave(function(){
241+            $(this).hide();
242+            $(this).siblings('span.sortposition').show();
243+        });
244     });
245 })(django.jQuery);
246 //-->