From 501ad2798f7f6705ddad50a103058eff0cbd8391 Mon Sep 17 00:00:00 2001 From: Rizwan Date: Tue, 3 Apr 2018 00:09:59 +0530 Subject: [PATCH] Add ability to trigger actions on unchecking checkbox widget (#3182) * Add uncheck-actions to checkbox widget * Update checkbox.js * Docs for "uncheckactions" param of checkbox widget --- core/modules/widgets/checkbox.js | 6 +++++- editions/tw5.com/tiddlers/widgets/CheckboxWidget.tid | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/modules/widgets/checkbox.js b/core/modules/widgets/checkbox.js index 6ed7a7a5c..9fa1c4889 100644 --- a/core/modules/widgets/checkbox.js +++ b/core/modules/widgets/checkbox.js @@ -156,6 +156,9 @@ CheckboxWidget.prototype.handleChangeEvent = function(event) { if(this.checkboxActions) { this.invokeActionString(this.checkboxActions,this,event); } + if(this.checkboxUncheckActions && !checked) { + this.invokeActionString(this.checkboxUncheckActions,this,event); + } }; /* @@ -164,6 +167,7 @@ Compute the internal state of the widget CheckboxWidget.prototype.execute = function() { // Get the parameters from the attributes this.checkboxActions = this.getAttribute("actions"); + this.checkboxUncheckActions = this.getAttribute("uncheckactions"); this.checkboxTitle = this.getAttribute("tiddler",this.getVariable("currentTiddler")); this.checkboxTag = this.getAttribute("tag"); this.checkboxField = this.getAttribute("field"); @@ -197,4 +201,4 @@ CheckboxWidget.prototype.refresh = function(changedTiddlers) { exports.checkbox = CheckboxWidget; -})(); \ No newline at end of file +})(); diff --git a/editions/tw5.com/tiddlers/widgets/CheckboxWidget.tid b/editions/tw5.com/tiddlers/widgets/CheckboxWidget.tid index 5165bde90..60f1b389b 100644 --- a/editions/tw5.com/tiddlers/widgets/CheckboxWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/CheckboxWidget.tid @@ -26,7 +26,8 @@ The content of the `<$checkbox>` widget is displayed within an HTML `