Skip to content

Commit

Permalink
Item14472: replaced use of attr()= with prop()
Browse files Browse the repository at this point in the history
fixed use of null value trying to trim values
  • Loading branch information
MichaelDaum committed Sep 13, 2017
1 parent 54b6d8e commit 5a62365
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 21 deletions.
3 changes: 2 additions & 1 deletion ConfigurePlugin/data/System/ConfigurePlugin.txt
@@ -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"}%
Expand Down Expand Up @@ -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 |
Expand Down
4 changes: 2 additions & 2 deletions ConfigurePlugin/lib/Foswiki/Plugins/ConfigurePlugin.pm
Expand Up @@ -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;

Expand Down
Expand Up @@ -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");
Expand All @@ -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>")
Expand Down Expand Up @@ -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');
Expand Down
34 changes: 19 additions & 15 deletions ConfigurePlugin/pub/System/ConfigurePlugin/types.uncompressed.js
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
});
Expand Down Expand Up @@ -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 :-(
Expand Down Expand Up @@ -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;
}
});
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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") {
Expand All @@ -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);
}
Expand All @@ -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;
}
Expand Down

0 comments on commit 5a62365

Please sign in to comment.