3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">Imgorg.ImageDv = Ext.extend(Ext.DataView,{
9 tpl: new Ext.XTemplate(
11 '<div class="thumb-wrap" id="{id}">',
12 '<div class="thumb"><img src="images/thumbs/{filename}" class="thumb-img"></div>',
13 '<span class="x-editable">{filename:ellipsis(15)}</span></div>',
17 initComponent: function() {
19 itemSelector: 'div.thumb-wrap',
20 style: 'overflow:auto',
22 overClass: 'x-view-over',
23 emptyText: 'No images to display',
24 plugins: [new Ext.DataView.DragSelector({
26 }), new Ext.DataView.LabelEditor({
31 store: new Ext.data.DirectStore({
32 directFn: Imgorg.ss.Images.load,
34 fields: ['filename', 'url', 'id', 'size']
38 this.addEvents('viewitem');
39 Imgorg.ImageDv.superclass.initComponent.call(this);
40 this.on({// hacks to force the labeleditor to stop editing when we get a click elsewhere
42 this.plugins[1].completeEdit();
44 containerclick: function(dv, e) {
45 this.plugins[1].completeEdit();
47 contextmenu: this.onContextMenu,
48 containercontextmenu: this.onContextMenu,
51 this.store.on('update', this.syncRename, this);
54 afterRender: function() {
55 Imgorg.ImageDv.superclass.afterRender.call(this);
56 this.el.unselectable(); // messy if they can select the text of the file names
59 onContextMenu: function(e, node) {
62 this.contMenu = new Ext.menu.Menu({
64 text: 'View in Tab(s)',
66 this.fireEvent('viewitem', this, node);
71 handler: this.selectAlbum,
79 handler: this.removeImages,
84 this.currentNode = node;
85 this.contMenu.showAt(e.getXY());
88 selectAlbum: function() {
90 this.albumWin = new Imgorg.AlbumWin();
92 this.albumWin.selectedRecords = this.getSelectedRecords();
93 this.albumWin.show(this.currentNode);
97 Imgorg.TagWin.selectedRecords = this.getSelectedRecords();
98 Imgorg.TagWin.show(this.currentNode);
101 syncRename: function(store, rec, op) {
103 Imgorg.ss.Images.rename({image: rec.data.id, name: rec.data.filename, url: rec.data.url});
107 removeImages: function() {
108 var recs = this.getSelectedRecords();
110 for (var i = 0;i < recs.length;i++) {
111 imageIds.push(recs[i].data.id);
112 this.store.remove(recs[i]);
114 Imgorg.ss.Images.remove({images: imageIds});
117 Ext.reg('img-dv', Imgorg.ImageDv);