mirror of
				https://github.com/Jermolene/TiddlyWiki5
				synced 2025-10-31 15:42:59 +00:00 
			
		
		
		
	Add disabled parameter to select widget and browse widget (#8816)
* Add disabled parameter to select widget and browse widget * Add disabled attribute to edit-shortcut
This commit is contained in:
		| @@ -56,6 +56,9 @@ BrowseWidget.prototype.render = function(parent,nextSibling) { | |||||||
| 	if(this.nwdirectory) { | 	if(this.nwdirectory) { | ||||||
| 		domNode.setAttribute("nwdirectory",this.nwdirectory); | 		domNode.setAttribute("nwdirectory",this.nwdirectory); | ||||||
| 	} | 	} | ||||||
|  | 	if(this.isDisabled === "yes") { | ||||||
|  | 		domNode.setAttribute("disabled", true); | ||||||
|  | 	} | ||||||
| 	// Add a click event handler | 	// Add a click event handler | ||||||
| 	domNode.addEventListener("change",function (event) { | 	domNode.addEventListener("change",function (event) { | ||||||
| 		if(self.message) { | 		if(self.message) { | ||||||
| @@ -94,6 +97,7 @@ BrowseWidget.prototype.execute = function() { | |||||||
| 	this.accept = this.getAttribute("accept"); | 	this.accept = this.getAttribute("accept"); | ||||||
| 	this.webkitdirectory = this.getAttribute("webkitdirectory"); | 	this.webkitdirectory = this.getAttribute("webkitdirectory"); | ||||||
| 	this.nwdirectory = this.getAttribute("nwdirectory"); | 	this.nwdirectory = this.getAttribute("nwdirectory"); | ||||||
|  | 	this.isDisabled = this.getAttribute("disabled", "no"); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| /* | /* | ||||||
|   | |||||||
| @@ -48,6 +48,9 @@ EditShortcutWidget.prototype.render = function(parent,nextSibling) { | |||||||
| 	if(this.shortcutAriaLabel) { | 	if(this.shortcutAriaLabel) { | ||||||
| 		this.inputNode.setAttribute("aria-label",this.shortcutAriaLabel); | 		this.inputNode.setAttribute("aria-label",this.shortcutAriaLabel); | ||||||
| 	} | 	} | ||||||
|  | 	if(this.isDisabled === "yes") { | ||||||
|  | 		this.inputNode.setAttribute("disabled", true); | ||||||
|  | 	} | ||||||
| 	// Assign the current shortcut | 	// Assign the current shortcut | ||||||
| 	this.updateInputNode(); | 	this.updateInputNode(); | ||||||
| 	// Add event handlers | 	// Add event handlers | ||||||
| @@ -77,6 +80,7 @@ EditShortcutWidget.prototype.execute = function() { | |||||||
| 	this.shortcutTooltip = this.getAttribute("tooltip"); | 	this.shortcutTooltip = this.getAttribute("tooltip"); | ||||||
| 	this.shortcutAriaLabel = this.getAttribute("aria-label"); | 	this.shortcutAriaLabel = this.getAttribute("aria-label"); | ||||||
| 	this.shortcutFocus = this.getAttribute("focus"); | 	this.shortcutFocus = this.getAttribute("focus"); | ||||||
|  | 	this.isDisabled = this.getAttribute("disabled", "no"); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| /* | /* | ||||||
| @@ -138,7 +142,7 @@ Selectively refreshes the widget if needed. Returns true if the widget needed re | |||||||
| */ | */ | ||||||
| EditShortcutWidget.prototype.refresh = function(changedTiddlers) { | EditShortcutWidget.prototype.refresh = function(changedTiddlers) { | ||||||
| 	var changedAttributes = this.computeAttributes(); | 	var changedAttributes = this.computeAttributes(); | ||||||
| 	if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes.placeholder || changedAttributes["default"] || changedAttributes["class"] || changedAttributes.style || changedAttributes.tooltip || changedAttributes["aria-label"] || changedAttributes.focus) { | 	if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes.placeholder || changedAttributes["default"] || changedAttributes["class"] || changedAttributes.style || changedAttributes.tooltip || changedAttributes["aria-label"] || changedAttributes.focus || changedAttributes.disabled) { | ||||||
| 		this.refreshSelf(); | 		this.refreshSelf(); | ||||||
| 		return true; | 		return true; | ||||||
| 	} else if(changedTiddlers[this.shortcutTiddler]) { | 	} else if(changedTiddlers[this.shortcutTiddler]) { | ||||||
|   | |||||||
| @@ -53,6 +53,9 @@ SelectWidget.prototype.render = function(parent,nextSibling) { | |||||||
| 	if(this.selectMultiple) { | 	if(this.selectMultiple) { | ||||||
| 		domNode.setAttribute("multiple","multiple"); | 		domNode.setAttribute("multiple","multiple"); | ||||||
| 	} | 	} | ||||||
|  | 	if(this.isDisabled === "yes") { | ||||||
|  | 		domNode.setAttribute("disabled", true); | ||||||
|  | 	} | ||||||
| 	if(this.selectSize) { | 	if(this.selectSize) { | ||||||
| 		domNode.setAttribute("size",this.selectSize); | 		domNode.setAttribute("size",this.selectSize); | ||||||
| 	} | 	} | ||||||
| @@ -172,6 +175,7 @@ SelectWidget.prototype.execute = function() { | |||||||
| 	this.selectTabindex = this.getAttribute("tabindex"); | 	this.selectTabindex = this.getAttribute("tabindex"); | ||||||
| 	this.selectTooltip = this.getAttribute("tooltip"); | 	this.selectTooltip = this.getAttribute("tooltip"); | ||||||
| 	this.selectFocus = this.getAttribute("focus"); | 	this.selectFocus = this.getAttribute("focus"); | ||||||
|  | 	this.isDisabled = this.getAttribute("disabled","no"); | ||||||
| 	// Make the child widgets | 	// Make the child widgets | ||||||
| 	this.makeChildWidgets(); | 	this.makeChildWidgets(); | ||||||
| }; | }; | ||||||
| @@ -182,7 +186,7 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of | |||||||
| SelectWidget.prototype.refresh = function(changedTiddlers) { | SelectWidget.prototype.refresh = function(changedTiddlers) { | ||||||
| 	var changedAttributes = this.computeAttributes(); | 	var changedAttributes = this.computeAttributes(); | ||||||
| 	// If we're using a different tiddler/field/index then completely refresh ourselves | 	// If we're using a different tiddler/field/index then completely refresh ourselves | ||||||
| 	if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes.tooltip || changedAttributes.tabindex) { | 	if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes.tooltip || changedAttributes.tabindex || changedAttributes.disabled) { | ||||||
| 		this.refreshSelf(); | 		this.refreshSelf(); | ||||||
| 		return true; | 		return true; | ||||||
| 	} else { | 	} else { | ||||||
|   | |||||||
| @@ -20,6 +20,7 @@ The content of the <<.wid BrowseWidget>> widget is ignored. | |||||||
| |accept |<<.from-version "5.1.23">> Optional comma delimited [[list of file accepted extensions|https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#Unique_file_type_specifiers]] and/or MIME types | | |accept |<<.from-version "5.1.23">> Optional comma delimited [[list of file accepted extensions|https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#Unique_file_type_specifiers]] and/or MIME types | | ||||||
| |message |Optional override of widget message to be generated. The files will be passed in the JavaScript object `event.target.files` | | |message |Optional override of widget message to be generated. The files will be passed in the JavaScript object `event.target.files` | | ||||||
| |param |Optional parameter to be passed with the custom message | | |param |Optional parameter to be passed with the custom message | | ||||||
|  | |disabled |<<.from-version "5.3.7">> Optional. Set to "yes" to disable file browser. Defaults to "no". | | ||||||
| |data-* |<<.from-version "5.3.2">> Optional [[data attributes|https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes]] to be assigned to the HTML element | | |data-* |<<.from-version "5.3.2">> Optional [[data attributes|https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes]] to be assigned to the HTML element | | ||||||
| |style.* |<<.from-version "5.3.2">> Optional [[CSS properties|https://developer.mozilla.org/en-US/docs/Web/CSS/Reference]] to be assigned to the HTML element | | |style.* |<<.from-version "5.3.2">> Optional [[CSS properties|https://developer.mozilla.org/en-US/docs/Web/CSS/Reference]] to be assigned to the HTML element | | ||||||
|  |  | ||||||
|   | |||||||
| @@ -42,6 +42,7 @@ The content of the `<$select>` widget should be one or more HTML `<option>` or ` | |||||||
| |actions |A string containing ActionWidgets to be triggered when the key combination is detected | | |actions |A string containing ActionWidgets to be triggered when the key combination is detected | | ||||||
| |focus |<<.from-version "5.2.4">> Optional. Set to "yes" to automatically focus the HTML select element after creation | | |focus |<<.from-version "5.2.4">> Optional. Set to "yes" to automatically focus the HTML select element after creation | | ||||||
| |tabindex |<<.from-version "5.3.1">> Optional. Sets the `tabindex` attribute of the HTML select element to the given value | | |tabindex |<<.from-version "5.3.1">> Optional. Sets the `tabindex` attribute of the HTML select element to the given value | | ||||||
|  | |disabled |<<.from-version "5.3.7">> Optional. Set to "yes" to disable select input. Defaults to "no". | | ||||||
| |data-* |<<.from-version "5.3.2">> Optional [[data attributes|https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes]] to be assigned to the HTML element | | |data-* |<<.from-version "5.3.2">> Optional [[data attributes|https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes]] to be assigned to the HTML element | | ||||||
| |style.* |<<.from-version "5.3.2">> Optional [[CSS properties|https://developer.mozilla.org/en-US/docs/Web/CSS/Reference]] to be assigned to the HTML element | | |style.* |<<.from-version "5.3.2">> Optional [[CSS properties|https://developer.mozilla.org/en-US/docs/Web/CSS/Reference]] to be assigned to the HTML element | | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Leilei332
					Leilei332