Commit 78b21abe authored by Nicolas Dumazet's avatar Nicolas Dumazet

completely inhibit selects when on readonly mode: listing the values is possible,

but when selecting a value, the previous value is restored and the save is not
visible


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36132 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent beb41c86
......@@ -158,6 +158,14 @@ function GetElementsWithClassName(elementName,className) {
function normalEvent() { return true; }
function ignoreEvent() { return false; }
var last_selected;
function registerSelection() {
last_selected = this.selectedIndex;
}
function dontChangeSelection() {
this.selectedIndex = last_selected;
}
var class_deletaged_list = GetElementsWithClassName('td','delegated');
for(var i=0; i<class_deletaged_list.length; i++) {
var disable_children = class_deletaged_list[i].childNodes;
......@@ -169,6 +177,9 @@ for(var i=0; i<class_deletaged_list.length; i++) {
element.readOnly = true;
if (element.type == 'checkbox'){
element.onclick = ignoreEvent;
} else if (element.tagName == 'SELECT') {
element.onfocus = registerSelection;
element.onchange = dontChangeSelection;
}
}
}
......@@ -190,12 +201,17 @@ function toggleFieldState(evt) {
field.readOnly = false;
if (field.type == 'checkbox'){
field.onclick = normalEvent;
} else if (field.tagName == 'SELECT') {
field.onchange = normalEvent;
}
}
else{
field.readOnly = true;
if (field.type == 'checkbox'){
field.onclick = ignoreEvent;
} else if (field.tagName == 'SELECT') {
field.onfocus = registerSelection;
field.onchange = dontChangeSelection;
}
}
}
......
......@@ -158,6 +158,14 @@ function GetElementsWithClassName(elementName,className) {
function normalEvent() { return true; }
function ignoreEvent() { return false; }
var last_selected;
function registerSelection() {
last_selected = this.selectedIndex;
}
function dontChangeSelection() {
this.selectedIndex = last_selected;
}
var class_deletaged_list = GetElementsWithClassName('td','delegated');
for(var i=0; i<class_deletaged_list.length; i++) {
var disable_children = class_deletaged_list[i].childNodes;
......@@ -169,6 +177,9 @@ for(var i=0; i<class_deletaged_list.length; i++) {
element.readOnly = true;
if (element.type == 'checkbox'){
element.onclick = ignoreEvent;
} else if (element.tagName == 'SELECT') {
element.onfocus = registerSelection;
element.onchange = dontChangeSelection;
}
}
}
......@@ -190,12 +201,17 @@ function toggleFieldState(evt) {
field.readOnly = false;
if (field.type == 'checkbox'){
field.onclick = normalEvent;
} else if (field.tagName == 'SELECT') {
field.onchange = normalEvent;
}
}
else{
field.readOnly = true;
if (field.type == 'checkbox'){
field.onclick = ignoreEvent;
} else if (field.tagName == 'SELECT') {
field.onfocus = registerSelection;
field.onchange = dontChangeSelection;
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment