3 * Copyright(c) 2006-2010 Ext JS, LLC
5 * http://www.extjs.com/license
7 Imgorg.ImageDv = Ext.extend(Ext.DataView,{
8 tpl: new Ext.XTemplate(
10 '<div class="thumb-wrap" id="{id}">',
11 '<div class="thumb"><img src="images/thumbs/{filename}" class="thumb-img"></div>',
12 '<span class="x-editable">{filename:ellipsis(15)}</span></div>',
16 initComponent: function() {
18 itemSelector: 'div.thumb-wrap',
19 style: 'overflow:auto',
21 overClass: 'x-view-over',
22 emptyText: 'No images to display',
23 plugins: [new Ext.DataView.DragSelector({
25 }), new Ext.DataView.LabelEditor({
30 store: new Ext.data.DirectStore({
31 directFn: Imgorg.ss.Images.load,
33 fields: ['filename', 'url', 'id', 'size']
37 this.addEvents('viewitem');
38 Imgorg.ImageDv.superclass.initComponent.call(this);
39 this.on({// hacks to force the labeleditor to stop editing when we get a click elsewhere
41 this.plugins[1].completeEdit();
43 containerclick: function(dv, e) {
44 this.plugins[1].completeEdit();
46 contextmenu: this.onContextMenu,
47 containercontextmenu: this.onContextMenu,
50 this.store.on('update', this.syncRename, this);
53 afterRender: function() {
54 Imgorg.ImageDv.superclass.afterRender.call(this);
55 this.el.unselectable(); // messy if they can select the text of the file names
58 onContextMenu: function(e, node) {
61 this.contMenu = new Ext.menu.Menu({
63 text: 'View in Tab(s)',
65 this.fireEvent('viewitem', this, node);
70 handler: this.selectAlbum,
78 handler: this.removeImages,
83 this.currentNode = node;
84 this.contMenu.showAt(e.getXY());
87 selectAlbum: function() {
89 this.albumWin = new Imgorg.AlbumWin();
91 this.albumWin.selectedRecords = this.getSelectedRecords();
92 this.albumWin.show(this.currentNode);
96 Imgorg.TagWin.selectedRecords = this.getSelectedRecords();
97 Imgorg.TagWin.show(this.currentNode);
100 syncRename: function(store, rec, op) {
102 Imgorg.ss.Images.rename({image: rec.data.id, name: rec.data.filename, url: rec.data.url});
106 removeImages: function() {
107 var recs = this.getSelectedRecords();
109 for (var i = 0;i < recs.length;i++) {
110 imageIds.push(recs[i].data.id);
111 this.store.remove(recs[i]);
113 Imgorg.ss.Images.remove({images: imageIds});
116 Ext.reg('img-dv', Imgorg.ImageDv);