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.

82 lines
2.5 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 xd = Ext.data;
  17. var store = new Ext.data.JsonStore({
  18. url: 'get-images.php',
  19. root: 'images',
  20. fields: ['name', 'url', {name:'size', type: 'float'}, {name:'lastmod', type:'date', dateFormat:'timestamp'}]
  21. });
  22. store.load();
  23. var tpl = new Ext.XTemplate(
  24. '<tpl for=".">',
  25. '<div class="thumb-wrap" id="{name}">',
  26. '<div class="thumb"><img src="{url}" title="{name}"></div>',
  27. '<span class="x-editable">{shortName}</span></div>',
  28. '</tpl>',
  29. '<div class="x-clear"></div>'
  30. );
  31. var panel = new Ext.Panel({
  32. id:'images-view',
  33. frame:true,
  34. width:535,
  35. autoHeight:true,
  36. collapsible:true,
  37. layout:'fit',
  38. title:'Simple DataView (0 items selected)',
  39. items: new Ext.DataView({
  40. store: store,
  41. tpl: tpl,
  42. autoHeight:true,
  43. multiSelect: true,
  44. overClass:'x-view-over',
  45. itemSelector:'div.thumb-wrap',
  46. emptyText: 'No images to display',
  47. plugins: [
  48. new Ext.DataView.DragSelector(),
  49. new Ext.DataView.LabelEditor({dataIndex: 'name'})
  50. ],
  51. prepareData: function(data){
  52. data.shortName = Ext.util.Format.ellipsis(data.name, 15);
  53. data.sizeString = Ext.util.Format.fileSize(data.size);
  54. data.dateString = data.lastmod.format("m/d/Y g:i a");
  55. return data;
  56. },
  57. listeners: {
  58. selectionchange: {
  59. fn: function(dv,nodes){
  60. var l = nodes.length;
  61. var s = l != 1 ? 's' : '';
  62. panel.setTitle('Simple DataView ('+l+' item'+s+' selected)');
  63. }
  64. }
  65. }
  66. })
  67. });
  68. panel.render(document.body);
  69. });