/
searchpanel.js
42 lines (41 loc) · 1.17 KB
/
searchpanel.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*global Ext, PM*/
Ext.ns('PM');
PM.SearchPanel = Ext.extend(Ext.Container, {
layout: 'table',
style: 'padding: 5px',
initComponent: function () {
this.createItems();
PM.SearchPanel.superclass.initComponent.call(this);
this.addEvents('beforeload', 'load');
this.btn.on('click', this.loadImages, this);
},
createItems: function () {
this.items = [{
xtype: 'textfield',
value: 'coffee',
ref: 'field'
}, {
xtype: 'button',
text: 'Kép keresés',
style: 'margin-left: 5px',
ref: 'btn'
}];
},
loadImages: function () {
if (this.fireEvent('beforeload', this, this.field.getValue()) === false) {
return;
}
Ext.Ajax.request({
url: 'images.php',
params: {
q: this.field.getValue()
},
scope: this,
success: function (response) {
var result = Ext.decode(response.responseText);
this.fireEvent('load', this, result);
}
});
}
});
Ext.reg('searchPanel', PM.SearchPanel);