Skip to content

Commit

Permalink
Add disable autofill plugin, #1535
Browse files Browse the repository at this point in the history
  • Loading branch information
risadams committed Nov 10, 2020
1 parent 277b234 commit 3d1e301
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 2 deletions.
15 changes: 15 additions & 0 deletions examples/plugins.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,21 @@ <h2>Plugin: "restore_on_backspace"</h2>
</script>
</div>

<div class="demo">
<h2>Plugin: "autofill_disable"</h2>
<div class="control-group">
<label for="input-sortable">Tags:</label>
<input type="text" id="auto-complete-off" class="demo-default" value="no,auto,complete">
</div>
<script>
$('#auto-complete-off').selectize({
plugins: ['autofill_disable'],
persist: false,
create: true
});
</script>
</div>

<div class="demo">
<h2>Plugin: "drag_drop"</h2>
<div class="control-group">
Expand Down
30 changes: 30 additions & 0 deletions src/plugins/autofill_disable/plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Plugin: "autofill_disable" (selectize.js)
* Copyright (c) 2013 Brian Reavis & contributors
* Copyright (c) 2020 Ris Adams & contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at:
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*
* @author Ris Adams <[email protected]>
*/

Selectize.define("autofill_disable", function (options) {
var self = this;

self.setup = (function () {
var original = self.setup;
return function () {
original.apply(self, arguments);

// https://stackoverflow.com/questions/30053167/autocomplete-off-vs-false
self.$control_input.attr({ autocomplete: "new-password", autofill: "no" });
};
})();
});
1 change: 1 addition & 0 deletions src/plugins/drag_drop/plugin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* Plugin: "drag_drop" (selectize.js)
* Copyright (c) 2013 Brian Reavis & contributors
* Copyright (c) 2020 Ris Adams & contributors*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at:
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/dropdown_header/plugin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/**
* Plugin: "dropdown_header" (selectize.js)
* Copyright (c) 2013 Brian Reavis & contributors
*
* Copyright (c) 2020 Ris Adams & contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at:
* http://www.apache.org/licenses/LICENSE-2.0
Expand Down
1 change: 1 addition & 0 deletions src/plugins/optgroup_columns/plugin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* Plugin: "optgroup_columns" (selectize.js)
* Copyright (c) 2013 Simon Hewitt & contributors
* Copyright (c) 2020 Ris Adams & contributors*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at:
Expand Down
1 change: 1 addition & 0 deletions src/plugins/remove_button/plugin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* Plugin: "remove_button" (selectize.js)
* Copyright (c) 2013 Brian Reavis & contributors
* Copyright (c) 2020 Ris Adams & contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at:
Expand Down
1 change: 1 addition & 0 deletions src/plugins/restore_on_backspace/plugin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* Plugin: "restore_on_backspace" (selectize.js)
* Copyright (c) 2013 Brian Reavis & contributors
* Copyright (c) 2020 Ris Adams & contributors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at:
Expand Down
2 changes: 1 addition & 1 deletion src/selectize.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ $.extend(Selectize.prototype, {

$wrapper = $('<div>').addClass(settings.wrapperClass).addClass(classes).addClass(inputMode);
$control = $('<div>').addClass(settings.inputClass).addClass('items').appendTo($wrapper);
$control_input = $('<input type="text" autocomplete="off" />').appendTo($control).attr('tabindex', $input.is(':disabled') ? '-1' : self.tabIndex);
$control_input = $('<input type="text" autocomplete="new-password" autofill="no" />').appendTo($control).attr('tabindex', $input.is(':disabled') ? '-1' : self.tabIndex);
$dropdown_parent = $(settings.dropdownParent || $wrapper);
$dropdown = $('<div>').addClass(settings.dropdownClass).addClass(inputMode).hide().appendTo($dropdown_parent);
$dropdown_content = $('<div>').addClass(settings.dropdownContentClass).appendTo($dropdown);
Expand Down

0 comments on commit 3d1e301

Please sign in to comment.