Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / docs / source / TagWin.html
1 <html>\r
2 <head>\r
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
6 </head>\r
7 <body  onload="prettyPrint();">\r
8     <pre class="prettyprint lang-js">Imgorg.TagWindow = Ext.extend(Ext.Window, {
9     title: 'Choose Tag',
10     layout: 'fit',
11     closeAction: 'hide',
12     width: 300,
13     modal: true,
14     
15     initComponent: function() {
16         Ext.apply(this, {
17             items: [{
18                 autoHeight: true,
19                 xtype: 'form',
20                 id: 'tag-select',
21                 bodyStyle: 'padding:15px',
22                 labelWidth: 50,
23                 items: [{
24                     anchor: '95%',
25                     fieldLabel: 'Tag',
26                     xtype: 'img-tagcombo',
27                     name: 'tag',
28                     allowBlank: false
29                 }]
30             }],
31             buttons: [{
32                 text: 'Tag Images',
33                 handler: this.tagImages,
34                 scope: this
35             },{
36                 text: 'Cancel',
37                 handler: function() {
38                     this.hide();
39                 },
40                 scope: this
41             }]
42         });
43         Imgorg.TagWindow.superclass.initComponent.call(this);
44     },
45     
46         
47     tagImages: function() {
48         var af = this.getComponent('tag-select').getForm();
49         if (af.isValid()) {
50             if (this.selectedRecords) {
51                 var imageIds = [];
52                 for (var i = 0; i < this.selectedRecords.length; i++) {
53                     var r = this.selectedRecords[i];
54                     imageIds.push(r.data.dbid || r.data.id);
55                 }
56                 var fld = af.findField('tag');
57                 var tag = fld.getRawValue();
58                 var idx = fld.store.find('text', tag);
59                 if (idx != -1) {
60                     rec = fld.store.getAt(idx);
61                     tag = rec.data.id;
62                 }
63                 Imgorg.ss.Images.tagImage({
64                     images: imageIds,
65                     tag: tag
66                 });
67             }
68             this.hide();
69         }
70     }
71 });
72
73 </pre>    \r
74 </body>\r
75 </html>