addon.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function ($, undefined, Backend, Table, Form, Template) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: Config.api_url ? Config.api_url + '/addon/index' : "addon/downloaded",
  8. add_url: '',
  9. edit_url: '',
  10. del_url: '',
  11. multi_url: ''
  12. }
  13. });
  14. var table = $("#table");
  15. // 弹窗自适应宽高
  16. var area = Fast.config.openArea != undefined ? Fast.config.openArea : [$(window).width() > 800 ? '800px' : '95%', $(window).height() > 600 ? '600px' : '95%'];
  17. table.on('load-success.bs.table', function (e, json) {
  18. if (json && typeof json.category != 'undefined' && $(".nav-category li").size() == 2) {
  19. $.each(json.category, function (i, j) {
  20. $("<li><a href='javascript:;' data-id='" + j.id + "'>" + j.name + "</a></li>").insertBefore($(".nav-category li:last"));
  21. });
  22. }
  23. });
  24. table.on('load-error.bs.table', function (e, status, res) {
  25. if (status == 404 && $(".btn-switch.active").data("type") != "local") {
  26. Layer.confirm(__('Store now available tips'), {
  27. title: __('Warmtips'),
  28. btn: [__('Switch to the local'), __('Try to reload')]
  29. }, function (index) {
  30. layer.close(index);
  31. $(".panel .nav-tabs").hide();
  32. $(".toolbar > *:not(:first)").hide();
  33. $(".btn-switch[data-type='local']").trigger("click");
  34. }, function (index) {
  35. layer.close(index);
  36. table.bootstrapTable('refresh');
  37. });
  38. return false;
  39. }
  40. });
  41. table.on('post-body.bs.table', function (e, settings, json, xhr) {
  42. var parenttable = table.closest('.bootstrap-table');
  43. var d = $(".fixed-table-toolbar", parenttable).find(".search input");
  44. d.off("keyup drop blur");
  45. d.on("keyup", function (e) {
  46. if (e.keyCode == 13) {
  47. var that = this;
  48. var options = table.bootstrapTable('getOptions');
  49. var queryParams = options.queryParams;
  50. options.pageNumber = 1;
  51. options.queryParams = function (params) {
  52. var params = queryParams(params);
  53. params.search = $(that).val();
  54. return params;
  55. };
  56. table.bootstrapTable('refresh', {});
  57. }
  58. });
  59. });
  60. Template.helper("Moment", Moment);
  61. Template.helper("addons", Config['addons']);
  62. $("#faupload-addon").data("params", function () {
  63. var userinfo = Controller.api.userinfo.get();
  64. return {
  65. uid: userinfo ? userinfo.id : '',
  66. token: userinfo ? userinfo.token : '',
  67. version: Config.faversion
  68. };
  69. });
  70. // 初始化表格
  71. table.bootstrapTable({
  72. url: $.fn.bootstrapTable.defaults.extend.index_url,
  73. queryParams: function (params) {
  74. var userinfo = Controller.api.userinfo.get();
  75. $.extend(params, {
  76. uid: userinfo ? userinfo.id : '',
  77. token: userinfo ? userinfo.token : '',
  78. version: Config.faversion
  79. });
  80. return params;
  81. },
  82. columns: [
  83. [
  84. {field: 'id', title: 'ID', operate: false, visible: false},
  85. {
  86. field: 'home',
  87. title: __('Index'),
  88. width: '50px',
  89. formatter: Controller.api.formatter.home
  90. },
  91. {field: 'name', title: __('Name'), operate: false, visible: false, width: '120px'},
  92. {
  93. field: 'title',
  94. title: __('Title'),
  95. operate: 'LIKE',
  96. align: 'left',
  97. formatter: Controller.api.formatter.title
  98. },
  99. {field: 'intro', title: __('Intro'), operate: 'LIKE', align: 'left', class: 'visible-lg'},
  100. {
  101. field: 'author',
  102. title: __('Author'),
  103. operate: 'LIKE',
  104. width: '100px',
  105. formatter: Controller.api.formatter.author
  106. },
  107. {
  108. field: 'price',
  109. title: __('Price'),
  110. operate: 'LIKE',
  111. width: '100px',
  112. align: 'center',
  113. formatter: Controller.api.formatter.price
  114. },
  115. {
  116. field: 'downloads',
  117. title: __('Downloads'),
  118. operate: 'LIKE',
  119. width: '80px',
  120. align: 'center',
  121. formatter: Controller.api.formatter.downloads
  122. },
  123. {
  124. field: 'version',
  125. title: __('Version'),
  126. operate: 'LIKE',
  127. width: '80px',
  128. align: 'center',
  129. formatter: Controller.api.formatter.version
  130. },
  131. {
  132. field: 'toggle',
  133. title: __('Status'),
  134. width: '80px',
  135. formatter: Controller.api.formatter.toggle
  136. },
  137. {
  138. field: 'id',
  139. title: __('Operate'),
  140. align: 'center',
  141. table: table,
  142. formatter: Controller.api.formatter.operate,
  143. align: 'right'
  144. },
  145. ]
  146. ],
  147. responseHandler: function (res) {
  148. $.each(res.rows, function (i, j) {
  149. j.addon = typeof Config.addons[j.name] != 'undefined' ? Config.addons[j.name] : null;
  150. });
  151. return res;
  152. },
  153. dataType: 'jsonp',
  154. templateView: false,
  155. clickToSelect: false,
  156. search: true,
  157. showColumns: false,
  158. showToggle: false,
  159. showExport: false,
  160. showSearch: false,
  161. commonSearch: true,
  162. searchFormVisible: true,
  163. searchFormTemplate: 'searchformtpl',
  164. pageSize: 50,
  165. });
  166. // 为表格绑定事件
  167. Table.api.bindevent(table);
  168. // 离线安装
  169. require(['upload'], function (Upload) {
  170. Upload.api.upload("#faupload-addon", function (data, ret) {
  171. Config['addons'][data.addon.name] = data.addon;
  172. Toastr.success(ret.msg);
  173. operate(data.addon.name, 'enable', false);
  174. return false;
  175. }, function (data, ret) {
  176. if (ret.msg && ret.msg.match(/(login|登录)/g)) {
  177. return Layer.alert(ret.msg, {
  178. title: __('Warning'),
  179. btn: [__('Login now')],
  180. yes: function (index, layero) {
  181. $(".btn-userinfo").trigger("click");
  182. }
  183. });
  184. }
  185. });
  186. //检测是否登录
  187. $(document).on("mousedown", "#faupload-addon", function (e) {
  188. var userinfo = Controller.api.userinfo.get();
  189. var uid = userinfo ? userinfo.id : 0;
  190. if (parseInt(uid) === 0) {
  191. $(".btn-userinfo").trigger("click");
  192. return false;
  193. }
  194. });
  195. });
  196. // 查看插件首页
  197. $(document).on("click", ".btn-addonindex", function () {
  198. if ($(this).attr("href") == 'javascript:;') {
  199. Layer.msg(__('Not installed tips'), {icon: 7});
  200. } else if ($(this).closest(".operate").find("a.btn-enable").size() > 0) {
  201. Layer.msg(__('Not enabled tips'), {icon: 7});
  202. return false;
  203. }
  204. });
  205. // 切换
  206. $(document).on("click", ".btn-switch", function () {
  207. $(".btn-switch").removeClass("active");
  208. $(this).addClass("active");
  209. $("form.form-commonsearch input[name='type']").val($(this).data("type"));
  210. table.bootstrapTable('refresh', {url: ($(this).data("url") ? $(this).data("url") : $.fn.bootstrapTable.defaults.extend.index_url), pageNumber: 1});
  211. return false;
  212. });
  213. $(document).on("click", ".nav-category li a", function () {
  214. $(".nav-category li").removeClass("active");
  215. $(this).parent().addClass("active");
  216. $("form.form-commonsearch input[name='category_id']").val($(this).data("id"));
  217. table.bootstrapTable('refresh', {url: $(this).data("url"), pageNumber: 1});
  218. return false;
  219. });
  220. var tables = [];
  221. $(document).on("click", "#droptables", function () {
  222. if ($(this).prop("checked")) {
  223. Fast.api.ajax({
  224. url: "addon/get_table_list",
  225. async: false,
  226. data: {name: $(this).data("name")}
  227. }, function (data) {
  228. tables = data.tables;
  229. return false;
  230. });
  231. var html;
  232. html = tables.length > 0 ? '<div class="alert alert-warning-light droptablestips" style="max-width:480px;max-height:300px;overflow-y: auto;">' + __('The following data tables will be deleted') + ':<br>' + tables.join("<br>") + '</div>'
  233. : '<div class="alert alert-warning-light droptablestips">' + __('The Addon did not create a data table') + '</div>';
  234. $(html).insertAfter($(this).closest("p"));
  235. } else {
  236. $(".droptablestips").remove();
  237. }
  238. $(window).resize();
  239. });
  240. // 会员信息
  241. $(document).on("click", ".btn-userinfo", function (e, name, version) {
  242. var that = this;
  243. var area = [$(window).width() > 800 ? '500px' : '95%', $(window).height() > 600 ? '400px' : '95%'];
  244. var userinfo = Controller.api.userinfo.get();
  245. if (!userinfo) {
  246. Layer.open({
  247. content: Template("logintpl", {}),
  248. zIndex: 99,
  249. area: area,
  250. title: __('Login FastAdmin'),
  251. resize: false,
  252. btn: [__('Login'), __('Register')],
  253. yes: function (index, layero) {
  254. Fast.api.ajax({
  255. url: Config.api_url + '/user/login',
  256. dataType: 'jsonp',
  257. data: {
  258. account: $("#inputAccount", layero).val(),
  259. password: $("#inputPassword", layero).val(),
  260. _method: 'POST'
  261. }
  262. }, function (data, ret) {
  263. Controller.api.userinfo.set(data);
  264. Layer.closeAll();
  265. Layer.alert(ret.msg);
  266. }, function (data, ret) {
  267. });
  268. },
  269. btn2: function () {
  270. return false;
  271. },
  272. success: function (layero, index) {
  273. this.checkEnterKey = function (event) {
  274. if (event.keyCode === 13) {
  275. $(".layui-layer-btn0").trigger("click");
  276. return false;
  277. }
  278. };
  279. $(document).on('keydown', this.checkEnterKey);
  280. $(".layui-layer-btn1", layero).prop("href", "http://www.fastadmin.net/user/register.html").prop("target", "_blank");
  281. },
  282. end: function () {
  283. $(document).off('keydown', this.checkEnterKey);
  284. }
  285. });
  286. } else {
  287. Fast.api.ajax({
  288. url: Config.api_url + '/user/index',
  289. dataType: 'jsonp',
  290. data: {
  291. user_id: userinfo.id,
  292. token: userinfo.token,
  293. }
  294. }, function (data) {
  295. Layer.open({
  296. content: Template("userinfotpl", userinfo),
  297. area: area,
  298. title: __('Userinfo'),
  299. resize: false,
  300. btn: [__('Logout'), __('Cancel')],
  301. yes: function () {
  302. Fast.api.ajax({
  303. url: Config.api_url + '/user/logout',
  304. dataType: 'jsonp',
  305. data: {uid: userinfo.id, token: userinfo.token}
  306. }, function (data, ret) {
  307. Controller.api.userinfo.set(null);
  308. Layer.closeAll();
  309. Layer.alert(ret.msg);
  310. }, function (data, ret) {
  311. Controller.api.userinfo.set(null);
  312. Layer.closeAll();
  313. Layer.alert(ret.msg);
  314. });
  315. }
  316. });
  317. return false;
  318. }, function (data) {
  319. Controller.api.userinfo.set(null);
  320. $(that).trigger('click');
  321. return false;
  322. });
  323. }
  324. });
  325. var install = function (name, version, force) {
  326. var userinfo = Controller.api.userinfo.get();
  327. var uid = userinfo ? userinfo.id : 0;
  328. var token = userinfo ? userinfo.token : '';
  329. Fast.api.ajax({
  330. url: 'addon/install',
  331. data: {
  332. name: name,
  333. force: force ? 1 : 0,
  334. uid: uid,
  335. token: token,
  336. version: version,
  337. faversion: Config.faversion
  338. }
  339. }, function (data, ret) {
  340. Layer.closeAll();
  341. Config['addons'][data.addon.name] = ret.data.addon;
  342. Layer.alert(__('Online installed tips'), {
  343. btn: [__('OK')],
  344. title: __('Warning'),
  345. icon: 1
  346. });
  347. Controller.api.refresh(table, name);
  348. }, function (data, ret) {
  349. //如果是需要购买的插件则弹出二维码提示
  350. if (ret && ret.code === -1) {
  351. //扫码支付
  352. Layer.open({
  353. content: Template("paytpl", ret.data),
  354. shade: 0.8,
  355. area: area,
  356. skin: 'layui-layer-msg layui-layer-pay',
  357. title: false,
  358. closeBtn: true,
  359. btn: false,
  360. resize: false,
  361. end: function () {
  362. Layer.alert(__('Pay tips'));
  363. }
  364. });
  365. } else if (ret && ret.code === -2) {
  366. //如果登录已经超时,重新提醒登录
  367. if (uid && uid != ret.data.uid) {
  368. Controller.api.userinfo.set(null);
  369. $(".operate[data-name='" + name + "'] .btn-install").trigger("click");
  370. return;
  371. }
  372. top.Fast.api.open(ret.data.payurl, __('Pay now'), {
  373. area: area,
  374. end: function () {
  375. top.Layer.alert(__('Pay tips'));
  376. }
  377. });
  378. } else if (ret && ret.code === -3) {
  379. //插件目录发现影响全局的文件
  380. Layer.open({
  381. content: Template("conflicttpl", ret.data),
  382. shade: 0.8,
  383. area: area,
  384. title: __('Warning'),
  385. btn: [__('Continue install'), __('Cancel')],
  386. end: function () {
  387. },
  388. yes: function () {
  389. install(name, version, true);
  390. }
  391. });
  392. } else {
  393. Layer.alert(ret.msg);
  394. }
  395. return false;
  396. });
  397. };
  398. var uninstall = function (name, force, droptables) {
  399. Fast.api.ajax({
  400. url: 'addon/uninstall',
  401. data: {name: name, force: force ? 1 : 0, droptables: droptables ? 1 : 0}
  402. }, function (data, ret) {
  403. delete Config['addons'][name];
  404. Layer.closeAll();
  405. Controller.api.refresh(table, name);
  406. }, function (data, ret) {
  407. if (ret && ret.code === -3) {
  408. //插件目录发现影响全局的文件
  409. Layer.open({
  410. content: Template("conflicttpl", ret.data),
  411. shade: 0.8,
  412. area: area,
  413. title: __('Warning'),
  414. btn: [__('Continue uninstall'), __('Cancel')],
  415. end: function () {
  416. },
  417. yes: function () {
  418. uninstall(name, true, droptables);
  419. }
  420. });
  421. } else {
  422. Layer.alert(ret.msg);
  423. }
  424. return false;
  425. });
  426. };
  427. var operate = function (name, action, force) {
  428. Fast.api.ajax({
  429. url: 'addon/state',
  430. data: {name: name, action: action, force: force ? 1 : 0}
  431. }, function (data, ret) {
  432. var addon = Config['addons'][name];
  433. addon.state = action === 'enable' ? 1 : 0;
  434. Layer.closeAll();
  435. Controller.api.refresh(table, name);
  436. }, function (data, ret) {
  437. if (ret && ret.code === -3) {
  438. //插件目录发现影响全局的文件
  439. Layer.open({
  440. content: Template("conflicttpl", ret.data),
  441. shade: 0.8,
  442. area: area,
  443. title: __('Warning'),
  444. btn: [__('Continue operate'), __('Cancel')],
  445. end: function () {
  446. },
  447. yes: function () {
  448. operate(name, action, true);
  449. }
  450. });
  451. } else {
  452. Layer.alert(ret.msg);
  453. }
  454. return false;
  455. });
  456. };
  457. var upgrade = function (name, version) {
  458. var userinfo = Controller.api.userinfo.get();
  459. var uid = userinfo ? userinfo.id : 0;
  460. var token = userinfo ? userinfo.token : '';
  461. Fast.api.ajax({
  462. url: 'addon/upgrade',
  463. data: {name: name, uid: uid, token: token, version: version, faversion: Config.faversion}
  464. }, function (data, ret) {
  465. Config['addons'][name] = data.addon;
  466. Layer.closeAll();
  467. Controller.api.refresh(table, name);
  468. }, function (data, ret) {
  469. Layer.alert(ret.msg);
  470. return false;
  471. });
  472. };
  473. // 点击安装
  474. $(document).on("click", ".btn-install", function () {
  475. var that = this;
  476. var name = $(this).closest(".operate").data("name");
  477. var version = $(this).data("version");
  478. var userinfo = Controller.api.userinfo.get();
  479. var uid = userinfo ? userinfo.id : 0;
  480. if (parseInt(uid) === 0) {
  481. return Layer.alert(__('Not login tips'), {
  482. title: __('Warning'),
  483. btn: [__('Login now')],
  484. yes: function (index, layero) {
  485. $(".btn-userinfo").trigger("click", name, version);
  486. },
  487. btn2: function () {
  488. install(name, version, false);
  489. }
  490. });
  491. }
  492. install(name, version, false);
  493. });
  494. // 点击卸载
  495. $(document).on("click", ".btn-uninstall", function () {
  496. var name = $(this).closest(".operate").data('name');
  497. if (Config['addons'][name].state == 1) {
  498. Layer.alert(__('Please disable the add before trying to uninstall'), {icon: 7});
  499. return false;
  500. }
  501. Template.helper("__", __);
  502. Layer.confirm(Template("uninstalltpl", {addon: Config['addons'][name]}), {focusBtn: false}, function (index, layero) {
  503. uninstall(name, false, $("input[name='droptables']", layero).prop("checked"));
  504. });
  505. });
  506. // 点击配置
  507. $(document).on("click", ".btn-config", function () {
  508. var name = $(this).closest(".operate").data("name");
  509. Fast.api.open("addon/config?name=" + name, __('Setting'));
  510. });
  511. // 点击启用/禁用
  512. $(document).on("click", ".btn-enable,.btn-disable", function () {
  513. var name = $(this).data("name");
  514. var action = $(this).data("action");
  515. operate(name, action, false);
  516. });
  517. // 点击升级
  518. $(document).on("click", ".btn-upgrade", function () {
  519. var name = $(this).closest(".operate").data('name');
  520. if (Config['addons'][name].state == 1) {
  521. Layer.alert(__('Please disable the add before trying to upgrade'), {icon: 7});
  522. return false;
  523. }
  524. var version = $(this).data("version");
  525. Layer.confirm(__('Upgrade tips', Config['addons'][name].title), function () {
  526. upgrade(name, version);
  527. });
  528. });
  529. $(document).on("click", ".operate .btn-group .dropdown-toggle", function () {
  530. $(this).closest(".btn-group").toggleClass("dropup", $(document).height() - $(this).offset().top <= 200);
  531. });
  532. $(document).on("click", ".view-screenshots", function () {
  533. var row = Table.api.getrowbyindex(table, parseInt($(this).data("index")));
  534. var data = [];
  535. $.each(row.screenshots, function (i, j) {
  536. data.push({
  537. "src": j
  538. });
  539. });
  540. var json = {
  541. "title": row.title,
  542. "data": data
  543. };
  544. top.Layer.photos(top.JSON.parse(JSON.stringify({photos: json})));
  545. });
  546. },
  547. add: function () {
  548. Controller.api.bindevent();
  549. },
  550. config: function () {
  551. Controller.api.bindevent();
  552. },
  553. api: {
  554. formatter: {
  555. title: function (value, row, index) {
  556. var title = '<a class="title" href="' + row.url + '" data-toggle="tooltip" title="' + __('View addon home page') + '" target="_blank">' + value + '</a>';
  557. if (row.screenshots && row.screenshots.length > 0) {
  558. title += ' <a href="javascript:;" data-index="' + index + '" class="view-screenshots text-success" title="' + __('View addon screenshots') + '" data-toggle="tooltip"><i class="fa fa-image"></i></a>';
  559. }
  560. return title;
  561. },
  562. operate: function (value, row, index) {
  563. return Template("operatetpl", {item: row, index: index});
  564. },
  565. toggle: function (value, row, index) {
  566. if (!row.addon) {
  567. return '';
  568. }
  569. return '<a href="javascript:;" data-toggle="tooltip" title="' + __('Click to toggle status') + '" class="btn btn-toggle btn-' + (row.addon.state == 1 ? "disable" : "enable") + '" data-action="' + (row.addon.state == 1 ? "disable" : "enable") + '" data-name="' + row.name + '"><i class="fa ' + (row.addon.state == 0 ? 'fa-toggle-on fa-rotate-180 text-gray' : 'fa-toggle-on text-success') + ' fa-2x"></i></a>';
  570. },
  571. author: function (value, row, index) {
  572. var url = 'javascript:';
  573. if (typeof row.homepage !== 'undefined') {
  574. url = row.homepage;
  575. } else if (typeof row.qq !== 'undefined' && row.qq) {
  576. url = 'https://wpa.qq.com/msgrd?v=3&uin=' + row.qq + '&site=fastadmin.net&menu=yes';
  577. }
  578. return '<a href="' + url + '" target="_blank" data-toggle="tooltip" class="text-primary">' + value + '</a>';
  579. },
  580. price: function (value, row, index) {
  581. if (isNaN(value)) {
  582. return value;
  583. }
  584. return parseFloat(value) == 0 ? '<span class="text-success">' + __('Free') + '</span>' : '<span class="text-danger">¥' + value + '</span>';
  585. },
  586. downloads: function (value, row, index) {
  587. return value;
  588. },
  589. version: function (value, row, index) {
  590. return row.addon && row.addon.version != row.version ? '<a href="' + row.url + '?version=' + row.version + '" target="_blank"><span class="releasetips text-primary" data-toggle="tooltip" title="' + __('New version tips', row.version) + '">' + row.addon.version + '<i></i></span></a>' : row.version;
  591. },
  592. home: function (value, row, index) {
  593. return row.addon && parseInt(row.addon.state) > 0 ? '<a href="' + row.addon.url + '" data-toggle="tooltip" title="' + __('View addon index page') + '" target="_blank"><i class="fa fa-home text-primary"></i></a>' : '<a href="javascript:;"><i class="fa fa-home text-gray"></i></a>';
  594. },
  595. },
  596. bindevent: function () {
  597. Form.api.bindevent($("form[role=form]"));
  598. },
  599. userinfo: {
  600. get: function () {
  601. var userinfo = localStorage.getItem("fastadmin_userinfo");
  602. return userinfo ? JSON.parse(userinfo) : null;
  603. },
  604. set: function (data) {
  605. if (data) {
  606. localStorage.setItem("fastadmin_userinfo", JSON.stringify(data));
  607. } else {
  608. localStorage.removeItem("fastadmin_userinfo");
  609. }
  610. }
  611. },
  612. refresh: function (table, name) {
  613. //刷新左侧边栏
  614. Fast.api.refreshmenu();
  615. //刷新行数据
  616. if ($(".operate[data-name='" + name + "']").length > 0) {
  617. var index = $(".operate[data-name='" + name + "']").closest("tr[data-index]").data("index");
  618. var row = Table.api.getrowbyindex(table, index);
  619. row.addon = typeof Config['addons'][name] !== 'undefined' ? Config['addons'][name] : undefined;
  620. table.bootstrapTable("updateRow", {index: index, row: row});
  621. } else if ($(".btn-switch.active").data("type") == "local") {
  622. $(".btn-refresh").trigger("click");
  623. }
  624. }
  625. }
  626. };
  627. return Controller;
  628. });