close Warning: HTML preview using PatchRenderer failed (ValueError: not enough values to unpack (expected 2, got 1))

Ticket #16059: 16059-filteredselectmultiple-better-ui.2.diff

File 16059-filteredselectmultiple-better-ui.2.diff, 20.5 KB (added by Julien Phalip, 13 years ago)
Line 
1diff --git a/django/contrib/admin/static/admin/css/widgets.css b/django/contrib/admin/static/admin/css/widgets.css
2index 4f4ea0a..710a473 100644
3--- a/django/contrib/admin/static/admin/css/widgets.css
4+++ b/django/contrib/admin/static/admin/css/widgets.css
5@@ -37,10 +37,6 @@
6 text-align: left;
7 }
8
9-.selector .selector-chosen .selector-filter {
10- padding: 4px 5px;
11-}
12-
13 .selector .selector-available input {
14 width: 230px;
15 }
16@@ -50,7 +46,7 @@
17 width: 22px;
18 height: 50px;
19 background: url(../img/chooser-bg.gif) top center no-repeat;
20- margin: 8em 3px 0 3px;
21+ margin: 10em 3px 0 3px;
22 padding: 0;
23 }
24
25@@ -78,18 +74,32 @@
26 margin-bottom: 2px;
27 }
28
29+.selector-add.active {
30+ background: url(../img/selector-add-active.gif) top center no-repeat;
31+}
32+
33 .selector-remove {
34 background: url(../img/selector-remove.gif) top center no-repeat;
35 }
36
37+.selector-remove.active {
38+ background: url(../img/selector-remove-active.gif) top center no-repeat;
39+}
40+
41 a.selector-chooseall, a.selector-clearall {
42- display: block;
43- width: 6em;
44+ display: inline-block;
45 text-align: left;
46 margin-left: auto;
47 margin-right: auto;
48 font-weight: bold;
49 color: #666;
50+}
51+
52+a.selector-chooseall {
53+ padding: 3px 18px 3px 0;
54+}
55+
56+a.selector-clearall {
57 padding: 3px 0 3px 18px;
58 }
59
60@@ -98,14 +108,20 @@ a.selector-chooseall:hover, a.selector-clearall:hover {
61 }
62
63 a.selector-chooseall {
64- width: 7em;
65- background: url(../img/selector-addall.gif) left center no-repeat;
66+ background: url(../img/selector-addall.gif) right center no-repeat;
67+}
68+
69+a.selector-chooseall.active {
70+ background: url(../img/selector-addall-active.gif) right center no-repeat;
71 }
72
73 a.selector-clearall {
74 background: url(../img/selector-removeall.gif) left center no-repeat;
75 }
76
77+a.selector-clearall.active {
78+ background: url(../img/selector-removeall-active.gif) left center no-repeat;
79+}
80
81 /* STACKED SELECTORS */
82
83@@ -151,10 +167,17 @@ a.selector-clearall {
84 background-image: url(../img/selector_stacked-add.gif);
85 }
86
87+.stacked .selector-add.active {
88+ background-image: url(../img/selector_stacked-add-active.gif);
89+}
90+
91 .stacked .selector-remove {
92 background-image: url(../img/selector_stacked-remove.gif);
93 }
94
95+.stacked .selector-remove.active {
96+ background-image: url(../img/selector_stacked-remove-active.gif);
97+}
98
99 /* DATE AND TIME */
100
101diff --git a/django/contrib/admin/static/admin/img/selector-add-active.gif b/django/contrib/admin/static/admin/img/selector-add-active.gif
102new file mode 100644
103index 0000000000000000000000000000000000000000..50132d1c439494a0a19e1d280385f03d3ac5599b
104GIT binary patch
105literal 606
106zcmZ?wbhEHb6krfwcoxafw(@M}n)ChZFW!3c{`tGF)3#h)y!U$bf@7^KPS-6uzUAco
107zS0BDVc=>6^`De|`PR`nSy<y48zyJQd`}||`iF+NZ&i1W6H+j>g_g{XjI&`ak@yUG`
108zo;EK(J#+ijhQ%lP*I%ezbo}9~&(pSE*?IQS;=MN)@4Gd3=e3%J$D5X(nz`fp(*3u$
109zoqaNI*R}d3CpVpX{Q29jre&vU7apIr<J!lsKewH_U$^+g#EqBw)?Il0;oG*ePnYb!
110z-Lm4$p)1etJp0(S=G=@OK%<WJZ@Ad7<ka-7SK3#edGqP}{5>~bzW=sp-|cz3uWvc?
111zWa{QC$8Wq`dhpJqjhE{epV)Z(?&i~vr*FGDch`+I#~w`He7Swq*`){W^sT@6^~dl3
112z|Nk@49Vq@}VPs&4WY7WG42ly5_T3GUO_4kje3Fi`Y|PEgg2Ei`p1iykJ|h0&z5Zgl
113z0rM9G$k+=tamfX*T&cAxSkXVyMZhv_>sB}KZDAbD#%4hW4zfg89~5H~^<`z%<UXet
114z5g~Qji=C6{hVsSR7nN=pa56sfxO3a}k(#I#1A`OGd!vi0Zy4CQ^h1CCQi#z0CC!#s
115zv%_hF0>2RJ`V9$77#OFv^CvqjY0A7XSuxNk>&%VE4w{br3Jf1VK49#UQa3Uc3OT{Z
116NtIjEA%EiK94FJ;24lMux
117
118literal 0
119HcmV?d00001
120
121diff --git a/django/contrib/admin/static/admin/img/selector-add.gif b/django/contrib/admin/static/admin/img/selector-add.gif
122index 50132d1c439494a0a19e1d280385f03d3ac5599b..a5e90637e8355446be7f66dd3ddb55f9e6dc4e5e 100644
123GIT binary patch
124literal 184
125zcmZ?wbhEHb6krfw*v!DNcGHga+YfBob!5km9mkI!KY#7s)jLma+_>@N*^3u%K79H1
126zg8>yN{$$}~VBluZ0SSZ5U|>ltI2p<$!OUWuE_Aq1;e;bk(<8=~7rR;vINxS3zT)s^
127zPtyl=7ls?bGs-l=0uP!fF^bDB^t4S_Fhh20<tZ1#P6P4DoD<G-x{51n%sJUv%C?a~
128auycp&qaycHHf0r>vO=PPQZmAV4AuY<UPX`q
129
130literal 606
131zcmZ?wbhEHb6krfwcoxafw(@M}n)ChZFW!3c{`tGF)3#h)y!U$bf@7^KPS-6uzUAco
132zS0BDVc=>6^`De|`PR`nSy<y48zyJQd`}||`iF+NZ&i1W6H+j>g_g{XjI&`ak@yUG`
133zo;EK(J#+ijhQ%lP*I%ezbo}9~&(pSE*?IQS;=MN)@4Gd3=e3%J$D5X(nz`fp(*3u$
134zoqaNI*R}d3CpVpX{Q29jre&vU7apIr<J!lsKewH_U$^+g#EqBw)?Il0;oG*ePnYb!
135z-Lm4$p)1etJp0(S=G=@OK%<WJZ@Ad7<ka-7SK3#edGqP}{5>~bzW=sp-|cz3uWvc?
136zWa{QC$8Wq`dhpJqjhE{epV)Z(?&i~vr*FGDch`+I#~w`He7Swq*`){W^sT@6^~dl3
137z|Nk@49Vq@}VPs&4WY7WG42ly5_T3GUO_4kje3Fi`Y|PEgg2Ei`p1iykJ|h0&z5Zgl
138z0rM9G$k+=tamfX*T&cAxSkXVyMZhv_>sB}KZDAbD#%4hW4zfg89~5H~^<`z%<UXet
139z5g~Qji=C6{hVsSR7nN=pa56sfxO3a}k(#I#1A`OGd!vi0Zy4CQ^h1CCQi#z0CC!#s
140zv%_hF0>2RJ`V9$77#OFv^CvqjY0A7XSuxNk>&%VE4w{br3Jf1VK49#UQa3Uc3OT{Z
141NtIjEA%EiK94FJ;24lMux
142
143diff --git a/django/contrib/admin/static/admin/img/selector-addall-active.gif b/django/contrib/admin/static/admin/img/selector-addall-active.gif
144new file mode 100644
145index 0000000000000000000000000000000000000000..d6e7c639bb2ec270122861f054289845281fae26
146GIT binary patch
147literal 358
148zcmZ?wbhEHb6krfwxN64GwdVYqV-FVYy|wM^)3z0-CvU#|?Z@x7m1n1IyE0+p#RUf*
149z*DpEQwCq&t%5&3q-kG-LYR}pWx1PLjUwNi;)tTmHr>AYX(!J*V^leu=SD$TPd3wsG
150zD~tDD-+uc3vi-Mqo_}`i`pffoUcPz%`N)+gC$B$Wu={53y7Nb`JiYSZ&E<QqzJ2?C
151z>gJ2jU%oBgck}JXFNZEY-hSr6{b%p@TzI-@&-ELR-)%g8_xtzn|NsAIzzr0CvM@3*
152zm@(*plz{xiz}D<AyTC(7s^23z#dv0pk_YqJhXEQgyt58^?B=nX*Z9Lp`<y}Jft8}(
153z>;}e*)+h-yWNC)(RZ<o*;pbO2Z81=hVyP1o5KwC|Rg@L$bT$%UXV+`dP-PdXbvEW^
154uU{KPQS;D|w=wc$os;|SkSt!*th=-GdgOex9!`Mht(rAt6@e{6&4AuaOP^lOI
155
156literal 0
157HcmV?d00001
158
159diff --git a/django/contrib/admin/static/admin/img/selector-addall.gif b/django/contrib/admin/static/admin/img/selector-addall.gif
160index d6e7c639bb2ec270122861f054289845281fae26..f7df7f75fd93563b3d37c4ffa3dbf373e2790e9c 100644
161GIT binary patch
162literal 166
163zcmZ?wbh9u|6krfw*v!DN0t|M5!3i+94hB!a;5!&FAOXdnEQ|~cJPbM@F_0MyEWr~_
164zdam9(Ly@t;VTKb!OJYw;l3-KgjAafX9G(iNJbNCf{Lyvg(^ybZ$F?x(uwfa4rz*R{
165mOsCeZeuY8KeDw|YT0(EVO%a=z>mC$q7FC$$x7>w+!5RQi7ecZC
166
167literal 358
168zcmZ?wbhEHb6krfwxN64GwdVYqV-FVYy|wM^)3z0-CvU#|?Z@x7m1n1IyE0+p#RUf*
169z*DpEQwCq&t%5&3q-kG-LYR}pWx1PLjUwNi;)tTmHr>AYX(!J*V^leu=SD$TPd3wsG
170zD~tDD-+uc3vi-Mqo_}`i`pffoUcPz%`N)+gC$B$Wu={53y7Nb`JiYSZ&E<QqzJ2?C
171z>gJ2jU%oBgck}JXFNZEY-hSr6{b%p@TzI-@&-ELR-)%g8_xtzn|NsAIzzr0CvM@3*
172zm@(*plz{xiz}D<AyTC(7s^23z#dv0pk_YqJhXEQgyt58^?B=nX*Z9Lp`<y}Jft8}(
173z>;}e*)+h-yWNC)(RZ<o*;pbO2Z81=hVyP1o5KwC|Rg@L$bT$%UXV+`dP-PdXbvEW^
174uU{KPQS;D|w=wc$os;|SkSt!*th=-GdgOex9!`Mht(rAt6@e{6&4AuaOP^lOI
175
176diff --git a/django/contrib/admin/static/admin/img/selector-remove-active.gif b/django/contrib/admin/static/admin/img/selector-remove-active.gif
177new file mode 100644
178index 0000000000000000000000000000000000000000..6c5d45ae6e7722a0f0c568a20c21458bb1cc2f99
179GIT binary patch
180literal 370
181zcmZ?wbh9u|6krfwxXQp#yYM&=wXHY<L4E5k^l!L0ecM$yTD<oL5G_4$8;CX?zY9cb
182zjy>3N<}ncMyYTeLwHH8i>&g2&&ptkR^96|BeEbeXUw{0DAO;*j6e`XLrP*+(!zB#U
183zr}&cv$W&m^0VxFeiGi)(VS+$OBtu^lTbjikn@N*aq$pOD%xY*Z(KfVc>vv9(nK<Ei
184z>wDFk8R2GcE0{M#N{IdNQg42*&m|Pe&MqR`Cf&i?%*M*V#wOG@sjaNvot2e)@}&A1
185z9!yN^lO&h0FJPLvoN1Qis^$FR3^QhMOKjd;qTt`(&%UQW)Jb|%^U<RReRm&YV+iwc
186Oa&>3$^mcY+um%9w4umuS
187
188literal 0
189HcmV?d00001
190
191diff --git a/django/contrib/admin/static/admin/img/selector-remove.gif b/django/contrib/admin/static/admin/img/selector-remove.gif
192index 2b9b0a2ac35a2051834bb9a49a7d57aaeebdcb48..8c0774cbbd49ab78ba73df7042a5434f481670e3 100644
193GIT binary patch
194literal 263
195zcmZ?wbhEHb6krfwIKsfNcEjeiTla3<b$H8`ExUK`K62#9sZ*!UUAueb%9X2k9^bxw
196z`@w?;kDk4L`tse2Hy_@-dGqPhr>{SL|NHlkfjFS}lZBIkL6|`Yq#R@?18d6z6+ce~
197z9%ccV#~Pe13w64i1ez{$wLbd4@6ZCpCdEE?=}ihVOxW61Br;AEThzkrv#KLxak%qA
198z7mY7Uf}AO}ri(dPSgdUKAG-f^=aRS`^8;8jva`!Im^2y$`8!xT7<rfr3fTB3O=8wD
199hNSmEB+d?@yXi=|=l0I`{0<)#Al4?D(wyq+BH2?@EVr2jT
200
201literal 398
202zcmV;90df9ENk%w1VGsZi0M$MK!NI}2yu9=C^R%?Iv9Ynv*4?eOy|A&e#l^+DySw1v
203z;PCM9vb)91%*?sDx%~b8tgyARva;st@73Jn!^6YAzP`)L%gV~i`T6;>yTq=rvah$l
204z-QC^j?C`?E!rI!}-rnBp>+8?Y&$F|$v%JQ(wzkK|$N2d8?d|R4>Fx3H@xZ{qud%ZB
205z_V&`!(&Fap*x1<3&CRj8!??J(+uPg8$;r;n&b76*)z#I=$jG<1x5UK6zrVlr`1}9=
206z{{R30A^8LW002G!EC2ui01yBW000K7K%dYz*=R~SmZ2~lJ~9pwN1*_@60%NHMxlAX
207zUK2qgWbklk^e2tm$$Y6>%tp5<1a<nXK&s^aIUGGIfPVl65Ig{jFg-md0+AO0D+C7t
208zm^h9-7@Ikm5eGA)2%DXb2%`}Y12?V|jx7tbJgx)`13J1or6{|)HwG^wJjKNpA;!f6
209sObiY?(9k*2J6J<92{qc=+7)9?88;pm4Gk7MI$2FZMH;OKOHDxlJ9N|8EC2ui
210
211diff --git a/django/contrib/admin/static/admin/img/selector-removeall-active.gif b/django/contrib/admin/static/admin/img/selector-removeall-active.gif
212new file mode 100644
213index 0000000000000000000000000000000000000000..28b4fad628aabdf644d01457404c81577a44d42b
214GIT binary patch
215literal 234
216zcmZ?wbh9u|6krfwIKseCzvN{5$}<quv-ZN2EmweO(ViPXwDI^|AX;(c0T69F`vi#g
217zTzGo?+A}!1eDBqb$M1mX&HK-9KYsc4{Ra>+paR98EQ|~c(hNEvVUV2+tmzNb`cg9I
218zy$F+aEC|V%#&UF%h~uQ0o)`b{dn}%y5z4gfD6{iM)`Z2*4+|Pnj6_~dajA|qp3r1*
219zKvhOBo+Ht>kBN!p)YpqlG9ID_W?f)d&lsR=oD}SAsb*A_#KK^up{=X0IeCh@B7-#m
220D>j`T<
221
222literal 0
223HcmV?d00001
224
225diff --git a/django/contrib/admin/static/admin/img/selector_stacked-add-active.gif b/django/contrib/admin/static/admin/img/selector_stacked-add-active.gif
226new file mode 100644
227index 0000000000000000000000000000000000000000..74261696522de5819780082d9d92d75f8ffdb4fc
228GIT binary patch
229literal 612
230zcmZ?wbhEHb6krfwcoxdgw({()C+`>Uz23RzeCvwSk6wMQUT~~#(eW)O@4x%}qhZO(
231z=4B^W9lAAn)1{a1zimDJ=;PO)eQVFX`tbe1%TKd*UVs1P$KQYdUVr@FvFhyR6ZdwU
232ze>P#`rA;RvPThQ^Vacg^yRJ>!dS%hR+gr{&*>?76|N09vw_ojAb8ha=YxRpy&e(CS
233zX5q0dryguM`QY`3Zw-r2%-nIkdHLz4Wv6Nu9$&Km_M1=N`!`%%e(?6hjhE^cpICbE
234zPW_UT?JLi0J9WQr-Gy6EKkPjFXz{*VlQv#%T6(H>;qm&#Ct6mV*>vi0?V{s*E<9;p
235zb#~+NyGsw;*?ju(++8>N)?b{q<?7_km#1&Ly5`t}{`D8X{`md>|9^%71&Tje7#SEs
236z8FWCd0L2Ld`@x3LrchxXZVfp-CdTGwF-aChB`GOoO9?O0UN2rZpZN=XRJAypI8=gG
237zu3D|&6>7p|?7dlrpI>J4W)?;pTi^Y@;vpg82Yh*%1Red)_zN8tI_odX#vXkAI^SWw
238z8`quLnIE#U3LF+-wUd@+HWGAYV9+`IIYj*f0~?2-=O67a@_!~B5V-KDV{)@!9S?KU
239zg-$*<4i1Nz9ITzZT>%EXL7SAjj`z#?N@%FQnAjwxsS!|7=<Kn~t%*zbfa8+`i`*I+
240G7_0%~kOZIr
241
242literal 0
243HcmV?d00001
244
245diff --git a/django/contrib/admin/static/admin/img/selector_stacked-add.gif b/django/contrib/admin/static/admin/img/selector_stacked-add.gif
246index 74261696522de5819780082d9d92d75f8ffdb4fc..9b4c1b308e6576eeac6367579de8f77747b33027 100644
247GIT binary patch
248literal 238
249zcmZ?wbh9u|6krfwIKsfNcGC_Z+71Tmw;$NF>&S61IDhTl4KTQR=gG6@FX8CLn-5>V
250z{eU0_B7ovg7DfgJ5e6NQT9BO#tl0{xLEMZSOb!Z<B}AJP&pR=0{jf&*rSDVg*xo}9
251zlC5rxOw)QSlsy|YxeA>YH3Wa|yecJeRh{LK_uRDe=}Bx1QbI4k_5@rxsLZX%J?+JJ
252i$+~P-W!C)0IyMG75q(2WZthysZe`UdEgfY=25SIFEL#fz
253
254literal 612
255zcmZ?wbhEHb6krfwcoxdgw({()C+`>Uz23RzeCvwSk6wMQUT~~#(eW)O@4x%}qhZO(
256z=4B^W9lAAn)1{a1zimDJ=;PO)eQVFX`tbe1%TKd*UVs1P$KQYdUVr@FvFhyR6ZdwU
257ze>P#`rA;RvPThQ^Vacg^yRJ>!dS%hR+gr{&*>?76|N09vw_ojAb8ha=YxRpy&e(CS
258zX5q0dryguM`QY`3Zw-r2%-nIkdHLz4Wv6Nu9$&Km_M1=N`!`%%e(?6hjhE^cpICbE
259zPW_UT?JLi0J9WQr-Gy6EKkPjFXz{*VlQv#%T6(H>;qm&#Ct6mV*>vi0?V{s*E<9;p
260zb#~+NyGsw;*?ju(++8>N)?b{q<?7_km#1&Ly5`t}{`D8X{`md>|9^%71&Tje7#SEs
261z8FWCd0L2Ld`@x3LrchxXZVfp-CdTGwF-aChB`GOoO9?O0UN2rZpZN=XRJAypI8=gG
262zu3D|&6>7p|?7dlrpI>J4W)?;pTi^Y@;vpg82Yh*%1Red)_zN8tI_odX#vXkAI^SWw
263z8`quLnIE#U3LF+-wUd@+HWGAYV9+`IIYj*f0~?2-=O67a@_!~B5V-KDV{)@!9S?KU
264zg-$*<4i1Nz9ITzZT>%EXL7SAjj`z#?N@%FQnAjwxsS!|7=<Kn~t%*zbfa8+`i`*I+
265G7_0%~kOZIr
266
267diff --git a/django/contrib/admin/static/admin/img/selector_stacked-remove-active.gif b/django/contrib/admin/static/admin/img/selector_stacked-remove-active.gif
268new file mode 100644
269index 0000000000000000000000000000000000000000..aa8b67f90449c32d7b52bd4bb352940ca6a7f7a8
270GIT binary patch
271literal 262
272zcmZ?wbh9u|6krfwIKseCyYM&=wXQe=L4E5k^l!L0ZR-^{TD<oL5G^}!8;CX?zY9cb
273zjy>3N`VkQAx$xxHllQltet7))GZ4M`_#KG8{`d_+3}B%6lZBCiL5@KO!~@yMz}mb(
274zy((Op;YCpI<8KVd6y@7Kq`Xl+^CytOqQB2Q^Fz)&o&^VV0?cN+eh$CLxlTx<q;Rj-
275z?#Q>>y0hZ+9(5m0_;K*Y8y*wpbp2%GpK6zxJ-E0VxvM0bxY?Q+c)NLp`h<GawE0;D
276kr%j*1&aceR)<0i}-9guiTS!D?f|;X^s=B7OvLb^u04`vA&j0`b
277
278literal 0
279HcmV?d00001
280
281diff --git a/django/contrib/admin/static/admin/js/SelectFilter2.js b/django/contrib/admin/static/admin/js/SelectFilter2.js
282index b7bc9d5..4520481 100644
283--- a/django/contrib/admin/static/admin/js/SelectFilter2.js
284+++ b/django/contrib/admin/static/admin/js/SelectFilter2.js
285@@ -5,7 +5,7 @@ Different than SelectFilter because this is coupled to the admin framework.
286
287 Requires core.js, SelectBox.js and addevent.js.
288 */
289-
290+(function($) {
291 function findForm(node) {
292 // returns the node of the form containing the given node
293 if (node.tagName.toLowerCase() != 'form') {
294@@ -14,7 +14,7 @@ function findForm(node) {
295 return node;
296 }
297
298-var SelectFilter = {
299+window.SelectFilter = {
300 init: function(field_id, field_name, is_stacked, admin_media_prefix) {
301 if (field_id.match(/__prefix__/)){
302 // Don't intialize on empty forms.
303@@ -45,40 +45,43 @@ var SelectFilter = {
304 var selector_available = quickElement('div', selector_div, '');
305 selector_available.className = 'selector-available';
306 quickElement('h2', selector_available, interpolate(gettext('Available %s'), [field_name]));
307- var filter_p = quickElement('p', selector_available, '');
308+
309+ var selector_filter_available = quickElement('p', selector_available, interpolate(gettext('To add %s, select some choice(s) below and click the "Add" button.'), [field_name]), 'id', field_id + '_add_help_text');
310+ selector_filter_available.className = 'selector-filter';
311+
312+ var filter_p = quickElement('p', selector_available, '', 'id', field_id + '_filter');
313 filter_p.className = 'selector-filter';
314
315 var search_filter_label = quickElement('label', filter_p, '', 'for', field_id + "_input", 'style', 'width:16px;padding:2px');
316
317- var search_selector_img = quickElement('img', search_filter_label, '', 'src', admin_media_prefix + 'img/selector-search.gif');
318- search_selector_img.alt = gettext("Filter");
319+ var search_selector_img = quickElement('img', search_filter_label, '', 'src', admin_media_prefix + 'img/selector-search.gif', 'alt', gettext("Filter"), 'title', gettext("Filter"));
320
321 filter_p.appendChild(document.createTextNode(' '));
322
323- var filter_input = quickElement('input', filter_p, '', 'type', 'text');
324+ var filter_input = quickElement('input', filter_p, '', 'type', 'text', 'placeholder', gettext("Filter"));
325 filter_input.id = field_id + '_input';
326+
327 selector_available.appendChild(from_box);
328- var choose_all = quickElement('a', selector_available, gettext('Choose all'), 'href', 'javascript: (function(){ SelectBox.move_all("' + field_id + '_from", "' + field_id + '_to"); })()');
329+ var choose_all = quickElement('a', selector_available, gettext('Add all'), 'href', 'javascript: (function(){ SelectBox.move_all("' + field_id + '_from", "' + field_id + '_to"); SelectFilter.refresh_icons("' + field_id + '");})()', 'id', field_id + '_add_all_link');
330 choose_all.className = 'selector-chooseall';
331
332 // <ul class="selector-chooser">
333 var selector_chooser = quickElement('ul', selector_div, '');
334 selector_chooser.className = 'selector-chooser';
335- var add_link = quickElement('a', quickElement('li', selector_chooser, ''), gettext('Add'), 'href', 'javascript: (function(){ SelectBox.move("' + field_id + '_from","' + field_id + '_to");})()');
336+ var add_link = quickElement('a', quickElement('li', selector_chooser, ''), gettext('Add'), 'title', gettext('Add'), 'href', 'javascript: (function(){ SelectBox.move("' + field_id + '_from","' + field_id + '_to"); SelectFilter.refresh_icons("' + field_id + '");})()', 'id', field_id + '_add_link');
337 add_link.className = 'selector-add';
338- var remove_link = quickElement('a', quickElement('li', selector_chooser, ''), gettext('Remove'), 'href', 'javascript: (function(){ SelectBox.move("' + field_id + '_to","' + field_id + '_from");})()');
339+ var remove_link = quickElement('a', quickElement('li', selector_chooser, ''), gettext('Remove'), 'title', gettext('Remove'), 'href', 'javascript: (function(){ SelectBox.move("' + field_id + '_to","' + field_id + '_from"); SelectFilter.refresh_icons("' + field_id + '");})()', 'id', field_id + '_remove_link');
340 remove_link.className = 'selector-remove';
341
342 // <div class="selector-chosen">
343 var selector_chosen = quickElement('div', selector_div, '');
344 selector_chosen.className = 'selector-chosen';
345- quickElement('h2', selector_chosen, interpolate(gettext('Chosen %s'), [field_name]));
346- var selector_filter = quickElement('p', selector_chosen, gettext('Select your choice(s) and click '));
347- selector_filter.className = 'selector-filter';
348- quickElement('img', selector_filter, '', 'src', admin_media_prefix + (is_stacked ? 'img/selector_stacked-add.gif':'img/selector-add.gif'), 'alt', 'Add');
349+ quickElement('h2', selector_chosen, interpolate(gettext('Added %s'), [field_name]));
350+ var selector_filter_chosen = quickElement('p', selector_chosen, interpolate(gettext('To remove %s, select some choice(s) below and click the "Remove" button.'), [field_name]), 'id', field_id + '_remove_help_text');
351+ selector_filter_chosen.className = 'selector-filter';
352 var to_box = quickElement('select', selector_chosen, '', 'id', field_id + '_to', 'multiple', 'multiple', 'size', from_box.size, 'name', from_box.getAttribute('name'));
353 to_box.className = 'filtered';
354- var clear_all = quickElement('a', selector_chosen, gettext('Clear all'), 'href', 'javascript: (function() { SelectBox.move_all("' + field_id + '_to", "' + field_id + '_from");})()');
355+ var clear_all = quickElement('a', selector_chosen, gettext('Remove all'), 'href', 'javascript: (function() { SelectBox.move_all("' + field_id + '_to", "' + field_id + '_from"); SelectFilter.refresh_icons("' + field_id + '");})()', 'id', field_id + '_remove_all_link');
356 clear_all.className = 'selector-clearall';
357
358 from_box.setAttribute('name', from_box.getAttribute('name') + '_old');
359@@ -86,16 +89,35 @@ var SelectFilter = {
360 // Set up the JavaScript event handlers for the select box filter interface
361 addEvent(filter_input, 'keyup', function(e) { SelectFilter.filter_key_up(e, field_id); });
362 addEvent(filter_input, 'keydown', function(e) { SelectFilter.filter_key_down(e, field_id); });
363- addEvent(from_box, 'dblclick', function() { SelectBox.move(field_id + '_from', field_id + '_to'); });
364- addEvent(to_box, 'dblclick', function() { SelectBox.move(field_id + '_to', field_id + '_from'); });
365+ addEvent(from_box, 'change', function(e) { SelectFilter.refresh_icons(field_id) });
366+ addEvent(to_box, 'change', function(e) { SelectFilter.refresh_icons(field_id) });
367+ addEvent(from_box, 'dblclick', function() { SelectBox.move(field_id + '_from', field_id + '_to'); SelectFilter.refresh_icons(field_id); });
368+ addEvent(to_box, 'dblclick', function() { SelectBox.move(field_id + '_to', field_id + '_from'); SelectFilter.refresh_icons(field_id); });
369 addEvent(findForm(from_box), 'submit', function() { SelectBox.select_all(field_id + '_to'); });
370 SelectBox.init(field_id + '_from');
371 SelectBox.init(field_id + '_to');
372 // Move selected from_box options to to_box
373 SelectBox.move(field_id + '_from', field_id + '_to');
374+
375+ if (!is_stacked) {
376+ // In horizontal mode, give the same height to the two boxes.
377+ $('#' + field_id + '_remove_help_text').height($('#' + field_id + '_add_help_text').height() + $('#' + field_id + '_filter').outerHeight());
378+ }
379+ },
380+ refresh_icons: function(field_id) {
381+ var from = $('#' + field_id + '_from');
382+ var to = $('#' + field_id + '_to');
383+ var is_from_selected = from.find('option:selected').length > 0;
384+ var is_to_selected = to.find('option:selected').length > 0;
385+ // Active if at least one item is selected
386+ $('#' + field_id + '_add_link').toggleClass('active', is_from_selected);
387+ $('#' + field_id + '_remove_link').toggleClass('active', is_to_selected);
388+ // Active if the corresponding box isn't empty
389+ $('#' + field_id + '_add_all_link').toggleClass('active', from.find('option').length > 0);
390+ $('#' + field_id + '_remove_all_link').toggleClass('active', to.find('option').length > 0);
391 },
392 filter_key_up: function(event, field_id) {
393- from = document.getElementById(field_id + '_from');
394+ var from = document.getElementById(field_id + '_from');
395 // don't submit form if user pressed Enter
396 if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)) {
397 from.selectedIndex = 0;
398@@ -109,7 +131,7 @@ var SelectFilter = {
399 return true;
400 },
401 filter_key_down: function(event, field_id) {
402- from = document.getElementById(field_id + '_from');
403+ var from = document.getElementById(field_id + '_from');
404 // right arrow -- move across
405 if ((event.which && event.which == 39) || (event.keyCode && event.keyCode == 39)) {
406 var old_index = from.selectedIndex;
407@@ -128,3 +150,5 @@ var SelectFilter = {
408 return true;
409 }
410 }
411+
412+})(django.jQuery);
Back to Top