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