OSDN Git Service

Improved the method of opening a dialog.
[mtpm/PluginManager.git] / tmpl / include / pm_package_list_table.tmpl
1 <style>
2 .updated img {
3         background-image:url(<mt:StaticWebPath />images/status_icons/success.gif);
4 }
5 .need_upgrade img {
6         background-image:url(<mt:StaticWebPath />images/status_icons/warning.gif);
7 }
8 .not_installed img {
9         background-image:url(<mt:StaticWebPath />images/status_icons/draft.gif);
10 }
11
12 .listing th.title {
13         width: 130px;
14 }
15 .listing th.category {
16         width: 50px;
17 }
18 .listing th.author {
19         ;
20 }
21 .listing th.compatiblity {
22         width: 50px;
23 }
24 .listing th.license {
25         width: 58px;
26 }
27 .listing th.target {
28         width: 80px;
29 }
30
31 .listing td.cb {
32         vertical-align: middle;
33 }
34
35 .listing td.description {
36         border-top: 1px dotted #999;
37 }
38 </style>
39
40 <form id="do_upgrade_form">
41
42
43 <div class="filter first-child last-child">
44         <div>
45                         <__trans phrase="Status" />
46                         <select id="status">
47                                 <option value="" class="first-child"><__trans phrase="Not specified" /></option>
48                                 <option value="not_installed"><__trans phrase="Not installed" /></option>
49                                 <option value="installed"><__trans phrase="Installed" /></option>
50                                 <option value="need_upgrade" class="last-child"><__trans phrase="Need upgrade" /></option>
51                         </select>
52         </div>
53         <div>
54                         <__trans phrase="Category" />
55                         <select id="category">
56                                 <option value="" class="first-child"><__trans phrase="Not specified" /></option>
57
58                                 <option value="action streams"><__trans phrase="Action Streams" /></option>
59                                 <option value="administrative/user interface"><__trans phrase="Administrative/User Interface" /></option>
60                                 <option value="anti-spam"><__trans phrase="Anti-spam" /></option>
61                                 <option value="commenting"><__trans phrase="Commenting" /></option>
62                                 <option value="community"><__trans phrase="Community" /></option>
63                                 <option value="developer"><__trans phrase="Developer" /></option>
64                                 <option value="organization"><__trans phrase="Organization" /></option>
65                                 <option value="photos"><__trans phrase="Photos" /></option>
66                                 <option value="template set"><__trans phrase="Template Set" /></option>
67                                 <option value="template/tag helpers"><__trans phrase="Template/Tag Helpers" /></option>
68                                 <option value="text formatting"><__trans phrase="Text Formatting" /></option>
69                                 <option value="utility"><__trans phrase="Utility" /></option>
70                                 <option value="web services"><__trans phrase="Web Services" /></option>
71                                 <option value="widgets"><__trans phrase="Widgets" /></option>
72
73                                 <option value="joke"><__trans phrase="Joke" /></option>
74                         </select>
75         </div>
76         <div>
77                         <__trans phrase="Compatiblity" />
78                         <select id="compatiblity">
79                                 <option value="" class="first-child"><__trans phrase="Not specified" /></option>
80                                 <option value="4">4</option>
81                                 <option value="5">5</option>
82                         </select>
83         </div>
84         <div>
85                         <__trans phrase="License" />
86                         <select id="license">
87                                 <option value="" class="first-child"><__trans phrase="Not specified" /></option>
88                                 <option value="freeware"><__trans phrase="Freeware" /></option>
89                                 <option value="donationware"><__trans phrase="Donationware" /></option>
90                                 <option value="shareware"><__trans phrase="Shareware" /></option>
91                                 <option value="commercial"><__trans phrase="Commercial" /></option>
92                                 <option value="gpl"><__trans phrase="GPL" /></option>
93                                 <option value="bsd"><__trans phrase="BSD" /></option>
94                                 <option value="mit"><__trans phrase="MIT" /></option>
95                                 <option value="perl artistic"><__trans phrase="Perl Artistic" /></option>
96                                 <option value="multiple"><__trans phrase="Multiple" /></option>
97                         </select>
98         </div>
99         <div>
100                         <__trans phrase="Target" />
101                         <select id="target">
102                                 <option value="" class="first-child"><__trans phrase="Not specified" /></option>
103                                 <option value="open source"><__trans phrase="Open Source" /></option>
104                                 <option value="commercial"><__trans phrase="Commercial" /></option>
105                                 <option value="enterprise "><__trans phrase="Enterprise " /></option>
106                         </select>
107         </div>
108         <div>
109                 <button onclick="update_table(); return false"><__trans phrase="Filter" /></button>
110         </div>
111 </div>
112
113 <br />
114
115 <div id="actions-bar-top" class="actions-bar actions-bar-top">
116     <span class="button-actions actions">
117                 <button
118                         accesskey="r"
119                         title=""
120                         id="do_update"
121                         onclick="window.location.href = '<mt:var name="link_package_update">'; return false;"
122                 ><__trans phrase="Update Packages"></button>
123         </span>
124 </div>
125
126 <div id="actions-bar-top" class="actions-bar actions-bar-top">
127 <!--
128         <div id="pagination-top" class="pagination">
129                 <span class="start-disabled"><em>&lt;&lt;</em>&nbsp;</span>
130                 <span class="to-start-disabled"><em>&lt;</em>&nbsp;</span>
131                 <span class="current-rows">1 &ndash; 112 / 112</span>
132                 <span class="to-end-disabled">&nbsp;<em>&gt;</em></span>
133                 <span class="end-disabled">&nbsp;<em>&gt;&gt;</em></span>
134         </div>
135 -->
136
137     <span class="button-actions actions">
138                 <button
139                         accesskey="r"
140                         title=""
141                         id="do_upgrade"
142                 ><__trans phrase="Install / Upgrade"></button>
143                 <button
144                         accesskey="x"
145                         title=""
146                         id="do_remove"
147                 ><__trans phrase="Remove"></button>
148         </span>
149
150 <!--
151     <span class="plugin-actions actions">
152         <select name="plugin_action_selector" onchange="updatePluginAction(this)">
153                 <option value="0">アクション...</option>
154                 <option value="set_draft">ブログ記事の公開を取り消し</option>
155                 <option value="add_tags">タグの追加</option>
156                 <option value="remove_tags">タグの削除</option>
157         </select>
158         <button
159                 class="small-button mt-entry-listing-form-action"
160         >Go</button>
161     </span>
162 -->
163 </div>
164
165 <div class="listing">
166 <!--
167 <table id="package_table">
168 -->
169 <table id="package_table" class="entry-listing-table compact" cellspacing="0">
170         <thead>
171             <tr>
172                 <th class="cb"><input type="checkbox" name="id-head" value="all" class="select" /></th>
173                 <th class="status si">
174                     <img src="<mt:StaticWebPath />images/status_icons/invert-flag.gif" alt="" title="" width="9" height="9" />
175                 </th>
176                 <th class="title primary-col"><__trans phrase="Name" /></th>
177                                 <th class="category"><__trans phrase="Category" /></th>
178                 <th class="author"><__trans phrase="Author" /></th>
179                 <th class="compatiblity"><__trans phrase="Compatiblity" /></th>
180                 <th class="license"><__trans phrase="License" /></th>
181                 <th class="target"><__trans phrase="Target" /></th>
182             </tr>
183         </thead>
184         <tfoot>
185             <tr>
186                 <th class="cb"><input type="checkbox" name="id-head" value="all" class="select" /></th>
187                 <th class="status si">
188                     <img src="<mt:StaticWebPath />images/status_icons/invert-flag.gif" alt="" title="" width="9" height="9" />
189                 </th>
190                 <th class="title primary-col"><__trans phrase="Name" /></th>
191                                 <th class="category"><__trans phrase="Category" /></th>
192                 <th class="author"><__trans phrase="Author" /></th>
193                 <th class="compatiblity"><__trans phrase="Compatiblity" /></th>
194                 <th class="license"><__trans phrase="License" /></th>
195                 <th class="target"><__trans phrase="Target" /></th>
196             </tr>
197         </tfoot>
198                 <tbody>
199
200 <tr id="package_row_template">
201         <td rowspan="2" class="cb">
202                 <input type="hidden" class="version" name="" value="" />
203                 <input type="checkbox" name="packages" value="" />
204         </td>
205         <td><img width="9" height="9" alt="" src="<mt:StaticWebPath />images/spacer.gif"/></td>
206         <td class="package_name"> </td>
207         <td class="category"> </td>
208         <td class="author"> </td>
209         <td class="compatiblity"> </td>
210         <td class="license"> </td>
211         <td class="target"> </td>
212 </tr>
213 <tr id="package_row_template2">
214         <td class="description" colspan="7"> </td>
215 </tr>
216
217 </tbody>
218 </table>
219 </div>
220
221 <script type="text/javascript">
222 var update_table = function() { };
223 jQuery(function() {
224         $ = jQuery;
225         var table = $('#package_table tbody');
226         var tmpl = $('#package_row_template');
227         var tmpl2 = $('#package_row_template2');
228
229         $('input[type="checkbox"].select').click(function() {
230                 $('input[type="checkbox"]').attr('checked', this.checked);
231         });
232
233         var packages = {
234         <mt:loop name="packages" glue=",">
235                 '<mt:var name="__key__" encode_js="1">': {
236                 <mt:loop name="__value__" glue=",">
237                         '<mt:var name="__key__" encode_js="1">': {
238                                 'id': '<mt:var name="__value__{id}" encode_js="1">',
239                                 'name': '<mt:var name="__value__{name}" encode_js="1">',
240                                 'version': '<mt:var name="__value__{version}" encode_js="1">',
241                                 'author_link': '<mt:var name="__value__{author_link}" encode_js="1">',
242                                 'author_name': '<mt:var name="__value__{author_name}" encode_js="1">',
243                                 'description': '<mt:var name="__value__{description}" encode_js="1">',
244                                 'doc_link': '<mt:var name="__value__{doc_link}" encode_js="1">',
245                                 'plugin_link': '<mt:var name="__value__{plugin_link}" encode_js="1">',
246
247                                 'category': '<mt:var name="__value__{category}" encode_js="1">',
248                                 <mt:var name="__value__{compatiblity}" setvar="compatiblity" />
249                                 'compatiblity': [<mt:loop name="compatiblity" glue=",">'<mt:var name="__value__" encode_js="1">'</mt:loop>],
250                                 'license': '<mt:var name="__value__{license}" encode_js="1">',
251                                 <mt:var name="__value__{target}" setvar="target" />
252                                 'target': [<mt:loop name="target" glue=",">'<mt:var name="__value__" encode_js="1">'</mt:loop>],
253
254                                 'installed': '<mt:var name="__value__{installed}" encode_js="1" >'
255                         }
256                 </mt:loop>
257                 }
258         </mt:loop>
259         };
260
261         function version_compare(a, b) {
262                 var atmp = a.replace(/\D/, '.').replace(/\.+/, '.').split(/\./);
263                 var btmp = b.replace(/\D/, '.').replace(/\.+/, '.').split(/\./);
264
265                 var i = 0;
266                 while (true) {
267                         if (! atmp[i]) {
268                                 if (btmp[i]) {
269                                         return -1;
270                                 }
271                                 else {
272                                         return 0;
273                                 }
274                         }
275                         else if (! btmp[i]) {
276                                 return 1;
277                         }
278                         else if (atmp[i] != btmp[i]) {
279                                 return atmp[i] - btmp[i];
280                         }
281                         i++;
282                 }
283         }
284
285         update_table = function(filter) {
286                 table.children().remove();
287                 var index = 0;
288
289                 var filters = [];
290                 filters['status'] = $('#status').val().toLowerCase();
291                 filters['category'] = $('#category').val().toLowerCase();
292                 filters['compatiblity'] = $('#compatiblity').val().toLowerCase();
293                 filters['license'] = $('#license').val().toLowerCase();;
294                 filters['target'] = $('#target').val().toLowerCase();
295                 var auto_filter1 = ['category', 'license'];
296                 var auto_filter2 = ['compatiblity', 'target'];
297
298                 $.each(packages, function(k, v) {
299                         var version = "0";
300                         var installed_version = "";
301                         var param = {};
302                         $.each(v, function(kk, vv) {
303                                 if (version_compare(kk, version) > 0) {
304                                         $.each(vv, function(kkk, vvv) {
305                                                 param[kkk] = vvv;
306                                         });
307                                         version = kk;
308                                 }
309
310                                 if (vv.installed) {
311                                         installed_version = kk;
312                                 }
313                         });
314
315
316                         for (var i = 0; i < auto_filter1.length; i++) {
317                                 var filter_key = auto_filter1[i];
318                                 if (
319                                         (filters[filter_key] != '')
320                                         && (filters[filter_key] != param[filter_key].toLowerCase())
321                                 ) {
322                                         return true;
323                                 }
324                         }
325
326                         for (var i = 0; i < auto_filter2.length; i++) {
327                                 var filter_key = auto_filter2[i];
328                                 if (filters[filter_key] != '') {
329                                         var found = false;
330
331                                         for (var j = 0; j < param[filter_key].length; j++) {
332                                                 if (filters[filter_key] == param[filter_key][j]) {
333                                                         found = true;
334                                                 }
335                                         }
336
337                                         if (! found) {
338                                                 return true;
339                                         }
340                                 }
341                         }
342
343                         var row = tmpl.clone();
344                         if ((index % 2) == 1) {
345                                 row.addClass('even');
346                         }
347
348                         if (installed_version) {
349                                 if (installed_version == version) {
350                                         row.addClass('updated');
351                                         if (
352                                                 (filters['status'] != '')
353                                                 && (filters['status'] != 'installed') 
354                                         ) {
355                                                 return true;
356                                         }
357                                 }
358                                 else {
359                                         row.addClass('need_upgrade');
360                                         if (
361                                                 (filters['status'] != '')
362                                                 && (filters['status'] != 'installed') 
363                                                 && (filters['status'] != 'need_upgrade') 
364                                         ) {
365                                                 return true;
366                                         }
367                                 }
368                         }
369                         else {
370                                 row.addClass('not_installed');
371                                 if (
372                                         (filters['status'] != '')
373                                         && (filters['status'] != 'not_installed') 
374                                 ) {
375                                         return true;
376                                 }
377                         }
378
379                         row.find('.version').
380                                 attr('name', param.id).
381                                 val(param.version);
382                         row.find('[name="packages"]').val(param.id);
383                         row.find('.package_name').append(param.name);
384                         row.find('.category').append(param.category);
385                         row.find('.compatiblity').append(param.compatiblity.join(','));
386                         row.find('.license').append(param.license);
387                         row.find('.target').append(param.target.join('<br />'));
388
389                         if (param.author_link) {
390                                 row.find('.author').append(
391                                         '<a href="' + param.author_link + '" target="_blank">'
392                                         + param.author_name + '</a>'
393                                 );
394                         }
395                         else {
396                                 row.find('.author').append(param.author_name);
397                         }
398
399                         row.show();
400
401                         table.append(row);
402
403
404                         var row2 = tmpl2.clone();
405                         if ((index % 2) == 1) {
406                                 row2.addClass('even');
407                         }
408                         row2.find('.description').append(param.description);
409                         row2.show();
410                         table.append(row2);
411
412
413                         index++;
414                 });
415         };
416
417         update_table();
418 });
419 </script>
420
421 </form>