1 | <script type="text/javascript"> |
---|
2 | $(function() { |
---|
3 | sets = <?php echo $javascript->object($sets);?>; |
---|
4 | set_ext = sets['all']; |
---|
5 | set_output = sets['all']; |
---|
6 | |
---|
7 | update_apps = function() { |
---|
8 | set_active = $.richArray.intersect(set_ext, set_output); |
---|
9 | $('#applications input[type=checkbox]').each(function(i) { |
---|
10 | if (jQuery.inArray(this.id, set_active) > -1) { |
---|
11 | $(this).removeAttr('disabled'); |
---|
12 | $('label[for=' + this.id + ']').toggleClass('disabled', false); |
---|
13 | } else { |
---|
14 | $(this).removeAttr('checked').attr('disabled', 'disabled'); |
---|
15 | $('label[for=' + this.id + ']').toggleClass('disabled', true); |
---|
16 | } |
---|
17 | }); |
---|
18 | } |
---|
19 | |
---|
20 | select_apps = function(type) { |
---|
21 | switch (type) { |
---|
22 | case 'all': |
---|
23 | case 'latest': |
---|
24 | case 'development': |
---|
25 | set_apps = sets[type]; |
---|
26 | break; |
---|
27 | case 'none': |
---|
28 | set_apps = []; |
---|
29 | break; |
---|
30 | default: |
---|
31 | set_apps = sets['platform'][type]; |
---|
32 | break; |
---|
33 | } |
---|
34 | |
---|
35 | $('#applications input[type=checkbox]:enabled').each(function(i) { |
---|
36 | if ($.inArray(this.id, set_apps) > -1) { |
---|
37 | $(this).attr('checked', 'checked'); |
---|
38 | } else { |
---|
39 | $(this).removeAttr('checked'); |
---|
40 | } |
---|
41 | }); |
---|
42 | } |
---|
43 | |
---|
44 | $('#applications').accordion({ |
---|
45 | header: 'h3', |
---|
46 | autoHeight: true |
---|
47 | }); |
---|
48 | |
---|
49 | $('#RequestFileUpload').change(function() { |
---|
50 | ext = $('#RequestFileUpload').val(); |
---|
51 | ext = ext.substr(ext.lastIndexOf('.') + 1); |
---|
52 | |
---|
53 | if (ext == '') { |
---|
54 | set_ext = sets['all']; |
---|
55 | } else { |
---|
56 | $('#applications').accordion('activate', 'h3.' + ext); |
---|
57 | set_ext = sets['extension'][ext]; |
---|
58 | } |
---|
59 | |
---|
60 | update_apps(); |
---|
61 | }); |
---|
62 | |
---|
63 | $("input[type=radio]").click(function() { |
---|
64 | var id = $("input[type=radio]:checked").val(); |
---|
65 | |
---|
66 | if (id == '') { |
---|
67 | set_output = sets['all']; |
---|
68 | } else { |
---|
69 | set_output = sets['format'][id]; |
---|
70 | } |
---|
71 | |
---|
72 | update_apps(); |
---|
73 | }); |
---|
74 | |
---|
75 | select_apps('latest'); |
---|
76 | }); |
---|
77 | </script> |
---|
78 | |
---|
79 | <?php |
---|
80 | $javascript->link('jquery-1.3.2.min.js', false); |
---|
81 | $javascript->link('jquery-ui-accordion-1.6rc6.min.js', false); |
---|
82 | $javascript->link('jquery.rich-array-min.js', false); |
---|
83 | ?> |
---|
84 | |
---|
85 | <div id="request-add"> |
---|
86 | <?php echo $form->create('Request', array('type' => 'file')); ?> |
---|
87 | <fieldset id="upload"> |
---|
88 | <legend><?php __('Upload your documents!');?></legend> |
---|
89 | <?php |
---|
90 | if ($can_submit_requests) { |
---|
91 | echo $form->file('Request.FileUpload'); |
---|
92 | echo $form->button(__('Upload', true), array('type' => 'submit', 'id' => 'RequestFileSubmit')); |
---|
93 | } else { |
---|
94 | echo '<p>' . __('Officeshots is in closed beta. You need to <a href="/users/login">login</a> or <a href="/users/register">register</a> before you can upload documents.', true) . '</p>'; |
---|
95 | echo $form->file('Request.FileUpload', array('disabled' => true)); |
---|
96 | echo $form->button(__('Upload', true), array('type' => 'submit', 'disabled' => true, 'id' => 'RequestFileSubmit')); |
---|
97 | } |
---|
98 | ?> |
---|
99 | <div class="input radio" id="RequestFormatId"> |
---|
100 | <label><?php __('Output format:'); ?></label> |
---|
101 | <ul id="RequestFormatIdList"> |
---|
102 | <li> |
---|
103 | <input type="radio" name="data[Request][format_id]" id="RequestFormatIdNone" value="" checked="checked" /> |
---|
104 | <label for="RequestFormatIdNone"><?php __('Does not matter'); ?></label> |
---|
105 | </li> |
---|
106 | <?php |
---|
107 | foreach ($formats as $id => $name) { |
---|
108 | echo '<li><input type="radio" name="data[Request][format_id]" id="RequestFormatId' . $id . '" value="' . $id . '" />'; |
---|
109 | echo ' <label for="RequestFormatId' . $id . '">' . $name . '</label></li>'; |
---|
110 | } |
---|
111 | ?> |
---|
112 | </ul> |
---|
113 | </div> |
---|
114 | <?php |
---|
115 | if ($can_have_factories) { |
---|
116 | echo $form->input('own_factory', array('label' => __('Only use my own factories to process this request.', true))); |
---|
117 | } |
---|
118 | ?> |
---|
119 | </fieldset> |
---|
120 | <fieldset id="applications"> |
---|
121 | <legend><?php __('Choose applications'); ?></legend> |
---|
122 | <div id="applications-container"> |
---|
123 | |
---|
124 | <span id="select"> |
---|
125 | <?php __('Select:')?> <a href="javascript:select_apps('all')"><?php __('All');?></a> - |
---|
126 | <a href="javascript:select_apps('none')"><?php __('None');?></a> - |
---|
127 | <a href="javascript:select_apps('latest')"><?php __('Latest');?></a> - |
---|
128 | <a href="javascript:select_apps('development')"><?php __('Upcoming');?></a> |
---|
129 | <?php foreach ($platforms as $platform): ?> |
---|
130 | - <a href="javascript:select_apps('<?php echo $platform['Platform']['id'];?>')"><?php echo $platform['Platform']['name'];?></a> |
---|
131 | <?php endforeach; ?> |
---|
132 | </span> |
---|
133 | <?php foreach ($doctypes as $doctype): ?> |
---|
134 | <div> |
---|
135 | <h3 class="<?php echo implode(' ', Set::extract('/Mimetype[doctype_id='.$doctype['Doctype']['id'].']/extension', $mimetypes)); ?>"> |
---|
136 | <?php echo $doctype['Doctype']['name'];?> |
---|
137 | </h3> |
---|
138 | <div style="margin-bottom: 0;"> |
---|
139 | <table> |
---|
140 | <tr> |
---|
141 | <?php |
---|
142 | $width = (int) 100 / sizeof($platforms); |
---|
143 | foreach ($platforms as $platform) { |
---|
144 | echo '<th style="width: '.$width.'%"><span class="platform">' . $platform['Platform']['name'] . '</span></th>'; |
---|
145 | } |
---|
146 | ?> |
---|
147 | </tr> |
---|
148 | <tr> |
---|
149 | <?php foreach ($platforms as $platform): ?> |
---|
150 | <td> |
---|
151 | <?php |
---|
152 | foreach($workers as $worker) { |
---|
153 | if ($worker['Doctype']['code'] == $doctype['Doctype']['code'] && $worker['Platform']['name'] == $platform['Platform']['name']) { |
---|
154 | echo "\n" . '<input type="checkbox" name="data[Request][App][]" id="' . $worker['short_id'] . '" value="' . $worker['id'] . '" />' |
---|
155 | . "\n" . '<label for="' . $worker['short_id'] . '">' |
---|
156 | . $worker['Application']['name'] . ' ' |
---|
157 | . $worker['Worker']['version'] |
---|
158 | . "</label>\n"; |
---|
159 | } |
---|
160 | } |
---|
161 | ?> |
---|
162 | </td> |
---|
163 | <?php endforeach;?> |
---|
164 | </tr> |
---|
165 | </table> |
---|
166 | </div> |
---|
167 | </div> |
---|
168 | <?php endforeach; ?> |
---|
169 | |
---|
170 | </div> |
---|
171 | </fieldset> |
---|
172 | <?php echo $form->end(); ?> |
---|
173 | </div> |
---|
174 | |
---|