Add ignore-case flag to Switch regex rule

closes #366
This commit is contained in:
Nick O'Leary
2015-10-04 22:14:49 +01:00
parent c1e8370916
commit 8b2b1669b5
4 changed files with 96 additions and 59 deletions

View File

@@ -82,6 +82,9 @@
{v:"else",t:this._("switch.rules.else")}
];
var andLabel = this._("switch.and");
var caseLabel = this._("switch.ignorecase");
function resizeRule(rule,width) {
var selectField = rule.find("select");
var type = selectField.children("option:selected").val();
@@ -99,8 +102,9 @@
selectField.width(selectWidth);
if (type === "btwn") {
btwnField1.width((width-288)/2);
btwnField2.width((width-288)/2);
var labelWidth = rule.find(".node-input-tule-btwn-label").width();
btwnField1.width((width-256-labelWidth)/2);
btwnField2.width((width-256-labelWidth)/2);
} else {
if (type === "true" || type === "false" || type === "null" || type === "nnull" || type === "else") {
// valueField.hide();
@@ -113,7 +117,7 @@
function generateRule(i,rule) {
var container = $('<li/>',{style:"background: #fff; margin:0; padding:8px 0px; border-bottom: 1px solid #ccc;"});
var row = $('<div/>').appendTo(container);
var row2 = $('<div/>',{style:"padding-top: 5px; text-align: right;"}).appendTo(container);
var row2 = $('<div/>',{style:"padding-top: 5px; padding-left: 175px;"}).appendTo(container);
$('<i style="color: #eee; cursor: move;" class="node-input-rule-handle fa fa-bars"></i>').appendTo(row);
var selectField = $('<select/>',{style:"width:120px; margin-left: 5px; text-align: center;"}).appendTo(row);
@@ -124,7 +128,7 @@
var valueField = $('<input/>',{class:"node-input-rule-value",type:"text",style:"margin-left: 5px; width: 145px;"}).appendTo(row);
var btwnField = $('<span/>').appendTo(row);
var btwnValueField = $('<input/>',{class:"node-input-rule-btwn-value",type:"text",style:"margin-left: 5px; width: 50px;"}).appendTo(btwnField);
btwnField.append(" and ");
var btwnAndLabel = $('<span/>',{class:"node-input-tule-btwn-label"}).text(" "+andLabel+" ").appendTo(btwnField);
var btwnValue2Field = $('<input/>',{class:"node-input-rule-btwn-value2",type:"text",style:"width: 50px;margin-left:2px;"}).appendTo(btwnField);
var finalspan = $('<span/>',{style:"float: right;margin-right: 10px;"}).appendTo(row);
@@ -133,6 +137,8 @@
var deleteButton = $('<a/>',{href:"#",class:"editor-button editor-button-small", style:"margin-top: 7px; margin-left: 5px;"}).appendTo(finalspan);
$('<i/>',{class:"fa fa-remove"}).appendTo(deleteButton);
var caseSensitive = $('<input/>',{id:"node-input-rule-case-"+i,class:"node-input-rule-case",type:"checkbox",style:"width:auto;vertical-align:top"}).appendTo(row2);
$('<label/>',{for:"node-input-rule-case-"+i,style:"margin-left: 3px;"}).text(caseLabel).appendTo(row2);
selectField.change(function() {
var width = $("#node-input-rule-container").width();
resizeRule(container,width);
@@ -149,6 +155,11 @@
valueField.show();
}
}
if (type === "regex") {
row2.show();
} else {
row2.hide();
}
});
deleteButton.click(function() {
@@ -171,6 +182,11 @@
} else if (typeof rule.v != "undefined") {
valueField.val(rule.v);
}
if (rule.case) {
caseSensitive.prop('checked',true);
} else {
caseSensitive.prop('checked',false);
}
selectField.change();
}
@@ -245,6 +261,9 @@
} else {
r.v = rule.find(".node-input-rule-value").val();
}
if (type === "regex") {
r.case = rule.find(".node-input-rule-case").prop("checked");
}
}
node.rules.push(r);
});