]> source.dussan.org Git - nextcloud-server.git/commitdiff
jquery.combobox: Added 'editable' option and cleaned up a bit.
authorThomas Tanghus <thomas@tanghus.net>
Fri, 27 Apr 2012 02:01:34 +0000 (04:01 +0200)
committerThomas Tanghus <thomas@tanghus.net>
Fri, 27 Apr 2012 08:35:31 +0000 (10:35 +0200)
apps/contacts/js/jquery.combobox.js

index f46d7c14c183b7eb0bfc9efcf3bd16d795120cbc..25f0f09429645886dd784ee497c09180b55e128f 100644 (file)
                                                                        return false;
                                                                }
                                                        });
-                                                       /*if ( !valid ) {
+                                                       if ( !self.options['editable'] && !valid ) {
                                                                // remove invalid value, as it didn't match anything
                                                                $( this ).val( "" );
                                                                select.val( "" );
                                                                input.data( "autocomplete" ).term = "";
                                                                return false;
-                                                       }*/
+                                                       }
                                                }
                                        }
                                })
                                        input.autocomplete( "search", "" );
                                        input.focus();
                                });*/
+                       this.options['editable'] = true;
                        $.each(this.options, function(key, value) {
                                self._setOption(key, value);
                        });
                },
                destroy: function() {
                        this.input.remove();
-                       this.button.remove();
+                       //this.button.remove();
                        this.element.show();
                        $.Widget.prototype.destroy.call( this );
                },
                },
                _setOption: function( key, value ) {
                        switch( key ) {
-                               case "id":
+                               case 'id':
                                        this.options['id'] = value;
                                        this.input.attr('id', value);
                                        break;
-                               case "name":
+                               case 'name':
                                        this.options['name'] = value;
                                        this.input.attr('name', value);
                                        break;
-                               case "attributes":
+                               case 'attributes':
                                        var input = this.input;
                                        $.each(this.options['attributes'], function(key, value) {
                                                input.attr(key, value);
                                        });
                                        break;
-                               case "classes":
+                               case 'classes':
                                        var input = this.input;
                                        $.each(this.options['classes'], function(key, value) {
                                                input.addClass(value);
                                        });
                                        break;
+                               case 'editable':
+                                       this.options['editable'] = value;
+                                       break;
                        }
                        // In jQuery UI 1.8, you have to manually invoke the _setOption method from the base widget
                        $.Widget.prototype._setOption.apply( this, arguments );
                },
                options: { 
                        id: null,
-                       name: null
+                       name: null,
+                       editable: true
                },
        });
 })( jQuery );