2009-03-04 04:44:11 +01:00
|
|
|
|
2007-09-04 05:30:59 +02:00
|
|
|
|
|
|
|
Event.observe( window, 'load', function() {
|
2012-02-16 12:27:47 +01:00
|
|
|
if(document.getElementById('sitetree')){
|
|
|
|
if(typeof document.getElementById('sitetree').observeMethod != 'undefined') {
|
|
|
|
document.getElementById('sitetree').observeMethod( 'NodeClicked' , function() {
|
2008-02-25 03:10:37 +01:00
|
|
|
checkedListNameArray = null;
|
|
|
|
checkedArray = null;
|
|
|
|
} );
|
|
|
|
}
|
2007-09-27 22:48:28 +02:00
|
|
|
}
|
2007-09-04 05:30:59 +02:00
|
|
|
} );
|
|
|
|
|
|
|
|
RelationComplexTableField = Class.create();
|
2009-03-04 04:44:11 +01:00
|
|
|
RelationComplexTableField.prototype = {
|
2007-09-04 05:30:59 +02:00
|
|
|
initialize: function() {
|
2009-03-04 04:44:11 +01:00
|
|
|
var checkedListNameArray = null;
|
|
|
|
var checkedListEndName = 'CheckedList';
|
|
|
|
var checkedListField = 'selected';
|
|
|
|
var checkedArray = null;
|
2007-09-04 05:30:59 +02:00
|
|
|
|
|
|
|
// 1) Find The Hidden Field Where The IDs Will Be Stored
|
|
|
|
|
|
|
|
var checkedList = document.getElementById( this.id + '_' + checkedListEndName );
|
|
|
|
|
|
|
|
// 2) Initialize The Array Or Update The Hidden Input Field And The HTML Table
|
|
|
|
|
|
|
|
var checkedListName = checkedList.getAttribute( 'name' );
|
2008-02-25 03:10:37 +01:00
|
|
|
//if( checkedListNameArray == null ) {
|
2007-09-04 05:30:59 +02:00
|
|
|
checkedListNameArray = [];
|
|
|
|
checkedListNameArray.push( checkedListName );
|
2009-06-18 01:14:40 +02:00
|
|
|
checkedArray = [];
|
2007-09-04 05:30:59 +02:00
|
|
|
if( checkedList.getAttribute( 'value' ) )
|
|
|
|
checkedArray.push( checkedList.getAttribute( 'value' ).split( ',' ) );
|
2008-02-25 03:10:37 +01:00
|
|
|
//}
|
|
|
|
/*
|
2007-09-04 05:30:59 +02:00
|
|
|
else if( checkedListNameArray.indexOf( checkedListName ) < 0 ) {
|
2009-06-18 01:14:40 +02:00
|
|
|
checkedListNameArray.push( checkedListName );
|
2007-09-04 05:30:59 +02:00
|
|
|
if( checkedList.getAttribute( 'value' ) )
|
2009-06-18 01:14:40 +02:00
|
|
|
checkedArray[ checkedListNameArray.length - 1 ] = checkedList.getAttribute( 'value' ).split( ',' );
|
2007-09-04 05:30:59 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
var index = checkedListNameArray.indexOf( checkedListName );
|
|
|
|
|
|
|
|
// a) Update The Hidden Input Field
|
|
|
|
|
|
|
|
checkedList.setAttribute( 'value', checkedArray[ index ] );
|
|
|
|
|
|
|
|
// b) Update The HTML Table
|
|
|
|
|
|
|
|
markingInputs = document.getElementsByName( checkedListName.substring( 0, checkedListName.indexOf( '[' ) ) + '[]' );
|
|
|
|
|
|
|
|
for( var i = 0; i < markingInputs.length; i++ ) {
|
|
|
|
markingInput = markingInputs[ i ];
|
|
|
|
if( checkedArray[ index ] && checkedArray[ index ].indexOf( markingInput.getAttribute( 'value' ) ) > -1 ) {
|
|
|
|
markingInput.setAttribute( 'checked', 'checked' );}
|
|
|
|
else
|
2009-06-18 01:14:40 +02:00
|
|
|
markingInput.removeAttribute( 'checked' );
|
2007-09-04 05:30:59 +02:00
|
|
|
}
|
2008-02-25 03:10:37 +01:00
|
|
|
} */
|
2007-09-04 05:30:59 +02:00
|
|
|
|
|
|
|
// 3) Create The Rules
|
|
|
|
|
|
|
|
var rules = {};
|
|
|
|
|
|
|
|
rules[ '#' + this.id + ' table.data tbody td.markingcheckbox input' ] = {
|
|
|
|
onclick : function() {
|
|
|
|
|
|
|
|
// 1) Find The Hidden Field Where The IDs Will Be Stored
|
|
|
|
|
|
|
|
var checkedListName = this.getAttribute( 'name' );
|
|
|
|
checkedListName = checkedListName.substring( 0, checkedListName.length - 1 ) + checkedListField + ']';
|
|
|
|
var inputs = document.getElementsByTagName( 'input' );
|
|
|
|
for( var i = 0; i < inputs.length; i++ ) {
|
|
|
|
var checkedList = inputs[ i ];
|
|
|
|
if( checkedList.getAttribute( 'name' ) == checkedListName )
|
2009-06-18 01:14:40 +02:00
|
|
|
break;
|
2007-09-04 05:30:59 +02:00
|
|
|
}
|
|
|
|
var index = checkedListNameArray.indexOf( checkedListName );
|
|
|
|
|
|
|
|
// 2) Update The Array
|
|
|
|
|
|
|
|
if( checkedArray[ index ] && checkedArray[ index ].indexOf( this.getAttribute( 'value' ) ) > -1 ) {
|
|
|
|
index2 = checkedArray[ index ].indexOf( this.getAttribute( 'value' ) );
|
|
|
|
var previousCheckedArray = checkedArray[ index ];
|
|
|
|
checkedArray[ index ] = [];
|
|
|
|
for( var i = 0; i < previousCheckedArray.length; i++ ) {
|
|
|
|
if( i != index2 )
|
|
|
|
checkedArray[ index ].push( previousCheckedArray[ i ] );
|
|
|
|
}
|
|
|
|
if( this.getAttribute( 'type' ) == 'radio' )
|
|
|
|
this.checked = false;
|
|
|
|
}
|
|
|
|
else if( checkedArray[ index ] ) {
|
|
|
|
if( this.getAttribute( 'type' ) == 'radio' )
|
|
|
|
checkedArray[ index ] = [];
|
|
|
|
checkedArray[ index ].push( this.getAttribute( 'value' ) );
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
checkedArray[ index ] = [];
|
|
|
|
checkedArray[ index ].push( this.getAttribute( 'value' ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// 3) Update The Hidden Input Field
|
|
|
|
|
2009-06-18 01:14:40 +02:00
|
|
|
checkedList.setAttribute( 'value', checkedArray[ index ] );
|
|
|
|
}
|
2007-09-04 05:30:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
Behaviour.register( rules );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RelationComplexTableField.applyTo('#Form_EditForm div.HasOneComplexTableField');
|
|
|
|
RelationComplexTableField.applyTo('#Form_EditForm div.HasManyComplexTableField');
|
2008-02-25 03:10:37 +01:00
|
|
|
RelationComplexTableField.applyTo('#Form_EditForm div.ManyManyComplexTableField');
|