add more precise selectors to css
[opensuse:software-o-o.git] / app / views / main / download.erb
1 var mymedium = "<%= @medium %>";
2
3 var mylink = '';
4 var myiso = '';
5 var directory = "<%= @directory %>";
6 var isos = new Array();
7 <% @isos.each { |key, value| %>
8   <%= "isos['#{key}'] = '#{value}';" %>
9 <% } %>
10
11 function changeiso () {
12   mylink = mymedium;
13   var arch_suffix = "-64";
14   if ($('#i686').attr('checked')) {
15     arch_suffix = "-32";
16   }
17   myiso = directory + "/iso/openSUSE-" + isos[mylink + arch_suffix] + ".iso";
18   mylink = myiso;
19   var download_suffix = '';
20   if ($('#p_torrent').attr('checked')) {
21     download_suffix = ".torrent";
22   }
23   if ($('#p_metalink').attr('checked')) {
24     download_suffix = ".meta4";
25   }
26   if ($('#p_mirror').attr('checked')) {
27     download_suffix = "?mirrorlist";
28   }
29   $('#sig_gpg').attr("href", myiso + ".asc");
30   $('#sig_md5').attr("href", myiso + ".md5");
31   $('#sig_sha1').attr("href", myiso + ".sha1");
32   mylink += download_suffix;
33
34   var langiso = directory + "/iso/openSUSE-" + isos['lang' + arch_suffix] + ".iso";
35   $('.md5_lang').attr('href', langiso + ".md5");
36   $('.sha1_lang').attr('href', langiso + ".sha1");
37   $('.gpg_lang').attr('href', langiso + ".asc");
38   $('.iso_lang').attr('href', langiso + download_suffix);
39   $('.iso_nonoss').attr('href', directory + "/iso/openSUSE-" + isos['nonoss'] + ".iso" + download_suffix);
40
41   $('#icon_' + mymedium).addClass('icon_selected').removeClass('icon_unselected').parent('div').addClass("medium_selected").removeClass('medium_unselected');
42   // $('#icon_' + mymedium).addClass('icon_selected').removeClass('icon_unselected');
43
44   // $('#download_button').html($('#download_' + mymedium).html());
45   $('#download_button').html($('#download_' + mymedium).html());
46
47   if (mymedium == 'net') {
48      $('#l_torrent').addClass('notavailable');
49      $('#p_torrent').attr('disabled', 'disabled');
50      if ($('#p_torrent').attr('checked')) {
51         $('#p_torrent').attr('checked', '');
52         $('#p_http').attr('checked', 'checked');
53         mylink = myiso;
54      }
55   } else {
56      $('#l_torrent').removeClass('notavailable');
57      $('#p_torrent').attr('disabled', '');
58   }
59
60   if ( mymedium == "derivatives"){
61     //mylink="http://www.opensuse-education.org/download/ISOs/openSUSE-Edu-li-f-e-11.2-latest-i686.iso";
62     mylink = "http://en.opensuse.org/Derivatives";
63
64 //      $('#l_x86_64').addClass('notavailable');
65 //    $('#x86_64').attr('disabled', 'disabled');
66 //   if ($('#x86_64').attr('checked')) {
67 //              $('#x86_64').attr('checked', '');
68 //              $('#i686').attr('checked', 'checked');
69 //    }
70 //  }
71 //  else {
72 //     $('#l_x86_64').removeClass('notavailable');
73 //     $('#x86_64').attr('disabled', '');
74   }
75 }
76
77
78 function unselectOld() {
79   // $('#icon_' + mymedium).removeClass('icon_selected').addClass('icon_unselected');
80   $('#icon_' + mymedium).removeClass('icon_selected').addClass('icon_unselected').parent('div').addClass("medium_unselected").removeClass('medium_selected');
81 }
82
83 $(function() {
84     changeiso();
85     $('.helplink').show();
86     $('.script_only').show();
87     $('.noscript').hide();
88
89     $('.changeiso').click(function(){
90                             changeiso();
91                             return true; 
92                           });
93     $('div.changeiso').click(function(){
94                                   unselectOld();
95                                   mymedium = this.id.substr(3);
96                                   changeiso();
97                               $(this).parent().trigger('click');
98                                   if ( mymedium == "derivatives"){
99                                       $(this).parent().next().append($('#derivativesDiv'));
100                                   }
101                                   else {
102                                       $(this).parent().next().append($('#downloadForm'));
103                                   }
104                                   return false; 
105                                 });
106     $('button.changeiso').click(function(){
107                                   unselectOld();
108                                   mymedium = this.id.substr(3);
109                                   changeiso();
110                                   return false; 
111                                 });
112     $('#download_button').click(function() {
113                            window.location = mylink;
114                            return false;
115                          });
116
117         $("#downloaderAccordion").accordion();
118         $("#help_method_content").dialog({
119                                 bgiframe: true,
120                                 autoOpen:false,
121                                 width: "80%",
122                                 draggable: false,
123                                 resizable: false,
124                                 title: 'openSUSE Download Help',
125                                 modal: true,
126                                 buttons: {
127                                         Ok: function() {
128                                                 $(this).dialog('close');
129                                         }
130                                 }
131                         });
132         $("#help_arch_content").dialog({
133                                 bgiframe: true,
134                                 autoOpen:false,
135                                 width: "80%",
136                                 draggable: false,
137                                 resizable: false,
138                                 title: 'openSUSE Download Help',
139                                 modal: true,
140                                 buttons: {
141                                         Ok: function() {
142                                                 $(this).dialog('close');
143                                         }
144                                 }
145                         });
146
147         $("#downloadMethodHelpPopup").click( function (){
148                 $("#help_method_content").dialog('open');
149         });
150
151         $("#architectureTypeHelpPopup").click( function (){
152                 $("#help_arch_content").dialog('open');
153         });
154 });