Permalink
Browse files

Item14472: replaced use of attr()= with prop()

fixed use of null value trying to trim values
  • Loading branch information...
1 parent 54b6d8e commit 5a62365fb909135b3c6dbfa0d7406580b5841109 MichaelDaum committed Sep 5, 2017
@@ -1,4 +1,4 @@
-%META:TOPICINFO{author="ProjectContributor" date="1493947845" format="1.1" version="1"}%
+%META:TOPICINFO{author="ProjectContributor" date="1504609147" format="1.1" version="1"}%
%META:TOPICPARENT{name="Plugins"}%
---+!! Configure Plugin
%FORMFIELD{"Description"}%
@@ -42,6 +42,7 @@ The plugin uses the =JsonRpcContrib=, which must be installed.
---++ Change History
+| 05 Sep 2017: | (1.09) Foswikitask:Item14472: replaced use of =attr()= with =prop()= where needed; fixed use of =null= value trying to trim values |
| 04 Apr 2017: | (1.08) Foswikitask:Item13883: Updated base template to suggest solutions when configure shows base login page.<br/>\
Foswikitask:Item13339: Warning or errors icons in configure get stuck unless page is reloaded.<br/>\
Foswikitask:Item14366: Reorder initialization to allow local CGI::Carp |
@@ -31,8 +31,8 @@ package Foswiki::Plugins::ConfigurePlugin;
use strict;
use warnings;
-our $VERSION = '1.08';
-our $RELEASE = '04 Apr 2017';
+our $VERSION = '1.09';
+our $RELEASE = '05 Sep 2017';
our $SHORTDESCRIPTION = '=configure= interface using json-rpc';
our $NO_PREFS_IN_TOPIC = 1;
@@ -649,7 +649,7 @@ function _id_ify(id) {
$butt = $('<input type="checkbox" id="' + id + '">').appendTo($buttons);
$butt.click(function() {
if ( $(this).attr("checked") ) {
- $ui.removeAttr("disabled");
+ $ui.prop("disabled", false);
$node.removeClass("disabled");
} else {
$ui.attr("disabled", "disabled");
@@ -666,7 +666,7 @@ function _id_ify(id) {
$ui.attr("disabled", "disabled");
$node.addClass("disabled");
} else {
- $butt.attr("checked", "checked");
+ $butt.prop("checked", true);
}
$butt.appendTo($buttons);
$("<label for='"+id+"'> enable</label>")
@@ -895,7 +895,7 @@ if (0) {
add_dependency(
entry.ENABLE_IF, $node, function($n, tf) {
if (tf) {
- $n.find("input,textarea").removeAttr('disabled');
+ $n.find("input,textarea").prop('disabled', false);
} else {
$n.find("input,textarea")
.attr('disabled', 'disabled');
@@ -45,7 +45,7 @@ var Types = {};
this.useVal(val);
}
if (this.spec.SPELLCHECK) {
- this.$ui.attr('spellcheck', 'true');
+ this.$ui.prop('spellcheck', true);
}
if (typeof(change_handler) !== "undefined") {
this.$ui.change(change_handler);
@@ -133,7 +133,7 @@ var Types = {};
}
if (this.spec.current_value !== 0) {
- this.$ui.attr('checked', true);
+ this.$ui.prop('checked', true);
}
if (this.spec.extraClass) {
this.$ui.addClass(this.spec.extraClass);
@@ -165,15 +165,15 @@ var Types = {};
} else if ( val == '1') {
val = true;
}
- this.$ui.attr('checked', val );
+ this.$ui.prop('checked', val );
}
});
Types.PASSWORD = Types.STRING.extend({
createUI: function(change_handler) {
this._super(change_handler);
this.$ui.attr('type', 'password');
- this.$ui.attr('autocomplete', 'off');
+ this.$ui.prop('autocomplete', false);
return this.$ui;
}
});
@@ -252,8 +252,10 @@ var Types = {};
isDefault: function() {
// To do this comparison requires parsing and rewriting the perl to
// javascript. Not impossible, but tricky.
- var a = this.currentValue().trim(),
- b = this.spec['default'].trim(), av, bv;
+ var a = this.currentValue(),
+ b = this.spec['default'], av, bv;
+ a = (a == null) ? null : a.trim();
+ b = (b == null) ? null : b.trim();
try {
// See if they parse as JS - they probably will! If they don't,
// parse, fall back to a string comparison :-(
@@ -308,7 +310,7 @@ var Types = {};
Types.PATHINFO = Types.STRING.extend({
createUI: function(change_handler) {
this._super(change_handler);
- this.$ui.attr('readonly', 'readonly');
+ this.$ui.prop('readonly', true);
return this.$ui;
}
});
@@ -340,8 +342,8 @@ var Types = {};
Types.NULL = Types.BaseType.extend({
createUI: function(change_handler) {
this._super(change_handler);
- this.$ui.attr('readonly', 'readonly');
- this.$ui.attr('disabled', 'disabled');
+ this.$ui.prop('readonly', true);
+ this.$ui.prop('disabled', true);
this.$ui.attr('size', '1');
return this.$ui;
}
@@ -392,7 +394,7 @@ var Types = {};
this.$ui.change(change_handler);
}
if (this.spec.MULTIPLE) {
- this.$ui.attr('multiple', 'multiple');
+ this.$ui.prop('multiple', true);
}
if (typeof(this.spec.select_from) !== "undefined") {
@@ -401,7 +403,7 @@ var Types = {};
opt = this.spec.select_from[i];
$option = $('<option>' + opt + '</option>');
if (sel[opt]) {
- $option.attr('selected', 'selected');
+ $option.prop('selected', true);
}
this.$ui.append($option);
}
@@ -420,17 +422,19 @@ var Types = {};
this.$ui.find('option').each(function() {
var opt = sf[i++];
if (sel[opt]) {
- $(this).attr('selected', 'selected');
+ $(this).prop('selected', true);
} else {
- $(this).removeAttr('selected');
+ $(this).prop('selected', false);
}
});
}
},
isDefault: function() {
- var a = this.currentValue().trim(),
- b = this.spec['default'].trim();
+ var a = this.currentValue(),
+ b = this.spec['default'];
+ a = (a == null) ? null : a.trim();
+ b = (b == null) ? null : b.trim();
b = b.replace(/^\s*(["'])(.*?)\1\s*/, "$2");
return a === b;
}

0 comments on commit 5a62365

Please sign in to comment.