You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.1 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. This file is part of Ext JS 3.4
  3. Copyright (c) 2011-2013 Sencha Inc
  4. Contact: http://www.sencha.com/contact
  5. GNU General Public License Usage
  6. This file may be used under the terms of the GNU General Public License version 3.0 as
  7. published by the Free Software Foundation and appearing in the file LICENSE included in the
  8. packaging of this file.
  9. Please review the following information to ensure the GNU General Public License version 3.0
  10. requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  11. If you are unsure which license is appropriate for your use, please contact the sales department
  12. at http://www.sencha.com/contact.
  13. Build date: 2013-04-03 15:07:25
  14. */
  15. Ext.onReady(function(){
  16. var store = new Ext.data.JsonStore({
  17. url: 'get-images.php',
  18. root: 'images',
  19. fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date', dateFormat:'timestamp'}]
  20. });
  21. store.load();
  22. var listView = new Ext.list.ListView({
  23. store: store,
  24. multiSelect: true,
  25. emptyText: 'No images to display',
  26. reserveScrollOffset: true,
  27. columns: [{
  28. header: 'File',
  29. width: .5,
  30. dataIndex: 'name'
  31. },{
  32. header: 'Last Modified',
  33. xtype: 'datecolumn',
  34. format: 'm-d h:i a',
  35. width: .35,
  36. dataIndex: 'lastmod'
  37. },{
  38. header: 'Size',
  39. dataIndex: 'size',
  40. tpl: '{size:fileSize}',
  41. align: 'right',
  42. cls: 'listview-filesize'
  43. }]
  44. });
  45. // put it in a Panel so it looks pretty
  46. var panel = new Ext.Panel({
  47. id:'images-view',
  48. width:425,
  49. height:250,
  50. collapsible:true,
  51. layout:'fit',
  52. title:'Simple ListView <i>(0 items selected)</i>',
  53. items: listView
  54. });
  55. panel.render(document.body);
  56. // little bit of feedback
  57. listView.on('selectionchange', function(view, nodes){
  58. var l = nodes.length;
  59. var s = l != 1 ? 's' : '';
  60. panel.setTitle('Simple ListView <i>('+l+' item'+s+' selected)</i>');
  61. });
  62. });