ajout date_invitation, corrections template
[mw_sourceml] / app / out / default / js / actions / users.js
1 $(document).ready
2 ( function()
3   { init_reference_select();
4     init_tinymce();
5     init_derivations();
6     init_reference();
7   }
8 );
9
10 var last_document_id = 1;
11
12 function select_groupe(id_groupe)
13 { var content =
14     "<label for=\"album\">album</label>"
15   + "<p>"
16   + "<select name=\"album\" id=\"album\">"
17   + "<option value=\"0\" selected=\"selected\">hors album</option>";
18   for(var id_album in albums["" + id_groupe])
19   { content +=
20       "<option value=\"" + id_album + "\">" + albums["" + id_groupe]["" + id_album] + "</option>";
21   }
22   content +=
23     "</select>"
24   + "</p>";
25   $("#album_select").html(content);
26 }
27
28 function select_morceaux_groupe(id_groupe)
29 { var content =
30     "<label for=\"morceau\">morceau</label>"
31   + "<p>"
32   + "<select name=\"morceau\" id=\"morceau\">"
33   + "<option value=\"0\" selected=\"selected\">hors morceau</option>";
34   for(var id_morceau in morceaux["" + id_groupe])
35   { content +=
36       "<option value=\"" + id_morceau + "\">" + morceaux["" + id_groupe]["" + id_morceau] + "</option>";
37   }
38   content +=
39     "</select>"
40   + "</p>";
41   $("#morceau_select").html(content);
42 }
43
44 function init_reference_select()
45 { $("#is_derivation").click
46   ( function()
47     { if($(this).get(0).checked) $("#derivation_input").slideDown(200);
48       else $("#derivation_input").slideUp(200);
49     }
50   );
51   $("#is_reference").click
52   ( function()
53     { if($(this).get(0).checked)
54       { $("#original_form").slideUp(200);
55         $("#reference_form").slideDown(200);
56       }
57       else 
58       { $("#reference_form").slideUp(200);
59         $("#original_form").slideDown(200);
60       }
61     }
62   );
63 }
64
65 function add_document()
66 { last_document_id++;
67   var id_document = last_document_id;
68   var content = "<div class=\"document\" id=\"document_" + id_document + "\">\n"
69               + "  <div class=\"delete\"><a href=\"#\" onclick=\"del_document('" + id_document + "'); return false;\">Enlever ce fichier</a></div>\n"
70               + "  <label for=\"document_nom_" + id_document + "\">nom</label>\n"
71               + "  <input type=\"text\" class=\"long_text\" name=\"document_nom_" + id_document + "\" id=\"document_nom_" + id_document + "\" value=\"\" />\n"
72               + "  <div class=\"clear\"><!-- --></div>\n"
73               + "  <label for=\"document_url_" + id_document + "\">url</label>\n"
74               + "  <input type=\"text\" size=\"48\" name=\"document_url_" + id_document + "\" id=\"document_url_" + id_document + "\" value=\"\" />\n"
75               + "</div>\n";
76   $("#documents").append(content);
77 }
78
79 function del_document(id_document)
80 { $("#document_" + id_document).remove();
81 }
82
83 function init_tinymce()
84 { $(".tinymce").each
85   ( function()
86     { tinyMCE.execCommand("mceAddControl", true, $(this).attr("id"));
87     }
88   );
89 }
90
91 function init_toggle_edit_derivation_content(id_derivation)
92 { $("#derivation_edit_" + id_derivation + " .use_edit_derivation_content").click
93   ( function()
94     { var id_derivation_content = $(this).attr("id");
95       if(id_derivation_content.length > 28)
96       { id_derivation_content = id_derivation_content.substr(28);
97         if($(this).get(0).checked)
98         { $("#derivation_edit_" + id_derivation_content + " span").slideDown(200);
99         }
100         else
101         { $("#derivation_edit_" + id_derivation_content + " span").slideUp(200);
102         }
103       }
104     }
105   );
106 }
107
108 function init_derivations()
109 { if(typeof(derivations) != "undefined")
110   { for(var id_derivation in derivations)
111     { init_toggle_edit_derivation_content(id_derivation);
112       $("#derivation_infos_" + id_derivation).slideDown(200);
113     }
114   }
115 }
116
117 function init_toggle_edit_reference_content(){
118   $("#reference_edit .use_edit_reference_content").click(
119     function(){
120       if($(this).get(0).checked){
121         $("#reference_edit span").slideDown(200);
122       }
123       else{
124         $("#reference_edit span").slideUp(200);
125       }
126     }
127   );
128 }
129
130 function init_reference()
131 { init_toggle_edit_reference_content();
132   if(typeof(is_reference) != "undefined")
133   { if(is_reference) $("#reference_form").slideDown(200);
134   }
135 }
136
137 function add_derivation(id_source, id_source_derivation)
138 { if(!id_source)
139   { index_derivation++;
140     id_source_derivation = index_derivation;
141   }
142   $.ajax
143   ( { url: mw_site_url + "index.php?e=content/sources/xml_form&id=" + id_source + "&derivation=" + id_source_derivation + "&form=" + (id_source ? "edit" : "add"),
144       dataType: "html",
145       success: function(content)
146       { $("#derivations_items").append(content);
147         init_toggle_edit_derivation_content(id_source_derivation);
148         $("#derivation_infos_" + id_source_derivation).slideDown(200);
149       }
150     }
151   );
152 }
153
154 function del_sml_xf(id_xf)
155 { $("#" + id_xf).slideUp(200, function () { $(this).remove(); });
156 }