/[drupal]/contributions/modules/multiselect/multiselect.js
ViewVC logotype

Contents of /contributions/modules/multiselect/multiselect.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.6 - (show annotations) (download) (as text)
Wed Sep 17 19:49:20 2008 UTC (14 months, 1 week ago) by jklsemicolon
Branch: MAIN
CVS Tags: DRUPAL-6--1-0, HEAD
Branch point for: DRUPAL-6--1
Changes since 1.5: +3 -2 lines
File MIME type: text/javascript
added css to ensure the multiselect description field  takes up whole div width

removed hook perm. For one, it was never being checked, secondly I see no security risk with this module.


added some checking for errors being thrown in the content/admin pages

now includes the description field in the node form.

uses alt tag on button images, so that when images aren't loaded, the buttons are still somewhat usable.
1 // $Id $
2
3 //@file
4 //Code that operates multiselect boxes
5
6 $(document).ready(function()
7 {
8 //note: Doesn't matter what sort of submit button it is really (preview or submit)
9 //selects all the items in the selected box (so they are actually selected) when submitted
10 $('input.form-submit').click(function()
11 {
12 $('fieldset.multiselect select[@name$="[selected][]"]').selectAll();
13 });
14
15 });
16
17 //selects all the items in the select box it is called from.
18 //usage $('nameofselectbox').selectAll();
19 //
20 jQuery.fn.selectAll = function()
21 {
22 this.each(function()
23 {
24 for (var i=0;i<this.options.length;i++)
25 {
26 option = this.options[i];
27 option.selected = true;
28 }
29 });
30 }
31
32
33 // -------------------------------------------------------------------
34 // hasOptions(obj)
35 // Utility function to determine if an object has an options array
36 // -------------------------------------------------------------------
37 function hasOptions(obj) {
38 if (obj!=null && obj.options!=null) {
39 return true;
40 }
41 else {
42 return false;
43 }
44 }
45
46 function moveSelectedOptions(from_name,to_name) {
47
48 from = document.getElementsByName(from_name)[0];
49 to = document.getElementsByName(to_name)[0];
50
51 // Move them over
52 if (!hasOptions(from)) {
53 return false;
54 }
55
56 for (var i=0; i<from.options.length; i++) {
57 var o = from.options[i];
58 if (o.selected) {
59 if (!hasOptions(to)) { var index = 0; } else { var index=to.options.length; }
60 to.options[index] = new Option( o.text, o.value, false, false);
61 }
62 }
63
64 // Delete them from original
65 for (var i=(from.options.length-1); i>=0; i--) {
66 var o = from.options[i];
67 if (o.selected) {
68 from.options[i] = null;
69 }
70 }
71
72 from.selectedIndex = -1;
73 to.selectedIndex = -1;
74 }

  ViewVC Help
Powered by ViewVC 1.1.2