Merge branch 'maint/7.0'
[ninja.git] / modules / lsfilter / media / js / LSFilterTextarea.js
blobebf5ea072291eaecd5770c843d6bcd040fc2e935
1 var lsfilter_textarea = {
2         // Configuration
4         // External methods
5         init: function(element, orderelement)
6         {
7                 var self = this; // To be able to access it from within handlers
9                 this.element = element;
10                 this.orderelement = orderelement;
11                 this.element.bind('keyup paste cut', function(evt)
12                 {
13                         var query = $.trim((self.element.val()).toString());
14                         lsfilter_main.update_delayed(query, 'textarea');
15                 });
16         },
17         on: {
18                 'update_failed': function() {
19                         this.element.css("border", "2px solid #f40");
20                 },
21                 'update_ok': function(data) {
22                         if (!this.element)
23                                 return;
24                         this.element.css("border", "2px solid #5d2");
25                         if (data.source == 'textarea') return;
26                         this.element.val(data.query);
27                 }
28         },
29         load: function()
30         {
31                 var query = this.element.val();
32                 var order = this.orderelement.val();
34                 lsfilter_main.update(query, 'textarea', order);
35         },
37         // Internal veriables
38         element: false,
39         orderelement: false,