Felix Meschberger | 9b3c4e0 | 2008-06-02 13:52:15 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | * contributor license agreements. See the NOTICE file distributed with |
| 4 | * this work for additional information regarding copyright ownership. |
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | * (the "License"); you may not use this file except in compliance with |
| 7 | * the License. You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 17 | // ui elements |
| 18 | var uploadDialog = false; |
| 19 | var bundlesTable = false; |
| 20 | var bundlesBody = false; |
| 21 | var bundlesTemplate = false; |
Valentin Valchev | 984d466 | 2010-04-13 11:01:11 +0000 | [diff] [blame] | 22 | var bundleOpError = false; |
Valentin Valchev | 46e3c9c | 2012-04-26 12:15:55 +0000 | [diff] [blame] | 23 | var bundleOpSuccess = false; |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 24 | |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 25 | function renderData( eventData, filter ) { |
| 26 | lastBundleData = eventData; |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 27 | var s = eventData.s; |
Carsten Ziegeler | 3566a9f | 2013-01-30 16:20:33 +0000 | [diff] [blame] | 28 | var statline = i18n.statlinePrefix + ' ' + i18n.statlineTotal.msgFormat(s[0]); |
Carsten Ziegeler | 322d874 | 2013-01-30 15:56:09 +0000 | [diff] [blame] | 29 | if ( s[0] == s[1] || s[0] == s[1] + s[2]) { |
| 30 | statline += ' - ' + i18n.statlineAll.msgFormat(s[0]); |
| 31 | } else { |
| 32 | if ( s[1] > 0 ) { |
Carsten Ziegeler | 3566a9f | 2013-01-30 16:20:33 +0000 | [diff] [blame] | 33 | statline += ', ' + i18n.statlineActive.msgFormat(s[1]); |
Carsten Ziegeler | 322d874 | 2013-01-30 15:56:09 +0000 | [diff] [blame] | 34 | } |
| 35 | if ( s[2] > 0 ) { |
Carsten Ziegeler | 3566a9f | 2013-01-30 16:20:33 +0000 | [diff] [blame] | 36 | statline += ', ' + i18n.statlineFragments.msgFormat(s[2]); |
Carsten Ziegeler | 322d874 | 2013-01-30 15:56:09 +0000 | [diff] [blame] | 37 | } |
| 38 | if ( s[3] > 0 ) { |
Carsten Ziegeler | 3566a9f | 2013-01-30 16:20:33 +0000 | [diff] [blame] | 39 | statline += ', ' + i18n.statlineResolved.msgFormat(s[3]); |
Carsten Ziegeler | 322d874 | 2013-01-30 15:56:09 +0000 | [diff] [blame] | 40 | } |
| 41 | if ( s[4] > 0 ) { |
Carsten Ziegeler | 3566a9f | 2013-01-30 16:20:33 +0000 | [diff] [blame] | 42 | statline += ', ' + i18n.statlineInstalled.msgFormat(s[4]); |
Carsten Ziegeler | 322d874 | 2013-01-30 15:56:09 +0000 | [diff] [blame] | 43 | } |
| 44 | } |
| 45 | $('.statline').html(statline); |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 46 | bundlesBody.empty(); |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 47 | for ( var idx in eventData.data ) { |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 48 | if ( currentBundle == null || !drawDetails || currentBundle == eventData.data[idx].id) { |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 49 | entry( eventData.data[idx], filter ); |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 50 | } |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 51 | } |
Carsten Ziegeler | 176aee4 | 2009-12-11 09:19:50 +0000 | [diff] [blame] | 52 | if ( drawDetails && eventData.data.length == 1 ) { |
Valentin Valchev | 8d9f103 | 2010-03-19 07:54:14 +0000 | [diff] [blame] | 53 | $('.filterBox input, .filterBox button').addClass('ui-state-disabled'); |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 54 | renderDetails(eventData.data[0]); |
Carsten Ziegeler | 176aee4 | 2009-12-11 09:19:50 +0000 | [diff] [blame] | 55 | } else if ( currentBundle != null ) { |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 56 | var id = currentBundle; |
| 57 | hideDetails(id); |
| 58 | showDetails(id); |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 59 | } |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 60 | initStaticWidgets(); |
Valentin Valchev | 88dbf70 | 2010-04-14 13:15:06 +0000 | [diff] [blame] | 61 | |
Felix Meschberger | 7efb546 | 2011-12-22 12:53:44 +0000 | [diff] [blame] | 62 | var cv = getCookie("bundlelist"); |
A. J. David Bosschaert | 197992b | 2015-02-18 14:51:06 +0000 | [diff] [blame] | 63 | if (cv && bundlesTable.find("tr").size() > 1) { |
Felix Meschberger | 7efb546 | 2011-12-22 12:53:44 +0000 | [diff] [blame] | 64 | bundlesTable.trigger('sorton', [cv]); |
| 65 | } |
Valentin Valchev | 88dbf70 | 2010-04-14 13:15:06 +0000 | [diff] [blame] | 66 | |
Valentin Valchev | 7032d35 | 2015-03-10 08:35:19 +0000 | [diff] [blame] | 67 | if (bundlesBody.find('tr').size() == 0) { |
| 68 | bundlesBody.html('<tr><td colspan="6">' + i18n.filterNoMatch + '</td></tr>');
|
| 69 | } |
| 70 | |
Valentin Valchev | 984d466 | 2010-04-13 11:01:11 +0000 | [diff] [blame] | 71 | // show dialog on error |
| 72 | if (eventData.error) bundleOpError.dialog('open').find('pre').text(eventData.error) |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 73 | } |
| 74 | |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 75 | function entry( /* Object */ bundle, filter ) { |
| 76 | var matches = !(filter && typeof filter.test == 'function') ? true : |
Valentin Valchev | 8d9f103 | 2010-03-19 07:54:14 +0000 | [diff] [blame] | 77 | filter.test(bundle.id) || filter.test(bundle.name) || filter.test(bundle.symbolicName) || filter.test(bundle.version) || filter.test(bundle.category); |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 78 | |
| 79 | if (matches) entryInternal( bundle ).appendTo(bundlesBody); |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 80 | } |
| 81 | |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 82 | function hasStart(b) { return (!b.fragment) && (b.stateRaw == 2 || b.stateRaw == 4) } // !isFragment && (installed | resolved) |
| 83 | function hasStop(b) { return (!b.fragment) && (b.stateRaw == 32) } // !isFragment && active |
| 84 | function hasUninstall(b) { return b.stateRaw == 2 || b.stateRaw == 4 || b.stateRaw == 32 } // installed | resolved | active |
| 85 | function stateString(b) { |
| 86 | var s = b.stateRaw; |
| 87 | return b.fragment && s == 4 ? |
| 88 | i18n.state.fragment : // fragment & resolved |
| 89 | i18n.state[s] ? i18n.state[s] : i18n.state.unknown.msgFormat(s) |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 90 | } |
| 91 | |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 92 | function entryInternal( /* Object */ bundle ) { |
| 93 | var tr = bundlesTemplate.clone(); |
| 94 | var id = bundle.id; |
Valentin Valchev | 8d9f103 | 2010-03-19 07:54:14 +0000 | [diff] [blame] | 95 | var name = bundle.name + '<span class="symName">' + bundle.symbolicName + '</span>'; |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 96 | |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 97 | tr.attr('id', 'entry'+id); |
Felix Meschberger | 8285c42 | 2012-03-26 20:10:45 +0000 | [diff] [blame] | 98 | tr.children('td:eq(0)').text(id); |
Valentin Valchev | 16bef4a | 2010-04-15 08:45:47 +0000 | [diff] [blame] | 99 | tr.find('.bIcon').attr('id', 'img'+id).click(function() {showDetails(id)}); |
| 100 | tr.find('.bName').html( drawDetails ? name : '<a href="' + pluginRoot + '/' + id + '">' + name + '</a>' ); |
Felix Meschberger | 8285c42 | 2012-03-26 20:10:45 +0000 | [diff] [blame] | 101 | tr.children('td:eq(2)').text( bundle.version ); |
| 102 | tr.children('td:eq(3)').text( bundle.category ); |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 103 | if (id == 0) { // system bundle has no actions |
Felix Meschberger | 8285c42 | 2012-03-26 20:10:45 +0000 | [diff] [blame] | 104 | tr.children('td:eq(4)').text( stateString(bundle) ); |
| 105 | tr.children('td:eq(5)').find('ul').addClass('ui-helper-hidden'); |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 106 | } else { |
Valentin Valchev | 984d466 | 2010-04-13 11:01:11 +0000 | [diff] [blame] | 107 | entrySetupState( bundle, tr, id ); |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 108 | } |
| 109 | return tr; |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 110 | } |
Valentin Valchev | 984d466 | 2010-04-13 11:01:11 +0000 | [diff] [blame] | 111 | function entrySetupState( /* Object */ bundle, tr, id) { |
Felix Meschberger | 8285c42 | 2012-03-26 20:10:45 +0000 | [diff] [blame] | 112 | var start = tr.children('td:eq(5)').find('ul li:eq(0)').removeClass('ui-helper-hidden').unbind('click'); |
| 113 | var stop = tr.children('td:eq(5)').find('ul li:eq(1)').removeClass('ui-helper-hidden').unbind('click'); |
| 114 | var refresh = tr.children('td:eq(5)').find('ul li:eq(2)').unbind('click').click(function() {return changeDataEntryState(id, 'refresh')}); |
| 115 | var update = tr.children('td:eq(5)').find('ul li:eq(3)').unbind('click').click(function() {return changeDataEntryState(id, 'update')}); |
| 116 | var remove = tr.children('td:eq(5)').find('ul li:eq(4)').removeClass('ui-helper-hidden').unbind('click'); |
Valentin Valchev | 984d466 | 2010-04-13 11:01:11 +0000 | [diff] [blame] | 117 | start = hasStart(bundle) ? |
| 118 | start.click(function() {return changeDataEntryState(id, 'start')}) : |
| 119 | start.addClass('ui-helper-hidden'); |
| 120 | stop = hasStop(bundle) ? |
| 121 | stop.click(function() {return changeDataEntryState(id, 'stop')}) : |
| 122 | stop.addClass('ui-helper-hidden'); |
| 123 | remove = hasUninstall(bundle) ? |
| 124 | remove.click(function() {return changeDataEntryState(id, 'uninstall')}) : |
| 125 | remove.addClass('ui-helper-hidden'); |
Felix Meschberger | 8285c42 | 2012-03-26 20:10:45 +0000 | [diff] [blame] | 126 | tr.children('td:eq(4)').text( stateString(bundle) ); |
Valentin Valchev | 984d466 | 2010-04-13 11:01:11 +0000 | [diff] [blame] | 127 | } |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 128 | |
| 129 | function loadData() { |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 130 | $.get(pluginRoot + "/.json", null, renderData, "json"); |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | function changeDataEntryState(/* long */ id, /* String */ action) { |
Valentin Valchev | 984d466 | 2010-04-13 11:01:11 +0000 | [diff] [blame] | 134 | $.post(pluginRoot + '/' + id, {'action':action}, function(b) { |
| 135 | var _tr = bundlesBody.find('#entry' + id); |
| 136 | if (1 == b.stateRaw) { // uninstalled |
| 137 | _tr.remove(); |
| 138 | } else { |
| 139 | entrySetupState( b, _tr, id ); |
| 140 | } |
Valentin Valchev | 46e3c9c | 2012-04-26 12:15:55 +0000 | [diff] [blame] | 141 | if ('refresh' == action || 'update' == action) { |
| 142 | bundleOpSuccess.dialog('open'); |
| 143 | // TODO: |
| 144 | |
| 145 | } |
Valentin Valchev | 984d466 | 2010-04-13 11:01:11 +0000 | [diff] [blame] | 146 | }, 'json'); |
| 147 | return false; |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | function refreshPackages() { |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 151 | $.post(pluginRoot, {"action": "refreshPackages"}, renderData, "json"); |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | function showDetails( id ) { |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 155 | currentBundle = id; |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 156 | $.get(pluginRoot + "/" + id + ".json", null, function(data) { |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 157 | renderDetails(data.data[0]); |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 158 | }, "json"); |
| 159 | } |
| 160 | |
| 161 | function hideDetails( id ) { |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 162 | currentBundle = null; |
| 163 | $("#img" + id).each(function() { |
| 164 | $("#pluginInlineDetails" + id).remove(); |
| 165 | $(this). |
| 166 | removeClass('ui-icon-triangle-1-w').//left |
| 167 | removeClass('ui-icon-triangle-1-s').//down |
| 168 | addClass('ui-icon-triangle-1-e').//right |
| 169 | attr("title", "Details"). |
| 170 | unbind('click').click(function() {showDetails(id)}); |
| 171 | }); |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | function renderDetails( data ) { |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 175 | $("#entry" + data.id + " > td").eq(1).append("<div id='pluginInlineDetails" + data.id + "'/>"); |
| 176 | $("#img" + data.id).each(function() { |
| 177 | if ( drawDetails ) { |
| 178 | var ref = window.location.pathname; |
| 179 | ref = ref.substring(0, ref.lastIndexOf('/')); |
| 180 | $(this). |
| 181 | removeClass('ui-icon-triangle-1-e').//right |
| 182 | removeClass('ui-icon-triangle-1-s').//down |
| 183 | addClass('ui-icon-triangle-1-w').//left |
| 184 | attr("title", "Back"). |
| 185 | unbind('click').click(function() {window.location = ref}); |
| 186 | } else { |
| 187 | $(this). |
| 188 | removeClass('ui-icon-triangle-1-w').//left |
| 189 | removeClass('ui-icon-triangle-1-e').//right |
| 190 | addClass('ui-icon-triangle-1-s').//down |
| 191 | attr("title", "Hide Details"). |
| 192 | unbind('click').click(function() {hideDetails(data.id)}); |
| 193 | } |
| 194 | }); |
| 195 | $("#pluginInlineDetails" + data.id).append("<table border='0'><tbody></tbody></table>"); |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 196 | var details = data.props; |
| 197 | for (var idx in details) { |
| 198 | var prop = details[idx]; |
Valentin Valchev | 57ba7bc | 2012-08-15 12:48:53 +0000 | [diff] [blame] | 199 | |
| 200 | if (prop.key == 'nfo') { |
| 201 | $.each(prop.value, function(name, bundleInfo) { |
| 202 | var txt = ''; |
| 203 | $.each(bundleInfo, function(idx, ie) { |
| 204 | txt += '<div title="' + makeSafe(ie.description) + '">'; |
| 205 | if (ie.type == 'link' || ie.type == 'resource') { |
| 206 | txt += '<a href="' + ie.value + '">' + ie.name + '</a>'; |
| 207 | } else { |
| 208 | txt += ie.name + " = " + ie.value; |
| 209 | } |
| 210 | txt += '</div>'; |
| 211 | }); |
| 212 | $("#pluginInlineDetails" + data.id + " > table > tbody").append( |
| 213 | renderDetailsEntry(name, txt) ); |
| 214 | }); |
| 215 | } else |
| 216 | $("#pluginInlineDetails" + data.id + " > table > tbody").append( |
| 217 | renderDetailsEntry(prop.key, prop.value) ); |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 218 | } |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 219 | } |
Valentin Valchev | 57ba7bc | 2012-08-15 12:48:53 +0000 | [diff] [blame] | 220 | function makeSafe(text) { |
| 221 | return text.replace(/\W/g, function (chr) { |
| 222 | return '&#' + chr.charCodeAt(0) + ';'; |
| 223 | }); |
| 224 | }; |
| 225 | |
| 226 | function renderDetailsEntry(key, value) { |
| 227 | var key18 = i18n[key] ? i18n[key] : key; |
| 228 | var txt = "<tr><td class='aligntop' noWrap='true' style='border:0px none'>" + key18 + "</td><td class='aligntop' style='border:0px none'>"; |
| 229 | if (value) { |
| 230 | if ( key == 'Bundle Documentation' ) { |
| 231 | txt += "<a href='" + value + "' target='_blank'>" + value + "</a>"; |
| 232 | } else { |
| 233 | if ( $.isArray(value) ) { |
| 234 | var i = 0; |
| 235 | for(var pi in value) { |
| 236 | var xv = value[pi]; |
| 237 | if (i > 0) { txt = txt + "<br/>"; } |
| 238 | var span; |
| 239 | if (xv.substring(0, 6) == "INFO: ") { |
| 240 | txt += "<span class='ui-state-info-text'>" + xv.substring(5) + "</span>"; |
| 241 | } else if (xv.substring(0, 7) == "ERROR: ") { |
| 242 | txt += "<span class='ui-state-error-text'>" + xv.substring(6) + "</span>"; |
| 243 | } else { |
| 244 | txt += xv; |
| 245 | } |
| 246 | i++; |
| 247 | } |
| 248 | } else { |
| 249 | txt += value; |
| 250 | } |
| 251 | } |
| 252 | } else { |
| 253 | txt += "\u00a0"; |
| 254 | } |
| 255 | return txt + "</td></tr>"; |
| 256 | } |
Carsten Ziegeler | f987915 | 2009-02-05 10:45:35 +0000 | [diff] [blame] | 257 | |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 258 | |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 259 | $(document).ready(function(){ |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 260 | $('.refreshPackages').click(refreshPackages); |
| 261 | $('.reloadButton').click(loadData); |
| 262 | $('.installButton').click(function() { |
| 263 | uploadDialog.dialog('open'); |
| 264 | return false; |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 265 | }); |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 266 | |
Valentin Valchev | 984d466 | 2010-04-13 11:01:11 +0000 | [diff] [blame] | 267 | bundleOpError = $('#bundleOpError').dialog({ |
| 268 | autoOpen: false, |
| 269 | modal : true, |
| 270 | width : '80%' |
| 271 | }); |
| 272 | bundleOpError.parent().addClass('ui-state-error'); |
Valentin Valchev | 46e3c9c | 2012-04-26 12:15:55 +0000 | [diff] [blame] | 273 | bundleOpSuccess = $('#bundleOpSuccess').dialog({ |
| 274 | autoOpen: false, |
| 275 | modal : true, |
| 276 | width : '80%' |
| 277 | }); |
Valentin Valchev | 984d466 | 2010-04-13 11:01:11 +0000 | [diff] [blame] | 278 | |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 279 | // filter |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 280 | $('.filterApply').click(function() { |
Valentin Valchev | 8d9f103 | 2010-03-19 07:54:14 +0000 | [diff] [blame] | 281 | if ($(this).hasClass('ui-state-disabled')) return; |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 282 | var el = $(this).parent().find('input.filter'); |
| 283 | var filter = el.length && el.val() ? new RegExp(el.val()) : false; |
| 284 | renderData(lastBundleData, filter); |
| 285 | }); |
| 286 | $('.filterForm').submit(function() { |
| 287 | $(this).find('.filterApply').click(); |
| 288 | return false; |
| 289 | }); |
| 290 | $('.filterClear').click(function() { |
Valentin Valchev | 8d9f103 | 2010-03-19 07:54:14 +0000 | [diff] [blame] | 291 | if ($(this).hasClass('ui-state-disabled')) return; |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 292 | $('input.filter').val(''); |
Valentin Valchev | 8d9f103 | 2010-03-19 07:54:14 +0000 | [diff] [blame] | 293 | loadData(); |
| 294 | }); |
| 295 | $('.filterLDAP').click(function() { |
| 296 | if ($(this).hasClass('ui-state-disabled')) return; |
| 297 | var el = $(this).parent().find('input.filter'); |
| 298 | var filter = el.val(); |
| 299 | if (filter) $.get(pluginRoot + '/.json', { 'filter' : filter }, renderData, 'json'); |
Valentin Valchev | e569ba2 | 2010-04-01 09:26:49 +0000 | [diff] [blame] | 300 | return false; |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 301 | }); |
| 302 | |
| 303 | // upload dialog |
| 304 | var uploadDialogButtons = {}; |
| 305 | uploadDialogButtons[i18n.install_update] = function() { |
| 306 | $(this).find('form').submit(); |
| 307 | } |
| 308 | uploadDialog = $('#uploadDialog').dialog({ |
| 309 | autoOpen: false, |
| 310 | modal : true, |
| 311 | width : '50%', |
| 312 | buttons : uploadDialogButtons |
| 313 | }); |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 314 | |
| 315 | // check for cookie |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 316 | bundlesTable = $("#plugin_table").tablesorter({ |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 317 | headers: { |
| 318 | 0: { sorter:"digit" }, |
| 319 | 5: { sorter: false } |
| 320 | }, |
Valentin Valchev | 16bef4a | 2010-04-15 08:45:47 +0000 | [diff] [blame] | 321 | textExtraction:mixedLinksExtraction |
Felix Meschberger | efc5de5 | 2012-12-02 18:44:51 +0000 | [diff] [blame] | 322 | }).bind("sortEnd", function(/* Event */ e) { |
| 323 | var t = e.target.config; |
| 324 | if (t && t.sortList) { |
Felix Meschberger | 7efb546 | 2011-12-22 12:53:44 +0000 | [diff] [blame] | 325 | setCookie("bundlelist", t.sortList); |
| 326 | } |
| 327 | }); |
Valentin Valchev | ce0a432 | 2010-03-17 08:13:39 +0000 | [diff] [blame] | 328 | bundlesBody = bundlesTable.find('tbody'); |
| 329 | bundlesTemplate = bundlesBody.find('tr').clone(); |
| 330 | |
| 331 | renderData(lastBundleData); |
Felix Meschberger | 63d692a | 2010-02-18 15:29:39 +0000 | [diff] [blame] | 332 | }); |
| 333 | |