1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-27 03:57:21 +00:00

Adding comparative operators to reveal widget (#3157)

* Adding comparative operators to reveal widget 

>, <, >=, <=

* Adding documentation and formatting changes

* Bring Alphanumericals to the scope of comparison operation
This commit is contained in:
Rizwan 2018-03-22 22:21:02 +05:30 committed by Jeremy Ruston
parent f1b38c42f9
commit 033feda02d
2 changed files with 31 additions and 3 deletions

View File

@ -127,13 +127,36 @@ RevealWidget.prototype.readState = function() {
this.readMatchState(state);
this.isOpen = !this.isOpen;
break;
case "lt":
this.readMatchStatelt(state);
break;
case "gt":
this.readMatchStategt(state);
break;
case "lteq":
this.readMatchStategt(state);
this.isOpen = !this.isOpen;
break;
case "gteq":
this.readMatchStatelt(state);
this.isOpen = !this.isOpen;
break;
}
};
RevealWidget.prototype.readMatchState = function(state) {
this.isOpen = state === this.text;
RevealWidget.prototype.compareStateText = function(state) {
var result = state.localeCompare(this.text, undefined, {numeric: true, sensitivity: 'case'});
return result;
};
RevealWidget.prototype.readMatchState = function(state) {
this.isOpen = (this.compareStateText(state) == 0) ? true : false;
};
RevealWidget.prototype.readMatchStatelt = function(state) {
this.isOpen = (this.compareStateText(state) < 0) ? true : false;
};
RevealWidget.prototype.readMatchStategt = function(state) {
this.isOpen = (this.compareStateText(state) > 0) ? true : false;
};
RevealWidget.prototype.readPopupState = function(state) {
var popupLocationRegExp = /^\((-?[0-9\.E]+),(-?[0-9\.E]+),(-?[0-9\.E]+),(-?[0-9\.E]+)\)$/,
match = popupLocationRegExp.exec(state);

View File

@ -13,6 +13,11 @@ The reveal widget hides or shows its content depending upon the value of a [[sta
* type=''match'': the content is displayed if the state tiddler matches a specified value
* type=''nomatch'': the content is displayed if the state tiddler doesn't match a specified value
* type=''popup'': the content is displayed as a popup as described in the PopupMechanism
* type=''lt'': the content is displayed if the state tiddler has an integer with a value ''less than'' a specified value
* type=''gt'': the content is displayed if the state tiddler has an integer with a value ''greater than'' a specified value
* type=''lteq'': the content is displayed if the state tiddler has an integer with a value ''less than or equal to'' a specified value
* type=''gteq'': the content is displayed if the state tiddler has an integer with a value ''greater than or equal to'' a specified value
! Content and Attributes