Skip to content

Commit

Permalink
Item2463: with the first setup (no LocalSite.cfg) the user should jus…
Browse files Browse the repository at this point in the history
…t go on and save the precalculated settings, so the Save button should not be disabled;

but in any case do not disable the Save button, the user might have reloaded the page (and would get stuck then);
use css selector to focus password field;
improve readability of some Webserver data (cookies and CGI user);
in Other Extensions, do not assume we know the user did not make any changes, otherwise show red alert

git-svn-id: http://svn.foswiki.org/trunk@5731 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
ArthurClemens authored and ArthurClemens committed Dec 5, 2009
1 parent 02a9856 commit c1709c0
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 53 deletions.
17 changes: 9 additions & 8 deletions core/lib/Foswiki/Configure/UIs/CGISetup.pm
Expand Up @@ -19,13 +19,12 @@ sub renderHtml {
my $num = 0;
for my $key ( sort keys %ENV ) {
my $value = $ENV{$key};
my $limit = 70;
if ( length $value > $limit ) {
my $partFirst = substr( $value, 0, $limit );
my $partLast = substr( $value, $limit );
my $id = "configureEllipsis_$num";
$value = $partFirst
. "<span class='configureEllipsis foswikiMakeVisible'><span class='configureEllipsisDots'>... </span><a href='#$id'>more</a></span><span class='foswikiMakeHidden' id='$id'>$partLast</span>";
if ($key eq 'HTTP_COOKIE') {

# url decode for readability
$value =~ s/%7C/ | /go;
$value =~ s/%3D/=/go;
$value .= $this->NOTE('Cookie string decoded for readability.');
}
$contents .= $this->setting( $key, $value );
$num++;
Expand Down Expand Up @@ -221,12 +220,14 @@ HERE
}
$contents .= $this->setting( 'mod_perl', $n );

my $groups = $::WebServer_gid;
$groups =~ s/,/, /go; # improve readability with linebreaks
$contents .= $this->setting(
'CGI user',
'userid = <strong>'
. $::WebServer_uid
. '</strong> groups = <strong>'
. $::WebServer_gid
. $groups
. '</strong>'
. $this->NOTE('Your CGI scripts are executing as this user.')
);
Expand Down
1 change: 0 additions & 1 deletion core/lib/Foswiki/Configure/resources/pattern.css
Expand Up @@ -223,7 +223,6 @@ a.foswikiButton,a.foswikiButton:hover,a.foswikiButton:link:active,a.foswikiButto
margin:1em 0;
}
.foswikiNotification,
.foswikiAlert,
.foswikiNotification h2,
.foswikiNotification h3 {
color:#000;
Expand Down
87 changes: 52 additions & 35 deletions core/lib/Foswiki/Configure/resources/scripts.js
Expand Up @@ -517,8 +517,56 @@ function toggleInfo(inId) {
}

/* SELECTORS */
var enableWhenSomethingChangedElements = new Array();
var showWhenNothingChangedElements = new Array();

/* Value changes. Event when a value is edited; enables the save changes
* button */
var somethingChanged = false;
function valueChanged(el) {
foswiki.CSS.addClass(el, 'foswikiValueChanged');

var els; // shorthand
els = showWhenNothingChangedElements;
if (els) {
for (var i in els) {
foswiki.CSS.addClass(els[i], 'foswikiHidden');
}
}
els = enableWhenSomethingChangedElements;
if (els) {
var controlTypes = [ 'Submit', 'Button', 'InputField' ];
for (var i in els) {
foswiki.CSS.removeClass(els[i], 'foswikiHidden');
for (var j in controlTypes) {
var ct = 'foswiki' + controlTypes[j];
if (foswiki.CSS.hasClass(els[i], ct + 'Disabled')) {
foswiki.CSS.removeClass(els[i], ct + 'Disabled');
foswiki.CSS.addClass(els[i], ct);
}
}
els[i].disabled = false;
}
}
somethingChanged = true;
}

var rules = {
'.enableWhenSomethingChanged' : function(el) {
enableWhenSomethingChangedElements.push(el);
if (el.tagName.toLowerCase() == 'input') {
// disable the Save Changes button until a change has been made
// we won't use this until an AJAX call has been implemented to make // this fault proof
// el.disabled = 'disabled';
// foswiki.CSS.addClass(el, 'foswikiSubmitDisabled');
// foswiki.CSS.removeClass(el, 'foswikiSubmit');
} else {
foswiki.CSS.addClass(el, 'foswikiHidden');
}
},
'.showWhenNothingChanged' : function(el) {
showWhenNothingChangedElements.push(el);
},
'.tabli a' : function(el) {
var sectionParts = getSectionParts(el.hash);
var id = sectionParts.main;
Expand Down Expand Up @@ -591,44 +639,13 @@ var rules = {
}
return true;
}
},
'input.foswikiFocus':function(el) {
el.focus();
}
};
Behaviour.register(rules);

/* Value changes. Event when a value is edited; enables the save changes
* button */
var somethingChanged = false;
function valueChanged(el) {
foswiki.CSS.addClass(el, 'foswikiValueChanged');
if (!somethingChanged) {
var els = getElementsByClassName(document, 'showWhenNothingChanged');
for (var i in els) {
foswiki.CSS.addClass(els[i], 'foswikiHidden');
}
els = getElementsByClassName(document, 'enableWhenSomethingChanged');
var controlTypes = [ 'Submit', 'Button', 'InputField' ];
for (var i in els) {
foswiki.CSS.removeClass(els[i], 'foswikiHidden');
for (var j in controlTypes) {
var ct = 'foswiki' + controlTypes[j];
if (foswiki.CSS.hasClass(els[i], ct + 'Disabled')) {
foswiki.CSS.removeClass(els[i], ct + 'Disabled');
foswiki.CSS.addClass(els[i], ct);
}
}
els[i].disabled = false;
}
somethingChanged = true;
}
}

function focusPassword() {
if (document.forms['update'].cfgAccess != null) {
document.forms['update'].cfgAccess.focus();
}
}

addLoadEvent(toggleExpertsMode);
addLoadEvent(toggleInfoMode);
addLoadEvent(initSection);
addLoadEvent(focusPassword);
addLoadEvent(initSection);
7 changes: 4 additions & 3 deletions core/lib/Foswiki/Configure/resources/styles.css
Expand Up @@ -247,13 +247,14 @@ table.configureSectionValues .foswikiTextarea {
color:#f60;
}

.configureRootSection .foswikiAlert {
.configureRootSection div.foswikiAlert {
background-color:#fff;
color:#000;
border:1px solid #e6e6e6;
margin:.25em 0 .7em 0;
padding:7px 1em;
}
table.configureSectionValues .foswikiAlert {
table.configureSectionValues div.foswikiAlert {
padding-left:3em;
}
div.configureInfoText {
Expand Down Expand Up @@ -553,7 +554,7 @@ div.configureMessageBox {
vertical-align:middle;
background-color:#fff;
}
.configureMessageBox .foswikiAlert {
.configureMessageBox div.foswikiAlert {
margin:0;
padding-left:3em;
}
Expand Down
4 changes: 2 additions & 2 deletions core/lib/Foswiki/Configure/templates/authorize.tmpl
Expand Up @@ -52,7 +52,7 @@
<h2>In order to save your changes, Configure requires that you type your password.</h2>
</div>
<div class='foswikiFormStep'>
<p>Password: <input type="password" name='cfgAccess' size='30' maxlength='80' class='foswikiInputField' />
<p>Password: <input type="password" name='cfgAccess' size='30' maxlength='80' class='foswikiInputField foswikiFocus' />
&nbsp; <input type="submit" class='foswikiSubmit' value='Save changes' /></p>
</div>
<div class='foswikiFormStep configureFormStepOutside'>
Expand All @@ -75,7 +75,7 @@
</div>
<div class='foswikiFormStep'>
<p>Current password:<br />
<input type="password" name='cfgAccess' size='30' maxlength='80' class='foswikiInputField' /></p>
<input type="password" name='cfgAccess' size='30' maxlength='80' class='foswikiInputField foswikiFocus' /></p>
${localNotePasswordForgotten}
</div>
${localFormNewPassword}
Expand Down
Expand Up @@ -10,10 +10,11 @@

<#assign localOkMessage>
<div class='foswikiNotification enableWhenSomethingChanged foswikiHidden'>
<strong>You made some changes! Consider saving them first.</strong>
<span class="foswikiAlert"><strong>You made some changes! Consider saving them first.</strong></span>
Otherwise click to <a href='${scriptName}?action=FindMoreExtensions' class='foswikiButton'>Install and Update Extensions</a>
</div>
<div class='foswikiNotification showWhenNothingChanged'>
<strong>If you have made any changes, consider saving them first.</strong>
<a href='${scriptName}?action=FindMoreExtensions' class='foswikiButton'>Install and Update Extensions</a>
</div>
</#assign>
Expand Down
5 changes: 2 additions & 3 deletions core/lib/Foswiki/Configure/templates/main.tmpl
Expand Up @@ -12,8 +12,7 @@
<#if totalErrors??><span class='configureStatusErrors'>${totalErrors}</span></#if>
<#if totalWarnings??><span class='configureStatusWarnings'>${totalWarnings}</span></#if>

<#if firstTime == 1>(we will solve this in a minute)</#if>

<#if firstTime == 1>(we will solve this in a minute)</#if>
</div><!--/configureTools-->
</div>

Expand Down Expand Up @@ -42,7 +41,7 @@

<div id="ft">
<div class="configureActions">
<input type='submit' class='enableWhenSomethingChanged foswikiSubmitDisabled' disabled="disabled" name='action' value='Save changes' />
<input type='submit' class='enableWhenSomethingChanged foswikiSubmit' name='action' value='Save changes' />
</div>
</div>

Expand Down

0 comments on commit c1709c0

Please sign in to comment.